Skip to content
NewNexus 2.0 is here, and it’s open source. Read the launch post

API reference

Spend limits

Spend limits per person and calendar month (UTC), checked with the organization's balance when every call reserves (chat completions, the agent gateway, module runs, chat sessions). The organization sets a default limit per person and overrides per person, both stored at the organization; no default means no person limit. Owners and admins also cap a team per UTC day, week or month (PUT /v1/teams/{slug}/budget): the cap is a pool for the team and every team under it. A call that would go over a person limit, a team cap or the organization's budget is refused with 402 budget_exceeded, naming the level, and counted as an overspend prevented. The 402 says what is left for the caller; only a person's 402 also names its limit. Person limits reset on the 1st at 00:00 UTC.

View as Markdown

Get person budget

get/v1/people/{userId}/budget

One person's spend limit this month: their limit and where it comes from (override, default or none), month-to-date spend, what is left and whether they are at it. Yours (me) for anyone; anyone's for owners and admins.

spend.read_ownEvery memberTry it in the API Explorer

Parameters

  • userIdpath · stringrequired

    A user id, or me

Responses

200OKapplication/json

  • userIdstringrequired
  • emailstring
  • namestring
  • role"owner" | "admin" | "member"required
  • limitManagerboolean

    An admin an owner allowed to set person spend limits

  • limitUsdnumber | nullrequired

    Their limit this month; null: no limit of their own. Deprecated: read limitUsdDecimal, the exact decimal string (root rule 9).

  • limitUsdDecimalstring | null

    limitUsd as an exact decimal string in US dollars with six decimals ("12.245000"), from the micro-dollars. Prefer it to limitUsd.

  • source"override" | "default" | "none"required

    Override: set for them; default: the organization's default per person; none: no limit

  • overrideUsdnumber | nullrequired

    Their override, when they have one. Deprecated: read overrideUsdDecimal, the exact decimal string (root rule 9).

  • overrideUsdDecimalstring | null

    overrideUsd as an exact decimal string in US dollars with six decimals ("12.245000"), from the micro-dollars. Prefer it to overrideUsd.

  • spentUsdnumberrequired

    Settled since the 1st, 00:00 UTC, across every team they spend through. Deprecated: read spentUsdDecimal, the exact decimal string (root rule 9).

  • spentUsdDecimalstring

    spentUsd as an exact decimal string in US dollars with six decimals ("12.245000"), from the micro-dollars. Prefer it to spentUsd.

  • reservedUsdnumberrequired

    Held by their calls in flight. Deprecated: read reservedUsdDecimal, the exact decimal string (root rule 9).

  • reservedUsdDecimalstring

    reservedUsd as an exact decimal string in US dollars with six decimals ("12.245000"), from the micro-dollars. Prefer it to reservedUsd.

  • remainingUsdnumber | nullrequired

    Deprecated: read remainingUsdDecimal, the exact decimal string (root rule 9).

  • remainingUsdDecimalstring | null

    remainingUsd as an exact decimal string in US dollars with six decimals ("12.245000"), from the micro-dollars. Prefer it to remainingUsd.

  • atLimitbooleanrequired

    Spent and reserved reach the limit: their next call is refused

  • overspendsPreventedintegerrequired

    Calls a spend limit refused this month

403A member asking for another person's limit (`role_required`)application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

404No member with this user id in the organization (`not_found`)application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

Errors

StatusCodeWhen
401authentication_errorNo key, or a key Gateway does not accept
403role_requiredYour role does not have this permission
404not_foundNothing matches the path in your organization
404No member with this user id in the organization (`not_found`)
429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).
429rate_limit_errorToo many requests from this key in a minute

Example

curl
curl "$NEXUS_URL/v1/people/user_123/budget" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
TypeScript · @nexus/kit
import { createCoreClient } from "@nexus/kit";

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.personBudget();

Set person budget

put/v1/people/{userId}/budget

