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

# Using DotPrompt

> Define your prompts as files that can be executed.

Google's [DotPrompt specification](https://google.github.io/dotprompt) allows
you to define prompts as files with metadata, templates, and validation. These
files can be executed by dartantic.

## Quick Start

You can use the `DotPrompt` class to parse `.prompt` files:

```dart theme={null}
import 'package:dotprompt_dart/dotprompt_dart.dart';

final dotPrompt = DotPrompt('''
---
model: openai
input:
  default:
    length: 3
    text: "The quick brown fox jumps over the lazy dog."
---
Summarize this in {{length}} words: {{text}}
''');

// Extract model and render prompt
final prompt = dotPrompt.render();
final agent = Agent(dotPrompt.frontMatter.model!);

final result = await agent.send(prompt);
print(result.output); // "Fox jumps dog."
```

## With Variables

You can pass variables to the `render` method:

```dart theme={null}
final dotPrompt = DotPrompt('''
---
model: anthropic
---
Translate "{{phrase}}" to {{language}}
''');

final prompt = dotPrompt.render({
  'phrase': 'Hello world',
  'language': 'Spanish',
});

final agent = Agent(dotPrompt.frontMatter.model!);
await agent.send(prompt);
```

## From Files

You can also read prompts from files:

```dart theme={null}
final file = File('prompts/summarize.prompt');
final content = await file.readAsString();
final dotPrompt = DotPrompt(content);

final agent = Agent(dotPrompt.frontMatter.model!);
await agent.send(dotPrompt.render());
```

## Examples

* [DotPrompt example](https://github.com/csells/dartantic_ai/blob/main/packages/dartantic_ai/example/bin/dotprompt.dart)
* [DotPrompt package](https://pub.dev/packages/dotprompt_dart)

## Next Steps

* [Quick Start](/quick-start) - Agent fundamentals
* [System Messages](/system-messages) - Built-in prompt management
