Skip to main content

Overview

Tool calling (also called function calling) enables models to request execution of external functions. The model proposes tool calls; your application executes them and returns results to continue the conversation.

How It Works

  1. Model proposes tool call - Model identifies when a tool should be called
  2. Client executes tool - Your application runs the function locally
  3. Return results - Send tool output back in the conversation
  4. Model processes - Model uses results to generate final response

Request Format

Include tools array in your request:

Tool Definition Schema

Tool Choice

Control when tools are called:
  • "auto": Model decides (default)
  • "none": No tools called
  • "required": Model must call a tool
  • {type: "function", function: {name: string}}: Force specific function

Response Format

When a tool is called, the response includes tool_calls:

Executing Tools

Parse arguments (JSON string) and execute:

Returning Tool Results

Send results as a tool message:

Parallel Tool Calls

Enable multiple tool calls in one response:
Default: true. When enabled, model can call multiple tools simultaneously.

Multi-Turn Conversations

Maintain conversation history including all tool calls and results:

Supported Models

View Tool-Calling Models

For a complete list of models that support tool calling, visit anannas.ai/models and filter by capability.
Tool calling is supported on:
  • OpenAI: GPT-4, GPT-3.5 Turbo, GPT-5 Mini, o1, o3
  • Anthropic: Claude 3 Opus, Claude 3 Sonnet, Claude 3 Haiku, Claude Sonnet 4.5
  • Other providers: Check /v1/models for tool_calling capability

Best Practices

  1. Clear descriptions: Write detailed function descriptions
  2. Required fields: Specify required array for critical parameters
  3. Type constraints: Use enum for limited options
  4. Error handling: Handle invalid tool calls gracefully
  5. Conversation history: Include all tool calls and results in subsequent requests

Example: Complete Tool Calling Flow

See Also