|
67 | 67 | from datadog_api_client.v2.model.ai_gateway_rate_limit_create_request import AiGatewayRateLimitCreateRequest |
68 | 68 | from datadog_api_client.v2.model.ai_gateway_rate_limit_usage_list_response import AiGatewayRateLimitUsageListResponse |
69 | 69 | from datadog_api_client.v2.model.ai_gateway_rate_limit_update_request import AiGatewayRateLimitUpdateRequest |
| 70 | +from datadog_api_client.v2.model.ai_gateway_rate_limit_instance_list_response import ( |
| 71 | + AiGatewayRateLimitInstanceListResponse, |
| 72 | +) |
| 73 | +from datadog_api_client.v2.model.ai_gateway_rate_limit_instance_sort import AiGatewayRateLimitInstanceSort |
| 74 | +from datadog_api_client.v2.model.ai_gateway_rate_limit_instances_summary_response import ( |
| 75 | + AiGatewayRateLimitInstancesSummaryResponse, |
| 76 | +) |
70 | 77 | from datadog_api_client.v2.model.ai_gateway_routing_rule_list_response import AiGatewayRoutingRuleListResponse |
71 | 78 | from datadog_api_client.v2.model.ai_gateway_routing_rule_response import AiGatewayRoutingRuleResponse |
72 | 79 | from datadog_api_client.v2.model.ai_gateway_routing_rule_create_request import AiGatewayRoutingRuleCreateRequest |
@@ -778,6 +785,35 @@ def __init__(self, api_client=None): |
778 | 785 | api_client=api_client, |
779 | 786 | ) |
780 | 787 |
|
| 788 | + self._get_ai_gateway_rate_limit_instances_summary_endpoint = _Endpoint( |
| 789 | + settings={ |
| 790 | + "response_type": (AiGatewayRateLimitInstancesSummaryResponse,), |
| 791 | + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], |
| 792 | + "endpoint_path": "/api/v2/rate-limits/{id}/instances/summary", |
| 793 | + "operation_id": "get_ai_gateway_rate_limit_instances_summary", |
| 794 | + "http_method": "GET", |
| 795 | + "version": "v2", |
| 796 | + }, |
| 797 | + params_map={ |
| 798 | + "id": { |
| 799 | + "required": True, |
| 800 | + "openapi_types": (UUID,), |
| 801 | + "attribute": "id", |
| 802 | + "location": "path", |
| 803 | + }, |
| 804 | + "split_dim": { |
| 805 | + "openapi_types": ([str],), |
| 806 | + "attribute": "split_dim", |
| 807 | + "location": "query", |
| 808 | + "collection_format": "multi", |
| 809 | + }, |
| 810 | + }, |
| 811 | + headers_map={ |
| 812 | + "accept": ["application/json"], |
| 813 | + }, |
| 814 | + api_client=api_client, |
| 815 | + ) |
| 816 | + |
781 | 817 | self._get_ai_gateway_rate_limit_usage_endpoint = _Endpoint( |
782 | 818 | settings={ |
783 | 819 | "response_type": (AiGatewayRateLimitUsageListResponse,), |
@@ -1100,6 +1136,57 @@ def __init__(self, api_client=None): |
1100 | 1136 | api_client=api_client, |
1101 | 1137 | ) |
1102 | 1138 |
|
| 1139 | + self._list_ai_gateway_rate_limit_instances_endpoint = _Endpoint( |
| 1140 | + settings={ |
| 1141 | + "response_type": (AiGatewayRateLimitInstanceListResponse,), |
| 1142 | + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], |
| 1143 | + "endpoint_path": "/api/v2/rate-limits/{id}/instances", |
| 1144 | + "operation_id": "list_ai_gateway_rate_limit_instances", |
| 1145 | + "http_method": "GET", |
| 1146 | + "version": "v2", |
| 1147 | + }, |
| 1148 | + params_map={ |
| 1149 | + "id": { |
| 1150 | + "required": True, |
| 1151 | + "openapi_types": (UUID,), |
| 1152 | + "attribute": "id", |
| 1153 | + "location": "path", |
| 1154 | + }, |
| 1155 | + "split_dim": { |
| 1156 | + "openapi_types": ([str],), |
| 1157 | + "attribute": "split_dim", |
| 1158 | + "location": "query", |
| 1159 | + "collection_format": "multi", |
| 1160 | + }, |
| 1161 | + "sort": { |
| 1162 | + "openapi_types": (AiGatewayRateLimitInstanceSort,), |
| 1163 | + "attribute": "sort", |
| 1164 | + "location": "query", |
| 1165 | + }, |
| 1166 | + "limit": { |
| 1167 | + "validation": { |
| 1168 | + "inclusive_maximum": 500, |
| 1169 | + "inclusive_minimum": 1, |
| 1170 | + }, |
| 1171 | + "openapi_types": (int,), |
| 1172 | + "attribute": "limit", |
| 1173 | + "location": "query", |
| 1174 | + }, |
| 1175 | + "offset": { |
| 1176 | + "validation": { |
| 1177 | + "inclusive_minimum": 0, |
| 1178 | + }, |
| 1179 | + "openapi_types": (int,), |
| 1180 | + "attribute": "offset", |
| 1181 | + "location": "query", |
| 1182 | + }, |
| 1183 | + }, |
| 1184 | + headers_map={ |
| 1185 | + "accept": ["application/json"], |
| 1186 | + }, |
| 1187 | + api_client=api_client, |
| 1188 | + ) |
| 1189 | + |
1103 | 1190 | self._list_ai_gateway_rate_limits_endpoint = _Endpoint( |
1104 | 1191 | settings={ |
1105 | 1192 | "response_type": (AiGatewayRateLimitListResponse,), |
@@ -1590,7 +1677,7 @@ def create_ai_gateway_rate_limit( |
1590 | 1677 | ) -> AiGatewayRateLimitResponse: |
1591 | 1678 | """Create an AI Gateway rate limit. |
1592 | 1679 |
|
1593 | | - Create a rate limit. All requests matching its scope share one allowance, and every matching rate limit applies. Returns 409 when another active rate limit has the same user, Team, and tags, or when the organization already has the maximum number of rate limits. |
| 1680 | + Create a rate limit. All requests matching its scope share one allowance, unless a selector makes it a template, which gives each matched user, Team, or value its own allowance. Every matching rate limit applies. Returns 409 when another active rate limit has the same user, Team, tags, and selector, or when the organization already has the maximum number of rate limits. |
1594 | 1681 |
|
1595 | 1682 | :type body: AiGatewayRateLimitCreateRequest |
1596 | 1683 | :rtype: AiGatewayRateLimitResponse |
@@ -1990,6 +2077,30 @@ def get_ai_gateway_rate_limit( |
1990 | 2077 |
|
1991 | 2078 | return self._get_ai_gateway_rate_limit_endpoint.call_with_http_info(**kwargs) |
1992 | 2079 |
|
| 2080 | + def get_ai_gateway_rate_limit_instances_summary( |
| 2081 | + self, |
| 2082 | + id: UUID, |
| 2083 | + *, |
| 2084 | + split_dim: Union[List[str], UnsetType] = unset, |
| 2085 | + ) -> AiGatewayRateLimitInstancesSummaryResponse: |
| 2086 | + """Get an AI Gateway rate limit counter summary. |
| 2087 | +
|
| 2088 | + Aggregate a template rate limit's counters, including how many there are, how many are near or at their limit, and the fullest counter's utilization. Use split_dim to aggregate only counters that match every given dimension value. |
| 2089 | +
|
| 2090 | + :param id: Rate limit UUID. |
| 2091 | + :type id: UUID |
| 2092 | + :param split_dim: Keep only counters whose split dimension equals a value, written as ``<dim>=<value>`` , such as ``split_dim=user_id=<uuid>&split_dim=model=gpt-4o``. Dimensions use the ``split_dims`` names ``user_id`` , ``team_id`` , ``model`` , ``provider`` , and ``tag:<key>``. Repeat the parameter to filter on several dimensions; a counter must match all of them. Each dimension may appear once and must be a per-value dimension of the rate limit. |
| 2093 | + :type split_dim: [str], optional |
| 2094 | + :rtype: AiGatewayRateLimitInstancesSummaryResponse |
| 2095 | + """ |
| 2096 | + kwargs: Dict[str, Any] = {} |
| 2097 | + kwargs["id"] = id |
| 2098 | + |
| 2099 | + if split_dim is not unset: |
| 2100 | + kwargs["split_dim"] = split_dim |
| 2101 | + |
| 2102 | + return self._get_ai_gateway_rate_limit_instances_summary_endpoint.call_with_http_info(**kwargs) |
| 2103 | + |
1993 | 2104 | def get_ai_gateway_rate_limit_usage( |
1994 | 2105 | self, |
1995 | 2106 | ) -> AiGatewayRateLimitUsageListResponse: |
@@ -2252,6 +2363,48 @@ def list_ai_gateway_providers( |
2252 | 2363 | kwargs: Dict[str, Any] = {} |
2253 | 2364 | return self._list_ai_gateway_providers_endpoint.call_with_http_info(**kwargs) |
2254 | 2365 |
|
| 2366 | + def list_ai_gateway_rate_limit_instances( |
| 2367 | + self, |
| 2368 | + id: UUID, |
| 2369 | + *, |
| 2370 | + split_dim: Union[List[str], UnsetType] = unset, |
| 2371 | + sort: Union[AiGatewayRateLimitInstanceSort, UnsetType] = unset, |
| 2372 | + limit: Union[int, UnsetType] = unset, |
| 2373 | + offset: Union[int, UnsetType] = unset, |
| 2374 | + ) -> AiGatewayRateLimitInstanceListResponse: |
| 2375 | + """List AI Gateway rate limit counters. |
| 2376 | +
|
| 2377 | + List the counters of a template rate limit, one per matched user, Team, or value, with their live usage. Counters appear within a few minutes of their first request and are dropped after 30 days without one. Usage is read for counters seen in the last 20 minutes, at most 200 per request; past that, rows carry usage_known false. Counters for a provider or model the caller can't see are left out. A rate limit with one shared allowance, including one whose selector has no per_value entry, returns an empty list. |
| 2378 | +
|
| 2379 | + :param id: Rate limit UUID. |
| 2380 | + :type id: UUID |
| 2381 | + :param split_dim: Keep only counters whose split dimension equals a value, written as ``<dim>=<value>`` , such as ``split_dim=user_id=<uuid>&split_dim=model=gpt-4o``. Dimensions use the ``split_dims`` names ``user_id`` , ``team_id`` , ``model`` , ``provider`` , and ``tag:<key>``. Repeat the parameter to filter on several dimensions; a counter must match all of them. Each dimension may appear once and must be a per-value dimension of the rate limit. |
| 2382 | + :type split_dim: [str], optional |
| 2383 | + :param sort: Sort order for rate limit counters. |
| 2384 | + :type sort: AiGatewayRateLimitInstanceSort, optional |
| 2385 | + :param limit: Maximum number of rate limit counters to return. |
| 2386 | + :type limit: int, optional |
| 2387 | + :param offset: Number of rate limit counters to skip. |
| 2388 | + :type offset: int, optional |
| 2389 | + :rtype: AiGatewayRateLimitInstanceListResponse |
| 2390 | + """ |
| 2391 | + kwargs: Dict[str, Any] = {} |
| 2392 | + kwargs["id"] = id |
| 2393 | + |
| 2394 | + if split_dim is not unset: |
| 2395 | + kwargs["split_dim"] = split_dim |
| 2396 | + |
| 2397 | + if sort is not unset: |
| 2398 | + kwargs["sort"] = sort |
| 2399 | + |
| 2400 | + if limit is not unset: |
| 2401 | + kwargs["limit"] = limit |
| 2402 | + |
| 2403 | + if offset is not unset: |
| 2404 | + kwargs["offset"] = offset |
| 2405 | + |
| 2406 | + return self._list_ai_gateway_rate_limit_instances_endpoint.call_with_http_info(**kwargs) |
| 2407 | + |
2255 | 2408 | def list_ai_gateway_rate_limits( |
2256 | 2409 | self, |
2257 | 2410 | ) -> AiGatewayRateLimitListResponse: |
@@ -2478,7 +2631,7 @@ def update_ai_gateway_rate_limit( |
2478 | 2631 | ) -> AiGatewayRateLimitResponse: |
2479 | 2632 | """Update an AI Gateway rate limit. |
2480 | 2633 |
|
2481 | | - 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. |
| 2634 | + Update a rate limit. Only the attributes sent are changed, and changes never reset current usage. Scope stays editable, except on a template rate limit, whose user_id, team_id, and tags are rejected with 400. Returns 409 when the rule was changed concurrently or the new scope duplicates another rule. |
2482 | 2635 |
|
2483 | 2636 | :param id: Rate limit UUID. |
2484 | 2637 | :type id: UUID |
|
0 commit comments