Skip to main content
Astro AI spend limits set a monthly limit, in US dollars, on Astro AI spend in your Organization. You can set limits at three levels:
  • Organization total spend limit: The combined spend of every user and API token in your Organization, across all Workspaces.
  • Per-User spend limit and Per-API Token spend limit: The default limit for each user and each API token that doesn’t have a limit of its own.
  • Spend limit overrides: A limit for one specific user or API token. An override replaces the default for that user or API token.
LabsThe Per-User spend limit, Per-API Token spend limit, and Spend limit overrides are in Labs. Contact your account team to enable them. The Organization total spend limit is available without Labs.
You manage all spend limits on the AI usage and limits page in your Organization settings. You can also manage the per-user and per-API token limits with the Astro Labs API or with Terraform.

What counts toward a limit

A spend limit measures Astro AI spend. This total is the sum of both billable line items:
  • Model Chargeback
  • Intelligence fee
Requests that use your own model provider (bring your own model) don’t create Astro AI spend, so they don’t count toward a limit. Astro counts each request toward the user or API token that makes it. A request authenticated with an API token counts toward that API token, not toward the user who created the token. Every request also counts toward the Organization total spend limit. All spend limits reset at 00:00 UTC on the first day of each month.

Prerequisites

  • The Organization Owner or Organization Billing Admin role.
  • AI features enabled for your Organization. See Toggle AI features for your Organization. When AI features are disabled, the AI usage and limits page isn’t available.

Open the AI usage and limits page

  1. In the Astro UI, click Organization Settings.
  2. In the AI section, click AI usage and limits.
The Spend limits section lists the Organization total spend limit, the Per-User spend limit, the Per-API Token spend limit, and a link to Spend limit overrides.

Set the Organization total spend limit

  1. On the AI usage and limits page, click the edit button next to Organization total spend limit.
  2. Enter a monthly limit in US dollars.
  3. Click Save.
To remove the limit, click the edit button, then click the remove button. The page shows the status of the limit: Current spend below limit or Current spend above limit. The page doesn’t show the current spend amount.

Set default limits for users and API tokens

The Per-User spend limit applies to every user that doesn’t have an override. The Per-API Token spend limit applies to every API token that doesn’t have an override. The two defaults are independent. For example, you can set a limit for users and no limit for API tokens.
  1. On the AI usage and limits page, click the edit button next to Per-User spend limit or Per-API Token spend limit.
  2. Enter a monthly limit in US dollars. The maximum is $100,000.
  3. Click Save.
To remove a default, click the edit button, then click the remove button. Users or API tokens without an override then have no limit of their own. A default of $0 turns off Astro AI for every user or API token without an override. The page shows the limit as $0 - AI disabled.

Set a spend limit override

An override sets a limit for one user or API token. It can be higher or lower than the default, and it replaces the default for that user or API token.
  1. On the AI usage and limits page, click Spend limit overrides.
  2. Click the Users tab or the API Tokens tab. To find a specific user or API token, use the search field.
  3. In the Limit (Billing Cycle) column, click the limit for the user or API token.
  4. Enter a monthly limit in US dollars. The maximum is $100,000.
  5. Click Save.
The Limit (Billing Cycle) column shows one of the following values:
  • The override, if the user or API token has one.
  • The default, followed by (User default) or (API Token default), if no override exists.
  • No limit, if no override or default exists.
The Current Usage column shows each user’s and API token’s Astro AI spend in the current billing period. The column doesn’t appear when Astro can’t read spend data. To remove an override, click the limit, then click the remove button. The user or API token then follows the default again. An override of $0 turns off Astro AI for that user or API token, even if the default allows spend.
To give Astro AI access to only some users, set the Per-User spend limit to $0, then set an override for each user that needs access.

What happens when a limit is reached

