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:Never commit
.env
files to version control! Add to .gitignore
: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.json
with restricted permissions
API Key Authentication
Getting API Keys
- Anthropic
- OpenAI
- OpenRouter
- Go to console.anthropic.com
- Navigate to API Keys
- Click Create Key
- Name your key (e.g., “AgentUse”)
- Copy the key (starts with
sk-ant-api03-
)
Keys are shown only once. Store them securely!
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
You can override the model specified in an agent file at runtime using the--model
flag. This is especially useful for:
- Testing: Compare how different models handle the same task
- Cost Optimization: Use cheaper models during development
- Environment-Specific Deployment: Different models for dev/staging/prod
- Quick Experimentation: Try new models without editing files
Basic Usage
Environment-Specific Keys
Combine model override with environment suffixes:CI/CD Examples
When overriding to a different provider, provider-specific options (like OpenAI’s
reasoningEffort
)
from the original agent file will be ignored.Sub-Agent Model Inheritance
When using the--model
flag with agents that have sub-agents:
- Complete Override: The model override applies to the parent AND all sub-agents
- Uniform Execution: All agents in the hierarchy will use the same model
- Authentication: Ensures consistent authentication across all agents
- Consistent performance across the entire agent hierarchy
- Simplified testing with different model configurations
- Cost control when switching between expensive and cheap models
- No authentication conflicts between parent and sub-agents
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