API Documentation

Getting Started

Integrate GenSprite into your pipeline

The GenSprite API lets you generate sprites, textures, concept art, rotations, and animations programmatically. All endpoints use JSON requests/responses and require API key authentication.

Base URL https://gensprite.ai

Authentication

API key via Bearer token

All API requests require an API key passed in the Authorization header. Generate a key from your Dashboard.

Header
Authorization: Bearer gsk_your_api_key
API keys start with gsk_. Keys are shown once on creation — store them securely. You can revoke and regenerate keys from the Dashboard at any time.

Errors

The API returns standard HTTP status codes. Error responses include a JSON body with a message field.

StatusMeaning
400Bad request — invalid or missing parameters
401Unauthorized — missing or invalid API key
402Insufficient tokens
404Resource not found
429Rate limited
500Internal server error

Token Costs

Tokens are deducted before generation, refunded on failure

Sprite 3 tokens
PBR Texture 4 tokens
Concept Art 4 tokens
Concept Art Restyle 6 tokens
Rotation (4-dir) 12 tokens
Rotation (8-dir) 25 tokens
Animation dynamic
GET /api/agent/config

Fetch platform configuration for the GenSprite agent. Returns the Anthropic API key (platform-owned, not user-facing), model settings, and the user's current credit balance. Rate limited to 1 request per minute per key.

Response

200 OK
{
  "anthropic_api_key": "sk-ant-...",
  "model": "claude-opus-4-5",
  "max_tokens": 8096,
  "user_id": "abc123",
  "credits": 142
}
GET /api/billing

Get your current token balance and pricing information.

Response

200 OK
{
  "tokens": 47,
  "bonusTokens": 95,
  "totalTokens": 142,
  "tokenCosts": {
    "sprite": 3,
    "texture": 4,
    "rotation": 25,
    "rotationNew": 12,
    "conceptArt": 4,
    "conceptArtRestyle": 6,
    "spin": 25,
    "rotationSingleView": 7
  }
}
POST /api/assets/generate

Generate a game sprite with transparent background. Costs 3 tokens.

Request Body

FieldTypeRequiredDescription
promptstringYesDescription of the sprite (max 2000 chars)
stylestringNohand-painted, anime, cartoon, realistic, vector, outline
widthnumberNoImage width in px (default: 512)
heightnumberNoImage height in px (default: 512)
seednumberNoSeed for reproducibility
curl -X POST https://gensprite.ai/api/assets/generate \
  -H "Authorization: Bearer gsk_your_key" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "medieval knight with sword", "style": "hand-painted"}'

Response

200 OK
{
  "asset": {
    "id": "abc123",
    "visibleId": "xK9mQ2",
    "status": "pending",
    "prompt": "medieval knight with sword",
    "width": 512,
    "height": 512,
    "tokenCost": 3,
    "createdAt": "2026-03-09T12:00:00.000Z"
  },
  "isGuest": false,
  "tokensUsed": 3,
  "tokensRemaining": 44,
  "bonusTokensRemaining": 95,
  "totalTokensRemaining": 139
}
GET /api/assets/{id}/status

Poll the status of a sprite generation. When status is "completed", the image URLs are in resultUrls. Poll every 2–5 seconds.

Response

200 OK — completed
{
  "id": "abc123",
  "status": "completed",
  "progress": 100,
  "resultUrls": {
    "raw": "https://...",
    "processed": "https://..."
  },
  "seed": 4281937,
  "completedAt": "2026-03-09T12:00:30.000Z"
}
status values: pendingprocessingcompleted | failed
POST /api/assets/{id}/cancel

Cancel an in-progress sprite generation. Tokens are automatically refunded if the generation hasn't completed.

Response

200 OK
{
  "success": true,
  "tokensRefunded": 3
}
GET /api/assets

List your generated sprites with cursor-based pagination.

Query Parameters

FieldTypeDefaultDescription
cursorstringAsset ID to paginate from
limitnumber20Results per page (max 50)

Response

200 OK
{
  "assets": [ ... ],
  "nextCursor": "xyz789"
}
POST /api/textures/generate

Generate a PBR texture set (basecolor, normal, roughness, metallic maps). Costs 4 tokens.

Request Body

