Skip to main content

Tool Calling

This page only documents Tool Calling flows that were verified with real requests against Crazyrouter production. Verification date:
  • 2026-03-22
Verified models:
  • gpt-5.4
  • claude-sonnet-4-6
  • gemini-3-pro-preview

Verified matrix

ModelProtocolEndpointSuccess marker
gpt-5.4OpenAI Chat CompletionsPOST /v1/chat/completionsReturns tool_calls
claude-sonnet-4-6Anthropic MessagesPOST /v1/messagesReturns tool_use block
gemini-3-pro-previewGemini NativePOST /v1beta/models/{model}:generateContentReturns functionCall

GPT-5.4

curl https://crazyrouter.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "gpt-5.4",
    "messages": [
      {
        "role": "user",
        "content": "Use the get_time tool for Asia/Shanghai. Do not answer without calling the tool."
      }
    ],
    "tools": [
      {
        "type": "function",
        "function": {
          "name": "get_time",
          "description": "Get the current time for a timezone",
          "parameters": {
            "type": "object",
            "properties": {
              "timezone": { "type": "string" }
            },
            "required": ["timezone"],
            "additionalProperties": false
          }
        }
      }
    ],
    "tool_choice": "required"
  }'
Verified response shape:
{
  "tool_calls": [
    {
      "type": "function",
      "function": {
        "name": "get_time"
      }
    }
  ]
}

Claude Sonnet 4.6

curl https://crazyrouter.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 256,
    "tools": [
      {
        "name": "get_time",
        "description": "Get the current time for a timezone",
        "input_schema": {
          "type": "object",
          "properties": {
            "timezone": { "type": "string" }
          },
          "required": ["timezone"]
        }
      }
    ],
    "tool_choice": {
      "type": "any"
    },
    "messages": [
      {
        "role": "user",
        "content": "Use the get_time tool for Asia/Shanghai. Do not answer directly."
      }
    ]
  }'
Verified response shape:
{
  "stop_reason": "tool_use",
  "content": [
    {
      "type": "tool_use",
      "name": "get_time"
    }
  ]
}
For first-pass validation, use an explicit tool_choice and clearly instruct Claude not to answer directly.

Gemini 3 Pro Preview

curl "https://crazyrouter.com/v1beta/models/gemini-3-pro-preview:generateContent?key=YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [
          {
            "text": "Use the get_time function for Asia/Shanghai."
          }
        ]
      }
    ],
    "tools": [
      {
        "functionDeclarations": [
          {
            "name": "get_time",
            "description": "Get the current time for a timezone",
            "parameters": {
              "type": "object",
              "properties": {
                "timezone": { "type": "string" }
              },
              "required": ["timezone"]
            }
          }
        ]
      }
    ]
  }'
Verified response shape:
{
  "candidates": [
    {
      "content": {
        "parts": [
          {
            "functionCall": {
              "name": "get_time"
            }
          }
        ]
      }
    }
  ]
}

See Also