Alət axını
Model əvvəlcə hansı aləti çağıracağına qərar verir, siz aləti işlədib nəticəni qaytarırsınız, model son cavabı yaradır. Üç addım da ayrı HTTP sorğusudur.
1. Alət tərifi ilə sorğu
json
{
"model": "gemini-3.8-flash",
"messages": [{"role": "user", "content": "İstanbulda hava necədir?"}],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Şəhər üçün güncel hava durumu",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]
}
}
}
],
"tool_choice": "auto"
}2. Model alət çağırışı qaytarır
json
{
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_abc123",
"type": "function",
"function": {"name": "get_weather", "arguments": "{\"city\":\"Istanbul\"}"}
}
]
}3. Nəticəni göndərin, cavabı alın
json
{
"model": "gemini-3.8-flash",
"messages": [
{"role": "user", "content": "İstanbulda hava necədir?"},
{"role": "assistant", "content": null, "tool_calls": [
{"id": "call_abc123", "type": "function",
"function": {"name": "get_weather", "arguments": "{\"city\":\"Istanbul\"}"}}
]},
{"role": "tool", "tool_call_id": "call_abc123", "content": "{\"temp\": 18, \"desc\": \"buludlu\"}"}
]
}Assistant mesajındakı tool_calls ilə tool nəticəsi birebir eşləşməlidir (tool_call_id eyni olmalıdır). Əskik tərəf upstream-də rədd edilə bilər. Responses API işlədirsinizsə eyni axın function_call və function_call_output elementləri ilə qurulur.