開発者向け AI API
開発者向け AI API
Kinexa AI API を使うと、開発者は Kinexa AI Gateway を通じて AI 機能を自社のアプリケーションに組み込むことができます。
認証
すべての AI API リクエストには、Kinexa SSO から取得した Bearer トークン(JWT)が必要です。
Authorization: Bearer YOUR_JWT_TOKENJWT トークンは Kinexa SSO システムで認証を行うことで取得できます。詳細は API Getting Started ガイドをご覧ください。
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 リクエスト/日 |
|---|---|---|
| Free | 10 | 100 |
| Starter | 30 | 500 |
| Pro | 100 | 5,000 |
| Business | 300 | 20,000 |
| Enterprise | カスタム | カスタム |
上限を超えると、Retry-After ヘッダー付きの 429 Too Many Requests レスポンスが返されます。
エラーコード
| コード | 意味 |
|---|---|
| 400 | リクエストボディまたはパラメータが無効です |
| 401 | JWT トークンがないか、無効です |
| 403 | お使いのプランでは利用できないモデルです |
| 429 | レート制限を超えました |
| 503 | AI プロバイダーが一時的に利用できません |