Skip to navigation

Clef

View as Markdown

Clef is a 27B open-weight decision model. Like Sarvam Prism, it answers typed questions about an input on the 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.

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. Contact us to request access. See Provisioned Throughput.

At a glance

Model IDclef
What it doesAnswers yes/no (noul), pick-one (choice) and ordered-scale (score) questions about your input, with a probability for every option
APIDecisions API (POST /v2/systemone, reference), synchronous JSON, no streaming
InputText, or any JSON object or array (rendered as JSON), plus optional base64 images
Input limits65,536 tokens per request (state, all questions and options, and images), 1–255 options per choice, 1–10 levels per score. Details
OutputProbabilities that sum to 1 for each question, plus the top option, a confidence value, and (for score) a legend
RepeatabilityThe same request returns the same probabilities
Pricing₹20 per 1M input tokens; no output tokens are billed (Pricing). Check usage.input_tokens for the exact count

Quickstart

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)

Response:

{
"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.

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:

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:

{
"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), with these rules on Clef:

typecriteriaRules
noulOptional {"true": "...", "false": "..."}Needs instructions, or at least one of criteria.true and criteria.false.
choiceRequired object {option_id: description or null}1–255 options.
scoreRequired array of level descriptions, lowest first1–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

ClefSarvam Prism
ImagesSupported (images, base64)Not supported
Token limit65,536 per request32,768 per question
Over-long stateRejected with 400Rejected with 422
choice options1–2552–255
score levels1–10, array only2–10
RepeatabilityIdentical probabilities for identical requestsCan vary slightly; the top answer is stable
AccessProvisioned ThroughputServerless

Errors

StatusWhenRecommended action
404 not_found_errorYour organisation does not have Provisioned Throughput for ClefContact us to request access.
400 invalid_request_errorThe prompt is over 65,536 tokens, an image is a remote URL, or an image can’t be readShorten the state, or send images as base64 data URIs.
400 invalid_request_errorClef is called on another endpoint, such as /v2/chat/completions (“served only on /v2/systemone”)Send decisions to POST /v2/systemone.
422 unprocessable_entity_errorMissing state or questions, empty questions, unknown type, unknown key in a question, too many options or levels, a noul with nothing to decide, or temperatureFix the request. param names the field at fault.
403 invalid_api_key_errorAPI key is missing or invalidCheck the api-subscription-key header.
429 rate_limit_exceeded_errorRequest or concurrency limit is exceededBack off and retry.
5xxServer or capacity errorRetry with backoff.

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