Realtime TTS-2 is live. Built for realtime conversation that feels human. Learn more

Migration

Anthropic to Inworld

Migrate your existing Anthropic SDK workflows to Inworld Router

If you are already using the Anthropic API directly, migrating to Inworld Router is a two-line change. Inworld Router supports the Anthropic Messages API natively, so your existing code, message format, and streaming logic all work as-is.

Key Differences

FeatureAnthropic DirectInworld Router
Base URLhttps://api.anthropic.comhttps://api.inworld.ai
AuthAnthropic API keyInworld API Key (Authorization: Bearer)
Model Namesclaude-opus-4-6anthropic/claude-opus-4-6 or auto
RoutingSingle providerMulti-provider with failover, cost optimization
ObservabilityAnthropic ConsoleInworld Portal (unified across all providers)

Migration Steps

1. Update Base URL and API Key

Python:

python
import anthropic

client = anthropic.Anthropic(
    # From:
    # (default: https://api.anthropic.com)
    # api_key="sk-ant-..."
    # To:
    base_url="https://api.inworld.ai",
    auth_token="YOUR_INWORLD_API_KEY",  # Sends as Authorization: Bearer
)

# Everything else stays the same
message = client.messages.create(
    model="anthropic/claude-opus-4-6",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Hello!"}
    ]
)

TypeScript:

typescript
import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic({
  // From:
  // (default: https://api.anthropic.com)
  // apiKey: 'sk-ant-...'
  // To:
  baseURL: 'https://api.inworld.ai',
  authToken: 'YOUR_INWORLD_API_KEY',  // Sends as Authorization: Bearer
});

cURL:

bash
# From:
# curl https://api.anthropic.com/v1/messages -H "x-api-key: sk-ant-..."
# To:
curl --request POST \
  --url https://api.inworld.ai/v1/messages \
  --header 'Authorization: Bearer <your-inworld-api-key>' \
  --header 'anthropic-version: 2023-06-01' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "anthropic/claude-opus-4-6",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Hello!"}
    ]
  }'

2. Update Model Names

Add the anthropic/ prefix to model names:

  • claude-opus-4-6anthropic/claude-opus-4-6
  • claude-opus-4-20250514anthropic/claude-opus-4-20250514
  • claude-3-5-haiku-20241022anthropic/claude-3-5-haiku-20241022

3. Enable Intelligent Routing (Optional)

Instead of hardcoding a model, use Inworld Router's intelligent routing:

python
message = client.messages.create(
    model="auto",  # Inworld Router selects the best model
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Write a Python function to sort a list."}
    ]
)

What Stays the Same

  • Message format: messages array with role and content — identical.
  • Streaming: stream=True works the same way with Anthropic SSE events (message_start, content_block_delta, etc.).
  • System messages: Top-level system parameter works identically.
  • Tool use: Tool definitions, tool_use content blocks, and tool_result messages work identically.
  • max_tokens: Required parameter, same behavior.
  • temperature, top_p: Same behavior.
  • Multi-turn conversations: Same format, context is preserved correctly.

What You Gain

  1. Multi-Provider Failover: If Anthropic is down or rate-limited, Inworld Router automatically retries on OpenAI, Google, or other providers — and still returns the response in the Anthropic format.
  2. Cost Optimization: Route simple queries to cheaper models, reserve Claude for complex tasks.
  3. Cross-Provider Access: Use openai/gpt-5 or google-ai-studio/gemini-2.5-flash through the same Anthropic SDK — Inworld Router translates the request and returns an Anthropic-format response.
  4. Unified Observability: See all your LLM requests — across Anthropic, OpenAI, Google — in one dashboard.
  5. Custom Routing: Build routers with conditional logic, A/B testing, and weighted variants.

Environment Variables

If you use environment variables, update them:

bash
# From:
# export ANTHROPIC_API_KEY=sk-ant-...

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

Support

Need help with a complex migration? Contact our engineering team.