The Organization total spend limit applies to every surface that uses Astro AI, including: When your Organization reaches its Organization total spend limit, Astro rejects new AI requests from every user and API token in your Organization until the limit resets. This applies even to users and API tokens that are below their own limit. When a user or API token reaches its own limit, Astro rejects new AI requests from that user or API token only. Other users and API tokens can continue to use Astro AI. Blocked requests fail with a usage limit error. Otto in the Astro CLI shows one of the following messages, depending on which limit blocked the request: In some interfaces, such as Otto in the Astro UI, no error appears and Otto stops responding. To restore access before the monthly reset, an Organization Owner or Organization Billing Admin can increase or remove the limit.
Spend limits are soft limits. Astro can take a few minutes to detect that a user, an API token, or the Organization has reached a limit. Requests that run during this time can finish, so total spend can go slightly above a limit.
Astro doesn’t send a warning or email before a limit is reached. The AI usage and limits page shows a limit status only for the Organization total spend limit: whether current spend is above or below the limit. For users and API tokens, the Spend limit overrides page shows current spend, but not whether a user or API token has reached its limit. To check whether a limit blocks a user or API token, use the isCapReached field from the Labs API.

Names in the API and Terraform

The Labs API and Terraform call a spend limit a spending cap, and they take amounts in US cents instead of US dollars. The following table maps the names in the Astro UI to the API and Terraform: The Labs API and Terraform don’t manage the Organization total spend limit. Set it on the AI usage and limits page.

Manage per-user and per-API token limits with the API

The Astro Labs API has endpoints to read, set, and remove the defaults and overrides. Limits you set with the API also appear on the AI usage and limits page.

Prerequisites

  • An Organization API token with the Organization Owner or Organization Billing Admin role.
  • Per-user and per-API token spend limits enabled for your Organization. If they aren’t enabled, every endpoint returns 404 Not Found.

Endpoints

All paths are relative to https://api.astronomer.io/labs/v1/organizations/<organization-id>. When you list users or API tokens, the subjectType parameter is required. Set it to USER or SERVICEKEY. To list only users or API tokens with an override, add hasOverride=true. A page holds at most 100 results. An Organization can have at most 1,000 users and API tokens with an override. A request that would pass that limit fails, and nothing changes.

Set overrides

The following request sets an override of $200 for a user and turns off Astro AI for an API token:
The response reports a status for each entry, in the order you sent them:
  • UPDATED: The override changed.
  • UNCHANGED: The override already had that value.
  • FAILED: Nothing changed for that entry. You can send the same request again. Entries that already succeeded are reported as UNCHANGED.

Manage per-user and per-API token limits with Terraform

The astro_ai_spending_caps resource in the Astro Terraform provider manages the default limits and the overrides for one Organization.

Prerequisites

  • The Astro Terraform provider version 1.7.0 or later.
  • An Organization API token with the Organization Owner or Organization Billing Admin role.
  • Per-user and per-API token spend limits enabled for your Organization. If they aren’t enabled, Terraform fails with a not available error.

Example

To find user and API token IDs, use the astro_users and astro_api_tokens data sources.

How Terraform changes limits

Terraform manages each of default_cap_cents, user_cap_cents, and api_token_cap_cents only when you set it:
  • If you set an attribute, Terraform removes any limit of that kind that isn’t in it, including limits set in the Astro UI. To remove all of them, set the attribute to {}. If someone changes that kind of limit in the Astro UI, the next plan shows the change as drift, and the next apply reverts it.
  • If you leave an attribute out, Terraform doesn’t change what it covers. Admins can keep editing those limits in the Astro UI.
To let admins keep editing overrides in the Astro UI, manage only default_cap_cents in Terraform and leave user_cap_cents and api_token_cap_cents out. Use at most one astro_ai_spending_caps resource for each Organization.

Import existing limits

If your Organization already has limits that your configuration would change or remove, the first plan fails and asks you to import the resource. Import it with the Organization ID:
After the import, run terraform plan to review every change before you apply it.

Remove the resource

Destroying the resource doesn’t change any limits in Astro. To remove the limits, set default_cap_cents, user_cap_cents, and api_token_cap_cents to {} and apply before you destroy the resource.

Users who leave and deleted API tokens

If a user in user_cap_cents leaves your Organization, or an API token in api_token_cap_cents is deleted, each apply fails with a not found error for that ID. Remove the ID from the map, then apply again. Removing the ID from the map doesn’t remove the override. It stays in Astro and counts toward the limit of 1,000 overrides, but the Astro UI and the API’s list of users and API tokens don’t show it. To remove it, send a DELETE request to /billing/ai-spending-caps with its ID and its subjectType: USER for a user, or SERVICEKEY for an API token. If a user who left or a deleted API token in the request has no override, the request fails with 404 Not Found and removes nothing.