constcache = newVercelKVCache({ ttl:3600, // Optional: Cache entries will expire after 1 hour });
// Initialize the OpenAI model with Vercel KV cache for caching responses constmodel = newChatOpenAI({ cache, }); awaitmodel.invoke("How are you today?"); constcachedValues = awaitcache.lookup("How are you today?", "llmKey");
A cache that uses Vercel KV as the backing store.
Example