OpenAI 兼容 API
通过标准 OpenAI 兼容接口调用 SUITY 智造舱 (SUITY Lab) 的平台模型与已投放算力。使用项目 API Key 鉴权,客户端无需平台登录。
Base URL
将任意 OpenAI 兼容 SDK 的 base URL 指向此处:
bash
https://cloud-api.suitylab.com/openai-api/v1本地开发时默认 http://localhost:8787/openai-api/v1,可通过 VITE_API_BASE_URL 覆盖。
鉴权
以 Bearer 形式发送项目 API Key。仅读取 Authorization 头;api-key 头会被忽略。
bash
Authorization: Bearer <项目 Key>项目 Key 形如 sk-suity-...。前往 控制台打开项目 以创建与管理其 API Key。
接口
GET https://cloud-api.suitylab.com/openai-api/v1/models— 列出可用模型(公开,无需 Key)。POST https://cloud-api.suitylab.com/openai-api/v1/chat/completions— 创建对话补全(需有效 Key)。
持项目 Key 可访问平台模型,以及已投放给该项目的模型。
计费
项目 Key 调用消耗项目已投放的算力点数(平台 / 机构扶持)。不会回退到你的个人付费或免费点数;投放耗尽时请求返回 402。
- 用量按点数计费,模型按输入 / 输出分别标价。
- 可用模型与价格以
GET /models返回与控制台显示为准。
详见模型与计费说明。
错误与限制
| 状态 | 错误码 | 说明 |
|---|---|---|
401 | invalid_api_key | Key 无效或已吊销。 |
402 | PROJECT_COMPUTE_UNAVAILABLE | 无可用投放,或池不可服务。 |
402 | INSUFFICIENT_PROJECT_POINTS | 额度或点数耗尽。 |
- 只认
Authorization头,api-key头不会生效。 GET /models为公开接口;POST /chat/completions必须携带有效项目 Key。- 项目 Key 只消耗项目已投放点数,不触碰个人点数。
完整错误码见错误码参考。
示例
cURL
bash
curl https://cloud-api.suitylab.com/openai-api/v1/chat/completions \
-H "Authorization: Bearer $SUITY_PROJECT_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "cloudflare/llama-3.1-8b",
"messages": [{"role": "user", "content": "Hello"}]
}'Python(openai)
python
from openai import OpenAI
client = OpenAI(
base_url="https://cloud-api.suitylab.com/openai-api/v1",
api_key="sk-suity-...", # your project API key
)
resp = client.chat.completions.create(
model="cloudflare/llama-3.1-8b",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)Node.js(openai)
ts
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://cloud-api.suitylab.com/openai-api/v1",
apiKey: "sk-suity-...", // your project API key
});
const resp = await client.chat.completions.create({
model: "cloudflare/llama-3.1-8b",
messages: [{ role: "user", content: "Hello" }],
});
console.log(resp.choices[0].message.content);需要更多算力点数?见定价。
