服务信息

平台地址: 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

  1. 访问平台首页获取API Key
  2. 进入"API管理" -> "API密钥"页面
  3. 点击"生成新密钥"
  4. 复制并保存您的API Key

2. 充值账户

确保账户有足够余额(最小余额 ¥0.01):

  1. 联系客服进行充值

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 }'
POST /api/proxy/chat/completions 核心接口

调用AI模型进行对话,会根据Token用量扣除账户余额,支持流式和非流式响应

请求参数

参数 类型 必填 说明
modelstring模型ID,默认cloud-llm
messagesarray消息列表
max_tokensinteger最大生成Token数,默认512
temperaturefloat温度参数,0-2,默认0.7
streamboolean是否流式返回,默认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

获取支持的模型列表和价格信息

POST /api/proxy/apikeys

创建新的API Key

请求参数

参数类型必填说明
user_idstring用户ID
namestringKey名称
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)

{{ 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服务器内部错误

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'])