
# Anthropic SDK

The gateway accepts Anthropic-shaped requests on a separate path so
the official `anthropic` SDK works without a custom adapter. Use this
when your codebase is already standardised on Anthropic's
`messages.create()` style.

## Python

```bash
pip install anthropic
```

```python
import os
from anthropic import Anthropic

client = Anthropic(
    base_url="https://lowrouter.ai/api/v1/anthropic",
    api_key=os.environ["LOWROUTER_API_KEY"],
)

message = client.messages.create(
    model="anthropic/claude-sonnet-4-5",
    max_tokens=512,
    messages=[
        {"role": "user", "content": "In one sentence, what is a vector database?"}
    ],
)

print(message.content[0].text)
```

## TypeScript

```bash
npm install @anthropic-ai/sdk
```

```ts
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  baseURL: "https://lowrouter.ai/api/v1/anthropic",
  apiKey: process.env.LOWROUTER_API_KEY,
});

const message = await client.messages.create({
  model: "anthropic/claude-sonnet-4-5",
  max_tokens: 512,
  messages: [{ role: "user", content: "What's a vector database?" }],
});

console.log(message.content);
```

## Notes

- The model string is the LowRouter ID
  (`anthropic/claude-sonnet-4-5`), not Anthropic's bare model name.
- `api_key` is your LowRouter key, not an Anthropic API key.
- The `anthropic-version` header is set automatically by the SDK; the
  gateway accepts what the SDK sends.
- Streaming works as in the official SDK (`client.messages.stream(...)`).
- Eco metadata is appended to the response in a `lowrouter` field at
  the top level, the same shape as in the OpenAI-compatible path.

## When to prefer this over the OpenAI path

- Your codebase already uses Anthropic types end-to-end and you don't
  want to rewrite call-sites.
- You depend on Anthropic-specific request features (system prompt
  caching, citations, computer-use tool blocks) that aren't in the
  OpenAI schema.
- You want to keep tool definitions in Anthropic's `tools` shape.

If neither of these applies, the OpenAI-compatible path is simpler:
one set of types, one base URL, every model on the same endpoint.
