{"record":{"id":"0f8cf6b826da4e3f","repo":"diegosouzapw/OmniRoute","slug":"codex-hosted-image-generation-returns-one-image-pe","errorCode":null,"errorMessage":"Codex hosted image_generation returns one image per call; requested n=${requestedCount} will fan out in parallel","messagePattern":"Codex hosted image_generation returns one image per call; requested n=(.+?) will fan out in parallel","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"open-sse/handlers/imageGeneration.ts","lineNumber":2571,"sourceCode":"  logPath = \"/v1/images/generations\",\n}) {\n  const startTime = Date.now();\n  const prompt = typeof body.prompt === \"string\" ? body.prompt : \"\";\n  if (!prompt.trim()) {\n    return saveImageErrorResult({\n      provider,\n      model,\n      status: 400,\n      startTime,\n      error: \"Prompt is required for Codex image generation\",\n      path: logPath,\n    });\n  }\n\n  const requestedCount =\n    Number.isInteger(body.n) && (body.n as number) > 0 ? (body.n as number) : 1;\n  if (log && requestedCount > 1) {\n    log.warn(\n      \"IMAGE\",\n      `Codex hosted image_generation returns one image per call; requested n=${requestedCount} will fan out in parallel`\n    );\n  }\n\n  const token = credentials?.accessToken || credentials?.apiKey;\n  if (!token) {\n    return saveImageErrorResult({\n      provider,\n      model,\n      status: 401,\n      startTime,\n      error: \"Codex credentials missing accessToken — reconnect the Codex provider\",\n      path: logPath,\n    });\n  }\n\n  const workspaceId =","sourceCodeStart":2553,"sourceCodeEnd":2589,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/open-sse/handlers/imageGeneration.ts#L2553-L2589","documentation":"Informational notice: the Codex hosted image_generation endpoint produces exactly one image per API call, but the request asked for n>1. The handler transparently fans out n parallel calls to satisfy the request, so latency/cost scale linearly with n — this is a behavior note, not a failure.","triggerScenarios":"Thrown at open-sse/handlers/imageGeneration.ts:2571 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["No fix required — fan-out is automatic","Reduce n if cost/latency of parallel calls is a concern","Batch consciously: n parallel upstream calls consume quota n times"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}