API Documentation

Integrate Univers Studio tools into your workflow

Getting Started

1. Subscribe to the Commercial plan

API access is available exclusively on the Commercial plan ($43.99/month, 800 credits).

2. Generate an API key

Once subscribed, go to the Pricing page and scroll to the "API Keys" section. Click "Generate Key" and copy your key. It will only be shown once.

3. Authenticate your requests

Include your API key in the Authorization header:

Authorization: Bearer us_live_YOUR_API_KEY_HERE

API keys use the same credit system as the web interface. Each generation consumes credits from your account.

Base URL

https://mosaic-api.fly.dev

Endpoints

Generate (Single Image)

POST /api/generate

Generate a coloring page, color by number, or mystery mosaic from a single image.

ParameterTypeDescription
imagefilerequiredImage file (PNG, JPEG, WebP). Max 10 MB.
modestringoptionalhex (mosaic), voronoi, cbn (color by number), lineart (coloring page), ai (AI coloring). Default: hex
outputstringoptionalzip, mystery, answer, legend, full, beauty, svg. Default: zip
colorsintoptionalNumber of colors (4–20). Default: 12
pagestringoptionalletter, a4. Default: letter
presetstringoptionalUse a preset (overrides other params). See /api/presets
detailstringoptionalLineart detail: simple, standard, detailed, expert
densitystringoptionalVoronoi density: easy, standard, detailed, expert
hintstringoptionalSubject hint for AI mode (e.g. "a cat")

Example — Coloring page:

curl -X POST https://mosaic-api.fly.dev/api/generate \
  -H "Authorization: Bearer us_live_YOUR_KEY" \
  -F "image=@photo.jpg" \
  -F "mode=lineart" \
  -F "output=zip" \
  -o coloring-page.zip

Example — Color by Number:

curl -X POST https://mosaic-api.fly.dev/api/generate \
  -H "Authorization: Bearer us_live_YOUR_KEY" \
  -F "image=@photo.jpg" \
  -F "mode=cbn" \
  -F "colors=10" \
  -o color-by-number.zip

Bulk Generate

POST /api/bulk

Generate from multiple images at once. Returns a ZIP. Max 50 images. Each image costs 1 credit.

curl -X POST https://mosaic-api.fly.dev/api/bulk \
  -H "Authorization: Bearer us_live_YOUR_KEY" \
  -F "images=@photo1.jpg" \
  -F "images=@photo2.jpg" \
  -F "images=@photo3.jpg" \
  -F "mode=lineart" \
  -o bulk-coloring.zip

AI Image Generation

POST /api/ai-image

Generate an image from a text prompt using AI.

ParameterTypeDescription
promptstringrequiredText description (3–1000 chars)
stylestringoptionalcoloring, cartoon, realistic, pixel-art, watercolor, sticker. Default: coloring
sizestringoptional1024x1024, 1024x1536, 1536x1024. Default: 1024x1024
qualitystringoptionallow (1 credit), medium (3 credits), high (10 credits). Default: low
curl -X POST https://mosaic-api.fly.dev/api/ai-image \
  -H "Authorization: Bearer us_live_YOUR_KEY" \
  -F "prompt=a cute unicorn in a flower garden" \
  -F "style=coloring" \
  -F "quality=low" \
  -o ai-coloring.png

Check Balance

GET /api/credits/balance

Check your current credit balance and plan info.

curl https://mosaic-api.fly.dev/api/credits/balance \
  -H "Authorization: Bearer us_live_YOUR_KEY"

Response:

{
  "balance": 742,
  "monthly_quota": 800,
  "plan_name": "commercial",
  "sub_status": "active"
}

List Presets

GET /api/presets

List all available generation presets. No auth required.

Credit Costs

ToolCredits
Coloring Page (lineart)1
Color by Number (cbn)1
Mystery Mosaic (hex/voronoi)1
AI Image — Standard1
AI Image — HD3
AI Image — Ultra HD10
Bulk generation1 per image

Rate Limits

API requests are subject to rate limits to ensure fair usage:

Exceeding rate limits returns a 429 status code. Wait and retry.

Error Codes

CodeMeaning
400Bad request (invalid parameters, unsupported image type)
401Unauthorized (missing or invalid API key)
402Insufficient credits
403Forbidden (feature not available on your plan)
429Rate limit exceeded
502Upstream AI service error

Managing API Keys

You can manage your API keys from the Pricing page when logged in with a Commercial plan. You can also use these endpoints:

POST /api/keys

Create a new API key. Requires JWT auth (not API key auth). Body: {"name": "My App"}

GET /api/keys

List your API keys (prefix, name, dates). Requires JWT auth.

DELETE /api/keys/{key_id}

Revoke an API key. Requires JWT auth.

Support

For API questions or issues, contact us at hello@univers.studio.