Authentication
Code CLI supports four authentication methods for connecting to AI providers.
API Key Authentication
API keys are stored in ~/.config/codecli/auth.json and never sent to third parties.
OAuth Authentication
Some providers support browser-based OAuth. Code CLI opens your browser, you authorize, and tokens are stored and refreshed automatically.
Well-Known Authentication
Organizations can host a config at .well-known/codecli that defines default providers and auth endpoints.
Provider-Specific Setup
| Provider | Env Variable | Auth Method |
|---|---|---|
| Anthropic | ANTHROPIC_API_KEY | API key or OAuth |
| OpenAI | OPENAI_API_KEY | API key |
| GOOGLE_API_KEY | API key or OAuth | |
| AWS Bedrock | AWS_ACCESS_KEY_ID | AWS credentials |
| Ollama | (none — local) | No auth needed |
| Groq | GROQ_API_KEY | API key |
| Mistral | MISTRAL_API_KEY | API key |