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

# Anthropic

> Every Claude model Verlon supports — plus quickstart and SDK compatibility (use the Anthropic SDK unchanged against Verlon).

Every Claude model — Opus, Sonnet, and Haiku across the 3.5, 4, 4.5, 4.6, 4.7, and 4.8 generations — is routable through Verlon with your existing Anthropic SDK unchanged. Just point `baseURL` at Verlon and swap the API key.

## Chat models

| Model ID                     | Type | Context |
| ---------------------------- | ---- | ------- |
| `claude-3-5-sonnet`          | chat | 200K    |
| `claude-3-5-sonnet-20241022` | chat | 200K    |
| `claude-3-haiku-20250307`    | chat | 200K    |
| `claude-3-opus-20250219`     | chat | 200K    |
| `claude-haiku-4-5-20251001`  | chat | 200K    |
| `claude-opus-4`              | chat | 200K    |
| `claude-opus-4-1-20250805`   | chat | 200K    |
| `claude-opus-4-20250514`     | chat | 200K    |
| `claude-opus-4-5-20251101`   | chat | 200K    |
| `claude-opus-4-6`            | chat | 1000K   |
| `claude-opus-4-7`            | chat | 1000K   |
| `claude-opus-4-8`            | chat | 1000K   |
| `claude-sonnet-4`            | chat | 200K    |
| `claude-sonnet-4-20250514`   | chat | 1000K   |
| `claude-sonnet-4-5-20250929` | chat | 1000K   |
| `claude-sonnet-4-6`          | chat | 1000K   |

