feat(providers): use env variable instead of hardcoded api key in auth.json
I am doing this specifically for Gemini (Google), but this should work with any provider.
This is NOT available in the UI of opencode auth login because I am not sure what the UX there should be like, so instead you can just "manually" update your opencode auth.json to something like the following:
{
"google": {
"type": "env",
"env": "GEMINI_API_KEY"
}
}
This allows you to have opencode leverage an environment variable for an API Key instead of having to "hardcode" it into the opencode auth.json.
This should somewhat resolve #318
interesting but we actually have a few places in the config where people want to specify env vars. so we might just implement it at that layer
interesting but we actually have a few places in the config where people want to specify env vars. so we might just implement it at that layer
cool, sounds good! I figured this was fairly temporary / "hacky" but figured I would push some code that worked to give you more ideas. Would you like me to cancel / close this PR @thdxr? or do you want me to keep it open as a "reminder"?
interesting but we actually have a few places in the config where people want to specify env vars...
Btw, for the record, solving it in the config.json I agree with... this was just the shortest path to implementation so thought I would throw it out there.