# AI Generation with .prompt

> Generate dynamic text and images using AI with the .prompt parameter

- **URL**: https://orshot.com/docs/dynamic-parameters/prompt

---

## Overview

The `.prompt` parameter enables AI-powered content generation for text and image elements. Instead of providing static content, you can supply a natural language prompt that generates contextual content on-the-fly.

## How It Works

When you add `.prompt` to a parameterized element, Orshot uses AI to generate appropriate content:

- **Text elements** - Generates text using `openai/gpt-5-nano`
- **Image elements** - Generates images using `google/nano-banana`

The generated content replaces the element's default content during render.

## Syntax```
parameterID.prompt
```For multi-page templates:```
pageN@parameterID.prompt
```## Text Generation

### Basic Usage```json
{
  "modifications": {
    "headline.prompt": "Write a catchy headline about coffee"
  }
}
```This generates AI text for the `headline` element instead of using its template default.

### Detailed Prompts

Be specific to get better results:```json
{
  "modifications": {
    "description.prompt": "Write a 2-sentence product description for wireless headphones with noise cancellation, emphasizing comfort and battery life",
    "tagline.prompt": "Create a 5-word motivational tagline about productivity"
  }
}
```### Multi-Page Example```json
{
  "modifications": {
    "page1@title.prompt": "Write a title about morning routines",
    "page2@title.prompt": "Write a title about evening habits",
    "page1@body.prompt": "Write 3 tips for productive mornings",
    "page2@body.prompt": "Write 3 tips for better sleep"
  }
}
```## Image Generation

### Basic Usage```json
{
  "modifications": {
    "background.prompt": "A serene mountain landscape at sunset"
  }
}
```### Detailed Image Prompts

Include style, mood, and composition details:```json
{
  "modifications": {
    "hero.prompt": "Modern office workspace with plants, natural lighting, minimalist design, professional photography style",
    "illustration.prompt": "Flat design illustration of people collaborating, bright colors, vector art style"
  }
}
```### Multi-Page Image Generation```json
{
  "modifications": {
    "page1@background.prompt": "Sunrise over city skyline, golden hour",
    "page2@background.prompt": "Busy city street at noon, aerial view",
    "page3@background.prompt": "City lights at night, long exposure"
  }
}
```## Combining with Regular Parameters

You can mix `.prompt` with regular parameters to refine the output:```json
{
  "modifications": {
    "title.prompt": "Write a headline about innovation",
    "title.fontSize": "48px",
    "title.color": "#0066cc",
    "title.fontFamily": "Montserrat"
  }
}
```The AI generates the text content, while the style parameters control its appearance.

## Element Type Validation

The `.prompt` parameter only works with **text** and **image** elements:

✅ **Supported:**```json
{
  "textElement.prompt": "...", // ✓ Text element
  "imageElement.prompt": "..." // ✓ Image element
}
```❌ **Not Supported:**```json
{
  "rectangle.prompt": "...", // ✗ Shape element - ignored
  "circle.prompt": "..." // ✗ Shape element - ignored
}
```If you try to use `.prompt` on unsupported elements, Orshot will:

1. Log a warning
2. Skip the prompt generation
3. Use the element's default content

## Fallback Behavior

When AI generation fails (network issues, API errors, etc.), Orshot falls back gracefully:

1. **Regular modification exists** - Uses the regular parameter value

   ```json
   
   ```

   If AI fails, it uses "Fallback Title"

2. **No regular modification** - Uses template default
   If AI fails and no fallback is provided, the element shows its original template content

## Best Practices

### Text Prompts

1. **Be Specific** - Include length, tone, and context

   ```json
   
   ```

2. **Set Constraints** - Specify word/sentence count

   ```json
   
   ```

3. **Define Tone** - Mention style or emotion
   ```json
   
   ```

### Image Prompts

1. **Include Style** - Specify artistic style or medium

   ```json
   
   ```

2. **Describe Composition** - Mention perspective and layout

   ```json
   
   ```

3. **Add Context** - Include mood and atmosphere
   ```json
   
   ```

## Real-World Examples

### Social Media Post Generator```json
{
  "modifications": {
    "post_text.prompt": "Write an engaging Instagram caption about travel adventure, include 2 relevant hashtags",
    "background.prompt": "Tropical beach sunset, vibrant colors, palm trees silhouette",
    "username": "@traveler",
    "username.fontSize": "18px"
  }
}
```### Dynamic Report Headers```json
{
  "modifications": {
    "page1@title.prompt": "Create a professional title for a Q4 2024 sales report",
    "page1@summary.prompt": "Write a 2-sentence executive summary highlighting 25% growth",
    "company_name": "Acme Corp",
    "report_date": "Q4 2024"
  }
}
```### Personalized Certificates```json
{
  "modifications": {
    "achievement.prompt": "Write a formal achievement description for completing a Python programming course",
    "recipient_name": "John Doe",
    "date": "December 20, 2024",
    "recipient_name.fontSize": "36px"
  }
}
```## API Integration Examples

### REST API```bash
curl -X POST https://api.orshot.com/v1/studio/render \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "templateId": "your-template-id",
    "modifications": {
      "headline.prompt": "Write a tech startup tagline",
      "hero.prompt": "Modern tech office with engineers collaborating",
      "headline.fontSize": "48px"
    },
    "response": {
      "format": "png",
      "type": "url"
    }
  }'
```### Dynamic URL```markdown
https://api.orshot.com/v1/studio/dynamic-url/motivational-quote?
title.prompt=Create%20a%20motivational%20quote%20about%20success&
background.prompt=Inspirational%20mountain%20peak%20at%20sunrise&
title.fontSize=42px&
title.color=%23ffffff
```## Limitations & Considerations

1. **AI Credits Required** - Text and image generation consumes AI credits based on your plan
2. **Generation Time** - AI prompts add processing time (typically 2-5 seconds per element)
3. **Rate Limits** - Subject to plan-based rate limits for AI generation
4. **Content Safety** - Generated content passes through safety filters
5. **Determinism** - Same prompt may generate slightly different results each time

## Next Steps

- Learn about [Adding Interactive Links](https://orshot.com/docs/dynamic-parameters/link)
- Explore [Dynamic Parameters Introduction](https://orshot.com/docs/dynamic-parameters)
- Check [Pricing & Plans](https://orshot.com/pricing) for AI credit limits