LiqaaSupport

面向开发者的 AI API

面向开发者的 AI API

Kinexa AI API 允许开发者通过 Kinexa AI Gateway 将 AI 能力集成到自己的应用中。

身份验证

所有 AI API 请求都需要从 Kinexa SSO 获取的 Bearer 令牌(JWT):

Authorization: Bearer YOUR_JWT_TOKEN

JWT 令牌通过 Kinexa SSO 系统进行身份验证后获得。详情请参阅 API 入门指南。

POST /api/ai/chat

向 AI 发送消息并接收回复。

请求:

{
  "messages": [
    { "role": "system", "content": "You are a helpful assistant." },
    { "role": "user", "content": "What are your business hours?" }
  ],
  "model": "auto",
  "temperature": 0.7,
  "max_tokens": 1024
}
  • model — 使用 "auto":网关会根据您的套餐选择引擎(Liqaa AI、Liqaa AI Plus 或 Liqaa AI Pro)
  • temperature — 创造力水平(0.0 = 确定性,1.0 = 富有创造性)
  • max_tokens — 回复的最大长度

响应:

{
  "success": true,
  "data": {
    "id": "msg_abc123",
    "content": "Our business hours are Monday to Friday, 9 AM to 5 PM WIB.",
    "model": "liqaa-ai",
    "usage": {
      "prompt_tokens": 24,
      "completion_tokens": 18,
      "total_tokens": 42
    }
  }
}

GET /api/ai/models

显示您的套餐可用的 AI 级别。

响应:

{
  "success": true,
  "data": [
    { "id": "liqaa-ai", "available": true },
    { "id": "liqaa-ai-plus", "available": false, "reason": "Requires Pro tier" }
  ]
}

GET /api/ai/health

检查 AI 网关的健康状况。

响应:

{
  "success": true,
  "data": {
    "gateway": { "status": "healthy", "latency_ms": 180 }
  }
}

示例:JavaScript/TypeScript

const response = await fetch("https://api.kinexa.id/v1/ai/chat", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": `Bearer ${token}`,
  },
  body: JSON.stringify({
    messages: [
      { role: "user", content: "Summarize our sales this month" }
    ],
    model: "auto",
  }),
});

const data = await response.json();
logger.info(data.data.content);

各套餐的速率限制

套餐AI 请求数/分钟AI 请求数/天
Free10100
Starter30500
Pro1005,000
Business30020,000
Enterprise自定义自定义

超出限制时,您会收到带有 Retry-After 标头的 429 Too Many Requests 响应。

错误代码

代码含义
400请求体或参数无效
401JWT 令牌缺失或无效
403您的套餐不可使用该模型
429超出速率限制

| 503 | AI 提供方暂时不可用 |

这篇文章对您有帮助吗?

需要更多帮助? 联系我们的支持团队

面向开发者的 AI API — Liqaa Support