AI GIF Generator API

Create an animated GIF from text, one still image, or both. Use Python, Node.js or your own HTTP client.

Quick start

  1. Sign in to your account, buy credits and create an API key in the API access section. Set AIGIFGENERATOR_API_KEY in your environment or secret store.
  2. Download the Python helper or Node.js helper. Text-only generation needs Python 3.10+ or Node.js 22+ and no image dependencies.
  3. Run an example below, or have your AI agent set up the API. Keep the same output path to recover interrupted work.

Each successful API generation costs one credit (20 accounting units). The CLI examples confirm that charge. API requests do not use the daily free website allowance.

Set your key

PowerShell:

$env:AIGIFGENERATOR_API_KEY = 'aigifgenerator_YOUR_KEY'

macOS/Linux:

export AIGIFGENERATOR_API_KEY='aigifgenerator_YOUR_KEY'

Replace the placeholder locally. Never publish the key. A copied .env entry must be loaded by your runtime; the Python helper does not load .env automatically.

Python

python edit.py text.gif --prompt "A small fox waves in a seamless loop."
# Optional reference (also download export.py and install Pillow):
python -m pip install Pillow
python edit.py image.gif --input reference.jpg
python edit.py combined.gif --input reference.jpg --prompt "Make the leaves drift gently."

For image inputs, place the Python preparation helper beside edit.py. It prepares JPEG, PNG, WebP or the first frame of a GIF locally.

Node.js

node edit.mjs text.gif --prompt "A small fox waves in a seamless loop."
# Optional reference (also download export.mjs and install Sharp):
npm install sharp@0.35.5
node edit.mjs image.gif --input reference.jpg
node edit.mjs combined.gif --input reference.jpg --prompt "Make the leaves drift gently."

For image inputs, place the Node preparation helper beside edit.mjs. TypeScript declarations are also available.

Check installation without spending credits: python edit.py --help or node edit.mjs --help.

Have your AI agent set up the API

Give your agent this instruction and the documentation links. Keep the real key in your local environment or secret store.

Set up the AI-GIF-Generator.com API in my project using:
https://ai-gif-generator.com/api/
https://ai-gif-generator.com/openapi.json
Use the official Python or Node.js helper linked in the guide.
Read AIGIFGENERATOR_API_KEY from my local environment or secret store.
Never put my key in chat, source control, browser code, logs or screenshots.
Support text, one optional still reference, or both. Prepare references locally.
Keep the original idempotency key and job ID for interrupted work.
Upload and submit only when a reference is present, then poll and save GIF bytes unchanged.
Confirm the quoted price; one successful generation costs one credit (20 units).
Run --help and local mocked checks first. Do not send a paid generation until I explicitly request it.

Integration guide

  1. Prepare a draft locally and confirm its quote.
  2. Save its idempotency key before creation.
  3. For a reference, upload the prepared PNG and submit the original job.
  4. Poll that job, download its GIF, and retain recovery state until the download completes.

Python in your application

import os
from edit import edit_image
job = edit_image("result.gif", prompt="A paper boat rocks gently.",
                 key=os.environ["AIGIFGENERATOR_API_KEY"], expected_charge_units=20)

Node.js in your application

import {editImage} from './edit.mjs';
const job = await editImage({output:'result.gif', prompt:'A paper boat rocks gently.',
  key:process.env.AIGIFGENERATOR_API_KEY, expectedChargeUnits:20});

Both functions require explicit charge confirmation for a new request. Keep API keys in trusted server or local code, never public browser code.

Text to GIF with cURL

# macOS/Linux shell; use curl.exe and environment syntax appropriate to PowerShell on Windows.
# Review the quote before creating. These commands send a real generation when run with a real key.
curl --fail-with-body https://ai-gif-generator.com/api/v1/edits/quote \
  -H "Authorization: Bearer $AIGIFGENERATOR_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{"prompt":"A small fox waves in a seamless loop."}'

# If the quote is 20 units and you approve it, choose and save a unique key:
curl --fail-with-body https://ai-gif-generator.com/api/v1/edits \
  -H "Authorization: Bearer $AIGIFGENERATOR_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{"prompt":"A small fox waves in a seamless loop.","expectedChargeUnits":20,"idempotencyKey":"REPLACE_WITH_ONE_SAVED_UNIQUE_UUID"}'

Save the returned job ID and the exact creation body. Use the helper for automatic polling and interruption recovery, or follow the HTTP steps below.

Credits and API keys

Create, label and revoke keys in your account. Up to five keys can be active. A new key is shown only once; use Show key, Copy key or Copy .env to save it securely.

The account page shows your available balance, temporary holds, purchases and payment history. API keys access generation routes, not browser-only account, authentication or billing controls. One paid GIF uses one credit on success; no subscription or API free allowance applies.

Prepare an optional reference

Text is optional when an image is supplied. The helpers accept one still JPEG, PNG or WebP, or the first frame of a GIF; the website also supports HEIC/HEIF. GIF uploads provide a still reference for new motion. Their original animation and timing are not retained. Animated PNG/WebP and HEIF sequences are not supported. The source limit is 25 MiB, 50 MP and 16,384 pixels per edge. Low-memory browsers use a 16 MP source ceiling.

For a GIF, extract its first frame on the full logical canvas before preparation. Scale proportionally to at most 7 MP and a 3,840-pixel longest edge. Do not upscale, crop, pad or force an aspect ratio. Encode PNG within 32 MiB and compute its SHA-256 once. Reuse those same bytes and metadata for quote, creation, upload and recovery. Raw GIF uploads are not accepted by the API.

{
  "prompt": "Make the leaves drift gently.",
  "reference": {
    "width": 1920,
    "height": 1080,
    "uploadSha256": "SHA256_OF_PREPARED_PNG",
    "uploadBytes": 123456
  }
}

