Skip to main content

Crate llm_error_class

Crate llm_error_class 

Source
Expand description

§llm-error-class

Classify provider error responses from Anthropic, OpenAI, Google, and AWS Bedrock into a small set of retriable / non-retriable kinds.

Every provider returns errors in its own shape — Anthropic wraps them in {"type":"error","error":{"type":"...","message":"..."}}, OpenAI in {"error":{"type":"...","code":"..."}}, Bedrock as one of a dozen Java-exception-style names. This crate gives you a single ErrorClass enum and one classify function that handles all four providers via HTTP status + body.

§Example

use llm_error_class::{classify, ErrorClass};
let body = r#"{"error":{"type":"rate_limit_error","message":"slow down"}}"#;
assert_eq!(classify(429, body), ErrorClass::RateLimit);
assert!(classify(429, body).is_retriable());

Enums§

ErrorClass
Provider-agnostic error class.

Functions§

classify
Classify an HTTP error response from any supported provider.