Skip to content

Support Responses API#242

Open
Halcyonhal9 wants to merge 2 commits into
mistralai:mainfrom
Halcyonhal9:fix/responses-input-text-chunk-types
Open

Support Responses API#242
Halcyonhal9 wants to merge 2 commits into
mistralai:mainfrom
Halcyonhal9:fix/responses-input-text-chunk-types

Conversation

@Halcyonhal9

@Halcyonhal9 Halcyonhal9 commented Jun 14, 2026

Copy link
Copy Markdown

Accept Responses API input_text/output_text/input_image content types

What

Change _convert_openai_content_chunks to also accept the OpenAI Responses API
content types input_text, output_text (→ TextChunk) and input_image
(→ ImageURLChunk).

Why

ChunkTypes mirrors the OpenAI Chat Completions content types (text,
image_url, ...).

The Responses API
names text and image content differently — input_text/output_text for text
and input_image for images. This means parsing structured Responses content fails
with e.g. 'input_text' is not a valid ChunkTypes /
'input_image' is not a valid ChunkTypes.

This breaks the Responses API for Mistral models served on vLLM. Serving a
Mistral model on vLLM 0.23.0 (with mistral_common 1.11.3) using
--tokenizer-mode mistral and exposing /v1/responses hands request content
straight to mistral_common. A client sending the standard Responses input
shape — {"type": "input_text", "text": "..."} or
{"type": "input_image", "image_url": "..."}, which the official OpenAI client
libraries emit — gets an HTTP 400, making /v1/responses unusable for text
and image input alike.

The proposed change

Map the Responses content-type spellings onto their Chat Completions
equivalents in _convert_openai_content_chunks via a small alias table
(input_text/output_texttext, input_imageimage_url). The chunk's
type field is rewritten because the discriminated chunk models require the
canonical type; input_image's image_url is a bare string, which
ImageURLChunk already accepts.

Tests / checks

  • Regression tests for text (input_text/output_text) and image
    (input_image) content.
  • pytest tests/test_converters.py → 116 passed.
  • ruff check, ruff format --check, mypy → all clean.

A patched version of mistral_common 1.11.3 was tested on vLLM 0.23.0, using hf model mistralai/Mistral-Medium-3.5-128B and the responses api.

Halcyonhal9 and others added 2 commits June 13, 2026 17:20
ChunkTypes mirrors the OpenAI Chat Completions content types ("text",
"image_url", ...). The OpenAI Responses API spells text and image content
differently — "input_text"/"output_text" for text and "input_image" for
images — so parsing structured Responses content raised e.g.
"'input_text' is not a valid ChunkTypes" / "'input_image' is not a valid
ChunkTypes" (surfacing as a 400 when a model is served behind an
OpenAI-compatible Responses endpoint).

Map the Responses content type spellings onto their Chat Completions
equivalents in _convert_openai_content_chunks via a small alias table
(input_text/output_text -> text, input_image -> image_url). The chunk's type
field is rewritten because the discriminated chunk models require the canonical
type; input_image's image_url is a bare string, which ImageURLChunk already
accepts. Adds regression tests for text and image.
Resolve conflicts from mistralai#241 (consolidated ContentChunk, removed
UserContentChunk) and mistralai#245 (audio data URL handling):
- chunk.py: apply Responses-API content-type aliases on top of the
  consolidated ContentChunk; drop the removed UserContentChunk alias.
- tests/test_converters.py: keep both ChunkTypes and ContentChunk imports.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Halcyonhal9 Halcyonhal9 changed the title Accept Responses API input_text/output_text/input_image content types Support Responses API Jun 20, 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.

1 participant