Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,20 +210,43 @@ Use API keys for OpenAI or other compatible providers:

1. **Environment Variables**

**For Standard OpenAI:**

```bash
export OPENAI_API_KEY="your_api_key_here"
export OPENAI_BASE_URL="your_api_endpoint"
export OPENAI_MODEL="your_model_choice"
```

**For Azure OpenAI:**

```bash
export AZURE_OPENAI_ENDPOINT="https://your-resource-name.openai.azure.com"
export AZURE_OPENAI_DEPLOYMENT="your-deployment-name"
export AZURE_OPENAI_API_KEY="your-azure-api-key"
export AZURE_OPENAI_API_VERSION="2024-05-01-preview"
```

2. **Project `.env` File**
Create a `.env` file in your project root:

**For Standard OpenAI:**

```env
OPENAI_API_KEY=your_api_key_here
OPENAI_BASE_URL=your_api_endpoint
OPENAI_MODEL=your_model_choice
```

**For Azure OpenAI:**

```env
AZURE_OPENAI_ENDPOINT=https://your-resource-name.openai.azure.com
AZURE_OPENAI_DEPLOYMENT=your-deployment-name
AZURE_OPENAI_API_KEY=your-azure-api-key
AZURE_OPENAI_API_VERSION=2024-05-01-preview
```

**API Provider Options**

> ⚠️ **Regional Notice:**
Expand Down
25 changes: 23 additions & 2 deletions docs/cli/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,49 @@ Qwen Code supports two main authentication methods to access AI models. Choose t

a) **Environment Variables:**

**For Standard OpenAI:**

```bash
export OPENAI_API_KEY="your_api_key_here"
export OPENAI_BASE_URL="your_api_endpoint" # Optional
export OPENAI_MODEL="your_model_choice" # Optional
```

**For Azure OpenAI:**

```bash
export AZURE_OPENAI_ENDPOINT="https://your-resource-name.openai.azure.com"
export AZURE_OPENAI_DEPLOYMENT="your-deployment-name"
export AZURE_OPENAI_API_KEY="your-azure-api-key"
export AZURE_OPENAI_API_VERSION="2024-05-01-preview" # Optional
```

b) **Project `.env` File:**
Create a `.env` file in your project root:

**For Standard OpenAI:**

```env
OPENAI_API_KEY=your_api_key_here
OPENAI_BASE_URL=your_api_endpoint
OPENAI_MODEL=your_model_choice
```

**For Azure OpenAI:**

```env
AZURE_OPENAI_ENDPOINT=https://your-resource-name.openai.azure.com
AZURE_OPENAI_DEPLOYMENT=your-deployment-name
AZURE_OPENAI_API_KEY=your-azure-api-key
AZURE_OPENAI_API_VERSION=2024-05-01-preview
```

**Supported Providers:**
- OpenAI (https://platform.openai.com/api-keys)
- Azure OpenAI
- Alibaba Cloud Bailian
- ModelScope
- OpenRouter
- Azure OpenAI
- Any OpenAI-compatible API

## Switching Authentication Methods

Expand Down
28 changes: 27 additions & 1 deletion docs/cli/openai-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,21 @@ Qwen Code CLI supports OpenAI authentication for users who want to use OpenAI mo

### 1. Interactive Authentication (Recommended)

When you first run the CLI and select OpenAI as your authentication method, you'll be prompted to enter:
When you first run the CLI and select OpenAI as your authentication method, you'll be prompted to enter either:

**Standard OpenAI:**

- **API Key**: Your OpenAI API key from [https://platform.openai.com/api-keys](https://platform.openai.com/api-keys)
- **Base URL**: The base URL for OpenAI API (defaults to `https://api.openai.com/v1`)
- **Model**: The OpenAI model to use (defaults to `gpt-4o`)

**OR Azure OpenAI:**

- **Endpoint**: Your Azure OpenAI endpoint (e.g., `https://your-resource-name.openai.azure.com`)
- **Deployment**: Your Azure OpenAI deployment name
- **API Key**: Your Azure OpenAI API key
- **API Version**: The Azure OpenAI API version (defaults to `2024-05-01-preview`)

The CLI will guide you through each field:

1. Enter your API key and press Enter
Expand All @@ -33,18 +42,35 @@ qwen-code --openai-api-key "your-api-key-here" --openai-base-url "https://your-c

# With custom model
qwen-code --openai-api-key "your-api-key-here" --model "gpt-4-turbo"

# Azure OpenAI usage
qwen-code --azure-openai-endpoint "https://your-resource-name.openai.azure.com" \
--azure-openai-deployment "your-deployment-name" \
--azure-openai-api-key "your-azure-api-key" \
--azure-openai-api-version "2024-05-01-preview"
```

### 3. Environment Variables

Set the following environment variables in your shell or `.env` file:

**For Standard OpenAI:**

```bash
export OPENAI_API_KEY="your-api-key-here"
export OPENAI_BASE_URL="https://api.openai.com/v1" # Optional, defaults to this value
export OPENAI_MODEL="gpt-4o" # Optional, defaults to gpt-4o
```

**For Azure OpenAI:**

```bash
export AZURE_OPENAI_ENDPOINT="https://your-resource-name.openai.azure.com"
export AZURE_OPENAI_DEPLOYMENT="your-deployment-name"
export AZURE_OPENAI_API_KEY="your-azure-api-key"
export AZURE_OPENAI_API_VERSION="2024-05-01-preview" # Optional, defaults to 2024-05-01-preview
```

## Supported Models

The CLI supports all OpenAI models that are available through the OpenAI API, including:
Expand Down
Loading
Loading