Skip to content

OpenRouterProvider.generate_image 404s with image_config aspect_ratio on gemini-2.5-flash-image #586

@santoshkumarradha

Description

@santoshkumarradha

Summary

generate_image_openrouter in sdk/python/agentfield/vision.py 404s for every request when called with image_config={"aspect_ratio": "9:16"} against google/gemini-2.5-flash-image. Without image_config, the same call succeeds.

OpenRouter's current provider matrix for google/gemini-2.5-flash-image apparently has no upstream replica that exposes the image_config.aspect_ratio parameter, so routing returns empty.

Repro

from agentfield.vision import generate_image_openrouter
await generate_image_openrouter(
    prompt="A vertical portrait",
    model="openrouter/google/gemini-2.5-flash-image",
    size="1024x1024",
    quality="standard",
    style=None,
    response_format="url",
    image_config={"aspect_ratio": "9:16"},
)

Error

litellm.NotFoundError: NotFoundError: OpenrouterException -
{"error":{"message":"No endpoints found that support the requested
output modalities: image, text","code":404}}

(Note: on origin/main the SDK now sends modalities=["image"] only, but the underlying provider-matrix limitation around image_config.aspect_ratio may still cause a 404 for this specific combination.)

Suggested fix

When image_config is non-empty and OpenRouter returns this specific 404 ("No endpoints found that support the requested output modalities..."), either:

  • transparently retry without image_config and surface a warning, or
  • raise a clearer error: "no upstream provider for model X accepts image_config; drop the parameter or pick a different model"

Consumer workaround

reel-af drops image_config entirely, asks for vertical composition in the prompt, and center-crops the square output to 9:16 itself.

Found by the Python SDK consumer reel-af (an AgentField example pipeline).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:aiAI/LLM integrationbugSomething isn't workingsdk:pythonPython SDK related

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions