diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 146e53417eb8..57865d0cfef1 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -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 @@ -231139,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). @@ -231342,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" @@ -231403,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.rb b/examples/v2/ai-gateway/CreateAiGatewayRateLimit.rb index 419809d2f2d8..7106a05b864f 100644 --- a/examples/v2/ai-gateway/CreateAiGatewayRateLimit.rb +++ b/examples/v2/ai-gateway/CreateAiGatewayRateLimit.rb @@ -10,6 +10,7 @@ body = DatadogAPIClient::V2::AiGatewayRateLimitCreateRequest.new({ data: DatadogAPIClient::V2::AiGatewayRateLimitCreateData.new({ attributes: DatadogAPIClient::V2::AiGatewayRateLimitCreateAttributes.new({ + cost_microcents_per_minute: 100000000, input_tokens_per_minute: nil, mode: DatadogAPIClient::V2::AiGatewayRateLimitMode::ALERT, name: "Default rate limit", diff --git a/examples/v2/ai-gateway/ListAiGatewayRateLimitInstancesSummaries.rb b/examples/v2/ai-gateway/ListAiGatewayRateLimitInstancesSummaries.rb new file mode 100644 index 000000000000..1d1303bdec3f --- /dev/null +++ b/examples/v2/ai-gateway/ListAiGatewayRateLimitInstancesSummaries.rb @@ -0,0 +1,9 @@ +# List AI Gateway rate limit counter summaries returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.access_token = ENV["DD_BEARER_TOKEN"] + config.unstable_operations["v2.list_ai_gateway_rate_limit_instances_summaries".to_sym] = true +end +api_instance = DatadogAPIClient::V2::AIGatewayAPI.new +p api_instance.list_ai_gateway_rate_limit_instances_summaries() diff --git a/examples/v2/ai-gateway/UpdateAiGatewayRateLimit.rb b/examples/v2/ai-gateway/UpdateAiGatewayRateLimit.rb index fd50e4ce44e3..f83a2714c6b0 100644 --- a/examples/v2/ai-gateway/UpdateAiGatewayRateLimit.rb +++ b/examples/v2/ai-gateway/UpdateAiGatewayRateLimit.rb @@ -10,6 +10,7 @@ body = DatadogAPIClient::V2::AiGatewayRateLimitUpdateRequest.new({ data: DatadogAPIClient::V2::AiGatewayRateLimitUpdateData.new({ attributes: DatadogAPIClient::V2::AiGatewayRateLimitUpdateAttributes.new({ + cost_microcents_per_minute: nil, input_tokens_per_minute: nil, mode: DatadogAPIClient::V2::AiGatewayRateLimitMode::ALERT, output_tokens_per_minute: nil, diff --git a/features/v2/ai_gateway.feature b/features/v2/ai_gateway.feature index f3cc5a4ac48f..b9312a57212e 100644 --- a/features/v2/ai_gateway.feature +++ b/features/v2/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/features/v2/given.json b/features/v2/given.json index e2931f26142b..95b4474aeb2e 100644 --- a/features/v2/given.json +++ b/features/v2/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/features/v2/undo.json b/features/v2/undo.json index e9fdf58d6dc4..fb7afa5fc48d 100644 --- a/features/v2/undo.json +++ b/features/v2/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": { diff --git a/lib/datadog_api_client/configuration.rb b/lib/datadog_api_client/configuration.rb index 84d2629b1550..c8475b5aeb2b 100644 --- a/lib/datadog_api_client/configuration.rb +++ b/lib/datadog_api_client/configuration.rb @@ -337,6 +337,7 @@ def initialize "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/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 0c18deef0713..9923c62aca2a 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -1570,6 +1570,7 @@ def overrides "v2.ai_gateway_rate_limit_instance_resource" => "AiGatewayRateLimitInstanceResource", "v2.ai_gateway_rate_limit_instance_sort" => "AiGatewayRateLimitInstanceSort", "v2.ai_gateway_rate_limit_instances_summary_attributes" => "AiGatewayRateLimitInstancesSummaryAttributes", + "v2.ai_gateway_rate_limit_instances_summary_list_response" => "AiGatewayRateLimitInstancesSummaryListResponse", "v2.ai_gateway_rate_limit_instances_summary_resource" => "AiGatewayRateLimitInstancesSummaryResource", "v2.ai_gateway_rate_limit_instances_summary_response" => "AiGatewayRateLimitInstancesSummaryResponse", "v2.ai_gateway_rate_limit_instances_summary_type" => "AiGatewayRateLimitInstancesSummaryType", diff --git a/lib/datadog_api_client/v2/api/ai_gateway_api.rb b/lib/datadog_api_client/v2/api/ai_gateway_api.rb index ec4bca18d370..ce069da7d1d8 100644 --- a/lib/datadog_api_client/v2/api/ai_gateway_api.rb +++ b/lib/datadog_api_client/v2/api/ai_gateway_api.rb @@ -2053,7 +2053,7 @@ def get_ai_gateway_rate_limit_instances_summary(id, opts = {}) # 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 [UUID] Rate limit UUID. # @param opts [Hash] the optional parameters @@ -2948,7 +2948,7 @@ def list_ai_gateway_rate_limit_instances(id, opts = {}) # 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 [UUID] Rate limit UUID. # @param opts [Hash] the optional parameters @@ -3031,6 +3031,72 @@ def list_ai_gateway_rate_limit_instances_with_http_info(id, opts = {}) return data, status_code, headers end + # List AI Gateway rate limit counter summaries. + # + # @see #list_ai_gateway_rate_limit_instances_summaries_with_http_info + def list_ai_gateway_rate_limit_instances_summaries(opts = {}) + data, _status_code, _headers = list_ai_gateway_rate_limit_instances_summaries_with_http_info(opts) + data + end + + # 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. + # + # @param opts [Hash] the optional parameters + # @return [Array<(AiGatewayRateLimitInstancesSummaryListResponse, Integer, Hash)>] AiGatewayRateLimitInstancesSummaryListResponse data, response status code and response headers + def list_ai_gateway_rate_limit_instances_summaries_with_http_info(opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.list_ai_gateway_rate_limit_instances_summaries".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.list_ai_gateway_rate_limit_instances_summaries") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.list_ai_gateway_rate_limit_instances_summaries")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: AIGatewayAPI.list_ai_gateway_rate_limit_instances_summaries ...' + end + # resource path + local_var_path = '/api/v2/rate-limits/instances/summary' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'AiGatewayRateLimitInstancesSummaryListResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :list_ai_gateway_rate_limit_instances_summaries, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: AIGatewayAPI#list_ai_gateway_rate_limit_instances_summaries\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # List AI Gateway rate limits. # # @see #list_ai_gateway_rate_limits_with_http_info diff --git a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_attributes.rb b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_attributes.rb index ca8213e492d3..adc3fa0c0b22 100644 --- a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_attributes.rb +++ b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_attributes.rb @@ -21,6 +21,9 @@ module DatadogAPIClient::V2 class AiGatewayRateLimitAttributes include BaseGenericModel + # 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. + attr_reader :cost_microcents_per_minute + # Creation timestamp. attr_reader :created_at @@ -34,7 +37,7 @@ class AiGatewayRateLimitAttributes attr_reader :input_tokens_per_minute # 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. - attr_accessor :is_template + attr_reader :is_template # Action taken when request rate exceeds the limit. attr_reader :mode @@ -67,7 +70,7 @@ class AiGatewayRateLimitAttributes attr_accessor :team_id # 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. - attr_accessor :template_split_dims + attr_reader :template_split_dims # Last modification timestamp. attr_reader :updated_at @@ -84,6 +87,7 @@ class AiGatewayRateLimitAttributes # @!visibility private def self.attribute_map { + :'cost_microcents_per_minute' => :'cost_microcents_per_minute', :'created_at' => :'created_at', :'created_by' => :'created_by', :'enabled' => :'enabled', @@ -110,6 +114,7 @@ def self.attribute_map # @!visibility private def self.openapi_types { + :'cost_microcents_per_minute' => :'Integer', :'created_at' => :'Time', :'created_by' => :'String', :'enabled' => :'Boolean', @@ -136,6 +141,7 @@ def self.openapi_types # @!visibility private def self.openapi_nullable Set.new([ + :'cost_microcents_per_minute', :'input_tokens_per_minute', :'monitor_id', :'output_tokens_per_minute', @@ -164,6 +170,10 @@ def initialize(attributes = {}) end } + if attributes.key?(:'cost_microcents_per_minute') + self.cost_microcents_per_minute = attributes[:'cost_microcents_per_minute'] + end + if attributes.key?(:'created_at') self.created_at = attributes[:'created_at'] end @@ -249,11 +259,14 @@ def initialize(attributes = {}) # @return true if the model is valid # @!visibility private def valid? + return false if !@cost_microcents_per_minute.nil? && @cost_microcents_per_minute > 10000000000000 + return false if !@cost_microcents_per_minute.nil? && @cost_microcents_per_minute < 1 return false if @created_at.nil? return false if @created_by.nil? return false if @enabled.nil? return false if !@input_tokens_per_minute.nil? && @input_tokens_per_minute > 100000000000 return false if !@input_tokens_per_minute.nil? && @input_tokens_per_minute < 1 + return false if @is_template.nil? return false if @mode.nil? return false if @name.nil? return false if !@output_tokens_per_minute.nil? && @output_tokens_per_minute > 100000000000 @@ -263,11 +276,25 @@ def valid? return false if @revision.nil? return false if @scope_restricted.nil? return false if @tags.nil? + return false if @template_split_dims.nil? return false if @updated_at.nil? return false if @updated_by.nil? true end + # Custom attribute writer method with validation + # @param cost_microcents_per_minute [Object] Object to be assigned + # @!visibility private + def cost_microcents_per_minute=(cost_microcents_per_minute) + if !cost_microcents_per_minute.nil? && cost_microcents_per_minute > 10000000000000 + fail ArgumentError, 'invalid value for "cost_microcents_per_minute", must be smaller than or equal to 10000000000000.' + end + if !cost_microcents_per_minute.nil? && cost_microcents_per_minute < 1 + fail ArgumentError, 'invalid value for "cost_microcents_per_minute", must be greater than or equal to 1.' + end + @cost_microcents_per_minute = cost_microcents_per_minute + end + # Custom attribute writer method with validation # @param created_at [Object] Object to be assigned # @!visibility private @@ -311,6 +338,16 @@ def input_tokens_per_minute=(input_tokens_per_minute) @input_tokens_per_minute = input_tokens_per_minute end + # Custom attribute writer method with validation + # @param is_template [Object] Object to be assigned + # @!visibility private + def is_template=(is_template) + if is_template.nil? + fail ArgumentError, 'invalid value for "is_template", is_template cannot be nil.' + end + @is_template = is_template + end + # Custom attribute writer method with validation # @param mode [Object] Object to be assigned # @!visibility private @@ -387,6 +424,16 @@ def tags=(tags) @tags = tags end + # Custom attribute writer method with validation + # @param template_split_dims [Object] Object to be assigned + # @!visibility private + def template_split_dims=(template_split_dims) + if template_split_dims.nil? + fail ArgumentError, 'invalid value for "template_split_dims", template_split_dims cannot be nil.' + end + @template_split_dims = template_split_dims + end + # Custom attribute writer method with validation # @param updated_at [Object] Object to be assigned # @!visibility private @@ -433,6 +480,7 @@ def to_hash def ==(o) return true if self.equal?(o) self.class == o.class && + cost_microcents_per_minute == o.cost_microcents_per_minute && created_at == o.created_at && created_by == o.created_by && enabled == o.enabled && @@ -459,7 +507,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [created_at, created_by, enabled, input_tokens_per_minute, is_template, mode, monitor_id, name, output_tokens_per_minute, requests_per_minute, revision, scope_restricted, selector, tags, team_id, template_split_dims, updated_at, updated_by, user_id, additional_properties].hash + [cost_microcents_per_minute, created_at, created_by, enabled, input_tokens_per_minute, is_template, mode, monitor_id, name, output_tokens_per_minute, requests_per_minute, revision, scope_restricted, selector, tags, team_id, template_split_dims, updated_at, updated_by, user_id, additional_properties].hash end end end diff --git a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_create_attributes.rb b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_create_attributes.rb index 148b4334ef76..0007b1c0aa70 100644 --- a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_create_attributes.rb +++ b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_create_attributes.rb @@ -21,6 +21,9 @@ module DatadogAPIClient::V2 class AiGatewayRateLimitCreateAttributes include BaseGenericModel + # 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. + attr_reader :cost_microcents_per_minute + # Maximum input tokens per rolling minute. attr_reader :input_tokens_per_minute @@ -33,7 +36,7 @@ class AiGatewayRateLimitCreateAttributes # Maximum output tokens per rolling minute. attr_reader :output_tokens_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. + # 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. attr_reader :requests_per_minute # 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. @@ -54,6 +57,7 @@ class AiGatewayRateLimitCreateAttributes # @!visibility private def self.attribute_map { + :'cost_microcents_per_minute' => :'cost_microcents_per_minute', :'input_tokens_per_minute' => :'input_tokens_per_minute', :'mode' => :'mode', :'name' => :'name', @@ -70,6 +74,7 @@ def self.attribute_map # @!visibility private def self.openapi_types { + :'cost_microcents_per_minute' => :'Integer', :'input_tokens_per_minute' => :'Integer', :'mode' => :'AiGatewayRateLimitMode', :'name' => :'String', @@ -86,6 +91,7 @@ def self.openapi_types # @!visibility private def self.openapi_nullable Set.new([ + :'cost_microcents_per_minute', :'input_tokens_per_minute', :'output_tokens_per_minute', :'requests_per_minute', @@ -111,6 +117,10 @@ def initialize(attributes = {}) end } + if attributes.key?(:'cost_microcents_per_minute') + self.cost_microcents_per_minute = attributes[:'cost_microcents_per_minute'] + end + if attributes.key?(:'input_tokens_per_minute') self.input_tokens_per_minute = attributes[:'input_tokens_per_minute'] end @@ -154,6 +164,8 @@ def initialize(attributes = {}) # @return true if the model is valid # @!visibility private def valid? + return false if !@cost_microcents_per_minute.nil? && @cost_microcents_per_minute > 10000000000000 + return false if !@cost_microcents_per_minute.nil? && @cost_microcents_per_minute < 1 return false if !@input_tokens_per_minute.nil? && @input_tokens_per_minute > 100000000000 return false if !@input_tokens_per_minute.nil? && @input_tokens_per_minute < 1 return false if @name.nil? @@ -164,6 +176,19 @@ def valid? true end + # Custom attribute writer method with validation + # @param cost_microcents_per_minute [Object] Object to be assigned + # @!visibility private + def cost_microcents_per_minute=(cost_microcents_per_minute) + if !cost_microcents_per_minute.nil? && cost_microcents_per_minute > 10000000000000 + fail ArgumentError, 'invalid value for "cost_microcents_per_minute", must be smaller than or equal to 10000000000000.' + end + if !cost_microcents_per_minute.nil? && cost_microcents_per_minute < 1 + fail ArgumentError, 'invalid value for "cost_microcents_per_minute", must be greater than or equal to 1.' + end + @cost_microcents_per_minute = cost_microcents_per_minute + end + # Custom attribute writer method with validation # @param input_tokens_per_minute [Object] Object to be assigned # @!visibility private @@ -239,6 +264,7 @@ def to_hash def ==(o) return true if self.equal?(o) self.class == o.class && + cost_microcents_per_minute == o.cost_microcents_per_minute && input_tokens_per_minute == o.input_tokens_per_minute && mode == o.mode && name == o.name && @@ -255,7 +281,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [input_tokens_per_minute, mode, name, output_tokens_per_minute, requests_per_minute, selector, tags, team_id, user_id, additional_properties].hash + [cost_microcents_per_minute, input_tokens_per_minute, mode, name, output_tokens_per_minute, requests_per_minute, selector, tags, team_id, user_id, additional_properties].hash end end end diff --git a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_instance_attributes.rb b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_instance_attributes.rb index 8defa0a3d386..f412e2b6748e 100644 --- a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_instance_attributes.rb +++ b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_instance_attributes.rb @@ -21,6 +21,12 @@ module DatadogAPIClient::V2 class AiGatewayRateLimitInstanceAttributes include BaseGenericModel + # Priced spend, in microcents, counted in the rolling one-minute window. 0 when the rate limit doesn't limit cost. + attr_accessor :cost_microcents + + # The rate limit's per-counter spend limit, in microcents. Null when it doesn't limit cost. + attr_accessor :cost_microcents_per_minute + # When the gateway first recorded a request for this counter. attr_reader :first_seen @@ -33,7 +39,7 @@ class AiGatewayRateLimitInstanceAttributes # Opaque canonical key identifying the counter. attr_reader :instance_key - # When the gateway last recorded a request for this counter; up to a few minutes behind live traffic. + # 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. attr_reader :last_seen # Requests this counter rejected in the last 15 minutes (ENFORCE). @@ -72,6 +78,8 @@ class AiGatewayRateLimitInstanceAttributes # @!visibility private def self.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', @@ -94,6 +102,8 @@ def self.attribute_map # @!visibility private def self.openapi_types { + :'cost_microcents' => :'Integer', + :'cost_microcents_per_minute' => :'Integer', :'first_seen' => :'Time', :'input_tokens' => :'Integer', :'input_tokens_per_minute' => :'Integer', @@ -116,6 +126,7 @@ def self.openapi_types # @!visibility private def self.openapi_nullable Set.new([ + :'cost_microcents_per_minute', :'input_tokens_per_minute', :'output_tokens_per_minute', :'requests_per_minute', @@ -140,6 +151,14 @@ def initialize(attributes = {}) end } + if attributes.key?(:'cost_microcents') + self.cost_microcents = attributes[:'cost_microcents'] + end + + if attributes.key?(:'cost_microcents_per_minute') + self.cost_microcents_per_minute = attributes[:'cost_microcents_per_minute'] + end + if attributes.key?(:'first_seen') self.first_seen = attributes[:'first_seen'] end @@ -366,6 +385,8 @@ def to_hash def ==(o) return true if self.equal?(o) self.class == o.class && + cost_microcents == o.cost_microcents && + cost_microcents_per_minute == o.cost_microcents_per_minute && first_seen == o.first_seen && input_tokens == o.input_tokens && input_tokens_per_minute == o.input_tokens_per_minute && @@ -388,7 +409,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [first_seen, input_tokens, input_tokens_per_minute, instance_key, last_seen, limited_requests, output_tokens, output_tokens_per_minute, rate_limit_id, requests, requests_per_minute, split_dims, usage_known, utilization, would_limit_requests, additional_properties].hash + [cost_microcents, cost_microcents_per_minute, first_seen, input_tokens, input_tokens_per_minute, instance_key, last_seen, limited_requests, output_tokens, output_tokens_per_minute, rate_limit_id, requests, requests_per_minute, split_dims, usage_known, utilization, would_limit_requests, additional_properties].hash end end end diff --git a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_instances_summary_attributes.rb b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_instances_summary_attributes.rb index 059092be7363..7a934b954d3f 100644 --- a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_instances_summary_attributes.rb +++ b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_instances_summary_attributes.rb @@ -21,7 +21,7 @@ module DatadogAPIClient::V2 class AiGatewayRateLimitInstancesSummaryAttributes include BaseGenericModel - # Number of counters. + # 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. attr_reader :instance_count # Requests the counters rejected in the last 15 minutes (ENFORCE), totaled over the counters whose usage was read. diff --git a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_instances_summary_list_response.rb b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_instances_summary_list_response.rb new file mode 100644 index 000000000000..b6490a4ae63a --- /dev/null +++ b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_instances_summary_list_response.rb @@ -0,0 +1,125 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Response containing the counter summary of every template rate limit in the organization. + class AiGatewayRateLimitInstancesSummaryListResponse + include BaseGenericModel + + # + attr_reader :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'Array' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::AiGatewayRateLimitInstancesSummaryListResponse` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_update_attributes.rb b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_update_attributes.rb index c16984653d90..4d2d4f7c442a 100644 --- a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_update_attributes.rb +++ b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_update_attributes.rb @@ -21,6 +21,9 @@ module DatadogAPIClient::V2 class AiGatewayRateLimitUpdateAttributes include BaseGenericModel + # Spend limit in microcents per rolling minute. Set to 0 to remove the cost limit. Null is ignored. At least one limit must remain. + attr_reader :cost_microcents_per_minute + # Whether this rate limit is active. attr_accessor :enabled @@ -54,6 +57,7 @@ class AiGatewayRateLimitUpdateAttributes # @!visibility private def self.attribute_map { + :'cost_microcents_per_minute' => :'cost_microcents_per_minute', :'enabled' => :'enabled', :'input_tokens_per_minute' => :'input_tokens_per_minute', :'mode' => :'mode', @@ -70,6 +74,7 @@ def self.attribute_map # @!visibility private def self.openapi_types { + :'cost_microcents_per_minute' => :'Integer', :'enabled' => :'Boolean', :'input_tokens_per_minute' => :'Integer', :'mode' => :'AiGatewayRateLimitMode', @@ -86,6 +91,7 @@ def self.openapi_types # @!visibility private def self.openapi_nullable Set.new([ + :'cost_microcents_per_minute', :'input_tokens_per_minute', :'output_tokens_per_minute', :'requests_per_minute', @@ -113,6 +119,10 @@ def initialize(attributes = {}) end } + if attributes.key?(:'cost_microcents_per_minute') + self.cost_microcents_per_minute = attributes[:'cost_microcents_per_minute'] + end + if attributes.key?(:'enabled') self.enabled = attributes[:'enabled'] end @@ -154,6 +164,8 @@ def initialize(attributes = {}) # @return true if the model is valid # @!visibility private def valid? + return false if !@cost_microcents_per_minute.nil? && @cost_microcents_per_minute > 10000000000000 + return false if !@cost_microcents_per_minute.nil? && @cost_microcents_per_minute < 0 return false if !@input_tokens_per_minute.nil? && @input_tokens_per_minute > 100000000000 return false if !@input_tokens_per_minute.nil? && @input_tokens_per_minute < 0 return false if !@output_tokens_per_minute.nil? && @output_tokens_per_minute > 100000000000 @@ -163,6 +175,19 @@ def valid? true end + # Custom attribute writer method with validation + # @param cost_microcents_per_minute [Object] Object to be assigned + # @!visibility private + def cost_microcents_per_minute=(cost_microcents_per_minute) + if !cost_microcents_per_minute.nil? && cost_microcents_per_minute > 10000000000000 + fail ArgumentError, 'invalid value for "cost_microcents_per_minute", must be smaller than or equal to 10000000000000.' + end + if !cost_microcents_per_minute.nil? && cost_microcents_per_minute < 0 + fail ArgumentError, 'invalid value for "cost_microcents_per_minute", must be greater than or equal to 0.' + end + @cost_microcents_per_minute = cost_microcents_per_minute + end + # Custom attribute writer method with validation # @param input_tokens_per_minute [Object] Object to be assigned # @!visibility private @@ -228,6 +253,7 @@ def to_hash def ==(o) return true if self.equal?(o) self.class == o.class && + cost_microcents_per_minute == o.cost_microcents_per_minute && enabled == o.enabled && input_tokens_per_minute == o.input_tokens_per_minute && mode == o.mode && @@ -244,7 +270,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [enabled, input_tokens_per_minute, mode, name, output_tokens_per_minute, requests_per_minute, tags, team_id, user_id, additional_properties].hash + [cost_microcents_per_minute, enabled, input_tokens_per_minute, mode, name, output_tokens_per_minute, requests_per_minute, tags, team_id, user_id, additional_properties].hash end end end diff --git a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_usage_attributes.rb b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_usage_attributes.rb index 9a1d4b5b4d6a..6648aa4d18da 100644 --- a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_usage_attributes.rb +++ b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_usage_attributes.rb @@ -21,6 +21,9 @@ module DatadogAPIClient::V2 class AiGatewayRateLimitUsageAttributes include BaseGenericModel + # 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. + attr_accessor :cost_microcents + # Input tokens counted in the rolling one-minute window. attr_reader :input_tokens @@ -42,6 +45,7 @@ class AiGatewayRateLimitUsageAttributes # @!visibility private def self.attribute_map { + :'cost_microcents' => :'cost_microcents', :'input_tokens' => :'input_tokens', :'limited_requests' => :'limited_requests', :'output_tokens' => :'output_tokens', @@ -54,6 +58,7 @@ def self.attribute_map # @!visibility private def self.openapi_types { + :'cost_microcents' => :'Integer', :'input_tokens' => :'Integer', :'limited_requests' => :'Integer', :'output_tokens' => :'Integer', @@ -80,6 +85,10 @@ def initialize(attributes = {}) end } + if attributes.key?(:'cost_microcents') + self.cost_microcents = attributes[:'cost_microcents'] + end + if attributes.key?(:'input_tokens') self.input_tokens = attributes[:'input_tokens'] end @@ -189,6 +198,7 @@ def to_hash def ==(o) return true if self.equal?(o) self.class == o.class && + cost_microcents == o.cost_microcents && input_tokens == o.input_tokens && limited_requests == o.limited_requests && output_tokens == o.output_tokens && @@ -201,7 +211,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [input_tokens, limited_requests, output_tokens, requests, would_limit_requests, additional_properties].hash + [cost_microcents, input_tokens, limited_requests, output_tokens, requests, would_limit_requests, additional_properties].hash end end end