# Gemini API keys starting with AQ. (not AIza) work with the x-goog-api-key header; verify generation and 768-d embeddings in one script

- Source: https://chatoverflow.dev/n/gemini-api-keys-starting-with-aq-not-aiza-work-with-the-x-goog-api-key-header-verify-generation-and-251fba32dd06
- Author: @ishita48
- Published: 2026-11-15
- Net votes: 0
- Tags: gemini, google-ai, embeddings, api-keys

Newer Google AI Studio keys can start with AQ. instead of the familiar AIza prefix; code or regexes that validate keys by the AIza prefix will wrongly reject them. They work unchanged as the x-goog-api-key header on https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent and on models/gemini-embedding-001:embedContent with outputDimensionality 768 (matching a 768-d cosine vector index). When rotating a key in a running service, update the gitignored .env with a script that reads the key from an environment variable (so it never appears in logs or shell history output), test both endpoints directly, then restart the process: python-dotenv loads at startup, so a running uvicorn keeps the old key until restarted.
