diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index d301c22ee3b..11e6299128f 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -231,6 +231,15 @@ components: schema: maxLength: 256 type: string + AiGatewayModelCanonicalIDQuery: + description: Canonical model identifier. It can contain `/`, such as `openai/gpt-4o`. + example: openai/gpt-4o + in: query + name: canonical + required: true + schema: + maxLength: 256 + type: string AiGatewayModelGroupID: description: Model group ID, or "default" for the explicit organization-wide access policy. example: "7" @@ -241331,6 +241340,170 @@ paths: x-unstable: |- **Note**: This endpoint is in Preview and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/providers/{provider_id}/model-pricing: + delete: + description: >- + Clear a provider model's pricing override, naming the model in the `canonical` query parameter. Unlike the endpoint that takes the canonical ID in the path, this one accepts canonical IDs that contain `/`. Requires `ai_gateway_config_write` and provider Edit. Models and pricing inherit provider access. + operationId: DeleteAIGatewayModelPricingByCanonical + parameters: + - $ref: "#/components/parameters/AiGatewayProviderIDForModels" + - $ref: "#/components/parameters/AiGatewayModelCanonicalIDQuery" + responses: + "204": + description: No Content + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + $ref: "#/components/responses/ForbiddenResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - ai_gateway_config_write + summary: Delete a model pricing override by canonical ID + tags: + - AI Gateway + x-permission: + operator: OR + permissions: + - ai_gateway_config_write + x-unstable: |- + **Note**: This endpoint is in Preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + get: + description: >- + Get a provider model's pricing override and effective pricing source, naming the model in the `canonical` query parameter. Unlike the endpoint that takes the canonical ID in the path, this one accepts canonical IDs that contain `/`. Requires `ai_gateway_config_read` and provider View. Catalog and pricing metadata inherit provider access. Direct reads of hidden resources return 404. + operationId: GetAIGatewayModelPricingByCanonical + parameters: + - $ref: "#/components/parameters/AiGatewayProviderIDForModels" + - $ref: "#/components/parameters/AiGatewayModelCanonicalIDQuery" + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + effective_source: model_override + pricing_config: + rates: + cache_read_cost_per_mtok: 0.02 + cache_write_cost_per_mtok: 0.25 + non_cached_input_cost_per_mtok: 0.2 + output_cost_per_mtok: 1.0 + source: + type: custom + version: 1 + id: 7/openai/gpt-4o + type: model-pricing + schema: + $ref: "#/components/schemas/AiGatewayModelPricingResponse" + description: OK + "400": + $ref: "#/components/responses/BadRequestResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - ai_gateway_config_read + summary: Get a model pricing override by canonical ID + tags: + - AI Gateway + x-permission: + operator: OR + permissions: + - ai_gateway_config_read + x-unstable: |- + **Note**: This endpoint is in Preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + put: + description: >- + Set a provider model's pricing override, naming the model in the `canonical` query parameter. Unlike the endpoint that takes the canonical ID in the path, this one accepts canonical IDs that contain `/`. Requires `ai_gateway_config_write` and provider Edit. Models and pricing inherit provider access. + operationId: UpdateAIGatewayModelPricingByCanonical + parameters: + - $ref: "#/components/parameters/AiGatewayProviderIDForModels" + - $ref: "#/components/parameters/AiGatewayModelCanonicalIDQuery" + requestBody: + content: + application/json: + examples: + custom: + summary: Set custom pricing + value: + data: + attributes: + pricing_config: + rates: + cache_read_cost_per_mtok: 0.02 + cache_write_cost_per_mtok: 0.25 + non_cached_input_cost_per_mtok: 0.2 + output_cost_per_mtok: 1.0 + source: + type: custom + version: 1 + id: 7/openai/gpt-4o + type: model-pricing + schema: + $ref: "#/components/schemas/AiGatewayModelPricingRequest" + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + effective_source: model_override + pricing_config: + rates: + cache_read_cost_per_mtok: 0.02 + cache_write_cost_per_mtok: 0.25 + non_cached_input_cost_per_mtok: 0.2 + output_cost_per_mtok: 1.0 + source: + type: custom + version: 1 + id: 7/openai/gpt-4o + type: model-pricing + schema: + $ref: "#/components/schemas/AiGatewayModelPricingResponse" + description: OK + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + $ref: "#/components/responses/ForbiddenResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - ai_gateway_config_write + summary: Set a model pricing override by canonical ID + tags: + - AI Gateway + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - ai_gateway_config_write + x-unstable: |- + **Note**: This endpoint is in Preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/providers/{provider_id}/models: get: description: >- @@ -241589,7 +241762,7 @@ paths: /api/v2/providers/{provider_id}/models/{canonical}/pricing: delete: description: >- - Clear a custom provider model's pricing override. Requires `ai_gateway_config_write` and provider Edit. Models and pricing inherit provider access. + Clear a custom provider model's pricing override. A canonical ID that contains `/` can't be sent in the path; use the `/api/v2/providers/{provider_id}/model-pricing` endpoint with the `canonical` query parameter instead. Requires `ai_gateway_config_write` and provider Edit. Models and pricing inherit provider access. operationId: DeleteAiGatewayModelPricing parameters: - $ref: "#/components/parameters/AiGatewayProviderIDForModels" @@ -241622,7 +241795,7 @@ paths: If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). get: description: >- - Get a custom provider model's pricing override and effective pricing source. Requires `ai_gateway_config_read` and provider View. Catalog and pricing metadata inherit provider access. Lists omit hidden entries; direct reads of hidden resources return 404. + Get a custom provider model's pricing override and effective pricing source. A canonical ID that contains `/` can't be sent in the path; use the `/api/v2/providers/{provider_id}/model-pricing` endpoint with the `canonical` query parameter instead. Requires `ai_gateway_config_read` and provider View. Catalog and pricing metadata inherit provider access. Lists omit hidden entries; direct reads of hidden resources return 404. operationId: GetAiGatewayModelPricing parameters: - $ref: "#/components/parameters/AiGatewayProviderIDForModels" @@ -241674,7 +241847,7 @@ paths: If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). put: description: >- - Set a custom provider model's pricing override. Requires `ai_gateway_config_write` and provider Edit. Models and pricing inherit provider access. + Set a custom provider model's pricing override. A canonical ID that contains `/` can't be sent in the path; use the `/api/v2/providers/{provider_id}/model-pricing` endpoint with the `canonical` query parameter instead. Requires `ai_gateway_config_write` and provider Edit. Models and pricing inherit provider access. operationId: UpdateAiGatewayModelPricing parameters: - $ref: "#/components/parameters/AiGatewayProviderIDForModels" diff --git a/examples/v2/ai-gateway/DeleteAIGatewayModelPricingByCanonical.java b/examples/v2/ai-gateway/DeleteAIGatewayModelPricingByCanonical.java new file mode 100644 index 00000000000..73d472c6ddd --- /dev/null +++ b/examples/v2/ai-gateway/DeleteAIGatewayModelPricingByCanonical.java @@ -0,0 +1,25 @@ +// Delete a model pricing override by canonical ID returns "No Content" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.AiGatewayApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN")); + defaultClient.setUnstableOperationEnabled("v2.deleteAIGatewayModelPricingByCanonical", true); + AiGatewayApi apiInstance = new AiGatewayApi(defaultClient); + + try { + apiInstance.deleteAIGatewayModelPricingByCanonical(42L, "openai/gpt-4o"); + } catch (ApiException e) { + System.err.println( + "Exception when calling AiGatewayApi#deleteAIGatewayModelPricingByCanonical"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/ai-gateway/GetAIGatewayModelPricingByCanonical.java b/examples/v2/ai-gateway/GetAIGatewayModelPricingByCanonical.java new file mode 100644 index 00000000000..336838b4435 --- /dev/null +++ b/examples/v2/ai-gateway/GetAIGatewayModelPricingByCanonical.java @@ -0,0 +1,27 @@ +// Get a model pricing override by canonical ID returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.AiGatewayApi; +import com.datadog.api.client.v2.model.AiGatewayModelPricingResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN")); + defaultClient.setUnstableOperationEnabled("v2.getAIGatewayModelPricingByCanonical", true); + AiGatewayApi apiInstance = new AiGatewayApi(defaultClient); + + try { + AiGatewayModelPricingResponse result = + apiInstance.getAIGatewayModelPricingByCanonical(42L, "openai/gpt-4o"); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AiGatewayApi#getAIGatewayModelPricingByCanonical"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/ai-gateway/UpdateAIGatewayModelPricingByCanonical.java b/examples/v2/ai-gateway/UpdateAIGatewayModelPricingByCanonical.java new file mode 100644 index 00000000000..b2c6bc59089 --- /dev/null +++ b/examples/v2/ai-gateway/UpdateAIGatewayModelPricingByCanonical.java @@ -0,0 +1,70 @@ +// Set a model pricing override by canonical ID returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.AiGatewayApi; +import com.datadog.api.client.v2.model.AiGatewayModelPricingCustomRequestConfig; +import com.datadog.api.client.v2.model.AiGatewayModelPricingCustomRequestSource; +import com.datadog.api.client.v2.model.AiGatewayModelPricingCustomRequestSourceType; +import com.datadog.api.client.v2.model.AiGatewayModelPricingRates; +import com.datadog.api.client.v2.model.AiGatewayModelPricingRequest; +import com.datadog.api.client.v2.model.AiGatewayModelPricingRequestAttributes; +import com.datadog.api.client.v2.model.AiGatewayModelPricingRequestConfig; +import com.datadog.api.client.v2.model.AiGatewayModelPricingRequestData; +import com.datadog.api.client.v2.model.AiGatewayModelPricingRequiredRates; +import com.datadog.api.client.v2.model.AiGatewayModelPricingResponse; +import com.datadog.api.client.v2.model.AiGatewayModelPricingTier; +import com.datadog.api.client.v2.model.AiGatewayModelPricingType; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN")); + defaultClient.setUnstableOperationEnabled("v2.updateAIGatewayModelPricingByCanonical", true); + AiGatewayApi apiInstance = new AiGatewayApi(defaultClient); + + AiGatewayModelPricingRequest body = + new AiGatewayModelPricingRequest() + .data( + new AiGatewayModelPricingRequestData() + .attributes( + new AiGatewayModelPricingRequestAttributes() + .pricingConfig( + new AiGatewayModelPricingRequestConfig( + new AiGatewayModelPricingCustomRequestConfig() + .rates(new AiGatewayModelPricingRequiredRates()) + .source( + new AiGatewayModelPricingCustomRequestSource() + .type( + AiGatewayModelPricingCustomRequestSourceType + .CUSTOM)) + .tiers( + Collections.singletonList( + new AiGatewayModelPricingTier() + .contextMinTokens(200000L) + .rates( + new AiGatewayModelPricingRates() + .cacheReadCostPerMtok(0.6) + .cacheWriteCostPerMtok(7.5) + .nonCachedInputCostPerMtok(6.0) + .outputCostPerMtok(22.5)) + .serviceTier("priority"))) + .version(1L)))) + .id("gpt-4o") + .type(AiGatewayModelPricingType.MODEL_PRICING)); + + try { + AiGatewayModelPricingResponse result = + apiInstance.updateAIGatewayModelPricingByCanonical(42L, "openai/gpt-4o", body); + System.out.println(result); + } catch (ApiException e) { + System.err.println( + "Exception when calling AiGatewayApi#updateAIGatewayModelPricingByCanonical"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/datadog/api/client/ApiClient.java b/src/main/java/com/datadog/api/client/ApiClient.java index 3563c18ab25..e1726d750e5 100644 --- a/src/main/java/com/datadog/api/client/ApiClient.java +++ b/src/main/java/com/datadog/api/client/ApiClient.java @@ -1171,6 +1171,7 @@ public class ApiClient { put("v2.deleteAiGatewayModel", false); put("v2.deleteAiGatewayModelGroup", false); put("v2.deleteAiGatewayModelPricing", false); + put("v2.deleteAIGatewayModelPricingByCanonical", false); put("v2.deleteAiGatewayPolicy", false); put("v2.deleteAiGatewayProvider", false); put("v2.deleteAiGatewayRateLimit", false); @@ -1182,6 +1183,7 @@ public class ApiClient { put("v2.getAiGatewayGovernance", false); put("v2.getAiGatewayModelGroup", false); put("v2.getAiGatewayModelPricing", false); + put("v2.getAIGatewayModelPricingByCanonical", false); put("v2.getAiGatewayPolicy", false); put("v2.getAiGatewayProvider", false); put("v2.getAiGatewayRateLimit", false); @@ -1209,6 +1211,7 @@ public class ApiClient { put("v2.updateAiGatewayModel", false); put("v2.updateAiGatewayModelGroup", false); put("v2.updateAiGatewayModelPricing", false); + put("v2.updateAIGatewayModelPricingByCanonical", false); put("v2.updateAiGatewayProvider", false); put("v2.updateAiGatewayRateLimit", false); put("v2.updateAiGatewayRoutingRule", false); diff --git a/src/main/java/com/datadog/api/client/v2/api/AiGatewayApi.java b/src/main/java/com/datadog/api/client/v2/api/AiGatewayApi.java index 6c46a7bc9f5..72f83e33d6b 100644 --- a/src/main/java/com/datadog/api/client/v2/api/AiGatewayApi.java +++ b/src/main/java/com/datadog/api/client/v2/api/AiGatewayApi.java @@ -2115,8 +2115,10 @@ public CompletableFuture deleteAiGatewayModelPricingAsync( } /** - * Clear a custom provider model's pricing override. Requires ai_gateway_config_write - * and provider Edit. Models and pricing inherit provider access. + * Clear a custom provider model's pricing override. A canonical ID that contains / + * can't be sent in the path; use the /api/v2/providers/{provider_id}/model-pricing + * endpoint with the canonical query parameter instead. Requires + * ai_gateway_config_write and provider Edit. Models and pricing inherit provider access. * * @param providerId Provider ID. (required) * @param canonical Canonical model identifier. (required) @@ -2266,6 +2268,202 @@ public CompletableFuture> deleteAiGatewayModelPricingWithHttpI null); } + /** + * Delete a model pricing override by canonical ID. + * + *

