Track every call
If you don't log token counts per call, you can't answer simple questions like "how much did this user cost us today?" or "is this feature blowing up our bill?" Build the tracker on day one — retrofitting it after the fact is painful.
What to record
For every call: model, prompt tokens, completion tokens, cached tokens, finish reason, timestamp, route key (which feature called this). Store in a small DB or append to JSONL — both work for the volumes most apps see.
OpenAI ↔ Gemini message translation
If you have legacy OpenAI-shaped code or an adapter that takes OpenAI-style messages, you'll write the OpenAI → Gemini conversion many times. Three transformations matter:
role: "system"→ top-levelsystem_instructionfield, not a message.role: "assistant"→role: "model"incontents.role: "tool"withtool_call_id→ user-turnfunctionResponsepart withid.