API Quickstart
快速接入说明
示例使用 `YOUR_API_KEY` 作为安全替代值。请在服务端环境中使用真实 Key,并避免提交到公开仓库。
Base URL
https://api.grandvisionspace.example/v1认证方式
在请求头中传入 `Authorization: Bearer YOUR_API_KEY`。不要在客户端公开完整真实 Key。
curl
curl https://api.grandvisionspace.example/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"model_chat_fast","messages":[{"role":"user","content":"Hello"}]}' JavaScript
const response = await fetch("https://api.grandvisionspace.example/v1/chat/completions", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "model_chat_fast",
messages: [{ role: "user", content: "Hello" }],
}),
}); Python
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.grandvisionspace.example/v1",
)
completion = client.chat.completions.create(
model="model_chat_fast",
messages=[{"role": "user", "content": "Hello"}],
)常见错误
余额不足:请充值后继续使用
模型无权限:检查账户分组
Key 已禁用:启用或重新创建 Key