mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-06-22 04:42:48 +08:00
The OpenAI images path (/v1/images/*) previously called patchCodexCompletedOutput to concatenate collected output_item.done items back into the completed event and then re-parsed that rebuilt JSON to pull out the image results. For multi-megabyte base64 image payloads this produced two extra full-size copies per request (the concatenated output array plus the rebuilt completed event), inflating peak memory under concurrent image generation. Add codexExtractImageResults, which extracts image_generation_call results directly from either the completed event's response.output or the collected items, without the concatenate-and-reparse step. Semantics are preserved: completed output is preferred and collected items are used only when it is empty, matching the original patchCodexCompletedOutput behaviour. patchCodexCompletedOutput remains in use by the text/responses path, which still forwards the patched event downstream. Adds unit tests covering the completed-output path, the ordered fallback to collected items, output preference, fallback list, and the wrong-event-type guard.