如何安装(2/3)

Index of all LiteLLM docs: https://docs.litellm.ai/llms.txt

Use service_tier: "priority" for Fast mode or service_tier: "ultrafast" for Ultrafast on GPT-6 Astra. You can set the tier as a deployment default in the Admin UI or config.yaml, or choose it per request. The examples below use the Responses API.

The walkthrough creates gpt-6-astra-ultrafast for Astra Ultrafast, with a Fast alternative named gpt-6.1-sol-fast. These gateway aliases are names you choose; the service_tier parameter selects the processing mode.

Supported models and availability

Fast mode

OpenAI renamed Priority processing to Fast mode. Both service_tier: "priority" and service_tier: "fast" select it. This guide uses priority, which also keeps Codex's /fast command.

The following models were verified with completed Responses API calls through LiteLLM on October 6, 2026. Each returned a Fast processing tier:

OpenAI model ID LiteLLM upstream model Returned service_tier
gpt-6-astra openai/gpt-6-astra fast
gpt-6.1-sol openai/gpt-6.1-sol fast
gpt-6-sol openai/gpt-6-sol fast
gpt-6-luna openai/gpt-6-luna fast
gpt-5.6-sol openai/gpt-5.6-sol priority
gpt-5.6-terra openai/gpt-5.6-terra priority
gpt-5.6-luna openai/gpt-5.6-luna priority

These are the current models tested for this guide, not an exhaustive list. See OpenAI's Fast pricing table for additional supported models. Fast mode also supports Chat Completions. It is unavailable with EU data residency for the GPT-6 models above; check OpenAI's regional requirements.

Ultrafast mode

Use GPT-6 Astra (openai/gpt-6-astra) with service_tier: "ultrafast". A completed Responses API call through LiteLLM returned service_tier: "ultrafast" in testing. The Ultrafast setup in this guide uses Astra only.

OpenAI makes Astra Ultrafast available to all API users with low initial rate limits. Use the Responses API over HTTP or WebSocket. Ultrafast supports US data residency and global processing only; EU and other non-US regional processing endpoints are not supported. See OpenAI's Ultrafast guide for current availability and limits.

Your OpenAI account must support the selected tier for the model. Adding a tier to LiteLLM's catalog does not enable it at OpenAI, and Fast mode support does not imply Ultrafast support.

Before you start

Use a recent LiteLLM release with Responses API support, an OpenAI API credential with access to the selected model and available credits, and permission to add models to your gateway. The UI walkthrough below was captured on LiteLLM v1.105.0. For a new gateway, follow the Admin UI quickstart first.

Both modes cost more than Standard. Check OpenAI's Fast pricing and Ultrafast pricing. For LiteLLM spend tracking, confirm that your model's cost-map entry has the applicable *_priority rates for Fast or *_ultrafast rates for Ultrafast, including input, output, caching, and long-context rates. If pricing is missing or differs from your agreement, configure custom pricing before relying on spend totals or budgets.

Set up in the Admin UI

1. Select the model and credentials

Open Models + Endpoints, then Add Model. Choose OpenAI as the provider and gpt-6-astra under LiteLLM Model Name(s). In Model Mappings, set Public Model Name to gpt-6-astra-ultrafast.

For Fast mode, select a model from the Fast table above, such as gpt-6.1-sol, and use a public name such as gpt-6.1-sol-fast. The model-selection screenshot shows Astra; the Fast settings are shown separately below.

Select your OpenAI credential under Existing Credentials, or enter your OpenAI API key in the provider credential fields. The screenshot uses an existing credential named openai; use your own credential's name.

Leave Mode blank for now. In v1.105.0, that dropdown does not include Responses; set it through Model Info in the next step.

[Image: Add Model with OpenAI, gpt-6-astra, the gpt-6-astra-ultrafast public name, and an existing credential]

2. Set the service tier

Expand Advanced Settings and choose the settings for your mode:

