enterprise_ai.quotas
Source: sdks/python/src/enterprise_ai/quotas/__init__.py. Back to the Python SDK reference index.
This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.
Model Reservation
An open reservation. commit or release once.
Fields:
| Name | Type | Required | Description |
|---|---|---|---|
client | QuotasClient | yes | /v1/quotas. |
id | str | yes | Identifier of the reservation returned by the server. |
data | dict[str, Any] | no | Answer of the reservation call as returned by the server. |
state | str | no | reserved, then committed after a normal exit or released after an exception. |
actual | Any | no | Measured {cost, tokens} set by commit, sent at the end of the block; None when not set. |
Reservation.commit
commit(cost: Any = None, tokens: int | None = None) -> Any
Mark the measured cost and tokens; sent when the block exits.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
cost | Any | None | no | Measured cost, as a decimal string or number, optional. |
tokens | int | None | None | no | Measured number of tokens, optional. |
Returns: Any. The recorded {cost, tokens}, or None when neither is given.
Class QuotasClient
/v1/quotas.
Resource
QuotasClient.areservation
async areservation(cost: Any = '0', tokens: int = 0, **kwargs: Any) -> AsyncIterator[Reservation]
Async variant of :meth:reservation.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
cost | Any | '0' | no | Cost to reserve, as a decimal string or number (default "0"). |
tokens | int | 0 | no | Number of tokens to reserve (default 0). |
**kwargs | Any | no | Options of reserve: scope, ttl_seconds, idempotency_key. |
Returns: AsyncIterator[Reservation]. A Reservation: An open reservation. commit or release once.
QuotasClient.commit
commit(reservation_id: str, cost: number | string = None, tokens: int | None = None) -> Any
Commit a reservation. Replaces the reserved amount by the measured one on every quota window of the reservation and checks the alert thresholds. A closed reservation answers 409 reservation_closed; an unknown one 404 reservation_not_found. Audited. Requires finops, tenant_admin, agent or developer, and a tenant principal.
Route: /v1/quotas/{reservation_id}/commit (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
reservation_id | str | yes | Identifier (UUID) of the reservation returned by POST /v1/quotas/reserve. | |
cost | number | string | None | no | Measured cost in the currency of the reservation, at least 0, default 0. |
tokens | int | None | None | no | Measured tokens, at least 0, default 0. |
Returns: Any. Decoded JSON answer of the operation "Commit a reservation".
Raises: the typed errors of the transport (Errors).
QuotasClient.create
create(name: str, scope_type: str, scope_value: str | None = None, limit_cost: number | string | null = None, limit_tokens: int | None = None, period: str = 'month', **extra: Any) -> Any
Create a quota. Creates a quota of the tenant and answers 201. A cost or token limit is required, and scope_value is required unless scope_type is tenant (422 validation_error). Without currency, the tenant currency applies. Audited. Requires finops or tenant_admin, and a tenant principal.
Route: /v1/quotas (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
name | str | yes | Name of the quota, 1 to 200 characters. | |
scope_type | str | yes | What the quota limits: tenant (default), project, agent, user, model or provider. | |
scope_value | str | None | None | no | Identifier of the project, agent, user, model or provider; required unless scope_type is tenant, where it must be null. |
limit_cost | number | string | null | None | no | Cost limit per window, at least 0, in currency. |
limit_tokens | int | None | None | no | Token limit per window, at least 0. |
period | str | 'month' | no | Window of the limit: request (each call), run, hour, day or month (default), in UTC. |
**extra | Any | no | Extra fields merged into the request body. |
Returns: Any. Decoded JSON answer of the operation "Create a quota".
Raises: the typed errors of the transport (Errors).
QuotasClient.delete
delete(quota_id: str) -> Any
Delete a quota. Deletes a quota of the tenant and answers 204. Unknown id: 404 quota_not_found. Audited (finops.quota.delete). Requires finops or tenant_admin.
Route: /v1/quotas/{quota_id} (DELETE).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
quota_id | str | yes | Identifier (UUID) of the quota. |
Returns: Any. Decoded JSON answer of the operation "Delete a quota".
Raises: the typed errors of the transport (Errors).
QuotasClient.list
list(**page: Any) -> Any
List the quotas. Quotas of the tenant by name, including those mirrored from the LLM projects (llm-project:...). One page only. Requires a reader role and a tenant principal.
Route: /v1/quotas (GET).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
**page | Any | no | Pagination options passed to the listing: limit (maximum number of items per page) and cursor (the next_cursor of the previous page). Iterating the returned page follows every cursor. |
Returns: Any. Decoded JSON answer of the operation "List the quotas".
Raises: the typed errors of the transport (Errors).
QuotasClient.release
release(reservation_id: str) -> Any
Release a reservation. Gives the reserved amount back to every quota window of the reservation without consuming anything (the call failed or was not made). A closed reservation answers 409 reservation_closed; an unknown one 404 reservation_not_found. Audited. Requires finops, tenant_admin, agent or developer, and a tenant principal.
Route: /v1/quotas/{reservation_id}/release (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
reservation_id | str | yes | Identifier (UUID) of the reservation. |
Returns: Any. Decoded JSON answer of the operation "Release a reservation".
Raises: the typed errors of the transport (Errors).
QuotasClient.replace
replace(quota_id: str, quota: dict[str, Any]) -> Any
Replace a quota. Replaces every field of a quota (same rules as on creation; without currency, the current one is kept). Unknown id: 404 quota_not_found. Audited. Requires finops or tenant_admin, and a tenant principal.
Route: /v1/quotas/{quota_id} (PUT).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
quota_id | str | yes | Identifier (UUID) of the quota. | |
quota | dict[str, Any] | yes | Initial quota of the project; the defaults of the quota apply when omitted. |
Returns: Any. Decoded JSON answer of the operation "Replace a quota".
Raises: the typed errors of the transport (Errors).
QuotasClient.reservation
reservation(cost: Any = '0', tokens: int = 0, **kwargs: Any) -> Iterator[Reservation]
Reserve, then commit on success or release on error (sync client).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
cost | Any | '0' | no | Cost to reserve, as a decimal string or number (default "0"). |
tokens | int | 0 | no | Number of tokens to reserve (default 0). |
**kwargs | Any | no | Options of reserve: scope, ttl_seconds, idempotency_key. |
Returns: Iterator[Reservation]. A Reservation: An open reservation. commit or release once.
QuotasClient.reserve
reserve(cost: number | string = '0', tokens: int = 0, scope: dict[str, Any] | None = None, ttl_seconds: int | None = None, idempotency_key: str | None = None) -> Any
Reserve cost and tokens. Reserves an amount on every enabled quota matching the scope (tenant quotas always match; a user principal adds its own user scope) and answers 201 with the reservation, its items per quota and window, the soft quotas exceeded and its expiry. A hard quota that would be exceeded answers 429 quota_exceeded with Retry-After: 60, and nothing is reserved. Expired reservations are released first. Audited. Requires finops, tenant_admin, agent or developer, and a tenant principal.
Route: /v1/quotas/reserve (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
cost | number | string | '0' | no | Cost to reserve in the tenant currency, 0 to 10^15, default 0; converted to the currency of each quota. |
tokens | int | 0 | no | Tokens to reserve, 0 to 2^62, default 0. |
scope | dict[str, Any] | None | None | no | Who the call is for: keys project, agent, user, model, provider, run (or the same with _id), matched against the quota scopes. |
ttl_seconds | int | None | None | no | Lifetime of the reservation in seconds, 1 to 86400; default the tenant reservation_ttl_seconds (900). An expired reservation is released. |
idempotency_key | str | None | None | no | Idempotency-Key header: a retry with the same key replays the first answer. |
Returns: Any. Decoded JSON answer of the operation "Reserve cost and tokens".
Raises: the typed errors of the transport (Errors).
QuotasClient.usage
usage(**filters: Any) -> Any
Read the quota consumption. Each quota of the tenant with its current window and the cost and tokens used and reserved in it. Run quotas need run to find their window. Requires a reader role and a tenant principal.
Route: /v1/quotas/usage (GET).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
**filters | Any | no | Query parameters such as agent, project or run. |
Returns: Any. Decoded JSON answer of the operation "Read the quota consumption".
Raises: the typed errors of the transport (Errors).