> 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/kai-shi-shi-yong/quickstart.md).

# 三步接入

已有 OpenAI SDK 项目时，接入 AK AI Gateway 通常只需要三步。

## 1. 创建 API Key

登录后进入 [API Keys](https://aigateway.akile.ai/keys) 页面，创建一个新的 API Key。

创建时建议：

* 名称写清楚用途，例如 `prod-web`、`dev-test`、`billing-job`。
* 按项目设置额度上限。
* 如果请求来源固定，配置 IP 白名单。
* 为临时测试 Key 设置过期时间。

## 2. 替换 Base URL

把原来的 OpenAI Base URL 替换为：

```
https://aigateway.akile.ai/v1
```

API Key 使用控制台生成的密钥。

## 3. 发起请求

Python 示例：

```python
from openai import OpenAI

client = OpenAI(
    base_url="https://aigateway.akile.ai/v1",
    api_key="AK-xxxxxxxx",
)

response = client.chat.completions.create(
    model="claude-opus-4-8",
    messages=[
        {"role": "user", "content": "用一句话介绍 AK AI Gateway"}
    ],
)

print(response.choices[0].message.content)
```

curl 示例：

```bash
curl https://aigateway.akile.ai/v1/chat/completions \
  -H "Authorization: Bearer AK-xxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-4-8",
    "messages": [
      {"role": "user", "content": "你好"}
    ]
  }'
```

## 接入检查

如果请求失败，先检查：

* `base_url` 是否包含 `/v1`。
* 请求头是否为 `Authorization: Bearer <API Key>`。
* API 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/kai-shi-shi-yong/quickstart.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.
