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

# Billing

> Docex bills at 2× the actual upstream provider cost, estimated before queueing and trued-up after completion. Runs exceeding $1.00 require confirmation.

# Billing

> Billing is 2× the actual upstream provider cost, estimated before queueing and trued-up after completion. The `DOCEX_MARKUP_MULTIPLIER` environment variable controls the markup (default: `2`).

## Pricing model

Docex uses dynamic upstream-cost billing:

1. **Before execution** — the worker estimates cost based on file metadata (page count, image dimensions, task complexity)
2. **After execution** — the actual upstream cost is measured and charged
3. **Markup** — the billed amount is `upstreamCost × DOCEX_MARKUP_MULTIPLIER` (default `2×`)
4. **Refund** — if actual cost is below the estimate, the difference is refunded to your wallet

## Cost examples

| Input                 | Estimated upstream cost | Billed price (2×) |
| --------------------- | ----------------------- | ----------------- |
| Single image analysis | \~$0.02–$0.05           | \~$0.04–$0.10     |
| 10-page PDF           | \~$0.10–$0.50           | \~$0.20–$1.00     |
| 200-page PDF          | \~$1.00–$2.00           | \~$2.00–$4.00     |

## Confirmation threshold

Runs exceeding `DOCEX_COST_CONFIRMATION_THRESHOLD_USD` (default `$1.00`) require explicit user confirmation. You can confirm by:

* Passing `confirmCost: true` in the run request
* Setting a `maxCostUsd` budget — the job aborts if the estimate exceeds it

## Wallet

Docex uses a prepaid wallet. Top up via the dashboard or CLI:

```bash theme={null}
docex billing top-up --amount 10
```

Minimum top-up amount is configurable via `DOCEX_MIN_WALLET_TOP_UP_USD`. Default top-up amount is configurable via `DOCEX_DEFAULT_TOP_UP_USD`.

## Environment variables

| Variable                                | Default | Purpose                              |
| --------------------------------------- | ------- | ------------------------------------ |
| `DOCEX_MARKUP_MULTIPLIER`               | `2`     | Markup on upstream cost              |
| `DOCEX_COST_CONFIRMATION_THRESHOLD_USD` | `1.00`  | Runs above this require confirmation |
| `DOCEX_MIN_WALLET_TOP_UP_USD`           | —       | Minimum wallet recharge amount       |
| `DOCEX_DEFAULT_TOP_UP_USD`              | —       | Default wallet recharge amount       |
| `DOCEX_BILLING_CURRENCY`                | `USD`   | Wallet currency                      |
