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:

curl https://api.roteo.ai/v1/chat/completions \
-H "Authorization: Bearer $ROTEO_API_KEY" \
-H "content-type: application/json" \
-d '{
  "model": "gpt-6.1-sol",
  "tools": [{
    "type": "function",
    "function": {
      "name": "get_weather",
      "description": "Get the current weather for a city.",
      "parameters": {
        "type": "object",
        "properties": { "city": { "type": "string" } },
        "required": ["city"]
      }
    }
  }],
  "messages": [{ "role": "user", "content": "What is the weather in Tokyo?" }]
}'

The same request works for Claude, GPT and open-weight models.

The loop

  1. The model answers with finish_reason: "tool_calls" and a tool_calls list naming the function and its JSON arguments.
  2. You run the function and send the result back as a message with role: "tool" and the matching tool_call_id.
  3. 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.

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.

Tool use | Roteo