ApiX Docs
Docs / Tools
·View as Markdown

Tools

Standard OpenAI function calling: declare functions, read tool_calls, send the result back with role: "tool".

bash
curl "$APIX_BASE/v1/chat/completions" \
  -H "Authorization: Bearer $APIX_KEY" \
  -H "content-type: application/json" \
  -d '{
    "model": "2/kimi-k3",
    "messages": [{"role": "user", "content": "Weather in Caracas?"}],
    "tools": [{
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Current weather",
        "parameters": {
          "type": "object",
          "properties": {"city": {"type": "string"}},
          "required": ["city"]
        }
      }
    }]
  }'

The answer has finish_reason: "tool_calls" and:

json
{
  "tool_calls": [{
    "id": "call_1",
    "type": "function",
    "function": {"name": "get_weather", "arguments": "{\"city\":\"Caracas\"}"}
  }]
}

Send the result back and ask again:

json
{"role": "tool", "tool_call_id": "call_1", "content": "{\"temp_c\":27}"}

parallel_tool_calls: false forces one call at a time. In Anthropic clients this is tool_use and tool_result blocks; ApiX translates both ways.