How to obtain and use your API Key
The DashScope RAG API uses API Key authentication. Requests must include the API Key in the
Include the
Full example:
Authorization header. The business workspace is identified by the {workspaceId} in the endpoint URL, formatted as: https://{workspaceId}.cn-beijing.maas.aliyuncs.com/.
Obtaining Credentials
1
Access the Console
Open the Bailian Console and log in with your Alibaba Cloud account. Navigate to the Settings → API Key page.
2
Create an API Key
Click API Key in the left navigation bar to create a new API Key or copy an existing one.
Usage
Include the Authorization header with every request:
Permission Details
- Alibaba Cloud Root Account: Can directly call all APIs.
- RAM Sub-Account: Must be granted the
AliyunBailianDataFullAccesspermission and added to the target workspace. - The scope of permissions for an API Key is configured in the console.
Security Recommendations
- Never Commit to Code Repositories: Store your API Key in environment variables (e.g.,
DASHSCOPE_API_KEY). - Per-Application Keys: Use separate API Keys for different applications to simplify tracking and revocation.
- Regular Rotation: Rotate API Keys periodically to reduce risks associated with potential leaks.