Skip to main content
Prompts encapsulate model configuration, templates, and schemas. See genkit.DefinePrompt() for full API documentation.

Quick Reference

Prompt Options

Model Configuration

  • ai.WithModel(model)
  • ai.WithModelName(string)
  • ai.WithConfig(any)

Prompt Content

  • ai.WithPrompt(string) - User prompt template
  • ai.WithPromptFn(func) - Dynamic user prompt
  • ai.WithSystem(string) - System instructions
  • ai.WithSystemFn(func) - Dynamic system instructions
  • ai.WithMessages([]*Message) - Conversation history
  • ai.WithMessagesFn(func) - Dynamic messages

Input/Output

  • ai.WithInputType(T) - Input schema from type
  • ai.WithInputSchema(map[string]any) - Custom input schema
  • ai.WithOutputType(T) - Output schema from type
  • ai.WithOutputSchema(map[string]any) - Custom output schema
  • ai.WithOutputFormat(string) - Output format (json, text)

Tools

  • ai.WithTools(...Tool) - Enable tools
  • ai.WithToolChoice(ToolChoice) - Control tool usage
  • ai.WithMaxTurns(int) - Max tool iterations

Prompt Methods

Execute()

ExecuteStream()

Render()

DataPrompt (Typed)

Loading .prompt Files