<Note>
  This table is auto-generated from the Verlon model registry on every sync — see the [live registry](/provider-compatibility/models#live-registry) for pricing, benchmarks, and deprecation dates.
</Note>

## Other modalities

*No non-chat models.*

## Quickstart

<Note>
  First time? [Create a gate](/platform/gates) and grab an [API key](/getting-started/authentication) — the examples below need a `GATE_ID` and `VERLON_API_KEY`.
</Note>

The fastest path — Verlon SDK, one call:

```typescript theme={null}
import { Verlon } from '@verlon-ai/sdk';

const verlon = new Verlon({ apiKey: process.env.VERLON_API_KEY });

const response = await verlon.chat({
  gateId: process.env.GATE_ID,
  model: 'claude-sonnet-4-6', // optional — overrides the gate's configured model
  data: {
    messages: [{ role: 'user', content: 'Hello!' }],
  },
});

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

Any chat model from the table above works — swap `claude-sonnet-4-6` for `claude-opus-4-8`, `claude-haiku-4-5-20251001`, or any other ID.

## SDK compatibility

Verlon exposes an Anthropic-compatible endpoint. The official Anthropic SDK works unchanged — swap two lines and every model in the table above becomes callable through the SDK you already know.

### Configuration — just two lines

<CodeGroup>
  ```typescript Before theme={null}
  import Anthropic from '@anthropic-ai/sdk';

  const anthropic = new Anthropic({
    apiKey: process.env.ANTHROPIC_API_KEY,
  });
  ```

  ```typescript After (Verlon) theme={null}
  import Anthropic from '@anthropic-ai/sdk';

  const anthropic = new Anthropic({
    baseURL: 'https://api.verlon.ai', // ← add this
    apiKey: process.env.VERLON_API_KEY, // ← change this
  });
  ```
</CodeGroup>

### Specifying your gate

Verlon supports three ways to point a request at a gate:

<Tabs>
  <Tab title="Using gateId (Recommended)">
    ```typescript theme={null}
    // @ts-ignore - gateId is a Verlon AI extension
    const response = await anthropic.messages.create({
      gateId: process.env.GATE_ID,
      max_tokens: 1024,
      messages: [{ role: 'user', content: 'Hello!' }],
    });
    ```

    <Note>
      Requires `@ts-ignore` in TypeScript, but the clearest intent.
    </Note>
  </Tab>

  <Tab title="Using model field">
    ```typescript theme={null}
    const response = await anthropic.messages.create({
      model: process.env.GATE_ID, // gate UUID in the model slot
      max_tokens: 1024,
      messages: [{ role: 'user', content: 'Hello!' }],
    });
    ```

    <Tip>
      No TypeScript errors, drop-in with existing code.
    </Tip>
  </Tab>

  <Tab title="Using a default header">
    ```typescript theme={null}
    const anthropic = new Anthropic({
      baseURL: 'https://api.verlon.ai',
      apiKey: process.env.VERLON_API_KEY,
      defaultHeaders: { 'X-Verlon-Gate-Id': process.env.GATE_ID },
    });

    const response = await anthropic.messages.create({
      max_tokens: 1024,
      messages: [{ role: 'user', content: 'Hello!' }],
    });
    ```

    <Tip>
      Cleanest for TypeScript — set once, use everywhere.
    </Tip>
  </Tab>
</Tabs>

### Streaming

Identical behavior to the Anthropic SDK — `stream: true` returns an async iterable of `MessageStreamEvent` objects.

```typescript theme={null}
const stream = await anthropic.messages.create({
  gateId: process.env.GATE_ID,
  max_tokens: 1024,
  messages: [{ role: 'user', content: 'Tell me a joke.' }],
  stream: true,
});

for await (const event of stream) {
  if (event.type === 'content_block_delta' && event.delta.type === 'text_delta') {
    process.stdout.write(event.delta.text);
  }
}
```

### Language coverage

<CodeGroup>
  ```typescript TypeScript theme={null}
  import Anthropic from '@anthropic-ai/sdk';

  const anthropic = new Anthropic({
    baseURL: 'https://api.verlon.ai',
    apiKey: process.env.VERLON_API_KEY,
  });

  const response = await anthropic.messages.create({
    gateId: process.env.GATE_ID,
    max_tokens: 1024,
    messages: [{ role: 'user', content: 'Hello!' }],
  });

  console.log(response.content[0].text);
  ```

  ```python Python theme={null}
  from anthropic import Anthropic

  client = Anthropic(
      base_url="https://api.verlon.ai",
      api_key=os.environ["VERLON_API_KEY"],
  )

  response = client.messages.create(
      model=os.environ["GATE_ID"],
      max_tokens=1024,
      messages=[{"role": "user", "content": "Hello!"}],
  )

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

  ```bash cURL theme={null}
  curl https://api.verlon.ai/v1/messages \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $VERLON_API_KEY" \
    -H "anthropic-version: 2023-06-01" \
    -d '{
      "gateId": "'"$GATE_ID"'",
      "max_tokens": 1024,
      "messages": [{"role": "user", "content": "Hello!"}]
    }'
  ```
</CodeGroup>

### What's supported

<AccordionGroup>
  <Accordion title="Streaming">
    Full support for `stream: true`, identical semantics to Anthropic's SDK.
  </Accordion>

  <Accordion title="Tool use">
    Fully supported. Verlon translates across providers if your gate routes to a non-Claude model.
  </Accordion>

  <Accordion title="Vision">
    Image inputs in messages work with any vision-capable model.
  </Accordion>

  <Accordion title="System messages + all message types">
    System prompts, user, assistant, and tool\_result blocks all pass through.
  </Accordion>

  <Accordion title="Standard parameters">
    `temperature`, `max_tokens`, `top_p`, `top_k`, `stop_sequences`, and the rest — all passed through.
  </Accordion>

  <Accordion title="Usage + cost tracking">
    Standard `response.usage` with token counts, plus Verlon's `cost` field with per-call dollar amount.
  </Accordion>
</AccordionGroup>

## Migrating an existing Anthropic app

<Steps>
  <Step title="Update client initialization">
    Swap `baseURL` + `apiKey`. Two lines.
  </Step>

  <Step title="Add a gate reference">
    Pass `gateId` (or set the default header). `max_tokens`, `messages`, and everything else stay the same.
  </Step>

  <Step title="Test in development">
    Verify requests appear in the Verlon dashboard and cost tracking works.
  </Step>

  <Step title="Deploy">
    Ship. If anything breaks, revert the two-line diff — takes 30 seconds.
  </Step>
</Steps>

## How it works

1. **You send** an Anthropic-format request to `https://api.verlon.ai/v1/messages`
2. **Verlon receives** — validates the gate, applies routing rules
3. **Verlon routes** to whichever model your gate points at (Claude, GPT, Gemini, Mistral, or anything else in the registry)
4. **The provider responds** in its native format
5. **Verlon normalizes** back to Anthropic format
6. **You receive** a standard Anthropic response with an added `cost` field

Your code doesn't know the difference.

## Errors

Errors come back Anthropic-shaped — `{ "type": "error", "error": { "type", "message" } }` — so the Anthropic SDK's error classes work unchanged.

| Status | Meaning             | What to check                                                                                        |
| ------ | ------------------- | ---------------------------------------------------------------------------------------------------- |
| `400`  | Invalid request     | Malformed body or missing `gateId`                                                                   |
| `401`  | Invalid API key     | Your `VERLON_API_KEY` value and the `Authorization: Bearer` header                                   |
| `404`  | Gate not found      | Your `GATE_ID` — the error message names the offending ID                                            |
| `429`  | Rate limit exceeded | Back off and retry; the body includes `reset_at`, and every response carries `X-RateLimit-*` headers |

```typescript theme={null}
try {
  const response = await anthropic.messages.create({
    gateId: process.env.GATE_ID,
    max_tokens: 1024,
    messages: [{ role: 'user', content: 'Hello!' }],
  });
} catch (error) {
  if (error.status === 404) {
    console.error('Gate not found — check GATE_ID');
  } else if (error.status === 429) {
    console.error('Rate limited — retry after the reset');
  } else {
    throw error;
  }
}
```

## FAQ

<AccordionGroup>
  <Accordion title="Do I need to change my request code?">
    No. Change `baseURL` + `apiKey` in the client. The `messages.create` calls stay identical.
  </Accordion>

  <Accordion title="Can I still call Anthropic directly?">
    Yes. Revert `baseURL` + `apiKey` to Anthropic values and you're back on their API.
  </Accordion>

  <Accordion title="Can I route a GPT or Gemini model through the Anthropic SDK?">
    Yes — that's the point. Configure your gate to route to any model in the [registry](/provider-compatibility/models) and your Anthropic SDK code stays the same.
  </Accordion>

  <Accordion title="Do I need the Verlon SDK?">
    No. This whole guide uses only the Anthropic SDK.
  </Accordion>
</AccordionGroup>

## Full non-chat model list

*This provider is chat-only — see the table above.*

## Related

* [OpenAI](/provider-compatibility/openai) · [Google](/provider-compatibility/google) · [Mistral](/provider-compatibility/mistral)
* [Verlon SDK reference](/sdk-reference/overview) — full-feature native SDK for new projects
* [Gates](/platform/gates) — set up routing rules and model configuration
* [Bring your own key](/platform/byok) — use your own Anthropic account for provider costs
* [Anthropic's official docs ↗](https://docs.anthropic.com/en/docs/build-with-claude/overview)
