ナビゲーションにスキップ

GPT-6 Luna API

GPT-6 Luna を呼び出すには model: "gpt-6-luna" を指定します。以下の例では OpenAI Chat Completions を使って同期リクエストを送信します。

以下は実装例であり、実際のモデル出力を記録したものではありません。キーはサーバーの環境変数 BEATAPI_API_KEY に保存し、cURL の例では <BEATAPI_API_KEY> を自分のキーに置き換えてください。ブラウザー側のコードにキーを含めないでください。

リクエストの送信

POST https://api.beatapi.io/v1/chat/completions

サーバー側のプロジェクトに openai をインストールしてください。

import OpenAI from "openai";
const apiKey = process.env.BEATAPI_API_KEY;
if (!apiKey) throw new Error("Set BEATAPI_API_KEY in your server environment.");
const client = new OpenAI({
apiKey,
baseURL: "https://api.beatapi.io/v1",
});
const completion = await client.chat.completions.create({
model: "gpt-6-luna",
messages: [{ role: "user", content: "Classify the following support ticket using exactly one label: account_access, billing, or product_defect. Return the label and a brief reason. Ticket: I reset my password, but the new password still does not let me sign in." }],
});
const choice = completion.choices[0];
if (!choice || choice.finish_reason !== "stop") {
throw new Error(`Handle the finish reason before accepting the result: ${choice?.finish_reason}`);
}
const text = choice.message.content;
if (typeof text !== "string" || !text.trim()) {
throw new Error("The response contains no text answer.");
}
console.log(text);
console.log({ id: completion.id, model: completion.model, usage: completion.usage });

cURL

curl --request POST \
--url https://api.beatapi.io/v1/chat/completions \
--header 'Authorization: Bearer <BEATAPI_API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-6-luna",
"messages": [
{
"role": "user",
"content": "Classify the following support ticket using exactly one label: account_access, billing, or product_defect. Return the label and a brief reason. Ticket: I reset my password, but the new password still does not let me sign in."
}
]
}'

結果の取得と検証

choices[0].message.content から回答を取得し、実際の finish_reason と usage を確認してください。この例では stop を受け入れます。回答が途中で切れた場合やツール呼び出しが返った場合は、アプリケーション側で別途処理が必要です。チケットの振り分けに使う前に、返されたラベルが許可したラベルのいずれかであることを検証してください。

HTTP 200 が返っても、回答がタスクの要件を満たしているとは限りません。アプリケーション側で内容を検証してください。これらのテキストリクエストは直接結果を返すため、/v1/tasks をポーリングする必要はありません。

GET /v1/models でアカウントが利用できるモデル ID を確認してください。この最小構成の例は、追加の推論設定、サンプリング、キャッシュ制御、ホスト型ツール設定への対応を示すものではありません。