Streaming
Merki supports server-sent-events streaming on chat completion endpoints in both API families.
Quick path
- Set
stream: trueon the request. - Consume
data:chunks in order; the stream ends withdata: [DONE]. - On a mid-stream cut, only delivered tokens are billed. Re-issue the request.
Details
| Topic | Decision |
|---|---|
| Shapes | OpenAI-compatible SSE on https://api.merki.dev/v1; Anthropic-compatible SSE on https://api.merki.dev/v1/messages. |
| First token | Time to first token (TTFT) per model is in the model catalog. |
| Mid-stream failure | The stream ends without [DONE]. Treat the partial output as delivered and billed; re-issue for the rest. See Errors and Usage. |
| Caching | A streamed response populates the cache the same way a non-streamed one does. See Caching. |
Checklist
- [ ] Client handles a stream that ends without
[DONE]. - [ ] Partial output is usable or explicitly discarded.
- [ ] Retries create a new request, not a resume.
Next step
Understand what a retry costs: Usage and metering.