> This page is for Model APIs.

> Sarvam Voice Agents (Samvaad) is a voice AI agent platform for Indian languages: build, test and deploy AI calling agents on your own phone numbers, from ₹3 a minute. Start here: https://docs.sarvam.ai/voice-agents/why-voice-agents.
> For clean Markdown of any page, append `.md` to the page URL.
> For a complete documentation index, see https://docs.sarvam.ai/llms.txt. For a section index, append `/llms.txt` to any section URL (for example https://docs.sarvam.ai/voice-agents/llms.txt).
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.sarvam.ai/_mcp/server.

# Clef

> Clef is a 27B multimodal decision model. Send a state, optional images, and typed questions to POST /v2/systemone and get a calibrated probability for every option. Available on Provisioned Throughput.

Clef is a 27B open-weight **decision model**. Like [Sarvam Prism](/api/token-factory/models/sarvam-prism),
it answers typed questions about an input on the [Decisions API](/api/token-factory/decisions-api):
you send a **state** and a map of **questions**, and it returns a probability for every option of
every question in one pass. It generates no text, so there is nothing to parse.

Unlike Sarvam Prism, Clef also reads **images**, and it takes up to 65,536 tokens per request.

> **Note**
>
> Clef is available on **Provisioned Throughput**: capacity is set up for your workload and enabled for your organisation. Without access, requests return `404 not_found_error` and the model isn't listed in [`GET /v2/models`](/api-reference/chat/models-v2). [Contact us](/api/getting-started/help) to request access. See [Provisioned Throughput](/api/token-factory/models#provisioned-throughput).

## At a glance

