You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds imageGenerate support to the OpenRouter provider, wiring it to OpenRouter's dedicated image generation endpoint (POST https://openrouter.ai/api/v1/images), which is OpenAI-Images-compatible.
src/providers/openrouter/api.ts: route imageGenerate to /v1/images (resolves to https://openrouter.ai/api/v1/images).
src/providers/openrouter/imageGenerate.ts (new): request config mapping OpenAI Images params (prompt, model, n 1-10, size) plus OpenRouter-specific params (seed, aspect_ratio, resolution, input_references for image-to-image). response_format is intentionally not mapped — OpenRouter always returns base64 (b64_json) and ignores/strips unknown params. Response transform follows the OpenAI/Deepbricks pattern: pass through the already-OpenAI-shaped success body ({created, data: [{b64_json}], usage}), and normalize upstream errors via OpenAIErrorResponseTransform (OpenRouter errors are {error: {message, code}}).
src/providers/openrouter/index.ts: register the config and response transform.
Tests Run/Test cases added: (required)
Live end-to-end through a locally running gateway (tsx src/start-server.ts) with a real OpenRouter API key against google/gemini-2.5-flash-image:
POST /v1/images/generations with {model, prompt, n: 1} → 200, data[0].b64_json decodes to a valid PNG (checked magic bytes), usage passed through.
size: "1024x1024" passthrough → 200, valid PNG.
Error normalization: unknown model → 404 {"error":{"message":"openrouter error: No model found...","code":404},"provider":"openrouter"}; conflicting size + aspect_ratio → 400 with OpenRouter's message, both in the gateway's standard error shape.
tsc --noEmit (no new errors; two pre-existing errors in bytez/open-ai-base untouched), npm run build succeeds, prettier --check clean, npm run test:gateway results identical to main (47 passed; the 8 pre-existing suite failures on main are unchanged).
Type of Change:
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to not work as expected)
This adds imageGenerate support to the OpenRouter provider, routed to OpenRouter's dedicated OpenAI-Images-compatible endpoint (POST /api/v1/images). It follows the existing OpenAI/Deepbricks pattern: map the OpenAI Images params (plus OpenRouter extras seed/aspect_ratio/resolution/input_references) and normalize upstream errors via OpenAIErrorResponseTransform. Like every other provider here, model is a passthrough param, so this exposes all of OpenRouter's image models with no hardcoded list to maintain.
Verified locally: tsc --noEmit clean on the new files (the 2 pre-existing bytez/open-ai-base errors are untouched), npm run build succeeds, and prettier --check passes on all 3 changed files (the CI formatting check should go green once the fork-PR workflow is approved to run). Happy to adjust anything.
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
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: (required)
imageGeneratesupport to the OpenRouter provider, wiring it to OpenRouter's dedicated image generation endpoint (POST https://openrouter.ai/api/v1/images), which is OpenAI-Images-compatible.src/providers/openrouter/api.ts: routeimageGenerateto/v1/images(resolves tohttps://openrouter.ai/api/v1/images).src/providers/openrouter/imageGenerate.ts(new): request config mapping OpenAI Images params (prompt,model,n1-10,size) plus OpenRouter-specific params (seed,aspect_ratio,resolution,input_referencesfor image-to-image).response_formatis intentionally not mapped — OpenRouter always returns base64 (b64_json) and ignores/strips unknown params. Response transform follows the OpenAI/Deepbricks pattern: pass through the already-OpenAI-shaped success body ({created, data: [{b64_json}], usage}), and normalize upstream errors viaOpenAIErrorResponseTransform(OpenRouter errors are{error: {message, code}}).src/providers/openrouter/index.ts: register the config and response transform.Tests Run/Test cases added: (required)
tsx src/start-server.ts) with a real OpenRouter API key againstgoogle/gemini-2.5-flash-image:POST /v1/images/generationswith{model, prompt, n: 1}→ 200,data[0].b64_jsondecodes to a valid PNG (checked magic bytes),usagepassed through.size: "1024x1024"passthrough → 200, valid PNG.{"error":{"message":"openrouter error: No model found...","code":404},"provider":"openrouter"}; conflictingsize+aspect_ratio→ 400 with OpenRouter's message, both in the gateway's standard error shape.tsc --noEmit(no new errors; two pre-existing errors inbytez/open-ai-baseuntouched),npm run buildsucceeds,prettier --checkclean,npm run test:gatewayresults identical tomain(47 passed; the 8 pre-existing suite failures onmainare unchanged).Type of Change: