async-bulkhead-llm - v3.19.1
    Preparing search index...

    Type Alias TokenBudgetOptions

    async-bulkhead-llm — public API surface.

    This entry point re-exports everything the package supports; the implementation lives in focused modules:

    • types.ts — request/result/options/stats/event types
    • errors.ts — LLMBulkheadRejectedError and the two errors for admitted work that ended early
    • profiles.ts — PROFILES presets
    • estimators.ts — naive + model-aware estimators, extractTextLength
    • adaptive.ts — createAdaptiveTokenEstimator (v3.8)
    • dedup.ts — deduplication internals (keying, share safety)
    • validation.ts — internal numeric/estimate/usage guards
    • bulkhead.ts — createLLMBulkhead: validates options and wires the engine parts together
    • reconfigurable-bulkhead.ts — internal concurrency gate (global slot count and queue)
    • engine/ — the parts of the admission engine, one concern per file (limits, token ledger, class slots, admission counts, capacity checks, the admitted token, run(), observe mode, deduplication, stats, shutdown, the running calls and the stop triggers); the full list is in the header of bulkhead.ts

    Deep-importing the internal modules is not supported; the package exports map exposes only this entry point.

    type TokenBudgetOptions = {
        budget: number;
        estimator?: TokenEstimator;
        highPriorityReserve?: number;
        outputCap?: number;
    }
    Index
    budget: number

    Maximum tokens allowed in-flight simultaneously across all active requests. Admission is always fail-fast when this ceiling is reached, independent of concurrency headroom and independent of profile.

    Must be a non-negative integer. 0 is valid and intentional — it represents a pool with no budget to grant this cycle (e.g. a lease ledger reporting exhaustion) and results in every budget-gated admission being rejected with "budget_limit" until the ceiling is raised (via applyLimits() or setBudget()) or tokenBudget admits a zero-token request.

    estimator?: TokenEstimator

    Estimator used to calculate token reservation pre-admission. Defaults to createModelAwareTokenEstimator seeded with the bulkhead's model.

    highPriorityReserve?: number

    Tokens of budget headroom reserved for priority: "high" requests.

    Normal-priority admission is checked against budget - highPriorityReserve; high-priority admission is checked against the full budget. This lets interactive traffic keep admitting while batch traffic has saturated the shared pool.

    Must satisfy 0 <= highPriorityReserve <= budget. Default: 0 (priority has no effect).

    outputCap?: number

    Fallback output reservation when request.max_tokens is absent. Default: 2048.