Вызов инструментов
Модель может вызывать ваши функции — совместимо с tools из OpenAI API.
Передайте массив tools — модель вернёт tool_calls, когда решит использовать инструмент. tool_choice поддерживает "auto" (по умолчанию), "none" или имя конкретной функции.
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].functionНебольшие модели вызывают инструменты менее надёжно — валидируйте аргументы на сервере и закладывайте повторы.