星智AI

用户名

邮箱

API文档

星智超级聚合AI的API调用说明

访问控制

  • 来自IP 152.136.175.209 的请求:直接通过,无需API密钥
  • 来自本地IP(如 127.0.0.1::1::ffff:127.0.0.1)的请求:直接通过,无需API密钥
  • 来自其他IP的请求:需要提供API密钥
  • API密钥可以通过请求头 x-api-key 或查询参数 apiKey 提供
  • /api/auth 路由公开访问,无需API密钥

API基础URL

https://xingkai.wu.airoe.cn/api

认证方式

JWT + API密钥

响应格式

JSON

认证API

用户登录

POST

端点:

/api/auth/login

请求体:

{"email": "user@example.com", "password": "your-password"}

响应:

{"message": "登录成功", "token": "your-jwt-token", "user": {"id": 1, "username": "user", "email": "user@example.com"}}

示例代码:

// 使用Fetch API
fetch('https://xingkai.wu.airoe.cn/api/auth/login', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    email: 'user@example.com',
    password: 'your-password'
  })
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));

用户注册

POST

端点:

/api/auth/register

请求体:

{"username": "user", "email": "user@example.com", "password": "your-password"}

响应:

{"message": "注册成功", "token": "your-jwt-token", "user": {"id": 1, "username": "user", "email": "user@example.com"}}

聊天API

获取聊天模型列表

GET

端点:

/api/chat/models

请求头:

// JWT认证
Authorization: Bearer your-jwt-token

// 或API密钥(来自其他域名)
x-api-key: your-api-key

响应:

{"models": [{"id": "ant", "name": "蚂蚁Ling2.0-1t", "description": "阿里官方镜像模型,支持多轮对话"}, {"id": "doubao", "name": "字节跳动豆包", "description": "抖音旗下开源Seed语言模型"}, ...]}

聊天请求

POST

端点:

/api/chat

请求头:

Authorization: Bearer your-jwt-token
Content-Type: application/json

// 或API密钥(来自其他域名)
x-api-key: your-api-key

请求体:

{"model": "ant", "question": "你好,如何学习编程?", "options": {}}

响应:

{"message": "聊天请求成功", "model": "ant", "question": "你好,如何学习编程?", "result": "学习编程的步骤...", "token": {"remaining": 999, "used": 1}}

代码生成API

获取代码模型列表

GET

端点:

/api/code/models

请求头:

Authorization: Bearer your-jwt-token

// 或API密钥(来自其他域名)
x-api-key: your-api-key

响应:

{"models": [{"id": "qwen3-coder", "name": "Qwen3-coder", "description": "阿里官方镜像模型,模态优化版"}, ...]}

代码生成请求

POST

端点:

/api/code

请求头:

Authorization: Bearer your-jwt-token
Content-Type: application/json

// 或API密钥(来自其他域名)
x-api-key: your-api-key

请求体:

{"model": "qwen3-coder", "question": "生成一个登录页面的HTML代码", "options": {}}

响应:

{"message": "编程请求成功", "model": "qwen3-coder", "question": "生成一个登录页面的HTML代码", "result": "<!DOCTYPE html>...", "token": {"remaining": 998, "used": 2}}

图片生成API

获取图片模型列表

GET

端点:

/api/image/models

请求头:

Authorization: Bearer your-jwt-token

// 或API密钥(来自其他域名)
x-api-key: your-api-key

响应:

{"models": [{"id": "flux", "name": "FLUX.1", "description": "先进的图像生成模型"}, ...]}

图片生成请求

POST

端点:

/api/image

请求头:

Authorization: Bearer your-jwt-token
Content-Type: application/json

// 或API密钥(来自其他域名)
x-api-key: your-api-key

请求体:

{"model": "flux", "prompt": "一只可爱的橘猫,坐在窗台上,阳光照射", "options": {"size": "1024*1024", "steps": 4}}

响应:

{"message": "图片生成请求成功", "model": "flux", "prompt": "一只可爱的橘猫,坐在窗台上,阳光照射", "result": "https://example.com/image.jpg", "token": {"remaining": 995, "used": 5}}

令牌管理API

获取令牌列表

GET

端点:

/api/token

请求头:

Authorization: Bearer your-jwt-token

// 或API密钥(来自其他域名)
x-api-key: your-api-key

响应:

{"tokens": [{"id": 1, "token_type": "free", "amount": 1000, "used": 0, "remaining": 1000, "status": "active", "created_at": "2024-01-01T00:00:00Z"}, ...]}

领取免费令牌

POST

端点:

/api/token/claim-free

请求头:

Authorization: Bearer your-jwt-token
Content-Type: application/json

// 或API密钥(来自其他域名)
x-api-key: your-api-key

响应:

{"message": "领取免费令牌成功", "token": {"id": 1, "token_type": "free", "amount": 1000, "used": 0, "remaining": 1000, "status": "active"}}

购买令牌(暂时免费)

POST

端点:

/api/token/purchase

请求头:

Authorization: Bearer your-jwt-token
Content-Type: application/json

// 或API密钥(来自其他域名)
x-api-key: your-api-key

请求体:

{"amount": 100, "token_type": "standard"}

响应:

{"message": "购买令牌成功(暂时免费)", "token": {"id": 2, "token_type": "standard", "amount": 100, "used": 0, "remaining": 100, "status": "active"}}

获取令牌统计

GET

端点:

/api/token/stats

请求头:

Authorization: Bearer your-jwt-token

// 或API密钥(来自其他域名)
x-api-key: your-api-key

响应:

{"stats": [{"token_type": "free", "total_amount": 1000, "total_used": 10, "total_remaining": 990}, ...]}

错误响应

401 Unauthorized

{"message": "API密钥缺失"}

原因:未提供API密钥或密钥无效

400 Bad Request

{"message": "令牌不足,请购买或领取免费令牌"}

原因:令牌余额不足

500 Internal Server Error

{"message": "Internal Server Error"}

原因:服务器内部错误