creamy-tiger-14805
10/10/2025, 10:20 AMtall-airline-16756
10/10/2025, 10:20 AMtall-airline-16756
10/10/2025, 10:21 AMcaching parameter to "ephemeral" when you create your LLM instance.
Here’s a quick example to guide you:
from livekit.plugins import anthropic
llm_instance = anthropic.LLM(
model="claude-3-5-sonnet-20241022",
caching="ephemeral" # Enable prompt caching
)
Once caching is turned on, the system prompt, tools, and chat history are stored temporarily. This helps avoid sending the same information repeatedly across requests, making things more efficient. Behind the scenes, this works by adding cache control metadata to both the system prompt and chat history.
If you want to check that caching is working, you can look at metrics like prompt_cached_tokens, cache_creation_tokens, and cache_read_tokens in the CompletionUsage object you get back after an inference call.
If you have any questions or want to dive deeper into this, I’m here to help!
Sources: examples/voice_agents/realtime_joke_teller.pycreamy-tiger-14805
10/10/2025, 10:21 AMtall-airline-16756
10/10/2025, 10:22 AMllm_instance. You can do this by initializing the LLM directly with the caching parameter set to "ephemeral". This option is specific to the Anthropic plugin in LiveKit.
Here's a simple example to guide you:
from livekit.plugins.anthropic import LLM
llm = LLM(
model="claude-3-5-sonnet-20241022",
caching="ephemeral" # Enables caching for system prompt, tools, and chat history
)
At the moment, this is the recommended way to enable caching for system prompts in LiveKit. If you're working with a different LLM provider like OpenAI or Google Gemini, caching might not be available out of the box. Please feel free to reach out if you'd like assistance with other options, such as setting up manual caching within your application—I’m here to help!
Sources: livekit-agents/livekit/agents/inference/llm.py | tools/server/public_legacy/index-new.html | Large language models (LLM) | LiveKit Docscreamy-tiger-14805
10/10/2025, 10:25 AMtall-airline-16756
10/10/2025, 10:25 AMinstructions parameter when you initialize, but there isn’t a built-in way to cache or reuse these prompts across different sessions without specifying them again.
If you’re aiming to optimize how prompts are handled or want to reduce latency, a good approach is to preload your instructions during agent initialization or manage the state externally. I’m here to help if you’d like some guidance on how to set this up—just let me know!
Sources: livekit-plugins/livekit-plugins-google/livekit/plugins/google/realtime/api_... | web/src/data/presets.ts | Gemini Live API plugin | LiveKit Docscreamy-tiger-14805
10/10/2025, 10:26 AMtall-airline-16756
10/10/2025, 10:27 AMcaching="ephemeral" parameter during initialization. This will cache the system prompt, tools, and chat history, making things smoother for you.
• llama.cpp: It supports caching through the cache_prompt=true flag, which is actually on by default to help optimize prompt reuse.
For Realtime GPT (OpenAI), I want to be transparent—there’s no clear indication that system prompt caching is currently supported in the LiveKit integration. Although the Realtime API offers features like chat context management and session state control, caching isn’t specifically mentioned.
If caching is really important for your work with Realtime GPT, a good workaround might be to use longer session durations to keep context or handle caching on your end externally. Please feel free to reach out if you'd like to explore this further or need any help—I’m here for you!
Sources: livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/realtime/real... | tools/server/public_simplechat/simplechat.js