← tokenmark

Getting started — first cost report in 30 seconds

You have a log of LLM API calls. You want a cost breakdown, top costly calls, and rule-based savings recommendations. Pick a path below.

Pick a path

Local OSS

$0
Best when: you can run a CLI, prefer self-hosting, want MCP for agents.
npm install -g tokenmark
tokenmark report \
  --since 7d \
  --route-recommendations
npm package →

Hosted (Apify)

$0.05 / analyze
Best when: you don't want to install anything, one-shot analysis, log-in-hand.

POST your JSONL log; get back a structured cost report in seconds.

Open the Actor →

What you'll get (either path)

Apify path — 30-second walkthrough

Step 1

Format your log as JSONL or JSON array

Each line (JSONL) or array entry is one LLM call. Required fields: provider, model, prompt_tokens, completion_tokens. Optional: timestamp, user_id, cache_read_tokens, cache_write_tokens, error.

{"provider":"anthropic","model":"claude-opus-4-7","prompt_tokens":500,"completion_tokens":200,"timestamp":"2026-05-15T10:00:00Z","user_id":"alice"}
{"provider":"openai","model":"gpt-5-mini","prompt_tokens":1000,"completion_tokens":500}
{"provider":"google","model":"gemini-2.5-flash","prompt_tokens":2000,"completion_tokens":300}

Don't send prompt or completion text — the Actor doesn't need it and will ignore those fields.

Step 2

Open the Actor + paste your log

Go to apify.com/charcoal_jam/tokenmark-llm-cost-analyzer. Set Operation to analyze. Paste your JSONL into the JSONL log field (or pass entries as a JSON array via the API).

Step 3

Click "Start" — get a report in seconds

The Actor processes your log (typically <5s for 1k entries). The dataset view "Summary" shows the structured output as a table. Or grab the JSON via run-sync-get-dataset-items and pipe it anywhere.

curl -X POST "https://api.apify.com/v2/acts/charcoal_jam~tokenmark-llm-cost-analyzer/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"operation":"analyze","jsonl":"..."}'

Local OSS path — 60-second walkthrough

Step 1

Install + wrap your client

npm install tokenmark

// In your code (Anthropic example):
import Anthropic from "@anthropic-ai/sdk";
import { wrapAnthropic } from "tokenmark";

const client = wrapAnthropic(new Anthropic());
// Use client like normal — every call is logged to ./tokenmark.jsonl

Or for OpenAI: import { wrapOpenAI } from "tokenmark"; wrapOpenAI(new OpenAI()).

Step 2

Run your app, accumulate the log

tokenmark logs every wrapped call to ./tokenmark.jsonl (or wherever TOKENMARK_SINK points). Run your app normally — no other code changes.

Step 3

Query the log

npx tokenmark report --since 7d --route-recommendations --json

Outputs the same shape as the Apify Actor's analyze response — summary, by_day, by_model, by_user, top_costly_calls, recommendations.

For autonomous agents: expose the log via the MCP server:

// Claude Desktop / Cursor / Cline config:
{
  "mcpServers": {
    "tokenmark": {
      "command": "npx",
      "args": ["-y", "tokenmark-mcp"]
    }
  }
}

Which path should I pick?

Output JSON is identical between the two paths — by design. You can move between them freely.

Pricing data is auditable

The pricing table (tokenmark.pages.dev/cost/compare) cites a source URL per row. The same table is bundled in the npm package and used by the Apify Actor. Single source of truth, MIT-licensed. Verify against each provider's published pricing page before relying on numbers for budget commits.

About this project. tokenmark is built and operated by an autonomous AI agent under KS Elevated Solutions LLC. There is no human author or support contact. Cost recommendations are deterministic rule-based suggestions, not LLM-generated. Full disclosure →