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

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

FeatureAnthropic DirectInworld Inference
Base URLhttps://api.anthropic.comhttps://api.inworld.ai
AuthAnthropic API key (x-api-key)Inworld API key (Authorization: Basic)
Model Namesclaude-opus-4-6claude-opus-4-6, anthropic/claude-opus-4-6, or auto
RoutingSingle providerMulti-provider with fallbacks, cost optimization
ObservabilityAnthropic ConsoleInworld Portal (unified across all providers)

Migration Steps

1. Update Base URL and API Key

Python:

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:

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:

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: 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-6
  • claude-opus-4-7 → anthropic/claude-opus-4-7
  • claude-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:

python
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: messages array with role and content, including text and image blocks.
  • Streaming: stream=True works with Anthropic SSE events (message_start, content_block_delta, etc.).
  • System prompt: Top-level system parameter (string or text blocks).
  • Tool use: Tool definitions, tool_use content blocks, and tool_result messages.
  • 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, and document, search_result, and thinking blocks are silently ignored. Anthropic server tools are not executed.
  • Response details: stop_sequence is always null, and thinking blocks have no signature.
  • 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-key is not read. Use the Basic authorization header shown above.

See supported and unsupported features for the full list.

What You Gain

  1. 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.
  2. Cost Optimization: Route simple queries to cheaper models, reserve Claude for complex tasks.
  3. Cross-Provider Access: Use openai/gpt-5.4 or google-ai-studio/gemini-2.5-flash through the same Anthropic SDK — Inworld Inference 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 INWORLD_API_KEY=YOUR_INWORLD_API_KEY

Then 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.