fix(translate): normalize image detail "original" to "high" for chat-completions#32
Closed
Samuel86-star wants to merge 1 commit into
Closed
Conversation
…completions
Codex Desktop emits `detail: "original"` on input_image items, but
"original" is not a valid value in the OpenAI Chat Completions API.
Providers like Kimi K2.6 (via Ark) reject it with:
The parameter `messages.content.image_url.detail` specified in the
request are not valid: invalid value: `original`, supported values
are: `low`, `high`, `xhigh`, and `auto`.
The shim's responses-to-chat translation layer (`_chat_image_part`)
was forwarding the detail value verbatim.
Fix: map "original" to "high" (the nearest standard OpenAI value,
"full resolution image"). Any other unrecognised detail value falls
back to "auto" rather than producing a cryptic 400 at the upstream.
Well-known detail values (`low`, `auto`, `high`, `xhigh`) pass
through unchanged so there is zero behaviour change for providers that
already emitted standard values.
Test: `test_responses_to_chat_normalises_original_image_detail`
encodes the contract that detail="original" on input is rewritten to
"high" on output. Full suite: 125 passed (was 124 + 1).
2 tasks
Collaborator
|
Integrated in #36 (image |
Collaborator
|
Closing as superseded — this work was integrated and merged in #36. Thank you for the contribution! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Codex Desktop emits
detail: "original"oninput_imageitems when sendingimages to the shim.
"original"is not a valid value in the OpenAI ChatCompletions API — it is a Codex-internal detail level. When the shim translates
a Responses API request into a chat-completions request and forwards the image
verbatim, providers that strictly validate the
detailfield reject it.Concrete error from Kimi K2.6 via Ark:
This makes the shim's BYOK vision-routing path unusable with any image-capable
model that validates the
detailfield.Solution
_chat_image_part()— the private helper that constructs thechat-completions image part from a Responses API image item — now normalises
the detail value before forwarding it:
"original""high"(the closest standard OpenAI value)"low","high","xhigh","auto""auto"The normalisation uses a simple inline tuple membership check rather than a
module-level constant to keep the fix self-contained. The logic only fires
when a detail value is present and non-standard; standard values pass through
unchanged at zero cost.
Verification
test_responses_to_chat_normalises_original_image_detailencodes theuser-visible contract:
detail="original"on the Responses input sidebecomes
detail="high"on the chat-completions output side.No new dependencies. No behaviour change for providers that already emit
standard detail values.