Skip to content

feat: add OpenRouter provider support - #5

Merged
dippatel1994 merged 3 commits into
llmsresearch:mainfrom
nicremo:feat/openrouter-provider
Feb 8, 2026
Merged

feat: add OpenRouter provider support#5
dippatel1994 merged 3 commits into
llmsresearch:mainfrom
nicremo:feat/openrouter-provider

Conversation

@nicremo

@nicremo nicremo commented Feb 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Added OpenRouter as an alternative provider for both VLM and image generation. Needed this for myself since the Google free tier quota runs out pretty quickly — OpenRouter lets you use the same models (Gemini, etc.) with a single API key.

What's new:

  • openrouter VLM provider (text generation via OpenRouter's OpenAI-compatible API)
  • openrouter_imagen image generation provider (uses modalities: ["image", "text"])
  • OPENROUTER_API_KEY config field in Settings

Usage:

paperbanana generate \
  --vlm-provider openrouter \
  --vlm-model google/gemini-2.0-flash-001 \
  --image-provider openrouter_imagen \
  --image-model google/gemini-3-pro-image-preview \
  -i input.txt -o output.png

No changes to existing Gemini providers — purely additive.

Add support for OpenRouter's OpenAI-compatible API as an alternative to
the direct Google Gemini SDK. This allows using any model available on
OpenRouter (Gemini, Claude, GPT, etc.) for both text planning and image
generation via a single OPENROUTER_API_KEY.

New providers:
- openrouter (VLM): text generation via /chat/completions
- openrouter_imagen (ImageGen): image generation via modalities param

Usage:
  --vlm-provider openrouter --vlm-model google/gemini-2.0-flash-001
  --image-provider openrouter_imagen --image-model google/gemini-3-pro-image-preview
Comment thread paperbanana/providers/vlm/openrouter.py Outdated

from __future__ import annotations

import re

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import

  • re isn't used anywhere in this file (it's used in the image gen provider but not here). This will fail ruff check with F401.

Comment thread paperbanana/providers/vlm/openrouter.py Outdated
if self._client is None:
import httpx

self._client = httpx.Client(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking suggestion: since generate() is an async method and httpx has a native async API, it would be cleaner to use httpx.AsyncClient with await client.post(...) here and in the image gen provider. The current synchronous client works but will block the event loop during requests. Not a hard requirement since the existing Gemini providers also use synchronous SDK calls inside async methods, but httpx makes async easy so it would be a nice improvement.

@dippatel1994 dippatel1994 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution, Fabian! This is a clean addition, and the provider pattern looks good.

Minor corrections (if you can address them, that would be great):

  1. Unused import re in the VLM provider (will fail ruff).
  2. Consider using httpx.AsyncClient since httpx has native async support (optional but recommended).

Happy to merge once the unused import is removed. Thanks again @nicremo!

Address PR review feedback:
- Remove unused `import re` from VLM provider (F401)
- Switch both OpenRouter providers from httpx.Client to
  httpx.AsyncClient to avoid blocking the event loop
@nicremo

nicremo commented Feb 7, 2026

Copy link
Copy Markdown
Collaborator Author

Thank you for the feedback! Really happy you like the addition 😊

Just pushed both fixes:

  • Removed the unused re import
  • Switched both providers to httpx.AsyncClient with await — good call, much cleaner this way

Let me know if there's anything else!

@dippatel1994 dippatel1994 added the enhancement New feature or request label Feb 8, 2026
@dippatel1994 dippatel1994 linked an issue Feb 8, 2026 that may be closed by this pull request
1 task
@dippatel1994

Copy link
Copy Markdown
Member

Thanks for the contribution and for the quick fixes!

@dippatel1994
dippatel1994 merged commit 8b39005 into llmsresearch:main Feb 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add OpenRouter VLM providers

2 participants