# Streaming

Enable streaming on a supported text route and consume the events for that endpoint’s native wire format.

Source: https://zrelay.net/docs/capabilities/streaming/

## Make a streaming request

```
curl -N https://api.zrelay.net/v1/chat/completions \
  -H "Authorization: Bearer $ZRELAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-6.1-sol","messages":[{"role":"user","content":"Hello from Zrelay"}],"max_tokens":256,"stream":true}'
```

## Handle native events

| Endpoint | Stream format |
| --- | --- |
| Chat Completions | Read choices[].delta; [DONE] ends the stream |
| Messages | Anthropic events such as content_block_delta and message_stop |
| Responses | Typed response events; handle both completion and failure |

## Handle interruption

A 200 status starts a stream; it does not prove completion. Handle error events, early disconnects and missing terminal events. Keep the request ID and check request history for confirmed billing before retrying.

A cancelled or interrupted request may still have a confirmed charge. Avoid restarting a whole agent action automatically.

## Use an endpoint-aware client

An SDK can parse event boundaries and partial text for you. See [SDKs and frameworks](https://zrelay.net/docs/md/integrations/sdks.md). Do not assume one network chunk equals one JSON event.
