All errors return JSON with the same structure:
{
"error": "error_code",
"message": "Human-readable description",
"details": { } // optional
}
Success.
Missing or invalid field. Check the required fields in the request body.
Invalid or missing API key. Check the Authorization header.
Insufficient credits. Upgrade your plan or wait for the monthly reset.
Rate limit exceeded. See the Retry-After header for when to retry.
Unexpected error on our end. Retry with exponential backoff.
Check the Retry-After header and implement exponential backoff:
async function callWithRetry(url, body, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
const res = await fetch(url, { method: 'POST', body: JSON.stringify(body) });
if (res.status !== 429) return res;
const retryAfter = res.headers.get('Retry-After') ?? 60;
await new Promise(r => setTimeout(r, retryAfter * 1000 * Math.pow(2, i)));
}
throw new Error('Max retries exceeded');
}
When the validator can't extract the data, use smart_suggestion to re-ask the user in context:
{
"obtained": false,
"extracted_value": null,
"smart_suggestion": "Could you rephrase? I need just your full name, e.g.: 'John Smith'",
"credits_used": 3
}