For image-only work, omit the prompt. The server supplies a subtle, natural-motion instruction.

Raw HTTP: quote, create and upload

Send JSON to POST /api/v1/edits/quote with prompt, reference or both. The response includes chargeUnits, chargeCredits and inputKind. Quote requests do not create jobs.

Create with POST /api/v1/edits, adding the confirmed expectedChargeUnits and a saved unique idempotencyKey of 16–80 ASCII letters, digits, underscores or hyphens. A changed charge returns 409 quote_changed before a job or credit hold is created. Review it explicitly instead of silently accepting another price.

Text jobs enter queued immediately and have no upload URL. Reference jobs enter awaiting_upload: PUT the exact prepared PNG to uploadUrl with Content-Type: image/png, then POST to the job’s /submit route. Upload within ten minutes. Generation settings are controlled by the service.

Retries and interrupted uploads

Keep the original draft, confirmed charge, request key and job ID. Repeating creation with the same unchanged request key recovers its job, including a queued text job whose enqueue acknowledgement was lost. Repeated submission is idempotent. Never create a replacement because a response was lost.

Both helpers keep an output.gif.aigifgenerator.json recovery file containing request metadata and the prompt, but no API key or image bytes. Treat it as private. They reject changed sources/prompts, changed confirmation amounts, malformed state and recovery files older than six days. Use the same input, encoder, prompt and output path when resuming.

A companion .lock prevents concurrent processes from using the same output. If a process crashes, confirm it stopped before removing only that lock; preserve the JSON. Downloads use a temporary file and atomic publication that refuses to overwrite an existing output. A failed download leaves the original job recoverable. Use a local filesystem supporting hard links, such as NTFS, APFS or ext4.

Failed, canceled and expired jobs are terminal. A new generation requires an explicit new submission. The helpers report safe errors and any Retry-After delay; they do not automatically replace failed generations.

Polling and downloads

GET /api/v1/edits/JOB_ID
Authorization: Bearer YOUR_KEY

# Reference jobs: PUT the raw prepared PNG to uploadUrl,
# then POST {} to /api/v1/edits/JOB_ID/submit.
# Text jobs are queued already, with no upload URL or submit step.
# Poll the same job, respecting pollAfterMs.
# When ready: GET resultUrl with the same Bearer credential.
# Save image/gif bytes unchanged; no conversion or export step.
# DELETE /api/v1/edits/JOB_ID cancels eligible work or deletes private files.

Honor pollAfterMs: 3 seconds initially, then 5 and 10 seconds. Browser integrations pause polling in hidden tabs. Ready jobs include resultUrl and gif metadata: width, height, frameCount, frameDurationMs, durationMs and loopCount.

The GIF has nine frames of 200 ms each, totaling 1,800 ms. A loop count of 0 is infinite, a positive count is finite, and null means unspecified. Save the original image/gif bytes at their native dimensions. Previews and thumbnails are separate and must not replace the download.

The service requests high-quality rendering and selects dimensions automatically. Text-only jobs use 896 × 896 pixels. Reference jobs use the closest supported proportions within a 1:3–3:1 aspect ratio, with up to 1,280 pixels per edge and 830,208 pixels per frame. The returned dimensions must match the job’s saved selection and appear in gif.width and gif.height. These are service settings, not client options; a GIF need not match its reference’s original dimensions or composition.

The website can additionally create a separate resized GIF in the visitor’s browser, fitting within the reference’s original dimensions and browser limits without cropping, added borders or forced stretching. The button shows its actual size. Resizing adds pixels rather than recovering detail; GIF palette encoding can change colors. API downloads always return the unchanged native file. Browser exports create no additional generation, credit charge or stored server copy, and do not change API metadata.

The website shows its recent 24-hour processing average below progress when samples exist. It arrives in the existing startup response, is cached for five minutes, and is an observation rather than a remaining-time prediction. Do not add a separate timing poll to an integration.

Results are private and available for one hour after successful completion. Repeated downloads do not extend expiry. A failed download retries the same result URL; it does not require another generation. Deletion is unavailable while inference is processing. Confirmed generation failure releases held credits.

n8n, Make and Zapier

Use HTTP request steps with a secret Bearer credential. Retain the exact JSON draft, confirmed charge, idempotency key and job ID with the run. For text, send JSON directly. For a reference, prepare the PNG in a trusted local or server code step, send raw binary PNG to the returned upload URL, then submit.

Use wait steps for polling and a binary response step for the GIF. Resume the same job on interruption. Disable any automation that generates a new request key or creates replacement work after an ambiguous response or terminal failure.

Limits and errors

StatusMeaningAction
400 / 413 / 415Invalid or oversized inputCorrect the prompt, image or prepared PNG before submitting.
401 / 403Invalid key or restricted endpointCheck the key and its revocation status. Account and billing routes require a browser session.
402Insufficient available creditsBuy credits or wait for outstanding holds to settle.
409Changed quote, idempotency or job stateExplicitly review a changed price. For interrupted work, resume the original job and request key.
410Expired upload or resultUpload within ten minutes. Expired result bytes cannot be recovered.
429Rate or shared capacity limitHonor Retry-After; do not rapidly retry or create replacement jobs.
502 / 503Generation failed or service unavailableRead the original job. A terminal failure needs an explicit new submission.

API accounts have limits of six creations and 120 control requests per minute. Concurrent holds, active-job limits and shared processing capacity also apply. The prepared PNG and GIF limits are each 32 MiB, inclusive. The prompt limit is 4,000 characters.

Errors contain a safe error code. Keep keys, prompts, images and private URLs out of logs. See the OpenAPI specification for the complete contract. /api/edits exposes the same generation contracts for the website. Contact support with a job ID and safe error code.