feat(codex): add GPT Image 2.5, Flare and Sunburst image models
- Add gpt-image-1.5, gpt-image-2, gpt-image-2.5, gpt-image-2.5-flare and gpt-image-2.5-sunburst as Codex image models with multi-image support - Add gpt-image-2.5, gpt-image-2.5-flare and gpt-image-2.5-sunburst to the OpenAI provider catalog - Route tool-backed image models through the Codex responses model while passing the selected model to the image_generation tool, pinning tool_choice and deriving generate/edit from the presence of references - Cover the Codex gpt-image-2.5 request shape with a unit test
This commit is contained in:
@@ -367,6 +367,47 @@ describe("handleImageGenerationCore", () => {
|
||||
expect(responseBody.data[0].b64_json).toBe("base64codeximage");
|
||||
});
|
||||
|
||||
it("generates image with Codex gpt-image-2.5 tool model", async () => {
|
||||
global.fetch.mockResolvedValueOnce(
|
||||
new Response(
|
||||
[
|
||||
"event: response.output_item.done",
|
||||
'data: {"item":{"type":"image_generation_call","result":"base64codeximage"}}',
|
||||
"",
|
||||
"",
|
||||
].join("\n"),
|
||||
{ status: 200, headers: { "Content-Type": "text/event-stream" } }
|
||||
)
|
||||
);
|
||||
|
||||
const result = await handleImageGenerationCore({
|
||||
body: {
|
||||
prompt: "A futuristic city",
|
||||
size: "1024x1024",
|
||||
output_format: "png",
|
||||
},
|
||||
modelInfo: { provider: "codex", model: "gpt-image-2.5" },
|
||||
credentials: {
|
||||
accessToken: "codex-token",
|
||||
providerSpecificData: { chatgptAccountId: "account-123" },
|
||||
},
|
||||
log: null,
|
||||
});
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
const fetchCall = global.fetch.mock.calls[0];
|
||||
const requestBody = JSON.parse(fetchCall[1].body);
|
||||
expect(requestBody.model).toBe("gpt-5.5");
|
||||
expect(requestBody.tools).toEqual([
|
||||
{ type: "image_generation", output_format: "png", size: "1024x1024", action: "generate", model: "gpt-image-2.5" },
|
||||
]);
|
||||
expect(requestBody.tool_choice).toEqual({ type: "image_generation" });
|
||||
expect(requestBody.reasoning).toEqual({ effort: "medium", summary: "auto" });
|
||||
|
||||
const responseBody = await result.response.json();
|
||||
expect(responseBody.data[0].b64_json).toBe("base64codeximage");
|
||||
});
|
||||
|
||||
it("generates image with Cloudflare Workers AI JSON response", async () => {
|
||||
global.fetch.mockResolvedValueOnce(
|
||||
new Response(
|
||||
|
||||
Reference in New Issue
Block a user