Skip to main content
Budget limits control how much your agents can spend.

Quick Start

1

Set Budget

use praisonai::Agent;

let agent = Agent::new()
    .name("Assistant")
    .max_tokens(10000)  // Token limit
    .build()?;

// Agent stops when limit reached
2

Track Usage

let response = agent.chat("Hello").await?;
let usage = agent.usage();

println!("Tokens used: {}", usage.total_tokens);
println!("Estimated cost: ${:.4}", usage.estimated_cost);

Budget Options

OptionTypeDescription
max_tokensusizeMaximum tokens per session
max_costf64Maximum cost in dollars
max_requestsusizeMaximum API calls