Files
langchain/libs/partners
Akash Choudhary d1a3c3d0a5 feat(mistralai): add image input support for human messages (#37112)
Closes #37007

---

`ChatMistralAI` was POSTing `HumanMessage` content lists verbatim, so
canonical `ImageContentBlock` dicts (`{"type": "image", "url"/"base64":
...}`) reached the Mistral API unchanged and were rejected — the API
expects OpenAI-shape `{"type": "image_url", "image_url": {"url":
"..."}}`. Multimodal inputs failed for both URL and base64 images.

## Changes
- Introduce `_format_message_content` in
`langchain_mistralai.chat_models`, which delegates to
`is_data_content_block` and
`convert_to_openai_data_block(api="chat/completions")` from
`langchain-core`. Reuses the same translator `langchain-openai` and
`langchain-fireworks` (#37090) use, so v0 `source_type` blocks, v1
`url`/`base64` blocks, and `file_id` references are all handled by one
canonical path.
- Route `HumanMessage` content through `_format_message_content` in
`_convert_message_to_mistral_chat_message`. Strings, already-translated
`image_url` blocks, and Mistral-specific blocks (`document_url`,
`input_audio`) pass through unchanged; the API surfaces an error for
anything it doesn't recognize.

---------

Co-authored-by: Akash Choudhary <achoudhary@lenovo.com>
Co-authored-by: Mason Daugherty <github@mdrxy.com>
2026-05-01 17:06:39 -04:00
..

FAQ

Looking for an integration not listed here? Check out the integrations documentation and the note in the libs/ README about third-party maintained packages.

Integration docs

For full documentation, see the primary and API reference docs for integrations.