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
| Feature | Anthropic Direct | Inworld Router |
|---|---|---|
| Base URL | https://api.anthropic.com | https://api.inworld.ai |
| Auth | Anthropic API key | Inworld API Key (Authorization: Bearer) |
| Model Names | claude-opus-4-6 | anthropic/claude-opus-4-6 or auto |
| Routing | Single provider | Multi-provider with failover, cost optimization |
| Observability | Anthropic Console | Inworld Portal (unified across all providers) |
Migration Steps
1. Update Base URL and API Key
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:
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:
# 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-6→anthropic/claude-opus-4-6claude-opus-4-20250514→anthropic/claude-opus-4-20250514claude-3-5-haiku-20241022→anthropic/claude-3-5-haiku-20241022
3. Enable Intelligent Routing (Optional)
Instead of hardcoding a model, use Inworld Router's intelligent routing:
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:
messagesarray withroleandcontent— identical. - Streaming:
stream=Trueworks the same way with Anthropic SSE events (message_start,content_block_delta, etc.). - System messages: Top-level
systemparameter works identically. - Tool use: Tool definitions,
tool_usecontent blocks, andtool_resultmessages 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
- 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.
- Cost Optimization: Route simple queries to cheaper models, reserve Claude for complex tasks.
- Cross-Provider Access: Use
openai/gpt-5orgoogle-ai-studio/gemini-2.5-flashthrough the same Anthropic SDK — Inworld Router translates the request and returns an Anthropic-format response. - Unified Observability: See all your LLM requests — across Anthropic, OpenAI, Google — in one dashboard.
- Custom Routing: Build routers with conditional logic, A/B testing, and weighted variants.
Environment Variables
If you use environment variables, update them:
# From:
# export ANTHROPIC_API_KEY=sk-ant-...
# To:
export ANTHROPIC_AUTH_TOKEN=YOUR_INWORLD_API_KEY
export ANTHROPIC_BASE_URL=https://api.inworld.aiSupport
Need help with a complex migration? Contact our engineering team.