prehistoric-alligator-43413
10/24/2025, 7:30 PMtall-airline-16756
10/24/2025, 7:30 PMtall-airline-16756
10/24/2025, 7:31 PMchat-persistent.sh script. This handy feature saves processed prompt tokens to disk and reuses them across interactions, helping speed things up. You can easily set this up using environment variables like PROMPT_CACHE_FILE and CHAT_SAVE_DIR. It’s a great option for achieving low-latency with local AI agents.
• Cloud Integration with Anthropic: For those using cloud-based models, LiveKit integrates smoothly with Anthropic and supports ephemeral prompt caching. Just set caching="ephemeral" in the LLM constructor, and it will automatically cache key parts of the prompt, like the last system and assistant messages, to avoid redundant processing.
If you'd like, I’m here to guide you through the detailed steps for either method. Just let me know whether your setup is local or cloud-based, and we can take it from there together!
Sources: livekit-plugins/livekit-plugins-anthropic/livekit/plugins/anthropic/utils.p... | tools/server/public_simplechat/readme.mdprehistoric-alligator-43413
10/24/2025, 7:33 PMtall-airline-16756
10/24/2025, 7:34 PMprompt_cache_key parameter available in LiveKit's plugins. Let me walk you through how to set it up:
• OpenAI Models: You can use the OpenAI plugin and specify a prompt_cache_key when initializing the LLM. Here's a simple example:
from livekit.plugins import openai
llm = openai.LLM(
model="gpt-4o",
prompt_cache_key="my_openai_cached_prompt"
)
• If you're working with Azure OpenAI, you can also include the azure_endpoint and azure_deployment parameters to make it work smoothly.
• Groq LLaMA Models: In a similar way, you can use the Groq plugin and set the prompt_cache_key like this:
from livekit.plugins import groq
llm = groq.LLM(
model="llama-3.3-70b-versatile",
prompt_cache_key="my_cached_prompt"
)
By using consistent cache keys for similar prompt patterns, you'll get the best out of caching, improving performance and reducing latency. If you have any questions or want a hand with the setup, just let me know—I'm here to help!
Sources: livekit-plugins/livekit-plugins-anthropic/livekit/plugins/anthropic/llm.py | plugins/openai/src/stt.ts | tools/main/README.mdprehistoric-alligator-43413
10/24/2025, 7:35 PMtall-airline-16756
10/24/2025, 7:36 PMprompt_cache_key uniquely captures the structure of your prompt while staying consistent for similar prompts. Let me walk you through an example and some helpful tips:
Example: OpenAI Model with Prompt Caching
from livekit.plugins import openai
# Define a consistent cache key based on the prompt structure
cache_key = "user123_session1_prompt_v1"
llm = openai.LLM(
model="gpt-4o",
prompt_cache_key=cache_key
)
# Send a prompt to the model
response = llm.generate(
prompt="What is the capital of France?"
)
Best Practices for Cache Keys
• Consistency: Try to use the same cache key for prompts that share the same structure. For example, if your prompt always includes a system message and user input, make sure the cache key reflects that.
• Uniqueness: It’s helpful to include identifiers like user IDs, session IDs, or version numbers so different prompts don’t conflict.
• Granularity: Avoid making the cache key too detailed (like including the entire prompt text) because that can limit how often the cache is reused.
Example Cache Key Strategy
For instance, in a chatbot application, you might organize your cache keys like this:
• `"chatbot_v1_user123_session1"`: This is for a specific user and session.
• `"chatbot_v1_system_prompt"`: This could be for a shared system prompt used across sessions.
Following these guidelines can really help your cache work efficiently, making your application faster and smoother. If anything isn’t clear or you want to dive deeper, just let me know—I’m here to help!prehistoric-alligator-43413
10/24/2025, 7:40 PMtall-airline-16756
10/24/2025, 7:41 PMprompt_cache_key parameter is still available and fully supported in LiveKit for OpenAI models. It hasn’t been deprecated at all. While OpenAI does manage some caching behind the scenes, using prompt_cache_key gives you that extra control to fine-tune caching for specific prompt patterns, which can really help boost performance in certain cases.
Feel free to keep using prompt_cache_key in your LiveKit setups without any worries about it going away. If you have any more questions or need a hand with anything else, I’m here to help!
Sources: livekit-plugins/livekit-plugins-baseten/livekit/plugins/baseten/llm.pyprehistoric-alligator-43413
10/24/2025, 7:57 PMtall-airline-16756
10/24/2025, 7:57 PMchatbot_v1_user123_session1
• For a shared system prompt: chatbot_v1_system_prompt
Best Practices:
• Keep the key concise but descriptive, so it’s easy to understand.
• Make sure similar prompts use consistent keys to get the most out of your cache.
• Try to avoid including data that changes a lot (like the full prompt text) to prevent unnecessary cache misses.
If you’d like, I’d be happy to help you design a cache key tailored to your specific needs — just let me know!tall-airline-16756
10/24/2025, 8:01 PM{agentName}_{businessType}_{callFlowVersion}_{businessHoursVersion}_{knowledgeBaseVersion}
Example Cache Key:
real-estate_real-estate_v1_v1_v1
Explanation:
• agentName: This represents the agent, like "real-estate".
• businessType: Specifies your type of business, for example, "real-estate".
• callFlowVersion: A version number for your call flow setup. You’d increase this whenever the call flow changes.
• businessHoursVersion: A version number for your business hours. Update this if your schedule changes.
• knowledgeBaseVersion: A version number for your knowledge base. Increment this when you update the content.
How to Use:
1. Start by assigning version numbers to your call flow, business hours, and knowledge base configurations.
2. Then, combine these parts into one string as shown above.
3. Finally, use this cache key in your prompt_cache_key parameter when you initialize the LLM.
If you have any questions or need a hand with implementing this, please don’t hesitate to reach out—I’m here to help!prehistoric-alligator-43413
10/24/2025, 8:05 PMprompt_cache_key
parameter looks inside?tall-airline-16756
10/24/2025, 8:06 PMprehistoric-alligator-43413
10/24/2025, 8:08 PM