Set one person's monthly limit in USD, above or below the organization's default (owners, and admins an owner allowed: grantLimitManager; an owner's limit: owners only), or null to remove the override so the default applies again. Stored at the organization, naming the person; audited as budget.person_limit_changed, before and after. 403 limit_grant_required for an admin without the grant, and role_required for an owner's limit set by an allowed admin (both gateways). The amount is monthlyUsd (a number, deprecated, or a decimal string) or monthlyUsdDecimal, read exactly. 400 invalid_amount, too_many_decimals, amount_mismatch.

budgets.manageOwner, AdminTry it in the API Explorer

Parameters

  • userIdpath · stringrequired

    A user id, or me

  • Idempotency-Keyheader · string

    Send the same key again to retry safely: the request runs once. See Idempotency keys.

Request body · application/json

  • monthlyUsdnumber | string | null

    This person's monthly limit, in US dollars, at most 1000000: a JSON number (deprecated) or a decimal string with at most 6 decimals ("12.245"), read exactly; null removes the override. Send monthlyUsdDecimal instead to send only a string.

  • monthlyUsdDecimalstring | null

    This person's monthly limit as a decimal string in US dollars, at most 6 decimals, never below 0; read exactly into micro-dollars, never through a float. null removes the override. With monthlyUsd too, both must name the same amount (400 amount_mismatch).

    pattern ^[0-9]+(\.[0-9]{1,6})?$

Responses

200OKapplication/json

  • userIdstringrequired
  • emailstring
  • namestring
  • role"owner" | "admin" | "member"required
  • limitManagerboolean

    An admin an owner allowed to set person spend limits

  • limitUsdnumber | nullrequired

    Their limit this month; null: no limit of their own. Deprecated: read limitUsdDecimal, the exact decimal string (root rule 9).

  • limitUsdDecimalstring | null

    limitUsd as an exact decimal string in US dollars with six decimals ("12.245000"), from the micro-dollars. Prefer it to limitUsd.

  • source"override" | "default" | "none"required

    Override: set for them; default: the organization's default per person; none: no limit

  • overrideUsdnumber | nullrequired

    Their override, when they have one. Deprecated: read overrideUsdDecimal, the exact decimal string (root rule 9).

  • overrideUsdDecimalstring | null

    overrideUsd as an exact decimal string in US dollars with six decimals ("12.245000"), from the micro-dollars. Prefer it to overrideUsd.

  • spentUsdnumberrequired

    Settled since the 1st, 00:00 UTC, across every team they spend through. Deprecated: read spentUsdDecimal, the exact decimal string (root rule 9).

  • spentUsdDecimalstring

    spentUsd as an exact decimal string in US dollars with six decimals ("12.245000"), from the micro-dollars. Prefer it to spentUsd.

  • reservedUsdnumberrequired

    Held by their calls in flight. Deprecated: read reservedUsdDecimal, the exact decimal string (root rule 9).

  • reservedUsdDecimalstring

    reservedUsd as an exact decimal string in US dollars with six decimals ("12.245000"), from the micro-dollars. Prefer it to reservedUsd.

  • remainingUsdnumber | nullrequired

    Deprecated: read remainingUsdDecimal, the exact decimal string (root rule 9).

  • remainingUsdDecimalstring | null

    remainingUsd as an exact decimal string in US dollars with six decimals ("12.245000"), from the micro-dollars. Prefer it to remainingUsd.

  • atLimitbooleanrequired

    Spent and reserved reach the limit: their next call is refused

  • overspendsPreventedintegerrequired

    Calls a spend limit refused this month

400`monthlyUsd` and `monthlyUsdDecimal` both missing (`invalid_request`), a decimal string with more than 6 decimals (`too_many_decimals`), an amount that is not one, is below 0 or is above 1000000 (`invalid_amount`), or a number and its `Decimal` twin that name different amounts, or `null` beside an amount (`amount_mismatch`)application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

403A member (`role_required`), an admin an owner has not allowed (`limit_grant_required`), or an allowed admin setting an owner's limit (`role_required`)application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

404No member with this user id in the organization (`not_found`)application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

Errors

StatusCodeWhen
400invalid_request_errorA field is missing or not valid; the message names it
400`monthlyUsd` and `monthlyUsdDecimal` both missing (`invalid_request`), a decimal string with more than 6 decimals (`too_many_decimals`), an amount that is not one, is below 0 or is above 1000000 (`invalid_amount`), or a number and its `Decimal` twin that name different amounts, or `null` beside an amount (`amount_mismatch`)
400invalid_amount400 `invalid_amount`, `too_many_decimals`, `amount_mismatch`
401authentication_errorNo key, or a key Gateway does not accept
403role_requiredYour role does not have this permission
403limit_grant_required403 `limit_grant_required` for an admin without the grant, and `role_required` for an owner's limit set by an allowed admin (both gateways)
404not_foundNothing matches the path in your organization
404No member with this user id in the organization (`not_found`)
409idempotency_in_progressA request with the same Idempotency-Key is still running
409idempotency_interruptedThe first request with this Idempotency-Key was cut off and may have run in part
422idempotency_key_reusedThe Idempotency-Key was used with a different request
429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).
429rate_limit_errorToo many requests from this key in a minute

