Skip to content

Billing and projects

Funding and usage

Read funding, orders, paid lots, usage and refunds, quote a run, and raise Company budget ceilings. Billing is a shared platform foundation, not a product API.

Local preview

Local preview only, contract 1. Fixture tariffs and confirmations do not prove live payments. The broader export and deletion lifecycle is not established.

Quickstart

Call billing from a trusted backend with a project credential and scope headers. Amounts are integer USD microdollars (USD1 = 1,000,000); times are UTC Unix milliseconds.

Headers
Authorization: Bearer <project credential>
X-Roye-Project: <projectId>
X-Roye-Environment: development
Roye-Contract-Version: 1
Content-Type: application/json

Each thin SDK method maps to one route.

billing.ts
import { Roye } from '@roye-ai/client';
const roye = new Roye({ baseURL, projectId, environment: 'development', token });
const preview = await roye.billing.preview();
const status = await roye.billing.status();
const quote = await roye.billing.quote({
  mode: definition.mode,
  participants: definition.participants.map(({ id, model, maxOutputTokens }) => ({ id, model, maxOutputTokens })),
});
const usage = await roye.billing.usage.list({ limit: 25 });
const runBill = await roye.billing.usage.getRoundtableRun(runId);
const executionBill = await roye.billing.usage.getAgentExecution(executionId);
const evaluationBill = await roye.billing.usage.getEvaluationRun(evaluationRunId);
const budget = await roye.billing.companyBudgets.get(companyId);

Authentication and scope

  • Calls use current project management authority, rechecked on replay. Keep backend keys out of browsers. Without Roye-Contract-Version you get contract 1.
  • Redeeming a code needs the organization owner's console sign-in.
  • Roye staff record payments, refund outcomes and funding control under a restricted authority that no customer credential confers.

Response fields

Orders, lots, grants, refunds and usage also have id and scope.

ResourceFields
Statuscurrency, fundingState, reason, supportEmail, packsUsd, available/held/refundHeld/used/expired/refundedMicros, expiryPending, liabilityState
OrderorganizationId, packUsd, amountMicros, currency, state, lotId, created/confirmedAt
Paid lotorderId, purchasedAt, expiresAt, granted/available/held/used/refundHeld/refunded/expired/reversedMicros
Promotional grantcurrency, grantedAt, expiresAt, granted/available/held/used/expiredMicros
RefundlotId, orderId, amount/payout/roundingCost/originalRoutePayout/residualMicros, state, route, requested/due/escalate/updatedAt, originalRouteUntil
Usagesource, deprecated original, currency, maximum/held/charged/releasedMicros, pricing (only for originals of up to eight participants), state (reserved/pending/settled/waived), reason (completed/cancelled/failed/unknown_deadline or null), companyId, created/release/settledAt
Company budgetcompanyId, scope, currency, limit/packageLimit/held/chargedMicros, revision, created/updatedAt
  • Creating an order, refund or redemption returns 201 and reads return 200, as bare resource objects.
  • Server policy sets packUsd, packsUsd, supportEmail, the preview limits and the refund route. Keep unseen values, here and in usage source; requests accept only listed ones.

Quotes

POST /v1/billing/quote is read-only: it reserves nothing and grants no permission to run.

ShapeBody
Roundtable (no module, or roundtable)mode (single, opening, parallel) and 1 to 8 unique participants with id, model, maxOutputTokens. single takes one.
Agents (module: "agents")profile, model and maxOutputTokens (its defaults.maxOutputTokens) of the definition revision you will run. Prices one participant, agent.

The response has maximumMicros, policyRevision and each participant's model, tariff revision, cache semantics, token bounds and rational unitMicros rates. An Agents quote's maximumMicros equals the execution's hold after admission while catalog and policy are unchanged.

quote.http
POST /v1/billing/quote
{"module":"agents","profile":{"id":"structured","revision":"1"},
 "model":"<definition model>","maxOutputTokens":1024}
quote.ts
// revision: the Agents definition revision the execution will run
const quote = await roye.billing.quote({
  module: 'agents',
  profile: revision.profile,
  model: revision.model,
  maxOutputTokens: revision.defaults.maxOutputTokens,
});
// After admission the execution holds the same maximum.
const bill = await roye.billing.usage.getAgentExecution(executionId);
// bill.maximumMicros === quote.maximumMicros
// bill.source: { module: 'agents', type: 'execution', id: executionId }

An unlisted Agents profile or other module returns unsupported_capability; a missing verified price or funded goodwill returns not_ready.

Packs, lots and grants

  • Default packs are USD 10, 30 and 100 (packsUsd), of equal value. No subscription or automatic top-up.
  • An order collects no funds and grants no credit. A confirmed order's paid lot expires 12 UTC calendar months after purchase (February 29 clamps to 28); delays, retries and recreation never extend it.
  • Promotional grants are separate, nonrefundable credit with no purchase path, and expire one UTC calendar year after grant. Usage spends eligible grants first.
  • The credits list's purchasesAvailable, not a grant, says whether paid orders are open.
  • expiryPending and liabilityState: blocked are explicit containment states.

Refunds

A refund request reserves unused, unheld paid money on the original lot. accepted does not mean paid.

RuleValue
EligibilityWithin 150 days of purchase.
TargetFive UTC business days, Monday to Friday.
EscalationPurchase day 165, or earlier on a known denial or unavailability.
Original routePayPal's 180-day limit never writes off the obligation.
RoundingPayouts round up to cents; Roye funds the fraction.
ResidualoriginalRoutePayoutMicros is the original route's capacity. residualMicros stays owed, never silently paid there or discarded.
Pending or unknownNo duplicate payment.
Bank fallbackNeeds consent, the original payer as verified beneficiary, proof the original cannot complete, and separate transfer authority.
ReversalPreserves obligations.
SupportEmail only, support@roye.ai. First response target: two UTC business days.

