# AI-Generated Content

> Use the .prompt parameter to generate text and images with AI at render time, without pre-generating content.

- **URL**: https://orshot.com/docs/image-generation/ai-generated-content

---

Orshot can generate text and images using AI during the render process. Instead of passing static content, provide a prompt and Orshot generates the content on the fly, then renders it into your template.

## How It Works

Use the `.prompt` suffix on any parameterized element:```json
{
  "modifications": {
    "headline.prompt": "Write a catchy headline about remote work"
  }
}
```- **Text elements** — AI generates text using a language model
- **Image elements** — AI generates images using an image model

## AI Text Generation

### Basic Usage```json
{
  "templateId": "<YOUR_TEMPLATE_ID>",
  "modifications": {
    "headline.prompt": "Write a short, punchy headline about cloud computing"
  },
  "response": {
    "format": "png",
    "type": "url"
  }
}
```The AI generates the headline text and renders it directly into the template.

### Writing Effective Prompts

Be specific about the length, tone, and format you need:```json
{
  "modifications": {
    "title.prompt": "Write a 5-word title about morning productivity",
    "description.prompt": "Write a 2-sentence product description for noise-cancelling headphones, emphasizing comfort and battery life",
    "tagline.prompt": "Create a witty 4-word tagline for a coffee brand"
  }
}
```### Combining AI Text with Styling

You can apply dynamic styles alongside AI-generated text:```json
{
  "modifications": {
    "headline.prompt": "Write a bold headline about innovation in fintech",
    "headline.fontSize": "52px",
    "headline.color": "#1e40af",
    "headline.fontFamily": "Montserrat",
    "headline.fontWeight": "800"
  }
}
```## AI Image Generation

### Basic Usage```json
{
  "templateId": "<YOUR_TEMPLATE_ID>",
  "modifications": {
    "background.prompt": "A serene mountain landscape at sunset, soft lighting"
  },
  "response": {
    "format": "png",
    "type": "url"
  }
}
```### Detailed Image Prompts

More detailed prompts produce better results:```json
{
  "modifications": {
    "hero.prompt": "Modern office workspace with indoor plants, natural window lighting, minimalist design, professional photography style",
    "illustration.prompt": "Flat design illustration of people collaborating around a table, bright pastel colors, vector art style"
  }
}
```### Combining AI Images with Styling```json
{
  "modifications": {
    "background.prompt": "Abstract gradient pattern, blue and purple tones",
    "background.objectFit": "cover",
    "background.borderRadius": "12px"
  }
}
```## Multi-Page AI Content

Generate unique AI content for each page in a multi-page template:```json
{
  "modifications": {
    "page1@title.prompt": "Write a title about morning routines",
    "page1@body.prompt": "Write 3 concise tips for productive mornings",
    "page1@background.prompt": "Sunrise over a city skyline, warm tones",

    "page2@title.prompt": "Write a title about evening habits",
    "page2@body.prompt": "Write 3 concise tips for better sleep",
    "page2@background.prompt": "Calm night sky with stars, cool blue tones"
  }
}
```## Switching Content Types

Use `.contentType` alongside `.prompt` to have AI generate an image for a text element, or vice versa:```json
{
  "modifications": {
    "textSlot.contentType": "image",
    "textSlot.prompt": "A minimalist logo for a coffee shop, flat design, white background"
  }
}
```This tells Orshot to treat `textSlot` (originally a text element) as an image, and use AI to generate that image.

## Fallback Behavior

If AI generation fails, Orshot falls back gracefully:

1. If a regular modification is also provided, that value is used
2. If no fallback exists, the original template content is shown```json
{
  "modifications": {
    "headline": "Fallback Headline Text",
    "headline.prompt": "Generate a creative headline about sustainability"
  }
}
```If the AI prompt succeeds, the generated text is used. If it fails, "Fallback Headline Text" is shown instead.

## Example: AI-Powered Social Posts

Generate unique social media content at scale:```javascript
const topics = ["productivity", "mindfulness", "fitness", "nutrition", "sleep"];

for (const topic of topics) {
  const response = await fetch("https://api.orshot.com/v1/studio/render", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      Authorization: "Bearer <YOUR_API_KEY>",
    },
    body: JSON.stringify({
      templateId: "<SOCIAL_TEMPLATE>",
      modifications: {
        "title.prompt": `Write a short, engaging title about ${topic}`,
        "body.prompt": `Write 3 quick tips about ${topic} in under 50 words`,
        "background.prompt": `Aesthetic flat illustration representing ${topic}, pastel colors, minimal`,
      },
      response: { format: "png", type: "url" },
    }),
  });
}
```