> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.tramlabs.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.tramlabs.io/_mcp/server.

# Streaming

> Sử dụng streaming (SSE) với Trạm AI API

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

## Ví dụ

```bash
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:

| Endpoint               | Stream support |
| ---------------------- | -------------- |
| `/v1/chat/completions` | Yes            |
| `/v1/completions`      | Yes            |
| `/v1/messages`         | Yes            |
| `/v1/responses`        | Yes            |