agentfield icon indicating copy to clipboard operation
agentfield copied to clipboard

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

Open santoshkumarradha opened this issue 6 months ago • 10 comments

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).

santoshkumarradha avatar May 24 '26 21:05 santoshkumarradha

Hi @santoshkumarradha, I'd like to work on this issue :)

Baradwaz-122 avatar Jul 09 '26 13:07 Baradwaz-122

Thanks for picking this up, @Baradwaz-122! :tada:

Here's what to expect:

  • We'll check in after 7 days if we haven't heard an update
  • After 14 days, we'll send a second reminder
  • After 21 days without activity, we'll unassign to let others contribute

Tips for success:

  • Drop a comment when you start working on it
  • Share any blockers - we're here to help!
  • Link your PR with Fixes #586 in the description

Happy coding! :rocket:

github-actions[bot] avatar Jul 09 '26 14:07 github-actions[bot]

@Baradwaz-122 all yours ! :)

santoshkumarradha avatar Jul 09 '26 14:07 santoshkumarradha

Hey @Baradwaz-122! :wave:

Just a friendly reminder that you're assigned to this issue. It's been about a week since assignment.

How's it going? We'd love to hear:

  • Any progress updates?
  • Running into any blockers we can help with?
  • Need more time? (Totally fine!)

A quick comment helps us know you're still interested. If your plans have changed, no worries at all - just let us know and we can find another contributor.

Thanks for contributing to AgentField! :rocket:

github-actions[bot] avatar Jul 18 '26 10:07 github-actions[bot]

Hi @Baradwaz-122,

Just checking in again! It's been 14 days since we last heard from you on this issue.

Quick options:

  • :speech_balloon: Drop a comment with a progress update
  • :link: Link a draft PR if you've started working on it
  • :wave: Let us know if you'd like to be unassigned (no judgment!)

If we don't hear back in 7 days, we'll unassign this issue to give other contributors a chance to help.

Thanks for understanding!

github-actions[bot] avatar Jul 24 '26 10:07 github-actions[bot]

Hi @santoshkumarradha, sorry for late reply. Found root cause already fixed in vision.py — retry/strip logic (lines 178-219) handles OpenRouter's "No endpoints found" 404 when image_config unsupported upstream, verified via existing test test_generate_image_openrouter_strips_image_config_after_retries. Since fix predates this issue, should I just close referencing that commit, or still open PR

Baradwaz-122 avatar Jul 25 '26 05:07 Baradwaz-122

Hey @Baradwaz-122! :wave:

Just a friendly reminder that you're assigned to this issue. It's been about a week since assignment.

How's it going? We'd love to hear:

  • Any progress updates?
  • Running into any blockers we can help with?
  • Need more time? (Totally fine!)

A quick comment helps us know you're still interested. If your plans have changed, no worries at all - just let us know and we can find another contributor.

Thanks for contributing to AgentField! :rocket:

github-actions[bot] avatar Aug 01 '26 10:08 github-actions[bot]

Hi @Baradwaz-122,

Just checking in again! It's been 14 days since we last heard from you on this issue.

Quick options:

  • :speech_balloon: Drop a comment with a progress update
  • :link: Link a draft PR if you've started working on it
  • :wave: Let us know if you'd like to be unassigned (no judgment!)

If we don't hear back in 7 days, we'll unassign this issue to give other contributors a chance to help.

Thanks for understanding!

github-actions[bot] avatar Aug 08 '26 09:08 github-actions[bot]

Hi @Baradwaz-122,

It's been 21 days since the last update on this issue. To keep the project moving, we've unassigned this issue so other contributors can pick it up.

No worries at all! Life happens, and we totally understand. If you'd like to continue working on this, just comment here and we'll reassign it to you.

This issue is now available for anyone who'd like to contribute. Check out our contribution guidelines if you're interested!

Thanks for your interest in AgentField! :heart:

github-actions[bot] avatar Aug 15 '26 09:08 github-actions[bot]

@Baradwaz-122 good find on vision.py:178-219 — that logic is real and its test passes. But it's unreachable: generate_image_openrouter has had no caller inside the SDK since #619 (v0.1.90) rewrote OpenRouterProvider.generate_image into a direct aiohttp POST and dropped the delegation, a week after #600 (v0.1.85) added the retry/strip. So the repro in this issue (importing straight from agentfield.vision) was fixed, but the path anyone actually hits — app.ai_generate_image(model="openrouter/...") → MediaRouter → OpenRouterProvider.generate_image — still raised on the first 404 with no retry and no image_config strip.

#967 ports the retry into the provider path (matching the "No endpoints found" marker against the 404 response body, three attempts with backoff, then one attempt with image_config removed), with provider-level tests against the aiohttp fake. Same PR covers #588, since it's the same block. Closing via #967.

AbirAbbas avatar Aug 26 '26 16:08 AbirAbbas