Error Handling
The Meter SDK uses exceptions to signal errors. All API-related errors raiseMeterError, which you should catch and handle appropriately.
MeterError
The base exception for all Meter SDK errors.Catching errors
Common error scenarios
401 Unauthorized
Cause: Invalid or missing API key- Verify your API key is correct
- Check that the key hasn’t been deleted
- Ensure you’re using the full key (starts with
sk_live_)
400 Bad Request
Cause: Invalid request parameters- Check all required parameters are provided
- Verify parameter types are correct
- Ensure values are valid (e.g., URL is well-formed)
404 Not Found
Cause: Resource doesn’t exist- Verify the UUID is correct
- Check the resource hasn’t been deleted
- Ensure you have permission to access the resource
429 Too Many Requests
Cause: Rate limit exceeded on strategy generation- Wait before retrying (the API returns a
Retry-Afterheader with seconds to wait) - Reduce request frequency
- Use exponential backoff
500 Internal Server Error
Cause: Server-side error- Retry the request after a short delay
- If persistent, contact support
- Check API status page for incidents
503 Service Unavailable
Cause: LLM service temporarily unavailable- Retry the request after 30-60 seconds
- This is usually temporary
Timeout errors
When waiting for jobs with a timeout:Best practices
Always catch MeterError
Implement retry logic
For transient errors (429, 500, 503, network issues):Graceful degradation
Handle errors without crashing:Log errors for debugging
Error response format
API errors return JSON with details:MeterError exception.
Handling specific error types
Strategy generation failures
Job failures
Error monitoring
Set up error tracking for production:Next steps
MeterClient Reference
Explore all SDK methods
Quick Start
See error handling in practice
Best Practices
Learn SDK best practices
REST API Errors
View REST API error codes