- 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.
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
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
- In the Astro UI, click Organization Settings.
- In the AI section, click AI usage and limits.
Set the Organization total spend limit
- On the AI usage and limits page, click the edit button next to Organization total spend limit.
- Enter a monthly limit in US dollars.
- Click Save.
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.- On the AI usage and limits page, click the edit button next to Per-User spend limit or Per-API Token spend limit.
- Enter a monthly limit in US dollars. The maximum is $100,000.
- Click Save.
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.- On the AI usage and limits page, click Spend limit overrides.
- Click the Users tab or the API Tokens tab. To find a specific user or API token, use the search field.
- In the Limit (Billing Cycle) column, click the limit for the user or API token.
- Enter a monthly limit in US dollars. The maximum is $100,000.
- Click Save.
- 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.
What happens when a limit is reached
The Organization total spend limit applies to every surface that uses Astro AI, including:- Otto in the Astro UI and the Astro CLI.
- AI-powered authoring in the Astro IDE.
- Otto code review and investigations.
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 tohttps://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: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 asUNCHANGED.
Manage per-user and per-API token limits with Terraform
Theastro_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 availableerror.
Example
astro_users and astro_api_tokens data sources.
How Terraform changes limits
Terraform manages each ofdefault_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.
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: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, setdefault_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 inuser_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.