First step to using models
Create an API key
1
Create an API key
Go to API Keys and click Create API key.
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
This topic describes the pay-as-you-go API key. If you are using a Token Plan or Coding Plan, use the corresponding dedicated API key (
sk-sp-xxxxx format) from the API Keys page.-
Method 1: In third-party tools such as Chatbox
When calling models in third-party tools, provide:
- API key (from this page)
- Base URL:
https://dashscope-intl.aliyuncs.com/compatible-mode/v1 - 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 varies by region. Refer to the documentation for the protocol you use:- OpenAI-compatible protocol: OpenAI-compatible - Chat
- Anthropic-compatible protocol: Anthropic-compatible Messages
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.
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 / Coding Plan API key
| Key type | Format | Billing | Base URL |
|---|---|---|---|
| Pay-as-you-go | sk-xxxxx | Per API call | dashscope-intl.aliyuncs.com |
| Token Plan | sk-sp-xxxxx | Monthly subscription (credits) | token-plan.ap-southeast-1.maas.aliyuncs.com |
| Coding Plan | sk-sp-xxxxx | Monthly subscription | coding-intl.dashscope.aliyuncs.com |
sk-sp- prefix but are not interchangeable — each key is bound to a specific plan and base URL. Do not mix them.
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
sudocommand.sudodoes not inherit all environment variables by default. Usesudo -E python xx.pywhere the-Eparameter ensures that environment variables are passed.