Example

curl
curl -X PUT "$NEXUS_URL/v1/people/user_123/budget" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
TypeScript · @nexus/kit
import { createCoreClient } from "@nexus/kit";

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.setPersonBudget("<user id>", 200);

List budgets

get/v1/budgets

Spend limits this month: the organization's default per person and, for owners and admins, every person's limit (override or default), month-to-date spend, what is left, whether they are at their limit and the overspends prevented. Members see only their own row. canManage: you may set a person's limit (an owner, or an admin an owner allowed); canGrant: you may set the default per person and allow admins to set person limits (owners).

spend.read_ownEvery memberTry it in the API Explorer

Responses

200OKapplication/json

  • periodstringrequired

    The calendar month (UTC)

  • periodStartstring (date-time)required
  • resetsAtstring (date-time)required

    The 1st of next month, 00:00 UTC

  • personDefaultobjectrequired
    • monthlyUsdnumber | nullrequired

      Deprecated: read monthlyUsdDecimal, the exact decimal string (root rule 9).

    • monthlyUsdDecimalstring | null

      monthlyUsd as an exact decimal string in US dollars with six decimals ("12.245000"), from the micro-dollars. Prefer it to monthlyUsd.

    • updatedAtstring (date-time)
    • updatedBystring
  • scope"org" | "own"required

    Org: everyone (owners and admins); own: only you

  • peoplearray of PersonBudgetrequired
    • userIdstringrequired
    • emailstring
    • namestring
    • role"owner" | "admin" | "member"required
    • limitManagerboolean

      An admin an owner allowed to set person spend limits

    • limitUsdnumber | nullrequired

      Their limit this month; null: no limit of their own. Deprecated: read limitUsdDecimal, the exact decimal string (root rule 9).

    • limitUsdDecimalstring | null

      limitUsd as an exact decimal string in US dollars with six decimals ("12.245000"), from the micro-dollars. Prefer it to limitUsd.

    • source"override" | "default" | "none"required

      Override: set for them; default: the organization's default per person; none: no limit

    • overrideUsdnumber | nullrequired

      Their override, when they have one. Deprecated: read overrideUsdDecimal, the exact decimal string (root rule 9).

    • overrideUsdDecimalstring | null

      overrideUsd as an exact decimal string in US dollars with six decimals ("12.245000"), from the micro-dollars. Prefer it to overrideUsd.

    • spentUsdnumberrequired

      Settled since the 1st, 00:00 UTC, across every team they spend through. Deprecated: read spentUsdDecimal, the exact decimal string (root rule 9).

    • spentUsdDecimalstring

      spentUsd as an exact decimal string in US dollars with six decimals ("12.245000"), from the micro-dollars. Prefer it to spentUsd.

    • reservedUsdnumberrequired

      Held by their calls in flight. Deprecated: read reservedUsdDecimal, the exact decimal string (root rule 9).

    • reservedUsdDecimalstring

      reservedUsd as an exact decimal string in US dollars with six decimals ("12.245000"), from the micro-dollars. Prefer it to reservedUsd.

    • remainingUsdnumber | nullrequired

      Deprecated: read remainingUsdDecimal, the exact decimal string (root rule 9).

    • remainingUsdDecimalstring | null

      remainingUsd as an exact decimal string in US dollars with six decimals ("12.245000"), from the micro-dollars. Prefer it to remainingUsd.

    • atLimitbooleanrequired

      Spent and reserved reach the limit: their next call is refused

    • overspendsPreventedintegerrequired

      Calls a spend limit refused this month

  • canManagebooleanrequired

    You may set a person's limit: an owner, or an admin an owner allowed (both gateways)

  • canGrantboolean

    You may set the default per person and allow admins to set person limits: owners

