Skip to main content

Prompts API

Prompts in Genkit provide a structured way to define and manage model interactions with built-in support for templates, schemas, and tool integration.

definePrompt()

Defines and registers a prompt based on a function or template. Signature:

Parameters

PromptConfig
required
Prompt configuration
string | PromptFn
Template string or function (deprecated - use options.messages instead)

Returns

ExecutablePrompt
An executable prompt that can be called like a function

Example

prompt()

Looks up a prompt by name (from .prompt files or defined prompts). Signature:

Parameters

string
required
Prompt name (without .prompt extension)
object

Example

loadPromptFolder()

Loads all .prompt files from a directory. Signature:

Parameters

string
required
Path to directory containing .prompt files
string
default:"''"
Namespace prefix for loaded prompts

Example

Dotprompt Files

Genkit supports .prompt files using a YAML-like format:

Usage

Prompt Types

PromptConfig

ExecutablePrompt

PromptGenerateOptions

Options when executing a prompt:

Usage with Genkit Instance

See Also