> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orq.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Budgets SDK Reference

> SDK reference for the Budgets API, available in Node.js and Python.

## Budgets

### List Budgets

Returns budgets visible to the current workspace, ordered by creation time with the newest first. Supports filtering by scope kind, scope target id, period, and active state, plus an optional free-text query that searches across denormalized target names via Typesense.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from orq_ai_sdk import Orq
  import os

  with Orq(
      api_key=os.getenv("ORQ_API_KEY", ""),
  ) as orq:

      res = orq.budgets.list()

      # Handle response
      print(res)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import { Orq } from "@orq-ai/node";

  const orq = new Orq({
    apiKey: process.env["ORQ_API_KEY"] ?? "",
  });

  async function run() {
    const result = await orq.budgets.list();

    console.log(result);
  }

  run();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "limit": Optional[int],
        "starting_after": Optional[str],
        "ending_before": Optional[str],
        "scope_kind": List[Literal["BUDGET_SCOPE_KIND_UNSPECIFIED", "BUDGET_SCOPE_KIND_WORKSPACE", "BUDGET_SCOPE_KIND_PROJECT", "BUDGET_SCOPE_KIND_IDENTITY", "BUDGET_SCOPE_KIND_API_KEY", "BUDGET_SCOPE_KIND_PROVIDER", "BUDGET_SCOPE_KIND_MODEL"]],
        "scope_target_id": Optional[str],
        "is_active": Optional[bool],
        "period": List[Literal["BUDGET_PERIOD_UNSPECIFIED", "BUDGET_PERIOD_DAILY", "BUDGET_PERIOD_WEEKLY", "BUDGET_PERIOD_MONTHLY", "BUDGET_PERIOD_YEARLY", "BUDGET_PERIOD_ONE_TIME"]],
        "query": Optional[str],
        "sort_by": Optional[Literal["BUDGET_SORT_FIELD_UNSPECIFIED", "BUDGET_SORT_FIELD_EXPIRES_AT", "BUDGET_SORT_FIELD_CREATED_AT", "BUDGET_SORT_FIELD_UPDATED_AT"]],
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      limit?: number;
      startingAfter?: string;
      endingBefore?: string;
      scopeKind?: string;
      scopeTargetId?: string;
      isActive?: boolean;
      period?: string;
      query?: string;
      sortBy?: string;
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "object": Optional[str],
        "data": {  # optional
            "budget_id": Optional[str],
            "scope": {  # optional
                "workspace": {},  # optional
                "project": {  # optional
                    "project_id": Optional[str],
                },
                "identity": {  # optional
                    "identity_external_id": Optional[str],
                },
                "api_key": {  # optional
                    "api_key_id": Optional[str],
                },
                "provider": {  # optional
                    "provider": Optional[str],
                },
                "model": {  # optional
                    "model_id": Optional[str],
                },
            },
            "match": {  # optional
                "cel": Optional[str],
            },
            "limits": {  # optional
                "period": Optional[Literal["BUDGET_PERIOD_UNSPECIFIED", "BUDGET_PERIOD_DAILY", "BUDGET_PERIOD_WEEKLY", "BUDGET_PERIOD_MONTHLY", "BUDGET_PERIOD_YEARLY", "BUDGET_PERIOD_ONE_TIME"]],
                "amount": Optional[float],
                "token_limit": Optional[float],
            },
            "rate_limit": {  # optional
                "requests_per_minute": Optional[int],
            },
            "is_active": Optional[bool],
            "expires_at": date,
            "created_at": date,
            "updated_at": date,
            "usage": {  # optional
                "amount": Optional[float],
                "tokens": Optional[float],
                "requests": Optional[int],
            },
        },
        "has_more": Optional[bool],
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      object?: string;
      data?: {
        budgetId?: string;
        scope?: {
          workspace?: {};
          project?: {
            projectId?: string;
          };
          identity?: {
            identityExternalId?: string;
          };
          apiKey?: {
            apiKeyId?: string;
          };
          provider?: {
            provider?: string;
          };
          model?: {
            modelId?: string;
          };
        };
        match?: {
          cel?: string;
        };
        limits?: {
          period?: string;
          amount?: number;
          tokenLimit?: number;
        };
        rateLimit?: {
          requestsPerMinute?: number;
        };
        isActive?: boolean;
        expiresAt?: Date;
        createdAt?: Date;
        updatedAt?: Date;
        usage?: {
          amount?: number;
          tokens?: number;
          requests?: number;
        };
      };
      hasMore?: boolean;
    }
    ```
  </CodeGroup>
</Expandable>

### Create a Budget

Creates a new budget in the workspace. Exactly one scope variant must be set (workspace / project / identity / api\_key / provider / model). At least one of `limits.amount`, `limits.token_limit`, or `rate_limit.requests_per_minute` MUST be provided. Uniqueness is enforced across (workspace\_id, scope\_kind, scope\_target\_id).

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from orq_ai_sdk import Orq
  import os

  with Orq(
      api_key=os.getenv("ORQ_API_KEY", ""),
  ) as orq:

      res = orq.budgets.create()

      # Handle response
      print(res)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import { Orq } from "@orq-ai/node";

  const orq = new Orq({
    apiKey: process.env["ORQ_API_KEY"] ?? "",
  });

  async function run() {
    const result = await orq.budgets.create({});

    console.log(result);
  }

  run();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "scope": {  # optional
            "workspace": {},  # optional
            "project": {  # optional
                "project_id": Optional[str],
            },
            "identity": {  # optional
                "identity_external_id": Optional[str],
            },
            "api_key": {  # optional
                "api_key_id": Optional[str],
            },
            "provider": {  # optional
                "provider": Optional[str],
            },
            "model": {  # optional
                "model_id": Optional[str],
            },
        },
        "match": {  # optional
            "cel": Optional[str],
        },
        "limits": {  # optional
            "period": Optional[Literal["BUDGET_PERIOD_UNSPECIFIED", "BUDGET_PERIOD_DAILY", "BUDGET_PERIOD_WEEKLY", "BUDGET_PERIOD_MONTHLY", "BUDGET_PERIOD_YEARLY", "BUDGET_PERIOD_ONE_TIME"]],
            "amount": Optional[float],
            "token_limit": Optional[float],
        },
        "rate_limit": {  # optional
            "requests_per_minute": Optional[int],
        },
        "is_active": Optional[bool],
        "expires_at": date,
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      scope?: {
        workspace?: {};
        project?: {
          projectId?: string;
        };
        identity?: {
          identityExternalId?: string;
        };
        apiKey?: {
          apiKeyId?: string;
        };
        provider?: {
          provider?: string;
        };
        model?: {
          modelId?: string;
        };
      };
      match?: {
        cel?: string;
      };
      limits?: {
        period?: string;
        amount?: number;
        tokenLimit?: number;
      };
      rateLimit?: {
        requestsPerMinute?: number;
      };
      isActive?: boolean;
      expiresAt?: Date;
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "budget": {  # optional
            "budget_id": Optional[str],
            "scope": {  # optional
                "workspace": {},  # optional
                "project": {  # optional
                    "project_id": Optional[str],
                },
                "identity": {  # optional
                    "identity_external_id": Optional[str],
                },
                "api_key": {  # optional
                    "api_key_id": Optional[str],
                },
                "provider": {  # optional
                    "provider": Optional[str],
                },
                "model": {  # optional
                    "model_id": Optional[str],
                },
            },
            "match": {  # optional
                "cel": Optional[str],
            },
            "limits": {  # optional
                "period": Optional[Literal["BUDGET_PERIOD_UNSPECIFIED", "BUDGET_PERIOD_DAILY", "BUDGET_PERIOD_WEEKLY", "BUDGET_PERIOD_MONTHLY", "BUDGET_PERIOD_YEARLY", "BUDGET_PERIOD_ONE_TIME"]],
                "amount": Optional[float],
                "token_limit": Optional[float],
            },
            "rate_limit": {  # optional
                "requests_per_minute": Optional[int],
            },
            "is_active": Optional[bool],
            "expires_at": date,
            "created_at": date,
            "updated_at": date,
            "usage": {  # optional
                "amount": Optional[float],
                "tokens": Optional[float],
                "requests": Optional[int],
            },
        },
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      budget?: {
        budgetId?: string;
        scope?: {
          workspace?: {};
          project?: {
            projectId?: string;
          };
          identity?: {
            identityExternalId?: string;
          };
          apiKey?: {
            apiKeyId?: string;
          };
          provider?: {
            provider?: string;
          };
          model?: {
            modelId?: string;
          };
        };
        match?: {
          cel?: string;
        };
        limits?: {
          period?: string;
          amount?: number;
          tokenLimit?: number;
        };
        rateLimit?: {
          requestsPerMinute?: number;
        };
        isActive?: boolean;
        expiresAt?: Date;
        createdAt?: Date;
        updatedAt?: Date;
        usage?: {
          amount?: number;
          tokens?: number;
          requests?: number;
        };
      };
    }
    ```
  </CodeGroup>
