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

# Claude Code API Key 配置

> 使用 OmniaKey API key 和 Anthropic 兼容 base URL 配置 Claude Code。

Claude Code 可以通过 OmniaKey 调用 Claude 模型。把 Anthropic base URL 设置为
`https://api.omniakey.com`，并把你的 OmniaKey API key 填到认证变量里即可。

> [!NOTE]
>
> Claude Code 的 base URL 不要加 `/v1`。Claude Code 和 Anthropic SDK 会自动拼接
> `/v1/messages`。

## 直接答案

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

## 第 1 步：创建 OmniaKey API key

打开 [API Keys dashboard](https://omniakey.com/dashboard/tokens)，为本机或 CI
环境创建一把 key，并复制保存。

## 第 2 步：设置 Claude Code 环境变量

Claude Code 使用 Anthropic Messages API。OmniaKey 的 Anthropic 兼容入口是裸域名：

```bash macOS / Linux theme={null}
export ANTHROPIC_BASE_URL="https://api.omniakey.com"
export ANTHROPIC_AUTH_TOKEN="your-omniakey-api-key"
claude
```

```powershell Windows (PowerShell) theme={null}
$env:ANTHROPIC_BASE_URL = "https://api.omniakey.com"
$env:ANTHROPIC_AUTH_TOKEN = "your-omniakey-api-key"
claude
```

## 第 3 步：选择 Claude 模型

从 [支持模型](https://docs.omniakey.com/zh/models.md) 复制模型 id，例如 `claude-opus-4-8`、`claude-sonnet-5`
或 `claude-haiku-4-5`。你请求的模型 id 就是实际运行的模型。

## 常见问题

### Claude Code 应该使用什么 base URL？

使用 `https://api.omniakey.com`，不要加 `/v1`。

### 认证变量应该填哪个？

把 OmniaKey API key 填到 `ANTHROPIC_AUTH_TOKEN`。

### OmniaKey 会替换 Claude 模型吗？

不会。OmniaKey 不会静默替换、量化或蒸馏模型。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.