Skip to content

Caching

Pay less for repeated work: the provider's prompt cache, and the gateway's cache of identical calls.

Applies to EngineCloud
View as Markdown
On this page
  1. The provider’s cache
  2. 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:

sypnia.toml
[ai.tasks.bread-of-the-day]
cache = { ttl = "6h" }
What counts as the same callthe same route version, messages, options and schema, and the same person of your app; cache: { shared: true } shares answers between people
A hitcosts nothing; the response says sypnia.cache: "hit" and the trace marks it
How longfrom 1 minute to 24 hours
Wherethe answer is kept encrypted for that time only, then deleted: the one case where Sypnia AI keeps an answer without store
Never forcalls with tools

npx @sypnia/ai cache purge --task bread-of-the-day empties a route’s cache, for example after the menu changes.

  1. The provider’s cache
  2. The gateway’s cache of identical calls

    Search pages, sections and terms