1. 基础信息
Feather API 提供统一的 AI 模型聚合服务,接口格式兼容 OpenAI。 你可以通过一个 API Key 调用多个模型。
2. 鉴权方式
所有 API 请求都需要在请求头中携带你的令牌。 令牌可以在控制台的「令牌」或「API Key」页面创建。
Authorization: Bearer YOUR_API_KEY Content-Type: application/json
3. Chat Completions 聊天接口
该接口用于文本对话、代码生成、内容创作、问答和多轮聊天。
请求地址
POST https://lazymoon.cn/v1/chat/completions
请求参数
| 参数 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
| model | string | 是 | 要调用的模型名称,例如 gpt-5.4-mini |
| messages | array | 是 | 对话消息数组,包含 role 和 content |
| temperature | number | 否 | 控制输出随机性,数值越高越发散 |
| max_tokens | number | 否 | 限制最大输出 token 数 |
| stream | boolean | 否 | 是否开启流式输出,true 表示开启 |
cURL 示例
curl https://lazymoon.cn/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4-mini",
"messages": [
{
"role": "user",
"content": "你好,请介绍一下 Feather API"
}
]
}'
返回示例
{
"id": "chatcmpl-xxxx",
"object": "chat.completion",
"created": 1710000000,
"model": "gpt-5.4-mini",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "你好,我是 Feather API 提供的 AI 助手。"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 20,
"completion_tokens": 18,
"total_tokens": 38
}
}
4. OpenAI SDK 接入
Feather API 兼容 OpenAI SDK。你只需要把 base_url 或 baseURL 修改为 Feather API 的地址。
Python 示例
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://lazymoon.cn/v1"
)
response = client.chat.completions.create(
model="gpt-5.4-mini",
messages=[
{"role": "user", "content": "你好"}
]
)
print(response.choices[0].message.content)
Node.js 示例
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "https://lazymoon.cn/v1"
});
const completion = await client.chat.completions.create({
model: "gpt-5.4-mini",
messages: [
{ role: "user", content: "你好" }
]
});
console.log(completion.choices[0].message.content);
5. 流式输出
如果你希望像 ChatGPT 一样逐字输出内容,可以开启流式响应。 请求参数中加入 "stream": true 即可。
cURL 流式示例
curl https://lazymoon.cn/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4-mini",
"stream": true,
"messages": [
{
"role": "user",
"content": "写一首关于月亮的短诗"
}
]
}'
Node.js 流式示例
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "https://lazymoon.cn/v1"
});
const stream = await client.chat.completions.create({
model: "gpt-5.4-mini",
stream: true,
messages: [
{ role: "user", content: "写一首关于月亮的短诗" }
]
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || "");
}
6. 模型列表
你可以通过模型接口获取当前账号可用的模型列表。 实际可用模型、倍率和价格请以站内「模型价格」页面为准。
获取模型列表
curl https://lazymoon.cn/v1/models \ -H "Authorization: Bearer YOUR_API_KEY"
常见模型示例
7. 第三方客户端配置
Feather API 支持大多数 OpenAI Compatible 客户端,例如 Cherry Studio、LobeChat、Open WebUI 等。
通用配置
类型 / Provider: OpenAI Compatible API Key: YOUR_API_KEY Base URL: https://lazymoon.cn/v1
Cherry Studio
供应商类型:OpenAI Compatible API 地址:https://lazymoon.cn/v1 API Key:你的 Feather API Key 模型:选择或手动填写模型名称
Open WebUI
OPENAI_API_BASE_URL=https://lazymoon.cn/v1 OPENAI_API_KEY=YOUR_API_KEY
8. 常见错误码
如果请求失败,可以根据状态码排查问题。
| 状态码 | 含义 | 常见原因 | 处理方式 |
|---|---|---|---|
| 400 | 请求参数错误 | JSON 格式错误、messages 不合法、参数类型错误 | 检查请求体和参数格式 |
| 401 | 认证失败 | API Key 错误、未携带 Authorization | 检查令牌是否正确 |
| 403 | 权限不足 | 账号被禁用、模型无权限、分组限制 | 检查账号状态和模型权限 |
| 404 | 资源不存在 | 接口地址错误、模型名称不存在 | 确认 Base URL 和模型名 |
| 429 | 请求过多 | 频率过高、并发过高、额度限制 | 降低请求频率后重试 |
| 500 | 服务器错误 | 服务异常或内部错误 | 稍后重试或联系管理员 |
| 502 / 503 | 上游异常 | 上游模型服务不可用或网络异常 | 稍后重试或更换模型 |
9. 计费与注意事项
Feather API 通常按模型实际调用量计费。不同模型倍率和价格不同,最终费用以站内展示为准。
- 请在控制台查看余额、日志、模型价格和调用记录。
- 请勿在前端代码中直接暴露 API Key。
- 余额不足、模型不可用或令牌过期可能导致请求失败。
- 流式输出需要客户端支持 SSE。
- 第三方客户端中请优先选择 OpenAI Compatible 类型。
- 如果模型调用异常,可以尝试更换模型或稍后重试。