Documentation

Build LLM-powered agents
with production-ready TypeScript

DSPy for TypeScript. Working with LLMs is complex—they don't always do what you want. DSPy makes it easier to build amazing things with LLMs. Just define your inputs and outputs (signature) and an efficient prompt is auto-generated and used. Connect together various signatures to build complex systems and workflows using LLMs.

15+ LLM Providers
End-to-end Streaming
Auto Prompt Tuning

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:

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


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.