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

# Cost control | Agent guide

> Review completed-run usage and useful results, then set controls for future work.

[Human guide: task steps and agent prompt →](https://deepline.com/docs/human/cost-control.md)

Review the results and recorded usage of the task you just ran before expanding it. Keep its run ID or direct execution's `job_id` with the accepted outputs; org balance changes do not isolate one job's cost.

## Review completed usage

In the intended org, open [Usage](https://code.deepline.com/dashboard/usage). **Show: All / Plays / Actions** and **By: Provider / Action** filter the breakdown. **Recent activity** shows operation, run, billed units, time, and credits. This is separate from [Billing](https://code.deepline.com/dashboard/billing), which holds funding and cap controls.

For spend scoped to a Play run:

```bash theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
deepline billing usage --run-id <run-id> --json
```

For a direct tool execution, use its returned `job_id` or `next.billing` command:

```bash theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
deepline billing usage --request-id <job_id> --json
```

Follow returned pagination for recent-call pages. Keep pending holds, unknown amounts, and final charges distinct: absent charge evidence is not zero. An active run's usage is partial; read it again after the run finishes and reconcile any remaining pending charge. Failed runs can still have billed work.

## Compare credits with useful results

Review accepted results, misses, and errors under the same acceptance rule and input population. For example, compare `leads-pilot-results.csv` with the selected rows in `leads-pilot.csv`. [Use a CSV as Play input](https://deepline.com/docs/sdk-v2/batch-csv.md) covers record-safe selection for the next pilot.

Divide scoped, recorded credits by accepted results. In an illustrative comparison, 100 credits for 50 accepted results is 2 credits each; 80 credits for 20 is 4 each. These are examples, not Deepline prices. With zero accepted results, report the count and usage without dividing or calling the run free.

Keep a legitimate no-match result separate from invalid inputs and authentication or source-access errors. Check the selected operation's live contract and pricing before changing the route:

```bash theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
deepline describe <tool-id> --json
```

An estimate describes the proposed input mix; it neither enforces a limit nor establishes the final charge. Request-priced misses, validation, retries, and refreshes can carry charges.

> [accordion] Compare fallback routes and reuse
>
> Count each fallback's additional accepted rows among unresolved inputs and the extra credits needed to obtain them. Duplicate matches add no coverage, and stopping after acceptance does not refund earlier work.
>
> Completed runtime reuse is conditional: an unfinished receipt or a historical customer-table value does not guarantee the next request is free or current. For BYOK, add your own provider-account charges separately when evaluating total cost; Deepline's customer billing shows its applicable charges, not internal provider spend.
>
> See [Waterfall enrichment](https://deepline.com/docs/features/waterfall-enrichment.md) for coverage evaluation and [Pricing](https://deepline.com/docs/pricing.md) for the pricing contract.

## Choose controls for future work

```bash theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
deepline billing balance --json
deepline billing limit --json
```

| Control | What it controls |
| - | - |
| Org balance | Funding available for org work; other callers, purchases, and concurrent runs also change it. |
| Org Usage cap | New-call checks against a rolling 30-day usage limit, separately from funding. CLI/API fields call it a monthly limit. In-flight work can still exceed it; buying credits does not reset it. |
| Play per-run cap | Provider-call admission for that run and its child Plays. Calls whose projected charge would exceed the cap are refused. Already admitted work and compute remain billable; estimates, concurrency, and final charges mean this is not an all-in hard ceiling. |

### Set a Play cap

Set `billing.maxCreditsPerRun` in an authored Play under the [authoring contract](https://deepline.com/docs/sdk-v2/sdk-reference.md). For one run, `--max-credits` replaces that value and can raise or lower it:

```bash theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
deepline plays run my.play.ts --max-credits 50
```

This command starts work and can spend credits. The API and SDK run request accept the equivalent `maxCredits` field. Child Plays share the parent's billing cap. A refusal reports the cap, spent credits, and refused call estimate; it does not cancel or refund work already admitted.

### Change org policy with approval

In **Billing → Usage cap**, choose **Set cap** or **Manage**. Enable the cap, enter the **Rolling 30-day limit** in Deepline credits, and save the approved amount. Org access permits this edit; dashboard credit purchases require an **owner** or **admin** role.

The equivalent CLI change below sets an org cap of 10,000 credits. Confirm the amount and org before executing it, since it affects other users and jobs:

```bash theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
deepline billing set-limit 10000 --json
deepline billing limit --json
```

Removing it also changes org policy:

```bash theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
deepline billing off
```

For API callers, `GET /api/v2/billing/limit` reads the policy, `PUT` sets `monthly_credits_limit` to a positive integer, and `DELETE` disables it. Get explicit approval before changing caps, funding, or automatic purchases. Inspect any funding or access refusal and its recovery action before choosing another paid route.

> [!TIP]
>
> Compare recorded usage with accepted results first, then choose the next
> sample and cap. A budget stated in chat is not an enforced control. Reconcile
> uncertain usage before repeating provider work; use [tool
> recovery](https://deepline.com/docs/sdk-v2/tool-execution-recovery.md#billing-and-plays) when a response
> was lost.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.