Құрылымды шығыс
response_format арқылы жауапты JSON немесе JSON Schema түрінде алыңыз.
Еркін JSON үшін response_format {"type": "json_object"}, схемаға сай шығыс үшін {"type": "json_schema", ...} қойыңыз. Генерация серверде грамматикамен шектеледі, сондықтан шығыс әрқашан парсталады.
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
}
}}
}'