Skip to main content
Inworld Router is available through Anthropic-compatible API endpoints, so you can use the Anthropic SDK and tools like Claude Code, while benefiting from Inworld Router’s multi-provider routing, failover, and cost optimization.

Endpoint

The Anthropic-compatible Messages API is available at:
https://api.inworld.ai/v1/messages
When using the Anthropic SDK, set the base URL to https://api.inworld.ai. The SDK automatically appends /v1/messages.

Authentication

Use your Inworld API Key with the Authorization: Bearer header:
Authorization: Bearer <your-api-key>
When using the Anthropic SDK, pass your key via the auth_token parameter (not api_key), which sends it as Authorization: Bearer:
client = anthropic.Anthropic(
    base_url="https://api.inworld.ai",
    auth_token="YOUR_INWORLD_API_KEY",
)

Anthropic SDK

Below is an example request using Anthropic’s SDK
import anthropic

client = anthropic.Anthropic(
    base_url="https://api.inworld.ai",
    auth_token="YOUR_INWORLD_API_KEY",  # Sends as Authorization: Bearer
)

message = client.messages.create(
    model="inworld/<router-id>",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Explain how neural networks learn."}
    ]
)

print(message.content[0].text)

Response

The response follows the Anthropic Messages API format:
{
  "content": [
    {"text": "Neural networks learn through...", "type": "text"}
  ],
  "id": "msg-...",
  "model": "anthropic/claude-opus-4-6",
  "role": "assistant",
  "stop_reason": "end_turn",
  "type": "message",
  "usage": {
    "input_tokens": 12,
    "output_tokens": 150
  },
  "metadata": {
    "attempts": [
      {"model": "anthropic/claude-opus-4-6", "success": true, "time_to_first_token_ms": 1152}
    ],
    "generation_id": "019b...",
    "reasoning": "Using specified model: 'anthropic/claude-opus-4-6' - success"
  }
}
Inworld Router adds a metadata field to the response containing routing information — which model was selected, attempt history, and timing. This field is not part of the standard Anthropic response format, but it does not break Anthropic SDK parsing.

Next Steps