---
title: "Update an AI Gateway rate limit"
method: PATCH
path: "/api/v2/rate-limits/{id}"
tags: ["AI Gateway"]
---

# Update an AI Gateway rate limit

`PATCH /api/v2/rate-limits/{id}`

## Request

- Base URL: `https://api.datadoghq.com`
- URL: `https://api.datadoghq.com/api/v2/rate-limits/{id}`
- Auth: one of:
  - API key in header `DD-API-KEY` and API key in header `DD-APPLICATION-KEY`
  - OAuth 2
    - Authorization code: `/oauth2/v1/authorize`
    - Token URL: `/oauth2/v1/token` scopes: `ai_gateway_config_write`
- TypeScript: <https://skmtc.dev/datadog/apis/datadog-api-v2-collection/docs/api/v2/rate-limits/:id/patch.ts> (a function with typed inputs; its response is checked against the schema)

Update a rate limit. Only the attributes sent are changed. Scope stays editable, and changes never reset current usage. Returns 409 when the rule was changed concurrently or the new scope duplicates another rule.

## Path parameters

- `id` string, uuid, required

## Request body

- AiGatewayRateLimitUpdateRequest: Request to update an AI Gateway rate limit.
  - `data` AiGatewayRateLimitUpdateData, required: Data used to update an AI Gateway rate limit.
    - `attributes` AiGatewayRateLimitUpdateAttributes, required: Attributes used to update an AI Gateway rate limit. Only sent fields are changed.
      - `enabled` boolean: Whether this rate limit is active.
      - `input_tokens_per_minute` integer, nullable: Set to 0 to remove the request limit. Null is ignored. At least one limit must remain.
      - `mode` 'ALERT' | 'ENFORCE': Action taken when request rate exceeds the limit.
      - `name` string: Rate limit name.
      - `output_tokens_per_minute` integer, nullable: Set to 0 to remove the request limit. Null is ignored. At least one limit must remain.
      - `requests_per_minute` integer, nullable: Set to 0 to remove the request limit. Null is ignored. At least one limit must remain.
      - `tags` object, nullable: Replaces all scope tags. An empty object clears them. Null is ignored.
      - `team_id` string, nullable: Replaces the Team scope. An empty string clears it. Null is ignored.
      - `user_id` string, nullable: Replaces the user scope. An empty string clears it. Null is ignored.
    - `id` string, uuid, required: Rate limit UUID. Must match the path parameter.
    - `type` 'rate-limits', required: AI Gateway rate limit resource type.

## Response `200`

OK

- AiGatewayRateLimitResponse: Response containing one AI Gateway rate limit.
  - `data` AiGatewayRateLimitResource, required: AI Gateway rate limit resource.
    - `attributes` AiGatewayRateLimitAttributes, required: Attributes of an AI Gateway rate limit.
      - `created_at` string, date-time, required: Creation timestamp.
      - `created_by` string, required: Email of the user who created this rate limit.
      - `enabled` boolean, required: Whether this rate limit is active.
      - `input_tokens_per_minute` integer, nullable: Maximum input tokens per rolling minute shared by all matching traffic. Null when this rule does not limit input tokens.
      - `mode` 'ALERT' | 'ENFORCE', required: Action taken when request rate exceeds the limit.
      - `monitor_id` integer, nullable: Datadog monitor that alerts on this rule. Null until one is provisioned.
      - `name` string, required: Rate limit name.
      - `output_tokens_per_minute` integer, nullable: Maximum output tokens per rolling minute shared by all matching traffic. Null when this rule does not limit output tokens.
      - `requests_per_minute` integer, nullable: Maximum requests per rolling minute shared by all matching traffic. Null when this rule does not limit requests.
      - `revision` integer, required: Increases on every change to the definition.
      - `scope_restricted` boolean, required: Whether provider or model scope metadata was withheld. Omit unchanged scope fields on an unrelated update to preserve their saved values.
      - `tags` object, required: Optional scope tags, such as provider, model, ml_app, or custom dimensions. A request matches when it has all of these tags.
      - `team_id` string, uuid, nullable: Optional Team UUID. Count only requests attributed to this Datadog Team.
      - `updated_at` string, date-time, required: Last modification timestamp.
      - `updated_by` string, required: Email of the user who last modified this rate limit.
      - `user_id` string, uuid, nullable: Optional user UUID. Count only this user's requests.
    - `id` string, uuid, required: Rate limit UUID.
    - `type` 'rate-limits', required: AI Gateway rate limit resource type.

## Other responses

- `400`: Bad Request
- `404`: Not Found
- `409`: Conflict
- `429`: Too many requests

---

[API](https://skmtc.dev/datadog/apis/datadog-api-v2-collection.md) - [All operations](https://skmtc.dev/datadog/apis/datadog-api-v2-collection/llms.txt) - [OpenAPI document](https://skmtc.dev/datadog/apis/datadog-api-v2-collection/revisions/3f70db624329?raw)
