API playground

Fill params, build sample code, try it live.

Fill in the parameters on the left and the request sample in each language updates on the right — copy it and run. You can also click "Send request" to try one live call and see the returned figure.

Endpoint & auth

POST https://promptfigure.pages.dev/api/v1/generate
Authorization: Bearer pf_...   (create in the console under "API keys"; shown in full only once)
Content-Type: application/json

Request parameters

ParamTypeRequiredDescription
promptstringYesOne-sentence description (any language; name every entity), ≤ 8000 chars; the server-side pipeline expands it into a publication-grade prompt automatically
modelstringNostandard (default, $0.02/call, 1K output) or premium ($0.15/call, 1K and 2K at the same price)
sizestringNopremium only: 1K or 2K, default 2K; standard always outputs 1K
ratiostringNoAspect ratio: 1:1 (default) / 3:2 / 2:3 / 16:9 / 9:16; invalid values fall back to 1:1
refDataUrlstringNoPNG reference image as a data URL (data:image/png;base64,…, ≤ 8MB after base64). PNG data URLs only. For image-to-image edits and composition/style alignment. Invalid references are ignored and the response carries refIgnored: true
refUrlstringNoPublic URL of the reference image (http/https, PNG ≤ 8MB, fetched server-side; must be a direct image link that renders the image itself with content-type image/png — not a web page). Mutually exclusive with refDataUrl — refDataUrl wins when both are sent. No host? Upload to a free image host first, tested working: x0.at (curl -F "file=@ref.png" https://x0.at) or uguu.se (~24h)

Auto-refund on failure: when generation fails (502) or rate limiting kicks in (429), the fee is refunded to your balance. On 502 the detail field explains the failure and refunded shows the amount; on 429 the limit field is your tier's RPM.

Response fields

FieldTypeDescription
b64_jsonstringPNG image (base64); decode with base64 -d to get the file
sizestringActual output tier: 1K / 2K
ratiostringActual aspect ratio
modelstringTier used: standard / premium
providerstringImage channel that served the request
craftedbooleanWhether the LLM pipeline ran (always true on success)
refIgnoredbooleanPresent only when a reference (refDataUrl/refUrl) was sent but missing, invalid or unreachable: true = the reference was dropped (the call still generates text-to-image and bills normally)
chargednumberFee charged for this call (USD)
balancenumberBalance after the charge

Error codes

HTTPerrorMeaningWhat to do
400prompt_required / prompt_too_longMissing prompt, or over 8000 charsFix the prompt in the request body and retry
401invalid_api_keyKey invalid or revokedCreate a new key in the console under "API keys"
402insufficient_balanceInsufficient balance (response includes required and balance)Top up in the console (from $1, whole-dollar amounts) and retry
429rate_limitedRPM exceeded (Free 5 / Lite 10 / Plus 15 / Pro 40 / Ultra 80, shared per-minute window with the web app)Retry serially with 1s+ gaps; the fee is auto-refunded
502generation_failedGeneration failedFee auto-refunded; check the detail field and retry