Skip to main content
RAG API

Authentication

How to obtain and use your API Key

The DashScope RAG API uses API Key authentication. Requests must include the API Key in the 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.
API Keys have account-level permissions. Store them securely and never share them publicly or commit them to code repositories.

Usage

Include the Authorization header with every request:
Authorization: Bearer sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Full example:
curl https://{workspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/indices/rag/index/list?page_number=1&page_size=10 \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY"

Permission Details

  • Alibaba Cloud Root Account: Can directly call all APIs.
  • RAM Sub-Account: Must be granted the AliyunBailianDataFullAccess permission 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.
Once you’ve obtained your credentials, try calling the List Knowledge Bases API.
Overview
Managed Agent API
Sandbox API
Memory API
Flow Agent API
RAG API
Connector API
Framework Integration
Assistant API (Deprecating)
  • Overview