429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

Errors

StatusCodeWhen
401authentication_errorNo key, or a key Gateway does not accept
403role_requiredYour role does not have this permission
429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).
429rate_limit_errorToo many requests from this key in a minute

Example

curl
curl "$NEXUS_URL/v1/budgets" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
TypeScript · @nexus/kit
import { createCoreClient } from "@nexus/kit";

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.budgets();

Set person default budget

put/v1/budgets/person-default

Set the organization's default monthly limit per person in USD (owners only), or null to clear it: then people without an override have no limit of their own. Audited as budget.person_default_changed, before and after. 403 role_required for an admin an owner allowed (only an owner changes the default per person), and limit_grant_required for an admin without the grant (both gateways). The amount is monthlyUsd (a number, deprecated, or a decimal string) or monthlyUsdDecimal, read exactly. 400 invalid_amount, too_many_decimals, amount_mismatch.

budgets.manageOwner, AdminTry it in the API Explorer

Parameters

  • Idempotency-Keyheader · string

    Send the same key again to retry safely: the request runs once. See Idempotency keys.

Request body · application/json

  • monthlyUsdnumber | string | null

    The default monthly limit per person, in US dollars, at most 1000000: a JSON number (deprecated) or a decimal string with at most 6 decimals ("12.245"), read exactly; null clears it. Send monthlyUsdDecimal instead to send only a string.

  • monthlyUsdDecimalstring | null

    The default monthly limit per person as a decimal string in US dollars, at most 6 decimals, never below 0; read exactly into micro-dollars, never through a float. null clears it. With monthlyUsd too, both must name the same amount (400 amount_mismatch).

    pattern ^[0-9]+(\.[0-9]{1,6})?$

Responses

200OKapplication/json

  • periodstringrequired

    The calendar month (UTC)

  • periodStartstring (date-time)required
  • resetsAtstring (date-time)required

    The 1st of next month, 00:00 UTC

  • personDefaultobjectrequired
    • monthlyUsdnumber | nullrequired

      Deprecated: read monthlyUsdDecimal, the exact decimal string (root rule 9).

    • monthlyUsdDecimalstring | null

      monthlyUsd as an exact decimal string in US dollars with six decimals ("12.245000"), from the micro-dollars. Prefer it to monthlyUsd.

    • updatedAtstring (date-time)
    • updatedBystring
  • scope"org" | "own"required

    Org: everyone (owners and admins); own: only you

  • peoplearray of PersonBudgetrequired
    • userIdstringrequired
    • emailstring
    • namestring
    • role"owner" | "admin" | "member"required
    • limitManagerboolean

      An admin an owner allowed to set person spend limits

    • limitUsdnumber | nullrequired

      Their limit this month; null: no limit of their own. Deprecated: read limitUsdDecimal, the exact decimal string (root rule 9).

    • limitUsdDecimalstring | null

      limitUsd as an exact decimal string in US dollars with six decimals ("12.245000"), from the micro-dollars. Prefer it to limitUsd.

    • source"override" | "default" | "none"required

      Override: set for them; default: the organization's default per person; none: no limit

    • overrideUsdnumber | nullrequired

      Their override, when they have one. Deprecated: read overrideUsdDecimal, the exact decimal string (root rule 9).

    • overrideUsdDecimalstring | null

      overrideUsd as an exact decimal string in US dollars with six decimals ("12.245000"), from the micro-dollars. Prefer it to overrideUsd.

    • spentUsdnumberrequired

      Settled since the 1st, 00:00 UTC, across every team they spend through. Deprecated: read spentUsdDecimal, the exact decimal string (root rule 9).

    • spentUsdDecimalstring

      spentUsd as an exact decimal string in US dollars with six decimals ("12.245000"), from the micro-dollars. Prefer it to spentUsd.

    • reservedUsdnumberrequired

      Held by their calls in flight. Deprecated: read reservedUsdDecimal, the exact decimal string (root rule 9).

    • reservedUsdDecimalstring

      reservedUsd as an exact decimal string in US dollars with six decimals ("12.245000"), from the micro-dollars. Prefer it to reservedUsd.

    • remainingUsdnumber | nullrequired

      Deprecated: read remainingUsdDecimal, the exact decimal string (root rule 9).

    • remainingUsdDecimalstring | null

      remainingUsd as an exact decimal string in US dollars with six decimals ("12.245000"), from the micro-dollars. Prefer it to remainingUsd.

    • atLimitbooleanrequired

      Spent and reserved reach the limit: their next call is refused

    • overspendsPreventedintegerrequired

      Calls a spend limit refused this month

  • canManagebooleanrequired

    You may set a person's limit: an owner, or an admin an owner allowed (both gateways)

  • canGrantboolean

    You may set the default per person and allow admins to set person limits: owners

