Skip to content

fix(vision): prefer free-tier voice key for describe_screen (Option B) - #697

Merged
sonichi merged 1 commit into
mainfrom
feat-vision-voice-key-fallback
May 14, 2026
Merged

sonichi merged 1 commit into
mainfrom
feat-vision-voice-key-fallback

Conversation

@sonichi

@sonichi sonichi commented May 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • describeScreenshot() in both src/browser-tools.ts and src/recording-tools.ts now reads GEMINI_VOICE_API_KEY first, falling back to GEMINI_API_KEY.
  • Vision (REST generateContent on gemini-3.1-flash-lite-preview) is free-tier eligible — routes vision off the paid key by default.

Why

Users following the PR #452 voice-key isolation pattern now get vision at $0 instead of metering it on their main key.

Empirical check

  • curl :generateContent?key=\$GEMINI_VOICE_API_KEY with gemini-3.1-flash-lite-preview → HTTP 200, serviceTier: standard (2026-05-14).
  • Live API + image input also works on the voice key via send_client_content + Part(inline_data=Blob) — separate finding, not part of this PR.

Caveats not addressed in this PR

  • describeScreenshot() is duplicated verbatim across the two files — DRY refactor deferred.
  • Free-tier RPM caps under sustained describe_screen load (5s intervals during screen recording) untested. Current code returns an error string on 429 — no automatic fallback to paid key. If sustained recording sessions break, a follow-up should add a 429-retry-on-paid-key path.
  • src/voice-agent.ts header comment (line 14) still calls GEMINI_API_KEY the "vision" key. .env.example (5-16) still implies vision = paid. Doc cleanup deferred to a separate PR.

Test plan

  • With GEMINI_VOICE_API_KEY set: voice-agent describe_screen returns a valid caption.
  • With only GEMINI_API_KEY set: behavior unchanged (fallback).
  • With neither set: error message names both keys.

🤖 Generated with Claude Code

…ck to paid key

describe_screen calls in src/browser-tools.ts and src/recording-tools.ts hit
REST generateContent with VISION_MODEL (default gemini-3.1-flash-lite-preview).
That model + surface is free-tier eligible on AI Studio (verified HTTP 200 with
voice key 2026-05-14). Routing vision through GEMINI_VOICE_API_KEY first means
users with the free-tier voice key isolation pattern (PR #452) get vision at $0
instead of paying out of the main GEMINI_API_KEY quota.

Fallback preserves existing behavior for users who haven't set GEMINI_VOICE_API_KEY.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sonichi
sonichi merged commit c513608 into main May 14, 2026
1 check passed
@sonichi
sonichi deleted the feat-vision-voice-key-fallback branch May 14, 2026 22:18
liususan091219 pushed a commit to liususan091219/sutando-fork that referenced this pull request May 28, 2026
…ck to paid key (sonichi#697)

describe_screen calls in src/browser-tools.ts and src/recording-tools.ts hit
REST generateContent with VISION_MODEL (default gemini-3.1-flash-lite-preview).
That model + surface is free-tier eligible on AI Studio (verified HTTP 200 with
voice key 2026-05-14). Routing vision through GEMINI_VOICE_API_KEY first means
users with the free-tier voice key isolation pattern (PR sonichi#452) get vision at $0
instead of paying out of the main GEMINI_API_KEY quota.

Fallback preserves existing behavior for users who haven't set GEMINI_VOICE_API_KEY.

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.

1 participant