Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

ci(rust): build and test the ai-gateway server feature

mateo-berricf958c0e6f9f
diff --git a/.github/workflows/test-rust.yml b/.github/workflows/test-rust.yml
index 1b71232bc2e..ae80155305a 100644
--- a/.github/workflows/test-rust.yml
+++ b/.github/workflows/test-rust.yml
@@ -74,12 +74,18 @@ jobs:
- name: Run Clippy with Bedrock auth
run: cargo clippy -p litellm-core --all-targets --features bedrock-auth --locked -- -D warnings
+ - name: Run Clippy with the gateway server
+ run: cargo clippy -p litellm-ai-gateway --all-targets --features server --locked -- -D warnings
+
- name: Run Rust tests
run: cargo test --workspace --locked
- name: Run core tests with Bedrock auth
run: cargo test -p litellm-core --features bedrock-auth --locked
+ - name: Run gateway tests with the server feature
+ run: cargo test -p litellm-ai-gateway --features server --locked
+
release-wheel:
name: release wheel
runs-on: ubuntu-latest
diff --git a/litellm-rust/CLAUDE.md b/litellm-rust/CLAUDE.md
index 3dcf1853efc..be0fcdd1474 100644
--- a/litellm-rust/CLAUDE.md
+++ b/litellm-rust/CLAUDE.md
@@ -178,6 +178,8 @@ cargo fmt --check
cargo clippy -p litellm-ai-gateway --all-targets --features server -- -D warnings
cargo clippy -p litellm-core -p litellm-python-interop -p litellm-python-bridge --all-targets -- -D warnings
cargo test --workspace
+# the `auth`, `routes`, `state` and `realtime` tests only exist under `server`
+cargo test -p litellm-ai-gateway --features server
```
When a Rust path is exposed through Python, add Python parity tests that compare
diff --git a/litellm-rust/crates/ai-gateway/src/realtime/streaming.rs b/litellm-rust/crates/ai-gateway/src/realtime/streaming.rs
index c32e727de54..edd9338b4f2 100644
--- a/litellm-rust/crates/ai-gateway/src/realtime/streaming.rs
+++ b/litellm-rust/crates/ai-gateway/src/realtime/streaming.rs
@@ -106,16 +106,16 @@ impl RealTimeStreaming {
/// `litellm_call_id`, replacing the gateway-generated fallback.
fn on_session(&mut self, event: &RealtimeEvent) {
let session = event.data.get("session").and_then(Value::as_object);
- if let Some(id) = session.and_then(|s| s.get("id")).and_then(Value::as_str) {
- if !id.is_empty() {
- self.id = id.to_string();
- self.litellm_call_id = id.to_string();
- }
+ if let Some(id) = session.and_then(|s| s.get("id")).and_then(Value::as_str)
+ && !id.is_empty()
+ {
+ self.id = id.to_string();
+ self.litellm_call_id = id.to_string();
}
- if let Some(model) = session.and_then(|s| s.get("model")).and_then(Value::as_str) {
- if !model.is_empty() {
- self.model = model.to_string();
- }
+ if let Some(model) = session.and_then(|s| s.get("model")).and_then(Value::as_str)
+ && !model.is_empty()
+ {
+ self.model = model.to_string();
}
}
diff --git a/litellm-rust/crates/ai-gateway/src/routes/realtime/service.rs b/litellm-rust/crates/ai-gateway/src/routes/realtime/service.rs
index b8ee77c4269..f7bbb37dff4 100644
--- a/litellm-rust/crates/ai-gateway/src/routes/realtime/service.rs
+++ b/litellm-rust/crates/ai-gateway/src/routes/realtime/service.rs
@@ -50,18 +50,17 @@ where
provider_model,
params.api_key.as_deref(),
params.api_base.as_deref(),
- ) {
- if let Some(handoff) = pool.take(&key) {
- return crate::io::realtime::realtime_warm(
- provider_model,
- handoff,
- idle_timeout,
- observe,
- client_in,
- client_out,
- )
- .await;
- }
+ ) && let Some(handoff) = pool.take(&key)
+ {
+ return crate::io::realtime::realtime_warm(
+ provider_model,
+ handoff,
+ idle_timeout,
+ observe,
+ client_in,
+ client_out,
+ )
+ .await;
}
// Cold path: fresh dial (the original behavior).