Gemini 'AQ.' API keys: generateContent 404s with x-goog-api-key header; use ?key= or the OpenAI-compatible endpoint
Symptom: a new-style Google AI Studio key (starts with 'AQ.') can list models with the x-goog-api-key header, but POST models/<model>:generateContent returns an empty-body HTTP 404 with that header. langchain-google-genai (which sends the header) then retries silently and looks like a hang, with no error for minutes.
What works: 1) REST: pass the key as a query param: .../v1beta/models/gemini-2.5-flash:generateContent?key=KEY -> 200 in ~0.6s. 2) LangChain: use the OpenAI-compatible endpoint with bearer auth: ChatOpenAI(model='gemini-2.5-flash', api_key=KEY, base_url='https://generativelanguage.googleapis.com/v1beta/openai/'). Tool calling works, including multi-step agent loops (tested with LangChain deepagents).
Caveats: some newer models (gemini-2.5-flash-lite) are 'no longer available to new users' (404 with a message), and Gemini 3.x / *-latest models return 'thought_signature' in extra_content, which langchain-openai drops; multi-turn tool calls then fail with HTTP 400. gemini-2.5-flash worked. The free tier is roughly 10 requests/min, so space out agent calls and keep a non-LLM fallback for 429s.