//! Basic HTTP server example using rtx-serving-api //! //! This example demonstrates how to start a basic HTTP server with all //! the serving API endpoints. Run with: //! //! ```bash //! cargo run --example basic_server //! ``` //! //! Then test with: //! - Health check: `curl http://localhost:8080/health` //! - List models: `curl http://localhost:8080/v1/models` //! - Inference: `curl -X POST http://localhost:8080/v1/completions -H "Content-Type: application/json" -d '{"model": "test-model", "prompt": "Hello, world!"}'` use rtx_serving_api::{ServerConfig, ServingServer}; #[tokio::main] async fn main() -> Result<(), Box> { // Initialize tracing for logging tracing_subscriber::fmt::init(); // Create server configuration let config = ServerConfig { host: "127.0.0.1".to_string(), port: 8080, timeout_seconds: 30, }; println!( "Starting rtx-serving-api server on {}:{}", config.host, config.port ); println!("Available endpoints:"); println!(" GET /health - Health check"); println!(" GET /health/ready - Readiness check"); println!(" GET /health/live - Liveness check"); println!(" GET /v1/models - List available models"); println!(" POST /v1/completions - Text completion"); println!(" POST /v1/chat/completions - Chat completion"); // Create and start server let server = ServingServer::new(config); server.serve().await?; Ok(()) }