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
- Start a session → Get a
session_id - Push chunks → Send tokens as they arrive
- Finalize → Get the repaired result
POST /v1/repair/stream/start
Start a new streaming session.Request
| Header | Required | Value |
|---|---|---|
Authorization | Yes | Bearer sk_live_xxxxx |
Content-Type | Yes | application/json |
Response
Example
cURL
Response
POST /v1/repair/stream/push
Push a chunk to an active session.Request
| Header | Required | Value |
|---|---|---|
Authorization | Yes | Bearer sk_live_xxxxx |
Content-Type | Yes | application/json |
Response
structurally_complete: Braces balanced, not in string, no incomplete tokenjson_parseable:JSON.parse()will succeedsafe_to_emit: Safe to show to user (parseable + no critical issues)partial: Parsed object (null if not parseable)buffered: Current buffer contentincomplete_token: Held incomplete token (e.g.,"0.")brace_depth: Current nesting depthin_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
| Header | Required | Value |
|---|---|---|
Authorization | Yes | Bearer sk_live_xxxxx |
Content-Type | Yes | application/json |
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 existBUFFER_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
