Skip to content

Conversation

GitMurf
Copy link
Contributor

@GitMurf GitMurf commented Jun 23, 2025

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

@thdxr
Copy link
Contributor

thdxr commented Jun 23, 2025

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

@GitMurf
Copy link
Contributor Author

GitMurf commented Jun 23, 2025

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"?

@GitMurf
Copy link
Contributor Author

GitMurf commented Jun 23, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature: Ability to pass credentials without storing in environment file
2 participants