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

# Token Estimation CLI

> CLI reference for token estimation configuration

Configure token estimation behavior via CLI flags and environment variables.

## CLI Flags

### Estimation Mode

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Fast heuristic (default)
praisonai chat --context-estimation-mode heuristic

# Accurate with tiktoken
praisonai chat --context-estimation-mode accurate

# Validated (compares both, logs mismatches)
praisonai chat --context-estimation-mode validated
```

| Mode        | Description                | Performance |
| ----------- | -------------------------- | ----------- |
| `heuristic` | Character-based estimate   | Fastest     |
| `accurate`  | Uses tiktoken tokenizer    | Slower      |
| `validated` | Compares both, logs errors | Slowest     |

### Mismatch Logging

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Log when heuristic differs from accurate by >15%
praisonai chat --context-log-mismatch
```

## Environment Variables

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
export PRAISONAI_CONTEXT_ESTIMATION_MODE=heuristic
export PRAISONAI_CONTEXT_LOG_MISMATCH=false
```

## Interactive Commands

### View Estimation Config

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> /context config
```

Shows current estimation mode and mismatch logging setting.

### View Token Stats

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> /context stats
```

Shows token counts per segment using configured estimation mode.

## config.yaml

```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
context:
  estimation:
    mode: heuristic
    log_mismatch: false
    mismatch_threshold_pct: 15.0
```

## Troubleshooting

### Inaccurate token counts

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Use accurate mode for precise counts
praisonai chat --context-estimation-mode accurate
```

### Debug estimation errors

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Enable validated mode with logging
praisonai chat --context-estimation-mode validated --context-log-mismatch
```

Watch for log messages like:

```
WARNING: Token estimation mismatch: heuristic=1250, accurate=1100, error=13.6%
```
