Skip to content

fix(ocr): add missing Mistral OCR params to allowlist#25858

Merged
krrish-berri-2 merged 1 commit intoBerriAI:litellm_internal_stagingfrom
michelligabriele:litellm_fix-mistral-ocr-missing-params
Apr 17, 2026
Merged

fix(ocr): add missing Mistral OCR params to allowlist#25858
krrish-berri-2 merged 1 commit intoBerriAI:litellm_internal_stagingfrom
michelligabriele:litellm_fix-mistral-ocr-missing-params

Conversation

@michelligabriele
Copy link
Copy Markdown
Collaborator

Relevant issues

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/test_litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

CI (LiteLLM team)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • Branch creation CI run
    Link:

  • CI run for the last commit
    Link:

  • Merge / cherry-pick CI run
    Links:

Screenshots / Proof of Fix

table_format, confidence_scores_granularity, document_annotation_prompt, and id are documented Mistral OCR API parameters that were missing from MistralOCRConfig.get_supported_ocr_params(). Because the OCR pipeline uses this allowlist to filter kwargs, these params were silently dropped before reaching the Mistral API.

Before: passing table_format="html" to litellm.ocr() → param silently dropped, Mistral defaults to markdown tables
After: param passes through the allowlist → included in the request body → Mistral returns HTML tables as requested

Type

🐛 Bug Fix

Changes

  • Added 4 missing params to the allowlist in MistralOCRConfig.get_supported_ocr_params(): document_annotation_prompt, table_format, confidence_scores_granularity, id
  • Updated docstring to document the new params
  • Added 3 new test classes covering all pipeline stages (allowlist → mapping → request transformation)

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Apr 16, 2026 1:49pm

Request Review

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 16, 2026

Greptile Summary

This PR adds four previously missing Mistral OCR API parameters — document_annotation_prompt, table_format, confidence_scores_granularity, and id — to MistralOCRConfig.get_supported_ocr_params() so they are no longer silently dropped before reaching the Mistral API. The change is isolated to the allowlist, the docstring, and a well-structured test file that covers all three pipeline stages (allowlist → mapping → request body) with fully local tests and no real API calls.

Confidence Score: 5/5

Safe to merge — minimal, targeted allowlist addition with comprehensive mock tests and no side-effects on other code paths.

All changes are a straightforward additive fix to a string list plus docstring updates. Tests cover all three pipeline stages (allowlist, mapping, request body), are fully local with no real API calls, and existing test assertions are unchanged in behavior (only Black-reformatted). No custom rules are violated.

No files require special attention.

Important Files Changed

Filename Overview
litellm/llms/mistral/ocr/transformation.py Adds 4 missing params to get_supported_ocr_params() allowlist and updates the docstring; no logic changes elsewhere.
tests/test_litellm/llms/mistral/ocr/test_mistral_ocr_transformation.py Adds three new test classes covering the full param pipeline (allowlist, mapping, request body); existing test only reformatted by Black with no behavioral change.

Sequence Diagram

sequenceDiagram
    participant Caller as litellm.ocr()
    participant Pipeline as OCR Pipeline
    participant Config as MistralOCRConfig
    participant Mistral as Mistral API

    Caller->>Pipeline: ocr(model, document, table_format="html", id="req-123", ...)
    Pipeline->>Config: get_supported_ocr_params(model)
    Config-->>Pipeline: ["pages", ..., "table_format", "confidence_scores_granularity", "document_annotation_prompt", "id"]
    Note over Pipeline: kwargs filtered against allowlist
    Pipeline->>Config: map_ocr_params(non_default_params, optional_params, model)
    Config-->>Pipeline: {table_format: "html", id: "req-123", ...}
    Pipeline->>Config: transform_ocr_request(model, document, optional_params, headers)
    Config-->>Pipeline: OCRRequestData(data={model, document, table_format, id, ...})
    Pipeline->>Mistral: POST /v1/ocr {model, document, table_format="html", id="req-123", ...}
    Mistral-->>Pipeline: OCR response
Loading

Reviews (1): Last reviewed commit: "fix(ocr): add missing Mistral OCR params..." | Re-trigger Greptile

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@krrish-berri-2
Copy link
Copy Markdown
Contributor

@michelligabriele — could you add a screenshot or short video showing that this change works as expected? The before/after text explanation is helpful, but a visual demo (e.g., showing the OCR params being passed through correctly) really helps reviewers verify the fix quickly. Thanks!

@krrish-berri-2 krrish-berri-2 merged commit cd92b04 into BerriAI:litellm_internal_staging Apr 17, 2026
43 of 44 checks passed
shiva-manu pushed a commit to shiva-manu/litellm that referenced this pull request Apr 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants