What you need
- An OpenRouter API key in
OPENROUTER_API_KEY. - Your Squasher ingest key and project ID in
SQUASHER_API_KEYandSQUASHER_PROJECT_ID. See Create an ingest key.
Record calls with the Agent SDK
1
Install the packages
2
Wrap the AI SDK and call a model
src/ai.ts
usage: { include: true } asks OpenRouter to return the cost of the call. The SDK reads it
from providerMetadata.openrouter.usage.cost.3
Check the call in Squasher
Select AI observability in the sidebar, then the Requests tab. The provider is
openrouter, and the model is the full OpenRouter model name, such as openai/gpt-4.1-nano.ai.flush() after each call. For all SDK options, see
the Agent SDK.
Send events with HTTP batch ingest
Without an SDK, post a batch of JSON events. Each event has anid, a type, a timestamp, and a
body. The format follows the Langfuse ingestion API.
207 with a successes list when it accepts the batch. The project ID in the URL
must be the project of the key.
Fields of a generation
body:
How Squasher counts cost
When the call reports its cost, Squasher uses it. Otherwise, Squasher computes the cost from the token counts and a public price list, which it updates every 24 hours. Models that are not on the list have a cost of0.
Limits
score-createevents are not supported in HTTP batch ingest. Squasher answers201for them but drops them. Send scores with the Agent SDK.- A
costDetailstotal of0counts as no cost, and Squasher computes the cost instead. - The key goes in the
x-squasher-keyheader. Never put it in the URL.
Next steps
AI observability
Read cost, latency, and sessions in the dashboard.
Agent SDK
All options, scores, and privacy settings.