> ## Documentation Index
> Fetch the complete documentation index at: https://docs.inworld.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Anthropic Compatibility

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`:

```python theme={"system"}
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

<CodeGroup>
  ```python Python theme={"system"}
  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)
  ```

  ```typescript Typescript theme={"system"}
  import Anthropic from '@anthropic-ai/sdk';

  const client = new Anthropic({
    baseURL: 'https://api.inworld.ai',
    authToken: 'YOUR_INWORLD_API_KEY',  // Sends as Authorization: Bearer
  });

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

  console.log(message.content[0].text);
  ```
</CodeGroup>

### Response

The response follows the Anthropic Messages API format:

```json theme={"system"}
{
  "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"
  }
}
```

<Note>
  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.
</Note>

## Next Steps

* [Claude Code Integration](/router/guides/claude-code) to use Inworld Router as your Claude Code backend.
* [Migrating from Anthropic](/router/migration/anthropic-to-inworld) for a step-by-step migration guide.
