---
title: "Create an AI Gateway budget"
method: POST
path: "/api/v2/budgets"
tags: ["AI Gateway"]
---

# Create an AI Gateway budget

`POST /api/v2/budgets`

## Request

- Base URL: `https://api.datadoghq.com`
- URL: `https://api.datadoghq.com/api/v2/budgets`
- Auth: one of:
  - API key in header `DD-API-KEY` and API key in header `DD-APPLICATION-KEY`
  - OAuth 2
    - Authorization code: `/oauth2/v1/authorize`
    - Token URL: `/oauth2/v1/token` scopes: `ai_gateway_config_write`
- TypeScript: <https://skmtc.dev/datadog/apis/datadog-api-v2-collection/docs/api/v2/budgets/post.ts> (a function with typed inputs; its response is checked against the schema)

Create a spend budget. Scope tags may include provider, model, and custom dimensions.
Reserved metadata keys are rejected.

## Request body

- AiGatewayBudgetCreateRequest: Request to create an AI Gateway budget.
  - `data` AiGatewayBudgetCreateData, required: Data used to create an AI Gateway budget.
    - `attributes` AiGatewayBudgetCreateAttributes, required: Attributes used to create an AI Gateway budget.
      - `capacity_microcents` integer, required: Budget capacity in microcents.
      - `enforcement` 'BLOCK' | 'NOTIFY', required: Action taken when spend exceeds the budget.
      - `name` string, required: Human-readable resource name.
      - `selector` AiGatewayBudgetSelectorEntry[], nullable: Dimension rules for a template budget. A nonempty selector creates independent counters for matched instances. Omit or pass an empty selector for a legacy fixed-scope budget.
        - `dim` string, required: Dimension to match: user_id, team_id, model, provider, or tag:<key>. Reserved metadata tag keys are rejected.
        - `per_value` boolean, required: Separate counters by the matched value when true. Otherwise, pool spend within the other separated dimensions.
        - `values` string[]: Allowed dimension values. Omit to match any value, including an absent dimension. An explicit list must contain at least one value.
      - `tags` AiGatewayBudgetTags: Request tags that must match for the budget to apply.
      - `team_id` string, uuid: Optional Datadog Team scope.
      - `track_existing` boolean: Initialize current-period spend from historical priced LLM Observability spans. Defaults to false. Unsupported for template budgets; failures can be retried with an update.
      - `user_id` string, uuid: Optional user scope.
      - `warning_threshold` number, double: Fraction of capacity at which to issue a warning.
      - `window_policy` 'DAILY' | 'WEEKLY' | 'MONTHLY', required: UTC accounting period for a budget.
    - `type` 'budgets', required: AI Gateway budget resource type.

## Response `201`

Created

- AiGatewayBudgetResponse: Response containing one AI Gateway budget.
  - `data` AiGatewayBudgetResource, required: AI Gateway budget resource.
    - `attributes` AiGatewayBudgetAttributes, required: AI Gateway budget configuration and metadata.
      - `capacity_microcents` integer, required: Budget capacity in microcents.
      - `created_at` string, date-time, required: Time when the resource was created.
      - `created_by` string, required: Identifier of the principal that created the resource.
      - `enabled` boolean, required: Whether the resource is enabled.
      - `enforcement` 'BLOCK' | 'NOTIFY', required: Action taken when spend exceeds the budget.
      - `monitor_id` integer, nullable, required: Datadog monitor ID provisioned for this budget. Null when monitor provisioning was skipped or failed.
      - `name` string, required: Human-readable resource name.
      - `scope_restricted` boolean, required: Whether provider or model scope metadata was withheld. Omit unchanged scope fields on an unrelated update to preserve their saved values.
      - `selector` AiGatewayBudgetSelectorEntry[], nullable: Dimension rules for a template budget. A nonempty selector creates independent counters for matched instances. Omit or pass an empty selector for a legacy fixed-scope budget.
        - `dim` string, required: Dimension to match: user_id, team_id, model, provider, or tag:<key>. Reserved metadata tag keys are rejected.
        - `per_value` boolean, required: Separate counters by the matched value when true. Otherwise, pool spend within the other separated dimensions.
        - `values` string[]: Allowed dimension values. Omit to match any value, including an absent dimension. An explicit list must contain at least one value.
      - `tags` AiGatewayBudgetTags, required: Request tags that must match for the budget to apply.
      - `team_id` string, uuid: Optional Datadog Team scope.
      - `updated_at` string, date-time, required: Time when the resource was last updated.
      - `user_id` string, uuid: User scope. Omitted when the budget is not user-scoped.
      - `warning_threshold` number, double, required: Fraction of capacity at which to issue a warning.
      - `window_policy` 'DAILY' | 'WEEKLY' | 'MONTHLY', required: UTC accounting period for a budget.
    - `id` string, uuid, required: Resource identifier.
    - `type` 'budgets', required: AI Gateway budget resource type.

## Other responses

- `400`: Bad Request
- `409`: Conflict
- `429`: Too many requests

---

[API](https://skmtc.dev/datadog/apis/datadog-api-v2-collection.md) - [All operations](https://skmtc.dev/datadog/apis/datadog-api-v2-collection/llms.txt) - [OpenAPI document](https://skmtc.dev/datadog/apis/datadog-api-v2-collection/revisions/3f70db624329?raw)
