# AI Agent Cost Per Task Calculator for Tool-Calling Loops

> Source: https://netray.co/tools/agent-loop-cost-per-task-calculator
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

Models input tokens that accumulate across tool calls in an agent loop and prices a single task and a month of tasks.

## Category

ai-automation

## Audience

- AI engineer
- ERP integration developer
- IT manager

## Tool

**Kind:** calculator

**Currency:** $

**Inputs:**

#### Tool-calling steps per task

**Key:** steps

**Type:** slider

**Default:** 8

**Min:** 1

**Max:** 40

**Step:** 1

**Unit:** steps

#### Initial prompt tokens

**Key:** base

**Type:** number

**Default:** 6000

**Min:** 0

**Step:** 500

**Unit:** tokens

**Help:** System prompt, tool definitions and the user request.

#### Average tool result size

**Key:** result

**Type:** number

**Default:** 1200

**Min:** 0

**Step:** 100

**Unit:** tokens

**Help:** ERP query results are often truncated rows. Measure yours.

#### Output tokens per step

**Key:** out

**Type:** number

**Default:** 250

**Min:** 0

**Step:** 25

**Unit:** tokens

**Help:** Reasoning text plus the tool call arguments.

#### Input price per million tokens

**Key:** price_in

**Type:** number

**Default:** 3

**Min:** 0

**Step:** 0.1

**Unit:** $ per 1M

#### Output price per million tokens

**Key:** price_out

**Type:** number

**Default:** 15

**Min:** 0

**Step:** 0.5

**Unit:** $ per 1M

#### Tasks per month

**Key:** tasks_month

**Type:** number

**Default:** 3000

**Min:** 0

**Step:** 100

**Outputs:**

#### Total input tokens per task

**Key:** in_total

**Expr:** steps * base + (result + out) * steps * (steps - 1) / 2

**Format:** integer

**Description:** Each step re-reads everything before it.

#### Total output tokens per task

**Key:** out_total

**Expr:** steps * out

**Format:** integer

#### Cost per task

**Key:** cost_task

**Expr:** in_total / 1000000 * price_in + out_total / 1000000 * price_out

**Format:** currency

**Primary:** true

#### Cost per month

**Key:** cost_month

**Expr:** cost_task * tasks_month

**Format:** currency

**Primary:** true

#### Context size at the last step

**Key:** last_ctx

**Expr:** base + (result + out) * (steps - 1)

**Format:** integer

**Chart:**

#### Cost per task as steps increase

**Type:** line

**X:** steps

**From:** 1

**To:** 40

**Steps:** 40

**Series:**

- cost_task

**Disclaimer:** Assumes no prompt caching and no context trimming. Real providers may charge differently for cached input or long contexts.

## Content

**Intro:** A tool-calling agent re-sends its whole conversation on every step, so input tokens grow roughly with the square of the step count. This calculator makes that visible and prices a task and a month of tasks.

**Sections:**

#### How to use it

**Body:** Set the number of tool calls a typical task needs, the starting prompt size, and the average size of each tool result. Add output tokens per step and your model's prices. The cost per task is the headline. Then drag the steps slider to see what happens when the agent takes twice as many steps because of a vague tool or a failing query. The chart plots cost per task from one to forty steps, which shows the curve bending upward rather than rising in a straight line.

#### Formula and reading the result

**Body:** At step i the input is the base prompt plus all earlier results and outputs, so the sum over n steps is n times base plus (result + out) times n(n-1)/2. Output tokens are simply n times the per-step output. Multiply each by its price per million. If the last-step context approaches your model window, the real agent will fail or need truncation, regardless of cost.

**Bullets:**

- Halving tool result size often saves more than switching models.
- Cutting steps has a compounding effect.
- Prompt caching on the stable base prefix reduces the first term.

#### Common mistakes

**Body:** Teams often price one call and multiply by the step count, which understates cost because later calls are larger. Another mistake is ignoring retries and failed tool calls, which add steps. For ERP agents, unfiltered list queries can return thousands of tokens per call; capping rows and returning only requested fields is the cheapest optimization. Add a hard step limit and a budget guard so a confused agent cannot spend unbounded tokens on one task.

**Cta:** Netray builds ERP agents with step limits, trimmed results and models served on your own GPUs, which changes this cost curve. We can model your workload with you.

**Faq:**

#### Why does cost grow faster than linearly with steps?

**Answer:** Because each step includes all previous messages as input. Step ten carries nine steps of history. The sum of those growing inputs scales with steps squared, while output scales linearly.

#### Does caching remove the quadratic growth?

**Answer:** It lowers the price of the repeated prefix, so growth is cheaper, but the context still gets longer and uncached portions such as new results are billed normally. Check your provider's cache pricing and minimum sizes.

#### How do I measure average tool result size?

**Answer:** Log the token count of each tool response for a week of real tasks and take the mean or median. ERP queries vary widely, so also look at the 95th percentile to find outliers worth truncating.

#### Does this apply to self-hosted models?

**Answer:** The token growth does, but the price is replaced by GPU time and capacity. Use your measured tokens per second to convert total tokens into GPU seconds, or compare with an on-prem cost calculator.

## Search terms

ai agent cost per task, agent loop token cost, tool calling agent cost estimate, llm agent steps cost calculator, cost of agentic workflow per run, context growth agent calculator

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
