回答を少しずつ表示するには?
チャット画面では stream を true にすると回答を順次受け取れます。まず通常のリクエストでメッセージ形式を確認してから、ストリームの読み取りを実装してください。
POST /v1/chat/completionschoices[0].message.content Python
import os
import requests
response = requests.post(
"https://api.rokoapi.com/v1/chat/completions",
headers={"Authorization": "Bearer " + os.environ["API_KEY"]},
json={"model": "gpt-6-luna", "messages": [{"role": "user", "content": "Hello"}]},
timeout=60,
)
response.raise_for_status()
print(response.json()["choices"][0]["message"]["content"])JavaScript · Node.js
const response = await fetch("https://api.rokoapi.com/v1/chat/completions", {
method: "POST",
headers: {
Authorization: "Bearer " + process.env.API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "gpt-6-luna",
messages: [{ role: "user", content: "Hello" }],
}),
});
if (!response.ok) throw new Error(String(response.status));
console.log((await response.json()).choices[0].message.content);導入シナリオ
-
問い合わせ対応:関連する履歴を渡し、ストリーミングで回答を順次表示します。
リクエスト例
POST https://api.rokoapi.com/v1/chat/completions{ "model": "gpt-6-luna", "messages": [ { "role": "user", "content": "Our webhook returns HTTP 401." }, { "role": "assistant", "content": "Check whether the Authorization header is present." }, { "role": "user", "content": "The header is present. What should I check next?" } ], "max_completion_tokens": 256, "stream": true }実際の応答
Next, verify the **authentication format and value**, not just that a header exists: - Does the endpoint expect `Authorization: Bearer …`, `Basic …`, or a provider-specific signature? Webhooks often use a signature header instead of `Authorization`. - Check for typos, extra whitespace, wrong capitalization or encoding, and an expired or rotated credential. - Confirm the sender is using the credential for the right environment and endpoint (test vs. production). - Check whether a proxy, gateway, or serverless layer is removing or changing the header before it reaches your app. - Look at logs to identify which layer returns the 401—the provider, gateway, or your application202611221254505938784048268d9d6B7wQZjaO·finish_reason: length· USD 0.00012 -
JSON 抽出:必要なキーをメッセージで指定し、アプリ側で解析と検証を行います。
リクエスト例
POST https://api.rokoapi.com/v1/chat/completions{ "model": "gpt-6-luna", "messages": [ { "role": "user", "content": "Return only a JSON object with summary and action fields. Ticket: The build failed because the lockfile references a removed package." } ], "max_completion_tokens": 256, "stream": false }実際の応答
{"summary":"The build failed because the lockfile references a package that has been removed.","action":"Update or regenerate the lockfile to remove the stale package reference, then rerun the build to verify the fix."}202611221254577052278048268d9d6U2jViPdr·finish_reason: stop· USD 0.000046 -
デバッグ:共有可能な最小限のエラーを送り、検証できる仮説を求めます。
リクエスト例
POST https://api.rokoapi.com/v1/chat/completions{ "model": "gpt-6-luna", "messages": [ { "role": "user", "content": "A Node.js job processes the same webhook twice after a timeout. Suggest two causes and one reproducible test for each." } ], "max_completion_tokens": 256, "stream": false }実際の応答
生成トークン上限に達し、回答本文は返りませんでした。
202611221255031218619338268d9d6Hdn7s16K·finish_reason: length· USD 0.000118 -
一括要約:入力を短く保ち、usage から 1 件あたりの費用を測ります。
リクエスト例
POST https://api.rokoapi.com/v1/chat/completions{ "model": "gpt-6-luna", "messages": [ { "role": "user", "content": "Summarize in one sentence: The weekly import completed 820 rows and skipped 17 with invalid dates. No retry has run." } ], "max_completion_tokens": 256, "stream": false }
リクエストパラメーター
基本パラメーター
| フィールド | 詳細 |
|---|---|
| string · 必須 | この公開モデル ID を指定します。gpt-6-luna |
| array · 必須 | role と content を順に渡します。続きの応答には必要な履歴を含めます。 |
詳細パラメーター
| フィールド | 詳細 |
|---|---|
| boolean · 任意 | true で SSE の差分を要求します。 既定値 false |
| integer · 任意 | 生成トークン数の上限です。料金に影響 |
モデル価格
1つのページでこのシリーズのすべての公開プランと現在の価格を比較できます。
カタログ参考料金 · 実際のトークン使用量で課金
- 入力トークン
- $0.092 / 100万トークン
- 出力トークン
- $0.45 / 100万トークン
- キャッシュ読み取り
- $0.092 / 100万トークン
- キャッシュ書き込み
- $0.115 / 100万トークン
- キャッシュ書き込み(1時間)
- $0.184 / 100万トークン
- 画像入力トークン
- $0.092 / 100万トークン
- 音声入力トークン
- $0.092 / 100万トークン
- 音声出力トークン
- $0.092 / 100万トークン
コンテキストの区分は未公開です。参考料金はすべての長さに適用されるとは限りません。
コンテキスト
—
最大出力
—
- モデルID
-
gpt-6-luna - 利用可能なグループ
- default, svip
- 機能
- chat
APIリファレンス
Base URLはhttps://api.rokoapi.com/v1です。リクエストのmodelには上記のモデルIDを使用してください。
curl https://api.rokoapi.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6-luna",
"messages": [{"role":"user","content":"一言で自己紹介してください"}]
}' その他のパラメータ、制限、非同期タスクの照会方法については、GPT 6 Luna開発ガイドを参照してください。 GPT 6 Luna 開発ドキュメント · OpenAI · Authorization