Calls the POST /api/v1/models/limits endpoint to update the rate limit quotas (QPM/TPM) of models in a specified workspace. Both merge overlay and delete rate limit operations are supported.
Prerequisites
An API key has been created and configured as the environment variable DASHSCOPE_API_KEY. For more information, see Configure an API key in environment variables.
Request
- HTTP method: POST
-
Request URL
Replace
{WorkspaceId}with your workspace ID.Region
Endpoint
China (Beijing)
https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/models/limits -
Authentication
Set
Authorization: Bearer {API_KEY}in the request header.
Request parameters
All parameters are passed through the request body.
Parameter | Type | Required | Description |
|---|---|---|---|
models | Array[Object] | Yes | List of per-model rate limit items. Required. The number of items must be 1~200. Example: |
models[].model | String | Yes | The model ID. Cannot be empty. Examples: |
models[].operation_type | String | No | Operation type. Valid values:
Default value: |
models[].request_limit | Number | No | Request count limit (QPM), non-negative. Maximum number of requests per minute, in requests/minute. Must be empty when |
models[].request_limit_period | Number | No | Time period for the request rate limit, a positive integer in seconds. For example, |
models[].usage_limit | Number | No | Usage limit (TPM), non-negative. Maximum token usage per minute. Must be empty when |
models[].usage_limit_period | Number | No | Time period for the usage limit, a positive integer in seconds. For example, |
Response parameters
Parameter | Type | Description |
|---|---|---|
request_id | String | The request ID. Example: |
code | String | Error code. |
message | String | Error message. |
success | Boolean | Whether the call succeeded. Example: |
output | Object | Business data. |
TPM exemption scenario
To limit only RPM and exempt TPM, the recommended two-step approach is: first call this endpoint with {"model":"X","operation_type":"DELETE"} to delete all rate limits for the target model, then pass {"model":"X","operation_type":"OVERLAY","request_limit":60,"request_limit_period":60} to set only the QPM. The two steps are not atomic, so there is a brief window without any limit in between.