service_tier (singular) in LiteLLM Params selects the processing mode. service_tiers (plural) in Model Info is an optional list of modes advertised to clients such as Codex.

Ultrafast (Astra)

Enter this JSON in LiteLLM Params:

{
  "service_tier": "ultrafast"
}

Enter this JSON in Model Info:

{
  "mode": "responses",
  "service_tiers": ["priority", "ultrafast"]
}

[Image: Advanced Settings showing service_tier set to ultrafast and Model Info with responses mode and the advertised service tiers]

Fast

Enter this JSON in LiteLLM Params:

{
  "service_tier": "priority"
}

Enter this JSON in Model Info:

{
  "mode": "responses",
  "service_tiers": ["priority"]
}

[Image: Fast mode in Advanced Settings with service_tier set to priority and Model Info set to responses with only the priority tier]

mode: "responses" makes the connection test use the Responses endpoint.

3. Test and save

Click Test Connect. The test should send the selected upstream model and service_tier (priority for Fast, ultrafast for Astra Ultrafast) to OpenAI's /v1/responses endpoint. Resolve any credential, quota, or access errors shown by the test, then click Add Model to save.

Under Deployed Models, search for the public name you configured, open its model ID, and select Raw JSON. Confirm that litellm_params.service_tier matches your chosen tier and model_info.mode is "responses". Use a virtual key with access to this public model name for the requests below.

Set up with config.yaml

Add the following deployment to your gateway configuration as an alternative to adding it in the UI:

Ultrafast (GPT-6 Astra)

model_list:
  - model_name: gpt-6-astra-ultrafast
    litellm_params:
      model: openai/gpt-6-astra
      api_key: os.environ/OPENAI_API_KEY
      service_tier: ultrafast
    model_info:
      mode: responses
      service_tiers: ["priority", "ultrafast"]

Fast (GPT-6.1 Sol)

model_list:
  - model_name: gpt-6.1-sol-fast
    litellm_params:
      model: openai/gpt-6.1-sol
      api_key: os.environ/OPENAI_API_KEY
      service_tier: priority
    model_info:
      mode: responses
      service_tiers: ["priority"]

Set OPENAI_API_KEY in the gateway's environment and restart with the updated configuration. For a local proxy installation, start it with litellm --config config.yaml; see proxy configuration for deployment options.

The openai/ prefix selects the upstream provider. Clients call the selected deployment's public model_name, such as gpt-6-astra-ultrafast. Keep the provider key on the gateway; clients authenticate with their LiteLLM virtual keys.

Send a request through the gateway

The requests below use the Astra Ultrafast alias. For the Fast deployment, use model: "gpt-6.1-sol-fast" and service_tier: "priority" instead.

Set LITELLM_BASE_URL to your gateway URL without a trailing /v1, and LITELLM_API_KEY to a virtual key that can access the model:

export LITELLM_BASE_URL="http://localhost:4000"
export LITELLM_API_KEY="<your-litellm-virtual-key>"

curl

curl "${LITELLM_BASE_URL}/v1/responses" \
  -H "Authorization: Bearer ${LITELLM_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-6-astra-ultrafast",
    "service_tier": "ultrafast",
    "input": "Say hello in one sentence."
  }'

OpenAI Python SDK

Install or upgrade openai, then run:

import os
from openai import OpenAI

client = OpenAI(
    base_url=os.environ["LITELLM_BASE_URL"].rstrip("/") + "/v1",
    api_key=os.environ["LITELLM_API_KEY"],
)

response = client.responses.create(
    model="gpt-6-astra-ultrafast",
    service_tier="ultrafast",
    input="Say hello in one sentence.",
)

print(response.output_text)
print(response.service_tier)

Both examples explicitly request a tier. If the client omits service_tier, the deployment default above supplies it. An explicit tier in the request overrides that default. To choose Fast or Ultrafast only for selected calls, leave service_tier out of the deployment and send it on those calls.

