From c1509e0bf43579e2d1d65bdae61b6bf672ffdd90 Mon Sep 17 00:00:00 2001 From: Ahmed N Date: Tue, 21 Jul 2026 14:12:16 +0100 Subject: [PATCH 1/4] docs: document periodic token budget reset and guardrail member budgets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add coverage for two new spending-control features: - Custom API Keys: periodic budget reset (balance_reset_period / balance_reset_amount), documented both in the dashboard (Spending Limit → Reset allowance / Resets) and via the API. - Guardrails: per-member budget caps (Member budget → Budget / Per), including how the cap behaves and how it resolves across member/role levels, plus a note that budgets are ignored on token-attached guardrails. - Users & Organisation: mention member spend caps in the guardrails summary. --- v3/general/custom-api-keys.mdx | 63 +++++++++++++++++++++++++- v3/organization/guardrails.mdx | 44 ++++++++++++++---- v3/organization/users-organisation.mdx | 2 +- 3 files changed, 99 insertions(+), 10 deletions(-) diff --git a/v3/general/custom-api-keys.mdx b/v3/general/custom-api-keys.mdx index f6e0296..c518561 100644 --- a/v3/general/custom-api-keys.mdx +++ b/v3/general/custom-api-keys.mdx @@ -14,7 +14,7 @@ import { TechArticleSchema } from "/snippets/TechArticleSchema.mdx"; proficiencyLevel="Intermediate" keywords={["Eden AI", "AI API", "rate limits", "billing", "monitoring"]} datePublished="2026-05-06T00:00:00Z" - dateModified="2026-05-07T00:00:00Z" + dateModified="2026-07-21T00:00:00Z" /> Custom API keys let you create additional tokens beyond your main account key. Each token can have its own budget, expiration, and type, giving you fine-grained control over access and spending. @@ -122,6 +122,66 @@ curl -X POST https://api.edenai.run/v2/user/custom_token/ \ When `active_balance` is `true`, every API call deducts from the token's balance. Once it reaches $0, the token stops working. +## Periodic Budget Reset + +By default a token budget is **one-time**: once spent, it stays at $0 until you top it up manually. You can instead have the budget **reinitialize automatically** each day, week, or month by setting `balance_reset_period` together with `balance_reset_amount` (the amount the balance is restored to at the start of each period). + +### In the dashboard + +On the [API Keys](https://app.edenai.run/settings/api-keys) page, create or edit a key and turn on **Spending Limit**. Set the **Reset allowance** (the amount restored each period) and choose a **Resets** frequency — **Daily**, **Weekly**, **Monthly**, or **Never**. A separate **Current balance** field shows what's available right now; editing the allowance only takes effect at the next reset. + +### Through the API + + +```python Python +import requests + +headers = { + "Authorization": "Bearer YOUR_API_KEY", + "Content-Type": "application/json" +} + +response = requests.post( + "https://api.edenai.run/v2/user/custom_token/", + headers=headers, + json={ + "name": "team-daily", + "token_type": "api_token", + "balance_reset_amount": "10.00", + "balance_reset_period": "daily" + } +) +``` + +```bash cURL +curl -X POST https://api.edenai.run/v2/user/custom_token/ \ + -H "Authorization: Bearer YOUR_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "team-daily", + "balance_reset_amount": "10.00", + "balance_reset_period": "daily" + }' +``` + + +| Field | Values | Meaning | +|-------|--------|---------| +| `balance_reset_period` | `none`, `daily`, `weekly`, `monthly` | How often the balance is restored. `none` (default) = one-time budget. | +| `balance_reset_amount` | positive amount | The value the balance is reset to each period. Required whenever the period is not `none`. | + +Behaviour to know: + +- Setting a reset period **automatically enforces the budget** (`active_balance` becomes `true`) — you don't have to set it separately. +- `balance_reset_amount` is the reset **target**, kept separate from the live `balance` (the amount remaining right now). They are not the same field. +- A new periodic token **starts the period full**: if you don't pass a starting `balance`, it begins at `balance_reset_amount`. Passing an explicit `balance` lets a key start partway through a period. +- Resets run at **midnight Europe/Paris time**: daily every night, weekly on Monday, monthly on the 1st. +- Setting the period back to `none` clears `balance_reset_amount` and returns the token to a one-time budget. + + +This per-token reset is distinct from the **per-member budget cap** you can set on a [guardrail](/v3/organization/guardrails#budget-cap). A token budget is a hard cap on one key (it stops at $0); a member budget is a soft periodic spend cap that follows a person across all their keys. + + ## List All Tokens @@ -155,6 +215,7 @@ Use clear naming conventions like `env-project-purpose` (e.g., `prod-billing-api - **Set budgets on non-production tokens** to prevent accidental overspending during development. +- **Use a periodic reset** (`balance_reset_period`) for recurring allowances — e.g. a $10/day CI key — instead of topping up manually. - **Use sandbox tokens for CI/CD** to validate integrations without incurring costs. - **Rotate tokens periodically** — create a new token, migrate your application, then delete the old one. - **Set expiration dates** on temporary tokens (e.g., for contractors or short-term projects). diff --git a/v3/organization/guardrails.mdx b/v3/organization/guardrails.mdx index 53cb67e..0f0be5d 100644 --- a/v3/organization/guardrails.mdx +++ b/v3/organization/guardrails.mdx @@ -1,28 +1,29 @@ --- icon: "shield-check" title: "Guardrails" -description: "Guardrails are reusable usage policies that control which models your team can call and how often. Create them in the dashboard and attach them to roles, members, or API tokens." +description: "Guardrails are reusable usage policies that control which models your team can call, how often, and how much a member can spend. Create them in the dashboard and attach them to roles, members, or API tokens." --- import { TechArticleSchema } from "/snippets/TechArticleSchema.mdx"; -A **guardrail** is a reusable usage policy that controls two things: +A **guardrail** is a reusable usage policy that controls: - **Model access**: which providers and models can be called. - **Rate limits**: how many requests can be made over a given period. +- **Member budget**: a spending cap for a member over a period (see [Budget cap](#budget-cap)). -You create a guardrail once, then attach it to a **role**, a **member**, or an individual **API token**. For example, one team can be limited to a curated set of models, or a shared token can be capped to a low request rate. +You create a guardrail once, then attach it to a **role**, a **member**, or an individual **API token**. For example, one team can be limited to a curated set of models, a shared token can be capped to a low request rate, or a member can be given a monthly spending cap. Guardrails are part of the advanced organisation features. See [plans and pricing](https://www.edenai.co/pricing) for availability. @@ -43,6 +44,9 @@ In the **Rate Limit** field, enter a limit in the form `N/period`, for example ` Turn on **Enable model rules** to control which models can be used, then define your allow/deny rules. See [Model rules](#model-rules) below. + +Enter a **Budget** amount and a **period** (daily, weekly, or monthly) to cap how much a member can spend. See [Budget cap](#budget-cap) below. + Click **Create Guardrail**. It now appears in your guardrails list, ready to assign. @@ -83,6 +87,28 @@ The rate limit uses the format `N/period`, where `period` is `second`, `minute`, Leave the rate limit empty on a guardrail to inherit it from the next level up (role → organisation default). +## Budget cap + +A guardrail can cap how much a **member** spends over a recurring period. In the **Create/Edit Guardrail** dialog, turn on **Member budget** ("Cap each member's spend across all their API keys"), then set a **Budget** amount (in USD) and a **Per** period: + +| Period | Window | +| --- | --- | +| `daily` | Resets each day | +| `weekly` | Resets each week | +| `monthly` | Resets each month | + +Both fields are set together — a budget needs a period, and a period needs an amount. Leave them empty to apply no spend cap. + +How it behaves: + +- **Per member, not shared.** The cap applies to each member the guardrail resolves to individually — it is not a shared pool across the team. +- **Soft cap.** The check happens before each request. A request already in flight can push spend past the cap; the *next* request is the one that gets blocked. The limit is a spending guardrail, not a hard cutoff mid-request. +- **Counts real usage only.** [Sandbox](/v3/general/sandbox) calls and calls made with your own provider keys ([BYOK](/v3/general/byok)) don't count toward the budget. Refunds credit it back. + + +The budget only applies when a guardrail is attached to a **role** or a **member**. A budget set on a guardrail that is attached to an **API token** is ignored — use a [token budget](/v3/general/custom-api-keys) to cap a single key instead. + + ## Assigning a guardrail A guardrail does nothing until it's attached to something. You can assign it to: @@ -97,7 +123,9 @@ When a request comes in, Eden AI resolves the policy **per field, most specific token → member → role → organisation default ``` -For each setting (model rules and rate limit) independently, Eden AI uses the value from the most specific level that has it set, and inherits the rest. So a token can override the model rules while still inheriting its role's rate limit. +For **model rules** and **rate limit** independently, Eden AI uses the value from the most specific level that has it set, and inherits the rest. So a token can override the model rules while still inheriting its role's rate limit. + +The **member budget** resolves differently: only the **member** and **role** levels are considered (token budgets are handled separately, on the token itself), and the budget amount and period are always taken together from the most specific level that sets them — they are never mixed across levels. Guardrails can also be managed programmatically through the User Management API if you need to automate provisioning. See the [API Reference](https://www.edenai.co/docs) for the `guardrails` endpoints. @@ -106,5 +134,5 @@ Guardrails can also be managed programmatically through the User Management API ## Related - [Users & Organisation](/v3/organization/users-organisation): roles, permissions, and members. -- [Custom API Keys](/v3/general/custom-api-keys): per-token budgets that pair well with per-token guardrails. +- [Custom API Keys](/v3/general/custom-api-keys): per-token budgets, which cap a single key rather than a member. - [Rate Limits](/v3/overview/rate-limits): how default rate limiting works. diff --git a/v3/organization/users-organisation.mdx b/v3/organization/users-organisation.mdx index dbca7a9..d8bd328 100644 --- a/v3/organization/users-organisation.mdx +++ b/v3/organization/users-organisation.mdx @@ -62,7 +62,7 @@ If the built-in roles don't fit, click **+ Create Role** to define a custom role ## Guardrails -Beyond who can manage the organisation, you can control **which models members can call and how often** using [guardrails](/v3/organization/guardrails): reusable usage policies that combine model/provider access rules with rate limits. Guardrails can be attached to a role, an individual member, or a single API token, and resolve most-specific-first (token → member → role → organisation default). +Beyond who can manage the organisation, you can control **which models members can call, how often, and how much they can spend** using [guardrails](/v3/organization/guardrails): reusable usage policies that combine model/provider access rules, rate limits, and per-member budget caps. Guardrails can be attached to a role, an individual member, or a single API token, and resolve most-specific-first (token → member → role → organisation default). ## Single Sign-On & Directory Sync From e99f89104f1118f46058f184fae08dde22d42ef2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 21 Jul 2026 13:16:35 +0000 Subject: [PATCH 2/4] chore: bump dateModified for changed docs --- v3/organization/users-organisation.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/organization/users-organisation.mdx b/v3/organization/users-organisation.mdx index d8bd328..2979134 100644 --- a/v3/organization/users-organisation.mdx +++ b/v3/organization/users-organisation.mdx @@ -14,7 +14,7 @@ import { TechArticleSchema } from "/snippets/TechArticleSchema.mdx"; proficiencyLevel="Intermediate" keywords={["Eden AI", "AI API", "RBAC", "roles", "permissions", "organisation"]} datePublished="2026-06-11T00:00:00Z" - dateModified="2026-06-11T00:00:00Z" + dateModified="2026-07-21T00:00:00Z" /> Eden AI provides team and organisation management features for companies that need structured access control, role-based permissions, and governance over their AI usage. From ca171953c63f290036813ebf634a570a9abe85b7 Mon Sep 17 00:00:00 2001 From: Ahmed N Date: Tue, 21 Jul 2026 14:30:11 +0100 Subject: [PATCH 3/4] docs: clarify budget-cap resolution in guardrails summary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Users & Organisation guardrails summary implied all guardrail settings resolve token → member → role. Per-member budget caps only resolve at member/role levels (token-attached budgets are ignored), so split the sentence to state the model-rule/rate-limit resolution and the budget resolution separately. Addresses CodeRabbit review feedback on PR #78. --- v3/organization/users-organisation.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/organization/users-organisation.mdx b/v3/organization/users-organisation.mdx index 2979134..18d1491 100644 --- a/v3/organization/users-organisation.mdx +++ b/v3/organization/users-organisation.mdx @@ -62,7 +62,7 @@ If the built-in roles don't fit, click **+ Create Role** to define a custom role ## Guardrails -Beyond who can manage the organisation, you can control **which models members can call, how often, and how much they can spend** using [guardrails](/v3/organization/guardrails): reusable usage policies that combine model/provider access rules, rate limits, and per-member budget caps. Guardrails can be attached to a role, an individual member, or a single API token, and resolve most-specific-first (token → member → role → organisation default). +Beyond who can manage the organisation, you can control **which models members can call, how often, and how much they can spend** using [guardrails](/v3/organization/guardrails): reusable usage policies that combine model/provider access rules, rate limits, and per-member budget caps. Guardrails can be attached to a role, an individual member, or a single API token. Model rules and rate limits resolve most-specific-first (token → member → role → organisation default); the per-member budget cap resolves at the member and role levels only (budgets set on a token-attached guardrail are ignored). ## Single Sign-On & Directory Sync From 3d62dd37271047c7adf1f135d45e28c93ffec0d2 Mon Sep 17 00:00:00 2001 From: Ahmed N Date: Tue, 21 Jul 2026 14:50:15 +0100 Subject: [PATCH 4/4] docs: correct default reset framing for token budgets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The intro claimed a token budget is one-time "by default", but the dashboard pre-selects a recurring Monthly reset whenever a spending limit is enabled — "Never" (one-time) is an option, not the default. - Reframe the intro so neither reset nor one-time is stated as the universal default. - Note in the dashboard section that a frequency is always selected and defaults to Monthly, with Never for a one-time budget. - Qualify the API field table: `none` is the default only when the field is omitted from the API request. --- v3/general/custom-api-keys.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/v3/general/custom-api-keys.mdx b/v3/general/custom-api-keys.mdx index c518561..2b1fbd0 100644 --- a/v3/general/custom-api-keys.mdx +++ b/v3/general/custom-api-keys.mdx @@ -124,11 +124,11 @@ When `active_balance` is `true`, every API call deducts from the token's balance ## Periodic Budget Reset -By default a token budget is **one-time**: once spent, it stays at $0 until you top it up manually. You can instead have the budget **reinitialize automatically** each day, week, or month by setting `balance_reset_period` together with `balance_reset_amount` (the amount the balance is restored to at the start of each period). +A budget can either **reinitialize automatically** each day, week, or month, or be a **one-time** allowance that stays at $0 once spent until you top it up manually. You control this with `balance_reset_period` (the reset frequency) and `balance_reset_amount` (the amount the balance is restored to at the start of each period). ### In the dashboard -On the [API Keys](https://app.edenai.run/settings/api-keys) page, create or edit a key and turn on **Spending Limit**. Set the **Reset allowance** (the amount restored each period) and choose a **Resets** frequency — **Daily**, **Weekly**, **Monthly**, or **Never**. A separate **Current balance** field shows what's available right now; editing the allowance only takes effect at the next reset. +On the [API Keys](https://app.edenai.run/settings/api-keys) page, create or edit a key and turn on **Spending Limit**. Set the **Reset allowance** (the amount restored each period) and choose a **Resets** frequency — **Daily**, **Weekly**, **Monthly**, or **Never**. A reset frequency is always selected when a spending limit is on; it defaults to **Monthly**. Choose **Never** for a one-time budget that does not renew. A separate **Current balance** field shows what's available right now; editing the allowance only takes effect at the next reset. ### Through the API @@ -167,7 +167,7 @@ curl -X POST https://api.edenai.run/v2/user/custom_token/ \ | Field | Values | Meaning | |-------|--------|---------| -| `balance_reset_period` | `none`, `daily`, `weekly`, `monthly` | How often the balance is restored. `none` (default) = one-time budget. | +| `balance_reset_period` | `none`, `daily`, `weekly`, `monthly` | How often the balance is restored. `none` = one-time budget; it is the default when the field is omitted from the API request. (The dashboard instead pre-selects **Monthly** when you enable a spending limit.) | | `balance_reset_amount` | positive amount | The value the balance is reset to each period. Required whenever the period is not `none`. | Behaviour to know: