Skip to main content

Crate liter_llm

Crate liter_llm 

Source
Expand description

Universal LLM API client with provider-agnostic chat, embeddings, files, batches, responses, image generation, transcription, moderation, OCR, rerank, and web-search across 174 providers.

See LlmClient for the high-level streaming client, DefaultClient (native-http only) for the canonical reqwest-backed implementation, and client::ClientConfig for builder-style configuration.

Re-exports§

pub use client::BatchClient;
pub use client::BedrockConfig;
pub use client::BoxFuture;
pub use client::BoxStream;
pub use client::ClientBuilder;
pub use client::ClientConfig;
pub use client::ClientConfigBuilder;
pub use client::FileClient;
pub use client::FileConfig;
pub use client::LlmBudgetConfig;
pub use client::LlmCacheConfig;
pub use client::LlmClient;
pub use client::LlmClientRaw;
pub use client::LlmConfig;
pub use client::LlmInFlightLimitConfig;
pub use client::LlmProviderConfig;
pub use client::LlmRateLimitConfig;
pub use client::ResponseClient;
pub use client::BatchWaitError;
pub use client::WaitForBatchConfig;
pub use client::DefaultClient;
pub use bindings::create_client_with_options;
pub use bindings::ClientOptions;
pub use bindings::create_client;
pub use bindings::create_client_from_json;
pub use error::LiterLlmError;
pub use error::Result;
pub use cost::CatalogInfo;
pub use cost::ModelInfo;
pub use cost::ModelTier;
pub use cost::catalog_info;
pub use cost::completion_cost;
pub use cost::completion_cost_with_cache;
pub use cost::completion_cost_with_cache_details;
pub use cost::exact_model_info;
pub use cost::model_info;
pub use cost::refresh::CatalogRefreshConfig;
pub use cost::refresh::CatalogRefreshError;
pub use cost::refresh::DEFAULT_CATALOG_URL;
pub use cost::refresh::RefreshOutcome;
pub use cost::refresh::clear_catalog_overlay;
pub use cost::refresh::install_catalog_overlay_from_str;
pub use cost::refresh::refresh_catalog;
pub use provider::custom::AuthHeaderFormat;
pub use provider::custom::CustomProviderConfig;
pub use provider::custom::register_custom_provider;
pub use provider::custom::unregister_custom_provider;
pub use provider::AuthConfig;
pub use provider::AuthType;
pub use provider::ProviderCapabilities;
pub use provider::ProviderConfig;
pub use provider::StreamFormat;
pub use provider::all_providers;
pub use provider::capabilities;
pub use provider::complex_provider_names;
pub use realtime::OpenAiRealtimeTranslator;
pub use realtime::RealtimeEnvelope;
pub use realtime::RealtimeEvent;
pub use realtime::RealtimeTranslator;
pub use realtime::ResponseStatus;
pub use tenant::InMemoryKeyResolver;
pub use tenant::KeyResolver;
pub use tenant::KeyResolverError;
pub use tenant::ResolvedKey;
pub use tenant::TenantContext;
pub use tenant::TenantId;
pub use types::*;

Modules§

auth
Per-provider authentication strategies (API keys, AWS SigV4, OAuth tokens).
bindings
FFI-friendly client constructors used by the polyglot bindings. Binding-friendly API surface for FFI/polyglot bindings.
client
High-level LLM client traits and the reqwest-backed client::DefaultClient.
cost
Token-cost tracking helpers. Cost estimation for LLM API calls.
error
Public error types and the crate-wide Result alias. OpenAI-compatible error normalization.
guardrail
Vendor-neutral guardrail plugin system (trait, stage enum, registry, built-in primitives). Guardrail plugin system for liter-llm.
image
Base64 data URL encoding and decoding for inline image payloads.
observability
Canonical per-request usage events and pluggable sinks.
provider
Provider catalog (built-in providers plus runtime registration of custom providers).
realtime
Unified Realtime API event schema and per-provider translator trait. Unified Realtime API types and translator trait for liter-llm.
streaming
Ingress/egress streaming pipeline with zero-copy passthrough optimisation.
tenant
Generic multi-tenant primitives: tenant::TenantId, tenant::TenantContext, tenant::KeyResolver, and tenant::InMemoryKeyResolver. Generic multi-tenant primitives for propagating tenant identity through the Tower request stack.
types
Request/response DTOs shared across providers and bindings.
util
Shared utility helpers (memory-bound guards, etc.). Utility helpers shared across the library.

Structs§

TransportConfig
HTTP transport configuration for reqwest::Client.

Functions§

ensure_crypto_provider
Install the ring crypto provider as the rustls process default, idempotently.