Skip to content

fix(openai): support image edit accounting and task image responses#2266

Open
Brisbanehuang wants to merge 2 commits intoWei-Shaw:mainfrom
Brisbanehuang:fix/openai-image-task-responses
Open

fix(openai): support image edit accounting and task image responses#2266
Brisbanehuang wants to merge 2 commits intoWei-Shaw:mainfrom
Brisbanehuang:fix/openai-image-task-responses

Conversation

@Brisbanehuang
Copy link
Copy Markdown

Summary

  • Count image_edit.completed SSE events as completed image outputs while continuing to ignore partial edit image events.
  • Support OpenAI-compatible image providers that return asynchronous task responses from /v1/images/generations: detect task_id, poll /v1/tasks/{task_id}, download final image URLs, and convert them back to OpenAI Images-compatible b64_json responses.
  • Add tests for both image_edit.completed accounting and task-based image generation results.

This helps with providers such as APIMart whose gpt-image-2 generation endpoint returns a task object first, with final images available through the task status endpoint. Docs: https://docs.apimart.ai/cn/api-reference/images/gpt-image-2/generation

Tests

  • go test ./internal/service -run 'TestOpenAIImageOutputCounter|TestOpenAIGatewayServiceForwardImages_APIKeyGenerationPollsTaskResult|TestOpenAIGatewayServiceForwardImages_APIKeyGenerationUsesConfiguredV1BaseURL|TestOpenAIGatewayServiceForwardImages_APIKeyStreamJSONResponseBillsImage'\n- go test ./internal/service\n

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

All contributors have signed the CLA. ✅
Posted by the CLA Assistant Lite bot.

@Brisbanehuang
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request May 7, 2026
@Brisbanehuang
Copy link
Copy Markdown
Author

recheck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant