Skip to content

feat(capture): support OpenRouter as alternative vision provider for image captioning#840

Open
CodAr-man wants to merge 1 commit into
heygen-com:mainfrom
CodAr-man:feat/openrouter-vision-provider
Open

feat(capture): support OpenRouter as alternative vision provider for image captioning#840
CodAr-man wants to merge 1 commit into
heygen-com:mainfrom
CodAr-man:feat/openrouter-vision-provider

Conversation

@CodAr-man
Copy link
Copy Markdown

What this does

Adds OpenRouter as an alternative AI provider for image captioning in hyperframes capture,
alongside the existing Gemini integration.

How it works

Provider is selected at runtime based on which API key is present:

Environment Variable Provider Model
OPENROUTER_API_KEY OpenRouter google/gemma-4-26b-a4b-it
GEMINI_API_KEY / GOOGLE_API_KEY Google Gemini (existing behavior)
Neither No AI captioning (existing DOM-only behavior)

OpenRouter is prioritized if both keys are present.

Why

Not everyone has access to a Gemini API key. OpenRouter provides access to
vision-capable models (including Gemma) with a single unified API, making
this feature accessible to more users.

Backwards compatibility

✅ Purely additive — the Gemini code path is completely untouched.
✅ Users with no API keys see identical behavior to before.
✅ Verified working end-to-end on a real site capture.

Adds OpenRouter alongside Gemini. Provider selected by API key at runtime:
- OPENROUTER_API_KEY set: uses google/gemma-4-26b-a4b-it via OpenRouter
- GEMINI_API_KEY set: existing Gemini behavior (unchanged)
- Neither: existing DOM-only behavior (unchanged)

Purely additive - Gemini code path untouched.
@jrusso1020
Copy link
Copy Markdown
Collaborator

Heads up — GitHub is rendering packages/cli/src/capture/contentExtractor.ts as "Binary file not shown", which is why the diff appears empty (additions: 0, deletions: 0) even though the file is 15.8 KB.

Cause: the file was saved with a UTF-8 BOM and CRLF line endings, while the version on main is UTF-8 (no BOM) with LF. Every line then differs at the byte level even though the substantive change is small, and GitHub's diff renderer falls back to "binary". I diffed locally with -wB and the actual code change is ~30 lines and matches the description (adds the OpenRouter branch; Gemini path untouched) — so this is fixable PR hygiene, not a content problem.

To unblock review, could you:

  1. Re-save the file as UTF-8 without BOM and LF line endings. In VS Code: click CRLF in the bottom status bar → LF; click UTF-8 with BOM → "Save with Encoding" → UTF-8.
  2. git commit --amend && git push --force-with-lease on this branch.

Once that lands the diff will render normally and reviewers can take a real look.

One small thing for the substantive change: the rewrite dropped some of the inline comments around Gemini batching (free-tier 5 RPM vs paid-tier 2000 RPM rationale, the model-override env var note, the per-model benchmark numbers). Those are useful context for future maintainers — worth preserving in the OpenRouter version too.

Separately, I'm opening a .gitattributes PR (* text=auto eol=lf) so this class of issue can't reach a diff again — that's on the repo side, not anything you need to do.

Thanks for the contribution!

lovicho pushed a commit to lovicho/hyperframes that referenced this pull request May 14, 2026
Add `* text=auto eol=lf` so text files are checked in with LF regardless
of the contributor's OS. Without this, Windows editors can save files
with CRLF (and sometimes a UTF-8 BOM), which makes every line differ at
the byte level on diff and trips GitHub's "Binary file not shown"
heuristic — see heygen-com#840 for an example where a ~30-line change was
unreviewable for this reason.

Existing LFS rules already carry `-text` and remain unaffected.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants