API DOCS OPEN APP
← API OVERVIEW

Text to Sprite

One prompt in, one cleaned sprite out: transparent background, quantised palette, crisp 1px outline. Then iterate for free with /resize.

POST /generate

POST /api/v1/generate 1 CR EPIC · 6 CR MYTHIC

Returns raw image/png bytes. The result is also saved to your SpriteLab history.

FieldTypeNotes
promptstring, requiredWhat to draw. Max 500 chars. Subject description only; the pixel art style scaffolding is added server-side
qualitystringepic (default, 1 credit) or mythic (6 credits, finer detail and cleaner shapes)
heightint16 to 512, default 128. Send height ONLY: the sprite is exactly this tall and width follows its natural proportions, no squishing
widthintLegacy: width plus a matching height forces an exact square canvas (stretches non-square subjects). Kept for existing clients; skip it for characters
directionstringauto, front, left, right, back, top, angled. Default right. auto picks front for tiny sprites, side for larger. Ignored when style_reference_id is set
detailint1 to 3 shading richness: 1 flat, 2 some shading, 3 rich detail. Default 1
isometricbool2:1 dimetric isometric view (Stardew Valley / Habbo Hotel framing)
style_notesstringFree-text style direction appended to the prompt, e.g. "muted earthy palette, thick outline". Max 500 chars
style_reference_idstringSprite id of an earlier generation to anchor style on (see Style reference)
…plus any of the tuning parameters below

curl:

curl -X POST https://spritelab.dev/api/v1/generate \
  -H "Authorization: Bearer sl_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "red health potion in a round glass bottle", "height": 64}' \
  --output potion.png

Python:

import requests

r = requests.post(
    "https://spritelab.dev/api/v1/generate",
    headers={"Authorization": "Bearer sl_live_YOUR_KEY"},
    json={
        "prompt": "armoured knight with tower shield",
        "quality": "mythic",
        "height": 128,
        "max_colours": 16,
        "palette_lock": "pico8",
    },
)
r.raise_for_status()
open("knight.png", "wb").write(r.content)
print("sprite id:", r.headers["X-SpriteLab-Sprite-Id"])
print("credits left:", r.headers["X-SpriteLab-Credits-Remaining"])

Response headers: X-SpriteLab-Sprite-Id (use it with /resize) and X-SpriteLab-Credits-Remaining.

POST /resize

POST /api/v1/resize FREE

Re-run the cleanup pipeline on a sprite you already generated, at new dimensions and/or with new tuning. No model call, so it's free and fast (typically under a second). This is the iteration endpoint: generate once, then resize and retune as many times as you like. Works on /generate and /convert results.

FieldTypeNotes
sprite_idstring, requiredFrom the X-SpriteLab-Sprite-Id header or the JSON id field of a previous generation. Owner-only
heightint, required16 to 512. Height only = natural proportions; adding a matching width = legacy exact square
…plus any of the tuning parameters below
curl -X POST https://spritelab.dev/api/v1/resize \
  -H "Authorization: Bearer sl_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"sprite_id": "SPRITE_ID", "height": 32, "max_colours": 8}' \
  --output potion_32.png

Sprites from other modes (micro, backgrounds, animation) can't go through this pipeline and return 409 not_resizable.

POST /enhance-prompt

POST /api/v1/enhance-prompt FREE

Rewrites a rough prompt into a richer sprite description (the same enhancement the app's prompt-improve button uses). Useful as a pre-processing step before /generate.

curl -X POST https://spritelab.dev/api/v1/enhance-prompt \
  -H "Authorization: Bearer sl_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "cool sword"}'

# → {"enhanced": "ornate longsword with a jewelled crossguard, ..."}

GET /credits

GET /api/v1/credits FREE

Your API-spendable balance (the top-up bucket) and account tier.

curl https://spritelab.dev/api/v1/credits \
  -H "Authorization: Bearer sl_live_YOUR_KEY"

# → {"credits": 380, "tier": "knight"}

Style reference

Generate one hero asset first. Pass its id as style_reference_id to everything after: palette, proportions and rendering match automatically, so a whole cast reads as one game. Same price as a plain generate.

hero = requests.post(f"{BASE}/generate", headers=KEY,
    json={"prompt": "knight hero, blue cloak"})
hero_id = hero.headers["X-SpriteLab-Sprite-Id"]

goblin = requests.post(f"{BASE}/generate", headers=KEY,
    json={"prompt": "goblin enemy, crooked dagger",
          "style_reference_id": hero_id})

Tuning parameters

Accepted on /generate, /resize and /convert. All optional; anything you omit uses the pipeline default. Anything not listed here is ignored.

ParamType / rangeWhat it does
max_coloursint, 2 to 64Palette size after quantisation
outline_thicknessint, 0 to 4Outline width in pixels. 0 disables the outline entirely
outline_colourhex, #RGB or #RRGGBBOutline colour (default black)
palette_lockstringSnap to a preset palette: gameboy, demichrome, cga, slso8, pico8, sweetie16, nes, endesga16, endesga32, apollo. Or pass your own space-separated hex list ("#1a1c2c #5d275d #b13e53"). "none" or omit to disable
ditheringboolFloyd-Steinberg dithering. Only meaningful with palette_lock
contrastfloat, 0.0 to 3.01.0 = unchanged
saturationfloat, 0.0 to 3.01.0 = unchanged
brightnessfloat, 0.0 to 3.01.0 = unchanged