> For the complete documentation index, see [llms.txt](https://anyint.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://anyint.gitbook.io/docs/features/streaming.md).

# streaming

Streaming is the simplest way to improve perceived latency in chat, copilots, and interactive generation flows.

## Published streaming surfaces

| Surface                | How to enable it                                    |
| ---------------------- | --------------------------------------------------- |
| OpenAI-compatible chat | set `stream: true` on `/openai/v1/chat/completions` |
| Gemini streaming       | call `streamGenerateContent?alt=sse`                |

## When to use streaming

* chat interfaces
* progressive generation in IDEs or copilots
* long-running answer generation where first-token latency matters

## What the stream looks like

* OpenAI-compatible chat returns SSE chunks in `chat.completion.chunk` format
* Gemini streaming uses the published `streamGenerateContent?alt=sse` route
* neither stream should be treated as a final answer until the stream closes

## Implementation tips

* treat each chunk as partial state, not a final answer
* keep your server tolerant to dropped connections
* store the final assembled output if you need auditing or replay
* separate UI rendering from business-side completion logic

## Related pages

* [OpenAI Compatible API](/docs/api-reference/openai-compatible.md)
* [Gemini Compatible API](/docs/api-reference/gemini-compatible.md)
