Streaming

Server-sent events on every endpoint

Enabling streaming

Set "stream": true on a request to either /v1/chat/completions or /v1/responses. Responses come back as standard OpenAI-compatible server-sent events.

$curl https://api.singularityapi.dev/v1/chat/completions \
> -N \
> -H "Authorization: Bearer $SINGULARITY_API_KEY" \
> -H "Content-Type: application/json" \
> -d '{
> "model": "deepseek-v4-flash",
> "messages": [{"role": "user", "content": "Say hello."}],
> "stream": true
> }'

Usage in the stream

  • On /v1/chat/completions, the platform automatically sets stream_options.include_usage, so the final chunk carries token usage — you don’t need to set this yourself.
  • On /v1/responses, nothing is injected; standard Responses-API streaming semantics apply.

Receipts and streams

Receipt headers (x-singularity-request-id, x-singularity-receipt-id) arrive with the start of the response, before any content streams. The receipt itself settles to its final cost shortly after the stream terminates.

Fetch the receipt after the stream ends for the exact cost — usage and total_cost_usd are null until the request is terminal.

Timeouts

The ~230-second request deadline applies to the entire stream, from first byte to last. Workflows that need longer than that should chain multiple calls rather than rely on one long stream.