# GenAIScript Cheat Sheet

[Section titled “GenAIScript Cheat Sheet”](#genaiscript-cheat-sheet)

Quick reference guide for GenAIScript syntax, core functions, and common patterns.

## Quick Reference

[Section titled “Quick Reference”](#quick-reference)

| Function      | Purpose                   | Example                                                  |
| ------------- | ------------------------- | -------------------------------------------------------- |
| `script()`    | Configure script metadata | `script({ title: "My Script", model: "openai:gpt-4o" })` |
| `def()`       | Include content in prompt | `def("FILES", env.files)`                                |
| ` $``...`` `  | Create prompt template    | `$`Analyze the FILES``                                   |
| `defTool()`   | Define custom tool        | `defTool("weather", "Get weather", {}, () => "sunny")`   |
| `defSchema()` | Define data schema        | `defSchema("DATA", { type: "object" })`                  |
| `runPrompt()` | Execute inline prompt     | `await runPrompt((_) => _.$`Hello`)`                     |

## Basic Script Structure

[Section titled “Basic Script Structure”](#basic-script-structure)

### Minimal Script

[Section titled “Minimal Script”](#minimal-script)

```js
$`Write a poem about code.`;
```

### Complete Script

[Section titled “Complete Script”](#complete-script)

```js
script({
  title: "My Script",
  description: "Does something useful",
  model: "openai:gpt-4o",
  temperature: 0.1,
});


def("FILES", env.files);
$`Analyze FILES and provide insights.`;
```

### Markdown Script Alternative

[Section titled “Markdown Script Alternative”](#markdown-script-alternative)

script.genai.md

```markdown
---
title: "My Script"
description: "Does something useful"
model: "openai:gpt-4o"
---