diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index a3892ad9d2..e640ff80ba 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1992,7 +1992,7 @@ components: type: string ResourceID: description: |- - Identifier, formatted as `type:id`. Supported types: `ai-gateway-provider`, `dashboard`, `integration-service`, `integration-webhook`, `notebook`, `powerpack`, `reference-table`, `security-rule`, `slo`, `synthetics-global-variable`, `synthetics-test`, `synthetics-private-location`, `monitor`, `workflow`, `app-builder-app`, `connection`, `connection-group`, `rum-application`, `cross-org-connection`, `spreadsheet`, `on-call-schedule`, `on-call-escalation-policy`, `on-call-team-routing-rules`, `logs-pipeline`, `case-management-project`, `monitor-notification-rule`, `status-page`, `feature-flag`, `network-path-config`. + Identifier, formatted as `type:id`. Supported types: `ai-gateway-provider`, `ai-gateway-route`, `dashboard`, `integration-service`, `integration-webhook`, `notebook`, `powerpack`, `reference-table`, `security-rule`, `slo`, `synthetics-global-variable`, `synthetics-test`, `synthetics-private-location`, `monitor`, `workflow`, `app-builder-app`, `connection`, `connection-group`, `rum-application`, `cross-org-connection`, `spreadsheet`, `on-call-schedule`, `on-call-escalation-policy`, `on-call-team-routing-rules`, `logs-pipeline`, `case-management-project`, `monitor-notification-rule`, `status-page`, `feature-flag`, `network-path-config`. example: "dashboard:abc-def-ghi" in: path name: resource_id @@ -9333,8 +9333,13 @@ components: routing_rules: items: $ref: "#/components/schemas/AiGatewayModelGroupRoutingRule" - description: Routing rule in the group. + description: Viewable routing rule in the group. Hidden route identities are omitted. type: array + routing_rules_restricted: + description: Whether some saved routes are hidden from the caller. Omit routing_rule_slugs to preserve all memberships; replacing the visible selection also preserves saved hidden memberships. + example: true + readOnly: true + type: boolean updated_at: description: Time when the resource was last updated. example: "2026-08-24T12:00:00Z" @@ -10369,18 +10374,19 @@ components: - XHIGH - MAX AiGatewayNullableRoutingRuleTierOrdering: - default: configured description: >- - How a tier orders its targets. Omitted or null defaults to configured, which preserves target order. 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. + 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 + - classified example: configured nullable: true type: string x-enum-varnames: - CONFIGURED - WEIGHTED_AFFINITY + - CLASSIFIED AiGatewayPolicyAttributes: description: Routing policy configuration. properties: @@ -11271,10 +11277,61 @@ components: required: - restricted_details type: object + AiGatewayRoutingClassifier: + description: Saved classified-tier settings. Provider and model are empty when the caller cannot view the provider. + properties: + confidence_threshold: + description: Minimum decision confidence. + example: 0.5 + format: double + type: number + context: + description: Traffic context for the classifier. + example: Requests come from engineers. + type: string + model: + description: Viewable decision model, or an empty string. + example: gpt-6-luna + type: string + provider: + description: Viewable decision-model provider slug, or an empty string. + example: openai + type: string + required: + - provider + - model + - confidence_threshold + type: object + AiGatewayRoutingClassifierRequest: + description: Decision model and settings for a classified tier. Omission preserves the saved classifier; null clears it. Newly selected models require provider View. + nullable: true + properties: + confidence_threshold: + description: Minimum decision confidence. Omission preserves a saved value; new classifiers and explicit null default to 0.5. + example: 0.5 + format: double + maximum: 1 + minimum: 0 + nullable: true + type: number + context: + description: Traffic context for the classifier. Omission preserves saved context. + example: Requests come from engineers. + maxLength: 2000 + type: string + model: + description: Decision model on the provider. Omit together with provider to preserve the saved selection. + example: gpt-6-luna + type: string + provider: + description: Decision-model provider slug. Omit together with model to preserve the saved selection. + example: openai + type: string + type: object AiGatewayRoutingReasoningLevel: description: >- - 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. Omitted or null clears an override on full replacement. 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. + 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. enum: - none - minimal @@ -11303,7 +11360,7 @@ components: format: date-time type: string route_id: - description: Stable numeric route identifier used by scoped policies. + description: Stable numeric route identifier used by scoped policies and `ai-gateway-route` restriction policies. example: 123 format: int64 type: integer @@ -11319,6 +11376,7 @@ components: format: date-time type: string required: + - route_id - tiers - created_at - updated_at @@ -11373,16 +11431,28 @@ components: - data type: object AiGatewayRoutingRuleReplaceAttributes: - description: Attributes used to replace an AI Gateway routing rule. + description: Partial route update. Omit tiers to preserve the entire graph, including hidden selections. Saved target IDs retain omitted settings. Replacing tiers must explicitly retain or remove every hidden occurrence. properties: + expected_updated_at: + description: Saved route revision. A mismatched value returns 409 without changes. + example: "2026-08-24T12:00:00Z" + format: date-time + type: string + removed_target_ids: + description: Parent-local saved occurrence IDs explicitly removed from the submitted tiers. IDs must be distinct, belong to this route, and not also be retained. + items: + example: 901 + format: int64 + minimum: 1 + type: integer + type: array + uniqueItems: true tiers: items: $ref: "#/components/schemas/AiGatewayRoutingRuleTierRequest" description: Routing fallback tier. minItems: 1 type: array - required: - - tiers type: object AiGatewayRoutingRuleReplaceData: description: Data used to replace an AI Gateway routing rule. @@ -11435,6 +11505,10 @@ components: AiGatewayRoutingRuleTarget: description: Model target or reference to another routing rule. properties: + default: + description: Present and true for the default classified destination. + example: true + type: boolean id: description: Saved target row ID. On replacement, retain this ID only within its original route and at most once. A stale or foreign ID is rejected. example: 901 @@ -11457,8 +11531,12 @@ components: type: string reasoning_level: $ref: "#/components/schemas/AiGatewayRoutingReasoningLevel" + rubric: + description: Destination rubric, present only for non-default targets in classified tiers. + example: Short factual questions. + type: string slug: - description: Organization-unique resource slug. + description: Referenced route slug. Omitted when the caller lacks View; only the parent-local occurrence ID remains. example: coding-fallback type: string type: @@ -11476,8 +11554,13 @@ components: AiGatewayRoutingRuleTargetRequest: description: Model target or reference to another routing rule used to create or replace a rule. properties: + default: + description: Whether this is the single default classified destination. Omission preserves a saved value; null clears it. + example: false + nullable: true + type: boolean id: - description: Saved target row ID. On replacement, retain this ID only within its original route and at most once. A stale or foreign ID is rejected. + description: Saved target row ID. On replacement, retain this ID only within its original route and at most once. A stale, foreign, duplicate, or destination-changing ID is rejected. Hidden route targets can be retained using only this parent-local ID and type. example: 901 format: int64 minimum: 1 @@ -11498,15 +11581,21 @@ components: type: string reasoning_level: $ref: "#/components/schemas/AiGatewayRoutingReasoningLevel" + rubric: + 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 + type: string slug: - description: Organization-unique routing rule slug. Allowed only in configured tiers. + description: 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. example: coding-fallback type: string type: $ref: "#/components/schemas/AiGatewayRoutingRuleTargetType" weight: description: >- - Relative weight in a weighted_affinity tier. Omitted or null defaults to 1. Weights need not total 100. Must be omitted or null in configured tiers. + Relative weight in a weighted_affinity tier. Omission preserves a saved target weight; new targets and explicit null default to 1. Weights need not total 100. Must be omitted or null in configured tiers. example: 70 format: int64 maximum: 10000 @@ -11529,6 +11618,8 @@ components: AiGatewayRoutingRuleTier: description: Routing fallback tier containing targets and their effective ordering. properties: + classifier: + $ref: "#/components/schemas/AiGatewayRoutingClassifier" ordering: $ref: "#/components/schemas/AiGatewayRoutingRuleTierOrdering" ordering_issue: @@ -11548,11 +11639,13 @@ components: enum: - configured - weighted_affinity + - classified example: configured type: string x-enum-varnames: - CONFIGURED - WEIGHTED_AFFINITY + - CLASSIFIED AiGatewayRoutingRuleTierOrderingIssue: description: >- Stored tier ordering is inconsistent. mixed means targets have different supported orderings, and unknown means a target has an unsupported ordering. The tier is reported as configured without weights. Replace the rule to repair it. Omitted for consistent tiers. A forced deletion cannot rewrite a surviving tier with an unknown issue. @@ -11568,6 +11661,8 @@ components: AiGatewayRoutingRuleTierRequest: description: Routing fallback tier used to create or replace a rule. properties: + classifier: + $ref: "#/components/schemas/AiGatewayRoutingClassifierRequest" ordering: $ref: "#/components/schemas/AiGatewayNullableRoutingRuleTierOrdering" targets: @@ -75405,6 +75500,10 @@ components: JSONAPIErrorItem: description: API error response body properties: + code: + description: An application-specific error code. + example: invalid_request + type: string detail: description: A human-readable explanation specific to this occurrence of the error. example: Missing required attribute in body @@ -228840,7 +228939,8 @@ paths: /api/v2/providers/{id}: delete: description: >- - Requires `ai_gateway_config_write` and provider Edit. Models and pricing inherit provider access. This also applies when force=true. Existing cascades remain and can affect policies the caller cannot edit. Delete a provider by ID. Providers used by routing rules return provider_in_use with HTTP 409 and the affected rules in error metadata. Retry with force=true to remove provider targets and delete rules left without targets. Surviving tiers keep their ordering and weights. A deletion that would rewrite a surviving tier with an unknown ordering_issue fails with HTTP 409 and code routing_rule_unknown_ordering until that rule is replaced or deleted. + Requires `ai_gateway_config_write` and provider View/Edit. Models and pricing inherit provider access. Every affected route and policy membership requires the corresponding Edit permission; force=true never bypasses authorization. Providers used by routing rules return provider_in_use with HTTP 409. Each JSON:API error item's `meta` contains blocked, restricted_dependencies, policies, rules_to_delete, and rules_to_update. Visible policy entries contain id, name, and editable; visible route entries contain id, slug, and editable. Hidden dependencies are omitted from every collection and reported only by restricted_dependencies. A blocked response changes no configuration; an authorized editor must first remove the blocking references. Retry with force=true to confirm an authorized cascade that removes provider targets and deletes rules left without targets. Surviving tiers keep their ordering and weights. A deletion that would rewrite a surviving tier with an unknown ordering_issue + fails with HTTP 409 and code routing_rule_unknown_ordering until that rule is replaced or deleted. operationId: DeleteAiGatewayProvider parameters: - $ref: "#/components/parameters/AiGatewayProviderID" @@ -228853,7 +228953,31 @@ paths: "404": $ref: "#/components/responses/NotFoundResponse" "409": - $ref: "#/components/responses/ConflictResponse" + content: + application/json: + examples: + protected_dependencies: + value: + errors: + - code: provider_in_use + detail: An authorized editor must first remove blocking references. No configuration was changed. + meta: + blocked: true + policies: + - editable: false + id: default + name: Default policy + restricted_dependencies: true + rules_to_delete: + - editable: false + id: 123 + slug: coding + rules_to_update: [] + status: "409" + title: Provider is used by routing rules + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Conflict "429": $ref: "#/components/responses/TooManyRequestsResponse" security: @@ -233098,8 +233222,8 @@ paths: delete: description: |- Deletes the restriction policy associated with a specified resource. - For AI Gateway provider policies, requires `ai_gateway_config_write` and standard restriction-policy authorization. - Deleting a provider policy restores normal unrestricted defaults. + For AI Gateway provider and route policies, requires `ai_gateway_config_write` and standard restriction-policy authorization. + Deleting a provider or route policy restores normal unrestricted defaults. operationId: DeleteRestrictionPolicy parameters: - $ref: "#/components/parameters/ResourceID" @@ -233125,7 +233249,7 @@ paths: get: description: |- Retrieves the restriction policy associated with a specified resource. - For AI Gateway provider policies, requires `ai_gateway_config_read`. + For AI Gateway provider and route policies, requires `ai_gateway_config_read`. operationId: GetRestrictionPolicy parameters: - $ref: "#/components/parameters/ResourceID" @@ -233170,6 +233294,7 @@ paths: #### Supported resources Restriction policies can be applied to the following resources: - AI Gateway Providers: `ai-gateway-provider` + - AI Gateway Routes: `ai-gateway-route` - Dashboards: `dashboard` - Integration Services: `integration-service` - Integration Webhooks: `integration-webhook` @@ -233199,17 +233324,18 @@ paths: - Feature Flags: `feature-flag` - Network Path Configs: `network-path-config` - AI Gateway provider policies control configuration and inherited model/catalog/pricing visibility. - The editor relation includes View. Providers have no Run relation; restriction policies don't affect inference. - Reading provider policies requires `ai_gateway_config_read`. Updating or deleting them requires + AI Gateway provider policies control configuration and inherited model/catalog/pricing visibility. Route policies control route configuration and identifying nested references. + The editor relation includes View. Providers and routes have no Run relation; restriction policies don't affect inference. + Reading provider or route policies requires `ai_gateway_config_read`. Updating or deleting them requires `ai_gateway_config_write` and follows standard restriction-policy authorization, including administrator recovery and self-lockout checks. - Providers without a restriction policy retain the normal unrestricted defaults. + Providers and routes without a restriction policy retain the normal unrestricted defaults. #### Supported relations for resources Resource Type | Supported Relations ----------------------------|-------------------------- AI Gateway Providers | `viewer`, `editor` + AI Gateway Routes | `viewer`, `editor` Dashboards | `viewer`, `editor` Integration Services | `viewer`, `editor` Integration Webhooks | `viewer`, `editor` @@ -234069,7 +234195,8 @@ paths: /api/v2/routing-rules: delete: description: >- - Delete a routing rule. Referenced rules require force=true. Surviving tiers keep their ordering and weights. A deletion that would rewrite a surviving tier with an unknown ordering_issue fails with HTTP 409 and code routing_rule_unknown_ordering until that rule is replaced or deleted. + Delete a route with `ai_gateway_config_write` and route View/Edit. Every affected route and policy membership requires the corresponding Edit permission. The force=true parameter confirms impact and never bypasses authorization. A denied or unavailable check changes no configuration. Visible dependencies include editable; hidden dependencies are omitted and reported only by restricted_dependencies. A blocked response means an authorized editor must first remove blocking references. Each JSON:API error item's `meta` contains blocked, restricted_dependencies, policies, rules_to_delete, and rules_to_update. Visible policy entries contain id, name, and editable. Route deletion entries contain rule, reason, and editable; update entries contain rule, removed_tiers, and editable. Each rule contains route_id, slug, tiers, created_at, and updated_at with hidden nested selections redacted. The removed_tiers array identifies original tier numbers removed entirely by the cascade. Already-authorized + in-flight operations may finish. Referenced rules require force=true. Surviving tiers keep their ordering and weights. A deletion that would rewrite a surviving tier with an unknown ordering_issue fails with HTTP 409 and code routing_rule_unknown_ordering until that rule is replaced or deleted. Restriction cleanup occurs only after confirmed deletion. Cleanup failure returns 500 with configuration_deleted=true and permissions_cleanup_failed=true; refresh instead of assuming the route still exists. operationId: DeleteAiGatewayRoutingRule parameters: - $ref: "#/components/parameters/AiGatewayRoutingRuleSlug" @@ -234080,7 +234207,42 @@ paths: "404": $ref: "#/components/responses/NotFoundResponse" "409": - $ref: "#/components/responses/ConflictResponse" + content: + application/json: + examples: + protected_dependencies: + value: + errors: + - code: routing_rule_referenced + detail: An authorized editor must first remove blocking references. No configuration was changed. + meta: + blocked: true + policies: + - editable: false + id: default + name: Default policy + restricted_dependencies: true + rules_to_delete: + - editable: true + reason: requested + rule: + created_at: "2026-08-24T12:00:00Z" + route_id: 123 + slug: coding + tiers: + - ordering: configured + targets: + - id: 901 + model: gpt-5.2-codex + provider: prod-us + type: model + updated_at: "2026-08-24T12:00:00Z" + rules_to_update: [] + status: "409" + title: Routing rule is in use + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Conflict "429": $ref: "#/components/responses/TooManyRequestsResponse" security: @@ -234099,7 +234261,7 @@ paths: **Note**: This endpoint is in Preview and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). get: - description: List all routing rules for the organization. + description: List the organization's routing rules that the caller has View access to. Requires `ai_gateway_config_read`. Hidden route references are omitted from nested targets. operationId: ListAiGatewayRoutingRules responses: "200": @@ -234143,7 +234305,7 @@ paths: If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). post: description: >- - Create an organization-owned routing rule. Data capture overrides are managed independently. Each tier has an ordering, which defaults to configured. A weighted_affinity tier distributes first-choice assignments by relative target weights (1 to 10000, default 1) and accepts only distinct model targets with an explicit provider. Weights need not total 100. Configured tiers must omit weights or set them to null. + Create an organization-owned route with `ai_gateway_config_write`. New provider/model and route references require View. New routes use standard unrestricted defaults. To restrict configuration access, create the route and then apply a restriction policy using its numeric route_id. Sharing follows standard restriction-policy propagation and does not grant or revoke policy-authorized inference. Data capture overrides are managed independently. Each tier has an ordering, which defaults to configured. A weighted_affinity tier distributes first-choice assignments by relative target weights (1 to 10000, default 1) and accepts only distinct model targets with an explicit provider. Weights need not total 100. Configured tiers must omit weights or set them to null. operationId: CreateAiGatewayRoutingRule requestBody: content: @@ -234235,7 +234397,7 @@ paths: If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). put: description: >- - Replace a routing rule's tiers. The slug is immutable; data capture is managed independently. This is a full replacement: omitted or null ordering resets the tier to configured, and omitted or null weights in a weighted_affinity tier reset to 1. Omitted or null reasoning_level clears a model destination's reasoning override. Replacing a rule repairs tiers reported with an ordering_issue. + Update a route with `ai_gateway_config_write` and route View/Edit. The slug is immutable; data capture is managed independently. Omitting tiers preserves the entire graph. When tiers are supplied, saved parent-local target IDs retain omitted destination and reasoning, weight, rubric, and default settings. Omitted ordering/classifier settings preserve the saved same-position tier. Explicit null resets nullable settings. New references require View on their resources. A hidden target omitted from tiers must be explicitly listed in removed_target_ids, otherwise the update fails without changes. expected_updated_at rejects stale updates with 409. Sharing-only saves do not replace target rows. Hidden and missing routes return the same 404; visible non-editors receive 403. Inference authorization is unchanged. operationId: UpdateAiGatewayRoutingRule parameters: - $ref: "#/components/parameters/AiGatewayRoutingRuleSlug" @@ -234281,7 +234443,7 @@ paths: appKeyAuth: [] - AuthZ: - ai_gateway_config_write - summary: Replace an AI Gateway routing rule + summary: Update an AI Gateway routing rule tags: - AI Gateway x-codegen-request-body-name: body @@ -234294,7 +234456,7 @@ paths: If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/routing-rules/get: get: - description: Get a routing rule by its organization-unique slug. + description: Get a routing rule by slug with `ai_gateway_config_read` and route View. Hidden and missing routes both return 404. Hidden target identities are omitted; parent-local target IDs remain available for retention. operationId: GetAiGatewayRoutingRule parameters: - $ref: "#/components/parameters/AiGatewayRoutingRuleSlug" diff --git a/examples/v2/ai-gateway/CreateAiGatewayRoutingRule.py b/examples/v2/ai-gateway/CreateAiGatewayRoutingRule.py index 57da44c546..d72d6d6102 100644 --- a/examples/v2/ai-gateway/CreateAiGatewayRoutingRule.py +++ b/examples/v2/ai-gateway/CreateAiGatewayRoutingRule.py @@ -8,6 +8,7 @@ from datadog_api_client.v2.model.ai_gateway_nullable_routing_rule_tier_ordering import ( AiGatewayNullableRoutingRuleTierOrdering, ) +from datadog_api_client.v2.model.ai_gateway_routing_classifier_request import AiGatewayRoutingClassifierRequest from datadog_api_client.v2.model.ai_gateway_routing_reasoning_level import AiGatewayRoutingReasoningLevel from datadog_api_client.v2.model.ai_gateway_routing_rule_create_attributes import AiGatewayRoutingRuleCreateAttributes from datadog_api_client.v2.model.ai_gateway_routing_rule_create_data import AiGatewayRoutingRuleCreateData @@ -23,14 +24,22 @@ slug="coding", tiers=[ AiGatewayRoutingRuleTierRequest( + classifier=AiGatewayRoutingClassifierRequest( + confidence_threshold=0.5, + context="Requests come from engineers.", + model="gpt-6-luna", + provider="openai", + ), ordering=AiGatewayNullableRoutingRuleTierOrdering.CONFIGURED, targets=[ AiGatewayRoutingRuleTargetRequest( + default=False, id=901, model="gpt-5.2-codex", model_id=101, provider="prod-us", reasoning_level=AiGatewayRoutingReasoningLevel.MEDIUM, + rubric="Short factual questions.", slug="coding-fallback", type=AiGatewayRoutingRuleTargetType.MODEL, weight=70, diff --git a/examples/v2/ai-gateway/UpdateAiGatewayRoutingRule.py b/examples/v2/ai-gateway/UpdateAiGatewayRoutingRule.py index 8915f3d035..416fc0d658 100644 --- a/examples/v2/ai-gateway/UpdateAiGatewayRoutingRule.py +++ b/examples/v2/ai-gateway/UpdateAiGatewayRoutingRule.py @@ -1,5 +1,5 @@ """ -Replace an AI Gateway routing rule returns "OK" response +Update an AI Gateway routing rule returns "OK" response """ from os import environ @@ -8,6 +8,7 @@ from datadog_api_client.v2.model.ai_gateway_nullable_routing_rule_tier_ordering import ( AiGatewayNullableRoutingRuleTierOrdering, ) +from datadog_api_client.v2.model.ai_gateway_routing_classifier_request import AiGatewayRoutingClassifierRequest from datadog_api_client.v2.model.ai_gateway_routing_reasoning_level import AiGatewayRoutingReasoningLevel from datadog_api_client.v2.model.ai_gateway_routing_rule_replace_attributes import AiGatewayRoutingRuleReplaceAttributes from datadog_api_client.v2.model.ai_gateway_routing_rule_replace_data import AiGatewayRoutingRuleReplaceData @@ -16,20 +17,34 @@ from datadog_api_client.v2.model.ai_gateway_routing_rule_target_type import AiGatewayRoutingRuleTargetType from datadog_api_client.v2.model.ai_gateway_routing_rule_tier_request import AiGatewayRoutingRuleTierRequest from datadog_api_client.v2.model.ai_gateway_routing_rule_type import AiGatewayRoutingRuleType +from datetime import datetime +from dateutil.tz import tzutc body = AiGatewayRoutingRuleReplaceRequest( data=AiGatewayRoutingRuleReplaceData( attributes=AiGatewayRoutingRuleReplaceAttributes( + expected_updated_at=datetime(2026, 8, 24, 12, 0, tzinfo=tzutc()), + removed_target_ids=[ + 901, + ], tiers=[ AiGatewayRoutingRuleTierRequest( + classifier=AiGatewayRoutingClassifierRequest( + confidence_threshold=0.5, + context="Requests come from engineers.", + model="gpt-6-luna", + provider="openai", + ), ordering=AiGatewayNullableRoutingRuleTierOrdering.CONFIGURED, targets=[ AiGatewayRoutingRuleTargetRequest( + default=False, id=901, model="gpt-5.2-codex", model_id=101, provider="prod-us", reasoning_level=AiGatewayRoutingReasoningLevel.MEDIUM, + rubric="Short factual questions.", slug="coding-fallback", type=AiGatewayRoutingRuleTargetType.MODEL, weight=70, 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 ad2c4405cc..d0894bfa5a 100644 --- a/src/datadog_api_client/v2/api/ai_gateway_api.py +++ b/src/datadog_api_client/v2/api/ai_gateway_api.py @@ -1606,7 +1606,7 @@ def create_ai_gateway_routing_rule( ) -> AiGatewayRoutingRuleResponse: """Create an AI Gateway routing rule. - Create an organization-owned routing rule. Data capture overrides are managed independently. Each tier has an ordering, which defaults to configured. A weighted_affinity tier distributes first-choice assignments by relative target weights (1 to 10000, default 1) and accepts only distinct model targets with an explicit provider. Weights need not total 100. Configured tiers must omit weights or set them to null. + Create an organization-owned route with ``ai_gateway_config_write``. New provider/model and route references require View. New routes use standard unrestricted defaults. To restrict configuration access, create the route and then apply a restriction policy using its numeric route_id. Sharing follows standard restriction-policy propagation and does not grant or revoke policy-authorized inference. Data capture overrides are managed independently. Each tier has an ordering, which defaults to configured. A weighted_affinity tier distributes first-choice assignments by relative target weights (1 to 10000, default 1) and accepts only distinct model targets with an explicit provider. Weights need not total 100. Configured tiers must omit weights or set them to null. :type body: AiGatewayRoutingRuleCreateRequest :rtype: AiGatewayRoutingRuleResponse @@ -1748,7 +1748,7 @@ def delete_ai_gateway_provider( ) -> None: """Delete an AI Gateway provider. - Requires ``ai_gateway_config_write`` and provider Edit. Models and pricing inherit provider access. This also applies when force=true. Existing cascades remain and can affect policies the caller cannot edit. Delete a provider by ID. Providers used by routing rules return provider_in_use with HTTP 409 and the affected rules in error metadata. Retry with force=true to remove provider targets and delete rules left without targets. Surviving tiers keep their ordering and weights. A deletion that would rewrite a surviving tier with an unknown ordering_issue fails with HTTP 409 and code routing_rule_unknown_ordering until that rule is replaced or deleted. + Requires ``ai_gateway_config_write`` and provider View/Edit. Models and pricing inherit provider access. Every affected route and policy membership requires the corresponding Edit permission; force=true never bypasses authorization. Providers used by routing rules return provider_in_use with HTTP 409. Each JSON:API error item's ``meta`` contains blocked, restricted_dependencies, policies, rules_to_delete, and rules_to_update. Visible policy entries contain id, name, and editable; visible route entries contain id, slug, and editable. Hidden dependencies are omitted from every collection and reported only by restricted_dependencies. A blocked response changes no configuration; an authorized editor must first remove the blocking references. Retry with force=true to confirm an authorized cascade that removes provider targets and deletes rules left without targets. Surviving tiers keep their ordering and weights. A deletion that would rewrite a surviving tier with an unknown ordering_issue fails with HTTP 409 and code routing_rule_unknown_ordering until that rule is replaced or deleted. :param id: Provider ID. :type id: int @@ -1789,7 +1789,7 @@ def delete_ai_gateway_routing_rule( ) -> None: """Delete an AI Gateway routing rule. - Delete a routing rule. Referenced rules require force=true. Surviving tiers keep their ordering and weights. A deletion that would rewrite a surviving tier with an unknown ordering_issue fails with HTTP 409 and code routing_rule_unknown_ordering until that rule is replaced or deleted. + Delete a route with ``ai_gateway_config_write`` and route View/Edit. Every affected route and policy membership requires the corresponding Edit permission. The force=true parameter confirms impact and never bypasses authorization. A denied or unavailable check changes no configuration. Visible dependencies include editable; hidden dependencies are omitted and reported only by restricted_dependencies. A blocked response means an authorized editor must first remove blocking references. Each JSON:API error item's ``meta`` contains blocked, restricted_dependencies, policies, rules_to_delete, and rules_to_update. Visible policy entries contain id, name, and editable. Route deletion entries contain rule, reason, and editable; update entries contain rule, removed_tiers, and editable. Each rule contains route_id, slug, tiers, created_at, and updated_at with hidden nested selections redacted. The removed_tiers array identifies original tier numbers removed entirely by the cascade. Already-authorized in-flight operations may finish. Referenced rules require force=true. Surviving tiers keep their ordering and weights. A deletion that would rewrite a surviving tier with an unknown ordering_issue fails with HTTP 409 and code routing_rule_unknown_ordering until that rule is replaced or deleted. Restriction cleanup occurs only after confirmed deletion. Cleanup failure returns 500 with configuration_deleted=true and permissions_cleanup_failed=true; refresh instead of assuming the route still exists. :param slug: Organization-unique routing rule slug. :type slug: str @@ -2008,7 +2008,7 @@ def get_ai_gateway_routing_rule( ) -> AiGatewayRoutingRuleResponse: """Get an AI Gateway routing rule. - Get a routing rule by its organization-unique slug. + Get a routing rule by slug with ``ai_gateway_config_read`` and route View. Hidden and missing routes both return 404. Hidden target identities are omitted; parent-local target IDs remain available for retention. :param slug: Organization-unique routing rule slug. :type slug: str @@ -2269,7 +2269,7 @@ def list_ai_gateway_routing_rules( ) -> AiGatewayRoutingRuleListResponse: """List AI Gateway routing rules. - List all routing rules for the organization. + List the organization's routing rules that the caller has View access to. Requires ``ai_gateway_config_read``. Hidden route references are omitted from nested targets. :rtype: AiGatewayRoutingRuleListResponse """ @@ -2497,9 +2497,9 @@ def update_ai_gateway_routing_rule( slug: str, body: AiGatewayRoutingRuleReplaceRequest, ) -> AiGatewayRoutingRuleResponse: - """Replace an AI Gateway routing rule. + """Update an AI Gateway routing rule. - Replace a routing rule's tiers. The slug is immutable; data capture is managed independently. This is a full replacement: omitted or null ordering resets the tier to configured, and omitted or null weights in a weighted_affinity tier reset to 1. Omitted or null reasoning_level clears a model destination's reasoning override. Replacing a rule repairs tiers reported with an ordering_issue. + Update a route with ``ai_gateway_config_write`` and route View/Edit. The slug is immutable; data capture is managed independently. Omitting tiers preserves the entire graph. When tiers are supplied, saved parent-local target IDs retain omitted destination and reasoning, weight, rubric, and default settings. Omitted ordering/classifier settings preserve the saved same-position tier. Explicit null resets nullable settings. New references require View on their resources. A hidden target omitted from tiers must be explicitly listed in removed_target_ids, otherwise the update fails without changes. expected_updated_at rejects stale updates with 409. Sharing-only saves do not replace target rows. Hidden and missing routes return the same 404; visible non-editors receive 403. Inference authorization is unchanged. :param slug: Organization-unique routing rule slug. :type slug: str diff --git a/src/datadog_api_client/v2/api/restriction_policies_api.py b/src/datadog_api_client/v2/api/restriction_policies_api.py index d54330068a..db19c818cc 100644 --- a/src/datadog_api_client/v2/api/restriction_policies_api.py +++ b/src/datadog_api_client/v2/api/restriction_policies_api.py @@ -111,10 +111,10 @@ def delete_restriction_policy( """Delete a restriction policy. Deletes the restriction policy associated with a specified resource. - For AI Gateway provider policies, requires ``ai_gateway_config_write`` and standard restriction-policy authorization. - Deleting a provider policy restores normal unrestricted defaults. + For AI Gateway provider and route policies, requires ``ai_gateway_config_write`` and standard restriction-policy authorization. + Deleting a provider or route policy restores normal unrestricted defaults. - :param resource_id: Identifier, formatted as ``type:id``. Supported types: ``ai-gateway-provider`` , ``dashboard`` , ``integration-service`` , ``integration-webhook`` , ``notebook`` , ``powerpack`` , ``reference-table`` , ``security-rule`` , ``slo`` , ``synthetics-global-variable`` , ``synthetics-test`` , ``synthetics-private-location`` , ``monitor`` , ``workflow`` , ``app-builder-app`` , ``connection`` , ``connection-group`` , ``rum-application`` , ``cross-org-connection`` , ``spreadsheet`` , ``on-call-schedule`` , ``on-call-escalation-policy`` , ``on-call-team-routing-rules`` , ``logs-pipeline`` , ``case-management-project`` , ``monitor-notification-rule`` , ``status-page`` , ``feature-flag`` , ``network-path-config``. + :param resource_id: Identifier, formatted as ``type:id``. Supported types: ``ai-gateway-provider`` , ``ai-gateway-route`` , ``dashboard`` , ``integration-service`` , ``integration-webhook`` , ``notebook`` , ``powerpack`` , ``reference-table`` , ``security-rule`` , ``slo`` , ``synthetics-global-variable`` , ``synthetics-test`` , ``synthetics-private-location`` , ``monitor`` , ``workflow`` , ``app-builder-app`` , ``connection`` , ``connection-group`` , ``rum-application`` , ``cross-org-connection`` , ``spreadsheet`` , ``on-call-schedule`` , ``on-call-escalation-policy`` , ``on-call-team-routing-rules`` , ``logs-pipeline`` , ``case-management-project`` , ``monitor-notification-rule`` , ``status-page`` , ``feature-flag`` , ``network-path-config``. :type resource_id: str :rtype: None """ @@ -130,9 +130,9 @@ def get_restriction_policy( """Get a restriction policy. Retrieves the restriction policy associated with a specified resource. - For AI Gateway provider policies, requires ``ai_gateway_config_read``. + For AI Gateway provider and route policies, requires ``ai_gateway_config_read``. - :param resource_id: Identifier, formatted as ``type:id``. Supported types: ``ai-gateway-provider`` , ``dashboard`` , ``integration-service`` , ``integration-webhook`` , ``notebook`` , ``powerpack`` , ``reference-table`` , ``security-rule`` , ``slo`` , ``synthetics-global-variable`` , ``synthetics-test`` , ``synthetics-private-location`` , ``monitor`` , ``workflow`` , ``app-builder-app`` , ``connection`` , ``connection-group`` , ``rum-application`` , ``cross-org-connection`` , ``spreadsheet`` , ``on-call-schedule`` , ``on-call-escalation-policy`` , ``on-call-team-routing-rules`` , ``logs-pipeline`` , ``case-management-project`` , ``monitor-notification-rule`` , ``status-page`` , ``feature-flag`` , ``network-path-config``. + :param resource_id: Identifier, formatted as ``type:id``. Supported types: ``ai-gateway-provider`` , ``ai-gateway-route`` , ``dashboard`` , ``integration-service`` , ``integration-webhook`` , ``notebook`` , ``powerpack`` , ``reference-table`` , ``security-rule`` , ``slo`` , ``synthetics-global-variable`` , ``synthetics-test`` , ``synthetics-private-location`` , ``monitor`` , ``workflow`` , ``app-builder-app`` , ``connection`` , ``connection-group`` , ``rum-application`` , ``cross-org-connection`` , ``spreadsheet`` , ``on-call-schedule`` , ``on-call-escalation-policy`` , ``on-call-team-routing-rules`` , ``logs-pipeline`` , ``case-management-project`` , ``monitor-notification-rule`` , ``status-page`` , ``feature-flag`` , ``network-path-config``. :type resource_id: str :rtype: RestrictionPolicyResponse """ @@ -157,6 +157,7 @@ def update_restriction_policy( Restriction policies can be applied to the following resources: * AI Gateway Providers: ``ai-gateway-provider`` + * AI Gateway Routes: ``ai-gateway-route`` * Dashboards: ``dashboard`` * Integration Services: ``integration-service`` * Integration Webhooks: ``integration-webhook`` @@ -186,12 +187,12 @@ def update_restriction_policy( * Feature Flags: ``feature-flag`` * Network Path Configs: ``network-path-config`` - AI Gateway provider policies control configuration and inherited model/catalog/pricing visibility. - The editor relation includes View. Providers have no Run relation; restriction policies don't affect inference. - Reading provider policies requires ``ai_gateway_config_read``. Updating or deleting them requires + AI Gateway provider policies control configuration and inherited model/catalog/pricing visibility. Route policies control route configuration and identifying nested references. + The editor relation includes View. Providers and routes have no Run relation; restriction policies don't affect inference. + Reading provider or route policies requires ``ai_gateway_config_read``. Updating or deleting them requires ``ai_gateway_config_write`` and follows standard restriction-policy authorization, including administrator recovery and self-lockout checks. - Providers without a restriction policy retain the normal unrestricted defaults. + Providers and routes without a restriction policy retain the normal unrestricted defaults. **Supported relations for resources** @@ -202,6 +203,8 @@ def update_restriction_policy( - Supported Relations * - AI Gateway Providers - ``viewer`` , ``editor`` + * - AI Gateway Routes + - ``viewer`` , ``editor`` * - Dashboards - ``viewer`` , ``editor`` * - Integration Services @@ -260,7 +263,7 @@ def update_restriction_policy( - ``viewer`` , ``editor`` - :param resource_id: Identifier, formatted as ``type:id``. Supported types: ``ai-gateway-provider`` , ``dashboard`` , ``integration-service`` , ``integration-webhook`` , ``notebook`` , ``powerpack`` , ``reference-table`` , ``security-rule`` , ``slo`` , ``synthetics-global-variable`` , ``synthetics-test`` , ``synthetics-private-location`` , ``monitor`` , ``workflow`` , ``app-builder-app`` , ``connection`` , ``connection-group`` , ``rum-application`` , ``cross-org-connection`` , ``spreadsheet`` , ``on-call-schedule`` , ``on-call-escalation-policy`` , ``on-call-team-routing-rules`` , ``logs-pipeline`` , ``case-management-project`` , ``monitor-notification-rule`` , ``status-page`` , ``feature-flag`` , ``network-path-config``. + :param resource_id: Identifier, formatted as ``type:id``. Supported types: ``ai-gateway-provider`` , ``ai-gateway-route`` , ``dashboard`` , ``integration-service`` , ``integration-webhook`` , ``notebook`` , ``powerpack`` , ``reference-table`` , ``security-rule`` , ``slo`` , ``synthetics-global-variable`` , ``synthetics-test`` , ``synthetics-private-location`` , ``monitor`` , ``workflow`` , ``app-builder-app`` , ``connection`` , ``connection-group`` , ``rum-application`` , ``cross-org-connection`` , ``spreadsheet`` , ``on-call-schedule`` , ``on-call-escalation-policy`` , ``on-call-team-routing-rules`` , ``logs-pipeline`` , ``case-management-project`` , ``monitor-notification-rule`` , ``status-page`` , ``feature-flag`` , ``network-path-config``. :type resource_id: str :param body: Restriction policy payload :type body: RestrictionPolicyUpdateRequest diff --git a/src/datadog_api_client/v2/model/ai_gateway_model_group_attributes.py b/src/datadog_api_client/v2/model/ai_gateway_model_group_attributes.py index 739eb8f56d..646fa463d5 100644 --- a/src/datadog_api_client/v2/model/ai_gateway_model_group_attributes.py +++ b/src/datadog_api_client/v2/model/ai_gateway_model_group_attributes.py @@ -49,6 +49,7 @@ def openapi_types(_): "providers": ([AiGatewayModelGroupProvider],), "revision": (int,), "routing_rules": ([AiGatewayModelGroupRoutingRule],), + "routing_rules_restricted": (bool,), "updated_at": (datetime,), } @@ -63,8 +64,12 @@ def openapi_types(_): "providers": "providers", "revision": "revision", "routing_rules": "routing_rules", + "routing_rules_restricted": "routing_rules_restricted", "updated_at": "updated_at", } + read_only_vars = { + "routing_rules_restricted", + } def __init__( self_, @@ -79,6 +84,7 @@ def __init__( routing_rules: List[AiGatewayModelGroupRoutingRule], updated_at: datetime, revision: Union[int, UnsetType] = unset, + routing_rules_restricted: Union[bool, UnsetType] = unset, **kwargs, ): """ @@ -114,11 +120,16 @@ def __init__( :param routing_rules: :type routing_rules: [AiGatewayModelGroupRoutingRule] + :param routing_rules_restricted: Whether some saved routes are hidden from the caller. Omit routing_rule_slugs to preserve all memberships; replacing the visible selection also preserves saved hidden memberships. + :type routing_rules_restricted: bool, optional + :param updated_at: Time when the resource was last updated. :type updated_at: datetime """ if revision is not unset: kwargs["revision"] = revision + if routing_rules_restricted is not unset: + kwargs["routing_rules_restricted"] = routing_rules_restricted super().__init__(kwargs) self_.allow_fast_mode = allow_fast_mode 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 e64826a314..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,18 +14,20 @@ class AiGatewayNullableRoutingRuleTierOrdering(ModelSimple): """ - How a tier orders its targets. Omitted or null defaults to configured, which preserves target order. 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. + 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: If omitted defaults to "configured". Must be one of ["configured", "weighted_affinity"]. + :param value: Must be one of ["configured", "weighted_affinity", "classified"]. :type value: str """ allowed_values = { "configured", "weighted_affinity", + "classified", } CONFIGURED: ClassVar["AiGatewayNullableRoutingRuleTierOrdering"] WEIGHTED_AFFINITY: ClassVar["AiGatewayNullableRoutingRuleTierOrdering"] + CLASSIFIED: ClassVar["AiGatewayNullableRoutingRuleTierOrdering"] _nullable = True @@ -40,3 +42,4 @@ def openapi_types(_): AiGatewayNullableRoutingRuleTierOrdering.WEIGHTED_AFFINITY = AiGatewayNullableRoutingRuleTierOrdering( "weighted_affinity" ) +AiGatewayNullableRoutingRuleTierOrdering.CLASSIFIED = AiGatewayNullableRoutingRuleTierOrdering("classified") diff --git a/src/datadog_api_client/v2/model/ai_gateway_routing_classifier.py b/src/datadog_api_client/v2/model/ai_gateway_routing_classifier.py new file mode 100644 index 0000000000..dc0403fcbf --- /dev/null +++ b/src/datadog_api_client/v2/model/ai_gateway_routing_classifier.py @@ -0,0 +1,57 @@ +# 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 Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +class AiGatewayRoutingClassifier(ModelNormal): + @cached_property + def openapi_types(_): + return { + "confidence_threshold": (float,), + "context": (str,), + "model": (str,), + "provider": (str,), + } + + attribute_map = { + "confidence_threshold": "confidence_threshold", + "context": "context", + "model": "model", + "provider": "provider", + } + + def __init__( + self_, confidence_threshold: float, model: str, provider: str, context: Union[str, UnsetType] = unset, **kwargs + ): + """ + Saved classified-tier settings. Provider and model are empty when the caller cannot view the provider. + + :param confidence_threshold: Minimum decision confidence. + :type confidence_threshold: float + + :param context: Traffic context for the classifier. + :type context: str, optional + + :param model: Viewable decision model, or an empty string. + :type model: str + + :param provider: Viewable decision-model provider slug, or an empty string. + :type provider: str + """ + if context is not unset: + kwargs["context"] = context + super().__init__(kwargs) + + self_.confidence_threshold = confidence_threshold + self_.model = model + self_.provider = provider 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 new file mode 100644 index 0000000000..d8b34f0b01 --- /dev/null +++ b/src/datadog_api_client/v2/model/ai_gateway_routing_classifier_request.py @@ -0,0 +1,76 @@ +# 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 Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + none_type, + unset, + UnsetType, +) + + +class AiGatewayRoutingClassifierRequest(ModelNormal): + validations = { + "confidence_threshold": { + "inclusive_maximum": 1, + "inclusive_minimum": 0, + }, + "context": { + "max_length": 2000, + }, + } + _nullable = True + + @cached_property + def openapi_types(_): + return { + "confidence_threshold": (float, none_type), + "context": (str,), + "model": (str,), + "provider": (str,), + } + + attribute_map = { + "confidence_threshold": "confidence_threshold", + "context": "context", + "model": "model", + "provider": "provider", + } + + def __init__( + self_, + confidence_threshold: Union[float, none_type, UnsetType] = unset, + context: Union[str, UnsetType] = unset, + model: Union[str, UnsetType] = unset, + provider: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + Decision model and settings for a classified tier. Omission preserves the saved classifier; null clears it. Newly selected models require provider View. + + :param confidence_threshold: Minimum decision confidence. Omission preserves a saved value; new classifiers and explicit null default to 0.5. + :type confidence_threshold: float, none_type, optional + + :param context: Traffic context for the classifier. Omission preserves saved context. + :type context: str, optional + + :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. Omit together with model to preserve the saved selection. + :type provider: str, optional + """ + if confidence_threshold is not unset: + kwargs["confidence_threshold"] = confidence_threshold + if context is not unset: + kwargs["context"] = context + if model is not unset: + kwargs["model"] = model + if provider is not unset: + kwargs["provider"] = provider + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/ai_gateway_routing_reasoning_level.py b/src/datadog_api_client/v2/model/ai_gateway_routing_reasoning_level.py index e901336455..eb946120fc 100644 --- a/src/datadog_api_client/v2/model/ai_gateway_routing_reasoning_level.py +++ b/src/datadog_api_client/v2/model/ai_gateway_routing_reasoning_level.py @@ -14,7 +14,7 @@ class AiGatewayRoutingReasoningLevel(ModelSimple): """ - 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. Omitted or null clears an override on full replacement. 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. + 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. :param value: Must be one of ["none", "minimal", "low", "medium", "high", "xhigh", "max"]. :type value: str diff --git a/src/datadog_api_client/v2/model/ai_gateway_routing_rule_attributes.py b/src/datadog_api_client/v2/model/ai_gateway_routing_rule_attributes.py index d430612f25..c8ff74fbf5 100644 --- a/src/datadog_api_client/v2/model/ai_gateway_routing_rule_attributes.py +++ b/src/datadog_api_client/v2/model/ai_gateway_routing_rule_attributes.py @@ -3,14 +3,12 @@ # Copyright 2019-Present Datadog, Inc. from __future__ import annotations -from typing import List, Union, TYPE_CHECKING +from typing import List, TYPE_CHECKING from datadog_api_client.model_utils import ( ModelNormal, cached_property, datetime, - unset, - UnsetType, ) @@ -46,9 +44,9 @@ def openapi_types(_): def __init__( self_, created_at: datetime, + route_id: int, tiers: List[AiGatewayRoutingRuleTier], updated_at: datetime, - route_id: Union[int, UnsetType] = unset, **kwargs, ): """ @@ -57,8 +55,8 @@ def __init__( :param created_at: Time when the resource was created. :type created_at: datetime - :param route_id: Stable numeric route identifier used by scoped policies. - :type route_id: int, optional + :param route_id: Stable numeric route identifier used by scoped policies and ``ai-gateway-route`` restriction policies. + :type route_id: int :param tiers: :type tiers: [AiGatewayRoutingRuleTier] @@ -66,10 +64,9 @@ def __init__( :param updated_at: Time when the resource was last updated. :type updated_at: datetime """ - if route_id is not unset: - kwargs["route_id"] = route_id super().__init__(kwargs) self_.created_at = created_at + self_.route_id = route_id self_.tiers = tiers self_.updated_at = updated_at diff --git a/src/datadog_api_client/v2/model/ai_gateway_routing_rule_replace_attributes.py b/src/datadog_api_client/v2/model/ai_gateway_routing_rule_replace_attributes.py index aa7ceb10a1..b6f6727454 100644 --- a/src/datadog_api_client/v2/model/ai_gateway_routing_rule_replace_attributes.py +++ b/src/datadog_api_client/v2/model/ai_gateway_routing_rule_replace_attributes.py @@ -3,11 +3,14 @@ # Copyright 2019-Present Datadog, Inc. from __future__ import annotations -from typing import List, TYPE_CHECKING +from typing import List, Union, TYPE_CHECKING from datadog_api_client.model_utils import ( ModelNormal, cached_property, + datetime, + unset, + UnsetType, ) @@ -27,20 +30,40 @@ def openapi_types(_): from datadog_api_client.v2.model.ai_gateway_routing_rule_tier_request import AiGatewayRoutingRuleTierRequest return { + "expected_updated_at": (datetime,), + "removed_target_ids": ([int],), "tiers": ([AiGatewayRoutingRuleTierRequest],), } attribute_map = { + "expected_updated_at": "expected_updated_at", + "removed_target_ids": "removed_target_ids", "tiers": "tiers", } - def __init__(self_, tiers: List[AiGatewayRoutingRuleTierRequest], **kwargs): + def __init__( + self_, + expected_updated_at: Union[datetime, UnsetType] = unset, + removed_target_ids: Union[List[int], UnsetType] = unset, + tiers: Union[List[AiGatewayRoutingRuleTierRequest], UnsetType] = unset, + **kwargs, + ): """ - Attributes used to replace an AI Gateway routing rule. + Partial route update. Omit tiers to preserve the entire graph, including hidden selections. Saved target IDs retain omitted settings. Replacing tiers must explicitly retain or remove every hidden occurrence. + + :param expected_updated_at: Saved route revision. A mismatched value returns 409 without changes. + :type expected_updated_at: datetime, optional + + :param removed_target_ids: Parent-local saved occurrence IDs explicitly removed from the submitted tiers. IDs must be distinct, belong to this route, and not also be retained. + :type removed_target_ids: [int], optional :param tiers: - :type tiers: [AiGatewayRoutingRuleTierRequest] + :type tiers: [AiGatewayRoutingRuleTierRequest], optional """ + if expected_updated_at is not unset: + kwargs["expected_updated_at"] = expected_updated_at + if removed_target_ids is not unset: + kwargs["removed_target_ids"] = removed_target_ids + if tiers is not unset: + kwargs["tiers"] = tiers super().__init__(kwargs) - - self_.tiers = tiers diff --git a/src/datadog_api_client/v2/model/ai_gateway_routing_rule_replace_data.py b/src/datadog_api_client/v2/model/ai_gateway_routing_rule_replace_data.py index e7f23f7469..837c503f35 100644 --- a/src/datadog_api_client/v2/model/ai_gateway_routing_rule_replace_data.py +++ b/src/datadog_api_client/v2/model/ai_gateway_routing_rule_replace_data.py @@ -44,7 +44,7 @@ def __init__( """ Data used to replace an AI Gateway routing rule. - :param attributes: Attributes used to replace an AI Gateway routing rule. + :param attributes: Partial route update. Omit tiers to preserve the entire graph, including hidden selections. Saved target IDs retain omitted settings. Replacing tiers must explicitly retain or remove every hidden occurrence. :type attributes: AiGatewayRoutingRuleReplaceAttributes :param id: Resource identifier. diff --git a/src/datadog_api_client/v2/model/ai_gateway_routing_rule_target.py b/src/datadog_api_client/v2/model/ai_gateway_routing_rule_target.py index e922fb18aa..2a1997de82 100644 --- a/src/datadog_api_client/v2/model/ai_gateway_routing_rule_target.py +++ b/src/datadog_api_client/v2/model/ai_gateway_routing_rule_target.py @@ -39,22 +39,26 @@ def openapi_types(_): from datadog_api_client.v2.model.ai_gateway_routing_rule_target_type import AiGatewayRoutingRuleTargetType return { + "default": (bool,), "id": (int,), "model": (str,), "model_id": (int,), "provider": (str,), "reasoning_level": (AiGatewayRoutingReasoningLevel,), + "rubric": (str,), "slug": (str,), "type": (AiGatewayRoutingRuleTargetType,), "weight": (int,), } attribute_map = { + "default": "default", "id": "id", "model": "model", "model_id": "model_id", "provider": "provider", "reasoning_level": "reasoning_level", + "rubric": "rubric", "slug": "slug", "type": "type", "weight": "weight", @@ -63,11 +67,13 @@ def openapi_types(_): def __init__( self_, type: AiGatewayRoutingRuleTargetType, + default: Union[bool, UnsetType] = unset, id: Union[int, UnsetType] = unset, model: Union[str, UnsetType] = unset, model_id: Union[int, UnsetType] = unset, provider: Union[str, UnsetType] = unset, reasoning_level: Union[AiGatewayRoutingReasoningLevel, none_type, UnsetType] = unset, + rubric: Union[str, UnsetType] = unset, slug: Union[str, UnsetType] = unset, weight: Union[int, UnsetType] = unset, **kwargs, @@ -75,6 +81,9 @@ def __init__( """ Model target or reference to another routing rule. + :param default: Present and true for the default classified destination. + :type default: bool, optional + :param id: Saved target row ID. On replacement, retain this ID only within its original route and at most once. A stale or foreign ID is rejected. :type id: int, optional @@ -87,10 +96,13 @@ def __init__( :param provider: Provider slug. Omitted for dynamic resolution and when the caller cannot view its provider. :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. Omitted or null clears an override on full replacement. 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. + :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 slug: Organization-unique resource slug. + :param rubric: Destination rubric, present only for non-default targets in classified tiers. + :type rubric: str, optional + + :param slug: Referenced route slug. Omitted when the caller lacks View; only the parent-local occurrence ID remains. :type slug: str, optional :param type: Type of routing target. @@ -99,6 +111,8 @@ def __init__( :param weight: Effective relative weight. Returned only for targets in weighted_affinity tiers. :type weight: int, optional """ + if default is not unset: + kwargs["default"] = default if id is not unset: kwargs["id"] = id if model is not unset: @@ -109,6 +123,8 @@ def __init__( kwargs["provider"] = provider if reasoning_level is not unset: kwargs["reasoning_level"] = reasoning_level + if rubric is not unset: + kwargs["rubric"] = rubric if slug is not unset: kwargs["slug"] = slug if weight 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 8c5f8f0cf5..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 @@ -27,6 +27,9 @@ class AiGatewayRoutingRuleTargetRequest(ModelNormal): "model_id": { "inclusive_minimum": 1, }, + "rubric": { + "max_length": 300, + }, "weight": { "inclusive_maximum": 10000, "inclusive_minimum": 1, @@ -39,22 +42,26 @@ def openapi_types(_): from datadog_api_client.v2.model.ai_gateway_routing_rule_target_type import AiGatewayRoutingRuleTargetType return { + "default": (bool, none_type), "id": (int,), "model": (str,), "model_id": (int,), "provider": (str,), "reasoning_level": (AiGatewayRoutingReasoningLevel,), + "rubric": (str, none_type), "slug": (str,), "type": (AiGatewayRoutingRuleTargetType,), "weight": (int, none_type), } attribute_map = { + "default": "default", "id": "id", "model": "model", "model_id": "model_id", "provider": "provider", "reasoning_level": "reasoning_level", + "rubric": "rubric", "slug": "slug", "type": "type", "weight": "weight", @@ -63,11 +70,13 @@ def openapi_types(_): def __init__( self_, type: AiGatewayRoutingRuleTargetType, + default: Union[bool, none_type, UnsetType] = unset, id: Union[int, UnsetType] = unset, model: Union[str, UnsetType] = unset, model_id: Union[int, UnsetType] = unset, provider: Union[str, UnsetType] = unset, reasoning_level: Union[AiGatewayRoutingReasoningLevel, none_type, UnsetType] = unset, + rubric: Union[str, none_type, UnsetType] = unset, slug: Union[str, UnsetType] = unset, weight: Union[int, none_type, UnsetType] = unset, **kwargs, @@ -75,7 +84,10 @@ def __init__( """ Model target or reference to another routing rule used to create or replace a rule. - :param id: Saved target row ID. On replacement, retain this ID only within its original route and at most once. A stale or foreign ID is rejected. + :param default: Whether this is the single default classified destination. Omission preserves a saved value; null clears it. + :type default: bool, none_type, optional + + :param id: Saved target row ID. On replacement, retain this ID only within its original route and at most once. A stale, foreign, duplicate, or destination-changing ID is rejected. Hidden route targets can be retained using only this parent-local ID and type. :type id: int, optional :param model: Model name. Omit when retaining a saved target by ID or selecting a concrete target by model_id. @@ -87,18 +99,23 @@ def __init__( :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. Omitted or null clears an override on full replacement. 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. + :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 slug: Organization-unique routing rule slug. Allowed only in configured tiers. + :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. :type slug: str, optional :param type: Type of routing target. :type type: AiGatewayRoutingRuleTargetType - :param weight: Relative weight in a weighted_affinity tier. Omitted or null defaults to 1. Weights need not total 100. Must be omitted or null in configured tiers. + :param weight: Relative weight in a weighted_affinity tier. Omission preserves a saved target weight; new targets and explicit null default to 1. Weights need not total 100. Must be omitted or null in configured tiers. :type weight: int, none_type, optional """ + if default is not unset: + kwargs["default"] = default if id is not unset: kwargs["id"] = id if model is not unset: @@ -109,6 +126,8 @@ def __init__( kwargs["provider"] = provider if reasoning_level is not unset: kwargs["reasoning_level"] = reasoning_level + if rubric is not unset: + kwargs["rubric"] = rubric if slug is not unset: kwargs["slug"] = slug if weight is not unset: diff --git a/src/datadog_api_client/v2/model/ai_gateway_routing_rule_tier.py b/src/datadog_api_client/v2/model/ai_gateway_routing_rule_tier.py index 4d54345c2c..5f38b3ff29 100644 --- a/src/datadog_api_client/v2/model/ai_gateway_routing_rule_tier.py +++ b/src/datadog_api_client/v2/model/ai_gateway_routing_rule_tier.py @@ -14,6 +14,7 @@ if TYPE_CHECKING: + from datadog_api_client.v2.model.ai_gateway_routing_classifier import AiGatewayRoutingClassifier from datadog_api_client.v2.model.ai_gateway_routing_rule_tier_ordering import AiGatewayRoutingRuleTierOrdering from datadog_api_client.v2.model.ai_gateway_routing_rule_tier_ordering_issue import ( AiGatewayRoutingRuleTierOrderingIssue, @@ -30,6 +31,7 @@ class AiGatewayRoutingRuleTier(ModelNormal): @cached_property def openapi_types(_): + from datadog_api_client.v2.model.ai_gateway_routing_classifier import AiGatewayRoutingClassifier from datadog_api_client.v2.model.ai_gateway_routing_rule_tier_ordering import AiGatewayRoutingRuleTierOrdering from datadog_api_client.v2.model.ai_gateway_routing_rule_tier_ordering_issue import ( AiGatewayRoutingRuleTierOrderingIssue, @@ -37,12 +39,14 @@ def openapi_types(_): from datadog_api_client.v2.model.ai_gateway_routing_rule_target import AiGatewayRoutingRuleTarget return { + "classifier": (AiGatewayRoutingClassifier,), "ordering": (AiGatewayRoutingRuleTierOrdering,), "ordering_issue": (AiGatewayRoutingRuleTierOrderingIssue,), "targets": ([AiGatewayRoutingRuleTarget],), } attribute_map = { + "classifier": "classifier", "ordering": "ordering", "ordering_issue": "ordering_issue", "targets": "targets", @@ -55,12 +59,16 @@ def __init__( self_, ordering: AiGatewayRoutingRuleTierOrdering, targets: List[AiGatewayRoutingRuleTarget], + classifier: Union[AiGatewayRoutingClassifier, UnsetType] = unset, ordering_issue: Union[AiGatewayRoutingRuleTierOrderingIssue, UnsetType] = unset, **kwargs, ): """ Routing fallback tier containing targets and their effective ordering. + :param classifier: Saved classified-tier settings. Provider and model are empty when the caller cannot view the provider. + :type classifier: AiGatewayRoutingClassifier, optional + :param ordering: How a tier orders its targets. :type ordering: AiGatewayRoutingRuleTierOrdering @@ -70,6 +78,8 @@ def __init__( :param targets: :type targets: [AiGatewayRoutingRuleTarget] """ + if classifier is not unset: + kwargs["classifier"] = classifier if ordering_issue is not unset: kwargs["ordering_issue"] = ordering_issue super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/ai_gateway_routing_rule_tier_ordering.py b/src/datadog_api_client/v2/model/ai_gateway_routing_rule_tier_ordering.py index d08fc79cd6..f236ace94e 100644 --- a/src/datadog_api_client/v2/model/ai_gateway_routing_rule_tier_ordering.py +++ b/src/datadog_api_client/v2/model/ai_gateway_routing_rule_tier_ordering.py @@ -16,16 +16,18 @@ class AiGatewayRoutingRuleTierOrdering(ModelSimple): """ How a tier orders its targets. - :param value: Must be one of ["configured", "weighted_affinity"]. + :param value: Must be one of ["configured", "weighted_affinity", "classified"]. :type value: str """ allowed_values = { "configured", "weighted_affinity", + "classified", } CONFIGURED: ClassVar["AiGatewayRoutingRuleTierOrdering"] WEIGHTED_AFFINITY: ClassVar["AiGatewayRoutingRuleTierOrdering"] + CLASSIFIED: ClassVar["AiGatewayRoutingRuleTierOrdering"] @cached_property def openapi_types(_): @@ -36,3 +38,4 @@ def openapi_types(_): AiGatewayRoutingRuleTierOrdering.CONFIGURED = AiGatewayRoutingRuleTierOrdering("configured") AiGatewayRoutingRuleTierOrdering.WEIGHTED_AFFINITY = AiGatewayRoutingRuleTierOrdering("weighted_affinity") +AiGatewayRoutingRuleTierOrdering.CLASSIFIED = AiGatewayRoutingRuleTierOrdering("classified") 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 02903d9102..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 @@ -15,6 +15,7 @@ if TYPE_CHECKING: + from datadog_api_client.v2.model.ai_gateway_routing_classifier_request import AiGatewayRoutingClassifierRequest from datadog_api_client.v2.model.ai_gateway_nullable_routing_rule_tier_ordering import ( AiGatewayNullableRoutingRuleTierOrdering, ) @@ -30,17 +31,20 @@ class AiGatewayRoutingRuleTierRequest(ModelNormal): @cached_property def openapi_types(_): + from datadog_api_client.v2.model.ai_gateway_routing_classifier_request import AiGatewayRoutingClassifierRequest from datadog_api_client.v2.model.ai_gateway_nullable_routing_rule_tier_ordering import ( AiGatewayNullableRoutingRuleTierOrdering, ) from datadog_api_client.v2.model.ai_gateway_routing_rule_target_request import AiGatewayRoutingRuleTargetRequest return { + "classifier": (AiGatewayRoutingClassifierRequest,), "ordering": (AiGatewayNullableRoutingRuleTierOrdering,), "targets": ([AiGatewayRoutingRuleTargetRequest],), } attribute_map = { + "classifier": "classifier", "ordering": "ordering", "targets": "targets", } @@ -48,18 +52,24 @@ def openapi_types(_): def __init__( self_, targets: List[AiGatewayRoutingRuleTargetRequest], + classifier: Union[AiGatewayRoutingClassifierRequest, none_type, UnsetType] = unset, ordering: Union[AiGatewayNullableRoutingRuleTierOrdering, none_type, UnsetType] = unset, **kwargs, ): """ Routing fallback tier used to create or replace a rule. - :param ordering: How a tier orders its targets. Omitted or null defaults to configured, which preserves target order. 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. + :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. :type ordering: AiGatewayNullableRoutingRuleTierOrdering, none_type, optional :param targets: :type targets: [AiGatewayRoutingRuleTargetRequest] """ + if classifier is not unset: + kwargs["classifier"] = classifier if ordering is not unset: kwargs["ordering"] = ordering super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/jsonapi_error_item.py b/src/datadog_api_client/v2/model/jsonapi_error_item.py index 6040e786d2..c55faea306 100644 --- a/src/datadog_api_client/v2/model/jsonapi_error_item.py +++ b/src/datadog_api_client/v2/model/jsonapi_error_item.py @@ -27,6 +27,7 @@ def openapi_types(_): from datadog_api_client.v2.model.jsonapi_error_item_source import JSONAPIErrorItemSource return { + "code": (str,), "detail": (str,), "meta": ( { @@ -50,6 +51,7 @@ def openapi_types(_): } attribute_map = { + "code": "code", "detail": "detail", "meta": "meta", "source": "source", @@ -59,6 +61,7 @@ def openapi_types(_): def __init__( self_, + code: Union[str, UnsetType] = unset, detail: Union[str, UnsetType] = unset, meta: Union[Dict[str, Any], UnsetType] = unset, source: Union[JSONAPIErrorItemSource, UnsetType] = unset, @@ -69,6 +72,9 @@ def __init__( """ API error response body + :param code: An application-specific error code. + :type code: str, optional + :param detail: A human-readable explanation specific to this occurrence of the error. :type detail: str, optional @@ -84,6 +90,8 @@ def __init__( :param title: Short human-readable summary of the error. :type title: str, optional """ + if code is not unset: + kwargs["code"] = code if detail is not unset: kwargs["detail"] = detail if meta is not unset: diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 5730fdc6bc..023c204e6e 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -618,6 +618,8 @@ from datadog_api_client.v2.model.ai_gateway_rate_limit_usage_resource import AiGatewayRateLimitUsageResource from datadog_api_client.v2.model.ai_gateway_rate_limit_usage_type import AiGatewayRateLimitUsageType from datadog_api_client.v2.model.ai_gateway_restricted_details_meta import AiGatewayRestrictedDetailsMeta +from datadog_api_client.v2.model.ai_gateway_routing_classifier import AiGatewayRoutingClassifier +from datadog_api_client.v2.model.ai_gateway_routing_classifier_request import AiGatewayRoutingClassifierRequest from datadog_api_client.v2.model.ai_gateway_routing_reasoning_level import AiGatewayRoutingReasoningLevel from datadog_api_client.v2.model.ai_gateway_routing_rule_attributes import AiGatewayRoutingRuleAttributes from datadog_api_client.v2.model.ai_gateway_routing_rule_create_attributes import AiGatewayRoutingRuleCreateAttributes @@ -14436,6 +14438,8 @@ "AiGatewayRateLimitUsageResource", "AiGatewayRateLimitUsageType", "AiGatewayRestrictedDetailsMeta", + "AiGatewayRoutingClassifier", + "AiGatewayRoutingClassifierRequest", "AiGatewayRoutingReasoningLevel", "AiGatewayRoutingRuleAttributes", "AiGatewayRoutingRuleCreateAttributes", diff --git a/tests/v2/features/ai_gateway.feature b/tests/v2/features/ai_gateway.feature index 7c5d3c87c8..1036e76dfa 100644 --- a/tests/v2/features/ai_gateway.feature +++ b/tests/v2/features/ai_gateway.feature @@ -208,7 +208,7 @@ Feature: AI Gateway Scenario: Create an AI Gateway routing rule returns "Bad Request" response Given operation "CreateAiGatewayRoutingRule" enabled And new "CreateAiGatewayRoutingRule" request - And body with value {"data": {"attributes": {"slug": "coding", "tiers": [{"ordering": "configured", "targets": [{"id": 901, "model": "gpt-5.2-codex", "model_id": 101, "provider": "prod-us", "reasoning_level": "medium", "slug": "coding-fallback", "type": "model", "weight": 70}]}]}, "type": "routing-rules"}} + And body with value {"data": {"attributes": {"slug": "coding", "tiers": [{"classifier": {"confidence_threshold": 0.5, "context": "Requests come from engineers.", "model": "gpt-6-luna", "provider": "openai"}, "ordering": "configured", "targets": [{"default": false, "id": 901, "model": "gpt-5.2-codex", "model_id": 101, "provider": "prod-us", "reasoning_level": "medium", "rubric": "Short factual questions.", "slug": "coding-fallback", "type": "model", "weight": 70}]}]}, "type": "routing-rules"}} When the request is sent Then the response status is 400 Bad Request @@ -216,7 +216,7 @@ Feature: AI Gateway Scenario: Create an AI Gateway routing rule returns "Conflict" response Given operation "CreateAiGatewayRoutingRule" enabled And new "CreateAiGatewayRoutingRule" request - And body with value {"data": {"attributes": {"slug": "coding", "tiers": [{"ordering": "configured", "targets": [{"id": 901, "model": "gpt-5.2-codex", "model_id": 101, "provider": "prod-us", "reasoning_level": "medium", "slug": "coding-fallback", "type": "model", "weight": 70}]}]}, "type": "routing-rules"}} + And body with value {"data": {"attributes": {"slug": "coding", "tiers": [{"classifier": {"confidence_threshold": 0.5, "context": "Requests come from engineers.", "model": "gpt-6-luna", "provider": "openai"}, "ordering": "configured", "targets": [{"default": false, "id": 901, "model": "gpt-5.2-codex", "model_id": 101, "provider": "prod-us", "reasoning_level": "medium", "rubric": "Short factual questions.", "slug": "coding-fallback", "type": "model", "weight": 70}]}]}, "type": "routing-rules"}} When the request is sent Then the response status is 409 Conflict @@ -224,7 +224,7 @@ Feature: AI Gateway Scenario: Create an AI Gateway routing rule returns "Created" response Given operation "CreateAiGatewayRoutingRule" enabled And new "CreateAiGatewayRoutingRule" request - And body with value {"data": {"attributes": {"slug": "coding", "tiers": [{"ordering": "configured", "targets": [{"id": 901, "model": "gpt-5.2-codex", "model_id": 101, "provider": "prod-us", "reasoning_level": "medium", "slug": "coding-fallback", "type": "model", "weight": 70}]}]}, "type": "routing-rules"}} + And body with value {"data": {"attributes": {"slug": "coding", "tiers": [{"classifier": {"confidence_threshold": 0.5, "context": "Requests come from engineers.", "model": "gpt-6-luna", "provider": "openai"}, "ordering": "configured", "targets": [{"default": false, "id": 901, "model": "gpt-5.2-codex", "model_id": 101, "provider": "prod-us", "reasoning_level": "medium", "rubric": "Short factual questions.", "slug": "coding-fallback", "type": "model", "weight": 70}]}]}, "type": "routing-rules"}} When the request is sent Then the response status is 201 Created @@ -815,42 +815,6 @@ Feature: AI Gateway When the request is sent Then the response status is 200 OK - @generated @skip @team:ddoghq/frontier-prd-gateway - Scenario: Replace an AI Gateway routing rule returns "Bad Request" response - Given operation "UpdateAiGatewayRoutingRule" enabled - And new "UpdateAiGatewayRoutingRule" request - And request contains "slug" parameter from "REPLACE.ME" - And body with value {"data": {"attributes": {"tiers": [{"ordering": "configured", "targets": [{"id": 901, "model": "gpt-5.2-codex", "model_id": 101, "provider": "prod-us", "reasoning_level": "medium", "slug": "coding-fallback", "type": "model", "weight": 70}]}]}, "id": "coding", "type": "routing-rules"}} - When the request is sent - Then the response status is 400 Bad Request - - @generated @skip @team:ddoghq/frontier-prd-gateway - Scenario: Replace an AI Gateway routing rule returns "Conflict" response - Given operation "UpdateAiGatewayRoutingRule" enabled - And new "UpdateAiGatewayRoutingRule" request - And request contains "slug" parameter from "REPLACE.ME" - And body with value {"data": {"attributes": {"tiers": [{"ordering": "configured", "targets": [{"id": 901, "model": "gpt-5.2-codex", "model_id": 101, "provider": "prod-us", "reasoning_level": "medium", "slug": "coding-fallback", "type": "model", "weight": 70}]}]}, "id": "coding", "type": "routing-rules"}} - When the request is sent - Then the response status is 409 Conflict - - @generated @skip @team:ddoghq/frontier-prd-gateway - Scenario: Replace an AI Gateway routing rule returns "Not Found" response - Given operation "UpdateAiGatewayRoutingRule" enabled - And new "UpdateAiGatewayRoutingRule" request - And request contains "slug" parameter from "REPLACE.ME" - And body with value {"data": {"attributes": {"tiers": [{"ordering": "configured", "targets": [{"id": 901, "model": "gpt-5.2-codex", "model_id": 101, "provider": "prod-us", "reasoning_level": "medium", "slug": "coding-fallback", "type": "model", "weight": 70}]}]}, "id": "coding", "type": "routing-rules"}} - When the request is sent - Then the response status is 404 Not Found - - @generated @skip @team:ddoghq/frontier-prd-gateway - Scenario: Replace an AI Gateway routing rule returns "OK" response - Given operation "UpdateAiGatewayRoutingRule" enabled - And new "UpdateAiGatewayRoutingRule" request - And request contains "slug" parameter from "REPLACE.ME" - And body with value {"data": {"attributes": {"tiers": [{"ordering": "configured", "targets": [{"id": 901, "model": "gpt-5.2-codex", "model_id": 101, "provider": "prod-us", "reasoning_level": "medium", "slug": "coding-fallback", "type": "model", "weight": 70}]}]}, "id": "coding", "type": "routing-rules"}} - When the request is sent - Then the response status is 200 OK - @generated @skip @team:ddoghq/frontier-prd-gateway Scenario: Reset a budget instance's spend returns "Bad Request" response Given operation "ResetAiGatewayBudgetInstanceSpend" enabled @@ -1072,3 +1036,39 @@ Feature: AI Gateway 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"}} When the request is sent Then the response status is 200 OK + + @generated @skip @team:ddoghq/frontier-prd-gateway + Scenario: Update an AI Gateway routing rule returns "Bad Request" response + Given operation "UpdateAiGatewayRoutingRule" enabled + And new "UpdateAiGatewayRoutingRule" request + And request contains "slug" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"expected_updated_at": "2026-08-24T12:00:00Z", "removed_target_ids": [901], "tiers": [{"classifier": {"confidence_threshold": 0.5, "context": "Requests come from engineers.", "model": "gpt-6-luna", "provider": "openai"}, "ordering": "configured", "targets": [{"default": false, "id": 901, "model": "gpt-5.2-codex", "model_id": 101, "provider": "prod-us", "reasoning_level": "medium", "rubric": "Short factual questions.", "slug": "coding-fallback", "type": "model", "weight": 70}]}]}, "id": "coding", "type": "routing-rules"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:ddoghq/frontier-prd-gateway + Scenario: Update an AI Gateway routing rule returns "Conflict" response + Given operation "UpdateAiGatewayRoutingRule" enabled + And new "UpdateAiGatewayRoutingRule" request + And request contains "slug" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"expected_updated_at": "2026-08-24T12:00:00Z", "removed_target_ids": [901], "tiers": [{"classifier": {"confidence_threshold": 0.5, "context": "Requests come from engineers.", "model": "gpt-6-luna", "provider": "openai"}, "ordering": "configured", "targets": [{"default": false, "id": 901, "model": "gpt-5.2-codex", "model_id": 101, "provider": "prod-us", "reasoning_level": "medium", "rubric": "Short factual questions.", "slug": "coding-fallback", "type": "model", "weight": 70}]}]}, "id": "coding", "type": "routing-rules"}} + When the request is sent + Then the response status is 409 Conflict + + @generated @skip @team:ddoghq/frontier-prd-gateway + Scenario: Update an AI Gateway routing rule returns "Not Found" response + Given operation "UpdateAiGatewayRoutingRule" enabled + And new "UpdateAiGatewayRoutingRule" request + And request contains "slug" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"expected_updated_at": "2026-08-24T12:00:00Z", "removed_target_ids": [901], "tiers": [{"classifier": {"confidence_threshold": 0.5, "context": "Requests come from engineers.", "model": "gpt-6-luna", "provider": "openai"}, "ordering": "configured", "targets": [{"default": false, "id": 901, "model": "gpt-5.2-codex", "model_id": 101, "provider": "prod-us", "reasoning_level": "medium", "rubric": "Short factual questions.", "slug": "coding-fallback", "type": "model", "weight": 70}]}]}, "id": "coding", "type": "routing-rules"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:ddoghq/frontier-prd-gateway + Scenario: Update an AI Gateway routing rule returns "OK" response + Given operation "UpdateAiGatewayRoutingRule" enabled + And new "UpdateAiGatewayRoutingRule" request + And request contains "slug" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"expected_updated_at": "2026-08-24T12:00:00Z", "removed_target_ids": [901], "tiers": [{"classifier": {"confidence_threshold": 0.5, "context": "Requests come from engineers.", "model": "gpt-6-luna", "provider": "openai"}, "ordering": "configured", "targets": [{"default": false, "id": 901, "model": "gpt-5.2-codex", "model_id": 101, "provider": "prod-us", "reasoning_level": "medium", "rubric": "Short factual questions.", "slug": "coding-fallback", "type": "model", "weight": 70}]}]}, "id": "coding", "type": "routing-rules"}} + When the request is sent + Then the response status is 200 OK