接入文档
这一章回答:怎么用 OpenAI 的方式发一次对话。
OpenAI Chat Completions
兼容 /v1/chat/completions。
按下面三步即可发起一次聊天补全请求:
这一章和「Responses」共用同一个基址和同一把密钥;要发 /v1/responses 就把路径换掉。
Base URL
https://platform.aasim.l.cd/v1
认证头
Authorization: Bearer sk-relay-xxxx...
curl 示例
curl https://platform.aasim.l.cd/v1/chat/completions \
-H "Authorization: Bearer $RELAYAB_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "YOUR_MODEL_ID","messages": [{"role": "user", "content": "Hello!"}]}'想知道你能用哪些模型?GET https://platform.aasim.l.cd/v1/models,参考你的密钥关联的模型映射。
厂商不必原生支持 OpenAI 协议:只要模型在目录里(GET /v1/models),哪怕厂商只提供 Anthropic 端点或 Google 原生 Gemini 端点,这一套接口照样调得通 —— 网关会把请求转成上游的形状再发出去,答案再转回来。流式请求照样逐块到达。
错误
失败响应的形状和 OpenAI 一致,可以直接按 OpenAI 的方式处理。
响应体
{ "error": {
"message": "积分 balance exhausted for this account",
"type": "insufficient_quota",
"code": "quota_exceeded_credits"
} }message 是写给人看的说明;type 是 OpenAI 的分类,由 HTTP 状态码推导:400 → invalid_request_error,401 → authentication_error,403 → permission_error,404 → not_found_error,429 → rate_limit_error,5xx → server_error。code 是本服务自己的具体原因,和 type 分开看。
「额度用完」是 429,但 type 是 insufficient_quota 而不是 rate_limit_error。客户端看到 429 惯例是退避重试,而用完的额度池不会自己恢复——不把这两件事分开,客户端就会一直重试下去。
想知道还剩多少额度,见「余额」那一章。