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

# Use Modellix LLM with the Anthropic SDK

> Point the Anthropic SDK at Modellix with ANTHROPIC_BASE_URL (no /v1) and your Modellix API key, then call Messages with anthropic/... models.

Use Anthropic client libraries against Modellix by pointing the base URL at the LLM gateway and authenticating with a Modellix API key. The gateway speaks the Anthropic Messages protocol at [`POST /v1/messages`](/llm/messages).

<Note>
  Use a Modellix API key from the [console](https://modellix.ai/console/api-key), not an Anthropic Console key. Model IDs use `provider/name` (for example `anthropic/claude-sonnet-5`)—see [Models & Pricing](/llm/overview#models-and-pricing) for the full list.
</Note>

## Configure the client

```bash theme={null}
export ANTHROPIC_API_KEY="mdlx-xxxxxxxx"
export ANTHROPIC_BASE_URL="https://llm.modellix.ai"
```

| Setting  | Value                                                                             |
| -------- | --------------------------------------------------------------------------------- |
| Base URL | `https://llm.modellix.ai` (**without** `/v1`; the SDK appends `/v1/messages`)     |
| API key  | Modellix API Key via `ANTHROPIC_API_KEY` (sent as `x-api-key`)                    |
| Model    | Prefer `anthropic/...`. See [Models & Pricing](/llm/overview#models-and-pricing). |

<Warning>
  Do not set `ANTHROPIC_BASE_URL` to `https://llm.modellix.ai/v1`. Including `/v1` breaks path construction for native Anthropic clients.
</Warning>

### Bearer alternative

If a tool requires Bearer auth instead of `x-api-key`, use `ANTHROPIC_AUTH_TOKEN` with the same Modellix key. Do not set `ANTHROPIC_API_KEY` and `ANTHROPIC_AUTH_TOKEN` to different values.

## Messages example

<CodeGroup>
  ```python Python theme={null}
  import anthropic

  client = anthropic.Anthropic()  # reads ANTHROPIC_API_KEY and ANTHROPIC_BASE_URL

  message = client.messages.create(
      model="anthropic/claude-sonnet-5",
      max_tokens=256,
      messages=[
          {"role": "user", "content": "ping"},
      ],
  )

  print(message.content)
  ```

  ```typescript TypeScript theme={null}
  import Anthropic from "@anthropic-ai/sdk";

  const client = new Anthropic(); // reads ANTHROPIC_API_KEY and ANTHROPIC_BASE_URL

  const message = await client.messages.create({
    model: "anthropic/claude-sonnet-5",
    max_tokens: 256,
    messages: [{ role: "user", content: "ping" }],
  });

  console.log(message.content);
  ```
</CodeGroup>

`max_tokens` is required on Messages. Put system instructions in `system`, not as a `system` role inside `messages` (roles are `user` or `assistant` only).

## Streaming

Set `stream=true` (or the SDK equivalent). The gateway returns Anthropic Messages SSE events.

## Optional headers

Native Anthropic clients often send `anthropic-version` (for example `2023-06-01`); Modellix forwards it upstream when present. For multi-turn session affinity you can also send `X-Mdlx-Session-Id` (see [LLM API](/llm/api#session-header)).

## Related

* [Claude Code](/llm/claude-code) — same base URL pattern with settings persistence
* [LLM API guide](/llm/api) — protocols, auth, and errors
* [Create message](/llm/messages) — OpenAPI reference
