Skip to main content

llmix_rs/
lib.rs

1#![forbid(unsafe_code)]
2#![cfg_attr(docsrs, feature(doc_cfg))]
3#![doc = include_str!("../README.md")]
4
5pub mod adaptive_semaphore;
6pub mod canonical_json;
7pub mod config;
8pub mod config_registry;
9pub mod dispatch;
10pub mod error;
11#[cfg(any(
12    feature = "providers-openai",
13    feature = "providers-sno-gpu",
14    feature = "providers-anthropic",
15    feature = "providers-gemini"
16))]
17#[cfg_attr(
18    docsrs,
19    doc(cfg(any(
20        feature = "providers-openai",
21        feature = "providers-sno-gpu",
22        feature = "providers-anthropic",
23        feature = "providers-gemini"
24    )))
25)]
26pub mod providers;
27#[cfg(any(
28    feature = "providers-openai",
29    feature = "providers-sno-gpu",
30    feature = "providers-anthropic",
31    feature = "providers-gemini"
32))]
33#[doc(hidden)]
34pub use providers as helpers;
35pub mod key_pool;
36pub mod pipeline;
37pub mod provider_kwargs;
38pub mod resilience;
39pub mod response_cache;
40pub mod thinking;
41pub mod types;
42
43pub use adaptive_semaphore::{parse_openai_ratelimit_headers, AdaptiveSemaphore, RateLimitHeaders};
44pub use config::{
45    load_config, load_config_preset, load_config_preset_with_options, load_config_with_options,
46    resolve_config_dir, validate_module, validate_preset, validate_version, ConfigDirSource,
47    LlmixPathConfig, MdaConfigLoadOptions, ResolvedConfigDir,
48};
49pub use config_registry::{
50    load_llmix_trust_manifest, registry_root_options_from_trust_manifest,
51    registry_root_options_from_trust_manifest_with_hooks, ConfigRegistryManager,
52    ConfigRegistryOpenOptions, ConfigRegistryPublishOptions, ConfigRegistryPublisher,
53    LlmixTrustManifest, LlmixTrustManifestRegistryRoot, LlmixTrustManifestReleasePlan,
54    PublishedRevision, RegistryRootCurrentBinding, RegistryRootEnvelope, RegistryRootFileDigest,
55    RegistryRootHighWatermark, RegistryRootManifestBinding, RegistryRootPayload,
56    RegistryRootSignature, RegistryRootSigner, RegistryRootSigningInput,
57    RegistryRootSigningOptions, RegistryRootVerificationOptions, LLMIX_TRUST_MANIFEST_KIND,
58    LLMIX_TRUST_MANIFEST_VERSION,
59};
60pub use dispatch::DispatchFn;
61pub use error::{
62    AdaptiveSemaphoreClosedError, CircuitOpenError, ConfigAccessError, ConfigNotFoundError,
63    InvalidConfigError, KeyPoolExhaustedError, KillSwitchActiveError, LlmixError, LlmixResult,
64    ProviderError, SecurityError,
65};
66pub use key_pool::{load_keys_from_env, KeyPool};
67pub use pipeline::{CallPipeline, PipelineConfig};
68pub use provider_kwargs::{
69    apply_transform_kwargs, gemini_transform_kwargs, is_reasoning_model, openai_transform_kwargs,
70    openrouter_transform_kwargs, provider_kwargs_callback, sno_gpu_transform_kwargs,
71    TransformKwargsCallback, TransformKwargsContext, PROVIDER_KWARGS_REGISTRY,
72};
73#[cfg(feature = "providers-anthropic")]
74#[cfg_attr(docsrs, doc(cfg(feature = "providers-anthropic")))]
75pub use providers::anthropic::AnthropicChatHelper;
76#[cfg(feature = "providers-gemini")]
77#[cfg_attr(docsrs, doc(cfg(feature = "providers-gemini")))]
78pub use providers::gemini::GeminiChatHelper;
79#[cfg(feature = "providers-openai")]
80#[cfg_attr(docsrs, doc(cfg(feature = "providers-openai")))]
81pub use providers::openai::OpenAiChatHelper;
82#[cfg(feature = "providers-sno-gpu")]
83#[cfg_attr(docsrs, doc(cfg(feature = "providers-sno-gpu")))]
84pub use providers::sno_gpu::SnoGpuChatHelper;
85pub use resilience::{
86    calculate_delay, is_retryable, parse_retry_after, resolve_state_dir, CircuitBreaker,
87    CircuitState, FileLock, KillSwitch, RetryPolicy, RetryPolicyOptions, SharedCallResult,
88    Singleflight,
89};
90pub use response_cache::{
91    generate_cache_key, is_response_cache_strategy, resolve_response_cache_strategy,
92    should_skip_cache, CacheKeyParams, CacheResult, TwoTierCache, TwoTierCacheConfig,
93    CACHE_KEY_PREFIX,
94};
95pub use snoai_mda_config::{
96    DidWebVerificationInput, DidWebVerifier, MdaConfigError, RekorClient, RekorPolicy,
97    Result as MdaConfigResult, SigstoreVerifier, TrustPolicy, TrustedSigner,
98};
99pub use thinking::{strip_thinking, StripThinkingResult};
100pub use types::{
101    CacheHitTier, CachingStrategy, CallInput, CallResponse, DispatchContext, LlmUsage,
102    ProviderResult, ResponseCacheStats, ResponseCacheStrategy,
103};