pub struct EmbeddingTokenBudget { /* private fields */ }Expand description
One execution’s embedding budget: tokens against its own ceiling and the server-wide one, plus the outbound request counter.
Implementations§
Source§impl EmbeddingTokenBudget
impl EmbeddingTokenBudget
pub fn new(limits: EmbeddingLimits, aggregate: SharedTokenBudget) -> Self
Sourcepub fn unmetered() -> Self
pub fn unmetered() -> Self
A budget that never refuses, for runs with no operator-installed budget.
pub fn limits(&self) -> EmbeddingLimits
pub fn used(&self) -> u64
pub fn held(&self) -> u64
Sourcepub fn reserve(&self, alias: &str, tokens: u64) -> Result<(), EmbeddingError>
pub fn reserve(&self, alias: &str, tokens: u64) -> Result<(), EmbeddingError>
Reserve a call’s whole estimate before dispatch. Like submilli:llm,
refused once held reserve is already past its cap, so held spend per run
is bounded by the cap plus one call’s sent estimate.
Sourcepub fn mark_sent(
&self,
alias: &str,
estimate: u64,
) -> Result<(), EmbeddingError>
pub fn mark_sent( &self, alias: &str, estimate: u64, ) -> Result<(), EmbeddingError>
Count one outbound request and move estimate (already reserved) to
held. Call immediately before sending; on Err, do not send. The error
is a EmbeddingError::BudgetExceeded with no settlements — attach the
provider’s with EmbeddingError::with_settlements.
Sourcepub fn settle(&self, reserved: u64, settlements: &[SubBatchSettlement])
pub fn settle(&self, reserved: u64, settlements: &[SubBatchSettlement])
Apply a call’s settlements and release whatever of reserved was never
sent. Idempotence is not provided: call once per reservation.