import type { BillingOrigin } from "@opengeni/contracts"; import type { Database } from "./database.js"; import { type CreditUsage } from "./credit-balances.js"; /** * How long a stateless model call's credit hold counts. A call deletes its * hold when it settles or fails; this bounds a hold left behind by a process * that stopped mid-call. It is far longer than any single call runs. */ export declare const MODEL_CALL_CREDIT_HOLD_WINDOW_SECONDS: number; export type ModelCallCreditReservation = { reserved: boolean; /** The credit policy revision the balance was read at, for settlement. */ creditPolicyRevision: number | undefined; }; /** * Reserve the maximum priced cost of one stateless Opengeni-credit model call * before its provider request. Under the account advisory lock that model * settlement takes, the call is admitted only when the spendable balance * minus every other live hold on the account covers `amountMicros`; the hold * is then recorded under the call's request id. Calls running at the same * time therefore cannot together be admitted for more than the balance. * Expired holds on the account are removed on the way. */ export declare function reserveModelCallCredits(db: Database, input: { accountId: string; workspaceId: string; requestId: string; /** Canonical product model id (or credit usage) whose grants may pay. */ usage: CreditUsage; origin: BillingOrigin; amountMicros: number; }): Promise; /** Delete a call's hold once it has settled, failed or been aborted. */ export declare function releaseModelCallCredits(db: Database, input: { accountId: string; workspaceId: string; requestId: string; }): Promise;