Skip to main content
The SDK caches resolved prompts in memory for fifteen seconds by default.

Configure the cache

Set cache: false to disable caching. Pinned versions have no TTL, but capacity eviction and same-client writes can remove them. Channel and default selectors use stale-while-revalidate. After ttlMs, the next call returns the cached value while a refresh runs. After maxStaleMs, the next call waits for refresh. If that request fails, the SDK may still return the cached value and mark it stale. Writes through the same client clear its cached selectors for that prompt.

Add a fallback

Fallbacks apply only when the API is unavailable and no cached value exists. They may be a content string or an object with content and config. Missing prompts, invalid keys, forbidden requests, and malformed selectors still throw. Keep a short fallback for prompts on a request path. Pin a version and fail the job for reproducible evals.