API Reference

All endpoints are relative to https://api.pixelengine.ai/functions/v1. Every request requires an API key.

GET/balance

Returns the authenticated user's current credit balance.

Response

Response 200
{
  "monthly_balance": 1200,
  "purchased_balance": 500,
  "total_balance": 1700,
  "reserved": 20,
  "available": 1680
}
FieldTypeDescription
monthly_balanceintegerCurrent monthly credit pool.
purchased_balanceintegerCurrent purchased credit pool.
total_balanceintegermonthly_balance + purchased_balance.
reservedintegerCredits held by in-flight jobs (not yet deducted).
availableintegerCredits available for new jobs (total_balance − reserved, floor 0).

Errors

HTTPCodeCause
401unauthorizedInvalid or inactive API key.
POST/animate

Submits an image-to-video pixel art generation job. Returns immediately with a job ID; generation runs asynchronously. Poll GET /jobs to track progress.

Cost: 20 credits (subject to per-user discount).

Request body

JSON
{
  "image": "<base64-encoded PNG or data URL>",
  "prompt": "a character walking through a forest",
  "negative_prompt": "blurry, distorted",
  "pixel_config": { "colors": 16 },
  "output_frames": 8,
  "output_format": "webp",
  "matte_color": "#808080"
}
FieldTypeRequiredDescription
imagestringYesBase64-encoded PNG, or a data URL (data:image/png;base64,…). See image constraints below.
promptstringYesNon-empty text describing the desired animation.
negative_promptstringNoWhat to avoid in the generation.
pixel_configobjectNoColor palette config. Defaults to { "colors": 24 }. See PixelConfig below.
output_framesintegerNoNumber of animation frames. Even integer between 2–16. Default: 8. Played back at 8 fps.
output_formatstringNo"webp" (default), "gif", or "spritesheet".
matte_colorstringNo6-character hex color (e.g. "#ff0000") used to flatten the alpha channel of the input PNG before processing. Default: "#808080" (50% gray).

PixelConfig

Provide one of two modes — never both. If pixel_config is omitted entirely, defaults to count mode with 24 colors.

Count mode — cluster output to N colors
{ "colors": 24 }
Palette mode — force specific colors
{ "palette": ["#ffaa00", "#223344", "#ffffff"] }
FieldTypeConstraints
colorsinteger2–256.
palettestring[]Array of hex color strings (e.g. "#ff0000")
Palette mode is an experimental feature. Forcing a specific palette can produce worse results than letting the model choose its own colors. If quality matters more than exact color matching, prefer count mode (colors).

Image constraints

  • Format: PNG only. Validated via magic bytes; data URL prefix is stripped automatically.
  • Max decoded size: 5 MB.
  • Max dimension: 256 px per axis (width or height).
  • Max aspect ratio: 2:1 in either orientation (e.g. 256×128 is ok; 256×100 is not).
  • Alpha: flattened onto a matte color before processing. Defaults to mid-grey (#808080); override with matte_color.

Response

Response 200
{
  "api_job_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
  "status": "queued",
  "error": null
}

Errors

HTTPCodeCause
400invalid_requestMissing or invalid field (prompt, image format, output_frames, etc.).
400image_too_largeImage exceeds 5 MB decoded.
401unauthorizedInvalid or inactive API key.
402insufficient_creditsNot enough available credits.
500internal_errorServer-side failure.
GET/jobs

Returns the current state of a job. On completion, includes a signed download URL or error details.

Query parameters

ParameterRequiredDescription
idYesThe api_job_id returned by POST /animate.

Response

Response 200 — queued
{
  "api_job_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
  "status": "queued",
  "progress": 0.0,
  "created_at": "2026-03-02T18:00:00.000Z",
  "finished_at": null,
  "output": null,
  "error": null
}

Status values

ValueMeaning
"queued"Job accepted, waiting to be picked up.
"pending"Job is actively running.
"success"Generation complete. output is populated.
"failure"Generation failed. error is populated.

progress is a float 0.0–1.0. May remain 0 until the job is actively running.

Output object (on success)

output — status: "success"
{
  "url": "https://...",
  "content_type": "image/webp",
  "metadata": { ... },
  "expires_at": "2026-03-03T18:00:00.000Z"
}
FieldDescription
urlPre-signed download URL. Valid for 1 hour. Re-poll to get a fresh URL after expiry.
content_type"image/webp", "image/gif", or "image/png" (spritesheet).
metadataOutput dimensions and format details. See shapes below.
expires_atISO timestamp when the output file is permanently deleted (24 hours after job creation).
Output files are permanently deleted 24 hours after job creation — after that, polling returns 410 job_expired. The signed url is valid for 1 hour; re-poll GET /jobs to get a fresh one before it expires.

Metadata shapes

webp and gif
{ "width": 64, "height": 64, "frame_count": 8, "fps": 8.0 }
spritesheet
{
  "width": 512,
  "height": 64,
  "output_format": "spritesheet",
  "frame_count": 8,
  "frame_w": 64,
  "frame_h": 64
}

Spritesheets are a single horizontal strip: width == frame_count × frame_w, height == frame_h. Output dimensions always match the original input image, regardless of internal upscaling.

Error object (on failure)

error — status: "failure"
{
  "code": "generation_failed",
  "message": "Generation failed"
}

Errors

HTTPCodeCause
400invalid_requestid query parameter missing.
401unauthorizedInvalid or inactive API key.
404job_not_foundNo job with that ID, or the job belongs to a different API key.
410job_expiredJob output has been deleted. Outputs are retained for 24 hours.
500internal_errorServer-side failure.

See also

The Introduction covers everything needed before making your first request: base URL, authentication and API key management, the credit system, the shared error response format, and the recommended polling pattern for async jobs.