Add OpenRouter as third image generation backend#29
Open
luyao618 wants to merge 1 commit intohtdt:masterfrom
Open
Add OpenRouter as third image generation backend#29luyao618 wants to merge 1 commit intohtdt:masterfrom
luyao618 wants to merge 1 commit intohtdt:masterfrom
Conversation
Adds OpenRouter support to asset_gen.py alongside Gemini and Grok, providing flexible access to any OpenRouter-hosted image model via --model openrouter and --openrouter-model <id>. Key details: - Default model: openai/gpt-5-image-mini (~5¢) - Dynamic cost estimation from OpenRouter /v1/models API, checking per-image, per-request, and per-token pricing in priority order - Adaptive modalities: requests text+image for models that support both, image-only for pure image models (FLUX, Seedream, etc.) - Multi-strategy response parsing (content array, images array, DALL-E style b64_json) - Model catalog cached per process to avoid redundant API calls Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
--model openrouter) alongside Gemini and Grok, providing flexible access to any OpenRouter-hosted image model via--openrouter-model <id>(default:openai/gpt-5-image-mini)./v1/modelsAPI, checkingpricing.image,pricing.request, andpricing.prompt/pricing.completionin priority order — so budget tracking stays accurate regardless of how the model is priced.modalitiesfield per model: requests["image", "text"]for models that support both,["image"]for image-only models (FLUX, Seedream, etc.), preventing rejected requests.choices[].message.content[]image_url entries,choices[].message.images[], and DALL-E-styledata[].b64_json.Why
Gemini and Grok cover most use cases, but having a third backend is useful when:
Changed files
skills/godogen/tools/asset_gen.pyskills/godogen/asset-gen.md--model openrouterand--openrouter-modelskills/godogen/asset-planner.mdREADME.mdOPENROUTER_API_KEYto prerequisitessetup.mdOPENROUTER_API_KEYto API keys sectionTest plan
asset_gen.py image --model openrouter --prompt "red ball" -o test.pngwithOPENROUTER_API_KEYset — verify image generation works--openrouter-model google/gemini-2.5-flash-image— verify custom model selectionOPENROUTER_API_KEY— verify clear error messageset_budget 10then generate with openrouter — verify budget check uses dynamic cost, not flat 5¢budget.jsonlog records actual estimated cost🤖 Generated with Claude Code