API Reference
Endpoint, request, response, and event reference for the Sprite Fusion API.
Base URL:
https://www.spritefusion.com/api/v1Authenticate every API request with your API key:
Authorization: Bearer $SPRITE_FUSION_API_KEYGET /credits
Returns the credits currently available to the account.
curl -sS https://www.spritefusion.com/api/v1/credits \
-H "Authorization: Bearer $SPRITE_FUSION_API_KEY"{"credits":285}GET /assets
Lists your saved assets from the editor, API, and integrations, newest first. The asset and tag endpoints require authentication and consume no credits.
curl -sS 'https://www.spritefusion.com/api/v1/assets?limit=10' \
-H "Authorization: Bearer $SPRITE_FUSION_API_KEY"limit is optional: 1–100 assets, default 20. Batch members count individually, retain their batch metadata, and may span pages.
tag is optional: only assets with that tag are listed, for example ?tag=weapons.
Returns assets, hasMore, and nextCursor. Start without a cursor. For the next page, pass nextCursor unchanged as the URL-encoded cursor query parameter. Stop when nextCursor is null (hasMore: false).
Each asset matches output.asset: ID, type, prompt, dimensions, timestamps, tags, and assetUrl. Images generated with a palette also include palette: {colors, paletteId?}, kept when the saved palette is renamed or deleted. Animations also include sourceImageUrl, spritesheetUrl, frameCount, and optional fps.
GET /assets/{assetId}
Returns {"asset": {...}} for an asset you own, with the same fields as the list endpoint.
Returned file URLs are public and can be downloaded directly. Reuse an image asset's id as an asset_id input for generation requests, and any asset's id, animations included, for normal maps.
PATCH /assets/{assetId}
Replaces the tags of an asset you own and returns {"asset": {...}}. Send JSON with the complete new list; an empty list removes every tag.
curl -sS -X PATCH https://www.spritefusion.com/api/v1/assets/asset_... \
-H "Authorization: Bearer $SPRITE_FUSION_API_KEY" \
-H "Content-Type: application/json" \
--data '{"tags":["dungeon-crawler","weapons"]}'An asset has up to 10 tags. Each is 1–32 letters, numbers, spaces, hyphens, or underscores, and is stored trimmed and lowercase. The basic, recommended tag is the game or project name.
GET /tags
Lists the tags on your saved assets, most used first, with how many assets carry each. Returns up to 200 tags.
curl -sS https://www.spritefusion.com/api/v1/tags \
-H "Authorization: Bearer $SPRITE_FUSION_API_KEY"{"tags":[{"name":"weapons","count":12},{"name":"dungeon","count":5}]}GET /palettes
Lists your saved palettes, newest first, and the built-in presets. The palette endpoints are free. See Color Palettes to generate with a palette.
curl -sS https://www.spritefusion.com/api/v1/palettes \
-H "Authorization: Bearer $SPRITE_FUSION_API_KEY"{"palettes":[{"id":"pal_...","name":"Forest","colors":["#182818","#f0e8c0"],"createdAt":"2026-11-04T10:00:00.000Z","updatedAt":"2026-11-04T10:00:00.000Z"}],"presets":[{"preset":"nintendo-game-boy","name":"Game Boy","author":"Black Zero","colors":["#2e463d","#385d49","#577b46","#7e8416"]}]}Pass a saved palette's id or a preset's preset value as the palette of a generation request.
POST /palettes
Saves a palette and returns 201 with {"palette": {...}}.
curl -sS https://www.spritefusion.com/api/v1/palettes \
-H "Authorization: Bearer $SPRITE_FUSION_API_KEY" \
-H "Content-Type: application/json" \
--data '{"name":"Forest","colors":["#182818","#F0E8C0"]}'| Field | Type | Description |
|---|---|---|
name | string | 1–80 characters, trimmed |
colors | array | 2–256 different six-digit RGB hex colors, with or without # |
Colors are saved lowercase with #, in order, without duplicates. Requests are limited to 16 KiB. An invalid name returns 400 with the invalid_request code, and invalid colors return 400 with invalid_palette.
You can save up to 1,000 palettes. Past that, this returns 409 with the palette_limit_reached code: delete a palette to save another.
GET /palettes/{paletteId}
Returns {"palette": {...}} for a palette you saved, with its id, name, colors, createdAt, and updatedAt.
Unknown IDs return 404 with the palette_not_found code, as do the endpoints below.
PATCH /palettes/{paletteId}
Renames a saved palette and returns {"palette": {...}}. Send JSON with only name, 1–80 characters. To change a palette's colors, save a new one.
curl -sS -X PATCH https://www.spritefusion.com/api/v1/palettes/pal_... \
-H "Authorization: Bearer $SPRITE_FUSION_API_KEY" \
-H "Content-Type: application/json" \
--data '{"name":"Forest at dusk"}'DELETE /palettes/{paletteId}
Deletes a saved palette and returns {"deleted":true}. Sprites generated with it keep their colors.
curl -sS -X DELETE https://www.spritefusion.com/api/v1/palettes/pal_... \
-H "Authorization: Bearer $SPRITE_FUSION_API_KEY"GET /vfx-library
Lists the open source pixel art VFX library: every effect with its category, a one-line description, and its situations with animated previews. Free.
curl -sS https://www.spritefusion.com/api/v1/vfx-library \
-H "Authorization: Bearer $SPRITE_FUSION_API_KEY"{"effects":[{"slug":"ice","title":"Ice","category":"Elements","description":"Spikes, a frost nova, crystals, shattering blocks, frozen characters.","situations":[{"name":"Nova","preview":"https://www.spritefusion.com/images/pixel-art-vfx/ice-nova.webp"}]}]}GET /vfx-library/{slug}
Returns one effect as the reference to build it into a game, as {"vfx": {...}}. Free.
reference: Markdown with its recipe (timeline, layers, palette, and the numbers that make it look right, enough to rebuild it in any engine), its situations as ready calls, its options and hooks, how to use the file, and its source.source: its TypeScript file alone, the same as its ZIP: one file, no dependencies.situations,page, anddownload: its previews, its page, and its ZIP.
curl -sS https://www.spritefusion.com/api/v1/vfx-library/ice \
-H "Authorization: Bearer $SPRITE_FUSION_API_KEY"Unknown slugs return 404 with the vfx_not_found code.
POST /uploads
Creates a short-lived upload URL for an input image. Send JSON with these fields:
| Field | Type | Description |
|---|---|---|
content_type | string | image/png, image/jpeg, image/webp, image/gif, image/bmp, image/tiff, or image/avif |
size_bytes | integer | Exact file size, up to 20 MiB |
sha256 | string | Lowercase SHA-256 digest of the file |
{
"content_type": "image/png",
"size_bytes": 12480,
"sha256": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
}The response contains the signed upload_id, upload URL, their separate expiry times, and headers to use for the upload:
{
"upload_id": "upl_...",
"upload_url": "https://...",
"upload_url_expires_at": "2026-08-28T12:05:00.000Z",
"upload_id_expires_at": "2026-08-29T12:00:00.000Z",
"headers": {"Content-Type":"image/png"}
}See Input Images for the complete upload flow.
POST /generate
Starts any generation or transformation operation. Send Content-Type: application/json. A successful request returns a text/event-stream response.
| Operation | Required fields | Optional fields |
|---|---|---|
generate | prompt, size | count, palette |
edit | prompt, inputs (1–9) | palette |
style-reference | prompt, inputs (1–20) | size, palette |
direction-set | inputs (exactly 1) | size, palette |
animate | prompt, inputs (exactly 1) | output_frames, colors |
Every operation also accepts optional tags, saved on each output, with the same rules as PATCH /assets/{assetId}.
generate accepts an optional count: 1 returns a single sprite for 3 credits up to 80, or 5 from 96; leave it out for the full set.
palette is exactly one of {colors: [...]}, {id: "pal_…"}, or {preset: "pico-8"}: every result then uses only its colors. Edits, style references, and 8 directions keep the palette of an input sprite made with one; null drops it. Animations don't accept a palette. See Color Palettes.
For generate, style-reference and direction-set, size may be 16, 24, 32, 48, 64, 80, 96, 112, or 128; for style-reference and direction-set, when omitted, it is inferred from the input sprites. edit keeps the size of its primary input and takes no size. Animation output_frames must be an even number from 2 to 16, and colors must be an integer from 2 to 256.
{
"operation": "edit",
"prompt": "Give this character a blue cape",
"inputs": [{"asset_id":"asset_..."}]
}Each item in inputs uses one of the following forms:
{"asset_id":"asset_..."}{"data_url":"data:image/png;base64,..."}{"upload_id":"upl_..."}See Generate and Transform Sprites for an example of every operation.
POST /normal-maps
Returns the normal map of one sprite or animation as an image/png body. Free, and nothing is saved. Send Content-Type: application/json:
| Field | Type | Description |
|---|---|---|
inputs | array | Exactly 1 input, in the same forms as POST /generate. An asset_id may be an animation |
strength | number | Optional, 0–8, default 1.5 |
format | string | Optional, opengl (default) or directx |
{"inputs":[{"asset_id":"asset_..."}],"format":"opengl"}The map keeps the input's size and transparency, and an animation's frame layout. Each sprite or frame can be up to 1024×1024 pixels. Errors use the JSON format below.
POST /palette-snaps
Returns a sprite recolored with a palette as an image/png body: every opaque pixel becomes one of the palette's colors, and transparency is kept. Without a palette, it returns the sprite in fewer of its own colors. Free, and nothing is saved. Send Content-Type: application/json:
| Field | Type | Description |
|---|---|---|
inputs | array | Exactly 1 input, in the same forms as POST /generate, up to 1024×1024 pixels |
palette | object | Optional: exactly one of colors, id or preset, as for POST /generate |
mode | string | Optional, with a palette: nearest (default) or lightness |
max_colors | number | Optional, without a palette: the most colors to keep, from 1 to 256 (default 32) |
{"inputs":[{"asset_id":"asset_..."}],"palette":{"colors":["#000000","#ffffff","#ff004d","#29adff"]}}Stream events
Each JSON event is sent on an SSE data: line.
See the Agent Guide for tracking results and revisions.
| Event | Description |
|---|---|
started | The request started and credits were reserved |
progress | Generation is underway |
output | Emitted once per saved asset, with its index (arrival order) and asset details. An image asset's batchIndex is its place in the batch |
completed | Final event with succeeded or failed and the total output_count |
data: {"type":"started","request_id":"req_...","operation":"edit","credits":{"reserved":15,"remaining":285}}
data: {"type":"progress","message":"Generating sprites"}
data: {"type":"output","index":0,"asset":{"id":"asset_1","type":"image","assetUrl":"https://media.spritefusion.com/example-1.png"}}
data: {"type":"output","index":1,"asset":{"id":"asset_2","type":"image","assetUrl":"https://media.spritefusion.com/example-2.png"}}
data: {"type":"completed","status":"succeeded","output_count":2,"credits":{"remaining":285}}See Streaming, Errors, and Credits for complete readers and interruption handling.
Errors
Errors returned before streaming use JSON:
{"error":{"code":"invalid_request","message":"At least one input image is required."}}| Status | Meaning |
|---|---|
400 | Invalid request or image |
401 | Missing, invalid, or revoked authentication |
402 | Subscription or credit requirement not met |
404 | Asset, input image, palette, or effect not found |
409 | Saved palette limit reached |
413 | Request or image limit exceeded |
429 | Rate limit or temporary credit contention |
500 | Unexpected application failure |
When a 429 response includes Retry-After, wait that many seconds before trying again.