> ## 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 GIF Generator Tool - Magic Hour Docs

> Create animated GIFs from images or text prompts with AI-powered generation.

export const ToolSection = ({type = "image", outputs = [], title = "", productSlug = "", apiSlug = ""}) => <>
    {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} />}
            </Frame>
          </Tab>)}
      </Tabs>}

    <CardGroup cols={2}>
      <Card title="API Spec" icon="webhook" horizontal href={`/api-reference/${type}-projects/${apiSlug}`}>
        See API details
      </Card>
      <Card title="Product Page" icon="video" horizontal href={`https://magichour.ai/products/${productSlug}`}>
        Learn more about {title}
      </Card>
    </CardGroup>

  </>;

## Overview

AI GIF Generator creates animated GIFs using AI technology. Generate looping animations from static images or create entirely new animated content from text descriptions.

<ToolSection
  title="AI GIF Generator"
  productSlug="ai-gif-generator"
  apiSlug="ai-gif-generator"
  type="image"
  outputs={[
{
  src: "/get-started/images/gifgeneratorexample1.gif",
},
{
  src: "/get-started/images/gifgeneratorexample2.gif",
},
]}
/>

## How It Works

1. **Provide input** - Upload an image or provide a text prompt
2. **Set animation style** - Choose animation type and duration
3. **AI generates** - AI creates smooth, looping animated GIF
4. **Download GIF** - Retrieve your animated GIF file

## Use Cases

* **Social media content** - Create eye-catching animated posts
* **Reactions and memes** - Generate custom reaction GIFs
* **Marketing materials** - Animated graphics for campaigns
* **Website elements** - Dynamic visual content
* **Messaging** - Custom animated stickers and GIFs

## Code Examples

### Generate GIF from Image

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

  client = Client(token=getenv("API_TOKEN"))
  result = client.v1.ai_gif_generator.generate(
      style={"prompt": "Cat fighting a lion, pixel art"},
      name="Ai Gif gif",
      output_format="gif",
      wait_for_completion=True,
      download_outputs=True,
      download_directory="."
  )

  if result.status == "complete":
      print(f"✅ GIF 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 hasattr(result, 'error_message'):
          print(f"Error: {result.error_message}")
  ```

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

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

  const result = await client.v1.aiGifGenerator.generate({
    assets: {
      imageFilePath: "https://raw.githubusercontent.com/runshouse/Sample_Assets/main/tomcruise.png",
    },
    style: {
      prompt: "Create a smooth zoom and rotation animation",
    },
    outputFormat: "gif",
    name: "GIF Generator image",
    waitForCompletion: true,
    downloadOutputs: true,
    downloadDirectory: ".",
  });

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

## Pricing

| Output         | Credits    |
| :------------- | :--------- |
| 1 animated GIF | 15 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 GIF Generator API Reference" icon="webhook" href="/api-reference/image-projects/ai-gif-generator">
  View full API specification
</Card>

## Related Tools

<CardGroup cols={2}>
  <Card title="Animation" icon="film" href="/tools/video/animation">
    Create video animations with advanced effects
  </Card>

  <Card title="AI Meme Generator" icon="face-laugh" href="/tools/image/meme-generator">
    Generate memes with text and templates
  </Card>
</CardGroup>