Use the LiteLLM Python SDK directly

Without a gateway, set OPENAI_API_KEY in your application's environment and call the upstream model with litellm.responses():

import litellm

response = litellm.responses(
    model="openai/gpt-6-astra",
    service_tier="ultrafast",
    input="Say hello in one sentence.",
)

print(response)

For Fast mode, use model="openai/gpt-6.1-sol" and service_tier="priority", or another model from the Fast table above.

Offer /fast and /ultrafast in Codex

Use model_info.service_tiers: ["priority"] to offer /fast. For Astra, use ["priority", "ultrafast"] to offer both /fast and /ultrafast. Codex CLI 0.159 or newer also needs model_catalog_url pointed at your gateway's /v1/models endpoint and [features] api_key_model_discovery = true. Follow the Codex model catalog setup, select your gateway model, then choose a mode.

For a model where users toggle modes on and off, omit the deployment's litellm_params.service_tier and keep model_info.service_tiers. Otherwise, a client that stops sending a tier still inherits the deployment's default. Advertising a tier does not grant OpenAI access to it.

Verify and troubleshoot

Check the completed response's service_tier field to confirm the tier that served the request: fast or priority for Fast mode, and ultrafast for Ultrafast. OpenAI's Fast guide explains the returned tier names and when traffic ramp limits can downgrade a Fast request to default. For streaming, inspect the response on the response.completed event. A saved model name, a catalog entry, or an outgoing request alone does not confirm the served tier.

Symptom What to check
insufficient_quota or credit_balance_exhausted Check the OpenAI account's credits and billing. A LiteLLM virtual-key budget does not fund the upstream account.
Invalid service_tier argument, or the provider rejects the model or tier Check the supported models, account access, regional endpoint, and requested tier. Use Astra for the Ultrafast setup above. Model access alone does not guarantee access to every tier.
Fast or Ultrafast requests appear to cost the same as Standard Confirm the model's *_priority or *_ultrafast pricing fields, or configure custom pricing. Provider access and LiteLLM cost tracking are separate.
The request uses a different tier Inspect the client's service_tier; it overrides the deployment default. Confirm the selected alias routes to the intended deployment.
A Fast request returns service_tier: "default" OpenAI can downgrade requests when traffic ramps too quickly. Check the provider's ramp limits; HTTP 200 alone does not prove Fast processing.
Codex does not show /fast or /ultrafast Check both catalog settings and the model's service_tiers. If several deployments share an alias, configure the list on each. See the Codex guide for catalog caching and version requirements.

The examples use HTTP Responses requests. For repeated agent tool calls, OpenAI recommends a persistent WebSocket connection to reduce connection overhead; see LiteLLM's Responses WebSocket guide.



Index of all LiteLLM docs: https://docs.litellm.ai/llms.txt

This tutorial shows how to connect OpenCode to your existing LiteLLM instance and switch between models.

:::info

This integration allows you to use any LiteLLM supported model through OpenCode with centralized authentication, usage tracking, and cost controls.

:::

<br />

Video Walkthrough

<iframe width="840" height="500" src="https://www.loom.com/embed/00791498f1d84e4ba6d7476bd2e1442f" frameBorder="0" allowFullScreen></iframe>

Prerequisites

  • LiteLLM already configured and running (e.g., http://localhost:4000)
  • LiteLLM API key

Installation

Step 1: Install OpenCode

Choose your preferred installation method:

One-line install (recommended)

curl -fsSL https://opencode.ai/install | bash

NPM

npm install -g opencode-ai

Homebrew

brew install sst/tap/opencode

Verify installation:

opencode --version

Step 2: Configure LiteLLM Provider

Create your OpenCode configuration file. You can place this in different locations depending on your needs:

Configuration locations: - Global: ~/.config/opencode/opencode.json (applies to all projects) - Project: opencode.json in your project root (project-specific settings) - Custom: Set OPENCODE_CONFIG environment variable

Create ~/.config/opencode/opencode.json (global config):

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "litellm": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "LiteLLM",
      "options": {
        "baseURL": "http://localhost:4000/v1"
      },
      "models": {
        "gpt-5.6-terra": {
          "name": "GPT-5.6 Terra"
        },
        "claude-sonnet-5": {
          "name": "Claude Sonnet 5"
        },
        "deepseek-chat": {
          "name": "DeepSeek Chat"
        }
      }
    }
  }
}

