Convex agents, convex/chat.ts: process.env.OPENROUTER_API_KEY is undefined
I have this code in chat.ts, following a Convex Agents tutorial:
I have this in .env.local:
Despite that, I keep getting
3 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
the environment variables read from your convex/ folder come from your deployment's (server) environment variables, not .env.local. run
npx convex dashboard
or go to dashboard.convex,.dev/deployment/settings - and you can set / list your env variables from the CLI with npx convex env list
and npx convex env set OPENROUTER_API_KEY <your key>
Aah gotcha -- thank you! I added it in my dashboard and that worked 🙏