Skip to main content

Streaming Repair Endpoints

Repair JSON token-by-token as it arrives from your LLM. No buffering delays. For complete outputs, use batch repair.

How Streaming Works

  1. Start a session → Get a session_id
  2. Push chunks → Send tokens as they arrive
  3. Finalize → Get the repaired result
Sessions expire after 60 seconds of inactivity.

POST /v1/repair/stream/start

Start a new streaming session.

Request

Headers: Body:

Response

Example

cURL
Response

POST /v1/repair/stream/push

Push a chunk to an active session.

Request

Headers: Body:

Response

State Fields:
  • structurally_complete: Braces balanced, not in string, no incomplete token
  • json_parseable: JSON.parse() will succeed
  • safe_to_emit: Safe to show to user (parseable + no critical issues)
  • partial: Parsed object (null if not parseable)
  • buffered: Current buffer content
  • incomplete_token: Held incomplete token (e.g., "0.")
  • brace_depth: Current nesting depth
  • in_string: Are we inside a string?
  • expected_next: Hints for what might come next

Example

cURL
Response

POST /v1/repair/stream/finalize

Finalize a session and get the repaired result.

Request

Headers: Body:

Response

Same as batch repair response.

Example

cURL
Response

Complete Example


Error Codes

See Error Codes Reference for full list. Common errors:
  • SESSION_NOT_FOUND: Session expired or doesn’t exist
  • BUFFER_SIZE_EXCEEDED: Possible hallucination loop (circuit breaker)
  • SERVICE_UNAVAILABLE: Server at max capacity

Next Steps

Batch Endpoint

Fix complete JSON outputs

TypeScript SDK

Use the official SDK

Streaming Guide

Best practices for streaming

Error Codes

Complete error reference