mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
Add Codex GPT 5.5 image support (#991)
This commit is contained in:
@@ -58,6 +58,7 @@ export const PROVIDER_MODELS = {
|
|||||||
{ id: "gpt-5-codex", name: "GPT 5 Codex" },
|
{ id: "gpt-5-codex", name: "GPT 5 Codex" },
|
||||||
{ id: "gpt-5-codex-mini", name: "GPT 5 Codex Mini" },
|
{ id: "gpt-5-codex-mini", name: "GPT 5 Codex Mini" },
|
||||||
// Image models (uses image_generation tool, requires Plus/Pro plan)
|
// Image models (uses image_generation tool, requires Plus/Pro plan)
|
||||||
|
{ id: "gpt-5.5-image", name: "GPT 5.5 Image", type: "image", capabilities: ["text2img", "edit"], params: ["size", "quality", "background", "image_detail", "output_format"] },
|
||||||
{ id: "gpt-5.4-image", name: "GPT 5.4 Image", type: "image", capabilities: ["text2img", "edit"], params: ["size", "quality", "background", "image_detail", "output_format"] },
|
{ id: "gpt-5.4-image", name: "GPT 5.4 Image", type: "image", capabilities: ["text2img", "edit"], params: ["size", "quality", "background", "image_detail", "output_format"] },
|
||||||
{ id: "gpt-5.3-image", name: "GPT 5.3 Image", type: "image", capabilities: ["text2img", "edit"], params: ["size", "quality", "background", "image_detail", "output_format"] },
|
{ id: "gpt-5.3-image", name: "GPT 5.3 Image", type: "image", capabilities: ["text2img", "edit"], params: ["size", "quality", "background", "image_detail", "output_format"] },
|
||||||
{ id: "gpt-5.2-image", name: "GPT 5.2 Image", type: "image", capabilities: ["text2img", "edit"], params: ["size", "quality", "background", "image_detail", "output_format"] },
|
{ id: "gpt-5.2-image", name: "GPT 5.2 Image", type: "image", capabilities: ["text2img", "edit"], params: ["size", "quality", "background", "image_detail", "output_format"] },
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { nowSec } from "./_base.js";
|
|||||||
|
|
||||||
const CODEX_RESPONSES_URL = "https://chatgpt.com/backend-api/codex/responses";
|
const CODEX_RESPONSES_URL = "https://chatgpt.com/backend-api/codex/responses";
|
||||||
const CODEX_USER_AGENT = "codex-imagen/0.2.6";
|
const CODEX_USER_AGENT = "codex-imagen/0.2.6";
|
||||||
const CODEX_VERSION = "0.122.0";
|
const CODEX_VERSION = "0.129.0";
|
||||||
const CODEX_ORIGINATOR = "codex_cli_rs";
|
const CODEX_ORIGINATOR = "codex_cli_rs";
|
||||||
const CODEX_MODEL_SUFFIX = "-image";
|
const CODEX_MODEL_SUFFIX = "-image";
|
||||||
const CODEX_REF_DETAIL = "high";
|
const CODEX_REF_DETAIL = "high";
|
||||||
|
|||||||
@@ -284,6 +284,57 @@ describe("handleImageGenerationCore", () => {
|
|||||||
expect(responseBody.data[0].b64_json).toBeTruthy();
|
expect(responseBody.data[0].b64_json).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("generates image with Codex gpt-5.5-image using current Codex version header", 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 green square",
|
||||||
|
size: "1024x1024",
|
||||||
|
output_format: "png",
|
||||||
|
},
|
||||||
|
modelInfo: { provider: "codex", model: "gpt-5.5-image" },
|
||||||
|
credentials: {
|
||||||
|
accessToken: "codex-token",
|
||||||
|
providerSpecificData: { chatgptAccountId: "account-123" },
|
||||||
|
},
|
||||||
|
log: null,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result.success).toBe(true);
|
||||||
|
expect(global.fetch).toHaveBeenCalledWith(
|
||||||
|
"https://chatgpt.com/backend-api/codex/responses",
|
||||||
|
expect.objectContaining({
|
||||||
|
method: "POST",
|
||||||
|
headers: expect.objectContaining({
|
||||||
|
authorization: "Bearer codex-token",
|
||||||
|
"chatgpt-account-id": "account-123",
|
||||||
|
version: "0.129.0",
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
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" },
|
||||||
|
]);
|
||||||
|
|
||||||
|
const responseBody = await result.response.json();
|
||||||
|
expect(responseBody.data[0].b64_json).toBe("base64codeximage");
|
||||||
|
});
|
||||||
|
|
||||||
it("generates image with Cloudflare Workers AI JSON response", async () => {
|
it("generates image with Cloudflare Workers AI JSON response", async () => {
|
||||||
global.fetch.mockResolvedValueOnce(
|
global.fetch.mockResolvedValueOnce(
|
||||||
new Response(
|
new Response(
|
||||||
|
|||||||
Reference in New Issue
Block a user