Streaming

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

Ví dụ

$curl https://api.staging.tram.ai.vn/v1/chat/completions \
> -H "Content-Type: application/json" \
> -H "Authorization: Bearer $TRAM_AI_API_KEY" \
> -d '{
> "model": "~openai/gpt-latest",
> "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