Overview
The/auth command opens the authentication configuration dialog where you can set up or modify your API credentials and OAuth settings.
Usage
In Interactive Mode
Alternative Names
The following aliases are available:/auth/login
What It Does
The/auth command:
- Opens an interactive dialog for authentication setup
- Allows you to choose between different authentication methods
- Guides you through the setup process
- Validates credentials before saving
- Stores authentication tokens securely
Authentication Methods
Qwen Code supports multiple authentication providers:OpenAI
Authenticate with OpenAI API:- Run
/auth - Select “OpenAI”
- Enter your API key
- Test the connection
Anthropic
Authenticate with Anthropic (Claude):- Run
/auth - Select “Anthropic”
- Enter your API key
- Test the connection
Qwen (Dashscope)
Authenticate with Qwen models:- Run
/auth - Select “Dashscope”
- Enter your API key from Alibaba Cloud
- Test the connection
OAuth
For providers supporting OAuth:- Run
/auth - Select OAuth provider
- Complete browser-based authentication
- Return to the CLI
Command-Line Authentication
You can also configure authentication via command-line flags:OpenAI API Key
Custom Base URL
Authentication Type
openaianthropicdashscopegoogle-genaiazure-openai
Environment Variables
Authentication can be configured through environment variables:Configuration Files
Authentication settings are stored in:Switching Authentication
To switch between different authentication methods:- Run
/auth - Select a different provider
- Configure the new credentials
- The change takes effect immediately
Troubleshooting
Invalid API Key
If you see authentication errors:- Verify your API key is correct
- Check if the key has the necessary permissions
- Ensure you’re using the right authentication type
- Try regenerating your API key
Connection Issues
If authentication fails:- Network connectivity
- Firewall settings
- Proxy configuration
- API service status
Proxy Configuration
If you’re behind a proxy:Security Best Practices
Use Environment Variables
Use Environment Variables
Store API keys in environment variables instead of hardcoding them:
Rotate Keys Regularly
Rotate Keys Regularly
Periodically regenerate your API keys and update your configuration:
- Generate new API key from provider
- Run
/authto update - Revoke old API key
Use Project-Specific Keys
Use Project-Specific Keys
For team projects, use project-specific API keys with limited permissions:
External Authentication
External Authentication
For enterprise deployments, use external authentication services:
See Also
Authentication Guide
Complete authentication setup guide
Configuration
Settings and configuration options
Security
Security best practices
Environment Setup
Initial setup and quickstart
