メインコンテンツへスキップ

テキスト補完(レガシー)

POST /v1/completions

古典的な「テキスト入力 → テキスト出力」の補完エンドポイントです(会話構造はありません)。新規プロジェクトでは チャット補完 を推奨します。

RequestREQUEST
POSThttps://test.kailin.com.cn/v1/completions
ResponseRESPONSE
Fill in the request and hit Send — the response shows up here

リクエスト​

curl https://test.kailin.com.cn/v1/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-your-token" \
-d '{
"model": "gpt-3.5-turbo-instruct",
"prompt": "Three keywords about artificial intelligence:",
"max_tokens": 30,
"temperature": 0.8
}'

リクエストボディ​

パラメーター型必須説明
modelstringはい補完系のモデルである必要があります
promptstring / arrayはい続きを生成するテキスト。配列を渡すとバッチリクエストになります
streambooleanいいえストリーム出力(SSE)、デフォルトは false
max_tokensnumberいいえ生成する最大トークン数
temperaturenumberいいえサンプリング温度 0–2
top_pnumberいいえNucleus サンプリング
nintegerいいえ生成する補完の数
stopstring / arrayいいえ終了シーケンス
echobooleanいいえプロンプトを結果にそのまま含めて返す
logprobsintegerいいえトークンごとの対数確率を返す(最大 5)
frequency_penalty / presence_penaltynumberいいえ繰り返しに対するペナルティ
seedintegerいいえランダムシード

レスポンス​

{
"id": "cmpl-xxx",
"object": "text_completion",
"created": 1730000000,
"model": "gpt-3.5-turbo-instruct",
"choices": [
{
"index": 0,
"text": " deep learning, neural networks, and natural language processing.",
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 18,
"total_tokens": 30
}
}
注意

すべてのチャネルで補完系のモデルが提供されているとは限りません。モデル名でエラーが出る場合は、まず GET /v1/models で利用可能な一覧を確認してください。