开发者快速入门指南
本文提供详细的配置指南,帮助你快速接入胜算云 API,统一调用多个主流 AI 模型。平台将根据请求内容自动路由到最优模型,帮你降低成本、提升响应质量。
获取 API Key
访问 胜算云控制台 注册并登录账号。
- 进入「控制台」页面。
- 在「API 密钥」模块创建并复制你的专属 API Key。
创建 API Key 时,请注意当前账户的
RPM 和 TPM,如有疑问请联系客服。请妥善保管密钥,避免泄露。调用统一接口
胜算云提供统一的 API 调用地址,你只需调用一个端点,即可访问多个模型。下面用三种语言演示如何调用 anthropic/claude-sonnet-4.6。
from openai import OpenAI
client = OpenAI(
base_url="https://router.shengsuanyun.com/api/v1",
api_key="$SSY_API_KEY",
)
try:
completion = client.chat.completions.create(
model="anthropic/claude-sonnet-4.6",
messages=[{"role": "user", "content": "Which number is larger, 9.11 or 9.8?"}],
temperature=0.6,
top_p=0.7,
stream=True,
)
for chunk in completion:
if chunk.choices and chunk.choices[0].delta.content is not None:
print(chunk.choices[0].delta.content, end="", flush=True)
except Exception as e:
print(f"Request failed: {e}")
import OpenAI from "openai";
const openai = new OpenAI({
baseURL: "https://router.shengsuanyun.com/api/v1",
apiKey: "$SSY_API_KEY",
});
async function main() {
const stream = await openai.chat.completions.create({
model: "anthropic/claude-sonnet-4.6",
messages: [{ role: "user", content: "Which number is larger, 9.11 or 9.8?" }],
temperature: 0.6,
top_p: 0.7,
stream: true,
});
for await (const chunk of stream) {
if (chunk.choices[0].delta.content) {
process.stdout.write(chunk.choices[0].delta.content);
}
}
console.log("\n[chat complete]");
}
main();
API_KEY="$SSY_API_KEY"
BASE_URL="https://router.shengsuanyun.com/api/v1/chat/completions"
MODEL="anthropic/claude-sonnet-4.6"
curl -s -X POST "$BASE_URL" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $API_KEY" \
-d '{
"model": "'"$MODEL"'",
"messages": [{"role": "user", "content": "Which number is larger, 9.11 or 9.8?"}],
"temperature": 0.6,
"top_p": 0.7,
"stream": true
}'
API 参考
接入完成后,可以从下面的 API 参考查看各端点的完整参数与响应结构:
- API 错误代码说明,请参见 OpenAI 兼容 API 参考
- 其他可用模型,请参见 模型总览
- 账号管理与计费,请参见 账号指南
提示:所有兼容接口都使用同一个 Base URL 和 API Key,切换模型只需改
model 字段。官方客服和交流群
如有问题,欢迎联系官方客服或进入开发者交流群获取支持。