All Products
Search
Document Center

Alibaba Cloud Model Studio:Obtain an API key

Last Updated:Apr 25, 2025

An API key is needed for authentication when you call large language models (LLMs) or applications through API or SDK. This topic describes how to obtain an API key.

Activate Model Studio

Log on to the Model Studio console. If the following message appears at the top of the page, you need to activate Model Studio and claim the free quota. It is free to activate the service, but after you run out of the quota, you are charged for model calling.image

Obtain API key

  1. Go to API Key Management. Click Create My API Key.

  2. In the Actions column, click View. Then, you can view the API KEY.

    image

    Note
    • You can only use the All API Keys page if you are using the Alibaba Cloud account. The Alibaba Cloud account can obtain the API keys of all RAM users, but a RAM user can only obtain its own API key.

    • Keep your API key confidential to avoid security risks or financial losses caused by unauthorized usage.

    • Your API key is an important asset, make sure to keep it safe. If you click Delete in the Actions column to delete an existing API Key, you cannot use the key to use Model Studio services again. All applications or services associated with this key will fail.

    • When creating an API key, we recommend that you select the default workspace for Workspace. To use API keys of a sub-workspace, you must use the Alibaba Cloud account to authorize the sub-workspace to use models.

What to do next

After obtaining an API key, we recommend that you set it as an environment variable. This avoids explicitly specifying it when you use Alibaba Cloud Model Studio SDK and reduce the risk of an API leak. For more information, see Set API key as an environment variable.

Scope of API key

  1. The API key of the Alibaba Cloud account can access all services in all workspaces. But you must specify the workspace ID when you access a sub-workspace. For more information, see Call a model in a sub-workspace.

  2. The API key of a RAM user can access the authorized services in the associated workspace. For more information about how to authorize a workspace, see Authorize a sub-workspace to use models.

  3. If a RAM user needs to access services in the default workspace, use one of the following methods:

    • Use the API key of the Alibaba Cloud account.

    • Use the Alibaba Cloud account to grant the RAM user access permission to the default workspace. Then, the RAM user can create an API key in the default workspace.

Validity period of API key

By default, the API Keys created in API Key Management are permanently valid. But you can manually delete them and they will become invalid.

If you need to provide temporary access for third-party applications or users, or if you want to strictly control high-risk operations like access to sensitive data and deletion, obtain a temporary authentication token that is valid for 60 seconds. This approach helps avoid directly exposing long-term API Keys, thereby reducing the risk of leaks.

OSZAR »