Core concepts
Tool use
Let models call your functions and act on the results.
Every text model supports tools. You describe your functions, the model decides when to call one and with what arguments, you run it, and you send the result back.
Define tools
Pass a tools array on a Chat Completions request, in the OpenAI function format. Each tool has a name, a description and a JSON Schema for its arguments:
The same request works for Claude, GPT and open-weight models.
The loop
- The model answers with
finish_reason: "tool_calls"and atool_callslist naming the function and its JSON arguments. - You run the function and send the result back as a message with
role: "tool"and the matchingtool_call_id. - The model uses the result to write its answer.
Set tool_choice to "required" to force a tool call, name a specific function, or leave it on "auto", the default.
Web search
In Claude Code, on the Messages API, models can also use a built-in web search tool: the model searches server-side and answers with citations. Each search is billed on top of the token cost, and max_uses caps how many a turn can run.