30 秒快速验证
复制 API Key,一条 curl 命令即可完成首次调用验证。
01
1. 获取 API Key
登录控制台 → API 密钥 → 创建密钥。审核通过后即可创建,完整 Key 仅在创建时显示一次,请妥善保存。
02
2. 发送测试请求
在终端执行以下命令(将 `sk-opc-...` 替换为你的真实 Key):
export OPC_API_KEY="sk-opc-your-api-key"
curl https://api.qiyuanapi.cc/v1/chat/completions \
-H "Authorization: Bearer $OPC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.6",
"messages": [{"role": "user", "content": "你好,请用一句话介绍启元Hub"}]
}'03
3. 确认响应
成功时你会收到类似下面的 JSON 响应,`choices[0].message.content` 中有模型回复:
{
"id": "chatcmpl-...",
"object": "chat.completion",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "..."
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 28,
"total_tokens": 40
}
}04
常见错误
若请求失败,请对照以下错误码排查:
- 401 unauthorized — API Key 无效或已禁用
- 402 quota_exceeded — 余额不足,请充值或使用兑换码
- 403 application_pending — 账号尚未审核通过
- 403 ip_not_allowed — 当前 IP 不在 Key 白名单内
- 429 rate_limited — 请求过于频繁,请稍后重试
05
下一步
验证通过后,可在控制台 Playground 在线调试,或继续阅读 Node.js / Claude Code 等工具链接入文档。