概述
通过星云 AI API 将平台支持的模型集成到应用。公开文档可直接阅读;模型调用需要有效 API Key,账号管理接口按文档要求认证。具体模型参数、限额、价格与可用性以当前文档及控制台为准。
服务信息
平台地址: https://nebulai.top
API基础路径: /api/proxy
版本: v1.0.0
最小余额: ¥0.01
重要提示: 客户需要通过本平台申请API Key后才能使用服务,所有请求必须携带有效的API Key。
认证方式
API Key认证
所有API请求需要在Header中携带API Key:
Authorization: Bearer YOUR_API_KEY
安全警告: API Key是您的身份凭证,请妥善保管,不要在客户端代码中暴露,建议通过后端代理调用。
快速开始
3步开始使用
1. 申请API Key
- 访问平台首页获取API Key
- 进入"API管理" -> "API密钥"页面
- 点击"生成新密钥"
- 复制并保存您的API Key
2. 充值账户
确保账户有足够余额(最小余额 ¥0.01):
- 联系客服进行充值
3. 调用API
curl -X POST https://nebulai.top/api/proxy/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "DeepSeek-V3",
"messages": [{"role": "user", "content": "你好"}],
"max_tokens": 512
}'
模型代理 API
POST
/api/proxy/chat/completions
核心接口
调用AI模型进行对话,会根据Token用量扣除账户余额,支持流式和非流式响应
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 否 | 模型ID,默认cloud-llm |
messages | array | 是 | 消息列表 |
max_tokens | integer | 否 | 最大生成Token数,默认512 |
temperature | float | 否 | 温度参数,0-2,默认0.7 |
stream | boolean | 否 | 是否流式返回,默认false |
响应示例
{
"success": true,
"id": "chatcmpl-xxx",
"model": "DeepSeek-V3",
"choices": [{
"message": {"role": "assistant", "content": "你好!"}
}],
"billing": {
"input_tokens": 10,
"output_tokens": 20,
"total_tokens": 30,
"cost": 0.00009,
"balance": 99.99991,
"currency": "CNY"
}
}
GET
/api/proxy/models
获取支持的模型列表和价格信息
API Key 管理
POST
/api/proxy/apikeys
创建新的API Key
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | string | 是 | 用户ID |
name | string | 否 | Key名称 |
GET
/api/proxy/apikeys?user_id={user_id}
获取用户的API Key列表
DELETE
/api/proxy/apikeys/{api_key}
删除指定的API Key
余额与计费
GET
/api/proxy/balance/{user_id}
查询用户账户余额
POST
/api/proxy/recharge
为账户充值(后台充值)
GET
/api/proxy/usage/{user_id}?period={period}
查询用户使用记录(today/week/month)
模型列表
浏览并了解所有可用的AI模型,点击卡片查看详细信息
{{ totalModels }}
全部模型
{{ multimodalCount }}
多模态模型
{{ visionCount + textCount + vectorCount }}
其他模型
{{ model.name }}
{{ getTypeLabel(model.type) }}
{{ model.id }}
{{ key }}
{{ price }}
{{ model.description }}
查看详情
错误码说明
HTTP状态码
| 状态码 | 说明 |
|---|---|
| 200 | 请求成功 |
| 400 | 请求参数错误 |
| 401 | 未授权,API Key无效 |
| 402 | 余额不足 |
| 403 | 无权限操作 |
| 500 | 服务器内部错误 |
SDK示例
JavaScript/TypeScript
class NebulaAIClient {
constructor(apiKey) {
this.apiKey = apiKey;
this.baseUrl = 'https://nebulai.top/api/proxy';
}
async chat(messages, model = 'DeepSeek-V3') {
const response = await fetch(`${this.baseUrl}/chat/completions`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${this.apiKey}`
},
body: JSON.stringify({ model, messages })
});
return response.json();
}
async getBalance(userId) {
const response = await fetch(`${this.baseUrl}/balance/${userId}`);
return response.json();
}
}
// 使用示例
const client = new NebulaAIClient('YOUR_API_KEY');
const result = await client.chat([{ role: 'user', content: '你好' }]);
console.log(result.choices[0].message.content);
Python
import requests
class NebulaAIClient:
def __init__(self, api_key):
self.api_key = api_key
self.base_url = 'https://nebulai.top/api/proxy'
self.headers = {
'Content-Type': 'application/json',
'Authorization': f'Bearer {api_key}'
}
def chat(self, messages, model='DeepSeek-V3'):
response = requests.post(
f'{self.base_url}/chat/completions',
headers=self.headers,
json={'model': model, 'messages': messages}
)
return response.json()
client = NebulaAIClient('YOUR_API_KEY')
result = client.chat([{'role': 'user', 'content': '你好'}])
print(result['choices'][0]['message']['content'])