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

# 快速开始

> 几行代码，完成你的第一次模型调用。

> [!NOTE]
>
> 一把密钥，连接多家模型。请从控制台复制实际区域地址和模型 ID；下方域名与模型仅为占位符。

**1. 创建 API 密钥**

在控制台为你的应用创建独立密钥，并使用环境变量保存。

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

[管理 API 密钥 ↗](http://localhost:3001/console/keys)

**2. 选择区域与模型**

在密钥页复制所选区域的 Base URL，在模型详情中复制兼容 Responses 协议的模型 ID。

| 配置 | 示例占位符 |
| - | - |
| Base URL | `https://YOUR-REGION.example/v1` |
| 模型 ID | `MODEL_ID` |

[查看模型与协议 ↗](http://localhost:3001/console/models)

**3. 发起第一次请求**

安装对应 SDK，然后替换地址与模型。Python 使用 `python -m pip install openai`；JavaScript 使用 `npm install openai`。

```python Python theme={null}
from openai import OpenAI
import os

client = OpenAI(
    api_key=os.environ["CODEFLARE_API_KEY"],
    base_url="https://YOUR-REGION.example/v1",
    max_retries=0,
)
response = client.responses.create(
    model="MODEL_ID", input="Hello",
    max_output_tokens=256, store=False,
)
print(response.output_text)
```

```javascript JavaScript theme={null}
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.CODEFLARE_API_KEY,
  baseURL: "https://YOUR-REGION.example/v1",
  maxRetries: 0,
});
const response = await client.responses.create({
  model: "MODEL_ID", input: "Hello",
  max_output_tokens: 256, store: false,
});
console.log(response.output_text);
```

```bash cURL theme={null}
curl "https://YOUR-REGION.example/v1/responses" \
  -H "Authorization: Bearer $CODEFLARE_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"model":"MODEL_ID","input":"Hello","max_output_tokens":256,"store":false}'
```

> [!WARNING]
>
> 请求中断后请先检查结果，避免重复生成。示例关闭 SDK 自动重试，不会替你执行请求。

## 接下来

> **[了解协议与鉴权](https://docs.liverstra.com/zh/api/overview.md)**
>
> 根据模型选择匹配的请求格式。

> **[配置 Codex CLI](https://docs.liverstra.com/zh/tools/codex.md)**
>
> 使用 Responses 自定义 Provider。

> **[配置 Claude Code](https://docs.liverstra.com/zh/tools/claude-code.md)**
>
> 使用 Anthropic Messages 网关。

> **[排查调用问题](https://docs.liverstra.com/zh/troubleshooting.md)**
>
> 检查密钥、余额、区域与能力。


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