Authenticate a model provider
getting started
// what it does
opencode auth login walks you through picking one of 75+ providers (Anthropic, OpenAI, Google, OpenRouter, local, and more, via the AI SDK and Models.dev) and storing its key. Credentials go to ~/.local/share/opencode/auth.json, separate from your config; opencode auth list shows what is connected and opencode auth logout removes one. Inside the TUI the equivalent is /connect.
// shell
$ opencode auth login$ opencode auth list$ opencode auth logout// gotcha
auth.json holds keys in plaintext — keep it out of dotfile repos and backups. Some providers (GitHub Copilot and others) use a browser OAuth flow rather than a pasted key; choose the method opencode offers instead of forcing an API key.