> For the complete documentation index, see [llms.txt](https://ai-docs.akile.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ai-docs.akile.ai/kong-zhi-tai/api-keys.md).

# API Key 管理

API Key 是调用 AK AI Gateway 的凭证。进入 [API Keys](https://aigateway.akile.ai/keys) 页面可以创建和管理密钥。

## 创建密钥

创建时可配置：

* 名称：便于区分用途。
* 分组：选择密钥使用的可用分组。
* 自定义 Key：如页面允许，可自定义密钥内容。
* IP 白名单：只允许指定来源 IP 使用。
* IP 黑名单：禁止指定来源 IP 使用。
* 配额：限制该 Key 可消耗额度。
* 过期时间：临时 Key 可设置自动过期。
* 速率限制：可设置 5 小时、1 天、7 天维度限制。

## 推荐命名

使用能体现环境和业务的名称：

* `prod-api`
* `staging-web`
* `dev-local`
* `billing-worker`
* `customer-support-tool`

## 启用与禁用

如果怀疑密钥泄露，立即禁用或删除该 Key，并创建新 Key 替换。

## 多 Key 管理建议

* 不同项目使用不同 Key。
* 开发、测试、生产环境分开。
* 给外包、临时脚本或短期活动单独创建 Key。
* 对预算敏感的项目设置 Key 级配额。
* 对固定服务器调用配置 IP 白名单。

## 泄露处理

1. 立即禁用或删除泄露的 Key。
2. 检查 Usage 是否出现异常调用。
3. 创建新 Key 并更新服务端环境变量。
4. 排查 Key 泄露来源，例如日志、前端包、公开仓库或截图。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ai-docs.akile.ai/kong-zhi-tai/api-keys.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
