User Tracking
Track sub-user usage without exposing prompt content
The optional `user` field helps attribute usage to your own customer IDs and can improve routing consistency for cached workflows.
Overview
This page mirrors the OpenRouter workflow and adapts it for TheRouter.ai. Use TheRouter.ai as your OpenAI-compatible endpoint and keep model IDs in `provider/model` format.
Installation
Install the required SDKs and keep your TheRouter.ai key in environment variables.
install.sh
curl https://api.therouter.ai/v1/chat/completions -H "Authorization: Bearer $THEROUTER_API_KEY" -H "Content-Type: application/json" -d '{"model":"openai/gpt-4o","user":"user_42","messages":[{"role":"user","content":"hello"}]}'Configuration
Set TheRouter.ai base URL overrides and pass your API key. Add attribution headers when your app should appear in rankings.
TypeScript
const body = {
model: "openai/gpt-4o",
user: "acct_123:user_42",
messages: [{ role: "user", content: "Summarize my inbox" }],
};Caveats
Integration note
Use pseudonymous stable IDs rather than email addresses to keep user tracking privacy-preserving.
For production rollouts, pin SDK versions and validate model compatibility in staging before broad rollout.