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 URLhttps://apik.plus/v1
鉴权方式AuthenticationAuthorization: Bearer <API_KEY>
接口格式API formatOpenAI-compatible
当前模型Current modelsGET /v1/models

查看 Token 价格表 →View token pricing →

Token 计费Token billing

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
401API 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.