Tool calling

NOXERY API

Tool calling

Des guides courts et directs pour utiliser l'API compatible OpenAI dans vos applications et vos agents.

Araç akışı

Model önce hangi aracı çağıracağına karar verir, sen aracı çalıştırıp sonucu dönersin, model son yanıtı üretir. Üç adım da ayrı HTTP isteğidir.

1. Araç tanımıyla istek

json
{
  "model": "gpt-6-astra",
  "messages": [{"role": "user", "content": "İstanbul'da hava nasıl?"}],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Şehir için güncel hava durumu",
        "parameters": {
          "type": "object",
          "properties": {"city": {"type": "string"}},
          "required": ["city"]
        }
      }
    }
  ],
  "tool_choice": "auto"
}

2. Model araç çağrısı döner

json
{
  "role": "assistant",
  "content": null,
  "tool_calls": [
    {
      "id": "call_abc123",
      "type": "function",
      "function": {"name": "get_weather", "arguments": "{\"city\":\"İstanbul\"}"}
    }
  ]
}

3. Sonucu gönder, yanıtı al

json
{
  "model": "gpt-6-astra",
  "messages": [
    {"role": "user", "content": "İstanbul'da hava nasıl?"},
    {"role": "assistant", "content": null, "tool_calls": [
      {"id": "call_abc123", "type": "function",
       "function": {"name": "get_weather", "arguments": "{\"city\":\"İstanbul\"}"}}
    ]},
    {"role": "tool", "tool_call_id": "call_abc123", "content": "{\"temp\": 18, \"desc\": \"parçalı bulutlu\"}"}
  ]
}

Assistant mesajındaki tool_calls ile tool sonucu birebir eşleşmelidir (tool_call_id aynı olmalı). Eksik taraf upstream'de reddedilebilir. Responses API kullanıyorsan aynı akış function_call ve function_call_output öğeleriyle kurulur.