8gifs agent api
8gifs API and MCP docs
Turn anything into a looping pixel-art GIF: a text brief, a tweet, an X profile, a YouTube video (with a ?t= timestamp), a photo, or any website. The AI director plans the motion, an image model draws the sprite sheet, and the server keys/slices/aligns and encodes a looping GIF.
Three surfaces, one pipeline
Every surface runs the same shared pipeline (classify source → AI director → sprite-sheet generation → server-side keying/slicing/alignment → GIF encoding). Pick by who is calling:
| POST /api/agent/* | platform edge agent token | Automatio agents on this platform |
| POST /api/v1/* | 8gifs API key (kg_...) | any external agent or script |
| POST /api/mcp | open discovery; API key for tool calls | MCP clients (Claude, ChatGPT, Cursor, ...) |
Error convention: every REST endpoint answers HTTP 200 and carries the real outcome in the ok field of the JSON body (ok: false plus an error message on failure). Proxies rewrite 5xx bodies into HTML error pages, so a non-2xx status is never a reliable signal - always read the JSON body.
Auth & tiers
External callers request an API key from the site admin (minted via POST /api/admin/keys, admin session required). The plaintext key is shown ONCE; only its SHA-256 hash is stored.
| header | Authorization: Bearer kg_... or x-api-key: kg_... |
| free tier | 20 generations/day, 6/hour per key |
| free caps | watermark forced ON, grid capped at 4x4 |
| over quota | ok: false with a 429-style message in-band plus a quota block |
| read-only endpoints | /api/v1/presets verifies the key but never consumes quota |
REST API: POST /api/v1/animate
The full home-page pipeline in one call. Same code as the composer UI./api/agent/animate is the same handler on the platform-token surface (it does not archive - the caller decides what belongs in the gallery).
| subject | text brief, e.g. "a grumpy cat with a permanent scowl" - OR inputUrl, one of the two is required |
| inputUrl | tweet URL, X profile URL/handle, YouTube (...?t=90), image URL, or any website URL. Auto-classified. |
| preset | motion preset name from GET /api/v1/presets, e.g. "tail wag" |
| prompt | free-form motion steer; wins over preset |
| cols / rows | sprite grid, default 4x4 (16 frames). Free tier caps at 4x4, paid up to 6x6 |
| keepBackground | keep the painted scene (tweet/website sources default true) |
| watermark | stamp the 8gifs.com chip. Default true; paid tiers may disable |
| delayMs | frame delay. Default 100 |
| archive | v1 only, default true: archive gif+sheet and return slug + pageUrl. false = raw bytes only |
curl -X POST https://8gifs.com/api/v1/animate \
-H "Authorization: Bearer kg_..." \
-H "content-type: application/json" \
-d '{ "inputUrl": "https://x.com/user/status/123", "preset": "tail wag" }'Response (abridged):
{
"ok": true,
"gifBase64": "R0lGODlh...",
"sheetBase64": "iVBORw0...",
"sheetUrl": "https://.../sheet.png",
"slug": "calm-amber-fox-3kq",
"pageUrl": "https://8gifs.com/g/calm-amber-fox-3kq",
"meta": { "frames": 16, "cols": 4, "rows": 4, "cellW": 208, "cellH": 208 },
"model": "openai/gpt-image-2.5-flare",
"quota": { "used": 1, "limit": 20, "tier": "free" }
}GET /api/v1/presets
Keyed, read-only (no quota). The full motion-preset catalog with categories. Pass presets[i].name as preset to animate.
curl https://8gifs.com/api/v1/presets -H "x-api-key: kg_..."
-> { "ok": true, "count": 171, "presets": [ { "name": "moonwalk", "category": "iconic dances", "prompt": "..." }, ... ] }GET /api/agent/describe
Read-only. Photo URL in, character brief out - the brief feeds straight back into sheet or animate as subject.
curl "https://8gifs.com/api/agent/describe?imageUrl=https://example.com/me.jpg"
-> { "ok": true, "description": "Short dark brown hair ... bomber jacket ..." }POST /api/agent/sheet
Draws a sprite sheet or portrait from a text brief - no animation. For callers who slice the sheet themselves.
| character | required, minimum 8 characters |
| style | "sheet" (default) or "portrait" |
| aspectRatio | default "1:1" |
| prompt | full prompt override, skips the built-in template |
Archive & gallery
| POST /api/gifs | multipart gif, sheet, photo, meta, slug, replace - the gallery archive. Returns { ok: true, slug } naming the /g/[slug] share page |
| GET /api/gifs?limit=12 | recent gallery rows, keyset pagination via before= |
| GET /api/gifs/[slug] | one gif's generation context - the data the remix flow reuses |
| GET /api/presets | unauthenticated preset list + archived example gifs per preset (used by the composer hover previews) |
MCP server: POST /api/mcp
Stateless JSON-RPC 2.0 MCP server (streamable-HTTP-compatible: initialize → tools/list → tools/call, no session state). Point any MCP client at https://8gifs.com/api/mcp.initialize and tools/list are open; tools/call requires an API key (auth failures come back as JSON-RPC errors, code -32001).
| animate_gif | subject or inputUrl (tweet/X/YouTube/image/website), optional preset, prompt, cols, rows, keepBackground, delayMs. Archives and returns the /g/<slug> share page URL |
| list_presets | the 171-preset catalog with categories |
| describe_image | imageUrl - photo to character brief |
x402 payments (no account, per-call)
POST /api/v1/animate accepts two ways in: an API key (free tier above) or an x402 payment - call without a key and the endpoint replies 402 Payment Required with a PAYMENT-REQUIRED header (Base64 JSON: price, USDC asset, network, receiving wallet). The client signs an EIP-3009 transferWithAuthorization, retries with PAYMENT-SIGNATURE, and the server verifies + settles AFTER the generation succeeds - a failed generation is never charged. Paid callers get FULL caps: grids up to 6x6, watermark optional.
| price | $0.05 per generation (X402_PRICE_USD) |
| network | base - real mainnet USDC (X402_NETWORK) |
| facilitator | v2.facilitator.mogami.tech on mainnet (free, no account). x402.org facilitator is testnet-only |
| payer needs | USDC on Base and nothing else - the facilitator covers gas, USDC-only wallets work |
| disable | X402_ENABLED=0 keeps the API-key path only |
Remix
Every /g/[slug] page carries a remix this button. It opens the composer at /?remix=<slug>with the gif's character brief, grid and background setting already loaded, and its source image attached (the original photo when archived, otherwise the first frame of the sheet). The remixer adds their own motion and generates - the new gif carries meta.remixOf pointing at the parent, shown as one-level attribution on the page.
Roadmap (not yet live)
- Paid API-key tiers: register + prepaid balance. The plumbing (tier field, caps in the pipeline) is already wired.
- x402 on the MCP server: animate_gif currently requires a key; the same 402 gate can wrap tools/call once agent-side MCP clients ship built-in wallets.