:::tip The keys in the "models" object (e.g., "gpt-5.6-terra", "claude-sonnet-5") should match the model_name values from your LiteLLM configuration. The "name" field provides a friendly display name that will appear as an alias in OpenCode.

If a model accepts images, it also needs a modalities entry; see Enabling image and vision input. :::

Step 3: Connect to LiteLLM Provider

Launch OpenCode:

opencode

Add your API key:

/connect

Then: - Enter provider name: LiteLLM (must match the "name" field in your config) - Enter your LiteLLM API key: Your LiteLLM master key or virtual key

Step 4: Switch Between Models

In OpenCode, run:

/models

Select any model from your LiteLLM configuration. OpenCode will route all requests through your LiteLLM instance.

Advanced Configuration

Model Parameters

You can customize model parameters like context limits:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "litellm": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "LiteLLM",
      "options": {
        "baseURL": "http://localhost:4000/v1"
      },
      "models": {
        "gpt-5.6-terra": {
          "name": "GPT-5.6 Terra",
          "limit": {
            "context": 922000,
            "output": 128000
          }
        },
        "claude-sonnet-5": {
          "name": "Claude Sonnet 5",
          "limit": {
            "context": 1000000,
            "output": 128000
          }
        }
      }
    }
  }
}

Enabling image and vision input

OpenCode does not discover model capabilities from the /v1/models endpoint. The OpenAI model-listing schema has no field for modalities, so there is nothing for it to read. Models under a custom @ai-sdk/openai-compatible provider therefore fall back to text-only input.

The effect is client-side and silent: OpenCode checks the model's declared input modalities, sees no image, and strips image attachments out of the request before it is sent. LiteLLM never receives the image, and the model replies as though you had pasted nothing.

Declare modalities on every vision-capable model in your OpenCode config:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "litellm": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "LiteLLM",
      "options": {
        "baseURL": "http://localhost:4000/v1"
      },
      "models": {
        "claude-sonnet-5": {
          "name": "Claude Sonnet 5",
          "modalities": { "input": ["text", "image"], "output": ["text"] }
        },
        "gpt-5.6-terra": {
          "name": "GPT-5.6 Terra",
          "modalities": { "input": ["text", "image"], "output": ["text"] }
        },
        "deepseek-chat": {
          "name": "DeepSeek Chat"
        }
      }
    }
  }
}

Leave modalities off text-only models such as deepseek-chat; declaring image input for a model that cannot accept it moves the failure from the client to the provider.

:::warning Setting supports_vision: true under model_info in your LiteLLM config.yaml does not fix this. That flag drives LiteLLM's own routing and cost logic and is not exposed on /v1/models, and OpenCode would not read it if it were. modalities in the OpenCode config is the only place this can be declared. :::

Auto Router and other model groups

A model group is just another model name to OpenCode, so an Auto Router entry needs the same declaration even though the models behind it are vision-capable:

{
  "models": {
    "smart-router": {
      "name": "Smart Router",
      "modalities": { "input": ["text", "image"], "output": ["text"] }
    }
  }
}

Declare image input only when every tier the router can select accepts images. If one tier is text-only, an image-bearing request will fail once the router lands on that tier.

Multi-Provider Setup

You can configure multiple LiteLLM instances or mix with other providers:

