Skip to main content

PromptVariable

Types for prompt variables with modality definitions.

Overview

Variable types define dynamic content that can be injected into prompts, with support for multiple modalities.

PromptVariable

Prompt variable with name and modality.
Properties:
  • name - Variable name (used as {{variable_name}} in prompts)
  • modality - Variable modality type (VariableModality)
Example:
JSON:

VariableModality

See the dedicated VariableModality page for full documentation. Variable modality type enumeration.
Values:
  • 'text' - Plain text content
  • 'image' - Image content (URL or base64)
  • 'pdf' - PDF document content
  • 'api' - External API data source
  • 'prompt' - Nested prompt reference
Example:

VariableValue

See the dedicated VariableValue page for full documentation. Variable value type, discriminated by modality. Used when providing values for prompt variables.
Example:

Using with Deployments


Replacing variables at runtime

The SDK returns deployments with {{variable_name}} placeholders intact — substitute them yourself before sending the prompt to your AI provider.

Text variables

Image and PDF variables

For non-text variables, replace a text content item whose entire value is {{variable_name}} with the corresponding ImageContent or PdfContent item:
Image and PDF variables can only replace a text content item whose entire value is {{variable_name}}. A placeholder embedded in larger text (e.g., "See: {{pic}}") cannot be swapped for a binary modality.