Data, Evals & Observability

Agentic cost benchmark

Run a task across multiple models on Token Factory, then compare measured cost, tokens, latency, and correctness - not just list price.

Build it with an agent

Paste into Claude Code, Cursor, or any coding agent — it builds the recipe for you.

Start in an empty directory. Clone `https://github.com/nebius/token-factory-cookbook` and work inside `agents/agent-cost-comparison-1`. Read its `README.md` and `agent_cost_comparison_1.py` before running anything.

Install the dependencies with `uv sync`. Read the Token Factory credential from `NEBIUS_API_KEY`, or from a `.env` file in that directory if the variable is not set. If neither is present, stop and ask the user for their Nebius Token Factory API key, then write it to `.env` as `NEBIUS_API_KEY=<key>` before running. Do not search elsewhere on the machine for a key. Never print or commit the key.

Run the benchmark once against the default `data-1` suite with `uv run python agent_cost_comparison_1.py`, wrapping the command so wall-clock time is measured, and save all output to `run-data1.log`. The script runs the same data-analysis task as a `deepagents` filesystem agent on three Nemotron models hosted on Nebius Token Factory, validates each `result.json` against `expected.json`, and prints a per-model metrics block plus a final comparison table sorted by cost.

From the log, report: the total estimated cost of the run summed across all three models, the wall-clock time of the run, and each model's success, turns, tool calls, token counts, latency, and cost. Reference runs of this suite cost between $0.05 and $0.11 in total and finished in 45 to 60 seconds of wall-clock time, with Lightning cheapest, then Super, then Ultra. The spread comes from Ultra, which sometimes takes twice as many turns. Say whether your run falls in that cost and time range and keeps that ordering.

Recipe

A model’s price-per-token tells you almost nothing about what a task actually costs. An agent that takes five tool calls to answer a question and one that takes fifteen pay a very different bill, even on the same model — and swap in a bigger, pricier model and the gap can go either way. The only way to know what a task costs is to run it and count.

In this cookbook we run the same data-analysis task against three models hosted on Nebius Token Factory, and report measured token usage, latency, estimated cost, and whether the answer was actually right.

The Models

We are using the Nemotron models because there are 3 distinct models from the same family. But the benchmark is not at all tied to Nemotron — you can use any models.

Here is a visualization of the 3 Nemotron models:

  • Ultra: the largest (550B parameters)
  • Super: midsize (120B parameters)
  • Lightning: smallest (30B parameters)

Scatter plot of AA Intelligence Index versus blended price per 1M tokens for the three Nemotron models: Lightning lowest on both axes, Super in the middle, Ultra highest on both

The three Nemotron tiers by intelligence index and blended list price. Source: Artificial Analysis.

The Benchmark

What

  • A fixed task: analyze sales data in CSV format and produce the final output in two formats — JSON, which is easily verifiable programmatically, and Markdown, which is human readable.

  • Three models: the same benchmark across multiple models.

The Process

  • We use the deepagents framework, which coordinates the agents and gives them tools. It also runs the benchmark in an isolated sandbox workspace — no shell, no Python execution. The model has to read the CSVs, do the arithmetic itself, and write the answer to a file.

  • Validation: Model output is compared against a ground-truth expected.json. We also collect metrics like tool calls and token counts and compute cost from the configured prices.

Flow diagram: input files are copied into a per-model workspace, a deep agent with file tools only produces result.json and summary.md, a validator scores them against expected.json, and everything lands in a comparison table

Code and Data

Here is the code

And we have 2 datasets — data-1 and data-2.

Prerequisites

  • Python 3.12 or newer
  • uv (or pip, if you’d rather manage the virtualenv yourself)
  • Nebius Token Factory account with access to the three Nemotron models listed above
  • NEBIUS_API_KEY in an environment variable or a local .env file — never pasted into the script or committed

