From 22e44c6c3b37dec51e6d0c7edd7996b316fbb2f7 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Fri, 17 Apr 2026 02:54:56 +0100 Subject: Explicitly enable automatic prompt caching. --- kaagum/openai.scm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kaagum/openai.scm b/kaagum/openai.scm index 5e4cab5..f57cc25 100644 --- a/kaagum/openai.scm +++ b/kaagum/openai.scm @@ -95,6 +95,17 @@ compatible with the OpenAI API specification." #:headers `((authorization . ,(string-append "Bearer " api-key))) #:json `(("model" . ,model) + ;; Some providers (like Anthropic) require you to + ;; explicitly enable automatic prompt caching. See + ;; https://openrouter.ai/docs/guides/best-practices/prompt-caching + ("cache_control" + ("type" . "ephemeral") + ;; Anthropic offers cheaper cache writes for a ttl of 5 + ;; minutes. But, it doesn't make a difference for an + ;; extended session and is not worth it for our use case. + ;; If we change our mind about this, we can make this a + ;; configurable parameter. + ("ttl" . "1h")) ("messages" . ,(list->vector messages)) ("tools" . ,(list->vector tools))))) -- cgit 1.4.1