You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Title: Improve diagnostics when stored credentials or background service environment override API keys #52891
In OpenCode v2.0.21 on macOS, I encountered two authentication issues while configuring a custom OpenAI-compatible provider.
An outdated API key stored in SQLite took precedence over the correct key supplied through the environment variable and configuration.
After removing the outdated credential, opencode run --standalone worked, but the normal TUI continued to fail because it reused a background service that had been started without the required environment variable.
The TUI process had the correct environment variable, but the background service did not. Restarting the service from a terminal with the correct environment resolved the issue.
Expected behavior
It would be helpful if OpenCode could:
Show which credential source is being used, without exposing the API key.
Warn when stored credentials override a configured environment variable.
Provide a diagnostic hint when the background service does not have an environment variable required by the selected provider.
Suggest restarting the service when its environment is outdated.
Actual behavior
The TUI reported an authentication error even though the correct API key was present in the terminal environment and standalone execution succeeded.
Environment
OpenCode v2.0.21
macOS
Custom OpenAI-compatible provider
Managed background service
The issue was resolved by removing the outdated stored credential and running opencode service restart with the correct environment variable.
Thanks for the detailed write-up, @hagix9, and for including the fix that worked for you (removing the stale stored credential and running opencode service restart from a shell that has the variable set).
What you're asking for is better visibility into where a provider's credential comes from. Specifically:
show which credential source is in use (without revealing the key)
warn when a stored credential overrides a configured environment variable
give a hint when the background service doesn't have an environment variable the selected provider needs, and suggest restarting it
The TUI connects to the background service, and that service only sees the environment it was started with. So what you saw is how it currently works, but it's easy to get caught by and hard to diagnose. These suggestions would help.
I've marked this as a feature request for the maintainers to consider.
Activity
github-actions commentedon Oct 3, 2026
This issue might be a duplicate of existing issues. Please check:
opencodejr commentedon Oct 27, 2026
Thanks for the detailed write-up, @hagix9, and for including the fix that worked for you (removing the stale stored credential and running
opencode service restartfrom a shell that has the variable set).What you're asking for is better visibility into where a provider's credential comes from. Specifically:
The TUI connects to the background service, and that service only sees the environment it was started with. So what you saw is how it currently works, but it's easy to get caught by and hard to diagnose. These suggestions would help.
I've marked this as a feature request for the maintainers to consider.