> ## 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

> Create an AI generated meme. Each meme costs 10 credits.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/ai-meme-generator
openapi: 3.0.2
info:
  title: Magic Hour API
  version: beta
  description: >

    Magic Hour provides an API (beta) that can be integrated into your own
    application to generate videos and images using AI. 


    Webhook documentation can be found
    [here](https://docs.magichour.ai/webhook-reference).


    If you have any questions, please reach out to us via
    [discord](https://discord.gg/JX5rgsZaJp).


    # Authentication


    Every request requires an API key.


    To get started, first generate your API key
    [here](https://magichour.ai/developer?tab=api-keys&utm_source=docs&utm_medium=referral&utm_campaign=api-reference).


    Then, add the `Authorization` header to the request.


    | Key | Value |

    |-|-|

    | Authorization | Bearer mhk_live_apikey |


    > **Warning**: any API call that renders a video will utilize credits in
    your account.
  termsOfService: https://magichour.ai/terms-of-service
servers:
  - url: https://api.magichour.ai
security: []
tags:
  - name: Files
    description: API related to uploading and reusing assets
  - name: Image Projects
    description: API related to image projects
  - name: Video Projects
    description: API related to video projects
  - name: Audio Projects
    description: API related to audio projects
  - name: Account
    description: API related to the account that owns the API key
paths:
  /v1/ai-meme-generator:
    post:
      tags:
        - Image Projects
      summary: AI Meme Generator
      description: Create an AI generated meme. Each meme costs 10 credits.
      operationId: aiMemeGenerator.createImage
      parameters: []
      requestBody:
        required: true
        description: Body
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: The name of the meme.
                  example: My Funny Meme
                style:
                  type: object
                  properties:
                    topic:
                      type: string
                      maxLength: 200
                      minLength: 1
                      description: The topic of the meme.
                      example: When the code finally works
                    template:
                      type: string
                      enum:
                        - Random
                        - Drake Hotline Bling
                        - Galaxy Brain
                        - Two Buttons
                        - Gru's Plan
                        - Tuxedo Winnie The Pooh
                        - Is This a Pigeon
                        - Panik Kalm Panik
                        - Disappointed Guy
                        - Waiting Skeleton
                        - Bike Fall
                        - Change My Mind
                        - Side Eyeing Chloe
                        - Woman Yelling at a Cat
                        - Success Kid
                        - One Does Not Simply
                        - Bad Luck Brian
                        - Futurama Fry
                        - Ancient Aliens
                        - Disaster Girl
                        - Hide the Pain Harold
                        - Distracted Boyfriend
                        - Left Exit 12 Off Ramp
                        - Running Away Balloon
                        - Batman Slapping Robin
                        - UNO Draw 25
                        - Mocking SpongeBob
                        - Boardroom Meeting Suggestion
                        - X, X Everywhere
                        - Buff Doge vs Cheems
                        - Bernie Once Again Asking
                        - Roll Safe Think About It
                        - Blank Nut Button
                        - Epic Handshake
                        - Sad Pablo Escobar
                        - Inhaling Seagull
                        - Surprised Pikachu
                        - Always Has Been
                        - Scroll of Truth
                        - Marked Safe From
                        - Y'all Got Any More of That
                        - Monkey Puppet
                        - Oprah You Get A
                        - They're the Same Picture
                        - I Bet He's Thinking About Other Women
                        - Evil Kermit
                        - This Is Fine
                        - This Is Where I'd Put My Trophy
                        - Anakin Padme Four Panel
                        - Who Killed Hannibal
                        - Clown Applying Makeup
                        - Trade Offer
                        - Laughing Leo
                        - Sleeping Shaq
                        - Megamind Peeking
                        - Grandma Finds the Internet
                        - Doge
                        - American Chopper Argument
                        - First World Problems
                        - Grumpy Cat
                        - SpongeBob Ight Imma Head Out
                        - But That's None of My Business
                        - Creepy Condescending Wonka
                        - Captain Picard Facepalm
                        - Hard to Swallow Pills
                        - Bell Curve
                        - Absolute Cinema
                        - You Guys Are Getting Paid
                        - Types of Headaches
                        - Mother Ignoring Kid Drowning in a Pool
                        - Flex Tape
                        - Spiderman Pointing at Spiderman
                        - Charlie Conspiracy
                        - Pawn Stars Best I Can Do
                        - 0 Days Without
                        - Squidward Window
                        - Where Monkey
                        - Soldier Protecting Sleeping Child
                        - They Don't Know
                        - Spiderman Triple
                        - Two Guys on a Bus
                        - Imagination SpongeBob
                        - All My Homies Hate
                        - You Know I'm Something of a Scientist Myself
                        - Anime Girl Hiding from Terminator
                        - A Train Hitting a School Bus
                        - AJ Styles and Undertaker
                        - Three-Headed Dragon
                        - Grant Gustin Over Grave
                        - Whisper and Goosebumps
                        - Scooby Doo Mask Reveal
                        - Domino Effect
                        - Two Paths
                        - I'm the Captain Now
                        - Say the Line Bart
                        - Star Wars Yoda
                        - Grim Reaper Knocking Door
                        - Yo Dawg Heard You
                        - Gus Fring We Are Not the Same
                        - C'mon Do Something
                        - Leonardo DiCaprio Cheers
                      description: To use our templates, pass in one of the enum values.
                      example: Drake Hotline Bling
                    searchWeb:
                      default: false
                      type: boolean
                      description: Whether to search the web for meme content.
                      example: false
                  required:
                    - topic
                    - template
              required:
                - style
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    example: cuid-example
                    description: >-
                      Unique ID of the image. Use it with the [Get image Project
                      API](https://docs.magichour.ai/api-reference/image-projects/get-image-details)
                      to fetch status and downloads.
                  credits_charged:
                    type: integer
                    description: >-
                      The amount of credits deducted from your account to
                      generate the image. We charge credits right when the
                      request is made. 


                      If an error occurred while generating the image(s),
                      credits will be refunded and this field will be updated to
                      include the refund.
                    example: 10
                required:
                  - id
                  - credits_charged
                description: Success
        '400':
          description: Invalid Request
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                  - message
                properties:
                  code:
                    type: string
                    enum:
                      - invalid_request
                    description: >-
                      Machine-readable error code.


                      - `invalid_request`: Fix request syntax or validation
                      errors before retrying.
                  message:
                    type: string
                    description: Human-readable error message.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                  - message
                properties:
                  code:
                    type: string
                    enum:
                      - unauthorized
                    description: |-
                      Machine-readable error code.

                      - `unauthorized`: Provide a valid API key before retrying.
                  message:
                    type: string
                    description: Human-readable error message.
        '402':
          description: Payment Required
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                  - message
                properties:
                  code:
                    type: string
                    enum:
                      - insufficient_credits
                      - subscription_required
                      - plan_upgrade_required
                    description: >-
                      Machine-readable error code.


                      - `insufficient_credits`: Purchase credits before
                      retrying.


                      - `subscription_required`: Start a subscription before
                      retrying.


                      - `plan_upgrade_required`: Upgrade the subscription plan
                      before retrying.
                  message:
                    type: string
                    description: Human-readable error message.
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                  - message
                properties:
                  code:
                    type: string
                    enum:
                      - not_found
                    description: |-
                      Machine-readable error code.

                      - `not_found`: Check the route or resource identifier.
                  message:
                    type: string
                    description: Human-readable error message.
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                  - message
                properties:
                  code:
                    type: string
                    enum:
                      - unprocessable_entity
                    description: >-
                      Machine-readable error code.


                      - `unprocessable_entity`: Change the request values before
                      retrying.
                  message:
                    type: string
                    description: Human-readable error message.
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                  - message
                properties:
                  code:
                    type: string
                    enum:
                      - internal_server_error
                    description: >-
                      Machine-readable error code.


                      - `internal_server_error`: Retry later or contact support
                      if the error continues.
                  message:
                    type: string
                    description: Human-readable error message.
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: python
          source: |-
            from magic_hour import Client
            from os import getenv

            client = Client(token=getenv("API_TOKEN"))
            res = client.v1.ai_meme_generator.generate(
                style={
                    "search_web": False,
                    "template": "Drake Hotline Bling",
                    "topic": "When the code finally works",
                },
                name="My Funny Meme",
                wait_for_completion=True,
                download_outputs=True,
                download_directory="."
            )
        - lang: javascript
          source: |-
            import { Client } from "magic-hour";

            const client = new Client({ token: process.env["API_TOKEN"]!! });
            const res = await client.v1.aiMemeGenerator.generate(
              {
                name: "My Funny Meme",
                style: {
                  searchWeb: false,
                  template: "Drake Hotline Bling",
                  topic: "When the code finally works",
                },
              },
              {
                waitForCompletion: true,
                downloadOutputs: true,
                downloadDirectory: ".",
              },
            );
        - lang: go
          source: "package main\n\nimport (\n\tos \"os\"\n\n\tsdk \"github.com/magichourhq/magic-hour-go/client\"\n\tnullable \"github.com/magichourhq/magic-hour-go/nullable\"\n\tai_meme_generator \"github.com/magichourhq/magic-hour-go/resources/v1/ai_meme_generator\"\n\ttypes \"github.com/magichourhq/magic-hour-go/types\"\n)\n\nfunc main() {\n\tclient := sdk.NewClient(\n\t\tsdk.WithBearerAuth(os.Getenv(\"API_TOKEN\")),\n\t)\n\tres, err := client.V1.AiMemeGenerator.Create(ai_meme_generator.CreateRequest{\n\t\tName: nullable.NewValue(\"My Funny Meme\"),\n\t\tStyle: types.V1AiMemeGeneratorCreateBodyStyle{\n\t\t\tSearchWeb: nullable.NewValue(false),\n\t\t\tTemplate:  types.V1AiMemeGeneratorCreateBodyStyleTemplateEnumDrakeHotlineBling,\n\t\t\tTopic:     \"When the code finally works\",\n\t\t},\n\t})\n}"
        - lang: rust
          source: |-
            let client = magic_hour::Client::default()
                .with_bearer_auth(&std::env::var("API_TOKEN").unwrap());
            let res = client
                .v1()
                .ai_meme_generator()
                .create(magic_hour::resources::v1::ai_meme_generator::CreateRequest {
                    name: Some("My Funny Meme".to_string()),
                    style: magic_hour::models::V1AiMemeGeneratorCreateBodyStyle {
                        search_web: Some(false),
                        template: magic_hour::models::V1AiMemeGeneratorCreateBodyStyleTemplateEnum::DrakeHotlineBling,
                        topic: "When the code finally works".to_string(),
                    },
                })
                .await;
        - lang: curl
          source: |-
            curl --request POST \
                 --url https://api.magichour.ai/v1/ai-meme-generator \
                 --header 'accept: application/json' \
                 --header 'authorization: Bearer <token>' \
                 --header 'content-type: application/json' \
                 --data '
            {
              "name": "My Funny Meme",
              "style": {
                "topic": "When the code finally works",
                "template": "Drake Hotline Bling",
                "searchWeb": false
              }
            }
            '
        - lang: php
          source: |-
            <?php

            $curl = curl_init();

            curl_setopt_array($curl, [
              CURLOPT_URL => "https://api.magichour.ai/v1/ai-meme-generator",
              CURLOPT_RETURNTRANSFER => true,
              CURLOPT_ENCODING => "",
              CURLOPT_MAXREDIRS => 10,
              CURLOPT_TIMEOUT => 30,
              CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
              CURLOPT_CUSTOMREQUEST => "POST",
              CURLOPT_POSTFIELDS => json_encode([
                'name' => 'My Funny Meme',
                'style' => [
                    'topic' => 'When the code finally works',
                    'template' => 'Drake Hotline Bling',
                    'searchWeb' => false
                ]
              ]),
              CURLOPT_HTTPHEADER => [
                "accept: application/json",
                "authorization: Bearer <token>",
                "content-type: application/json"
              ],
            ]);

            $response = curl_exec($curl);
            $err = curl_error($curl);

            curl_close($curl);

            if ($err) {
              echo "cURL Error #:" . $err;
            } else {
              echo $response;
            }
        - lang: java
          source: >-
            HttpResponse<String> response =
            Unirest.post("https://api.magichour.ai/v1/ai-meme-generator")
              .header("accept", "application/json")
              .header("content-type", "application/json")
              .header("authorization", "Bearer <token>")
              .body("{\"name\":\"My Funny Meme\",\"style\":{\"topic\":\"When the code finally works\",\"template\":\"Drake Hotline Bling\",\"searchWeb\":false}}")
              .asString();
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer authentication header of the form `Bearer <api_key>`, where
        `<api_key>` is your API key. To get your API key, go to [Developer
        Hub](https://magichour.ai/developer?tab=api-keys&utm_source=docs&utm_medium=referral&utm_campaign=api-reference)
        and click "Create new API Key".

````