400`monthlyUsd` and `monthlyUsdDecimal` both missing (`invalid_request`), a decimal string with more than 6 decimals (`too_many_decimals`), an amount that is not one, is below 0 or is above 1000000 (`invalid_amount`), or a number and its `Decimal` twin that name different amounts, or `null` beside an amount (`amount_mismatch`)application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

403A member (`role_required`), an admin an owner has not allowed (`limit_grant_required`), or an allowed admin (`role_required`: only an owner changes the default per person)application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

Errors

StatusCodeWhen
400invalid_request_errorA field is missing or not valid; the message names it
400`monthlyUsd` and `monthlyUsdDecimal` both missing (`invalid_request`), a decimal string with more than 6 decimals (`too_many_decimals`), an amount that is not one, is below 0 or is above 1000000 (`invalid_amount`), or a number and its `Decimal` twin that name different amounts, or `null` beside an amount (`amount_mismatch`)
400invalid_amount400 `invalid_amount`, `too_many_decimals`, `amount_mismatch`
401authentication_errorNo key, or a key Gateway does not accept
403role_requiredYour role does not have this permission
409idempotency_in_progressA request with the same Idempotency-Key is still running
409idempotency_interruptedThe first request with this Idempotency-Key was cut off and may have run in part
422idempotency_key_reusedThe Idempotency-Key was used with a different request
429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).
429rate_limit_errorToo many requests from this key in a minute

Example

curl
curl -X PUT "$NEXUS_URL/v1/budgets/person-default" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
TypeScript · @nexus/kit
import { createCoreClient } from "@nexus/kit";

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.setPersonDefaultBudget(50);

Get product budget

get/v1/budgets/products/{product}/{capability}

The monthly cap on one module capability, such as Nexus Review's robustness / review (owners and admins): its limit, the UTC month's spend of every call attributed to it (whoever paid the provider), what open calls hold, what is left and when it resets. Every amount is a decimal string. cap is null when the capability has none. 400 invalid_product.

spend.read_allOwner, AdminTry it in the API Explorer

Parameters

  • productpath · stringrequired

    The module's product, as its calls are attributed (robustness for Nexus Review).

  • capabilitypath · stringrequired

    The capability within it (review).

Responses

