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

# API 密钥

> 为每个应用创建独立凭据，按协议设置鉴权头。

export const ConsoleLink = ({path = "/console", children}) => <a href={"http://localhost:3001" + path} target="_blank" rel="noopener noreferrer">{children}</a>;

## 创建与复制

<ConsoleLink path="/console/keys">打开 API 密钥页 ↗</ConsoleLink>，创建密钥并按需要设置模型权限、消费上限与有效期。用复制按钮获取完整密钥；列表中的前缀不是完整凭据。密钥撤销后不能继续调用。

```bash theme={null}
export CODEFLARE_API_KEY="YOUR_CODEFLARE_KEY"
```

## 协议鉴权

| 入口 | 请求头 |
| - | - |
| Responses / Chat Completions / System One | `Authorization: Bearer YOUR_CODEFLARE_KEY` |
| Anthropic Messages | `x-api-key: YOUR_CODEFLARE_KEY` 与 `anthropic-version: 2023-06-01` |
| Gemini | `x-goog-api-key: YOUR_CODEFLARE_KEY` |

这些都是 **Codeflare 密钥**。用户不需要供应商的上游凭据；登录控制台的 Cookie 不能代替网关 API Key。

## 使用与轮换

将密钥保存到服务端环境变量或密钥管理器，不写入浏览器代码、仓库或分享截图。轮换时先创建新密钥、更新应用并验证，再撤销旧密钥。若收到 401，检查密钥状态、有效期和鉴权格式；403 时检查模型权限。

<Note>密钥消费上限和账户可用余额都会影响准入。若预算不足，请检查[故障排查](/zh/troubleshooting)。</Note>


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