Guides

Tool use

This is not available on this model yet. The model object's capabilities.tools turns true when it is.

What it is for

Antarya cannot look up your calendar or open your database. With tools, you describe a function; when she needs it, the reply contains a request to call it. You run the function and send the result back, and she finishes the answer.

The loop

  1. Send the question with tools, a list of functions you describe.
  2. If the reply has a tool_call part, run that function with its input.
  3. Send the conversation again, with the reply added and a tool message holding the result.
  4. Repeat until stop_reason is end_turn.
curl https://antarya.ai/v1/chat \
  -H "Authorization: Bearer $ANTARYA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      {"role": "user", "content": "Draft a reply that declines the meeting."}
    ],
    "tools": [
      {
        "name": "get_free_slots",
        "description": "Return the free calendar slots for a given week.",
        "input_schema": {
          "type": "object",
          "properties": {"week": {"type": "string"}},
          "required": ["week"]
        }
      }
    ],
    "tool_choice": {"type": "auto"}
  }'
Output
{
  "id": "req_06",
  "content": [
    {"type": "tool_call", "id": "call_01", "name": "get_free_slots", "input": {"week": "next"}}
  ],
  "stop_reason": "tool_call",
  "usage": {"input_tokens": 88, "output_tokens": 21}
}

The output shows the first reply, the one that asks for the function. After you send the result, the next reply has stop_reason of end_turn and holds the answer as text.

Parameters

NameTypeRequiredDescription
toolsarrayNoThe functions she may ask you to call.
nametextYesRequiredA short name for the function.
descriptiontextYesRequiredWhat the function does and when to use it. She reads this to decide.
input_schemaobjectYesRequiredA JSON schema for the function's input.
tool_choiceobjectNoHow freely she may use tools. `auto` lets her decide and is the default, `none` stops her using tools, `any` makes her use one, and {"type": "tool", "name": "..."} makes her use that tool.

Next steps