</Expandable>

### Check a Budget

Internal endpoint used by the gateway to resolve applicable budgets and check enforcement gates for a request. Returns allowed/rejected status with dimension info for rate-limit headers.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from orq_ai_sdk import Orq
  import os

  with Orq(
      api_key=os.getenv("ORQ_API_KEY", ""),
  ) as orq:

      res = orq.budgets.check()

      # Handle response
      print(res)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import { Orq } from "@orq-ai/node";

  const orq = new Orq({
    apiKey: process.env["ORQ_API_KEY"] ?? "",
  });

  async function run() {
    const result = await orq.budgets.check({});

    console.log(result);
  }

  run();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "api_key_id": Optional[str],
        "project_id": Optional[str],
        "identity_external_id": Optional[str],
        "provider": Optional[str],
        "model_id": Optional[str],
        "metadata": {},  # optional
        "headers": Dict[str, str],
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      apiKeyId?: string;
      projectId?: string;
      identityExternalId?: string;
      provider?: string;
      modelId?: string;
      metadata?: {};
      headers?: Record<string, string>;
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "allowed": Optional[bool],
        "rejection": {  # optional
            "scope_kind": Optional[str],
            "scope_target_id": Optional[str],
            "dimension": Optional[str],
            "code": Optional[str],
            "message": Optional[str],
        },
        "cost": {  # optional
            "limit": Optional[float],
            "remaining": Optional[float],
            "reset_seconds": Optional[int],
        },
        "tokens": {  # optional
            "limit": Optional[float],
            "remaining": Optional[float],
            "reset_seconds": Optional[int],
        },
        "requests": {  # optional
            "limit": Optional[float],
            "remaining": Optional[float],
            "reset_seconds": Optional[int],
        },
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      allowed?: boolean;
      rejection?: {
        scopeKind?: string;
        scopeTargetId?: string;
        dimension?: string;
        code?: string;
        message?: string;
      };
      cost?: {
        limit?: number;
        remaining?: number;
        resetSeconds?: number;
      };
      tokens?: {
        limit?: number;
        remaining?: number;
        resetSeconds?: number;
      };
      requests?: {
        limit?: number;
        remaining?: number;
        resetSeconds?: number;
      };
    }
    ```
  </CodeGroup>
</Expandable>

### Retrieve a Budget

Retrieves the metadata for an existing budget by its unique identifier. Returns `NotFound` when the budget does not exist in the caller's workspace.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from orq_ai_sdk import Orq
  import os

  with Orq(
      api_key=os.getenv("ORQ_API_KEY", ""),
  ) as orq:

      res = orq.budgets.get(budget_id="<id>")

      # Handle response
      print(res)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import { Orq } from "@orq-ai/node";

  const orq = new Orq({
    apiKey: process.env["ORQ_API_KEY"] ?? "",
  });

  async function run() {
    const result = await orq.budgets.get({
      budgetId: "<id>",
    });

    console.log(result);
  }

  run();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "budget_id": str,  # required
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      budgetId: string;  // required
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "budget": {  # optional
            "budget_id": Optional[str],
            "scope": {  # optional
                "workspace": {},  # optional
                "project": {  # optional
                    "project_id": Optional[str],
                },
                "identity": {  # optional
                    "identity_external_id": Optional[str],
                },
                "api_key": {  # optional
                    "api_key_id": Optional[str],
                },
                "provider": {  # optional
                    "provider": Optional[str],
                },
                "model": {  # optional
                    "model_id": Optional[str],
                },
            },
            "match": {  # optional
                "cel": Optional[str],
            },
            "limits": {  # optional
                "period": Optional[Literal["BUDGET_PERIOD_UNSPECIFIED", "BUDGET_PERIOD_DAILY", "BUDGET_PERIOD_WEEKLY", "BUDGET_PERIOD_MONTHLY", "BUDGET_PERIOD_YEARLY", "BUDGET_PERIOD_ONE_TIME"]],
                "amount": Optional[float],
                "token_limit": Optional[float],
            },
            "rate_limit": {  # optional
                "requests_per_minute": Optional[int],
            },
            "is_active": Optional[bool],
            "expires_at": date,
            "created_at": date,
            "updated_at": date,
            "usage": {  # optional
                "amount": Optional[float],
                "tokens": Optional[float],
                "requests": Optional[int],
            },
        },
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      budget?: {
        budgetId?: string;
        scope?: {
          workspace?: {};
          project?: {
            projectId?: string;
          };
          identity?: {
            identityExternalId?: string;
          };
          apiKey?: {
            apiKeyId?: string;
          };
          provider?: {
            provider?: string;
          };
          model?: {
            modelId?: string;
          };
        };
        match?: {
          cel?: string;
        };
        limits?: {
          period?: string;
          amount?: number;
          tokenLimit?: number;
        };
        rateLimit?: {
          requestsPerMinute?: number;
        };
        isActive?: boolean;
        expiresAt?: Date;
        createdAt?: Date;
        updatedAt?: Date;
        usage?: {
          amount?: number;
          tokens?: number;
          requests?: number;
        };
      };
    }
    ```
  </CodeGroup>
