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

# 创建、轮换与吊销你的 API 密钥

> 在控制台中创建 bfvk API 密钥、用于网关、进行轮换，以及吊销暴露的密钥的分步指南。

API 密钥让服务器与 CLI 能够调用咏唱引擎网关并下载认证模型包。本指南将带你走完完整生命周期：创建、使用、轮换与吊销。

<Steps>
  <Step title="打开 API 密钥页面">
    登录并打开 [/dashboard/api-keys](https://ariacompute.cn/dashboard/api-keys)（或在 `ariacompute.cn` 上的对应页面）。
  </Step>

  <Step title="创建密钥">
    点击 **创建**，输入一个描述性名称（例如 `production`、`ci` 或 `laptop`），然后提交。

    ```bash theme={null}
    curl -X POST https://ariacompute.cn/api/api-keys \
      -H "Authorization: Bearer eyJhbGciOi..." \
      -H "Content-Type: application/json" \
      -d '{"name": "production"}'
    ```

    ```json theme={null}
    {
      "id": "key_01H...",
      "name": "production",
      "key": "bfvk-XXXXXXXXXXXXXXXX",
      "prefix": "bfvk-XXXX",
      "created_at": "2026-09-23T10:00:00Z"
    }
    ```

    <Warning>
      立即复制 `key`。它仅在本响应中返回一次；控制台与后续 `GET /api/api-keys` 调用只显示 `prefix`。
    </Warning>
  </Step>

  <Step title="使用密钥">
    将完整值作为 Bearer 令牌发送给网关或下载接口。

    ```bash theme={null}
    curl -L -H "Authorization: Bearer bfvk-XXXXXXXXXXXXXXXX" \
      "https://ariacompute.cn/api/models/gemma-4-e2b-it/download?quant=int4&sdk=v1.0"
    ```
  </Step>

  <Step title="列出密钥">
    ```bash theme={null}
    curl -H "Authorization: Bearer eyJhbGciOi..." \
      https://ariacompute.cn/api/api-keys
    ```

    返回每个密钥的 `id`、`name`、`prefix`、`created_at` 与 `last_used_at`。
  </Step>

  <Step title="吊销密钥">
    ```bash theme={null}
    curl -X DELETE \
      -H "Authorization: Bearer eyJhbGciOi..." \
      https://ariacompute.cn/api/api-keys/key_01H...
    ```

    返回 `204 No Content`。该密钥立即停止生效。
  </Step>
</Steps>

## 轮换

定期轮换密钥，或在密钥可能已暴露时立即轮换：

1. 创建新密钥并存入密钥管理器。
2. 与旧密钥一同部署新密钥。
3. 等待日志确认全部流量已使用新密钥。
4. `DELETE` 旧密钥。

## 按站点隔离的密钥

API 密钥作用域限定于签发它的站点。如果你同时使用 `ariacompute.com` 与 `ariacompute.cn`，请在每个控制台各创建一个密钥，并用于对应的网关。

<Tip>
  为密钥取有意义的名称。短前缀加环境（`prod-api`、`staging-worker`）能让吊销操作一目了然。
</Tip>
