Skip to main content
Getting Started

Get an API key

First step to using models

Choose a billing method

QwenCloud provides pay-as-you-go and Token Plan API keys. You do not need a Token Plan subscription to create a pay-as-you-go key. See Choose an API key and endpoint.
Token Plan does not cover all QwenCloud models. Before subscribing or calling a model, check its exact model ID in the Individual edition model list or Team edition model list.To use plan Credits, use both a dedicated Token Plan API key (sk-sp-) and the dedicated endpoint for the capability you are calling. For text chat, see the Individual quickstart or Team quickstart. For images, video, and audio, see Multimodal integration. Calls using pay-as-you-go keys and endpoints remain billed separately and do not consume plan Credits. Token Plan is available only in Singapore.

Create an API key

These steps create a pay-as-you-go API key. For Token Plan, copy the dedicated key from the Individual or Team tab in the Token Plan section of the API Keys page.
1

Create an API key

Use the region selector in the upper-right corner of the console to select the region you will call. Then go to API Keys and click Create API key. The key works only with that region's endpoint. See Regions and endpoints.
2

Add a description

Enter a description to help identify your key, then click Generate Key.
3

Copy your API key

Copy and save your API key immediately. For security reasons, the full key is only shown once. The key list displays a masked version after creation.

Use an API key

The Base URL below is for pay-as-you-go text chat. For Token Plan or other capabilities, see Choose an API key and endpoint.
  • Method 1: In third-party tools such as Chatbox Configuration guides for common tools: Chatbox, Cline, Claude Code, OpenClaw, and Qwen Code. When calling models in third-party tools, provide:
    • API key (from this page)
    • Base URL of the region where the key was created, for example https://ap-southeast-1.maas.qwencloudapi.com/compatible-mode/v1 for Singapore. For another region, replace ap-southeast-1 with that region's ID.
    • Model name (such as qwen3.7-plus)
  • Method 2: Through code Set the API key as an environment variable to avoid hardcoding it in source code.
When you call a model from code or a third-party tool, in addition to the API key you must specify a service endpoint (the API Host shown in the creation success dialog, which corresponds to the base_url in your SDK or HTTP request). QwenCloud provides both OpenAI-compatible and Anthropic-compatible protocol interfaces. The base_url differs between the two protocols, and its domain contains the region ID ({region}.maas.qwencloudapi.com). Use the domain of the region where the API key was created. See Regions and endpoints. Refer to the documentation for the protocol you use:
Never share your API key—unauthorized use causes security risks and financial loss.

Manage API keys

From the API Keys page, you can:
  • Search: Find keys by description.
  • Edit: Update the description of an existing key.
  • Delete: Permanently remove a key. Deleted keys cannot be recovered and any applications using them will stop working.

Async tasks after an API key is deleted

After an API key is deleted, it can no longer be used and cannot be recovered. If async tasks created with this API key are still queued or have not finished running, the system continues to run them after the API key is deleted. If you do not want these tasks to continue, manually terminate the associated tasks to avoid charges incurred after the API key is deleted.

Validity

API keys remain valid permanently unless you manually delete them.

Error codes

If a model call fails and returns an error message, see Error codes for troubleshooting.

FAQ

Pay-as-you-go API key vs Token Plan API key

Key typeFormatBillingBase URL
Pay-as-you-gosk-ws-xxxxx (keys created before the API key security upgrade: sk-xxxxx)Per API call{region}.maas.qwencloudapi.com, region-specific (for example, ap-southeast-1.maas.qwencloudapi.com for Singapore)
Token Plansk-sp-xxxxxMonthly subscription (credits)token-plan.maas.qwencloudapi.com (Singapore only)
The two key types are not interchangeable — each key is bound to its own base URL. Do not use a Token Plan sk-sp- key against the pay-as-you-go endpoint, or vice versa. A pay-as-you-go key also works only with the endpoint of the region where it was created.

echo works but code reports "no API key found"

Q: I used the echo command and confirmed the environment variable was set correctly. Why does my code still report that the API key cannot be found? A: This can occur for the following reasons:
  • Scenario 1: A temporary environment variable was set. A temporary variable is valid only within the current terminal session and does not affect running IDEs or other applications. Refer to Configure your API key to set a permanent environment variable.
  • Scenario 2: The IDE, command-line tool, or application was not restarted. You must restart your IDE (such as VS Code) or terminal to load the new environment variables. If you set the environment variable after deploying an application, you must restart the application service.
  • Scenario 3: The variable is missing from a service configuration file. If your application is started by a service manager (such as systemd or supervisord), you may need to add the environment variable to the service manager's configuration file.
  • Scenario 4: Using the sudo command. sudo does not inherit all environment variables by default. Use sudo -E python xx.py where the -E parameter ensures that environment variables are passed.