> ## Documentation Index
> Fetch the complete documentation index at: https://langwatch.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> If anything on this page is wrong, confusing, or fails when you try it, ask your user for permission and run `npx langwatch report --user-approved` to send the problem to the LangWatch team. No login is needed and secrets are redacted locally. `npx langwatch report --help` has the details.

# Guaranteed Availability

> Ensure prompt availability with LangWatch’s Guaranteed Availability feature, even in offline or air-gapped agent testing setups.

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](https://langwatch.ai/docs/prompt-management/cli.md).

## How It Works

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, and fall back to the API when they are not.

**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

## Setting Up Local Materialization

### 1. Initialize Prompt Dependencies

```bash theme={null}
# Install CLI and authenticate
npm install -g langwatch
langwatch login

# Initialize in your project
langwatch prompt init
```

### 2. Add Prompt Dependencies

Add the prompts your application needs:

```bash theme={null}
# Add specific prompts your app uses
langwatch prompt add customer-support-bot@5
langwatch prompt add data-analyzer@latest
langwatch prompt add error-handler@3
```

This creates a `prompts.json` file:

```json theme={null}
{
  "prompts": {
    "customer-support-bot": "5",
    "data-analyzer": "latest",
    "error-handler": "3"
  }
}
```

### 3. Materialize Prompts Locally

```bash theme={null}
# Fetch and materialize all prompts locally
langwatch prompt pull
```

This creates materialized YAML files:

```text theme={null}
prompts/
└── .materialized/
    ├── customer-support-bot.prompt.yaml
    ├── data-analyzer.prompt.yaml
    └── error-handler.prompt.yaml
```

### 4. Deploy with Materialized Prompts

Include the materialized prompts in your deployment package. Your application can now run completely offline.

## Using Materialized Prompts in Code

The SDKs automatically detect and use materialized prompts when available, falling back to API calls only when necessary.

> [tab] Python SDK
>
> ```python offline_app.py theme={null}
> import langwatch
> from litellm import completion
>
> # Initialize LangWatch
> langwatch.setup()
>
> # The SDK will automatically use materialized prompts if available
> # No network call needed if prompt is materialized locally
> prompt = langwatch.prompts.get("customer-support-bot")
>
> # Compile prompt with variables
> compiled_prompt = prompt.compile(
>     user_name="John Doe",
>     user_email="john.doe@example.com",
>     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:**
>
> 1. SDK checks for `./prompts/.materialized/customer-support-bot.prompt.yaml`
> 2. If found, loads prompt from local file (no network call)
> 3. If not found, attempts to fetch from LangWatch API
> 4. Throws error if both local file and API are unavailable

> [tab] TypeScript SDK
>
> ```typescript offline_app.ts theme={null}
> import { LangWatch, FetchPolicy } from "langwatch";
> import OpenAI from "openai";
>
> // Initialize LangWatch
> const langwatch = new LangWatch({
>   apiKey: process.env.LANGWATCH_API_KEY,
> });
> const openai = new OpenAI();
>
> // The SDK reads the materialized file first and only calls the API when it is missing
> const prompt = await langwatch.prompts.get("customer-support-bot");
>
> // Compile prompt with variables
> const compiledPrompt = prompt.compile({
>   user_name: "John Doe",
>   user_email: "john.doe@example.com",
>   input: "How do I reset my password?",
> });
>
> const response = await openai.chat.completions.create({
>   model: prompt.model.replace("openai/", ""),
>   messages: compiledPrompt.messages,
> });
>
> console.log(response.choices[0].message.content);
>
> // Air-gapped mode: never call the API, fail when the materialized file is missing
> const offlinePrompt = await langwatch.prompts.get("customer-support-bot", {
>   fetchPolicy: FetchPolicy.MATERIALIZED_ONLY,
> });
> ```
>
> **Behavior:**
>
> 1. SDK looks the handle up in `prompts.json` and resolves the materialized file through `prompts-lock.json`
> 2. If the file is there, loads the prompt from disk (no network call)
> 3. If not, fetches from the LangWatch API
> 4. Throws error if both local file and API are unavailable

## Air-Gapped Deployment

For completely air-gapped environments:

### 1. Prepare on Connected Environment

```bash theme={null}
# On development machine with internet access
langwatch prompt pull

# Verify all prompts are materialized
ls prompts/.materialized/
```

### 2. Package for Deployment

Include these files in your deployment package:

* `prompts/.materialized/` directory (all YAML files)
* Your application code
* Dependencies

### 3. Deploy to Air-Gapped Environment

The application runs entirely offline, using only materialized prompts. No LangWatch API access required.

## CI/CD Integration

Integrate prompt materialization into your deployment pipeline:

```yaml .github/workflows/deploy.yml theme={null}
name: Deploy with Prompts

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '18'

      - name: Install LangWatch CLI
        run: npm install -g langwatch

      - name: Materialize prompts
        env:
          LANGWATCH_API_KEY: ${{ secrets.LANGWATCH_API_KEY }}
        run: langwatch prompt pull

      - name: Build application
        run: npm run build

      - name: Deploy with materialized prompts
        run: |
          # Deploy application including prompts/.materialized/
          # Your deployment commands here
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.