Ensure your prompts are always available, even in offline or air-gapped environments
Guaranteed availability ensures your application can continue operating with prompts even when disconnected from the LangWatch platform. This is achieved through local prompt materialization using the Prompts CLI.
When you use the Prompts CLI to manage dependencies, prompts are materialized locally as standard YAML files. The LangWatch SDKs automatically detect and use these materialized prompts when available, providing seamless fallback behavior.Benefits:
Offline operation - Your application works without internet connectivity
Air-gapped deployments - Deploy in secure environments with no external access
Reduced latency - No network calls for prompt retrieval
Guaranteed consistency - Prompts are locked to specific versions in your deployment
The SDKs automatically detect and use materialized prompts when available, falling back to API calls only when necessary.
offline_app.py
Copy
import langwatchfrom litellm import completion# Initialize LangWatchlangwatch.setup()# The SDK will automatically use materialized prompts if available# No network call needed if prompt is materialized locallyprompt = langwatch.prompts.get("customer-support-bot")# Compile prompt with variablescompiled_prompt = prompt.compile( user_name="John Doe", user_email="[email protected]", input="How do I reset my password?")# Use with LiteLLM (no need to strip provider prefixes)response = completion( model=compiled_prompt.model, messages=compiled_prompt.messages)print(response.choices[0].message.content)
Behavior:
SDK checks for ./prompts/.materialized/customer-support-bot.prompt.yaml
If found, loads prompt from local file (no network call)
If not found, attempts to fetch from LangWatch API
Throws error if both local file and API are unavailable