跳到主要內容

文字補全(舊版)

POST /v1/completions

經典的文字進 → 文字出補全端點(沒有對話結構)。新專案建議使用聊天補全。

请求REQUEST
POSThttps://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
}'

請求主體參數​

參數類型必填說明
modelstring是必須是補全型模型
promptstring / array是要續寫的文字;批次請求可傳陣列
streamboolean否串流輸出(SSE),預設 false
max_tokensnumber否最大生成 token 數
temperaturenumber否取樣溫度 0–2
top_pnumber否核心取樣
ninteger否生成候選數量
stopstring / array否停止序列
echoboolean否是否在結果中回顯 prompt
logprobsinteger否回傳每個 token 的對數機率(最多 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 確認可用清單。