Overview
AgentUse supports multiple AI providers. You need to authenticate with at least one provider to run agents.Supported Providers
Anthropic
Claude models (Opus, Sonnet, Haiku)
Supports OAuth and API keys
OpenAI
GPT models including GPT-5, GPT-4, GPT-4o, GPT-3.5
API key authentication
OpenRouter
Access to 100+ models via unified API
API key authentication
Authentication Methods
1. Interactive Login (Recommended)
The simplest way to authenticate:Anthropic supports OAuth login for both Claude Max and Console users - no API key needed!
2. Environment Variables
Set API keys as environment variables:3. Configuration File
Create a.env file in your project:
Advanced Environment Variable Configuration
AgentUse supports flexible environment variable patterns for multiple API keys:Managing Credentials
List Stored Credentials
Remove Credentials
Rotate API Keys
OAuth Authentication (Anthropic)
Both Claude Max and Console users can use OAuth for seamless authentication:1
Run OAuth Login
- Claude Pro/Max Plan (OAuth) - For claude.ai users
- Anthropic Console (OAuth) - For console.anthropic.com users
- Manual API Key - Traditional API key method
2
Authorization URL
Copy the authorization URL shown in terminal and visit in your browser
3
Authorize
Sign in and click “Authorize” to grant AgentUse access
4
Copy Code
Copy the authorization code from the browser
5
Paste Code
Paste the code in terminal - you’re authenticated!
OAuth Benefits
- No API key management required
- Automatic token refresh
- Secure PKCE authentication flow
- Works with both Claude Max and Console accounts
- Tokens stored securely in
~/.local/share/agentuse/auth.jsonwith restricted permissions
API Key Authentication
Getting API Keys
Get API keys from provider consoles:- Anthropic: console.anthropic.com → API Keys → Create Key (starts with
sk-ant-api03-) - OpenAI: platform.openai.com → API Keys → Create new secret key (starts with
sk-proj-) - OpenRouter: openrouter.ai → Keys → Create Key (starts with
sk-or-v1-)
Authentication Priority Order
AgentUse checks authentication sources in this order:- OAuth tokens (Anthropic only) - Checked first and refreshed automatically
- Stored API keys (via
agentuse auth login) - Stored in~/.local/share/agentuse/auth.json - Environment variables -
ANTHROPIC_API_KEY,OPENAI_API_KEY,OPENROUTER_API_KEY - Custom environment variables - Using suffix patterns (e.g.,
ANTHROPIC_API_KEY_DEV) or full variable names
Security Best Practices
Use OAuth When Possible
Use OAuth When Possible
OAuth is more secure than API keys as tokens can be revoked and rotated automatically. AgentUse uses PKCE flow for enhanced security.
Secure File Storage
Secure File Storage
Stored credentials in
~/.local/share/agentuse/auth.json are automatically set to user read/write only (0600 permissions).Rotate Keys Regularly
Rotate Keys Regularly
Change API keys every 90 days or immediately if compromised.
Limit Key Permissions
Limit Key Permissions
Create keys with minimal required permissions.
Use Environment Variables
Use Environment Variables
Never hardcode keys in your agent files or code.
Monitor Usage
Monitor Usage
Regularly check API usage to detect unusual activity.
Runtime Model Override
Override the model at runtime using the--model flag:
CLI Commands - Model Override
See the complete reference for model override format, environment-specific keys, CI/CD examples, and sub-agent inheritance behavior.
Multi-Provider Setup
Use different providers for different agents:Provider Options
Configure provider-specific settings for fine-tuned model behavior:OpenAI Provider Options
For OpenAI models (especially GPT-5), you can control reasoning and verbosity:reasoningEffort: Controls computational effort for reasoning
low: Faster responses with less thorough reasoningmedium: Balanced performance (default)high: More comprehensive reasoning, slower responses
low: Concise, minimal prosemedium: Balanced detail (default)high: Verbose, detailed explanations
- Speed vs Quality: Lower reasoning effort for faster responses
- Conciseness vs Detail: Lower verbosity for more direct answers
- Cost Optimization: Lower settings reduce token usage
Troubleshooting
Authentication failed
Authentication failed
- Verify API key is correct
- Check key hasn’t expired
- Ensure key has required permissions
- Try logging out and back in
Rate limiting
Rate limiting
- Check your API tier and limits
- Implement exponential backoff
- Consider upgrading your plan
- Use different keys for different projects
OAuth issues
OAuth issues
- Clear browser cookies
- Try a different browser
- Ensure you’re using the correct OAuth mode (Max vs Console)
- Check that your Claude subscription is active (for Max mode)
- Verify you have console access (for Console mode)
- Try manual API key authentication as fallback
