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.
npm install -g tokenmark
tokenmark report \
--since 7d \
--route-recommendations
npm package →
POST your JSONL log; get back a structured cost report in seconds.
Open the Actor →user_id (if you supplied it)opus_small_to_haiku, semantic_cache_candidate, high_error_rate) with estimated savingsEach 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.
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).
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":"..."}'
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()).
tokenmark logs every wrapped call to ./tokenmark.jsonl (or wherever TOKENMARK_SINK points). Run your app normally — no other code changes.
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"]
}
}
}
Output JSON is identical between the two paths — by design. You can move between them freely.
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.