Skip to main content
LangGraph nodes call a LangChain chat model — configure that model once and every node that uses it is tracked. Point ChatOpenAI at Toolken’s gateway, add X-Toolken-Key to default_headers, and spend appears in your dashboard broken down by agent.
1

Get your two keys

You need two keys:Toolken forwards your provider key to the upstream model provider untouched and never stores it.
2

Build the model

Use ChatOpenAI from langchain_openai. Set base_url to Toolken’s gateway and pass your keys in default_headers:
X-Toolken-Metadata-Agent labels this model’s traffic in the dashboard. Use any string that identifies the graph or workflow.
3

Use the model in your graph nodes

Pass model into whichever nodes call the LLM. A simple invoke pattern looks like:
No changes to your graph structure, edges, or state schema are needed.
4

Confirm in your dashboard

Run your graph. Within seconds, calls appear in the Toolken dashboard grouped under the research-agent agent. Cost, token usage, and latency are captured for every node invocation.
To attribute spend per agent or per node, create one ChatOpenAI instance per logical role and give each a distinct X-Toolken-Metadata-Agent value. For example, a "planner-agent" model and a "summarizer-agent" model each show up as separate line items in the dashboard, so you can see exactly which part of your graph is driving cost.

Next

CrewAI

Configure Toolken for CrewAI agents with the built-in LLM class.

Providers & Routing

One gateway URL, many providers, your own keys.