Structured outputs
Force responses into JSON or a JSON Schema with response_format.
Set response_format to {"type": "json_object"} for free-form JSON, or {"type": "json_schema", ...} to constrain output to a schema. Generation is grammar-constrained on the server, so the output always parses.
curl https://api.sara-ai.kz/v1/chat/completions \
-H "Authorization: Bearer $SARA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemma-4-31b",
"messages": [{"role": "user", "content": "Give me a city and its country."}],
"response_format": {"type": "json_schema", "json_schema": {
"name": "city",
"schema": {
"type": "object",
"properties": { "city": { "type": "string" }, "country": { "type": "string" } },
"required": ["city", "country"],
"additionalProperties": false
}
}}
}'