API 文档
OpenAI 兼容接入
获取 API Key 后,将官方 Base URL 替换为 `https://ningai.cc/v1` 即可。
请求示例
curl https://ningai.cc/v1/chat/completions \
-H "Authorization: Bearer sk-your-key" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"hello"}]}'import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-your-key",
baseURL: "https://ningai.cc/v1"
});支持端点
- POST /v1/chat/completions:聊天补全,支持 stream。
- GET /v1/models:模型列表。
- Header:Authorization: Bearer sk-xxx。
- 错误码:401 密钥无效,402 余额不足,429 频率限制,502 上游异常。
流式调用说明
请求体中设置 `stream: true` 后,服务端会透传上游 SSE 数据。流式请求会记录调用日志;非流式请求会读取 `usage` 字段并自动扣费。