200OKapplication/json

  • productstringrequired
  • capabilitystringrequired
  • capobject | nullrequired
    • limitUsdstringrequired

      The budget's amount for its period.

      pattern ^[0-9]+\.[0-9]{6}$

    • every"day" | "week" | "month"required

      The budget's period, in UTC: a day, an ISO week from Monday, or a calendar month.

    • monthlyUsdstringrequired

      The budget's amount whatever its period; read limitUsd and every instead.

      pattern ^[0-9]+\.[0-9]{6}$

    • periodstringrequired

      The period: YYYY-MM-DD for a day, YYYY-Www for a week, YYYY-MM for a month.

    • spentUsdstringrequired

      pattern ^[0-9]+\.[0-9]{6}$

    • feesUsdstringrequired

      The product's own fees this month (POST /v1/budgets/usage), part of spentUsd.

      pattern ^[0-9]+\.[0-9]{6}$

    • reservedUsdstringrequired

      pattern ^[0-9]+\.[0-9]{6}$

    • remainingUsdstringrequired

      pattern ^[0-9]+\.[0-9]{6}$

    • resetsAtstring (date-time)required
    • updatedAtstring (date-time)required
  • canManagebooleanrequired

400Not a product or capability slug (`invalid_product`)application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

403Only owners and admins read a product's cap (`role_required`): a member without `spend.read_all`application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

Errors

StatusCodeWhen
400Not a product or capability slug (`invalid_product`)
400invalid_product400 `invalid_product`
401authentication_errorNo key, or a key Gateway does not accept
403role_requiredYour role does not have this permission
404not_foundNothing matches the path in your organization
429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).
429rate_limit_errorToo many requests from this key in a minute

Example

curl
curl "$NEXUS_URL/v1/budgets/products/<product>/<capability>" \
  -H "Authorization: Bearer $NEXUS_API_KEY"

Set product budget

put/v1/budgets/products/{product}/{capability}

Set or remove the monthly cap on one module capability (owners and admins). monthlyUsd is a decimal string in US dollars, or null to remove the cap. The ledger refuses a call that would take the capability's UTC month past it with 402 budget_exceeded, details.level: product; a cap cut below what the month used refuses the next call and leaves calls in progress alone. Audited as budget.product_changed, before and after. 400 invalid_amount, too_many_decimals, invalid_product.

budgets.manageOwner, AdminTry it in the API Explorer

Parameters

  • productpath · stringrequired

    The module's product, as its calls are attributed (robustness for Nexus Review).

  • capabilitypath · stringrequired

    The capability within it (review).

  • Idempotency-Keyheader · string

    Send the same key again to retry safely: the request runs once. See Idempotency keys.

Request body · application/json

  • limitUsdstring | null

    pattern ^[0-9]+(\.[0-9]{1,6})?$

  • every"day" | "week" | "month"

    Required with limitUsd.

  • monthlyUsdstring | null

    A monthly budget. Not with limitUsd.

    pattern ^[0-9]+(\.[0-9]{1,6})?$

Responses

200OKapplication/json

  • productstringrequired
  • capabilitystringrequired
  • beforeobjectrequired
    • limitUsdstring | nullrequired

      pattern ^[0-9]+\.[0-9]{6}$

    • every"day" | "week" | "month" | nullrequired
    • monthlyUsdstring | nullrequired

      pattern ^[0-9]+\.[0-9]{6}$

  • afterobjectrequired
    • limitUsdstring | nullrequired

      pattern ^[0-9]+\.[0-9]{6}$

    • every"day" | "week" | "month" | nullrequired
    • monthlyUsdstring | nullrequired

      pattern ^[0-9]+\.[0-9]{6}$

400Not a valid cap (`invalid_amount`), a decimal string with more than 6 decimals (`too_many_decimals`), or not a slug (`invalid_product`)application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

403Members: only owners and admins set a cap (`role_required`)application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

Errors

StatusCodeWhen
400invalid_request_errorA field is missing or not valid; the message names it
400Not a valid cap (`invalid_amount`), a decimal string with more than 6 decimals (`too_many_decimals`), or not a slug (`invalid_product`)
400invalid_amount400 `invalid_amount`, `too_many_decimals`, `invalid_product`
401authentication_errorNo key, or a key Gateway does not accept
402budget_exceededThe ledger refuses a call that would take the capability's UTC month past it with 402 `budget_exceeded`, `details.level: product`; a cap cut below what the month used refuses the next call and leaves calls in progress alone
403role_requiredYour role does not have this permission
404not_foundNothing matches the path in your organization
409idempotency_in_progressA request with the same Idempotency-Key is still running
409idempotency_interruptedThe first request with this Idempotency-Key was cut off and may have run in part
422idempotency_key_reusedThe Idempotency-Key was used with a different request
429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).
429rate_limit_errorToo many requests from this key in a minute

