Guides · Tool calling

Tool calling.

Every model in the catalog calls tools, in both dialects, with strict schema-faithful arguments — the property agent loops live and die on. The loop is the same everywhere: define, receive a call, execute, return the result.

1 · Define tools

{
  "model": "lx1-gpt-oss-120b",
  "messages": [{ "role": "user", "content": "Weather in Paris?" }],
  "tools": [{
    "type": "function",
    "function": {
      "name": "get_weather",
      "description": "Current weather for a city",
      "parameters": {
        "type": "object",
        "properties": { "city": { "type": "string" } },
        "required": ["city"]
      }
    }
  }]
}
The same tool in both dialects

2 · The model calls

When the model decides to use a tool, the response carries a call instead of (or alongside) text:

{
  "message": {
    "role": "assistant",
    "tool_calls": [{
      "id": "call_abc123",
      "type": "function",
      "function": { "name": "get_weather", "arguments": "{\"city\": \"Paris\"}" }
    }]
  },
  "finish_reason": "tool_calls"
}
Chat Completions — finish_reason: tool_calls
{
  "content": [{
    "type": "tool_use",
    "id": "toolu_abc123",
    "name": "get_weather",
    "input": { "city": "Paris" }
  }],
  "stop_reason": "tool_use"
}
Messages — stop_reason: tool_use

Arguments conform to your schema — parse them, run the tool, and send the result back. Models may emit several calls in one turn (parallel tool use); execute them all and return one result per call id.

3 · Return results

{
  "role": "tool",
  "tool_call_id": "call_abc123",
  "content": "{\"temp_c\": 18, \"sky\": \"clear\"}"
}
Append to messages, then call again

Append the result to the conversation and call the endpoint again — the model continues with the tool output in context. Repeat until it answers in text.

Steering with tool_choice

  • auto (default) — the model decides whether to call.
  • required / { "type": "any" } — must call some tool (Chat Completions / Messages respectively).
  • Named — force one specific tool: { "type": "function", "function": { "name": "get_weather" } } or { "type": "tool", "name": "get_weather" }.
  • none — text only, tools stay visible but uncallable.
Note

Tool calls stream too: argument deltas arrive incrementally on both dialects (Streaming). For extracting structured data without any real tool, prefer Structured output.