> ## Documentation Index
> Fetch the complete documentation index at: https://resq-dependabot-github-actions-github-actions-478e18be3d.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Token

**resq\_ai > token**

# Module: token

## Contents

**Functions**

* [`estimate_tokens`](#estimate_tokens) - Estimate token count using the chars/4 heuristic.
* [`truncate_to_budget`](#truncate_to_budget) - Truncate text to fit within a token budget.

***

## resq\_ai::token::estimate\_tokens

*Function*

Estimate token count using the chars/4 heuristic.

```rust theme={null}
fn estimate_tokens(text: &str) -> usize
```

## resq\_ai::token::truncate\_to\_budget

*Function*

Truncate text to fit within a token budget.
Cuts at line boundaries to avoid broken diff hunks.

```rust theme={null}
fn truncate_to_budget(text: &str, max_tokens: usize) -> &str
```
