AxContextCacheOptions
type AxContextCacheOptions = object;
Defined in: https://github.com/ax-llm/ax/blob/242cf18d21de9f9d58c7c82f53305f0605497473/src/ax/ai/types.ts#L513
Options for explicit context caching (e.g., Gemini/Vertex context caching). Allows caching large prompt prefixes for cost savings and lower latency.
When this option is present, caching is enabled. The system will:
- Automatically cache the system prompt and any content marked with
cache: true - Reuse existing caches when content hash matches
- Create new caches when content changes
- Auto-refresh TTL when cache is near expiration
Properties
cacheBreakpoint?
optional cacheBreakpoint: "system" | "after-functions" | "after-examples";
Defined in: https://github.com/ax-llm/ax/blob/242cf18d21de9f9d58c7c82f53305f0605497473/src/ax/ai/types.ts#L555
Controls where the cache breakpoint is set in the prompt prefix. Prefix order: System → Functions → Examples → User Input
- ‘after-examples’ (default): Cache includes system + functions + examples
- ‘after-functions’: Cache includes system + functions only (use when examples are dynamic)
- ‘system’: Cache includes only system prompt (use when functions are dynamic)
minTokens?
optional minTokens: number;
Defined in: https://github.com/ax-llm/ax/blob/242cf18d21de9f9d58c7c82f53305f0605497473/src/ax/ai/types.ts#L532
Minimum token threshold for creating explicit caches. Content below this threshold won’t create explicit caches (implicit caching still applies). Default: 2048 (Gemini minimum requirement)
name?
optional name: string;
Defined in: https://github.com/ax-llm/ax/blob/242cf18d21de9f9d58c7c82f53305f0605497473/src/ax/ai/types.ts#L519
Explicit cache resource name/ID. If provided, this cache will be used directly (bypasses auto-creation). If omitted, a cache will be created/looked up automatically.
refreshWindowSeconds?
optional refreshWindowSeconds: number;
Defined in: https://github.com/ax-llm/ax/blob/242cf18d21de9f9d58c7c82f53305f0605497473/src/ax/ai/types.ts#L538
Window in seconds before expiration to trigger automatic TTL refresh. Default: 300 (5 minutes)
registry?
optional registry: AxContextCacheRegistry;
Defined in: https://github.com/ax-llm/ax/blob/242cf18d21de9f9d58c7c82f53305f0605497473/src/ax/ai/types.ts#L545
External registry for persisting cache metadata. If provided, cache lookups and storage will use this registry instead of in-memory storage. Useful for serverless/short-lived processes.
ttlSeconds?
optional ttlSeconds: number;
Defined in: https://github.com/ax-llm/ax/blob/242cf18d21de9f9d58c7c82f53305f0605497473/src/ax/ai/types.ts#L525
TTL (Time To Live) in seconds for the cache. Default: 3600 (1 hour). Maximum varies by provider.