FieldTypeRequiredDescription
promptstringYesDescription of the texture (max 2000 chars)

Status & Cancel

Use GET /api/textures/{id}/status and POST /api/textures/{id}/cancel. Completed textures include basecolorUrl, normalUrl, roughnessUrl, metallicUrl.

POST /api/concept-art/generate

Generate full-scene concept art. Costs 4 tokens (standard) or 6 tokens (restyle).

Request Body (JSON)

FieldTypeRequiredDescription
promptstringYesScene description (max 2000 chars)
imageSizestringNolandscape_16_9, landscape_4_3, square_hd, portrait_4_3, portrait_16_9
stylestringNopainterly, anime, realistic, pixel-art, watercolor, sci-fi, fantasy, ink-drawing
seednumberNoSeed for reproducibility

For restyle mode, use multipart/form-data with a compositionImage file, mode=restyle, controlMethod (canny | depth), and controlStrength (0–100).

Status & Cancel

Use GET /api/concept-art/{id}/status and POST /api/concept-art/{id}/cancel. Completed result includes imageUrl.

POST /api/rotate/generate

Generate 8-directional rotations from an input image. Costs 25 tokens. Accepts multipart/form-data (file upload) or JSON (image URL).

Request Body

FieldTypeRequiredDescription
imageFile*Image file (PNG/JPEG/WebP, max 10MB)
imageUrlstring*URL of existing image (* provide image or imageUrl)
elevationnumberNoCamera elevation angle, -90 to 90 (default: 0)
promptstringNoOptional description

Status & Cancel

Use GET /api/rotate/{id}/status and POST /api/rotate/{id}/cancel. Completed result includes rotationN, rotationNE, rotationE, etc. (8 direction URLs).

POST /api/rotate-new/generate

Generate 4-directional rotations (front, right, back, left). Costs 12 tokens. Same request format as 8-dir rotation.

Status & Cancel

Use GET /api/rotate-new/{id}/status and POST /api/rotate-new/{id}/cancel. Completed result includes rotationFront, rotationRight, rotationBack, rotationLeft.

POST /api/animate/generate

Generate frame-by-frame sprite animation with multi-direction support. Token cost varies by animation type and direction count. Uses multipart/form-data.

Form Fields

FieldTypeRequiredDescription
animationTypestringNowalk, run, idle, attack (default: run)
elevationstringNoside, low, iso, iso45, topdown (default: iso)
directionCountnumberNo4 or 8 (default: 4)
image_{dir}File*Image per direction (e.g. image_S, image_NE)
imageUrl_{dir}string*URL per direction (* provide at least one direction)
4-dir directions: S, W, N, E. 8-dir directions: S, SW, W, NW, N, NE, E, SE.

Status & Cancel

Use GET /api/animate/{id}/status and POST /api/animate/{id}/cancel. Completed result includes spritesheetUrl, frameCount, tileWidth, tileHeight.

Typical Workflow

Generate → Poll → Download

  1. 1
    Submit — POST to the generate endpoint. You'll get back a job id with status "pending".
  2. 2
    Poll — GET the status endpoint every 2–5 seconds. Watch for status to reach "completed" or "failed".
  3. 3
    Download — When completed, fetch the result URLs (images are publicly accessible).
# 1. Generate a sprite
RESPONSE=$(curl -s -X POST https://gensprite.ai/api/assets/generate \
  -H "Authorization: Bearer gsk_your_key" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "fire elemental monster", "style": "anime"}')

ASSET_ID=$(echo $RESPONSE | jq -r '.asset.id')

# 2. Poll until complete
while true; do
  STATUS=$(curl -s \
    -H "Authorization: Bearer gsk_your_key" \
    https://gensprite.ai/api/assets/$ASSET_ID/status)

  STATE=$(echo $STATUS | jq -r '.status')
  echo "Status: $STATE"

  if [ "$STATE" = "completed" ]; then
    IMAGE_URL=$(echo $STATUS | jq -r '.resultUrls.processed')
    echo "Done! $IMAGE_URL"
    break
  elif [ "$STATE" = "failed" ]; then
    echo "Failed: $(echo $STATUS | jq -r '.errorMessage')"
    break
  fi

  sleep 3
done

# 3. Download the image
curl -o sprite.png "$IMAGE_URL"