Example

curl
curl -X PUT "$NEXUS_URL/v1/budgets/products/<product>/<capability>" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "limitUsd": "<limitUsd>",
    "every": "day",
    "monthlyUsd": "<monthlyUsd>"
  }'

Get product usage

get/v1/budgets/usage

A module's product cap this UTC month and the price of each unit it records (a module's scoped key only). The product and capability are the key's. cap is null without a cap, else as GET /v1/budgets/products/{product}/{capability} shows it. Nexus Review reads it before its first model call and pauses a run the cap has no room for.

models.useEvery member, module keysTry it in the API Explorer

Responses

200OKapplication/json

  • productstringrequired
  • capabilitystringrequired
  • capobject | nullrequired

    Null without a cap, else as GET /v1/budgets/products/{product}/{capability} shows it.

    • limitUsdstringrequired

      The budget's amount for its period.

      pattern ^[0-9]+\.[0-9]{6}$

    • every"day" | "week" | "month"required

      The budget's period, in UTC: a day, an ISO week from Monday, or a calendar month.

    • monthlyUsdstringrequired

      The budget's amount whatever its period; read limitUsd and every instead.

      pattern ^[0-9]+\.[0-9]{6}$

    • periodstringrequired

      The period: YYYY-MM-DD for a day, YYYY-Www for a week, YYYY-MM for a month.

    • spentUsdstringrequired

      pattern ^[0-9]+\.[0-9]{6}$

    • feesUsdstringrequired

      The product's own fees this month (POST /v1/budgets/usage), part of spentUsd.

      pattern ^[0-9]+\.[0-9]{6}$

    • reservedUsdstringrequired

      pattern ^[0-9]+\.[0-9]{6}$

    • remainingUsdstringrequired

      pattern ^[0-9]+\.[0-9]{6}$

    • resetsAtstring (date-time)required
    • updatedAtstring (date-time)required
  • unitPricesUsdobjectrequired

    The price of one of each unit the product records (review for Nexus Review).

403Not a module's scoped key (`module_key_required`): a use belongs to the module that made itapplication/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

Errors

StatusCodeWhen
401authentication_errorNo key, or a key Gateway does not accept
403role_requiredYour role does not have this permission
429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).
429rate_limit_errorToo many requests from this key in a minute

Example

curl
curl "$NEXUS_URL/v1/budgets/usage" \
  -H "Authorization: Bearer $NEXUS_API_KEY"

Record product usage

post/v1/budgets/usage

Record one use of the key's product, such as one pull request Nexus Review reviewed (a module's scoped key only). The Gateway prices it (NEXUS_PRICE_REVIEW_PR_MICROS for Nexus Review's review, 0 by default), and the month's amounts count in the product cap. The row is append-only and keyed by usageKey: a repeat with the same unit and quantity answers the stored row with recorded: false, and a repeat that differs is a 409.

models.useEvery member, module keysTry it in the API Explorer

Request body · application/json

  • usageKeystringrequired

    One per use: Nexus Review sends <owner>/<repo>#<pr>.

    pattern ^[A-Za-z0-9._/#@-]{1,200}$

  • unitstringrequired

    What was used: review for Nexus Review.

  • quantityinteger

    min 1 · max 1000 · default 1

Responses

200OKapplication/json

  • idstringrequired
  • productstringrequired
  • capabilitystringrequired
  • usageKeystringrequired
  • unitstringrequired
  • quantityintegerrequired
  • unitPriceUsdstringrequired

    pattern ^[0-9]+\.[0-9]{6}$

  • amountUsdstringrequired

    pattern ^[0-9]+\.[0-9]{6}$

  • atstring (date-time)required
  • recordedbooleanrequired

    False when the usage key was already recorded: this is the stored row.

400Not a usage key (`invalid_usage_key`), a unit the product records (`unknown_unit`), a quantity from 1 to 1000 (`invalid_quantity`), or an amount over $1,000 (`amount_too_large`)application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

403Not a module's scoped key (`module_key_required`): a use belongs to the module that made itapplication/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

409The usage key was already recorded with another unit or quantity (`usage_conflict`)application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

Errors

StatusCodeWhen
400invalid_request_errorA field is missing or not valid; the message names it
400Not a usage key (`invalid_usage_key`), a unit the product records (`unknown_unit`), a quantity from 1 to 1000 (`invalid_quantity`), or an amount over $1,000 (`amount_too_large`)
401authentication_errorNo key, or a key Gateway does not accept
403role_requiredYour role does not have this permission
409The usage key was already recorded with another unit or quantity (`usage_conflict`)
429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).
429rate_limit_errorToo many requests from this key in a minute

Example

curl
curl -X POST "$NEXUS_URL/v1/budgets/usage" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "usageKey": "<usageKey>",
    "unit": "<unit>"
  }'

