llmrix-rust-sdk 1.0.0

Official Rust SDK for the llmrix AI Agent Platform API
Documentation
use thiserror::Error;

/// All errors returned by the Llmrix SDK.
#[derive(Debug, Error)]
pub enum LlmrixError {
    /// Low-level HTTP / connection failure.
    #[error("HTTP transport error: {0}")]
    Transport(#[from] reqwest::Error),

    /// JSON serialization or deserialization failure.
    #[error("JSON error: {0}")]
    Json(#[from] serde_json::Error),

    /// The server returned a 4xx or 5xx status.
    /// Inspect `status` to branch on specific codes (e.g. 404, 429).
    #[error("API error {status}: {message}")]
    Api {
        status: u16,
        message: String,
        body: String,
    },

    /// Returned on HTTP 401 (invalid API key) or 503
    /// (server running in native mode without auth configured).
    #[error("Authentication error {status}: {message}")]
    Auth { status: u16, message: String },

    /// Returned when the SSE stream cannot be read or parsed.
    #[error("SSE stream error: {0}")]
    Stream(String),

    /// General SDK-level error.
    #[error("{0}")]
    Other(String),
}

pub type Result<T> = std::result::Result<T, LlmrixError>;