Fix: Codex image support - convert image_url to input_image format (#236)
Cursor sends images as Chat Completions format:
{ type: "image_url", image_url: { url: "data:...", detail: "auto" } }
But Codex Responses API requires:
{ type: "input_image", image_url: "data:..." }
- openai-responses.js: bidirectional conversion image_url <-> input_image
- responsesApiHelper.js: input_image -> image_url in Responses->Chat path
- codex.js: safety net conversion in executor before sending to Codex API
Note: Cursor has a known bug where images bypass the Override OpenAI Base URL
and are sent directly to api.openai.com. This fix is effective for other clients
(curl, Codex CLI, Claude Code) that route through the proxy correctly.
Made-with: Cursor
This commit is contained in:
committed by
GitHub
parent
7195fee2f6
commit
40a53fbd33
@@ -34,6 +34,21 @@ export class CodexExecutor extends BaseExecutor {
|
||||
body.input = [{ type: "message", role: "user", content: [{ type: "input_text", text: "..." }] }];
|
||||
}
|
||||
|
||||
// Normalize image content: image_url → input_image (Responses API format)
|
||||
if (Array.isArray(body.input)) {
|
||||
for (const item of body.input) {
|
||||
if (Array.isArray(item.content)) {
|
||||
item.content = item.content.map(c => {
|
||||
if (c.type === "image_url") {
|
||||
const url = typeof c.image_url === "string" ? c.image_url : c.image_url?.url;
|
||||
return { type: "input_image", image_url: url, detail: c.image_url?.detail || "auto" };
|
||||
}
|
||||
return c;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure streaming is enabled (Codex API requires it)
|
||||
body.stream = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user