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

# Prompts

> Versioned prompt templates with variables, structured output, fallback chains, and A/B testing.

Prompts are versioned templates that separate prompt content from application code. Edit them in the dashboard, publish a version, and call them by slug from your app — no deploy needed.

## Creating a prompt

1. Go to **Prompts → New Prompt** (or use the `/prompts/new` route)
2. Pick a **model** (provider/model format)
3. Write your **system prompt** and **user message** template
4. Define **variables** (placeholders like `{{topic}}` that get filled at runtime)
5. Optionally configure: structured output schema, fallback chain, temperature, max tokens

## Variables

Variables are `{{double_braced}}` placeholders in your prompt template. Define them in the prompt editor with a name, type, and description:

```
Write a {{style}} summary of the following document in {{language}}:

{{document}}
```

Types: `string`, `number`, `boolean`. Required variables must be passed at runtime — the gateway returns a 400 if any are missing.

See [Prompt Engineering](/dashboard/prompt-engineering) for details on variables, partials, and fallback chains.

## Running a prompt

```bash theme={null}
curl https://gateway.yourapp.com/v1/prompts/my-summarizer/run \
  -H "Authorization: GatelitKey sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "variables": {
      "style": "concise",
      "language": "French",
      "document": "The quick brown fox..."
    }
  }'
```

Or with the SDK:

```ts theme={null}
const response = await client.chat({
  model: "openai/gpt-4o",
  messages: [{ role: "user", content: "placeholder" }],
  promptId: "my-summarizer",
})
```

The `promptId` field tags the request for log correlation — the prompt's template content is **not** used. To execute a prompt's actual template with variable interpolation, use `POST /v1/prompts/{slug}/run`.

## Versioning

Each edit creates a new draft. When you're ready:

1. Click **Publish** — creates a new version
2. The published version is cached by the gateway (60s TTL)
3. Existing API calls continue to use the previously published version until the cache expires

You can view and compare previous versions in the prompt's **Versions** tab.

## A/B testing

Enable A/B testing on a prompt to split traffic between the published version and a variant:

1. Create a new version with your changes
2. Enable A/B testing with a split ratio (e.g., 50/50)
3. The gateway randomly picks which version to serve per request
4. Compare results in the **Eval** tab

## Evals and scenarios

Define test scenarios with expected inputs and assertions, then run evals to compare prompt versions. See the **Eval** tab inside each prompt for the full workflow.

## Output schema

Attach a JSON schema to a prompt to enforce structured output. The gateway translates the schema to the provider's native format automatically. Define the schema in the prompt editor using the visual schema builder or raw JSON.

## Fallback chains

Configure fallback models per prompt. If the primary model returns a rate limit, provider error, timeout, or context limit, the gateway tries the next model in the chain:

```json theme={null}
[
  { "model": "openai/gpt-4o", "triggers": ["rate_limit"] },
  { "model": "anthropic/claude-3-5-haiku-20241022", "triggers": ["provider_error", "timeout"] },
  { "model": "google/gemini-2.5-flash" }
]
```

Without a `triggers` array, the fallback fires on **any** error — useful as a last-resort catch-all.

<Frame>
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/gatelit/images/dashboard/prompts.png" alt="Prompt editor" />
</Frame>