Run the cookbook

  1. From the agent-cost-comparison-1 directory, install dependencies:

    uv sync
    
  2. Create a .env file with your API key:

    NEBIUS_API_KEY=your-token-factory-key
    
  3. Run the benchmark against the default data suite:

    uv run python agent_cost_comparison_1.py
    # uses 'data-1' dir by default
    

    Each model gets its own workspace under benchmarks/data-1/<model>/, with the input files copied in and output/ created fresh.

    You can also specify a data dir:

    uv run python agent_cost_comparison_1.py --data-dir data-2
    

Verify the result

After each model finishes, the script prints its own validation block, its metrics, and the generated summary.md, then a final comparison table sorted by cost once all models are done.

A model “passes” when every field in result.json (model output) matches expected.json (expected output).

Here is an example expected.json:

{
  "region": "west",
  "change": -60000,
  "primary_product": "widget-b"
}

You can also open the workspace directly:

cat benchmarks/data-1/nvidia__Nemotron-3_5-Lightning/output/result.json

cat benchmarks/data-1/nvidia__Nemotron-3_5-Lightning/output/summary.md

Analysis

Here is a sample output from a run:

Model Success Turns Tool calls In tokens Out tokens Total tokens Latency Cost
Nemotron-3_5-Lightning YES 8 11 30,825 1,140 31,965 7.12s $0.002123
nemotron-3-super-120b-a12b YES 14 13 53,565 7,084 60,649 29.32s $0.022445
Nemotron-3-Ultra-550b-a55b YES 10 14 45,146 3,037 48,183 19.29s $0.054257

Some insights:

  • All three models succeeded at the task.
  • Looking at cost, Lightning wins by ~10x over Super and ~26x over Ultra.
  • Lightning really lives up to its name: it was the fastest run (7.1s vs 19-29s).
  • Super actually used the most tokens of the three (60,649 — more than Ultra) yet still cost 2.4x less than Ultra. Ultra’s per-token rate is 3.3x Super’s, so it costs more.
  • All models use more input tokens than output (see the more detailed analysis below).

TL;DR for most tasks, smaller models can produce perfectly good results at minimal cost. Faster and cheaper!

More In-Depth Analysis

Here is the cost breakdown of running on two datasets.

Grouped bar chart of estimated cost per run: Lightning around $0.0021 on both suites, Super at $0.0224 and $0.0159, Ultra at $0.0543 and $0.0896 - every run correct

Costs move run to run — the agent takes a different path each time — but the ordering has held on every run: Lightning, then Super, then Ultra.

Where the calls went

The agents work entirely through file tool calls (ls, read_file, write_file). Here is the breakdown by tool:

Run ls read_file write_file Total
Lightning · data-1 4 5 2 11
Super · data-1 2 9 2 13
Ultra · data-1 3 5 6 14

Input Tokens are the majority

Stacked bar chart of input versus output tokens per run: input dominates every run, and Ultra's input grows from 45k on data-1 to 80k on data-2 while output stays near 3k

Input tokens are the bill, everywhere. 72-87% of every model’s cost is input. That’s the agentic-loop tax: every turn re-sends the whole conversation plus accumulated tool results, so input grows quadratically-ish with turn count. You can see it in the run above: Super took the most turns (14), and that alone pushed its input to 53k tokens — the most of any model — even though its tool-call count was ordinary.

Why Nemotron Ultra needed a workaround

Nemotron-3-Ultra-550b-a55b ships with a Deep Agents harness profile that includes a NemotronPolicyNudgeMiddleware. On this particular task — a single-turn “read some files, write some files” job with no multi-step handoff — that middleware can mistake the work for a task transition and nudge the model off course. The fix is a runtime override that keeps the rest of the Ultra profile intact and disables just that one middleware:

register_harness_profile(
    "nebius:nvidia/Nemotron-3-Ultra-550b-a55b",
    HarnessProfile(excluded_middleware={"NemotronPolicyNudgeMiddleware"}),
)

There is a bug open for this issue.