文档

Base URL: https://api.1300323847.ccwu.cc

认证方式: Authorization: Bearer sk-xxx (OpenAI 兼容 API) 或 Authorization: Bearer <JWT> (用户 API)

💡 提示: 所有用户 API 返回 JSON 格式。OpenAI 兼容接口返回标准 OpenAI 格式。

🤖 OpenAI 兼容接口

POST /v1/chat/completions 聊天补全(核心接口)

请求头

参数
AuthorizationBearer sk-xxxxxxxx 必填
Content-Typeapplication/json

请求体

{
  "model": "deepseek-v4-flash",
  "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Hello!"}
  ],
  "stream": false,
  "max_tokens": 4096,
  "temperature": 0.7
}

响应

{
  "id": "chatcmpl-xxx",
  "object": "chat.completion",
  "created": 1717000000,
  "model": "deepseek-v4-flash",
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "Hello! How can I help you today?"
    },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 15,
    "total_tokens": 25
  }
}
GET /v1/models 列出所有可用模型

请求头

参数
AuthorizationBearer sk-xxx 可选

响应

{
  "object": "list",
  "data": [{
    "id": "deepseek-v4-flash",
    "object": "model",
    "created": 1717000000,
    "owned_by": "deepseek",
    "display_name": "DeepSeek V4 Flash",
    "pricing": {
      "input_price": 0.5,
      "output_price": 2,
      "cached_price": 0.25,
      "status": "active"
    }
  }]
}
POST /v1/embeddings 文本向量化
POST /v1/completions 补全(传统接口)

🔐 认证

POST /api/auth/register 用户注册

请求体

{
  "email": "user@example.com",
  "password": "your_password",
  "invite_code": "AIR-XXXX"  // 可选
}

响应

{
  "token": "jwt_token_here",
  "user": { "id": "u_xxx", "email": "user@example.com", "role": "user" }
}
POST /api/auth/login 用户登录
{
  "email": "user@example.com",
  "password": "your_password"
}
GET /api/auth/me 获取当前用户信息

Headers: Authorization: Bearer <jwt>

{
  "user": { "id": "u_xxx", "email": "user@example.com", "role": "user", "plan": "starter_monthly", "tokenUsed": 1234, "tokenLimit": 5000000 }
}
PUT /api/auth/password 修改密码
{
  "oldPassword": "old_pass",
  "newPassword": "new_pass"
}
POST /api/auth/apikey 生成 API Key
{ "api_key": "sk-xxxxxxxxxxxxxxxx" }
DELETE /api/auth/apikey 吊销 API Key
{ "api_key": "sk-xxx-to-revoke" }

📦 套餐 & 订单

GET /api/plans 获取所有套餐
GET /api/plans/:id 获取套餐详情
POST /api/orders/create 创建订单
{
  "planId": "starter_monthly",
  "paymentMethod": "wxpay"
}
GET /api/orders 我的订单列表
POST /api/orders/:id/cancel 取消订单

💰 支付

GET /api/payment/qrcode?orderId=xxx 获取微信支付二维码
{
  "code_url": "weixin://wxpay/...",
  "orderId": "ord_xxx",
  "expires_in": 300
}

📊 用量

GET /api/usage/stats 我的用量统计
{
  "tokenUsed": 12345,
  "tokenLimit": 5000000,
  "remaining": 4987655,
  "requestCount": 42,
  "plan": "starter_monthly",
  "expiresAt": 1718000000
}
GET /api/usage/log 最近请求日志
GET /api/export/self 导出自己的使用数据 (JSON)

需要 JWT 认证。返回用户的用量、日志和订单数据。

🧠 模型

GET /api/models 完整模型列表(含定价和分组)
{
  "models": [{
    "id": "deepseek-v4-flash",
    "display_name": "DeepSeek V4 Flash",
    "group": "DeepSeek",
    "status": "active",
    "input_price": 0.5,
    "output_price": 2,
    "cached_price": 0.25,
    "tags": ["DeepSeek"]
  }]
}

🎁 邀请返利

GET /api/invite/code 获取邀请码
GET /api/invite/stats 邀请统计
GET /api/invite/list 被邀请用户列表
POST /api/invite/transfer 提现返利到余额
POST /api/coupon/redeem 兑换码兑换
{
  "code": "WELCOME2026"
}

🔧 管理后台

POST /api/admin/login 管理员登录
GET /api/admin/stats 系统统计概览
GET /api/admin/users 用户列表
GET /api/export/users.csv 导出用户数据 (CSV)

需要 JWT 管理员权限。直接返回 CSV 文件下载。

GET /api/export/orders.csv 导出订单数据 (CSV)
GET /api/export/usage.csv 导出用量数据 (CSV)
GET /api/export/upstream_keys.csv 导出上游 Key 状态 (CSV)

❤️ 健康检查

GET /api/health 健康检查
{ "status": "ok", "timestamp": 1717000000000 }