Integrations
Migrate from Anthropic
Migrate your existing Anthropic SDK workflows to Inworld Inference
To migrate from the Anthropic API to Inworld Inference, you mainly change the client configuration. Standard message, streaming, and tool-use code keeps working through the Anthropic Messages API. Some Anthropic-specific parameters and content blocks are dropped, including top_k, PDF document blocks, and thinking blocks in history. Check supported and unsupported features before you migrate.
Key Differences
| Feature | Anthropic Direct | Inworld Inference |
|---|---|---|
| Base URL | https://api.anthropic.com | https://api.inworld.ai |
| Auth | Anthropic API key (x-api-key) | Inworld API key (Authorization: Basic) |
| Model Names | claude-opus-4-6 | claude-opus-4-6, anthropic/claude-opus-4-6, or auto |
| Routing | Single provider | Multi-provider with fallbacks, cost optimization |
| Observability | Anthropic Console | Inworld Portal (unified across all providers) |
Migration Steps
1. Update Base URL and API Key
Python:
import os
import anthropic
api_key = os.environ["INWORLD_API_KEY"] # Base64 credential copied from Portal
client = anthropic.Anthropic(
# From:
# (default: https://api.anthropic.com)
# api_key="sk-ant-..."
# To:
base_url="https://api.inworld.ai",
api_key=None,
auth_token=api_key,
default_headers={"Authorization": f"Basic {api_key}", "X-Api-Key": anthropic.omit},
)
# Standard requests stay 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 apiKey = process.env.INWORLD_API_KEY; // Base64 credential copied from Portal
const client = new Anthropic({
// From:
// (default: https://api.anthropic.com)
// apiKey: 'sk-ant-...'
// To:
baseURL: 'https://api.inworld.ai',
apiKey: null,
authToken: apiKey,
defaultHeaders: { Authorization: `Basic ${apiKey}` },
});See Anthropic compatibility for why both settings are needed.
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: Basic $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 (Optional)
Bare Claude model names work as-is: Inworld Inference finds the providers that serve the model and routes to one of them, with fallback between them. Add the anthropic/ prefix to pin a specific provider:
claude-opus-4-6→anthropic/claude-opus-4-6claude-opus-4-7→anthropic/claude-opus-4-7claude-haiku-4-5-20251001→anthropic/claude-haiku-4-5-20251001
3. Enable Intelligent Routing (Optional)
Instead of hardcoding a model, use Inworld Inference's intelligent routing:
message = client.messages.create(
model="auto", # Inworld Inference 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, including text and image blocks. - Streaming:
stream=Trueworks with Anthropic SSE events (message_start,content_block_delta, etc.). - System prompt: Top-level
systemparameter (string or text blocks). - Tool use: Tool definitions,
tool_usecontent blocks, andtool_resultmessages. max_tokens,temperature,top_p,stop_sequences: Passed through.- Multi-turn conversations: Same format.
What Changes
- Dropped fields:
top_k,service_tier,mcp_servers,container, anddocument,search_result, andthinkingblocks are silently ignored. Anthropic server tools are not executed. - Response details:
stop_sequenceis alwaysnull, and thinking blocks have nosignature. - Errors: Router error bodies use the
{"error": {"message", "type"}}shape rather than Anthropic's{"type": "error", ...}envelope. Authentication errors have a plain-text body. - API key header:
x-api-keyis not read. Use the Basic authorization header shown above.
See supported and unsupported features for the full list.
What You Gain
- Multi-provider fallbacks: List fallback
models(or use a router). If Anthropic is down or rate-limited, Inworld Inference retries on OpenAI, Google, or other providers. The response still uses the Anthropic format. - Cost Optimization: Route simple queries to cheaper models, reserve Claude for complex tasks.
- Cross-Provider Access: Use
openai/gpt-5.4orgoogle-ai-studio/gemini-2.5-flashthrough the same Anthropic SDK — Inworld Inference 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 INWORLD_API_KEY=YOUR_INWORLD_API_KEYThen pass INWORLD_API_KEY explicitly as shown in the client examples above. Don't rely on ANTHROPIC_API_KEY: the SDK sends it as x-api-key, which Inworld Inference does not read. For Claude Code, follow the Claude Code guide.
Support
Need help with a complex migration? Contact our engineering team.