> ## Documentation Index
> Fetch the complete documentation index at: https://docs.magichour.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# AI Meme Generator API

> Create AI-generated memes using popular templates and custom topics.

export const ToolSection = ({type = "image", outputs = [], title = "", productSlug = "", apiSlug = ""}) => <>
    <CardGroup cols={2}>
      <Card title={`${title} API reference`} icon="webhook" horizontal href={`/api-reference/${type}-projects/${apiSlug}`}>
        Request fields, responses, and examples
      </Card>
      <Card title="API quickstart" icon="forward-fast" horizontal href="/get-started/quick-start">
        Install an SDK and complete your first generation
      </Card>
    </CardGroup>

    <p>
      Check <a href="/billing/overview">API pricing</a> and <a href="/api-reference/models">model credit costs</a>, then <a href={`https://magichour.ai/developer?tab=api-keys&ref=docs-tool-${apiSlug}&utm_source=docs&utm_medium=referral&utm_campaign=tools`}>create an API key</a>.
    </p>
    <p>
      To try {title} without code, use the <a href={`https://magichour.ai/products/${productSlug}${productSlug.includes("?") ? "&" : "?"}utm_source=docs&utm_medium=referral&utm_campaign=tools`}>browser tool</a>.
    </p>

    {outputs && outputs.length > 0 && <Tabs>
        {outputs.map((output, idx) => <Tab key={idx} title={`Example Output ${idx + 1}`}>
            <Frame>
              {type === "video" ? <video controls preload="metadata" playsInline className="rounded-lg h-80" src={`${output.src}#t=0.001`} type={`${output.src?.endsWith("mp4") ? 'video/mp4' : "video/webm"}`}>
                </video> : type === "audio" ? <audio controls preload="metadata" className="w-full" src={output.src}>
                  Your browser does not support the audio element.
                </audio> : <img height="320" className="rounded-lg h-80" src={output.src} alt={`${title} example output ${idx + 1}`} />}
            </Frame>
          </Tab>)}
      </Tabs>}

  </>;

## Overview

AI Meme Generator writes panel text for your chosen meme template and topic.

<ToolSection
  title="AI Meme Generator"
  productSlug="ai-meme-generator"
  apiSlug="ai-meme-generator"
  type="image"
  outputs={[
{
  src: "/get-started/images/ai-meme-generator-example1.jpg",
},
{
  src: "/get-started/images/ai-meme-generator-example2.png",
},
]}
/>

## How It Works

1. **Choose a template** - Select from popular meme formats (Drake Hotline Bling, Two Buttons, etc.)
2. **Provide a topic** - Describe what the meme should be about
3. **Optional web search** - Enable AI to search for relevant context
4. **API generates text** - AI creates appropriate text for the meme panels
5. **Download** - Retrieve your completed meme

## Use Cases

* **Social media content** - Quick meme generation for engagement
* **Marketing campaigns** - Relatable brand content
* **Internal communications** - Team humor and culture building
* **Educational content** - Making learning more engaging
* **Community management** - Timely responses to trends

## Best Practices

### Topic Selection

<Tip>**Be specific about your topic** - Clear topics generate more relevant and funny memes.</Tip>

**✅ Good topics:**

* "When the code finally works after 3 hours of debugging"
* "Designers vs developers arguing about button placement"
* "Coffee before and after the first sip"
* "Me explaining my job to my parents"

**❌ Avoid:**

* Vague topics like "work" or "life"
* Topics requiring extensive context
* Offensive or controversial subjects

### Template Selection

Popular templates work best with their intended formats:

| Template            | Best For             | Example Topic                       |
| :------------------ | :------------------- | :---------------------------------- |
| Drake Hotline Bling | Preferences, choices | "Old code vs new refactored code"   |
| Gru's Plan          | Plans that backfire  | "Rewriting it in Rust to save time" |
| Two Buttons         | Difficult decisions  | "Fix bug or add feature"            |
| Galaxy Brain        | Progressive ideas    | "Levels of code optimization"       |

`template` accepts `Random` or a supported template name, including `Distracted Boyfriend`, `This Is Fine`, and `Surprised Pikachu`. See the [API reference](/api-reference/image-projects/ai-meme-generator) for the complete template enum. Keep `topic` between 1 and 200 characters.

### Web Search Option

Use `search_web` in the Python SDK and `searchWeb` in Node.js or raw JSON.

* Enable web search when your topic references current events or trends.
* Leave web search disabled, the default, for topics that don't need current context.
* Web search may add slight processing time but improves relevance

## Code Examples

### Basic Meme Generation

