POST /v1/repair
Fix malformed JSON in a single request. Use this for complete LLM outputs where you have the full string. For token-by-token repair, use streaming endpoints.Request
Headers
| Header | Required | Value |
|---|---|---|
Authorization | Yes | Bearer sk_live_xxxxx |
Content-Type | Yes | application/json |
Body
Parameters
raw_output (string, required)
- The malformed JSON string from your LLM
- Max size: 5MB
- Can include markdown fences, trailing commas, truncated objects
schema (JSONSchema, optional)
- JSON Schema for validation and type coercion
- Shim will coerce types (
"30"→30) - Detect missing required fields
- Remove extra fields in strict mode
mode (string, optional)
"strict": Remove extra fields not in schema (default)"lenient": Keep extra fields
Response
Always returns HTTP 200 with structured envelope. Checksuccess field.
Fields
success (boolean)
true: Repair succeeded, userepairedobjectfalse: Unrecoverable error, checkmetadata.errors
repaired (object | null)
- The fixed JSON object
nullif repair failed
metadata.confidence (string)
"high": Only structural fixes (safe)"medium": Schema repairs or warnings"low": Ambiguous repairs, review carefully"n/a": Reserved (not currently emitted; perfect input returns"high")
metadata.was_repaired (boolean)
true: Shim made changesfalse: Input was already valid
metadata.syntax_repairs (array)
- Structural fixes: missing brackets, trailing commas, markdown fences
- Always safe
metadata.schema_repairs (array)
- Type coercion, field validation
- Review these if confidence is
"medium"or"low"
metadata.warnings (array)
- Non-critical issues
- Repair succeeded but review recommended
metadata.errors (array)
- Critical failures
- Repair failed if this is non-empty
Examples
Basic Repair
cURL
Response
With Schema Validation
cURL
Response
Failed Repair
cURL
Response
Error Codes
See Error Codes Reference for full list. Common errors:INVALID_REQUEST: Missing or invalid parametersPAYLOAD_TOO_LARGE: Input exceeds 5MBUNRECOVERABLE_SYNTAX_ERROR: JSON too malformed to repairSCHEMA_VALIDATION_FAILED: Repaired JSON doesn’t match schema
Rate Limits
| Tier | Limit | Overage |
|---|---|---|
| Free | 1K repairs/month | Degraded service |
| Pro | 100K repairs/month | Degraded service |
| Team | 1M repairs/month | $0.30/1K overage |
Next Steps
Streaming Endpoints
Repair JSON token-by-token
Response Object
Full response schema
Error Codes
Complete error reference
TypeScript SDK
Use the official SDK
