Concepts
Safe Fallbacks
When all retries fail, Reliant returns a safe fallback instead of throwing an error — ensuring your application never breaks.
How it works
The safe_fallback is an object you define when creating the schema. If after all attempts the LLM still does not return a valid output, Reliant returns this object with success: false and status: "fallback".
Important: The fallback does not need to pass schema validation. It is returned directly as a last resort.
typescript
const schema = await reliant.createSchema({
name: 'Data Extraction',
slug: 'data-extraction',
definition: {
type: 'object',
required: ['name', 'email'],
properties: {
name: { type: 'string' },
email: { type: 'string' },
}
},
// Fallback returned when all retries fail
safe_fallback: {
name: null,
email: null,
}
})
Detecting fallback usage
You can detect when the fallback was used by checking the status and success of the response:
typescript
const result = await reliant.execute({
prompt: '...',
schemaId: schema.id,
provider: 'anthropic',
model: 'claude-sonnet-4-20250514',
})
if (result.success) {
// Valid output returned by the LLM
console.log('Output:', result.output)
} else if (result.metadata.status === 'fallback') {
// Fallback was used — handle accordingly
console.warn('Fallback used after', result.metadata.attempts, 'attempts')
// result.output contains the safe_fallback defined in the schema
}
Best practices
✅
Always define a fallback
Even if everything is null. It is better to return a predictable empty object than an unexpected error.
🔔
Monitor fallback usage
A high fallback rate indicates the schema is too strict or the prompt is poorly written.
🎯
Fallback with default values
Instead of null, use default values that make sense for your business when data is not available.
📊
Track in the Dashboard
The Dashboard shows the fallback rate separately from the success rate for easy monitoring.