API 使用说明API Guide
OpenAI 兼容接口,按实际输入/输出 Token 计费。支持自定义 Base URL 的客户端即可接入。 OpenAI-compatible API billed by actual input/output tokens. Works with any client supporting a custom Base URL.
快速开始Quick Start
| API Base URL | https://apik.plus/v1 |
|---|---|
| 鉴权方式Authentication | Authorization: Bearer <API_KEY> |
| 接口格式API format | OpenAI-compatible |
| 当前模型Current models | GET /v1/models |
查看 Token 价格表 →View token pricing →
Token 计费Token billing
- 输入和输出 Token 分开计量,具体模型价格见价格页。Input and output tokens are measured separately; see Pricing for model rates.
- 价格页中的"待确认"表示网关别名尚未与可靠官方价格匹配,不代表免费。"To verify" means the gateway alias is not matched to a reliable official rate; it does not mean free.
- 最终账单以实际上游、账户、地区和服务条款为准。Final billing follows the upstream provider, account, region and terms.
curl 示例curl example
curl https://apik.plus/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "YOUR_MODEL_ID",
"messages": [{"role": "user", "content": "你好"}],
"stream": false
}'
Python(OpenAI SDK)Python (OpenAI SDK)
import openai
client = openai.OpenAI(base_url="https://apik.plus/v1", api_key="YOUR_API_KEY")
resp = client.chat.completions.create(
model="YOUR_MODEL_ID",
messages=[{"role": "user", "content": "你好"}],
)
print(resp.choices[0].message.content)
Node.js(OpenAI SDK)Node.js (OpenAI SDK)
import OpenAI from "openai";
const client = new OpenAI({baseURL: "https://apik.plus/v1", apiKey: "YOUR_API_KEY"});
const resp = await client.chat.completions.create({
model: "YOUR_MODEL_ID",
messages: [{role: "user", content: "你好"}],
});
常见错误Common errors
| Code | 含义Meaning | 处理Action |
|---|---|---|
| 401 | API Key 无效或缺失Missing/invalid key | 检查请求头Check header |
| 404 | 路径或模型不存在Unknown path/model | 先查 /v1/modelsQuery /v1/models |
| 429 | 限流或配额Rate limit/quota | 退避重试Back off and retry |
| 5xx | 上游或网关异常Upstream/gateway error | 指数退避并报告 TRACE IDRetry and report trace ID |
安全Security
API Key 只放在服务端环境变量中,不要提交到代码仓库或前端代码。报告问题时请提供时间、路径、模型和 X-CPA-TRACE-ID,不要发送 API Key。
Keep API keys in server-side environment variables, never in repos or frontend code. Include time, path, model and X-CPA-TRACE-ID in reports — never send the key.