Realtime TTS-2 is live. Built for realtime conversation that feels human. Read the Realtime TTS-2 announcement

Integrations

Use with Claude Code

Route Claude Code requests through Inworld Inference for fallbacks, cost optimization, and observability

Overview

Claude Code is Anthropic's coding agent for the terminal. Route its requests through Inworld Inference for automatic fallbacks, cost optimization, and unified observability, without changing how you use Claude Code.

Why use Inworld Inference with Claude Code?

  • Fallbacks: If Anthropic is rate-limited or down, Inworld Inference automatically falls back to another provider.
  • Cost control: Use model: "auto" with cost-optimized routing to reduce API spend on simpler coding tasks.
  • Observability: Track all Claude Code requests, token usage, and costs in the Inworld Portal.
  • Multi-model access: Use auto to let Inworld Inference pick the best model, or route to OpenAI, Google, or other providers through the same Anthropic-compatible interface.

Setup

Claude Code uses the Anthropic SDK. Set environment variables to send its requests to Inworld Inference.

Add these to your shell configuration file (e.g., ~/.zshrc or ~/.bashrc):

bash
export ANTHROPIC_BASE_URL=https://api.inworld.ai
export ANTHROPIC_AUTH_TOKEN=YOUR_INWORLD_API_KEY

Claude Code sends ANTHROPIC_AUTH_TOKEN as Authorization: Bearer <key>. Inworld Inference accepts your API key in a Bearer header as well as Basic, so no other setup is needed. Don't use ANTHROPIC_API_KEY.

Then reload your shell and run Claude Code:

bash
source ~/.zshrc
claude

All requests from Claude Code will now route through Inworld Inference.

Per-Session Override

For a quick test without changing your global config:

bash
ANTHROPIC_BASE_URL=https://api.inworld.ai \
ANTHROPIC_AUTH_TOKEN=YOUR_INWORLD_API_KEY \
  claude

Using Auto Routing

By default, Claude Code sends requests to a specific Claude model. With Inworld Inference, you can override the model to use intelligent routing:

bash
claude --model auto

This lets Inworld Inference select the best available model based on your routing configuration (cost, latency, or intelligence priorities).

Using a Specific Model

You can route to any model supported by Inworld Inference:

bash
# Use a specific Anthropic model
claude --model anthropic/claude-opus-4-6

# Use an OpenAI model through the Anthropic interface
claude --model openai/gpt-5.4

# Use a Google model
claude --model google-ai-studio/gemini-2.5-flash

Using a Custom Router

If you've created a custom router (e.g., a cost-optimized or fallback router), reference it by ID:

bash
claude --model inworld/failover-system

Comparison: Anthropic direct versus Inworld Inference

FeatureAnthropic DirectVia Inworld Inference
Base URLhttps://api.anthropic.comhttps://api.inworld.ai
ModelsClaude models only50+ models across OpenAI, Google, Anthropic, Groq, and more
Auto routingNot availablemodel: "auto" with configurable sort criteria (cost, latency, intelligence)
Custom routersNot availablemodel: "inworld/your-router" with CEL conditions, variants, weights
FallbacksNone — single providerAutomatic fallbacks across providers
ObservabilityAnthropic ConsoleInworld Portal with routing metadata, attempt history, latency breakdown
Cost optimizationFixed pricingDynamic routing to cheaper models for simple tasks

Verifying the Setup

To confirm Claude Code is routing through Inworld Inference, check the Inworld Portal's Observability tab after making a request. You should see the request logged with routing metadata, including which model was selected and the latency breakdown.

Troubleshooting

"Unauthorized" errors

Ensure ANTHROPIC_AUTH_TOKEN is set to your Inworld API Key. You can find your API key in the Inworld Portal under Workspace Settings > Integrations.

ANTHROPIC_API_KEY is not supported: Claude Code sends it as an x-api-key header, which Inworld Inference does not read. If it is set, unset it and use ANTHROPIC_AUTH_TOKEN instead.

Model not found

Ensure you're using a valid model identifier:

  • auto — Inworld Inference selects the best model
  • anthropic/claude-opus-4-6 — Specific model with provider/model format
  • inworld/your-router-id — Custom router

Connection issues

Verify the base URL is https://api.inworld.ai (no trailing slash, no path suffix).

Next Steps