Tool calling
Let the model call functions you define — OpenAI-compatible tools.
Pass a tools array; the model returns tool_calls when it decides to use one. tool_choice supports "auto" (default), "none", or a named function.
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": "Weather in Astana? Use the tool."}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather for a city",
"parameters": {
"type": "object",
"properties": { "city": { "type": "string" } },
"required": ["city"]
}
}
}]
}'
# response: choices[0].message.tool_calls[0].functionSmall models call tools less reliably than large ones — validate arguments server-side and design for retries.