# Update model rate limits

> 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

- <strong>HTTP method</strong>: POST

- <strong>Request URL</strong>

  Replace `{WorkspaceId}` with your workspace ID.

| Region          | Endpoint                                                                  |
| --------------- | ------------------------------------------------------------------------- |
| China (Beijing) | `https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/models/limits` |

- <strong>Authentication</strong>

  Set `Authorization: Bearer {API_KEY}` in the request header.

## Request parameters

All parameters are passed through the request body.

<table style={{ display: "table", tableLayout: "fixed", width: "100%" }}>
  <colgroup>
    <col style={{ width: "22%" }} />

    <col style={{ width: "12%" }} />

    <col style={{ width: "12%" }} />

    <col style={{ width: "54%" }} />
  </colgroup>

  <thead><tr><th><p><strong>Parameter</strong></p></th><th><p><strong>Type</strong></p></th><th><p><strong>Required</strong></p></th><th><p><strong>Description</strong></p></th></tr></thead>

  <tbody>
    <tr><td><p><code>models</code></p></td><td><p>Array\[Object]</p></td><td><p>Yes</p></td><td><p>List of per-model rate limit items. The number of items must be 1 to 200. Example: <code>\[\{"model":"qwen-plus","request\_limit":60}]</code></p></td></tr>
    <tr><td><p><code>models\[].model</code></p></td><td><p>String</p></td><td><p>Yes</p></td><td><p>The model ID. Cannot be empty. Examples: <code>qwen-plus</code>, <code>qwen3.7-plus</code>.</p></td></tr>
    <tr><td><p><code>models\[].operation\_type</code></p></td><td><p>String</p></td><td><p>No</p></td><td><p>Operation type. Valid values:</p><ul><li><p><code>OVERLAY</code>: Merge overlay. Only the passed fields are overridden; fields not passed are backfilled with their current values.</p></li><li><p><code>DELETE</code>: Delete the rate limit. All rate limit value fields must be empty.</p></li></ul><p>Default value: <code>OVERLAY</code>.</p></td></tr>
    <tr><td><p><code>models\[].request\_limit</code></p></td><td><p>Number</p></td><td><p>No</p></td><td><p>Request count limit (QPM), non-negative. Maximum number of requests per minute, in requests/minute. Must be empty when <code>operation\_type=DELETE</code>. Default value: <code>null</code> (no change). Example: <code>60</code>.</p></td></tr>
    <tr><td><p><code>models\[].request\_limit\_period</code></p></td><td><p>Number</p></td><td><p>No</p></td><td><p>Time period for the request rate limit, a positive integer in seconds. For example, <code>60</code> = 1 minute. Default value: <code>null</code> (no change).</p></td></tr>
    <tr><td><p><code>models\[].usage\_limit</code></p></td><td><p>Number</p></td><td><p>No</p></td><td><p>Usage limit (TPM), non-negative. Maximum token usage per minute. Must be empty when <code>operation\_type=DELETE</code>. Default value: <code>null</code> (no change). Example: <code>100000</code>.</p></td></tr>
    <tr><td><p><code>models\[].usage\_limit\_period</code></p></td><td><p>Number</p></td><td><p>No</p></td><td><p>Time period for the usage limit, a positive integer in seconds. For example, <code>60</code> = 1 minute. Default value: <code>null</code> (no change).</p></td></tr>
  </tbody>
</table>

## Response parameters

<table style={{ display: "table", tableLayout: "fixed", width: "100%" }}>
  <colgroup>
    <col style={{ width: "20%" }} />

    <col style={{ width: "12%" }} />

    <col style={{ width: "68%" }} />
  </colgroup>

  <thead><tr><th><p><strong>Parameter</strong></p></th><th><p><strong>Type</strong></p></th><th><p><strong>Description</strong></p></th></tr></thead>

  <tbody>
    <tr><td><p><code>request\_id</code></p></td><td><p>String</p></td><td><p>The request ID. Example: <code>d5f5201f-ee7a-9e3d-8569-bc0eedec21f9</code>.</p></td></tr>
    <tr><td><p><code>code</code></p></td><td><p>String</p></td><td><p>Error code. <code>null</code> on success.</p></td></tr>
    <tr><td><p><code>message</code></p></td><td><p>String</p></td><td><p>Error message. <code>null</code> on success.</p></td></tr>
    <tr><td><p><code>success</code></p></td><td><p>Boolean</p></td><td><p>Whether the call succeeded. Example: <code>true</code>.</p></td></tr>
    <tr><td><p><code>output</code></p></td><td><p>Object</p></td><td><p>Business data. <code>null</code> for this endpoint.</p></td></tr>
  </tbody>
</table>

## TPM exemption scenario

To limit only RPM and exempt TPM, 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.

## Sample requests

<strong>Example 1: Set QPM=60 and TPM=100000</strong>

```bash
curl -X POST "https://dashscope.aliyuncs.com/api/v1/models/limits" \
    --header "Authorization: Bearer ${DASHSCOPE_API_KEY}" \
    --header 'Content-Type: application/json' \
    --data '{
        "models": [
            {
                "model": "qwen-plus",
                "operation_type": "OVERLAY",
                "request_limit": 60,
                "request_limit_period": 60,
                "usage_limit": 100000,
                "usage_limit_period": 60
            }
        ]
    }'
```

<strong>Example 2: Delete rate limits</strong>

```bash
curl -X POST "https://dashscope.aliyuncs.com/api/v1/models/limits" \
    --header "Authorization: Bearer ${DASHSCOPE_API_KEY}" \
    --header 'Content-Type: application/json' \
    --data '{
        "models": [
            {"model": "qwen-plus", "operation_type": "DELETE"}
        ]
    }'
```

## Sample response

<strong>Success example</strong>

```json
{
    "code": null,
    "message": null,
    "success": true,
    "output": null,
    "request_id": "d5f5201f-ee7a-9e3d-8569-bc0eedec21f9"
}
```

<strong>Failure example</strong>

```json
{
    "code": "InvalidParameter",
    "message": "Cannot set TPM without QPM for model qwen-plus: no existing QPM limit, please set QPM first",
    "success": false,
    "output": null,
    "request_id": "d5f5201f-ee7a-9e3d-8569-bc0eedec21f9"
}
```

## Error codes

If the call fails, an error message is returned. For more information about error codes and solutions, see [Error messages](/help/en/model-studio/error-code).