|                   |                                                                                                                                                           |
| ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Model ID**      | `clef`                                                                                                                                                    |
| **What it does**  | Answers yes/no (`noul`), pick-one (`choice`) and ordered-scale (`score`) questions about your input, with a probability for every option                  |
| **API**           | [Decisions API](/api/token-factory/decisions-api) (`POST /v2/systemone`, [reference](/api-reference/decisions/systemone)), synchronous JSON, no streaming |
| **Input**         | Text, or any JSON object or array (rendered as JSON), plus optional base64 images                                                                         |
| **Input limits**  | 65,536 tokens per request (state, all questions and options, and images), 1–255 options per `choice`, 1–10 levels per `score`. [Details](#limits)         |
| **Output**        | Probabilities that sum to 1 for each question, plus the top option, a confidence value, and (for `score`) a legend                                        |
| **Repeatability** | The same request returns the same probabilities                                                                                                           |
| **Pricing**       | ₹20 per 1M input tokens; no output tokens are billed ([Pricing](/api/getting-started/pricing)). Check `usage.input_tokens` for the exact count            |

## Quickstart

#### Python

```python
from sarvamai import SarvamAI

client = SarvamAI(api_subscription_key="YOUR_SARVAM_API_KEY")

response = client.decisions.create(
    model="clef",
    state="My Stripe integration stopped working and all checkout payments are failing.",
    questions={
        "urgent": {
            "type": "noul",
            "instructions": "Is this urgent and revenue-impacting?",
        },
        "department": {
            "type": "choice",
            "instructions": "Which team should handle this?",
            "criteria": {
                "billing": "Payments or invoices",
                "technical": "Bugs or outages",
                "sales": "New business enquiries",
            },
        },
        "severity": {
            "type": "score",
            "instructions": "Rate the severity.",
            "criteria": ["trivial", "minor", "moderate", "major", "critical"],
        },
    },
)

answers = response.answers
if answers["urgent"].noul > 0.5:
    print("Escalate to", answers["department"].choice)
```

#### cURL

```bash
curl -X POST https://api.sarvam.ai/v2/systemone \
  -H "api-subscription-key: $SARVAM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "clef",
    "state": "My Stripe integration stopped working and all checkout payments are failing.",
    "questions": {
      "urgent": {"type": "noul", "instructions": "Is this urgent and revenue-impacting?"},
      "department": {
        "type": "choice",
        "instructions": "Which team should handle this?",
        "criteria": {
          "billing": "Payments or invoices",
          "technical": "Bugs or outages",
          "sales": "New business enquiries"
        }
      },
      "severity": {
        "type": "score",
        "instructions": "Rate the severity.",
        "criteria": ["trivial", "minor", "moderate", "major", "critical"]
      }
    }
  }'
```

Response:

```json
{
  "model": "clef",
  "answers": {
    "urgent": {"type": "noul", "noul": 0.9926},
    "department": {
      "type": "choice",
      "choice": "billing",
      "confidence": 0.3099,
      "probabilities": {"billing": 0.5400, "technical": 0.4476, "sales": 0.0124}
    },
    "severity": {
      "type": "score",
      "score": 3.8746,
      "confidence": 0.8955,
      "legend": {"0": "trivial", "1": "minor", "2": "moderate", "3": "major", "4": "critical"},
      "probabilities": {"0": 0.0071, "1": 0.0068, "2": 0.0089, "3": 0.0587, "4": 0.9184}
    }
  },
  "usage": {"input_tokens": 357, "output_tokens": 0}
}
```

Probabilities are rounded here; the API returns full floats. For what each field means, see
[Read the answers](/api/token-factory/decisions-api#read-the-answers).

## Questions about images

Send images in `images`, as base64 data URIs. The questions are answered about the state and the
images together. Remote `http(s)` image URLs return `400`.

The `sarvamai` SDK's `decisions.create` doesn't have an `images` argument yet, so pass the images as an
extra body field:

```python
import base64

with open("receipt.jpg", "rb") as f:
    image = "data:image/jpeg;base64," + base64.b64encode(f.read()).decode()

response = client.decisions.create(
    model="clef",
    state="Review the attached receipt.",
    questions={"legible": {"type": "noul", "instructions": "Is the receipt total legible?"}},
    request_options={"additional_body_parameters": {"images": [image]}},
)
print(response.answers["legible"].noul)
```

In the JavaScript SDK, put `images` directly in the request object: `client.decisions.create({ model: "clef", state, questions, images: [image] })`. Its `requestOptions` can't add body fields.

Over HTTP, send `images` in the request body:

```json
{
  "model": "clef",
  "state": "Review the attached receipt.",
  "images": ["data:image/jpeg;base64,/9j/4AAQ..."],
  "questions": {
    "legible": {"type": "noul", "instructions": "Is the receipt total legible?"}
  }
}
```

## Question rules

The question types are the same as on Sarvam Prism ([Question types](/api/token-factory/decisions-api#question-types)),
with these rules on Clef:

| `type`   | `criteria`                                             | Rules                                                                          |
| -------- | ------------------------------------------------------ | ------------------------------------------------------------------------------ |
| `noul`   | Optional `{"true": "...", "false": "..."}`             | Needs `instructions`, or at least one of `criteria.true` and `criteria.false`. |
| `choice` | Required object `{option_id: description or null}`     | 1–255 options.                                                                 |
| `score`  | Required **array** of level descriptions, lowest first | 1–10 levels, numbered from 0. An object returns `422`.                         |

* Always send `instructions` (or `noul` criteria). The question ID is not used as the question.
* Any key in a question other than `type`, `instructions`, and `criteria` returns `422`, including
  misspellings such as `instruction`.
* `temperature` returns `422`. `max_tokens` and `stream` are accepted and ignored: Clef always answers in one
  JSON response.
* `chat_template_kwargs` must be empty or absent; a non-empty value returns `400`.
* `videos` and other unknown top-level fields are ignored.

## Limits

* **65,536 tokens per request**, counting the state, every question and its options, and images.
  The state is counted once, however many questions you ask.
* **The state is never truncated.** A request over the limit fails with `400 invalid_request_error`,
  and the message gives the count, such as "the prompt needs 70141 tokens (70001 for the state), but
  holds at most 65536". Shorten the state, or split a long document across requests.
* Ask several questions about the same state in one request: they are answered together, in one
  pass.

## Differences from Sarvam Prism

|                  | Clef                                           | Sarvam Prism                                |
| ---------------- | ---------------------------------------------- | ------------------------------------------- |
| Images           | Supported (`images`, base64)                   | Not supported                               |
| Token limit      | 65,536 per request                             | 32,768 per question                         |
| Over-long state  | Rejected with `400`                            | Rejected with `422`                         |
| `choice` options | 1–255                                          | 2–255                                       |
| `score` levels   | 1–10, array only                               | 2–10                                        |
| Repeatability    | Identical probabilities for identical requests | Can vary slightly; the top answer is stable |
| Access           | Provisioned Throughput                         | Serverless                                  |

## Errors

| Status                           | When                                                                                                                                                                        | Recommended action                                         |
| -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- |
| `404 not_found_error`            | Your organisation does not have Provisioned Throughput for Clef                                                                                                             | [Contact us](/api/getting-started/help) to request access. |
| `400 invalid_request_error`      | The prompt is over 65,536 tokens, an image is a remote URL, or an image can't be read                                                                                       | Shorten the state, or send images as base64 data URIs.     |
| `400 invalid_request_error`      | Clef is called on another endpoint, such as `/v2/chat/completions` ("served only on /v2/systemone")                                                                         | Send decisions to `POST /v2/systemone`.                    |
| `422 unprocessable_entity_error` | Missing `state` or `questions`, empty `questions`, unknown `type`, unknown key in a question, too many options or levels, a `noul` with nothing to decide, or `temperature` | Fix the request. `param` names the field at fault.         |
| `403 invalid_api_key_error`      | API key is missing or invalid                                                                                                                                               | Check the `api-subscription-key` header.                   |
| `429 rate_limit_exceeded_error`  | Request or concurrency limit is exceeded                                                                                                                                    | Back off and retry.                                        |
| `5xx`                            | Server or capacity error                                                                                                                                                    | Retry with backoff.                                        |

Every error carries `message`, `code`, and `request_id`; validation errors also carry `param`.