On this pageStreaming
Back to docs

Streaming

Handle events, usage and terminal errors.

A stream may contain usage events with no choices, completion markers or errors after output has begun. Process each event and check the terminal state; an initial HTTP 200 does not prove completion.

Time to first byte and stream idle timeouts differ from the route maximum of 15 minutes. Clients, proxies or providers may end requests earlier; this is not a promise of 15 minutes for every request.

Streaming

event: content_block_delta
data: {"delta":{"text":"Hello","type":"text_delta"},"index":0,"type":"content_block_delta"}

event: message_delta
data: {"delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":128}}

Response headers

HTTP headersMeaning
x-mientaymedia-request-idRetain x-mientaymedia-request-id when present and the failure time for investigation. Exclude API keys and sensitive payloads from reports.
Retry-AfterHonor Retry-After and use bounded exponential backoff with jitter. Cap attempts and total time. For video jobs that may already exist, look up the job ID before submitting again.
x-mientaymedia-modelActual model processed
x-mientaymedia-model-mapped-fromThe model name you submit, if already mapped
x-mientaymedia-input-tokensCharged input tokens
x-mientaymedia-output-tokensCharged output token
x-mientaymedia-cost-vndCost of call (VND)
x-mientaymedia-price-vnd-per-mtokToken price is applicable
x-mientaymedia-price-vnd-per-requestFixed price per call (if any)

For streaming requests, token/cost headers are not available (cost is only known when the stream ends) — check the Usage page.

Examples receive source review and local checks; this does not establish compatibility with every app version. Check settings, send a small request and confirm usage before production use.

Zalo groupWhatsApp