Skip to main content
Fast, type-safe implementation using Axum with async/await and Tokio runtime. Tested end-to-end with MIPRO - achieves 100% accuracy on Banking77.

Quick Start

cd examples/polyglot/rust/
cargo run --release
With authentication:
ENVIRONMENT_API_KEY=your-secret cargo run --release

Dependencies

[dependencies]
axum = "0.7"
tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
reqwest = { version = "0.11", features = ["json"] }
anyhow = "1"
tracing = "0.1"
tracing-subscriber = "0.3"

URL Construction

The most critical part is URL construction with query parameters. The inference_url from the optimizer includes query params for tracing:
// CORRECT: Insert path before query string
let url = if let Some(query_start) = inference_url.find('?') {
    let (base, query) = inference_url.split_at(query_start);
    format!("{}/chat/completions{}", base.trim_end_matches('/'), query)
} else {
    format!("{}/chat/completions", inference_url.trim_end_matches('/'))
};

// Result: http://host/path/chat/completions?cid=xxx

Cross-Compilation

# Linux
cargo build --release --target x86_64-unknown-linux-gnu

# macOS ARM64
cargo build --release --target aarch64-apple-darwin

# Windows
cargo build --release --target x86_64-pc-windows-gnu

When to Choose Rust

  • You want strong type safety and compile-time guarantees
  • You need async/await for concurrent processing
  • You’re comfortable with Rust’s ownership model

Full Example

rust/src/main.rs