Skip to content

Add retry-on-NotFoundError for intermittent OpenRouter image routing 404s #588

@santoshkumarradha

Description

@santoshkumarradha

Summary

Even without image_config, occasional requests through generate_image_openrouter against google/gemini-2.5-flash-image 404 with:

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

Sequential CLI tests and 7-way concurrent CLI tests succeed 100% of the time, but during long pipeline runs we see ~1-3% of frame generations fail with this error. Likely cause: OpenRouter routing momentarily lands on an upstream replica that does not expose image modality.

Suggested fix

Retry on NotFoundError from generate_image_openrouter when the error message matches the "No endpoints found that support the requested output modalities" shape. 3 retries with exponential backoff would mask the routing blip transparently.

This is conceptually similar to the existing MAX_POLL_RETRIES logic in generate_video for 502/503/504 — same idea, different error class.

Consumer workaround

reel-af wraps provider.generate_image(...) in a 4-retry loop with exponential backoff in video_gen._gen_first_frame, plus a placeholder-frame fallback so a permanently-failing shot does not take down the whole reel. That logic belongs in the SDK so every consumer benefits.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:aiAI/LLM integrationenhancementNew feature or requestsdk: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