How do I get my trace? β
A "trace" is just the request payload(s) you send the model. Capture a few calls from one agent run β caching, history & duplicate-doc waste only show across multiple calls.
// easiest: the capture helper (any SDK)
import { tap, writeTrace } from "tokendam/capture";
await openai.chat.completions.create(tap({ model, messages, tools }));
await writeTrace("trace.json"); // then paste trace.json here
β or log the request args yourself β
Raw OpenAI SDK
const params = { model, messages, tools };
console.log(JSON.stringify(params));
// paste it β or wrap several as [p1, p2, ...]
const res = await openai.chat.completions.create(params);
Raw Anthropic SDK
const req = { model, system, messages, tools };
console.log(JSON.stringify(req));
// TokenDam reads your cache_control markers directly
const res = await anthropic.messages.create(req);
Vercel AI SDK
const openai = createOpenAI({
fetch: async (url, init) => {
console.log(init?.body); // the exact request JSON
return fetch(url, init);
},
});
LangChain / LangSmith
from langsmith import Client print(Client().read_run(run_id).inputs) # paste the JSON β or paste a run/array of runs directly
Tip: add each response's usage object to include output-cost and score real cache hits.
How this fits
| TokenDam | Proxies & gateways (Tokenwise, OpenRouter, Portkeyβ¦) | |
|---|---|---|
| Setup | Paste a trace β zero integration | Route your prod traffic through them |
| Sees your prompts | Never β runs in your browser | Yes β sits in the request path |
| Best for | Auditing & fixing waste at the source | Ongoing routing / failover / caching |
Use TokenDam to find and fix the waste in your prompts; reach for a gateway when you want to route traffic. They're complementary β TokenDam just doesn't ask you to trust it with your data.