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

# PromptSnapshot

> Prompt configuration object within a Deployment, containing config, messages, tools, and variables.

# PromptSnapshot

The prompt configuration snapshot embedded in a [Deployment](/docs/reference/sdk/v2/typescript/types/deployment). Contains the complete prompt definition including model configuration, messages, tool definitions, and variable declarations.

## Import

```typescript theme={null}
import type { PromptSnapshot } from '@adaline/api';
```

## Type Definition

```typescript theme={null}
interface PromptSnapshot {
  config: PromptSnapshotConfig;
  messages: PromptMessage[];
  tools: ToolFunction[];
  variables: PromptVariable[];
}
```

## Properties

* `config` - Model provider and runtime settings ([PromptSnapshotConfig](/docs/reference/sdk/v2/typescript/types/PromptSnapshotConfig))
* `messages` - Ordered array of chat messages that form the prompt ([PromptMessage](/docs/reference/sdk/v2/typescript/types/PromptMessage))
* `tools` - Tool/function definitions available to the model ([ToolFunction](/docs/reference/sdk/v2/typescript/types/ToolFunction))
* `variables` - Dynamic variable declarations used in the prompt template ([PromptVariable](/docs/reference/sdk/v2/typescript/types/PromptVariable))

***

## Examples

### Accessing from a Deployment

```typescript theme={null}
import { Adaline } from '@adaline/client';
import type { Deployment, PromptSnapshot } from '@adaline/api';

const adaline = new Adaline();

const deployment: Deployment = await adaline.getLatestDeployment({
  promptId: 'prompt_abc123',
  deploymentEnvironmentId: 'environment_abc123'
});

const prompt: PromptSnapshot = deployment.prompt;

console.log(`Provider: ${prompt.config.providerName}`);
console.log(`Model: ${prompt.config.model}`);
console.log(`Messages: ${prompt.messages.length}`);
console.log(`Tools: ${prompt.tools.length}`);
console.log(`Variables: ${prompt.variables.map(v => v.name).join(', ')}`);
```

### Using with Adaline Gateway

```typescript theme={null}
import { Adaline } from '@adaline/client';
import type { PromptSnapshot } from '@adaline/api';
import { Gateway } from '@adaline/gateway';
import { OpenAI } from '@adaline/openai';

const adaline = new Adaline();
const gateway = new Gateway();
const openaiProvider = new OpenAI();

const deployment = await adaline.getLatestDeployment({
  promptId: 'prompt_abc123',
  deploymentEnvironmentId: 'environment_abc123'
});

const prompt: PromptSnapshot = deployment.prompt;

const model = openaiProvider.chatModel({
  modelName: prompt.config.model,
  apiKey: process.env.OPENAI_API_KEY!
});

const response = await gateway.completeChat({
  model,
  config: prompt.config.settings,
  messages: [
    ...prompt.messages,
    {
      role: 'user',
      content: [{ modality: 'text', value: 'Hello!' }]
    }
  ],
  tools: prompt.tools
});
```

### Injecting Variables

```typescript theme={null}
import { Adaline } from '@adaline/client';

const adaline = new Adaline();

const deployment = await adaline.getLatestDeployment({
  promptId: 'prompt_abc123',
  deploymentEnvironmentId: 'environment_abc123'
});

// Replace {{variable_name}} placeholders with your runtime values.
// See PromptVariable for the full pattern (text + image + PDF).
const variables = { user_name: 'Alice' };
const messages = deployment.prompt.messages.map((msg) => ({
  ...msg,
  content: msg.content.map((c) =>
    c.modality === 'text'
      ? { ...c, value: c.value.replace(/\{\{(\w+)\}\}/g, (m, n) => variables[n] ?? m) }
      : c,
  ),
}));
```

### Inspecting Prompt Structure

```typescript theme={null}
function inspectPrompt(prompt: PromptSnapshot) {
  // Check model configuration
  if (prompt.config.providerName) {
    console.log(`Using ${prompt.config.providerName}/${prompt.config.model}`);
  }

  // List system messages
  const systemMessages = prompt.messages.filter(m => m.role === 'system');
  console.log(`System messages: ${systemMessages.length}`);

  // List available tools
  prompt.tools.forEach(tool => {
    console.log(`Tool: ${tool.definition.schema.name}`);
  });

  // List required variables
  prompt.variables.forEach(v => {
    console.log(`Variable: {{${v.name}}} (${v.modality})`);
  });
}
```

***

## JSON

```json theme={null}
{
  "config": {
    "providerName": "openai",
    "providerId": "provider_abc123",
    "model": "gpt-4o",
    "settings": { "temperature": 0.7 }
  },
  "messages": [
    {
      "role": "system",
      "content": [{ "modality": "text", "value": "You are a helpful assistant." }]
    }
  ],
  "tools": [
    {
      "type": "function",
      "definition": {
        "schema": {
          "name": "get_weather",
          "description": "Get current weather",
          "parameters": {
            "type": "object",
            "properties": { "city": { "type": "string" } },
            "required": ["city"]
          }
        }
      }
    }
  ],
  "variables": [
    { "name": "user_name", "modality": "text" }
  ]
}
```
