Skip to content

Create an API key

Create an API key to call models and applications in Alibaba Cloud Model Studio.

1. Create an API key

Important

Use an Alibaba Cloud account, or a RAM user with administrator or API-Key page permissions.

Singapore and other regions

  1. Go to the Alibaba Cloud Model Studio console. In the upper-right corner, switch to your target region, such as Singapore . In the left-side navigation pane, choose API Key to go to the API key management page, and then click Create API Key.

  2. In the dialog box, configure the following and click OK:

    • Workspace: Select the default workspace.

    • Description: Enter a description to help you identify this API key later.

  3. The full API key is shown only once after creation. Copy and store it securely before closing the dialog box.

  4. In the API key list, click the icon next to an API key to copy the masked key.

    Alibaba Cloud accounts can view all API keys. RAM users can view only the API keys they create.

China (Beijing) region

  1. Go to the Alibaba Cloud Model Studio console. In the upper-right corner, select the China (Beijing) region. Go to the API Key page and click Create API Key.

  2. In the dialog box, configure the following and click OK:

    • Workspace: Select the default workspace.

    • Permission : Select All . For granular control, select Custom to configure an IP address whitelist for this API key.

    How to choose permission settings for an API key Model Studio provides two permission settings:

    • All: Allows calls to all models and applications.

    • Custom : Configures an IP address whitelist. Cannot be empty.

      Default: all IPv4 ( 0.0.0.0/0) and IPv6 ( ::/0) addresses.

      Only whitelisted IP addresses can use this API key. You can add up to 20 IPv4 or IPv6 addresses or CIDR blocks.

  3. Click the icon next to the API key to copy it.

    Alibaba Cloud accounts can view all API keys. RAM users can view only the API keys they create.

When to choose a different workspace For team collaboration or cost allocation:

  • Workspace: Workspaces isolate resources and permissions for different projects or teams. To control which models specific users can call, or to allocate costs for model calls, create or select a sub-workspace.

For more information, see API key permissions and Bill query and cost management.

2. Use an API key

Note

Coding Plan requires a dedicated API key (format: sk-sp-xxxxx) instead of the general-purpose Model Studio API key (format: sk-xxxxx) described in this topic. To get a Coding Plan API key, see Get your plan-specific API key and base URL.

  • Method 1: Call models from third-party tools

    To call a model from a tool such as Chatbox, provide the following:

    • Your API key

    • The base URL for your API key's region:

      • Singapore : https://dashscope-intl.aliyuncs.com/compatible-mode/v1

      • US (Virginia) : https://dashscope-us.aliyuncs.com/compatible-mode/v1

      • China (Beijing) : https://dashscope.aliyuncs.com/compatible-mode/v1

      • China (Hong Kong) : https://cn-hongkong.dashscope.aliyuncs.com/compatible-mode/v1

      • Germany (Frankfurt) : https://{WorkspaceId}.eu-central-1.maas++.aliyuncs.com++/compatible-mode/v1. Replace WorkspaceId with your actual workspace ID.

    • The model name, such as qwen-plus

Configuration guides for common tools: Chatbox, Cline, Claude Code, Dify, OpenClaw (formerly Clawdbot/Moltbot), Postman, and Qwen Code.

  • Method 2: Call models in code

    To call the Qwen API in code, configure the API key as an environment variable to avoid hardcoding it in source code.

Never share your API key publicly. Unauthorized use can cause security breaches or financial loss.

API key permissions

An API key's permissions depend on its workspace . All API keys in the same workspace share identical permissions. You do not need separate API keys for different model types, such as text-to-text, text-to-image, or speech synthesis.

  • API keys in the default workspace: Allow calls to all standard models and applications within the default workspace.

  • API keys in a sub-workspace: Allow calls to standard models authorized for the sub-workspace and to applications within that sub-workspace.

Note

Fine-grained permission control for API keys is currently available only in the China (Beijing) region.

When you Create API Key or click Edit for an existing API key, you can switch Permissions to Custom to configure:

  • IP address whitelist: Allows only whitelisted IP addresses to use the API key. Supports IPv4, IPv6, and CIDR blocks.

API key validity

API keys do not expire. They remain valid until you delete them.

To grant temporary access to third-party applications or users, or to control high-risk operations such as accessing or deleting sensitive data, generate a temporary API key (valid for 60 seconds). This avoids exposing long-term API keys and reduces leak risk.

FAQ

Q: How many API keys can I create under one Alibaba Cloud account?

A: In the Singapore, China (Beijing), China (Hong Kong), and Germany (Frankfurt) regions, each Alibaba Cloud account can create up to 50 API keys per region.

In the US (Virginia) region, each owner account (including the Alibaba Cloud account) can create up to 20 API keys. Q: Are API keys created by a RAM user still valid after the user is deleted?

A: No. After you delete a RAM user in the RAM console, all API keys created by that user become invalid.

Mirror of Alibaba Cloud Model Studio docs for reference and RAG. Not affiliated with Alibaba Cloud.