Agent Cost Calculator avatar

Agent Cost Calculator

Pricing

$0.001 / actor start

Go to Apify Store
Agent Cost Calculator

Agent Cost Calculator

Calculate what your AI agent runs cost, broken down by model, tool, task and run, from your token usage and price list. Flags any model or tool with no price. $0.001 per run.

Pricing

$0.001 / actor start

Rating

0.0

(0)

Developer

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

a day ago

Last modified

Categories

Features

Limited permissions

Share

Calculate decimal cost breakdowns by model, tool, task and run from supplied usage and versioned prices, with explicit missing-price findings.

This Actor runs Agent Cost Calculator only. Supply its native JSON object directly; no utility selector or dispatcher wrapper is accepted. Core computation is deterministic and offline: no LLM calls, remote schema retrieval or target-site requests. Apify runtime storage is used to save the result.

Behavior and limits

Exact resource/unit pairs choose prices; amount is per positive supplied per units (default 1). No unit conversion or live prices. Nonnegative numeric values or plain decimal strings (≤100 chars); strings recommended. Up to 10,000 usage and price records. Currency is a supplied three-letter uppercase code. Arithmetic uses 50 significant digits, half-even rounding, including nonterminating ratios. Missing prices produce a partial total with complete=false, never implicit zero. Supplied data is not provider billing proof.

Every request is limited to 2,000,000 bytes of canonical UTF-8 JSON. Runtime validation uses the bundled exact input_schema.json. The Console form is a supported Apify schemaVersion 1 presentation: root fields/types are retained, while nested and cross-field constraints run inside the Actor. Inputs containing arbitrary JSON or boolean schemas stay native JSON, without string encoding or forced object conversion. Schema evaluation is intended for bounded trusted workloads; it is not an adversarial multi-tenant sandbox.

Input

FieldRequiredJSON typeMeaning
usageyes"array"Native utility field; exact nested shape is in input_schema.json.
pricingyes"object"Versioned caller-supplied prices with currency and explicit resource/unit rates; no live prices.

Example input (example-input.json):

{
"usage": [
{
"resource": "model/input",
"unit": "token",
"quantity": 1000,
"model": "model"
}
],
"pricing": {
"version": "example-v1",
"currency": "USD",
"prices": [
{
"resource": "model/input",
"unit": "token",
"amount": "0.25",
"per": 1000000
}
]
}
}

Output and status

The Actor stores one result envelope in the default dataset and the same envelope under key OUTPUT in the default key-value store. Data fields for this utility: total, currency, pricing_version, complete, breakdown, by_dimension, unassigned, errors.

  • status: pass: execution completed and the result/check passed.
  • status: fail: execution completed and found a failed check, policy or retention constraint. This is a completed Actor run, not a runtime crash.
  • status: error: execution could not complete, with stable errors[].code, message and JSON Pointer path; the local process exits 2.

The envelope also contains utility, version, request_id, data, errors, warnings and provenance. See the output_schema.json, .actor/dataset_schema.json, and .actor/output_schema.json. Fields named errors inside data are check findings; envelope errors describe execution failures. Do not treat a platform run's success flag alone as a passing policy/check.

Actual core output for the example (example-output.json):

{
"utility": "agent-cost-calculator",
"version": "1.0.0",
"request_id": "documented-example",
"status": "pass",
"data": {
"total": "0.00025",
"currency": "USD",
"pricing_version": "example-v1",
"complete": true,
"breakdown": [
{
"usage_index": 0,
"resource": "model/input",
"unit": "token",
"quantity": "1000",
"cost": "0.00025"
}
],
"by_dimension": {
"model": {
"model": "0.00025"
},
"tool": {},
"task": {},
"run": {}
},
"unassigned": {
"model": "0",
"tool": "0.00025",
"task": "0.00025",
"run": "0.00025"
},
"errors": []
},
"errors": [],
"warnings": [
"Costs use caller-supplied usage and prices; no billing attestation. Decimal arithmetic uses 50 significant digits and half-even rounding."
],
"provenance": {
"engine": "deterministic-python",
"network_access": false,
"input_hash": "sha256:0303a1d1caac263b0b09e67ea132d256a6fc29d35a8919ef6dd0bfc56070b288"
}
}

The request ID above is fixed for illustration; actual Actor runs generate their own request IDs. Runtime provenance additionally identifies local or Apify storage; the example shows the utility's computed envelope before that storage annotation. Hashes identify supplied data, not independently verified facts.

Run through the API

Replace YOUR_APIFY_USERNAME with the namespace of this Actor's published listing. The fixed Actor name is agent-cost-calculator. This example assumes the Actor has been built and made accessible in that namespace; this README does not itself establish deployment or publication.

curl --fail-with-body --request POST \
--header "Authorization: Bearer $APIFY_TOKEN" \
--header 'Content-Type: application/json' \
--data-binary @example-input.json \
'https://api.apify.com/v2/acts/YOUR_APIFY_USERNAME~agent-cost-calculator/run-sync-get-dataset-items?format=json'

The response is an array containing the result envelope. Inspect its status and findings before consuming data. For asynchronous integrations, start a run, wait for completion and retrieve the default dataset or key-value-store OUTPUT. API authorization credentials belong in your client environment, never in utility input or captured fixtures.

Run locally

From this self-contained Actor directory, with Python 3.11 or newer:

python3 -m venv .venv
.venv/bin/python -m pip install -r requirements.txt
.venv/bin/python -m app --input example-input.json --storage-dir ./storage

This executes the fixed utility using real local SDK filesystem storage. It does not start another Actor or dispatch to another portfolio utility. A completed finding has envelope status fail while completing the storage run normally; execution errors exit 2. Inspect the stored envelope rather than assuming that a zero process exit means a check passed.

Compose with other utilities

Map trace usage into explicit resource/unit records; keep currency and pricing version. Pass the computed total and caller-measured run summaries into Agent Run Regression Comparator after aligning units and scope.

Composition is explicit caller orchestration: this Actor does not invoke other Actors. Pass only documented data fields between contracts and check every envelope status. Offline core tests use supplied fixtures; the Actor does not fabricate evidence or verify that supplied events, usage or artifact references occurred.