<CodeGroup>
  ```python Python theme={null}
  from magic_hour import Client
  import os

  client = Client(token=os.getenv("MAGIC_HOUR_API_KEY"))

  result = client.v1.ai_meme_generator.generate(
      style={
          "search_web": False,
          "template": "Drake Hotline Bling",
          "topic": "When the code finally works after hours of debugging"
      },
      name="Code Works Meme",
      wait_for_completion=True,
      download_outputs=True,
      download_directory="."
  )

  if result.status == "complete":
      print(f"✅ Meme complete!")
      print(f"Downloaded to: {result.downloaded_paths}")
      print(f"Credits charged: {result.credits_charged}")
  else:
      print(f"❌ Job failed with status: {result.status}")
      if result.error:
          print(f"Error: {result.error.code}: {result.error.message}")
  ```

  ```javascript Node.js theme={null}
  import { Client } from "magic-hour";

  const client = new Client({ token: process.env.MAGIC_HOUR_API_KEY });

  const result = await client.v1.aiMemeGenerator.generate(
    {
      style: {
        searchWeb: false,
        template: "Drake Hotline Bling",
        topic: "When the code finally works after hours of debugging",
      },
      name: "Code Works Meme",
    },
    {
      waitForCompletion: true,
      downloadOutputs: true,
      downloadDirectory: ".",
    }
  );

  console.log(`Status: ${result.status}`);
  console.log(`Downloaded to: ${result.downloadedPaths}`);
  ```
</CodeGroup>

### Random Template

<CodeGroup>
  ```python Python theme={null}
  result = client.v1.ai_meme_generator.generate(
      style={
          "search_web": False,
          "template": "Random",
          "topic": "Forgetting to turn the stove off at 2am"
      },
      name="Stove Meme",
      wait_for_completion=True,
      download_outputs=True,
      download_directory="."
  )

  if result.status == "complete":
      print(f"✅ Meme complete!")
      print(f"Downloaded to: {result.downloaded_paths}")
      print(f"Credits charged: {result.credits_charged}")
  else:
      print(f"❌ Job failed with status: {result.status}")
      if result.error:
          print(f"Error: {result.error.code}: {result.error.message}")
  ```

  ```javascript Node.js theme={null}
  const result = await client.v1.aiMemeGenerator.generate(
    {
      style: {
        searchWeb: false,
        template: "Random",
        topic: "Developers and shiny new frameworks",
      },
      name: "Framework Meme",
    },
    {
      waitForCompletion: true,
      downloadOutputs: true,
      downloadDirectory: ".",
    }
  );

  console.log(`✅ Downloaded to: ${result.downloadedPaths}`);
  ```
</CodeGroup>

### With Web Search

<CodeGroup>
  ```python Python theme={null}
  result = client.v1.ai_meme_generator.generate(
      style={
          "search_web": True,
          "template": "Two Buttons",
          "topic": "The latest controversy in AI image generation"
      },
      name="AI Controversy Meme",
      wait_for_completion=True,
      download_outputs=True,
      download_directory="."
  )

  if result.status == "complete":
      print(f"✅ Meme complete!")
      print(f"Downloaded to: {result.downloaded_paths}")
      print(f"Credits charged: {result.credits_charged}")
  else:
      print(f"❌ Job failed with status: {result.status}")
      if result.error:
          print(f"Error: {result.error.code}: {result.error.message}")
  ```

  ```javascript Node.js theme={null}
  const result = await client.v1.aiMemeGenerator.generate(
    {
      style: {
        searchWeb: true,
        template: "Two Buttons",
        topic: "Latest tech trends in AI development",
      },
      name: "AI Trends Meme",
    },
    {
      waitForCompletion: true,
      downloadOutputs: true,
      downloadDirectory: ".",
    }
  );

  console.log(`✅ Downloaded to: ${result.downloadedPaths}`);
  ```
</CodeGroup>

## Pricing

| Output | Credits    |
| :----- | :--------- |
| 1 meme | 10 credits |

<Tip>
  **Try this in our Google Colab Cookbook:** [Run this API with sample
  code](https://colab.research.google.com/drive/1NTHL_lr_s-qBJ-mSecSXPzRLi9_V5JiU?usp=sharing). Just
  add your API key.
</Tip>

## API Reference

<Card title="AI Meme Generator API Reference" icon="webhook" href="/api-reference/image-projects/ai-meme-generator">
  View full API specification
</Card>

## Related Tools

<CardGroup cols={2}>
  <Card title="AI Image Generator" icon="wand-magic-sparkles" href="/tools/image/image-generator">
    Create images from text descriptions
  </Card>

  <Card title="AI GIF Generator" icon="film" href="/tools/image/gif-generator">
    Create animated GIFs
  </Card>
</CardGroup>
