Skip to content

design setup: rejects new-format Gemini API keys ("AQ…"), only accepts "AIza…" #4239

Closed

Description

@slamtanna

Summary

Google AI Studio now issues Gemini API keys that start with AQ. $D setup --provider gemini rejects them:

Invalid key. A Gemini key starts with 'AIza'.

The check is in design/src/cli.ts:

const KEY_PREFIX: Record<ProviderName, string> = { openai: "sk-", gemini: "AIza" };   // line 95
...
if (!key || !key.startsWith(KEY_PREFIX[provider])) {                                    // line 136

The key itself is valid. Writing it straight to ~/.gstack/gemini.json ({"api_key": "AQ…"}), which auth.ts loads without a prefix check, lets Google accept it: requests go through and are billed.

Provider auto-detection has the same assumption (cli.ts:135): with no --provider, an AQ… key is classified as OpenAI and rejected for not starting with sk-.

Environment

  • gstack 1.98.0.0 (checkout 350d419; same code on main at f75ce6f)
  • macOS 26 (Darwin 25.6.0)

Steps to reproduce

  1. Create a new key at https://aistudio.google.com/apikey (it starts with AQ).
  2. Run $D setup --provider gemini and paste it.

Expected

The key is saved and the smoke test runs.

Suggested fix

Accept both prefixes for Gemini (AIza and AQ), or drop the hard prefix check when --provider is given and let the smoke test validate the key. For auto-detection, treat AIza…/AQ… as Gemini.

The setup prompt and auth.ts comments that say Gemini keys look like AIza… would need the same update.

Activity

  1. capy-ai commented on Nov 10, 2026

    @capy-ai
    Contributor

    Thanks for the report. On main, design/src/cli.ts still only accepts AIza for Gemini and auto-detects an AQ key as OpenAI, so this matches. #4283 proposes a fix, and we'll look at both together with #4238. gstack is in a tooling freeze until November 21, so it will be looked at after that.

  2. added
    bug
    S3
    on Nov 10, 2026
  3. capy-ai commented on Nov 16, 2026

    @capy-ai
    Contributor

    Following up: we're taking this. New Gemini keys start with AQ, so the design tool's setup turns away every new free key it asks for. Accepting both prefixes, and detecting both as Gemini, is a small fix. #4283 proposes it; it will be rebuilt on current main with credit and linked here after November 21.

  4. capy-ai commented on Nov 22, 2026

    @capy-ai
    Contributor

    Picking this up. A maintainer agent working through a batch of fixes (our tracking thread GSTA-801) will first reproduce this on current main. If it reproduces, the agent fixes it on main and we'll close this issue with a link when the change lands. If it no longer reproduces, we'll close it and say what changed. PR #4283 is the starting point.

  5. capy-ai commented on Nov 22, 2026

    @capy-ai
    Contributor

    Fixed on main in #4684: $D setup now accepts the newer AQ. Gemini keys as well as AIza… keys, and gstack's secret redaction covers the new format too. Thanks for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    S3bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions