fix(plugins): support OPENAI_IMAGE_API_MODEL env var + base_url config for third-party backends#18796
Open
y0shua1ee wants to merge 1 commit into
Open
Conversation
3 tasks
5992c0b to
815f9f2
Compare
Contributor
Author
|
Rebased and updated this PR against the current What changed in this revision:
Local verification: This should make the PR complementary to #21273 rather than conflicting with it: #21273 forwards CI note after the latest push:
This PR's changed files remain limited to: |
Split the OpenAI image plugin's virtual quality-tier IDs from the actual API model sent in images.generate requests. This keeps gpt-image-2-low/medium/high as UI/config tier selectors while allowing OpenAI-compatible backends to set the real payload model via OPENAI_IMAGE_API_MODEL, image_gen.openai.api_model, or the dispatcher-provided image_gen.model from NousResearch#21273 when it is not one of the virtual tier IDs. Also pass OPENAI_BASE_URL or image_gen.openai.base_url into openai.OpenAI(), and cover the resolver, provider.generate, and dispatcher model forwarding paths with tests. Closes: NousResearch#18793
815f9f2 to
8788925
Compare
Contributor
Author
|
Rebased this PR and refreshed CI. Status after the refresh:
Local verification run before pushing: uv run --with ruff ruff check plugins/image_gen/openai/__init__.py tests/plugins/image_gen/test_openai_provider.py tests/tools/test_image_generation_plugin_dispatch.py
uv run --extra dev --with pytest-xdist python -m pytest tests/plugins/image_gen/test_openai_provider.py tests/tools/test_image_generation_plugin_dispatch.py tests/gateway/test_restart_drain.py::test_restart_command_while_busy_requests_drain_without_interrupt tests/hermes_cli/test_tencent_tokenhub_provider.py::TestTencentTokenhubContextLength::test_hy3_preview_has_registered_context_length -q --tb=short -n 0The previous red checks were from the stale branch state; the fork-comment permission issue in the lint summary path is no longer present on the refreshed run. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
The OpenAI image gen plugin hardcodes
API_MODEL = "gpt-image-2"in the API request payload, making it impossible to use third-party OpenAI-compatible backends (e.g., Krill AI, OpenRouter image endpoints) that expect different model identifiers.Closes #18793
Solution
Three new escape hatches, fully backward-compatible — defaults unchanged:
API model override
OPENAI_IMAGE_API_MODELenv varimage_gen.openai.api_modelconfig keyAPI_MODEL(default:gpt-image-2)Base URL
OPENAI_BASE_URLenv var (standard SDK behaviour)image_gen.openai.base_urlconfig keyNone→ api.openai.comUsage example (Krill AI)
Or via env var:
export OPENAI_IMAGE_API_MODEL=gpt-image-2-1k-mediumChanges
_resolve_api_model()— resolves the model name for the API request_resolve_base_url()— resolves the base URL for the OpenAI clientgenerate()to use resolved values instead of hardcoded constantsNo breaking changes. Default behaviour unchanged.