litellm-rs 0.8.2

A high-performance AI Gateway written in Rust, providing OpenAI-compatible APIs with intelligent routing, load balancing, and enterprise features
Documentation
//! HTTP server implementation
//!
//! This module provides the HTTP server and routing functionality.

// Submodules
pub mod middleware;
pub mod routes;

// New modular server components
pub mod builder;
mod callbacks;
mod config_sync;
mod guardrails;
pub mod http;
mod http_listener;
mod http_runtime;
mod runtime;
pub mod state;
pub(crate) mod tls;
#[cfg(test)]
mod tls_listener_tests;
pub mod types;
mod utils;

pub use http::HttpServer;

#[cfg(test)]
pub(crate) fn valid_test_config() -> crate::config::Config {
    let mut config = crate::config::Config::default();
    config
        .gateway
        .providers
        .push(crate::config::models::provider::ProviderConfig {
            name: "test-openai".to_string(),
            provider_type: "openai".to_string(),
            api_key: "sk-test".to_string(),
            ..Default::default()
        });
    config
}

#[cfg(test)]
mod tests;

#[cfg(test)]
mod http_capacity_tests;

#[cfg(test)]
pub(crate) async fn test_admin_token(state: &state::AppState) -> String {
    use crate::core::models::user::types::{User, UserRole, UserStatus};
    let mut user = User::new(
        "test-admin".into(),
        "admin@example.test".into(),
        String::new(),
    );
    user.role = UserRole::Admin;
    user.status = UserStatus::Active;
    state.storage.database.create_user(&user).await.unwrap();
    state
        .auth
        .jwt()
        .create_access_token(user.id(), user.role.to_string(), vec![], None, None)
        .await
        .unwrap()
}