deadcoder0904
09/20/2025, 6:59 AM.env (for Gemini CLI) & .env.local (Convex uses this) but get error. API Key is valid since I tested it using CURL too generated by BAML Playground. Both .env & .env.local are 1:1 clone too.
BAML Playground in VSCode works. Minimal repro: https://github.com/deadcoder0904/tanstack-start-convex-baml-bun-hello-world
How do I solve this? My hunch is BAML being the issue, not anything else since rest deps work without BAML. I have another Electron project that works but it uses Dynamic LLM Registry. I even tried dotenv but that didn't work either. Altho I dont need dotenv since bun automatically loads it.
https://cdn.discordapp.com/attachments/1253172394345107466/1418854001788846090/CleanShot_2025-09-20_at_12.29.062x.png?ex=68cfa243&is=68ce50c3&hm=dc3fd70131a7a9da47977c2492c7c5f77b7498e00d21a972e2dcc69b9be0c4bd&Vaibhav (BAML š)
09/20/2025, 7:23 AMdeadcoder0904
09/20/2025, 7:34 AMLooks like your BAML config is already pointing at the right variableābaml_src/llm_clients/gemini.baml:4 now reads api_key env.GOOGLE_API_KEY, and the generated baml_client/
inlinedbaml.ts mirrors that, so the code is fine.
The 400 is coming from Convex running your action in its remote dev deployment. When you run bunx convex dev, it pushes your functions to Convex Cloud, and the runtime up
there doesnāt see your local .env.local unless you explicitly copy the secrets over. With no key in the deployment, BAML sends an empty x-goog-api-key header, and Gemini
answers with āAPI key not validā.
Fix it by setting the variable on the Convex deployment:
1. npx convex env set GOOGLE_API_KEY <your-key> (defaults to the dev deployment).
2. npx convex env list to double-check itās there.
3. Restart bunx convex dev so the local tooling reconnects.
If youād rather rely on the local .env.local, switch to a local Convex runtime with bunx convex dev --local, but for the default cloud dev setup you need to push secrets with
convex env.
Once the key is registered with Convex, BAML should reach Gemini without the 400.