Attribute LLM spend to each end-customer so you know the margin behind every account.
Know exactly what each customer costs you in LLM spend by tagging requests with their ID.
1
Tag every request with a customer identifier
Pass your customer’s identifier as a metadata key using X-Toolken-Metadata-Customer-Id. The header suffix maps directly to the customer_id metadata key in the dashboard. Use whatever ID you already have — a user ID, an org slug, or an account number.
from openai import OpenAIclient = OpenAI( base_url="https://gateway.toolken.ai/v1", api_key="sk-...", # your provider key, forwarded untouched default_headers={ "X-Toolken-Key": "tk_live_...", "X-Toolken-Metadata-Customer-Id": "cust_acme", },)client.chat.completions.create( model="gpt-4o-mini", messages=[{"role": "user", "content": "Generate a project summary."}],)
Go to the cost view in the dashboard. Use the “Group by” control to select Customer. Each customer ID appears as a row showing cost, token usage, and request count.
Cost grouped by customer
Set customer via metadata (precedence)
You can set the customer dimension in more than one way on the same request. If you send multiple, the highest-priority one wins:
Priority
Method
1 (highest)
"customer_id" key inside the provider request body metadata object
2
X-Toolken-Metadata: {"customer_id":"<id>"}
3 (lowest)
X-Toolken-Metadata-Customer-Id: <id>
Pick one method and stay consistent. The priority only matters when you accidentally set it multiple ways.
Cost per customer per agent
Add X-Toolken-Metadata-Agent alongside X-Toolken-Metadata-Customer-Id to get a two-dimensional view. You can then answer questions like “how much did cust_acme spend on the report-generator agent this month?”.