See {@link #deleteAIGatewayModelPricingByCanonicalWithHttpInfo}. + * + * @param providerId Provider ID. (required) + * @param canonical Canonical model identifier. It can contain /, such as + * openai/gpt-4o. (required) + * @throws ApiException if fails to make API call + */ + public void deleteAIGatewayModelPricingByCanonical(Long providerId, String canonical) + throws ApiException { + deleteAIGatewayModelPricingByCanonicalWithHttpInfo(providerId, canonical); + } + + /** + * Delete a model pricing override by canonical ID. + * + *

See {@link #deleteAIGatewayModelPricingByCanonicalWithHttpInfoAsync}. + * + * @param providerId Provider ID. (required) + * @param canonical Canonical model identifier. It can contain /, such as + * openai/gpt-4o. (required) + * @return CompletableFuture + */ + public CompletableFuture deleteAIGatewayModelPricingByCanonicalAsync( + Long providerId, String canonical) { + return deleteAIGatewayModelPricingByCanonicalWithHttpInfoAsync(providerId, canonical) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Clear a provider model's pricing override, naming the model in the canonical query + * parameter. Unlike the endpoint that takes the canonical ID in the path, this one accepts + * canonical IDs that contain /. Requires ai_gateway_config_write and + * provider Edit. Models and pricing inherit provider access. + * + * @param providerId Provider ID. (required) + * @param canonical Canonical model identifier. It can contain /, such as + * openai/gpt-4o. (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
204 No Content -
400 Bad Request -
403 Forbidden -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse deleteAIGatewayModelPricingByCanonicalWithHttpInfo( + Long providerId, String canonical) throws ApiException { + // Check if unstable operation is enabled + String operationId = "deleteAIGatewayModelPricingByCanonical"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = null; + + // verify the required parameter 'providerId' is set + if (providerId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'providerId' when calling" + + " deleteAIGatewayModelPricingByCanonical"); + } + + // verify the required parameter 'canonical' is set + if (canonical == null) { + throw new ApiException( + 400, + "Missing the required parameter 'canonical' when calling" + + " deleteAIGatewayModelPricingByCanonical"); + } + // create path and map variables + String localVarPath = + "/api/v2/providers/{provider_id}/model-pricing" + .replaceAll( + "\\{" + "provider_id" + "\\}", apiClient.escapeString(providerId.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "canonical", canonical)); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.AiGatewayApi.deleteAIGatewayModelPricingByCanonical", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"*/*"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "DELETE", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + null); + } + + /** + * Delete a model pricing override by canonical ID. + * + *

See {@link #deleteAIGatewayModelPricingByCanonicalWithHttpInfo}. + * + * @param providerId Provider ID. (required) + * @param canonical Canonical model identifier. It can contain /, such as + * openai/gpt-4o. (required) + * @return CompletableFuture<ApiResponse<Void>> + */ + public CompletableFuture> + deleteAIGatewayModelPricingByCanonicalWithHttpInfoAsync(Long providerId, String canonical) { + // Check if unstable operation is enabled + String operationId = "deleteAIGatewayModelPricingByCanonical"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = null; + + // verify the required parameter 'providerId' is set + if (providerId == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'providerId' when calling" + + " deleteAIGatewayModelPricingByCanonical")); + return result; + } + + // verify the required parameter 'canonical' is set + if (canonical == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'canonical' when calling" + + " deleteAIGatewayModelPricingByCanonical")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/providers/{provider_id}/model-pricing" + .replaceAll( + "\\{" + "provider_id" + "\\}", apiClient.escapeString(providerId.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "canonical", canonical)); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.AiGatewayApi.deleteAIGatewayModelPricingByCanonical", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"*/*"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "DELETE", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + null); + } + /** Manage optional parameters to deleteAiGatewayPolicy. */ public static class DeleteAiGatewayPolicyOptionalParameters { private UUID userId; @@ -4101,9 +4299,12 @@ public CompletableFuture getAiGatewayModelPricing } /** - * Get a custom provider model's pricing override and effective pricing source. Requires - * ai_gateway_config_read and provider View. Catalog and pricing metadata inherit provider - * access. Lists omit hidden entries; direct reads of hidden resources return 404. + * Get a custom provider model's pricing override and effective pricing source. A canonical ID + * that contains / can't be sent in the path; use the + * /api/v2/providers/{provider_id}/model-pricing endpoint with the canonical + * query parameter instead. Requires ai_gateway_config_read and provider View. + * Catalog and pricing metadata inherit provider access. Lists omit hidden entries; direct reads + * of hidden resources return 404. * * @param providerId Provider ID. (required) * @param canonical Canonical model identifier. (required) @@ -4252,6 +4453,207 @@ public ApiResponse getAiGatewayModelPricingWithHt new GenericType() {}); } + /** + * Get a model pricing override by canonical ID. + * + *

See {@link #getAIGatewayModelPricingByCanonicalWithHttpInfo}. + * + * @param providerId Provider ID. (required) + * @param canonical Canonical model identifier. It can contain /, such as + * openai/gpt-4o. (required) + * @return AiGatewayModelPricingResponse + * @throws ApiException if fails to make API call + */ + public AiGatewayModelPricingResponse getAIGatewayModelPricingByCanonical( + Long providerId, String canonical) throws ApiException { + return getAIGatewayModelPricingByCanonicalWithHttpInfo(providerId, canonical).getData(); + } + + /** + * Get a model pricing override by canonical ID. + * + *

See {@link #getAIGatewayModelPricingByCanonicalWithHttpInfoAsync}. + * + * @param providerId Provider ID. (required) + * @param canonical Canonical model identifier. It can contain /, such as + * openai/gpt-4o. (required) + * @return CompletableFuture<AiGatewayModelPricingResponse> + */ + public CompletableFuture getAIGatewayModelPricingByCanonicalAsync( + Long providerId, String canonical) { + return getAIGatewayModelPricingByCanonicalWithHttpInfoAsync(providerId, canonical) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Get a provider model's pricing override and effective pricing source, naming the model in the + * canonical query parameter. Unlike the endpoint that takes the canonical ID in the + * path, this one accepts canonical IDs that contain /. Requires + * ai_gateway_config_read and provider View. Catalog and pricing metadata inherit provider + * access. Direct reads of hidden resources return 404. + * + * @param providerId Provider ID. (required) + * @param canonical Canonical model identifier. It can contain /, such as + * openai/gpt-4o. (required) + * @return ApiResponse<AiGatewayModelPricingResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse getAIGatewayModelPricingByCanonicalWithHttpInfo( + Long providerId, String canonical) throws ApiException { + // Check if unstable operation is enabled + String operationId = "getAIGatewayModelPricingByCanonical"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = null; + + // verify the required parameter 'providerId' is set + if (providerId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'providerId' when calling" + + " getAIGatewayModelPricingByCanonical"); + } + + // verify the required parameter 'canonical' is set + if (canonical == null) { + throw new ApiException( + 400, + "Missing the required parameter 'canonical' when calling" + + " getAIGatewayModelPricingByCanonical"); + } + // create path and map variables + String localVarPath = + "/api/v2/providers/{provider_id}/model-pricing" + .replaceAll( + "\\{" + "provider_id" + "\\}", apiClient.escapeString(providerId.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "canonical", canonical)); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.AiGatewayApi.getAIGatewayModelPricingByCanonical", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Get a model pricing override by canonical ID. + * + *

See {@link #getAIGatewayModelPricingByCanonicalWithHttpInfo}. + * + * @param providerId Provider ID. (required) + * @param canonical Canonical model identifier. It can contain /, such as + * openai/gpt-4o. (required) + * @return CompletableFuture<ApiResponse<AiGatewayModelPricingResponse>> + */ + public CompletableFuture> + getAIGatewayModelPricingByCanonicalWithHttpInfoAsync(Long providerId, String canonical) { + // Check if unstable operation is enabled + String operationId = "getAIGatewayModelPricingByCanonical"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = null; + + // verify the required parameter 'providerId' is set + if (providerId == null) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'providerId' when calling" + + " getAIGatewayModelPricingByCanonical")); + return result; + } + + // verify the required parameter 'canonical' is set + if (canonical == null) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'canonical' when calling" + + " getAIGatewayModelPricingByCanonical")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/providers/{provider_id}/model-pricing" + .replaceAll( + "\\{" + "provider_id" + "\\}", apiClient.escapeString(providerId.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "canonical", canonical)); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.AiGatewayApi.getAIGatewayModelPricingByCanonical", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + /** Manage optional parameters to getAiGatewayPolicy. */ public static class GetAiGatewayPolicyOptionalParameters { private UUID userId; @@ -9128,8 +9530,10 @@ public CompletableFuture updateAiGatewayModelPric } /** - * Set a custom provider model's pricing override. Requires ai_gateway_config_write - * and provider Edit. Models and pricing inherit provider access. + * Set a custom provider model's pricing override. A canonical ID that contains / + * can't be sent in the path; use the /api/v2/providers/{provider_id}/model-pricing + * endpoint with the canonical query parameter instead. Requires + * ai_gateway_config_write and provider Edit. Models and pricing inherit provider access. * * @param providerId Provider ID. (required) * @param canonical Canonical model identifier. (required) @@ -9303,6 +9707,236 @@ public ApiResponse updateAiGatewayModelPricingWit new GenericType() {}); } + /** + * Set a model pricing override by canonical ID. + * + *

See {@link #updateAIGatewayModelPricingByCanonicalWithHttpInfo}. + * + * @param providerId Provider ID. (required) + * @param canonical Canonical model identifier. It can contain /, such as + * openai/gpt-4o. (required) + * @param body (required) + * @return AiGatewayModelPricingResponse + * @throws ApiException if fails to make API call + */ + public AiGatewayModelPricingResponse updateAIGatewayModelPricingByCanonical( + Long providerId, String canonical, AiGatewayModelPricingRequest body) throws ApiException { + return updateAIGatewayModelPricingByCanonicalWithHttpInfo(providerId, canonical, body) + .getData(); + } + + /** + * Set a model pricing override by canonical ID. + * + *

See {@link #updateAIGatewayModelPricingByCanonicalWithHttpInfoAsync}. + * + * @param providerId Provider ID. (required) + * @param canonical Canonical model identifier. It can contain /, such as + * openai/gpt-4o. (required) + * @param body (required) + * @return CompletableFuture<AiGatewayModelPricingResponse> + */ + public CompletableFuture + updateAIGatewayModelPricingByCanonicalAsync( + Long providerId, String canonical, AiGatewayModelPricingRequest body) { + return updateAIGatewayModelPricingByCanonicalWithHttpInfoAsync(providerId, canonical, body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Set a provider model's pricing override, naming the model in the canonical query + * parameter. Unlike the endpoint that takes the canonical ID in the path, this one accepts + * canonical IDs that contain /. Requires ai_gateway_config_write and + * provider Edit. Models and pricing inherit provider access. + * + * @param providerId Provider ID. (required) + * @param canonical Canonical model identifier. It can contain /, such as + * openai/gpt-4o. (required) + * @param body (required) + * @return ApiResponse<AiGatewayModelPricingResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse + updateAIGatewayModelPricingByCanonicalWithHttpInfo( + Long providerId, String canonical, AiGatewayModelPricingRequest body) + throws ApiException { + // Check if unstable operation is enabled + String operationId = "updateAIGatewayModelPricingByCanonical"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = body; + + // verify the required parameter 'providerId' is set + if (providerId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'providerId' when calling" + + " updateAIGatewayModelPricingByCanonical"); + } + + // verify the required parameter 'canonical' is set + if (canonical == null) { + throw new ApiException( + 400, + "Missing the required parameter 'canonical' when calling" + + " updateAIGatewayModelPricingByCanonical"); + } + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, + "Missing the required parameter 'body' when calling" + + " updateAIGatewayModelPricingByCanonical"); + } + // create path and map variables + String localVarPath = + "/api/v2/providers/{provider_id}/model-pricing" + .replaceAll( + "\\{" + "provider_id" + "\\}", apiClient.escapeString(providerId.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "canonical", canonical)); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.AiGatewayApi.updateAIGatewayModelPricingByCanonical", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "PUT", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Set a model pricing override by canonical ID. + * + *

See {@link #updateAIGatewayModelPricingByCanonicalWithHttpInfo}. + * + * @param providerId Provider ID. (required) + * @param canonical Canonical model identifier. It can contain /, such as + * openai/gpt-4o. (required) + * @param body (required) + * @return CompletableFuture<ApiResponse<AiGatewayModelPricingResponse>> + */ + public CompletableFuture> + updateAIGatewayModelPricingByCanonicalWithHttpInfoAsync( + Long providerId, String canonical, AiGatewayModelPricingRequest body) { + // Check if unstable operation is enabled + String operationId = "updateAIGatewayModelPricingByCanonical"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = body; + + // verify the required parameter 'providerId' is set + if (providerId == null) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'providerId' when calling" + + " updateAIGatewayModelPricingByCanonical")); + return result; + } + + // verify the required parameter 'canonical' is set + if (canonical == null) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'canonical' when calling" + + " updateAIGatewayModelPricingByCanonical")); + return result; + } + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'body' when calling" + + " updateAIGatewayModelPricingByCanonical")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/providers/{provider_id}/model-pricing" + .replaceAll( + "\\{" + "provider_id" + "\\}", apiClient.escapeString(providerId.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "canonical", canonical)); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.AiGatewayApi.updateAIGatewayModelPricingByCanonical", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "PUT", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + /** * Update an AI Gateway provider. * diff --git a/src/test/resources/com/datadog/api/client/v2/api/ai_gateway.feature b/src/test/resources/com/datadog/api/client/v2/api/ai_gateway.feature index aae4522d73d..278e9ee79dd 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/ai_gateway.feature +++ b/src/test/resources/com/datadog/api/client/v2/api/ai_gateway.feature @@ -262,6 +262,33 @@ Feature: AI Gateway When the request is sent Then the response status is 404 Not Found + @generated @skip @team:ddoghq/frontier-prd-gateway + Scenario: Delete a model pricing override by canonical ID returns "Bad Request" response + Given operation "DeleteAIGatewayModelPricingByCanonical" enabled + And new "DeleteAIGatewayModelPricingByCanonical" request + And request contains "provider_id" parameter from "REPLACE.ME" + And request contains "canonical" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:ddoghq/frontier-prd-gateway + Scenario: Delete a model pricing override by canonical ID returns "No Content" response + Given operation "DeleteAIGatewayModelPricingByCanonical" enabled + And new "DeleteAIGatewayModelPricingByCanonical" request + And request contains "provider_id" parameter from "REPLACE.ME" + And request contains "canonical" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:ddoghq/frontier-prd-gateway + Scenario: Delete a model pricing override by canonical ID returns "Not Found" response + Given operation "DeleteAIGatewayModelPricingByCanonical" enabled + And new "DeleteAIGatewayModelPricingByCanonical" request + And request contains "provider_id" parameter from "REPLACE.ME" + And request contains "canonical" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + @generated @skip @team:ddoghq/frontier-prd-gateway Scenario: Delete a model pricing override returns "Bad Request" response Given operation "DeleteAiGatewayModelPricing" enabled @@ -435,6 +462,33 @@ Feature: AI Gateway When the request is sent Then the response status is 200 OK + @generated @skip @team:ddoghq/frontier-prd-gateway + Scenario: Get a model pricing override by canonical ID returns "Bad Request" response + Given operation "GetAIGatewayModelPricingByCanonical" enabled + And new "GetAIGatewayModelPricingByCanonical" request + And request contains "provider_id" parameter from "REPLACE.ME" + And request contains "canonical" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:ddoghq/frontier-prd-gateway + Scenario: Get a model pricing override by canonical ID returns "Not Found" response + Given operation "GetAIGatewayModelPricingByCanonical" enabled + And new "GetAIGatewayModelPricingByCanonical" request + And request contains "provider_id" parameter from "REPLACE.ME" + And request contains "canonical" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:ddoghq/frontier-prd-gateway + Scenario: Get a model pricing override by canonical ID returns "OK" response + Given operation "GetAIGatewayModelPricingByCanonical" enabled + And new "GetAIGatewayModelPricingByCanonical" request + And request contains "provider_id" parameter from "REPLACE.ME" + And request contains "canonical" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:ddoghq/frontier-prd-gateway Scenario: Get a model pricing override returns "Bad Request" response Given operation "GetAiGatewayModelPricing" enabled @@ -904,6 +958,36 @@ Feature: AI Gateway When the request is sent Then the response status is 200 OK + @generated @skip @team:ddoghq/frontier-prd-gateway + Scenario: Set a model pricing override by canonical ID returns "Bad Request" response + Given operation "UpdateAIGatewayModelPricingByCanonical" enabled + And new "UpdateAIGatewayModelPricingByCanonical" request + And request contains "provider_id" parameter from "REPLACE.ME" + And request contains "canonical" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"pricing_config": {"rates": {"cache_read_cost_per_mtok": 0.0, "cache_write_cost_per_mtok": 0.0, "non_cached_input_cost_per_mtok": 0.0, "output_cost_per_mtok": 0.0}, "source": {"type": "custom"}, "tiers": [{"context_min_tokens": 200000, "rates": {"cache_read_cost_per_mtok": 0.6, "cache_write_cost_per_mtok": 7.5, "non_cached_input_cost_per_mtok": 6.0, "output_cost_per_mtok": 22.5}, "service_tier": "priority"}], "version": 1}}, "id": "gpt-4o", "type": "model-pricing"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:ddoghq/frontier-prd-gateway + Scenario: Set a model pricing override by canonical ID returns "Not Found" response + Given operation "UpdateAIGatewayModelPricingByCanonical" enabled + And new "UpdateAIGatewayModelPricingByCanonical" request + And request contains "provider_id" parameter from "REPLACE.ME" + And request contains "canonical" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"pricing_config": {"rates": {"cache_read_cost_per_mtok": 0.0, "cache_write_cost_per_mtok": 0.0, "non_cached_input_cost_per_mtok": 0.0, "output_cost_per_mtok": 0.0}, "source": {"type": "custom"}, "tiers": [{"context_min_tokens": 200000, "rates": {"cache_read_cost_per_mtok": 0.6, "cache_write_cost_per_mtok": 7.5, "non_cached_input_cost_per_mtok": 6.0, "output_cost_per_mtok": 22.5}, "service_tier": "priority"}], "version": 1}}, "id": "gpt-4o", "type": "model-pricing"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:ddoghq/frontier-prd-gateway + Scenario: Set a model pricing override by canonical ID returns "OK" response + Given operation "UpdateAIGatewayModelPricingByCanonical" enabled + And new "UpdateAIGatewayModelPricingByCanonical" request + And request contains "provider_id" parameter from "REPLACE.ME" + And request contains "canonical" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"pricing_config": {"rates": {"cache_read_cost_per_mtok": 0.0, "cache_write_cost_per_mtok": 0.0, "non_cached_input_cost_per_mtok": 0.0, "output_cost_per_mtok": 0.0}, "source": {"type": "custom"}, "tiers": [{"context_min_tokens": 200000, "rates": {"cache_read_cost_per_mtok": 0.6, "cache_write_cost_per_mtok": 7.5, "non_cached_input_cost_per_mtok": 6.0, "output_cost_per_mtok": 22.5}, "service_tier": "priority"}], "version": 1}}, "id": "gpt-4o", "type": "model-pricing"}} + When the request is sent + Then the response status is 200 OK + @generated @skip @team:ddoghq/frontier-prd-gateway Scenario: Set a model pricing override returns "Bad Request" response Given operation "UpdateAiGatewayModelPricing" enabled diff --git a/src/test/resources/com/datadog/api/client/v2/api/undo.json b/src/test/resources/com/datadog/api/client/v2/api/undo.json index 8863997ec51..6371f7ac7e8 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/undo.json +++ b/src/test/resources/com/datadog/api/client/v2/api/undo.json @@ -3574,6 +3574,12 @@ "type": "idempotent" } }, + "DeleteAIGatewayModelPricingByCanonical": { + "tag": "AI Gateway", + "undo": { + "type": "idempotent" + } + }, "DeleteAPIKey": { "tag": "Key Management", "undo": { @@ -5227,6 +5233,12 @@ "type": "safe" } }, + "GetAIGatewayModelPricingByCanonical": { + "tag": "AI Gateway", + "undo": { + "type": "safe" + } + }, "GetAPIKey": { "tag": "Key Management", "undo": { @@ -10891,6 +10903,12 @@ "type": "idempotent" } }, + "UpdateAIGatewayModelPricingByCanonical": { + "tag": "AI Gateway", + "undo": { + "type": "idempotent" + } + }, "UpdateAPIKey": { "tag": "Key Management", "undo": {