From c8b0d0ff1eb94e6aa401812d146af90eeaf72760 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Wed, 2 Sep 2026 20:14:42 -0700 Subject: [PATCH] feat: support parameterized ocr responses --- .../crates/core/src/ocr/transformation.rs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/litellm-rust/crates/core/src/ocr/transformation.rs b/litellm-rust/crates/core/src/ocr/transformation.rs index 3d3c16c8cb6..6017fbf0e13 100644 --- a/litellm-rust/crates/core/src/ocr/transformation.rs +++ b/litellm-rust/crates/core/src/ocr/transformation.rs @@ -27,14 +27,17 @@ pub enum OcrResponseHandling { pub trait OcrProviderConfig: Sync { fn supported_ocr_params(&self) -> &'static [&'static str]; - fn map_ocr_params(&self, non_default_params: &Map) -> Map { + fn map_ocr_params( + &self, + non_default_params: &Map, + ) -> Result, Error> { let mut mapped_params = Map::new(); for (param, value) in non_default_params { if self.supported_ocr_params().contains(¶m.as_str()) { mapped_params.insert(param.clone(), value.clone()); } } - mapped_params + Ok(mapped_params) } fn transform_ocr_request( @@ -50,6 +53,15 @@ pub trait OcrProviderConfig: Sync { response_json: Value, ) -> Result; + fn transform_ocr_response_with_params( + &self, + model: &str, + response_json: Value, + _optional_params: &Map, + ) -> Result { + self.transform_ocr_response(model, response_json) + } + fn complete_url( &self, api_base: Option<&str>, @@ -68,6 +80,10 @@ pub trait OcrProviderConfig: Sync { OcrAuthStrategy::Bearer } + fn allows_bearer_auth_fallback(&self) -> bool { + false + } + fn requires_data_uri_document(&self) -> bool { false }