Completions
POST /v1/completions
Tạo text completion (legacy). Tương thích với OpenAI Completions API.
Request
$ curl https://api.staging.tram.ai.vn/v1/completions \ > -H "Content-Type: application/json" \ > -H "Authorization: Bearer $TRAM_AI_API_KEY" \ > -d '{ > "model": "~openai/gpt-latest", > "prompt": "Once upon a time" > }'
Parameters
| Parameter | Type | Required | Mô tả |
|---|---|---|---|
model | string | Yes | Model ID |
prompt | string | Yes | Text prompt |
stream | boolean | No | Bật streaming (SSE) |
temperature | number | No | Sampling temperature (0-2) |
max_tokens | integer | No | Số token tối đa trong response |
top_p | number | No | Nucleus sampling |
stop | string/array | No | Stop sequences |
Response
1 { 2 "id": "cmpl-...", 3 "object": "text_completion", 4 "created": 1719900000, 5 "model": "~openai/gpt-latest", 6 "choices": [ 7 { 8 "index": 0, 9 "text": " there was a kingdom far, far away.", 10 "finish_reason": "stop" 11 } 12 ], 13 "usage": { 14 "prompt_tokens": 5, 15 "completion_tokens": 10, 16 "total_tokens": 15 17 } 18 }