Skip to content

feat: support gpt-image-2 OpenAI image fallback#510

Merged
wyuc merged 3 commits intoTHU-MAIC:mainfrom
xuruiray:feat/support-gpt-image-2
May 4, 2026
Merged

feat: support gpt-image-2 OpenAI image fallback#510
wyuc merged 3 commits intoTHU-MAIC:mainfrom
xuruiray:feat/support-gpt-image-2

Conversation

@xuruiray
Copy link
Copy Markdown
Contributor

Summary

Enable the OpenAI image provider for gpt-image-2 generation when deployments configure the standard OpenAI server environment instead of image-specific variables.

Related Issues

Closes #467

Changes

  • Added an OpenAI image provider fallback that reuses OPENAI_API_KEY and OPENAI_BASE_URL when IMAGE_OPENAI_API_KEY is not configured.
  • Exposed configured image provider model metadata from server provider config.
  • Added provider-config coverage for resolving OpenAI image fallback credentials.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • CI/CD or build changes

Verification

Steps to reproduce / test

  1. Configure OPENAI_API_KEY and optionally OPENAI_BASE_URL without IMAGE_OPENAI_API_KEY.
  2. Fetch server providers and confirm openai-image is available.
  3. Select the OpenAI Image provider and gpt-image-2 for image generation.

What you personally verified

  • pnpm vitest run tests/media/openai-image-adapter.test.ts tests/server/provider-config.test.ts
  • pnpm prettier lib/server/provider-config.ts tests/server/provider-config.test.ts --check
  • pnpm lint -- lib/server/provider-config.ts tests/server/provider-config.test.ts

Evidence

  • CI passes (pnpm check && pnpm lint && npx tsc --noEmit)
  • Manually tested locally
  • Screenshots / recordings attached (if UI changes)

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have added/updated documentation as needed
  • My changes do not introduce new warnings

Summary:
- Enable the OpenAI image provider from standard OpenAI server env vars when image-specific env vars are absent.
- Add provider-config coverage for resolving the fallback API key and base URL.

Rationale:
- Allows gpt-image-2 image generation to work with common OpenAI proxy configuration.

Tests:
- pnpm vitest run tests/media/openai-image-adapter.test.ts tests/server/provider-config.test.ts
- pnpm prettier lib/server/provider-config.ts tests/server/provider-config.test.ts --check
- pnpm lint -- lib/server/provider-config.ts tests/server/provider-config.test.ts

Co-authored-by: Codex <codex@openai.com>
Copy link
Copy Markdown
Contributor

@wyuc wyuc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, LGTM

@wyuc wyuc merged commit 58acad5 into THU-MAIC:main May 4, 2026
2 checks passed
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.

[Feature]: 希望支持 gpt-image-2 模型

2 participants