> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Token Budget • Rust AI Agent SDK

> TokenBudget: Token budget for context management.

# TokenBudget

> Defined in the [**RAG**](../modules/rag) module.

<Badge color="orange">Rust AI Agent SDK</Badge>

Token budget for context management.

## Fields

| Name       | Type    | Description              |
| ---------- | ------- | ------------------------ |
| `total`    | `usize` | Total available tokens   |
| `system`   | `usize` | Tokens for system prompt |
| `context`  | `usize` | Tokens for context       |
| `response` | `usize` | Tokens for response      |
| `reserved` | `usize` | Reserved tokens          |

## Methods

### `new`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn new(total: usize) -> Self
```

Create a new token budget

**Parameters:**

| Name    | Type    |
| ------- | ------- |
| `total` | `usize` |

### `available_context`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn available_context(&self) -> usize
```

Get available context tokens

### `can_add_context`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn can_add_context(&self, tokens: usize) -> bool
```

Check if budget allows more context

**Parameters:**

| Name     | Type    |
| -------- | ------- |
| `tokens` | `usize` |

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-rust/praisonai/src/rag/mod.rs#L347">
  `praisonai/src/rag/mod.rs` at line 347
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Rust Budget" icon="wallet" href="/docs/rust/budget" />

  <Card title="Rust Token Management" icon="coins" href="/docs/rust/token-management" />
</CardGroup>