Company budgets

  • Each Company has a shared lifetime ceiling and a per-package ceiling, USD 5 each by default, apart from supplier safety caps. No calendar reset, top-up or lowering; totals are projections, not charges.
  • Only the organization owner with current project authority can raise them, even on replay. Send whole micros and the current expectedRevision (a stale one returns 409 revision_conflict); only increases are accepted.

Endpoints

Paths start with /v1/billing except the preview. POSTs except the quote take an idempotencyKey.

RoutePurpose
GET /v1/projects/:projectId/:environment/billing/previewLifetime units, content bytes, occupied Company and staff places.
GET /statusFunding status and balances.
GET /credits[/:id]Promotional grants.
POST /redemptionsRedeems a code; returns redemption and credit.
POST /ordersOrders a listed pack.
GET /orders[/:id]Orders.
GET /lots[/:id]Paid lots.
POST /refundsRequests amountMicros above 0 from lotId.
GET /refunds[/:id]Refunds.
GET /usage[/:id]Original usage.
GET /usage/roundtable/:runIdUsage of one Roundtable run.
GET /usage/agents/:executionIdUsage of one Agents execution.
GET /usage/evaluations/:runIdUsage of one Evaluations run. not_found for a run that planned no model call.
GET /company-budgets/:companyIdCompany ceilings.
POST /company-budgets/:companyId/raiseexpectedRevision, limitMicros, packageLimitMicros.
POST /quoteExact rates and a conservative maximum.

SDK mutations persist and recover intents like other platform operations; the SDK executes no payment.

funding.ts
const order = await roye.billing.orders.create({ packUsd: 10, idempotencyKey: 'purchase-1' });
const lots = await roye.billing.lots.list({ limit: 25 });
// Use a verified original lot ID; acceptance reserves funds, it does not send money.
const refund = await roye.billing.refunds.request({
  lotId: originalLotId, amountMicros: 1000000, idempotencyKey: 'refund-1',
});

Limits

LimitValue
Listslimit 1 to 25, opaque cursor up to 512 characters passed back unchanged; pages return items and next.
Identifiers1 to 80 URL-safe characters; references and reasons 1 to 120.
Quote outputmaxOutputTokens 1 to 2,048.
Project preview1,000 original units and 10 MiB of content, shared by both environments.
Company and staffOne active Company and four staff places (proposed, hired, suspended or ending); withdrawn or ended ones free theirs.

Unknown body fields and repeated or unsupported queries are refused.

Errors

Errors use the common envelope. Missing and inaccessible resources both return not_found; neither an error nor an empty page proves zero supplier exposure.

CodeHTTPWhat to do
invalid_request, bounds_exceeded, payload_limit400, 400, 413Fix micros, pack, paging or headers.
contract_version_unsupported, unsupported_capability400Use a served contract or capability.
unauthorized, credential_expired, credential_revoked, forbidden, authority_revoked401, 403Get current scoped authority.
not_found404Check the scoped ID; do not probe other tenants.
idempotency_conflict409Recover the original input; never reuse a key for new input.
invalid_transition, binding_invalid, effect_unresolved409Check original evidence. A pending or unknown payout blocks fallback until its route is denied.
budget_exhausted, not_ready409Read status, unheld funds, liability and the original lot.
operation_pending, operation_replay_expired202, 410Observe or recover the original with its key.
rate_limited, unavailable429, 503Retry only as permitted, with the same input and key.
promotion_unavailable, promotion_already_redeemed409Paused, expired or used up, or already redeemed by this organization or user. Nothing more is credited.

Recovery

Before sending, persist the project, environment, module platform, kind, target, idempotencyKey and exact input.

KindTarget
billing.orders.createEmpty
billing.redemptions.createEmpty
billing.refunds.requestOriginal lotId
billing.company_budgets.raisecompanyId
  • Same key and input replay the original with Roye-Replayed: true; changed input conflicts.
  • After a lost response, call operations.recover with the original scope and target first. Keep the key, body and revision.
  • No response or unknown state never justifies a replacement payment or refund.
  • Permanent originals replay even after operation history expires, without replenishing usage.
recovery.http
POST /v1/operations/recover
{"module":"platform","kind":"billing.refunds.request",
 "target":{"lotId":"<originalLotId>"},"idempotencyKey":"refund-1"}

POST /v1/billing/refunds
{"idempotencyKey":"refund-1","lotId":"<originalLotId>","amountMicros":1000000}

Usage

A usage row is one customer original, apart from supplier liabilities. It keeps the frozen pricing snapshot only when the original has at most eight participants; a larger original, such as an Evaluations run of more than eight calls, has no pricing. source is open: { module: "roundtable", type: "run", id } for a Roundtable run, { module: "agents", type: "execution", id } for an Agents execution and { module: "evaluations", type: "run", id } for an Evaluations run. Other module codes may appear.

Unknown customer holds release as Roye-funded goodwill by the original 72-hour ceiling. Supplier unknowns stay preserved, and late facts never recreate the debit.

The no-model preview counts each productive mutation once: each Communication recipient delivery, each Automation productive entry. Bounded copies count once; new content needs admission. Deletion, replay and time never refill it. Reads, stop and cleanup stay available; the preview creates no charge or model entitlement.