</Expandable>

### Delete a Budget

Permanently deletes a budget. Consumption counters in Redis for this budget are cleared immediately. The response body is empty on success.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from orq_ai_sdk import Orq
  import os

  with Orq(
      api_key=os.getenv("ORQ_API_KEY", ""),
  ) as orq:

      res = orq.budgets.delete(budget_id="<id>")

      # Handle response
      print(res)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import { Orq } from "@orq-ai/node";

  const orq = new Orq({
    apiKey: process.env["ORQ_API_KEY"] ?? "",
  });

  async function run() {
    const result = await orq.budgets.delete({
      budgetId: "<id>",
    });

    console.log(result);
  }

  run();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "budget_id": str,  # required
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      budgetId: string;  // required
    }
    ```
  </CodeGroup>
</Expandable>

### Update a Budget

Updates mutable fields of a budget: limits, rate limit, activation, and expiration. The scope is immutable: to change a budget's target, delete and recreate it. Omitted fields keep their current values.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from orq_ai_sdk import Orq
  import os

  with Orq(
      api_key=os.getenv("ORQ_API_KEY", ""),
  ) as orq:

      res = orq.budgets.update(budget_id="<id>")

      # Handle response
      print(res)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import { Orq } from "@orq-ai/node";

  const orq = new Orq({
    apiKey: process.env["ORQ_API_KEY"] ?? "",
  });

  async function run() {
    const result = await orq.budgets.update({
      budgetId: "<id>",
      updateBudgetRequest: {},
    });

    console.log(result);
  }

  run();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "budget_id": str,  # required
        "limits": {  # optional
            "period": Optional[Literal["BUDGET_PERIOD_UNSPECIFIED", "BUDGET_PERIOD_DAILY", "BUDGET_PERIOD_WEEKLY", "BUDGET_PERIOD_MONTHLY", "BUDGET_PERIOD_YEARLY", "BUDGET_PERIOD_ONE_TIME"]],
            "amount": Optional[float],
            "token_limit": Optional[float],
        },
        "rate_limit": {  # optional
            "requests_per_minute": Optional[int],
        },
        "is_active": Optional[bool],
        "expires_at": date,
        "clear_expires_at": Optional[bool],
        "match": {  # optional
            "cel": Optional[str],
        },
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      budgetId: string;  // required
      updateBudgetRequest: {  // required
        limits?: {
          period?: string;
          amount?: number;
          tokenLimit?: number;
        };
        rateLimit?: {
          requestsPerMinute?: number;
        };
        isActive?: boolean;
        expiresAt?: Date;
        clearExpiresAt?: boolean;
        match?: {
          cel?: string;
        };
      };
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "budget": {  # optional
            "budget_id": Optional[str],
            "scope": {  # optional
                "workspace": {},  # optional
                "project": {  # optional
                    "project_id": Optional[str],
                },
                "identity": {  # optional
                    "identity_external_id": Optional[str],
                },
                "api_key": {  # optional
                    "api_key_id": Optional[str],
                },
                "provider": {  # optional
                    "provider": Optional[str],
                },
                "model": {  # optional
                    "model_id": Optional[str],
                },
            },
            "match": {  # optional
                "cel": Optional[str],
            },
            "limits": {  # optional
                "period": Optional[Literal["BUDGET_PERIOD_UNSPECIFIED", "BUDGET_PERIOD_DAILY", "BUDGET_PERIOD_WEEKLY", "BUDGET_PERIOD_MONTHLY", "BUDGET_PERIOD_YEARLY", "BUDGET_PERIOD_ONE_TIME"]],
                "amount": Optional[float],
                "token_limit": Optional[float],
            },
            "rate_limit": {  # optional
                "requests_per_minute": Optional[int],
            },
            "is_active": Optional[bool],
            "expires_at": date,
            "created_at": date,
            "updated_at": date,
            "usage": {  # optional
                "amount": Optional[float],
                "tokens": Optional[float],
                "requests": Optional[int],
            },
        },
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      budget?: {
        budgetId?: string;
        scope?: {
          workspace?: {};
          project?: {
            projectId?: string;
          };
          identity?: {
            identityExternalId?: string;
          };
          apiKey?: {
            apiKeyId?: string;
          };
          provider?: {
            provider?: string;
          };
          model?: {
            modelId?: string;
          };
        };
        match?: {
          cel?: string;
        };
        limits?: {
          period?: string;
          amount?: number;
          tokenLimit?: number;
        };
        rateLimit?: {
          requestsPerMinute?: number;
        };
        isActive?: boolean;
        expiresAt?: Date;
        createdAt?: Date;
        updatedAt?: Date;
        usage?: {
          amount?: number;
          tokens?: number;
          requests?: number;
        };
      };
    }
    ```
  </CodeGroup>
