feat: add OpenAI compatible image generation support #382
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces a new image provider
openai_compatiblethat allows users to connect to any OpenAI-API-compatible image generation endpoint (e.g., LiteLLM, vLLM, Azure OpenAI, or self-hosted gateways). This feature decouples image generation from the text LLM provider, offering greater flexibility for enterprise and self-hosted deployments where image generation might be handled by a separate proxy or service.Key Changes
openai_compatibleto theImageProviderenum.OPENAI_COMPAT_IMAGE_BASE_URLOPENAI_COMPAT_IMAGE_API_KEYOPENAI_COMPAT_IMAGE_MODEL(Strictly required, no default)generate_image_openai_compatiblemethod inImageGenerationService, utilizing the standardAsyncOpenAIclient with a custombase_url.tests/test_image_generation_openai_compatible.pywith comprehensive unit tests for provider selection, successful generation, and error handling for missing config.README.mdwith the new provider options and a specific "Using an OpenAI-Compatible Image Provider" configuration example.How to Test
uv run pytest servers/fastapi/tests/test_image_generation_openai_compatible.py.IMAGE_PROVIDER=openai_compatible OPENAI_COMPAT_IMAGE_BASE_URL=https://api.openai.com/v1 # or your proxy URL OPENAI_COMPAT_IMAGE_API_KEY=sk-proj-.... OPENAI_COMPAT_IMAGE_MODEL=dall-e-3Checklist
test_image_generation_openai_compatible.py)README.md)Closes #381