Chuyển đến nội dung chính

Hoàn thiện văn bản (Legacy)

POST /v1/completions

Endpoint completion kiểu cổ điển — văn bản vào → văn bản ra (không có cấu trúc hội thoại). Với các dự án mới, hãy ưu tiên Chat Completions.

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

Yêu cầu​

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
}'

Thân yêu cầu​

Tham sốKiểuBắt buộcMô tả
modelstringCóPhải là mô hình kiểu completion
promptstring / arrayCóVăn bản cần tiếp nối; truyền mảng cho các yêu cầu theo lô
streambooleanKhôngXuất dữ liệu dạng stream (SSE), mặc định false
max_tokensnumberKhôngSố token tối đa được sinh ra
temperaturenumberKhôngNhiệt độ lấy mẫu 0–2
top_pnumberKhôngLấy mẫu nucleus
nintegerKhôngSố lượng kết quả completion cần sinh
stopstring / arrayKhôngChuỗi dừng
echobooleanKhôngTrả lại prompt trong kết quả
logprobsintegerKhôngTrả về log probability theo từng token (tối đa 5)
frequency_penalty / presence_penaltynumberKhôngCác hệ số phạt lặp lại
seedintegerKhôngSeed ngẫu nhiên

Phản hồi​

{
"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
}
}
Cảnh báo

Không phải kênh nào cũng có mô hình kiểu completion. Nếu tên mô hình báo lỗi, hãy kiểm tra danh sách khả dụng bằng GET /v1/models trước.