Multiple LiteLLM Instances

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "litellm-prod": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "LiteLLM Production",
      "options": {
        "baseURL": "https://your-prod-instance.com/v1"
      },
      "models": {
        "gpt-5.6-terra": {
          "name": "GPT-5.6 Terra (Production)"
        }
      }
    },
    "litellm-dev": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "LiteLLM Development",
      "options": {
        "baseURL": "http://localhost:4000/v1"
      },
      "models": {
        "gpt-5.6-terra": {
          "name": "GPT-5.6 Terra (Development)"
        }
      }
    }
  }
}

Mixed Providers

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "litellm": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "LiteLLM",
      "options": {
        "baseURL": "http://localhost:4000/v1"
      },
      "models": {
        "gpt-5.6-terra": {
          "name": "GPT-5.6 Terra via LiteLLM"
        },
        "claude-sonnet-5": {
          "name": "Claude Sonnet 5 via LiteLLM"
        }
      }
    },
    "openai": {
      "npm": "@ai-sdk/openai",
      "name": "OpenAI Direct",
      "models": {
        "gpt-5.6-terra": {
          "name": "GPT-5.6 Terra (Direct)"
        }
      }
    }
  }
}

Example LiteLLM Configuration

Here's an example LiteLLM config.yaml that works well with OpenCode:

model_list:
  # OpenAI models
  - model_name: gpt-5.6-terra
    litellm_params:
      model: openai/gpt-5.6-terra
      api_key: os.environ/OPENAI_API_KEY

  - model_name: gpt-5.6-luna
    litellm_params:
      model: openai/gpt-5.6-luna
      api_key: os.environ/OPENAI_API_KEY

  # Anthropic models
  - model_name: claude-sonnet-5
    litellm_params:
      model: anthropic/claude-sonnet-5
      api_key: os.environ/ANTHROPIC_API_KEY

  # DeepSeek models
  - model_name: deepseek-chat
    litellm_params:
      model: deepseek/deepseek-chat
      api_key: os.environ/DEEPSEEK_API_KEY

Dropping OpenCode-specific parameters

OpenCode sends a reasoningSummary parameter with reasoning-capable models such as gpt-5.6-terra. This parameter is not supported by the Chat Completions API and will cause errors. Add additional_drop_params to every model entry in your model_list that will receive requests from OpenCode with reasoning enabled:

model_list:
  - model_name: gpt-5.6-terra
    litellm_params:
      model: openai/gpt-5.6-terra
      api_key: os.environ/OPENAI_API_KEY
      additional_drop_params: ["reasoningSummary"]

Troubleshooting

OpenCode not connecting: - Verify your LiteLLM proxy is running: curl http://localhost:4000/health - Check that the baseURL in your OpenCode config matches your LiteLLM instance - Ensure the provider name in /connect matches exactly with your config

Authentication errors: - Verify your LiteLLM API key is correct - Check that your LiteLLM instance has authentication properly configured - Ensure your API key has access to the models you're trying to use

Model not found: - Ensure the model names in OpenCode config match your LiteLLM model_name values - Check LiteLLM logs for detailed error messages - Verify the models are properly configured in your LiteLLM instance

Configuration not loading: - Check the config file path and permissions - Validate JSON syntax using a JSON validator - Ensure the $schema URL is accessible

Images and screenshots are ignored: - OpenCode defaults custom OpenAI-compatible provider models to text-only input and strips image attachments before sending, so the request reaching LiteLLM contains no image. Declare modalities on the model in your OpenCode config:

"claude-sonnet-5": {
  "name": "Claude Sonnet 5",
  "modalities": { "input": ["text", "image"], "output": ["text"] }
}

Unknown parameter: 'reasoningSummary' error: - OpenCode sends a reasoningSummary parameter that is not supported by the Chat Completions API. Add additional_drop_params: ["reasoningSummary"] to each affected model entry in your litellm_params:

- model_name: gpt-5.6-terra
  litellm_params:
    model: openai/gpt-5.6-terra
    api_key: os.environ/OPENAI_API_KEY
    additional_drop_params: ["reasoningSummary"]

