From 90509c9accca71a36dd66d0c475296ede1e461e7 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 16 Jul 2026 22:29:41 +0000 Subject: [PATCH] feat(rust-gateway): normalize OCR response model to requested alias Echo the caller's requested model alias in the public OCR response instead of the deployment's provider model, matching the Python OCR proxy so the Axum route is a drop-in and does not surface the underlying provider model name. Also treat empty or whitespace-only deployment credentials as absent. Co-Authored-By: Ishaan Jaffer <155045088+ishaan-berri@users.noreply.github.com> --- .../crates/ai-gateway/src/routes/ocr/mod.rs | 2 +- .../ai-gateway/src/routes/ocr/service.rs | 22 ++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/litellm-rust/crates/ai-gateway/src/routes/ocr/mod.rs b/litellm-rust/crates/ai-gateway/src/routes/ocr/mod.rs index 2d35dbd3ed3..1e6a43860fa 100644 --- a/litellm-rust/crates/ai-gateway/src/routes/ocr/mod.rs +++ b/litellm-rust/crates/ai-gateway/src/routes/ocr/mod.rs @@ -291,7 +291,7 @@ mod tests { assert_eq!(response.status(), reqwest::StatusCode::OK, "path {path}"); let body: Value = response.json().await.expect("json body"); assert_eq!(body["object"], "ocr", "path {path}"); - assert_eq!(body["model"], "mistral-ocr-latest", "path {path}"); + assert_eq!(body["model"], "rust-ocr-mistral", "path {path}"); assert_eq!(body["pages"][0]["markdown"], "hello ocr", "path {path}"); let upstream_request = upstream_handle.await.expect("upstream served"); diff --git a/litellm-rust/crates/ai-gateway/src/routes/ocr/service.rs b/litellm-rust/crates/ai-gateway/src/routes/ocr/service.rs index 2b011ac9d0f..5f6993501e2 100644 --- a/litellm-rust/crates/ai-gateway/src/routes/ocr/service.rs +++ b/litellm-rust/crates/ai-gateway/src/routes/ocr/service.rs @@ -35,17 +35,29 @@ pub async fn run_ocr(router: &Router, call: OcrCall) -> CoreResult { let params = &deployment.litellm_params; let (provider, provider_model) = split_provider(¶ms.model)?; - ocr(OcrRequest { + let OcrCall { + model: requested_model, + document, + optional_params, + timeout, + } = call; + + let mut response = ocr(OcrRequest { model: provider_model, - document: call.document, + document, api_key: present(params.api_key.as_deref()), api_base: present(params.api_base.as_deref()), custom_llm_provider: provider, extra_headers: None, - optional_params: call.optional_params, - timeout: call.timeout, + optional_params, + timeout, }) - .await + .await?; + + if let Value::Object(map) = &mut response { + map.insert("model".to_string(), Value::String(requested_model)); + } + Ok(response) } #[cfg(test)]