---
title: "Streaming"
description: "SSE responses, cost trailers, aborts, exhaustion and retries."
canonical_url: "https://minirouter.sh/docs/streaming"
markdown_url: "https://minirouter.sh/docs/streaming.md"
last_updated: "2026-08-04"
---

# Streaming

Set "stream": true on POST https://api.minirouter.sh/v1/chat/completions. Responses are
server-sent events, unbuffered end to end, ending with data: [DONE].

## First request

    curl -N https://api.minirouter.sh/v1/chat/completions \
      -H "Authorization: Bearer $MINIROUTER_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "model": "meta/llama-3.3-70b",
        "messages": [{"role":"user","content":"ping"}],
        "stream": true
      }'

## Cost trailer

The final chunk before [DONE] carries the usage object with usage.cost, the
exact USD charge for the request. Non-streaming responses carry the same field
plus x-minirouter-cost-usd, x-minirouter-provider, x-minirouter-ttft-ms and
x-minirouter-balance-usd headers.

## Aborting a stream

Press Stop and minirouter aborts the upstream immediately. You are charged for
tokens generated before the abort. The usage record is marked
usage_source=estimated_on_abort.

## Mid-stream exhaustion

If the balance reaches $0 mid-stream, the stream ends with an OpenAI-shaped
error chunk whose code is insufficient_credits, followed by [DONE] and a clean
close. Details: https://minirouter.sh/docs/errors#insufficient_credits

## Retries

Before the first content byte, minirouter retries another upstream
automatically. After it, the route is committed. See
https://minirouter.sh/docs/failover.
