Skip to main content

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:
  1. Opens an interactive dialog for authentication setup
  2. Allows you to choose between different authentication methods
  3. Guides you through the setup process
  4. Validates credentials before saving
  5. Stores authentication tokens securely

Authentication Methods

Qwen Code supports multiple authentication providers:

OpenAI

Authenticate with OpenAI API:
  1. Run /auth
  2. Select “OpenAI”
  3. Enter your API key
  4. Test the connection

Anthropic

Authenticate with Anthropic (Claude):
  1. Run /auth
  2. Select “Anthropic”
  3. Enter your API key
  4. Test the connection

Qwen (Dashscope)

Authenticate with Qwen models:
  1. Run /auth
  2. Select “Dashscope”
  3. Enter your API key from Alibaba Cloud
  4. Test the connection

OAuth

For providers supporting OAuth:
  1. Run /auth
  2. Select OAuth provider
  3. Complete browser-based authentication
  4. Return to the CLI

Command-Line Authentication

You can also configure authentication via command-line flags:

OpenAI API Key

Custom Base URL

Authentication Type

Available auth types:
  • openai
  • anthropic
  • dashscope
  • google-genai
  • azure-openai

Environment Variables

Authentication can be configured through environment variables:
Then run:

Configuration Files

Authentication settings are stored in:
Example configuration:
Never commit API keys to version control. Use environment variables or the secure credential store.

Switching Authentication

To switch between different authentication methods:
  1. Run /auth
  2. Select a different provider
  3. Configure the new credentials
  4. The change takes effect immediately

Troubleshooting

Invalid API Key

If you see authentication errors:
  1. Verify your API key is correct
  2. Check if the key has the necessary permissions
  3. Ensure you’re using the right authentication type
  4. Try regenerating your API key

Connection Issues

If authentication fails:
Check:
  • Network connectivity
  • Firewall settings
  • Proxy configuration
  • API service status

Proxy Configuration

If you’re behind a proxy:
Or set the environment variable:

Security Best Practices

Store API keys in environment variables instead of hardcoding them:
Periodically regenerate your API keys and update your configuration:
  1. Generate new API key from provider
  2. Run /auth to update
  3. Revoke old API key
For team projects, use project-specific API keys with limited permissions:
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