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

# 身份认证

> 创建并安全使用 Yir API Key，通过 Bearer Header 调用 Gateway。

每个公开 Gateway 请求都必须使用标准 HTTP Bearer Header 携带 Yir API Key。

<Steps>
  <Step title="在 Console 获取密钥">
    打开 [Yir Console](https://console.yir.ai/api-keys)。每个账户都有一条不可撤销的默认 API Key。
  </Step>

  <Step title="保存到服务端环境">
    将 Secret 放入密钥管理系统或服务端环境变量，不要写入浏览器代码。
  </Step>

  <Step title="发送 Bearer Header">
    在每次 Gateway 请求中设置 `Authorization: Bearer $YIR_API_KEY`。
  </Step>
</Steps>

```bash theme={null}
export YIR_API_KEY="your-yir-api-key"
```

```http theme={null}
Authorization: Bearer $YIR_API_KEY
```

<Warning>
  不要把完整 Secret 放入截图、URL、公开仓库、日志或支持工单。请求也不能携带上游 Provider API Key。
</Warning>

如果密钥可能泄露，请在 Console 中轮转。轮转保留逻辑 Key 身份和路由配置，成功后旧 Secret 立即失效。
