From 80b4d8a902b70a5596529cf60365b0f3c59bc87d Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 13 Nov 2026 16:00:33 +0000 Subject: [PATCH] Regenerate client from commit 4b6fa08 of spec repo --- .generator/schemas/v2/openapi.yaml | 128 ++++++++++++++++-- .../v2/ai-gateway/CreateAiGatewayRateLimit.py | 1 + ...istAiGatewayRateLimitInstancesSummaries.py | 16 +++ .../v2/ai-gateway/UpdateAiGatewayRateLimit.py | 1 + src/datadog_api_client/configuration.py | 1 + .../v2/api/ai_gateway_api.py | 35 ++++- ...way_nullable_routing_rule_tier_ordering.py | 2 +- .../model/ai_gateway_rate_limit_attributes.py | 26 ++-- ...ai_gateway_rate_limit_create_attributes.py | 14 +- ..._gateway_rate_limit_instance_attributes.py | 18 ++- ...rate_limit_instances_summary_attributes.py | 2 +- ...e_limit_instances_summary_list_response.py | 44 ++++++ ...ai_gateway_rate_limit_update_attributes.py | 12 ++ .../ai_gateway_rate_limit_usage_attributes.py | 11 ++ .../ai_gateway_routing_classifier_request.py | 2 +- .../ai_gateway_routing_rule_target_request.py | 4 +- .../ai_gateway_routing_rule_tier_request.py | 2 +- src/datadog_api_client/v2/models/__init__.py | 4 + tests/v2/features/ai_gateway.feature | 28 +++- tests/v2/features/given.json | 12 ++ tests/v2/features/undo.json | 15 +- 21 files changed, 341 insertions(+), 37 deletions(-) create mode 100644 examples/v2/ai-gateway/ListAiGatewayRateLimitInstancesSummaries.py create mode 100644 src/datadog_api_client/v2/model/ai_gateway_rate_limit_instances_summary_list_response.py diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 747c82b295..57865d0cfe 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -10826,7 +10826,7 @@ components: - MAX AiGatewayNullableRoutingRuleTierOrdering: description: >- - How a tier orders its targets. Omission preserves the saved same-position tier on update; null resets to configured. New tiers default to configured. The weighted_affinity ordering distributes first-choice assignments by relative target weights and accepts only model targets with an explicit provider, without repeated provider and model pairs in the same tier. The `classified` ordering is allowed only in the first tier and requires a classifier, destination rubrics, and one default destination. Its targets are model targets that each name one provider, not "*". Besides the default, it needs 1 to 9 destinations, each with a different rubric. Classified routing is in Preview: saving a classified tier returns 403 Forbidden unless the feature is enabled for the organization. + How a tier orders its targets. Omission preserves the saved same-position tier on update; null resets to configured. New tiers default to configured. The weighted_affinity ordering distributes first-choice assignments by relative target weights and accepts only model targets with an explicit provider, without repeated provider and model pairs in the same tier. The `classified` ordering is allowed only in the first tier and requires a classifier, destination rubrics, and one default destination. enum: - configured - weighted_affinity @@ -11356,6 +11356,14 @@ components: AiGatewayRateLimitAttributes: description: Attributes of an AI Gateway rate limit. properties: + cost_microcents_per_minute: + description: Maximum priced spend per rolling minute, in microcents of 1e-8 USD each, shared by all matching traffic, or per counter for a template rate limit. Null when this rule does not limit cost. + example: 100000000 + format: int64 + maximum: 10000000000000 + minimum: 1 + nullable: true + type: integer created_at: description: Creation timestamp. example: "2026-09-01T00:00:00Z" @@ -11459,6 +11467,8 @@ components: - scope_restricted - name - tags + - is_template + - template_split_dims - mode - enabled - revision @@ -11470,6 +11480,14 @@ components: AiGatewayRateLimitCreateAttributes: description: Attributes used to create an AI Gateway rate limit. properties: + cost_microcents_per_minute: + description: Maximum priced spend per rolling minute, in microcents of 1e-8 USD each. At most 10000000000000, that is $100,000. In `ENFORCE` mode, requests to a model with no pricing are rejected, because their cost can't be counted. + example: 100000000 + format: int64 + maximum: 10000000000000 + minimum: 1 + nullable: true + type: integer input_tokens_per_minute: description: Maximum input tokens per rolling minute. format: int64 @@ -11491,7 +11509,7 @@ components: nullable: true type: integer requests_per_minute: - description: Maximum requests per rolling minute. At least one of `requests_per_minute`, `input_tokens_per_minute`, and `output_tokens_per_minute` is required. + description: Maximum requests per rolling minute. At least one of `requests_per_minute`, `input_tokens_per_minute`, `output_tokens_per_minute`, and `cost_microcents_per_minute` is required. example: 600 format: int64 maximum: 10000000 @@ -11540,6 +11558,17 @@ components: AiGatewayRateLimitInstanceAttributes: description: One counter of a template rate limit and its live usage. properties: + cost_microcents: + description: Priced spend, in microcents, counted in the rolling one-minute window. 0 when the rate limit doesn't limit cost. + example: 25000000 + format: int64 + type: integer + cost_microcents_per_minute: + description: The rate limit's per-counter spend limit, in microcents. Null when it doesn't limit cost. + example: 100000000 + format: int64 + nullable: true + type: integer first_seen: description: When the gateway first recorded a request for this counter. example: "2026-10-28T10:00:00Z" @@ -11561,7 +11590,7 @@ components: example: "v1|7:user_id=36:11111111-1111-1111-1111-111111111111" type: string last_seen: - description: When the gateway last recorded a request for this counter; up to a few minutes behind live traffic. + description: When the gateway last saw this counter hot, that is near or at a limit or limiting; up to a few minutes behind live traffic. example: "2026-10-28T10:05:00Z" format: date-time type: string @@ -11684,7 +11713,7 @@ components: description: Aggregate of a template rate limit's counters. properties: instance_count: - description: Number of counters. + description: Number of counters that were near or at a limit, or limited a request, in the last hour. Counters with room to spare aren't recorded. example: 14 format: int64 type: integer @@ -11734,6 +11763,17 @@ components: - max_utilization - truncated type: object + AiGatewayRateLimitInstancesSummaryListResponse: + description: Response containing the counter summary of every template rate limit in the organization. + properties: + data: + items: + $ref: "#/components/schemas/AiGatewayRateLimitInstancesSummaryResource" + description: The aggregate of one template rate limit's counters. + type: array + required: + - data + type: object AiGatewayRateLimitInstancesSummaryResource: description: Aggregate of a template rate limit's counters. properties: @@ -11854,6 +11894,13 @@ components: AiGatewayRateLimitUpdateAttributes: description: Attributes used to update an AI Gateway rate limit. Only sent fields are changed. properties: + cost_microcents_per_minute: + description: Spend limit in microcents per rolling minute. Set to 0 to remove the cost limit. Null is ignored. At least one limit must remain. + format: int64 + maximum: 10000000000000 + minimum: 0 + nullable: true + type: integer enabled: description: Whether this rate limit is active. type: boolean @@ -11926,6 +11973,11 @@ components: AiGatewayRateLimitUsageAttributes: description: Live consumption of one AI Gateway rate limit. properties: + cost_microcents: + description: Priced spend, in microcents, counted in the rolling one-minute window. Only rules with a cost limit count it, so it is 0 for other rules and for the untracked and total entries. + example: 25000000 + format: int64 + type: integer input_tokens: description: Input tokens counted in the rolling one-minute window. example: 45000 @@ -12050,8 +12102,7 @@ components: example: gpt-6-luna type: string provider: - description: >- - Decision-model provider slug. It must name a provider of type `openai`, `baseten`, or `typesafe`, the provider types that serve a decision model. Omit together with model to preserve the saved selection. + description: Decision-model provider slug. Omit together with model to preserve the saved selection. example: openai type: string type: object @@ -12303,14 +12354,13 @@ components: minimum: 1 type: integer provider: - description: Provider slug. weighted_affinity and classified tiers require an explicit provider and do not allow "*". + description: Provider slug. weighted_affinity requires an explicit provider and does not allow "*". example: prod-us type: string reasoning_level: $ref: "#/components/schemas/AiGatewayRoutingReasoningLevel" rubric: - description: >- - Destination rubric in a classified tier: when the decision model picks this destination. Up to 300 characters after leading and trailing spaces are trimmed, and different for each destination in the tier. Omission preserves a saved value; null clears it. Must be absent on the default destination. + description: Destination rubric in a classified tier. Omission preserves a saved value; null clears it. Must be absent on the default destination. example: Short factual questions. maxLength: 300 nullable: true @@ -231141,6 +231191,62 @@ paths: x-unstable: |- **Note**: This endpoint is in Preview and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/rate-limits/instances/summary: + get: + description: Aggregate the counters of every template rate limit in the organization in one call, with one summary per template in the order the rate limit list returns them. Each summary is the one the single-template counter summary endpoint returns without split_dim, including scope_restricted and truncated. Rate limits with one shared allowance are left out. Summaries are cached for up to 15 seconds. + operationId: ListAiGatewayRateLimitInstancesSummaries + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + instance_count: 14 + limited_requests: 25 + limiting_count: 2 + max_utilization: 1.2 + near_limit_count: 3 + rate_limit_id: 33333333-3333-3333-3333-333333333333 + scope_restricted: false + truncated: false + would_limit_requests: 0 + id: 33333333-3333-3333-3333-333333333333 + type: rate-limit-instances-summary + - attributes: + instance_count: 0 + limited_requests: 0 + limiting_count: 0 + max_utilization: 0 + near_limit_count: 0 + rate_limit_id: 44444444-4444-4444-4444-444444444444 + scope_restricted: true + truncated: false + would_limit_requests: 0 + id: 44444444-4444-4444-4444-444444444444 + type: rate-limit-instances-summary + schema: + $ref: "#/components/schemas/AiGatewayRateLimitInstancesSummaryListResponse" + description: OK + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - ai_gateway_config_read + summary: List AI Gateway rate limit counter summaries + tags: + - AI Gateway + x-permission: + operator: OR + permissions: + - ai_gateway_config_read + x-unstable: |- + **Note**: This endpoint is in Preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/rate-limits/usage: get: description: Get live usage for the organization's rate limits. Returns requests and tokens counted in the rolling one-minute window and requests limited in the last 15 minutes for each enabled rate limit, plus `untracked` (traffic no enforced rate limit covers) and `total` (all gateway traffic). @@ -231344,7 +231450,7 @@ paths: If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/rate-limits/{id}/instances: get: - description: 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, and when the caller can't see the template's selector, the list is empty. A rate limit with one shared allowance, including one whose selector has no per_value entry, returns an empty list. Returns 503 when counter usage can't be read. + description: List the hot counters of a template rate limit, one per matched user, Team, or value, with their live usage. Only counters at 80% or more of a limit, or that limited or would have limited a request, in the last hour are listed. A counter appears within a few minutes of becoming hot. Usage is read for at most 200 counters per request; past that, rows carry usage_known false. Counters for a provider or model the caller can't see are left out, and when the caller can't see the template's selector, the list is empty. A rate limit with one shared allowance, including one whose selector has no per_value entry, returns an empty list. Returns 503 when counter usage can't be read. operationId: ListAiGatewayRateLimitInstances parameters: - $ref: "#/components/parameters/AiGatewayRateLimitID" @@ -231405,7 +231511,7 @@ paths: If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/rate-limits/{id}/instances/summary: get: - description: 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. When the caller can't see the template's selector, every count is zero and scope_restricted is true. Summaries are cached for up to 15 seconds. Returns 503 when counter usage can't be read. + description: Aggregate a template rate limit's hot counters (those near or at a limit, or limiting, in the last hour), 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. When the caller can't see the template's selector, every count is zero and scope_restricted is true. Summaries are cached for up to 15 seconds. Returns 503 when counter usage can't be read. operationId: GetAiGatewayRateLimitInstancesSummary parameters: - $ref: "#/components/parameters/AiGatewayRateLimitID" diff --git a/examples/v2/ai-gateway/CreateAiGatewayRateLimit.py b/examples/v2/ai-gateway/CreateAiGatewayRateLimit.py index dfb247d2f8..54fd16891f 100644 --- a/examples/v2/ai-gateway/CreateAiGatewayRateLimit.py +++ b/examples/v2/ai-gateway/CreateAiGatewayRateLimit.py @@ -16,6 +16,7 @@ body = AiGatewayRateLimitCreateRequest( data=AiGatewayRateLimitCreateData( attributes=AiGatewayRateLimitCreateAttributes( + cost_microcents_per_minute=100000000, input_tokens_per_minute=None, mode=AiGatewayRateLimitMode.ALERT, name="Default rate limit", diff --git a/examples/v2/ai-gateway/ListAiGatewayRateLimitInstancesSummaries.py b/examples/v2/ai-gateway/ListAiGatewayRateLimitInstancesSummaries.py new file mode 100644 index 0000000000..2964cd9702 --- /dev/null +++ b/examples/v2/ai-gateway/ListAiGatewayRateLimitInstancesSummaries.py @@ -0,0 +1,16 @@ +""" +List AI Gateway rate limit counter summaries returns "OK" response +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.ai_gateway_api import AIGatewayApi + +configuration = Configuration() +configuration.access_token = environ["DD_BEARER_TOKEN"] +configuration.unstable_operations["list_ai_gateway_rate_limit_instances_summaries"] = True +with ApiClient(configuration) as api_client: + api_instance = AIGatewayApi(api_client) + response = api_instance.list_ai_gateway_rate_limit_instances_summaries() + + print(response) diff --git a/examples/v2/ai-gateway/UpdateAiGatewayRateLimit.py b/examples/v2/ai-gateway/UpdateAiGatewayRateLimit.py index 86ba1f82e4..8bea2ae767 100644 --- a/examples/v2/ai-gateway/UpdateAiGatewayRateLimit.py +++ b/examples/v2/ai-gateway/UpdateAiGatewayRateLimit.py @@ -15,6 +15,7 @@ body = AiGatewayRateLimitUpdateRequest( data=AiGatewayRateLimitUpdateData( attributes=AiGatewayRateLimitUpdateAttributes( + cost_microcents_per_minute=None, input_tokens_per_minute=None, mode=AiGatewayRateLimitMode.ALERT, output_tokens_per_minute=None, diff --git a/src/datadog_api_client/configuration.py b/src/datadog_api_client/configuration.py index 227f8a56f6..0f851d3305 100644 --- a/src/datadog_api_client/configuration.py +++ b/src/datadog_api_client/configuration.py @@ -396,6 +396,7 @@ def __init__( "v2.list_ai_gateway_provider_models": False, "v2.list_ai_gateway_providers": False, "v2.list_ai_gateway_rate_limit_instances": False, + "v2.list_ai_gateway_rate_limit_instances_summaries": False, "v2.list_ai_gateway_rate_limits": False, "v2.list_ai_gateway_routing_rules": False, "v2.override_ai_gateway_budget_instance_capacity": False, diff --git a/src/datadog_api_client/v2/api/ai_gateway_api.py b/src/datadog_api_client/v2/api/ai_gateway_api.py index 30e4e4e9d6..3534f21310 100644 --- a/src/datadog_api_client/v2/api/ai_gateway_api.py +++ b/src/datadog_api_client/v2/api/ai_gateway_api.py @@ -65,6 +65,9 @@ from datadog_api_client.v2.model.ai_gateway_rate_limit_list_response import AiGatewayRateLimitListResponse from datadog_api_client.v2.model.ai_gateway_rate_limit_response import AiGatewayRateLimitResponse from datadog_api_client.v2.model.ai_gateway_rate_limit_create_request import AiGatewayRateLimitCreateRequest +from datadog_api_client.v2.model.ai_gateway_rate_limit_instances_summary_list_response import ( + AiGatewayRateLimitInstancesSummaryListResponse, +) from datadog_api_client.v2.model.ai_gateway_rate_limit_usage_list_response import AiGatewayRateLimitUsageListResponse from datadog_api_client.v2.model.ai_gateway_rate_limit_update_request import AiGatewayRateLimitUpdateRequest from datadog_api_client.v2.model.ai_gateway_rate_limit_instance_list_response import ( @@ -1187,6 +1190,22 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._list_ai_gateway_rate_limit_instances_summaries_endpoint = _Endpoint( + settings={ + "response_type": (AiGatewayRateLimitInstancesSummaryListResponse,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/rate-limits/instances/summary", + "operation_id": "list_ai_gateway_rate_limit_instances_summaries", + "http_method": "GET", + "version": "v2", + }, + params_map={}, + headers_map={ + "accept": ["application/json"], + }, + api_client=api_client, + ) + self._list_ai_gateway_rate_limits_endpoint = _Endpoint( settings={ "response_type": (AiGatewayRateLimitListResponse,), @@ -2085,7 +2104,7 @@ def get_ai_gateway_rate_limit_instances_summary( ) -> AiGatewayRateLimitInstancesSummaryResponse: """Get an AI Gateway rate limit counter summary. - 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. When the caller can't see the template's selector, every count is zero and scope_restricted is true. Summaries are cached for up to 15 seconds. Returns 503 when counter usage can't be read. + Aggregate a template rate limit's hot counters (those near or at a limit, or limiting, in the last hour), 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. When the caller can't see the template's selector, every count is zero and scope_restricted is true. Summaries are cached for up to 15 seconds. Returns 503 when counter usage can't be read. :param id: Rate limit UUID. :type id: UUID @@ -2374,7 +2393,7 @@ def list_ai_gateway_rate_limit_instances( ) -> AiGatewayRateLimitInstanceListResponse: """List AI Gateway rate limit counters. - 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, and when the caller can't see the template's selector, the list is empty. A rate limit with one shared allowance, including one whose selector has no per_value entry, returns an empty list. Returns 503 when counter usage can't be read. + List the hot counters of a template rate limit, one per matched user, Team, or value, with their live usage. Only counters at 80% or more of a limit, or that limited or would have limited a request, in the last hour are listed. A counter appears within a few minutes of becoming hot. Usage is read for at most 200 counters per request; past that, rows carry usage_known false. Counters for a provider or model the caller can't see are left out, and when the caller can't see the template's selector, the list is empty. A rate limit with one shared allowance, including one whose selector has no per_value entry, returns an empty list. Returns 503 when counter usage can't be read. :param id: Rate limit UUID. :type id: UUID @@ -2405,6 +2424,18 @@ def list_ai_gateway_rate_limit_instances( return self._list_ai_gateway_rate_limit_instances_endpoint.call_with_http_info(**kwargs) + def list_ai_gateway_rate_limit_instances_summaries( + self, + ) -> AiGatewayRateLimitInstancesSummaryListResponse: + """List AI Gateway rate limit counter summaries. + + Aggregate the counters of every template rate limit in the organization in one call, with one summary per template in the order the rate limit list returns them. Each summary is the one the single-template counter summary endpoint returns without split_dim, including scope_restricted and truncated. Rate limits with one shared allowance are left out. Summaries are cached for up to 15 seconds. + + :rtype: AiGatewayRateLimitInstancesSummaryListResponse + """ + kwargs: Dict[str, Any] = {} + return self._list_ai_gateway_rate_limit_instances_summaries_endpoint.call_with_http_info(**kwargs) + def list_ai_gateway_rate_limits( self, ) -> AiGatewayRateLimitListResponse: diff --git a/src/datadog_api_client/v2/model/ai_gateway_nullable_routing_rule_tier_ordering.py b/src/datadog_api_client/v2/model/ai_gateway_nullable_routing_rule_tier_ordering.py index 247d5dae46..c43b289658 100644 --- a/src/datadog_api_client/v2/model/ai_gateway_nullable_routing_rule_tier_ordering.py +++ b/src/datadog_api_client/v2/model/ai_gateway_nullable_routing_rule_tier_ordering.py @@ -14,7 +14,7 @@ class AiGatewayNullableRoutingRuleTierOrdering(ModelSimple): """ - How a tier orders its targets. Omission preserves the saved same-position tier on update; null resets to configured. New tiers default to configured. The weighted_affinity ordering distributes first-choice assignments by relative target weights and accepts only model targets with an explicit provider, without repeated provider and model pairs in the same tier. The `classified` ordering is allowed only in the first tier and requires a classifier, destination rubrics, and one default destination. Its targets are model targets that each name one provider, not "*". Besides the default, it needs 1 to 9 destinations, each with a different rubric. Classified routing is in Preview: saving a classified tier returns 403 Forbidden unless the feature is enabled for the organization. + How a tier orders its targets. Omission preserves the saved same-position tier on update; null resets to configured. New tiers default to configured. The weighted_affinity ordering distributes first-choice assignments by relative target weights and accepts only model targets with an explicit provider, without repeated provider and model pairs in the same tier. The `classified` ordering is allowed only in the first tier and requires a classifier, destination rubrics, and one default destination. :param value: Must be one of ["configured", "weighted_affinity", "classified"]. :type value: str diff --git a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_attributes.py b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_attributes.py index 8496258cde..ca6afd5c15 100644 --- a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_attributes.py +++ b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_attributes.py @@ -23,6 +23,10 @@ class AiGatewayRateLimitAttributes(ModelNormal): validations = { + "cost_microcents_per_minute": { + "inclusive_maximum": 10000000000000, + "inclusive_minimum": 1, + }, "input_tokens_per_minute": { "inclusive_maximum": 100000000000, "inclusive_minimum": 1, @@ -43,6 +47,7 @@ def openapi_types(_): from datadog_api_client.v2.model.ai_gateway_rate_limit_selector_entry import AiGatewayRateLimitSelectorEntry return { + "cost_microcents_per_minute": (int, none_type), "created_at": (datetime,), "created_by": (str,), "enabled": (bool,), @@ -65,6 +70,7 @@ def openapi_types(_): } attribute_map = { + "cost_microcents_per_minute": "cost_microcents_per_minute", "created_at": "created_at", "created_by": "created_by", "enabled": "enabled", @@ -91,27 +97,31 @@ def __init__( created_at: datetime, created_by: str, enabled: bool, + is_template: bool, mode: AiGatewayRateLimitMode, name: str, revision: int, scope_restricted: bool, tags: Dict[str, str], + template_split_dims: List[str], updated_at: datetime, updated_by: str, + cost_microcents_per_minute: Union[int, none_type, UnsetType] = unset, input_tokens_per_minute: Union[int, none_type, UnsetType] = unset, - is_template: Union[bool, UnsetType] = unset, monitor_id: Union[int, none_type, UnsetType] = unset, output_tokens_per_minute: Union[int, none_type, UnsetType] = unset, requests_per_minute: Union[int, none_type, UnsetType] = unset, selector: Union[List[AiGatewayRateLimitSelectorEntry], none_type, UnsetType] = unset, team_id: Union[UUID, none_type, UnsetType] = unset, - template_split_dims: Union[List[str], UnsetType] = unset, user_id: Union[UUID, none_type, UnsetType] = unset, **kwargs, ): """ Attributes of an AI Gateway rate limit. + :param cost_microcents_per_minute: Maximum priced spend per rolling minute, in microcents of 1e-8 USD each, shared by all matching traffic, or per counter for a template rate limit. Null when this rule does not limit cost. + :type cost_microcents_per_minute: int, none_type, optional + :param created_at: Creation timestamp. :type created_at: datetime @@ -125,7 +135,7 @@ def __init__( :type input_tokens_per_minute: int, none_type, optional :param is_template: Whether the selector gives each matching value its own allowance, that is, whether it has at least one per_value entry. Returned even when scope_restricted hides the selector. - :type is_template: bool, optional + :type is_template: bool :param mode: Action taken when request rate exceeds the limit. :type mode: AiGatewayRateLimitMode @@ -158,7 +168,7 @@ def __init__( :type team_id: UUID, none_type, optional :param template_split_dims: Dimensions of the selector's per_value entries, such as user_id or tag:env, each matching value of which gets its own allowance. Empty unless is_template is true. Returned even when scope_restricted hides the selector. - :type template_split_dims: [str], optional + :type template_split_dims: [str] :param updated_at: Last modification timestamp. :type updated_at: datetime @@ -169,10 +179,10 @@ def __init__( :param user_id: Optional user UUID. Count only this user's requests. :type user_id: UUID, none_type, optional """ + if cost_microcents_per_minute is not unset: + kwargs["cost_microcents_per_minute"] = cost_microcents_per_minute if input_tokens_per_minute is not unset: kwargs["input_tokens_per_minute"] = input_tokens_per_minute - if is_template is not unset: - kwargs["is_template"] = is_template if monitor_id is not unset: kwargs["monitor_id"] = monitor_id if output_tokens_per_minute is not unset: @@ -183,8 +193,6 @@ def __init__( kwargs["selector"] = selector if team_id is not unset: kwargs["team_id"] = team_id - if template_split_dims is not unset: - kwargs["template_split_dims"] = template_split_dims if user_id is not unset: kwargs["user_id"] = user_id super().__init__(kwargs) @@ -192,10 +200,12 @@ def __init__( self_.created_at = created_at self_.created_by = created_by self_.enabled = enabled + self_.is_template = is_template self_.mode = mode self_.name = name self_.revision = revision self_.scope_restricted = scope_restricted self_.tags = tags + self_.template_split_dims = template_split_dims self_.updated_at = updated_at self_.updated_by = updated_by diff --git a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_create_attributes.py b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_create_attributes.py index 5e87246374..e5c1f86f3d 100644 --- a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_create_attributes.py +++ b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_create_attributes.py @@ -22,6 +22,10 @@ class AiGatewayRateLimitCreateAttributes(ModelNormal): validations = { + "cost_microcents_per_minute": { + "inclusive_maximum": 10000000000000, + "inclusive_minimum": 1, + }, "input_tokens_per_minute": { "inclusive_maximum": 100000000000, "inclusive_minimum": 1, @@ -42,6 +46,7 @@ def openapi_types(_): from datadog_api_client.v2.model.ai_gateway_rate_limit_selector_entry import AiGatewayRateLimitSelectorEntry return { + "cost_microcents_per_minute": (int, none_type), "input_tokens_per_minute": (int, none_type), "mode": (AiGatewayRateLimitMode,), "name": (str,), @@ -54,6 +59,7 @@ def openapi_types(_): } attribute_map = { + "cost_microcents_per_minute": "cost_microcents_per_minute", "input_tokens_per_minute": "input_tokens_per_minute", "mode": "mode", "name": "name", @@ -68,6 +74,7 @@ def openapi_types(_): def __init__( self_, name: str, + cost_microcents_per_minute: Union[int, none_type, UnsetType] = unset, input_tokens_per_minute: Union[int, none_type, UnsetType] = unset, mode: Union[AiGatewayRateLimitMode, UnsetType] = unset, output_tokens_per_minute: Union[int, none_type, UnsetType] = unset, @@ -81,6 +88,9 @@ def __init__( """ Attributes used to create an AI Gateway rate limit. + :param cost_microcents_per_minute: Maximum priced spend per rolling minute, in microcents of 1e-8 USD each. At most 10000000000000, that is $100,000. In ``ENFORCE`` mode, requests to a model with no pricing are rejected, because their cost can't be counted. + :type cost_microcents_per_minute: int, none_type, optional + :param input_tokens_per_minute: Maximum input tokens per rolling minute. :type input_tokens_per_minute: int, none_type, optional @@ -93,7 +103,7 @@ def __init__( :param output_tokens_per_minute: Maximum output tokens per rolling minute. :type output_tokens_per_minute: int, none_type, optional - :param requests_per_minute: Maximum requests per rolling minute. At least one of ``requests_per_minute`` , ``input_tokens_per_minute`` , and ``output_tokens_per_minute`` is required. + :param requests_per_minute: Maximum requests per rolling minute. At least one of ``requests_per_minute`` , ``input_tokens_per_minute`` , ``output_tokens_per_minute`` , and ``cost_microcents_per_minute`` is required. :type requests_per_minute: int, none_type, optional :param selector: Dimension rules for a template rate limit, which gives each matched user, Team, or value its own allowance with the rule's limits. Can't be combined with user_id, team_id, or tags, and can't be changed after creation. Omit for a rule with one shared allowance. @@ -108,6 +118,8 @@ def __init__( :param user_id: Optional UUID. Count only this user's requests. :type user_id: UUID, optional """ + if cost_microcents_per_minute is not unset: + kwargs["cost_microcents_per_minute"] = cost_microcents_per_minute if input_tokens_per_minute is not unset: kwargs["input_tokens_per_minute"] = input_tokens_per_minute if mode is not unset: diff --git a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_instance_attributes.py b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_instance_attributes.py index 35294e7e55..3aa2d07b61 100644 --- a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_instance_attributes.py +++ b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_instance_attributes.py @@ -20,6 +20,8 @@ class AiGatewayRateLimitInstanceAttributes(ModelNormal): @cached_property def openapi_types(_): return { + "cost_microcents": (int,), + "cost_microcents_per_minute": (int, none_type), "first_seen": (datetime,), "input_tokens": (int,), "input_tokens_per_minute": (int, none_type), @@ -38,6 +40,8 @@ def openapi_types(_): } attribute_map = { + "cost_microcents": "cost_microcents", + "cost_microcents_per_minute": "cost_microcents_per_minute", "first_seen": "first_seen", "input_tokens": "input_tokens", "input_tokens_per_minute": "input_tokens_per_minute", @@ -69,6 +73,8 @@ def __init__( usage_known: bool, utilization: float, would_limit_requests: int, + cost_microcents: Union[int, UnsetType] = unset, + cost_microcents_per_minute: Union[int, none_type, UnsetType] = unset, input_tokens_per_minute: Union[int, none_type, UnsetType] = unset, output_tokens_per_minute: Union[int, none_type, UnsetType] = unset, requests_per_minute: Union[int, none_type, UnsetType] = unset, @@ -77,6 +83,12 @@ def __init__( """ One counter of a template rate limit and its live usage. + :param cost_microcents: Priced spend, in microcents, counted in the rolling one-minute window. 0 when the rate limit doesn't limit cost. + :type cost_microcents: int, optional + + :param cost_microcents_per_minute: The rate limit's per-counter spend limit, in microcents. Null when it doesn't limit cost. + :type cost_microcents_per_minute: int, none_type, optional + :param first_seen: When the gateway first recorded a request for this counter. :type first_seen: datetime @@ -89,7 +101,7 @@ def __init__( :param instance_key: Opaque canonical key identifying the counter. :type instance_key: str - :param last_seen: When the gateway last recorded a request for this counter; up to a few minutes behind live traffic. + :param last_seen: When the gateway last saw this counter hot, that is near or at a limit or limiting; up to a few minutes behind live traffic. :type last_seen: datetime :param limited_requests: Requests this counter rejected in the last 15 minutes (ENFORCE). @@ -122,6 +134,10 @@ def __init__( :param would_limit_requests: Requests this counter would have rejected in the last 15 minutes (ALERT). :type would_limit_requests: int """ + if cost_microcents is not unset: + kwargs["cost_microcents"] = cost_microcents + if cost_microcents_per_minute is not unset: + kwargs["cost_microcents_per_minute"] = cost_microcents_per_minute if input_tokens_per_minute is not unset: kwargs["input_tokens_per_minute"] = input_tokens_per_minute if output_tokens_per_minute is not unset: diff --git a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_instances_summary_attributes.py b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_instances_summary_attributes.py index 965c84a583..b1329ec42f 100644 --- a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_instances_summary_attributes.py +++ b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_instances_summary_attributes.py @@ -57,7 +57,7 @@ def __init__( """ Aggregate of a template rate limit's counters. - :param instance_count: Number of counters. + :param instance_count: Number of counters that were near or at a limit, or limited a request, in the last hour. Counters with room to spare aren't recorded. :type instance_count: int :param limited_requests: Requests the counters rejected in the last 15 minutes (ENFORCE), totaled over the counters whose usage was read. diff --git a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_instances_summary_list_response.py b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_instances_summary_list_response.py new file mode 100644 index 0000000000..9e44ac0e89 --- /dev/null +++ b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_instances_summary_list_response.py @@ -0,0 +1,44 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.ai_gateway_rate_limit_instances_summary_resource import ( + AiGatewayRateLimitInstancesSummaryResource, + ) + + +class AiGatewayRateLimitInstancesSummaryListResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.ai_gateway_rate_limit_instances_summary_resource import ( + AiGatewayRateLimitInstancesSummaryResource, + ) + + return { + "data": ([AiGatewayRateLimitInstancesSummaryResource],), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: List[AiGatewayRateLimitInstancesSummaryResource], **kwargs): + """ + Response containing the counter summary of every template rate limit in the organization. + + :param data: + :type data: [AiGatewayRateLimitInstancesSummaryResource] + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_update_attributes.py b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_update_attributes.py index 5078ab2630..1867be2075 100644 --- a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_update_attributes.py +++ b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_update_attributes.py @@ -20,6 +20,10 @@ class AiGatewayRateLimitUpdateAttributes(ModelNormal): validations = { + "cost_microcents_per_minute": { + "inclusive_maximum": 10000000000000, + "inclusive_minimum": 0, + }, "input_tokens_per_minute": { "inclusive_maximum": 100000000000, "inclusive_minimum": 0, @@ -39,6 +43,7 @@ def openapi_types(_): from datadog_api_client.v2.model.ai_gateway_rate_limit_mode import AiGatewayRateLimitMode return { + "cost_microcents_per_minute": (int, none_type), "enabled": (bool,), "input_tokens_per_minute": (int, none_type), "mode": (AiGatewayRateLimitMode,), @@ -51,6 +56,7 @@ def openapi_types(_): } attribute_map = { + "cost_microcents_per_minute": "cost_microcents_per_minute", "enabled": "enabled", "input_tokens_per_minute": "input_tokens_per_minute", "mode": "mode", @@ -64,6 +70,7 @@ def openapi_types(_): def __init__( self_, + cost_microcents_per_minute: Union[int, none_type, UnsetType] = unset, enabled: Union[bool, UnsetType] = unset, input_tokens_per_minute: Union[int, none_type, UnsetType] = unset, mode: Union[AiGatewayRateLimitMode, UnsetType] = unset, @@ -78,6 +85,9 @@ def __init__( """ Attributes used to update an AI Gateway rate limit. Only sent fields are changed. + :param cost_microcents_per_minute: Spend limit in microcents per rolling minute. Set to 0 to remove the cost limit. Null is ignored. At least one limit must remain. + :type cost_microcents_per_minute: int, none_type, optional + :param enabled: Whether this rate limit is active. :type enabled: bool, optional @@ -105,6 +115,8 @@ def __init__( :param user_id: Replaces the user scope. An empty string clears it. Null is ignored. :type user_id: str, none_type, optional """ + if cost_microcents_per_minute is not unset: + kwargs["cost_microcents_per_minute"] = cost_microcents_per_minute if enabled is not unset: kwargs["enabled"] = enabled if input_tokens_per_minute is not unset: diff --git a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_usage_attributes.py b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_usage_attributes.py index 303d2e37ce..63ac2a4bb0 100644 --- a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_usage_attributes.py +++ b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_usage_attributes.py @@ -3,10 +3,13 @@ # Copyright 2019-Present Datadog, Inc. from __future__ import annotations +from typing import Union from datadog_api_client.model_utils import ( ModelNormal, cached_property, + unset, + UnsetType, ) @@ -14,6 +17,7 @@ class AiGatewayRateLimitUsageAttributes(ModelNormal): @cached_property def openapi_types(_): return { + "cost_microcents": (int,), "input_tokens": (int,), "limited_requests": (int,), "output_tokens": (int,), @@ -22,6 +26,7 @@ def openapi_types(_): } attribute_map = { + "cost_microcents": "cost_microcents", "input_tokens": "input_tokens", "limited_requests": "limited_requests", "output_tokens": "output_tokens", @@ -36,11 +41,15 @@ def __init__( output_tokens: int, requests: int, would_limit_requests: int, + cost_microcents: Union[int, UnsetType] = unset, **kwargs, ): """ Live consumption of one AI Gateway rate limit. + :param cost_microcents: Priced spend, in microcents, counted in the rolling one-minute window. Only rules with a cost limit count it, so it is 0 for other rules and for the untracked and total entries. + :type cost_microcents: int, optional + :param input_tokens: Input tokens counted in the rolling one-minute window. :type input_tokens: int @@ -56,6 +65,8 @@ def __init__( :param would_limit_requests: Requests this rate limit would have rejected in the last 15 minutes. Applies when mode is ALERT. :type would_limit_requests: int """ + if cost_microcents is not unset: + kwargs["cost_microcents"] = cost_microcents super().__init__(kwargs) self_.input_tokens = input_tokens diff --git a/src/datadog_api_client/v2/model/ai_gateway_routing_classifier_request.py b/src/datadog_api_client/v2/model/ai_gateway_routing_classifier_request.py index 0d921231a1..d8b34f0b01 100644 --- a/src/datadog_api_client/v2/model/ai_gateway_routing_classifier_request.py +++ b/src/datadog_api_client/v2/model/ai_gateway_routing_classifier_request.py @@ -62,7 +62,7 @@ def __init__( :param model: Decision model on the provider. Omit together with provider to preserve the saved selection. :type model: str, optional - :param provider: Decision-model provider slug. It must name a provider of type ``openai`` , ``baseten`` , or ``typesafe`` , the provider types that serve a decision model. Omit together with model to preserve the saved selection. + :param provider: Decision-model provider slug. Omit together with model to preserve the saved selection. :type provider: str, optional """ if confidence_threshold is not unset: diff --git a/src/datadog_api_client/v2/model/ai_gateway_routing_rule_target_request.py b/src/datadog_api_client/v2/model/ai_gateway_routing_rule_target_request.py index b230f9a7a6..1e2cab70d7 100644 --- a/src/datadog_api_client/v2/model/ai_gateway_routing_rule_target_request.py +++ b/src/datadog_api_client/v2/model/ai_gateway_routing_rule_target_request.py @@ -96,13 +96,13 @@ def __init__( :param model_id: Opaque model catalog ID for a concrete model target. New selections require provider View; saved selections can be retained without metadata. :type model_id: int, optional - :param provider: Provider slug. weighted_affinity and classified tiers require an explicit provider and do not allow "*". + :param provider: Provider slug. weighted_affinity requires an explicit provider and does not allow "*". :type provider: str, optional :param reasoning_level: Optional reasoning effort preference for this model destination. Must be supported by the selected model and provider. For provider "*", every eligible provider must support the level. An explicit value overrides the request's reasoning setting, subject to model-group policy. Omitted or null preserves request and provider behavior; none is an explicit level, not the default. On update, omission preserves a saved target override; null explicitly clears it. Routing-rule references cannot set this field; each referenced model destination owns its override. If an override cannot be applied at runtime, the gateway keeps the destination and restores the caller's original reasoning settings, or preserves the provider default when omitted. It rechecks all applicable route and model-group policies against those settings before sending. Model-group max_reasoning_level enforces hard limits; the override is not an additional cap. Normal fallback applies if governance denies the resulting request or the destination cannot otherwise serve it. Metrics and span tags record the override outcome and incompatibility reason. When response headers have not already been committed, ``X-Ai-Gateway-Reasoning-Override`` reports applied or not_applied for the returned attempt, and ``X-Ai-Gateway-Reasoning-Override-Reason`` reports the reason when not applied. :type reasoning_level: AiGatewayRoutingReasoningLevel, none_type, optional - :param rubric: Destination rubric in a classified tier: when the decision model picks this destination. Up to 300 characters after leading and trailing spaces are trimmed, and different for each destination in the tier. Omission preserves a saved value; null clears it. Must be absent on the default destination. + :param rubric: Destination rubric in a classified tier. Omission preserves a saved value; null clears it. Must be absent on the default destination. :type rubric: str, none_type, optional :param slug: Organization-unique routing rule slug. New references require route View. Omit to retain a saved target by its parent-local ID. Allowed only in configured tiers. diff --git a/src/datadog_api_client/v2/model/ai_gateway_routing_rule_tier_request.py b/src/datadog_api_client/v2/model/ai_gateway_routing_rule_tier_request.py index c490489e8d..d5362c86e9 100644 --- a/src/datadog_api_client/v2/model/ai_gateway_routing_rule_tier_request.py +++ b/src/datadog_api_client/v2/model/ai_gateway_routing_rule_tier_request.py @@ -62,7 +62,7 @@ def __init__( :param classifier: Decision model and settings for a classified tier. Omission preserves the saved classifier; null clears it. Newly selected models require provider View. :type classifier: AiGatewayRoutingClassifierRequest, none_type, optional - :param ordering: How a tier orders its targets. Omission preserves the saved same-position tier on update; null resets to configured. New tiers default to configured. The weighted_affinity ordering distributes first-choice assignments by relative target weights and accepts only model targets with an explicit provider, without repeated provider and model pairs in the same tier. The ``classified`` ordering is allowed only in the first tier and requires a classifier, destination rubrics, and one default destination. Its targets are model targets that each name one provider, not "*". Besides the default, it needs 1 to 9 destinations, each with a different rubric. Classified routing is in Preview: saving a classified tier returns 403 Forbidden unless the feature is enabled for the organization. + :param ordering: How a tier orders its targets. Omission preserves the saved same-position tier on update; null resets to configured. New tiers default to configured. The weighted_affinity ordering distributes first-choice assignments by relative target weights and accepts only model targets with an explicit provider, without repeated provider and model pairs in the same tier. The ``classified`` ordering is allowed only in the first tier and requires a classifier, destination rubrics, and one default destination. :type ordering: AiGatewayNullableRoutingRuleTierOrdering, none_type, optional :param targets: diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index b0d4e01452..8153ee17ab 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -627,6 +627,9 @@ from datadog_api_client.v2.model.ai_gateway_rate_limit_instances_summary_attributes import ( AiGatewayRateLimitInstancesSummaryAttributes, ) +from datadog_api_client.v2.model.ai_gateway_rate_limit_instances_summary_list_response import ( + AiGatewayRateLimitInstancesSummaryListResponse, +) from datadog_api_client.v2.model.ai_gateway_rate_limit_instances_summary_resource import ( AiGatewayRateLimitInstancesSummaryResource, ) @@ -14480,6 +14483,7 @@ "AiGatewayRateLimitInstanceSort", "AiGatewayRateLimitInstanceType", "AiGatewayRateLimitInstancesSummaryAttributes", + "AiGatewayRateLimitInstancesSummaryListResponse", "AiGatewayRateLimitInstancesSummaryResource", "AiGatewayRateLimitInstancesSummaryResponse", "AiGatewayRateLimitInstancesSummaryType", diff --git a/tests/v2/features/ai_gateway.feature b/tests/v2/features/ai_gateway.feature index f3cc5a4ac4..b9312a5721 100644 --- a/tests/v2/features/ai_gateway.feature +++ b/tests/v2/features/ai_gateway.feature @@ -184,7 +184,7 @@ Feature: AI Gateway Scenario: Create an AI Gateway rate limit returns "Bad Request" response Given operation "CreateAiGatewayRateLimit" enabled And new "CreateAiGatewayRateLimit" request - And body with value {"data": {"attributes": {"input_tokens_per_minute": null, "mode": "ALERT", "name": "Default rate limit", "output_tokens_per_minute": null, "requests_per_minute": 600, "selector": [{"dim": "user_id", "per_value": true, "values": ["11111111-1111-1111-1111-111111111111"]}], "team_id": "00000000-0000-4000-8000-000000000002", "user_id": "00000000-0000-4000-8000-000000000001"}, "type": "rate-limits"}} + And body with value {"data": {"attributes": {"cost_microcents_per_minute": 100000000, "input_tokens_per_minute": null, "mode": "ALERT", "name": "Default rate limit", "output_tokens_per_minute": null, "requests_per_minute": 600, "selector": [{"dim": "user_id", "per_value": true, "values": ["11111111-1111-1111-1111-111111111111"]}], "team_id": "00000000-0000-4000-8000-000000000002", "user_id": "00000000-0000-4000-8000-000000000001"}, "type": "rate-limits"}} When the request is sent Then the response status is 400 Bad Request @@ -192,7 +192,7 @@ Feature: AI Gateway Scenario: Create an AI Gateway rate limit returns "Conflict" response Given operation "CreateAiGatewayRateLimit" enabled And new "CreateAiGatewayRateLimit" request - And body with value {"data": {"attributes": {"input_tokens_per_minute": null, "mode": "ALERT", "name": "Default rate limit", "output_tokens_per_minute": null, "requests_per_minute": 600, "selector": [{"dim": "user_id", "per_value": true, "values": ["11111111-1111-1111-1111-111111111111"]}], "team_id": "00000000-0000-4000-8000-000000000002", "user_id": "00000000-0000-4000-8000-000000000001"}, "type": "rate-limits"}} + And body with value {"data": {"attributes": {"cost_microcents_per_minute": 100000000, "input_tokens_per_minute": null, "mode": "ALERT", "name": "Default rate limit", "output_tokens_per_minute": null, "requests_per_minute": 600, "selector": [{"dim": "user_id", "per_value": true, "values": ["11111111-1111-1111-1111-111111111111"]}], "team_id": "00000000-0000-4000-8000-000000000002", "user_id": "00000000-0000-4000-8000-000000000001"}, "type": "rate-limits"}} When the request is sent Then the response status is 409 Conflict @@ -200,7 +200,7 @@ Feature: AI Gateway Scenario: Create an AI Gateway rate limit returns "Created" response Given operation "CreateAiGatewayRateLimit" enabled And new "CreateAiGatewayRateLimit" request - And body with value {"data": {"attributes": {"input_tokens_per_minute": null, "mode": "ALERT", "name": "Default rate limit", "output_tokens_per_minute": null, "requests_per_minute": 600, "selector": [{"dim": "user_id", "per_value": true, "values": ["11111111-1111-1111-1111-111111111111"]}], "team_id": "00000000-0000-4000-8000-000000000002", "user_id": "00000000-0000-4000-8000-000000000001"}, "type": "rate-limits"}} + And body with value {"data": {"attributes": {"cost_microcents_per_minute": 100000000, "input_tokens_per_minute": null, "mode": "ALERT", "name": "Default rate limit", "output_tokens_per_minute": null, "requests_per_minute": 600, "selector": [{"dim": "user_id", "per_value": true, "values": ["11111111-1111-1111-1111-111111111111"]}], "team_id": "00000000-0000-4000-8000-000000000002", "user_id": "00000000-0000-4000-8000-000000000001"}, "type": "rate-limits"}} When the request is sent Then the response status is 201 Created @@ -713,6 +713,20 @@ Feature: AI Gateway When the request is sent Then the response status is 200 OK + @skip @team:ddoghq/frontier-prd-gateway + Scenario: List AI Gateway rate limit counter summaries returns "OK" response + Given operation "ListAiGatewayRateLimitInstancesSummaries" enabled + And there is a valid "rate_limit_template" in the system + And new "ListAiGatewayRateLimitInstancesSummaries" request + When the request is sent + Then the response status is 200 OK + And the response "data" has item with field "id" with value "{{ rate_limit_template.data.id }}" + And the response "data" has item with field "attributes.rate_limit_id" with value "{{ rate_limit_template.data.id }}" + And the response "data[0].type" is equal to "rate-limit-instances-summary" + And the response "data[0].attributes" has field "instance_count" + And the response "data[0].attributes" has field "truncated" + And the response "data[0].attributes" has field "scope_restricted" + @generated @skip @team:ddoghq/frontier-prd-gateway Scenario: List AI Gateway rate limit counters returns "Bad Request" response Given operation "ListAiGatewayRateLimitInstances" enabled @@ -1054,7 +1068,7 @@ Feature: AI Gateway Given operation "UpdateAiGatewayRateLimit" enabled And new "UpdateAiGatewayRateLimit" request And request contains "id" parameter from "REPLACE.ME" - And body with value {"data": {"attributes": {"input_tokens_per_minute": null, "mode": "ALERT", "output_tokens_per_minute": null, "requests_per_minute": null, "tags": null, "team_id": null, "user_id": null}, "id": "11111111-1111-1111-1111-111111111111", "type": "rate-limits"}} + And body with value {"data": {"attributes": {"cost_microcents_per_minute": null, "input_tokens_per_minute": null, "mode": "ALERT", "output_tokens_per_minute": null, "requests_per_minute": null, "tags": null, "team_id": null, "user_id": null}, "id": "11111111-1111-1111-1111-111111111111", "type": "rate-limits"}} When the request is sent Then the response status is 400 Bad Request @@ -1063,7 +1077,7 @@ Feature: AI Gateway Given operation "UpdateAiGatewayRateLimit" enabled And new "UpdateAiGatewayRateLimit" request And request contains "id" parameter from "REPLACE.ME" - And body with value {"data": {"attributes": {"input_tokens_per_minute": null, "mode": "ALERT", "output_tokens_per_minute": null, "requests_per_minute": null, "tags": null, "team_id": null, "user_id": null}, "id": "11111111-1111-1111-1111-111111111111", "type": "rate-limits"}} + And body with value {"data": {"attributes": {"cost_microcents_per_minute": null, "input_tokens_per_minute": null, "mode": "ALERT", "output_tokens_per_minute": null, "requests_per_minute": null, "tags": null, "team_id": null, "user_id": null}, "id": "11111111-1111-1111-1111-111111111111", "type": "rate-limits"}} When the request is sent Then the response status is 409 Conflict @@ -1072,7 +1086,7 @@ Feature: AI Gateway Given operation "UpdateAiGatewayRateLimit" enabled And new "UpdateAiGatewayRateLimit" request And request contains "id" parameter from "REPLACE.ME" - And body with value {"data": {"attributes": {"input_tokens_per_minute": null, "mode": "ALERT", "output_tokens_per_minute": null, "requests_per_minute": null, "tags": null, "team_id": null, "user_id": null}, "id": "11111111-1111-1111-1111-111111111111", "type": "rate-limits"}} + And body with value {"data": {"attributes": {"cost_microcents_per_minute": null, "input_tokens_per_minute": null, "mode": "ALERT", "output_tokens_per_minute": null, "requests_per_minute": null, "tags": null, "team_id": null, "user_id": null}, "id": "11111111-1111-1111-1111-111111111111", "type": "rate-limits"}} When the request is sent Then the response status is 404 Not Found @@ -1081,7 +1095,7 @@ Feature: AI Gateway Given operation "UpdateAiGatewayRateLimit" enabled And new "UpdateAiGatewayRateLimit" request And request contains "id" parameter from "REPLACE.ME" - And body with value {"data": {"attributes": {"input_tokens_per_minute": null, "mode": "ALERT", "output_tokens_per_minute": null, "requests_per_minute": null, "tags": null, "team_id": null, "user_id": null}, "id": "11111111-1111-1111-1111-111111111111", "type": "rate-limits"}} + And body with value {"data": {"attributes": {"cost_microcents_per_minute": null, "input_tokens_per_minute": null, "mode": "ALERT", "output_tokens_per_minute": null, "requests_per_minute": null, "tags": null, "team_id": null, "user_id": null}, "id": "11111111-1111-1111-1111-111111111111", "type": "rate-limits"}} When the request is sent Then the response status is 200 OK diff --git a/tests/v2/features/given.json b/tests/v2/features/given.json index e2931f2614..95b4474aeb 100644 --- a/tests/v2/features/given.json +++ b/tests/v2/features/given.json @@ -1488,6 +1488,18 @@ "tag": "Powerpack", "operationId": "CreatePowerpack" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"rate-limits\",\n \"attributes\": {\n \"name\": \"{{ unique }}\",\n \"selector\": [{\"dim\": \"user_id\", \"per_value\": true}],\n \"requests_per_minute\": 1000000,\n \"mode\": \"ALERT\"\n }\n }\n}" + } + ], + "step": "there is a valid \"rate_limit_template\" in the system", + "key": "rate_limit_template", + "tag": "AI Gateway", + "operationId": "CreateAiGatewayRateLimit" + }, { "parameters": [ { diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index e9fdf58d6d..fb7afa5fc4 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -7747,7 +7747,20 @@ "CreateAiGatewayRateLimit": { "tag": "AI Gateway", "undo": { - "type": "idempotent" + "operationId": "DeleteAiGatewayRateLimit", + "parameters": [ + { + "name": "id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "ListAiGatewayRateLimitInstancesSummaries": { + "tag": "AI Gateway", + "undo": { + "type": "safe" } }, "GetAiGatewayRateLimitUsage": {