Skip to navigation

Streaming

Thêm "stream": true trong body để nhận response dạng Server-Sent Events (SSE).

Ví dụ

curl https://api.tramlabs.io/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TRAM_AI_API_KEY" \
-d '{
"model": "gemini-3.5-flash",
"messages": [{"role": "user", "content": "Hello"}],
"stream": true
}'

Format

Mỗi event có format:

data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"delta":{"content":"Hello"},"index":0}]}
data: [DONE]

Hỗ trợ

Streaming được hỗ trợ trên các endpoint:

EndpointStream support
/v1/chat/completionsYes
/v1/completionsYes
/v1/messagesYes
/v1/responsesYes