Response Format
A successful completion returns a JSON object with the model's output and token usage.
1{
2 "id": "chatcmpl-abc123",
3 "object": "chat.completion",
4 "created": 1700000000,
5 "model": "pai-001",
6 "choices": [
7 {
8 "index": 0,
9 "message": {
10 "role": "assistant",
11 "content": "Hello! How can I help you today?"
12 },
13 "finish_reason": "stop"
14 }
15 ],
16 "usage": {
17 "prompt_tokens": 20,
18 "completion_tokens": 12,
19 "total_tokens": 32
20 }
21}Response Fields
idUnique identifier for the completion.
objectObject type - always "chat.completion".
createdUnix timestamp when the completion was created.
modelThe model that generated the completion.
choicesArray of completion choices. Each has a message and finish_reason.
usageToken counts: prompt_tokens, completion_tokens, total_tokens.
Finish Reasons
stopThe model completed its response naturally or hit a stop sequence.
lengthThe response was cut off due to max_tokens limit.
content_filterContent was filtered by the safety system.
Streaming
When stream: true is set, the response is sent as Server-Sent Events (SSE). Each chunk contains a delta with the next piece of the response.
1data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1700000000,"model":"pai-001","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}
2
3data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1700000000,"model":"pai-001","choices":[{"index":0,"delta":{"content":"!"},"finish_reason":null}]}
4
5data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1700000000,"model":"pai-001","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
6
7data: [DONE]