文字補全(舊版)
經典的文字進 → 文字出補全端點(沒有對話結構)。新專案建議使用聊天補全。
请求REQUEST
POST
https://test.kailin.com.cn/v1/completions响应RESPONSE
填写参数并发送请求,响应会显示在这里
請求
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
}'
請求主體參數
| 參數 | 類型 | 必填 | 說明 |
|---|---|---|---|
model | string | 是 | 必須是補全型模型 |
prompt | string / array | 是 | 要續寫的文字;批次請求可傳陣列 |
stream | boolean | 否 | 串流輸出(SSE),預設 false |
max_tokens | number | 否 | 最大生成 token 數 |
temperature | number | 否 | 取樣溫度 0–2 |
top_p | number | 否 | 核心取樣 |
n | integer | 否 | 生成候選數量 |
stop | string / array | 否 | 停止序列 |
echo | boolean | 否 | 是否在結果中回顯 prompt |
logprobs | integer | 否 | 回傳每個 token 的對數機率(最多 5) |
frequency_penalty / presence_penalty | number | 否 | 重複懲罰 |
seed | integer | 否 | 隨機種子 |
回應
{
"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 確認可用清單。