Skip to content
API referenceClient tools (functions)

Client tools (functions)

Claude selects a function; your code executes it.

Model protocol

Claude client functions use the tool_usetool_result loop with and without a server prompt. Your client executes the function. Formats and restrictions depend on the selected API.

json
{
  "model": "claude-opus-5",
  "max_tokens": 1024,
  "tools": [{
    "name": "get_weather",
    "description": "Weather by city",
    "input_schema": {
      "type": "object",
      "properties": {"city": {"type": "string"}},
      "required": ["city"]
    }
  }],
  "messages": [{"role": "user", "content": "What's the weather in Moscow?"}]
}

The response includes a tool_use block with the tool name and arguments — run it on your side and return the result as a tool_result block.

json
{
  "role": "user",
  "content": [{
    "type": "tool_result",
    "tool_use_id": "toolu_…",
    "content": "Moscow: 18 °C, clear"
  }]
}

Kimi, Composer and Grok

FamilyClient tools
KimiAvailable in Messages, Chat Completions and Responses; tool and selection formats depend on the API
ComposerAvailable on all three surfaces; the client executes the tool. Only automatic tool_choice is supported
GrokAvailable on all three surfaces; the client executes the tool. Only automatic tool_choice is supported

Kimi: what is checked locally

  • tools must be an array of objects, a function must have a name, names must be unique.
  • The argument schema is checked for up to 32 levels of depth, 4096 nodes and 256 KiB in canonical form. Going over returns a local 400 before any charge.
  • On kimi-for-coding and kimi-for-coding-highspeed the value tool_choice: "required" is not supported and is rejected locally. On k3 and k3-256k it passes.

Composer and Grok: what a call looks like

The loop works on all three surfaces in their own format. The model returns a call; the client executes the tool and returns its result in the same conversation. Until the result arrives, the request remains unfinished.

SurfaceWhat arrives instead of an answerWhat you answer with
/v1/messagestool_use blocks in content and stop_reason: "tool_use"a tool_result block with the same tool_use_id
/v1/chat/completionschoices[0].message.tool_calls and finish_reason: "tool_calls"a message with role tool and a tool_call_id
/v1/responsesa type: "function_call" item in output with a call_ida function_call_output item with the same call_id

Our own ceilings

An unfinished tool loop has a result-wait limit and a total duration limit. Complete calls in the same conversation and account for the limits below.

LimitValueWhat happens past it
Answering a tool call120 seconds from the moment you received the turn with the callthe run is closed and the part of it already spent is charged. Coming back later starts the conversation from scratch, and you pay for the input a second time
Length of one run600 seconds504 cursor_run_timeout, or an error event with the same code in a stream. The run is charged
Unfinished conversations per keyConcurrent loops waiting for tool results are limited per key429 cursor_key_pause_limit before money is reserved, so the refusal is free. Finish or drop one conversation to start the next

Documentation sections

On this page