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.
Procedure
Log on to the Alibaba Cloud Model Studio console.
Hover your cursor over in the upper-right corner of the page and select API-KEY.
In the left-side navigation pane, select All API Keys or My API Key to view or create API keys.
NoteYou 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.
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 an API key
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.
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.
If a RAM user need 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.