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

# Claude Code API Key

> Configure Claude Code with an XMAI API key and the Anthropic-compatible base URL.

Use XMAI with Claude Code by setting the Anthropic base URL to
`https://xmapi.site` and using your XMAI API key as the auth token.

<Note>
  Do not add `/v1` to the Claude Code base URL. Claude Code and the Anthropic SDK
  append `/v1/messages` automatically.
</Note>

## Direct answer

```bash theme={null} theme={null}
export ANTHROPIC_BASE_URL="https://xmapi.site"
export ANTHROPIC_AUTH_TOKEN="your-XMAI-api-key"
claude
```

## Step 1: Create an XMAI key

Open the [API Keys dashboard](https://xbhuiz.com/dashboard/tokens), create a
key for your local machine or CI environment, and copy it once.

## Step 2: Set Claude Code environment variables

Claude Code speaks Anthropic's Messages API. Use the bare API host and your
XMAI token:

<CodeGroup>
  ```bash macOS / Linux theme={null} theme={null}
  export ANTHROPIC_BASE_URL="https://xmapi.site"
  export ANTHROPIC_AUTH_TOKEN="your-XMAI-api-key"
  claude
  ```

  ```powershell Windows (PowerShell) theme={null} theme={null}
  $env:ANTHROPIC_BASE_URL = "https://xmapi.site"
  $env:ANTHROPIC_AUTH_TOKEN = "your-XMAI-api-key"
  claude
  ```
</CodeGroup>

## Step 3: Choose a Claude model

Use Claude model ids from [Models](/en/models), such as `claude-opus-4-8`,
`claude-sonnet-5`, or `claude-haiku-4-5`. The model id you request is the
model that runs.

## FAQ

### What base URL should Claude Code use?

Use `https://xmapi.site`. Do not add `/v1`.

### Which auth variable should I set?

Set `ANTHROPIC_AUTH_TOKEN` to your XMAI API key.

### Does XMAI change the Claude model?

No. XMAI does not silently substitute, quantize, or distill models.
