Caching
Pay less for repeated work: the provider's prompt cache, and the gateway's cache of identical calls.
The provider’s cache
Many models charge less for the part of a request they read again a few minutes later. The gateway orders every request so the stable part comes first (the route’s instructions, then the tools, then the messages), so long instructions are read at the cheaper price on every call after the first. Usage shows them as cached_input_tokens.
There is nothing to turn on.
The gateway’s cache of identical calls
Off by default. Turn it on for a route whose answer can be reused:
[ai.tasks.bread-of-the-day]
cache = { ttl = "6h" }| What counts as the same call | the same route version, messages, options and schema, and the same person of your app; cache: { shared: true } shares answers between people |
| A hit | costs nothing; the response says sypnia.cache: "hit" and the trace marks it |
| How long | from 1 minute to 24 hours |
| Where | the answer is kept encrypted for that time only, then deleted: the one case where Sypnia AI keeps an answer without store |
| Never for | calls with tools |
npx @sypnia/ai cache purge --task bread-of-the-day empties a route’s cache, for example after the menu changes.