Create and use an API key.
The DashScope RAG API authenticates with an API key. Pass the key in the
Pass the key in the
Full example:
Authorization header on every request — the platform uses it to route the call to your workspace automatically.
Get an API key
1
Open the Model Studio console
Go to the RAG Console and sign in with your Alibaba Cloud account.
2
Create an API key
Click API Key in the left navigation, then create a new key or copy an existing one.
Use the API key
Pass the key in the Authorization header on every request:
Permissions
- Alibaba Cloud main account — can call every endpoint directly.
- RAM sub-account — needs the
AliyunBailianDataFullAccesspolicy and must be added to the target workspace. - An API key's scope is configured in the Model Studio console.
Security recommendations
- Keep keys out of the repo — store the API key in an environment variable such as
DASHSCOPE_API_KEY. - Split by application — use a separate API key per application so you can track and revoke them independently.
- Rotate regularly — replace your API keys on a schedule to limit the impact of a leak.