All case studies
PostHog saving PR #132240 open

84,000 tokens at full price, on every step.

−92%cost per repeat planner step, $0.215 to $0.018
−52%input cost per repeat chat-generator call
84,000tokens billed at full price on every step

At 100,000 repeat planner steps a month, that is about $19,700 a month.

PostHog's AI insight generation sends an ~84,000-token static prompt to the model on every planner step. Prompt caching should make the repeat sends nearly free, but a timestamp accurate to the second sat ahead of the static prefix, so no two requests ever matched, and every call paid full input price.

The fix pins that timestamp to the start of the conversation. The prefix becomes stable, the cache starts hitting, and repeat sends are billed at the cached rate. Nothing changes for users.

ee/hogai/…/schema_generator/nodes.py simplified
  prompt = construct_messages(      utc_now=timezone.now(),+     conversation_start_dt=state.start_dt,  )
The line that fixes it. Without a pinned start time, the rendered prompt changed every second, and every planner step paid for all 84,000 tokens again.
the same request, before and after the fix illustration
Every planner step resends the same ~84,000-token prefix. Before the fix, each send misses the cache and bills at full input price; after it, repeat sends bill at the provider's cached rate.

The same thing in your product

Anything that changes with each request, such as a timestamp, an ID or a user name, stops caching for everything that comes after it in the prompt. It is the most common leak we find: we found it in Chatwoot and Metabase too. If your prompts are long and mostly fixed, it is the first thing we check.

Find out how much you could save.

Tell us what you run and roughly what you spend on AI each month. If an audit isn't worth your time, we'll say so.

Get a free audit [email protected]