April 10, 20264 min readGuide

Function calling and tools across GPT, Claude and Gemini

Function calling is what turns a chat model into an agent. Instead of answering in prose, the model emits a structured request — "call get_weather with { "city": "Berlin" }" — your code runs the function, returns the result, and the model continues. GPT, Claude and Gemini all support this, but the wire formats and behaviors differ enough to bite you when you switch providers.

The same idea, three dialects

All three follow the same loop: you describe tools with a JSON Schema, the model decides when to call one, you execute it, and you feed the result back. The differences are in the envelope.

Aspect GPT (OpenAI) Claude (Anthropic) Gemini (Google)
Tool definition tools[].function with JSON Schema tools[].input_schema functionDeclarations
Model's call tool_calls on the message tool_use content block functionCall part
Your result role: "tool" message tool_result content block functionResponse part
Forcing a call tool_choice tool_choice toolConfig mode
Parallel calls Yes Yes Yes

The conceptual model is identical; the field names, nesting, and how results are threaded back into the conversation are not. Porting a working GPT agent to native Gemini means rewriting your request and response parsing.

Behavioral quirks that matter

  • Parallel tool calls. GPT and Claude readily emit several tool calls in one turn (fetch weather and calendar at once). Your executor must handle a list, run them, and return all results before the model proceeds. Gemini supports this too, but models vary in how aggressively they batch.
  • Strict schemas. OpenAI's strict mode guarantees arguments match your schema exactly. Claude is generally faithful but does not enforce the same hard guarantee, so validate inputs before executing anything destructive.
  • Forcing vs. choosing. Need the model to always call a specific tool (e.g. structured extraction)? Each provider has a mechanism, but the syntax differs — tool_choice: { type: "function", function: { name } } on GPT vs. an equivalent object on Claude.
  • Reasoning + tools. Newer reasoning models interleave thinking and tool calls. Test this explicitly; latency and token usage shift noticeably.

The practical takeaway: don't assume a prompt that produces clean tool calls on one model behaves the same on another. You need to compare them on your schemas and your prompts.

One endpoint, one schema, every model

This is where most of the friction disappears. AnyModel exposes a single OpenAI-compatible endpoint, so you write tools in the OpenAI tools format once and reach GPT, Claude, Gemini, plus DeepSeek, GLM, Kimi, Qwen and Grok. Switching models is just changing the model id — your tool definitions, tool_calls parsing, and result-passing code stay the same.

curl https://anymodel.org/v1/chat/completions \
  -H "Authorization: Bearer $ANYMODEL_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4.5",
    "messages": [{"role": "user", "content": "Weather in Berlin?"}],
    "tools": [{"type": "function", "function": {
      "name": "get_weather",
      "parameters": {"type": "object", "properties": {"city": {"type": "string"}}}
    }}]
  }'

Change "model" to gpt-5 or gemini-2.5-pro and rerun — same payload. That makes it trivial to benchmark which model calls your tools most reliably, then compare cost and latency before you commit.

Plug into your agent stack

Already using a CLI agent? One line wires it up:

bash <(curl -fsSL "https://anymodel.org/i?tool=codex") <YOUR_API_KEY>

Use tool=claude for Claude Code (also opencode, hermes). For Cursor, Windsurf, Zed, Cline, Aider, Continue or Gemini CLI, point a manual OpenAI-compatible config at https://anymodel.org/v1 with your key.

Build privately, pay per token

There's no subscription and no credit card to start: you get 1,000,000 free tokens on signup, and 6,000,000 total if you link Telegram. After that it's pay-per-token with no minimums. For sensitive tool inputs, opt into Ghost Mode — zero-retention keys where we keep only a token counter and don't store prompts or responses (the model provider still receives the prompt, so this isn't absolute privacy, but nothing is retained on our side).

Want more agent and tool-calling guides? Browse the blog.

Ready to test function calling across GPT, Claude and Gemini with one key? Create your free account and switch models by changing a single string.

Read next