</Expandable>

### Get Consumption

Returns the current-period cost, token, and per-minute request counters for the budget. Values reflect the live Redis state for the active period bucket.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from orq_ai_sdk import Orq
  import os

  with Orq(
      api_key=os.getenv("ORQ_API_KEY", ""),
  ) as orq:

      res = orq.budgets.get_consumption(budget_id="<id>")

      # Handle response
      print(res)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import { Orq } from "@orq-ai/node";

  const orq = new Orq({
    apiKey: process.env["ORQ_API_KEY"] ?? "",
  });

  async function run() {
    const result = await orq.budgets.getConsumption({
      budgetId: "<id>",
    });

    console.log(result);
  }

  run();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "budget_id": str,  # required
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      budgetId: string;  // required
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "budget_id": Optional[str],
        "period": Optional[Literal["BUDGET_PERIOD_UNSPECIFIED", "BUDGET_PERIOD_DAILY", "BUDGET_PERIOD_WEEKLY", "BUDGET_PERIOD_MONTHLY", "BUDGET_PERIOD_YEARLY", "BUDGET_PERIOD_ONE_TIME"]],
        "period_date": Optional[str],
        "cost": Optional[float],
        "tokens": Optional[float],
        "requests_in_window": Optional[int],
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      budgetId?: string;
      period?: string;
      periodDate?: string;
      cost?: number;
      tokens?: number;
      requestsInWindow?: number;
    }
    ```
  </CodeGroup>
</Expandable>

### Reset Consumption

Clears the current-period cost, token, and request counters for the budget. The budget record itself is preserved; only the Redis counters are reset.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from orq_ai_sdk import Orq
  import os

  with Orq(
      api_key=os.getenv("ORQ_API_KEY", ""),
  ) as orq:

      res = orq.budgets.reset_consumption(budget_id="<id>", reset_budget_consumption_request={})

      # Handle response
      print(res)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import { Orq } from "@orq-ai/node";

  const orq = new Orq({
    apiKey: process.env["ORQ_API_KEY"] ?? "",
  });

  async function run() {
    const result = await orq.budgets.resetConsumption({
      budgetId: "<id>",
      resetBudgetConsumptionRequest: {},
    });

    console.log(result);
  }

  run();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "budget_id": str,  # required
        "reset_budget_consumption_request": {},  # required
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      budgetId: string;  // required
      resetBudgetConsumptionRequest: {};  // required
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "budget": {  # optional
            "budget_id": Optional[str],
            "scope": {  # optional
                "workspace": {},  # optional
                "project": {  # optional
                    "project_id": Optional[str],
                },
                "identity": {  # optional
                    "identity_external_id": Optional[str],
                },
                "api_key": {  # optional
                    "api_key_id": Optional[str],
                },
                "provider": {  # optional
                    "provider": Optional[str],
                },
                "model": {  # optional
                    "model_id": Optional[str],
                },
            },
            "match": {  # optional
                "cel": Optional[str],
            },
            "limits": {  # optional
                "period": Optional[Literal["BUDGET_PERIOD_UNSPECIFIED", "BUDGET_PERIOD_DAILY", "BUDGET_PERIOD_WEEKLY", "BUDGET_PERIOD_MONTHLY", "BUDGET_PERIOD_YEARLY", "BUDGET_PERIOD_ONE_TIME"]],
                "amount": Optional[float],
                "token_limit": Optional[float],
            },
            "rate_limit": {  # optional
                "requests_per_minute": Optional[int],
            },
            "is_active": Optional[bool],
            "expires_at": date,
            "created_at": date,
            "updated_at": date,
            "usage": {  # optional
                "amount": Optional[float],
                "tokens": Optional[float],
                "requests": Optional[int],
            },
        },
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      budget?: {
        budgetId?: string;
        scope?: {
          workspace?: {};
          project?: {
            projectId?: string;
          };
          identity?: {
            identityExternalId?: string;
          };
          apiKey?: {
            apiKeyId?: string;
          };
          provider?: {
            provider?: string;
          };
          model?: {
            modelId?: string;
          };
        };
        match?: {
          cel?: string;
        };
        limits?: {
          period?: string;
          amount?: number;
          tokenLimit?: number;
        };
        rateLimit?: {
          requestsPerMinute?: number;
        };
        isActive?: boolean;
        expiresAt?: Date;
        createdAt?: Date;
        updatedAt?: Date;
        usage?: {
          amount?: number;
          tokens?: number;
          requests?: number;
        };
      };
    }
    ```
  </CodeGroup>
</Expandable>