Grant limit manager

put/v1/budgets/limit-managers/{userId}

Allow an admin to set each person's spend limit, but not an owner's and not the default per person (owners only; owners always can). The grant is on the admin's membership: it ends when they stop being an admin or leave, and does not come back when they return. Granting an admin who has it writes nothing. Audited as budget.limit_manager_granted, limitManager before and after, ids only. 409 not_an_admin for an owner, a team lead or a member.

budgets.delegateOwnerTry it in the API Explorer

Parameters

  • userIdpath · stringrequired

    A user id, or me

  • Idempotency-Keyheader · string

    Send the same key again to retry safely: the request runs once. See Idempotency keys.

Responses

200OKapplication/json

  • userIdstringrequired
  • limitManagerbooleanrequired

403Not an owner (`role_required`)application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

404No such memberapplication/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

409The person is not an admin (`not_an_admin`)application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

Errors

StatusCodeWhen
401authentication_errorNo key, or a key Gateway does not accept
403role_requiredYour role does not have this permission
404not_foundNothing matches the path in your organization
404No such member
409The person is not an admin (`not_an_admin`)
409not_an_admin409 `not_an_admin` for an owner, a team lead or a member
409idempotency_in_progressA request with the same Idempotency-Key is still running
409idempotency_interruptedThe first request with this Idempotency-Key was cut off and may have run in part
422idempotency_key_reusedThe Idempotency-Key was used with a different request
429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).
429rate_limit_errorToo many requests from this key in a minute

Example

curl
curl -X PUT "$NEXUS_URL/v1/budgets/limit-managers/user_123" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
TypeScript · @nexus/kit
import { createCoreClient } from "@nexus/kit";

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.grantLimitManager("<user id>");

Revoke limit manager

DEL/v1/budgets/limit-managers/{userId}

Stop an admin setting person spend limits (owners only). The limits they set stay. Revoking from someone without the grant writes nothing. Audited as budget.limit_manager_revoked, limitManager before and after, ids only.

budgets.delegateOwnerTry it in the API Explorer

Parameters

  • userIdpath · stringrequired

    A user id, or me

  • Idempotency-Keyheader · string

    Send the same key again to retry safely: the request runs once. See Idempotency keys.

Responses

200OKapplication/json

  • userIdstringrequired
  • limitManagerbooleanrequired

403Not an owner (`role_required`)application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

404No such memberapplication/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

Errors

StatusCodeWhen
401authentication_errorNo key, or a key Gateway does not accept
403role_requiredYour role does not have this permission
404not_foundNothing matches the path in your organization
404No such member
409idempotency_in_progressA request with the same Idempotency-Key is still running
409idempotency_interruptedThe first request with this Idempotency-Key was cut off and may have run in part
422idempotency_key_reusedThe Idempotency-Key was used with a different request
429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).
429rate_limit_errorToo many requests from this key in a minute

Example

curl
curl -X DELETE "$NEXUS_URL/v1/budgets/limit-managers/user_123" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
TypeScript · @nexus/kit
import { createCoreClient } from "@nexus/kit";

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.revokeLimitManager("<user id>");