Tips

  • Add more models to the config as needed - they'll appear in /models
  • Use project-specific configs for different codebases with different model requirements
  • Monitor your LiteLLM proxy logs to see OpenCode requests in real-time


Index of all LiteLLM docs: https://docs.litellm.ai/llms.txt

Provide concrete examples of valid tool inputs to help Claude understand how to use your tools more effectively. This is particularly useful for complex tools with nested objects, optional parameters, or format-sensitive inputs.

:::info Tool input examples is a beta feature. LiteLLM automatically detects tools with the input_examples field and adds the appropriate beta header based on your provider:

  • Anthropic API & Microsoft Foundry: advanced-tool-use-2025-11-20
  • Amazon Bedrock: advanced-tool-use-2025-11-20 (Claude Opus 4.5 only)
  • Google Cloud Vertex AI: Not supported

You don't need to manually specify beta headers; LiteLLM handles this automatically. :::

When to Use Input Examples

Input examples are most helpful for:

  • Complex nested objects: Tools with deeply nested parameter structures
  • Optional parameters: Showing when optional parameters should be included
  • Format-sensitive inputs: Demonstrating expected formats (dates, addresses, etc.)
  • Enum values: Illustrating valid enum choices in context
  • Edge cases: Showing how to handle special cases

:::tip Prioritize descriptions first! Clear, detailed tool descriptions are more important than examples. Use input_examples as a supplement for complex tools where descriptions alone may not be sufficient. :::

Quick Start

Add an input_examples field to your tool definition with an array of example input objects:

import litellm

response = litellm.completion(
    model="anthropic/claude-sonnet-5",
    messages=[
        {"role": "user", "content": "What's the weather like in San Francisco?"}
    ],
    tools=[
        {
            "type": "function",
            "function": {
                "name": "get_weather",
                "description": "Get the current weather in a given location",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "location": {
                            "type": "string",
                            "description": "The city and state, e.g. San Francisco, CA"
                        },
                        "unit": {
                            "type": "string",
                            "enum": ["celsius", "fahrenheit"],
                            "description": "The unit of temperature"
                        }
                    },
                    "required": ["location"]
                }
            },
            "input_examples": [
                {
                    "location": "San Francisco, CA",
                    "unit": "fahrenheit"
                },
                {
                    "location": "Tokyo, Japan",
                    "unit": "celsius"
                },
                {
                    "location": "New York, NY"  # 'unit' is optional
                }
            ]
        }
    ]
)

print(response)

How It Works

When you provide input_examples:

  1. LiteLLM detects the input_examples field in your tool definition
  2. Beta header added automatically: The advanced-tool-use-2025-11-20 header is injected
  3. Examples included in prompt: Anthropic includes the examples alongside your tool schema
  4. Claude learns patterns: The model uses examples to understand proper tool usage
  5. Better tool calls: Claude makes more accurate tool calls with correct parameter formats

Example Formats

Simple Tool with Examples

{
    "type": "function",
    "function": {
        "name": "send_email",
        "description": "Send an email to a recipient",
        "parameters": {
            "type": "object",
            "properties": {
                "to": {"type": "string", "description": "Email address"},
                "subject": {"type": "string"},
                "body": {"type": "string"}
            },
            "required": ["to", "subject", "body"]
        }
    },
    "input_examples": [
        {
            "to": "user@example.com",
            "subject": "Meeting Reminder",
            "body": "Don't forget our meeting tomorrow at 2 PM."
        },
        {
            "to": "team@company.com",
            "subject": "Weekly Update",
            "body": "Here's this week's progress report..."
        }
    ]
}

Complex Nested Objects

