1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//! # ModelMux - Vertex AI to OpenAI Proxy Library
//!
//! This crate provides a high-performance proxy server that converts OpenAI-compatible
//! API requests to Vertex AI (Anthropic Claude) format. While primarily designed as a
//! binary application, this library exposes its core functionality for programmatic use.
//!
//! ## Library Usage
//!
//! ```rust,no_run
//! use modelmux::{Config, create_app};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Load configuration
//! let config = Config::load()?;
//!
//! // Create the application
//! let app = create_app(config).await?;
//!
//! // Start server
//! let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await?;
//! axum::serve(listener, app).await?;
//!
//! Ok(())
//! }
//! ```
//!
//! ## Modules
//!
//! - [`config`] - Configuration management and environment variable handling
//! - [`provider`] - LLM backend abstraction ([`LlmProviderBackend`]); Vertex and OpenAI-compatible (stub)
//! - [`auth`] - Request auth (GCP OAuth2 or Bearer token)
//! - [`server`] - HTTP server setup and route handlers
//! - [`converter`] - Format conversion between OpenAI and Anthropic formats
//! - [`error`] - Error types and handling
// Re-export commonly used types
pub use Config;
pub use ProxyError;
/// Creates a new ModelMux application with the given configuration.
///
/// This is a convenience function that sets up the full application stack
/// including authentication, routing, and middleware.
///
/// # Arguments
///
/// * `config` - Application configuration
///
/// # Returns
///
/// Returns an Axum Router that can be served directly.
///
/// # Errors
///
/// Returns a `ProxyError` if authentication setup fails or other
/// initialization issues occur.
///
/// # Examples
///
/// ```rust,no_run
/// use modelmux::{Config, create_app};
///
/// #[tokio::main]
/// async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let config = Config::load()?;
/// let app = create_app(config).await?;
///
/// let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await?;
/// axum::serve(listener, app).await?;
/// Ok(())
/// }
/// ```
pub async