{
    "type": "function",
    "function": {
        "name": "create_calendar_event",
        "description": "Create a new calendar event",
        "parameters": {
            "type": "object",
            "properties": {
                "title": {"type": "string"},
                "start": {
                    "type": "object",
                    "properties": {
                        "date": {"type": "string"},
                        "time": {"type": "string"}
                    }
                },
                "attendees": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "email": {"type": "string"},
                            "optional": {"type": "boolean"}
                        }
                    }
                }
            },
            "required": ["title", "start"]
        }
    },
    "input_examples": [
        {
            "title": "Team Standup",
            "start": {
                "date": "2025-01-15",
                "time": "09:00"
            },
            "attendees": [
                {"email": "alice@example.com", "optional": False},
                {"email": "bob@example.com", "optional": True}
            ]
        },
        {
            "title": "Lunch Break",
            "start": {
                "date": "2025-01-15",
                "time": "12:00"
            }
            # No attendees - showing optional field
        }
    ]
}

Format-Sensitive Parameters

{
    "type": "function",
    "function": {
        "name": "search_flights",
        "description": "Search for available flights",
        "parameters": {
            "type": "object",
            "properties": {
                "origin": {"type": "string", "description": "Airport code"},
                "destination": {"type": "string", "description": "Airport code"},
                "date": {"type": "string", "description": "Date in YYYY-MM-DD format"},
                "passengers": {"type": "integer"}
            },
            "required": ["origin", "destination", "date"]
        }
    },
    "input_examples": [
        {
            "origin": "SFO",
            "destination": "JFK",
            "date": "2025-03-15",
            "passengers": 2
        },
        {
            "origin": "LAX",
            "destination": "ORD",
            "date": "2025-04-20",
            "passengers": 1
        }
    ]
}

Requirements and Limitations

Schema Validation

  • Each example must be valid according to the tool's input_schema
  • Invalid examples will return a 400 error from Anthropic
  • Validation happens server-side (LiteLLM passes examples through)

Server-Side Tools Not Supported

Input examples are only supported for user-defined tools. The following server-side tools do NOT support input_examples:

  • web_search (web search tool)
  • code_execution (code execution tool)
  • computer_use (computer use tool)
  • bash_tool (bash execution tool)
  • text_editor (text editor tool)

Token Costs

Examples add to your prompt tokens:

  • Simple examples: ~20-50 tokens per example
  • Complex nested objects: ~100-200 tokens per example
  • Trade-off: Higher token cost for better tool call accuracy

Model Compatibility

Input examples work with all Claude models that support the advanced-tool-use-2025-11-20 beta header:

  • Claude Sonnet 5 (claude-sonnet-5)
  • Claude Opus 5 (claude-opus-5)
  • Claude Opus 4.5 (claude-opus-4-5-20251101)
  • Claude Sonnet 4.5 (claude-sonnet-4-5-20250929)
  • Claude Opus 4.1 (claude-opus-4-1-20250805)

:::note On Google Cloud's Vertex AI and Amazon Bedrock, only Claude Opus 4.5 supports tool input examples. :::

Best Practices

1. Show Diverse Examples

Include examples that demonstrate different use cases:

"input_examples": [
    {"location": "San Francisco, CA", "unit": "fahrenheit"},  # US city
    {"location": "Tokyo, Japan", "unit": "celsius"},          # International
    {"location": "New York, NY"}                              # Optional param omitted
]

2. Demonstrate Optional Parameters

Show when optional parameters should and shouldn't be included:

"input_examples": [
    {
        "query": "machine learning",
        "filters": {"year": 2024, "category": "research"}  # With optional filters
    },
    {
        "query": "artificial intelligence"  # Without optional filters
    }
]

3. Illustrate Format Requirements

Make format expectations clear through examples:

"input_examples": [
    {
        "phone": "+1-555-123-4567",  # Shows expected phone format
        "date": "2025-01-15",         # Shows date format (YYYY-MM-DD)
        "time": "14:30"               # Shows time format (HH:MM)
    }
]

4. Keep Examples Realistic

Use realistic, production-like examples rather than placeholder data:

```python