LogoPhotopurr Docs
LogoPhotopurr Docs
HomepageWhat is PhotopurrGenerating imagesCreditsAPI reference
Developer Center

API reference

Full parameters, response and billing for POST /api/v1/generate

Photopurr exposes one synchronous generation endpoint: send a request, wait for the run to finish, get image URLs back in a single response. Built for scripts and server-side calls. First time here? Start with the quick start.

POST /api/v1/generate
Authorization: Bearer sk_your_key
Content-Type: application/json

Requires the generate:write scope. A single request can run for up to 5 minutes. Four 4K images can take a minute or two, so don't set your client timeout too low.

Request parameters

FieldTypeRequiredDescription
promptstringone of the twoPrompt, up to 4000 characters
ref_image_idsstring[]one of the twoReference image ids, see reference images
modelstringnoDefault auto, see models
ratiostringno1:1 / 3:4 (default) / 4:5 / 16:9 / 9:16
resolutionstringno1K / 2K / 4K. Omit to use the model's default
qualitystringnolow / medium (default) / high, GPT models only
nnumberno1 (default) / 2 / 4
session_idstringnoWhich session to file this under, see sessions
purpose_idstringnoPurpose, see purposes

At least one of prompt and ref_image_ids is required. Both together is fine.

Bad parameters are never silently ignored. An unknown model, a ratio the model doesn't support, or more reference images than the limit all return 400. We never swap in a default and report success.

Models

modelRatiosResolutionQualityReference limitCredits per imageStatus
auto————Per the model actually chosenDefault
nano-banana-2All1K / 2K / 4K, default 2KNone1412 / 16 / 23Stable
gpt-image-2All1K / 2K / 4K, default 1Klow / medium / high16By quality 5 / 15 / 50, +1 per reference imageStable
gpt-image-2.5AllSame as aboveSame as above16Same as aboveTesting
seedream-5-0-proNo 4:51K / 2K, default 1KNone106 / 12Testing
qwen-image-3.0-proNo 4:51K / 2K, default 1KNone36 / 11Testing
flux-kontext-proAll1KNone15Edit only

How auto picks: nano-banana-2 by default; gpt-image-2 when the prompt asks for text in the image (brand name, slogan, price); another model that fits when the reference count exceeds the preferred model's limit. The response has no field telling you which model Auto chose. Pass model explicitly when you need to know.

On GPT models an omitted quality is billed as medium (15 credits). Other models ignore quality.

Purposes

purpose_id decides which set of e-commerce photography rules is added on top of your prompt. Omitting it means free.

purpose_idMeaning
freeFree generation, prompt only
main_whiteMarketplace hero image
detailDetail shot
buyer_showBuyer show
pure_whiteWhite background, no person

Reference images

ref_image_ids takes image ids. Today the API can obtain ids from exactly one source: images[].id returned by earlier calls to this endpoint. Images uploaded on the website have no externally visible id yet, and there is no upload endpoint.

Ids must belong to the current account. If an image has been deleted or cleaned up you get 400 reference_image_missing; it is never skipped silently. Retention rules are on the image download page.

Sessions

Every generation belongs to a session. Omit session_id and a new one is created, titled "API generation", visible under "Recent conversations" in the website sidebar. Pass the session_id from a previous response to group several generations into one session so you can review them together on the website.

A session_id that doesn't exist or isn't yours returns 404 session_not_found.

Response

{
  "ok": true,
  "turn_id": "t_xxxxxxxxxx",
  "session_id": "s_xxxxxxxxxx",
  "credits_charged": 16,
  "duration_ms": 18320,
  "warnings": [],
  "images": [
    {
      "id": "img_xxxxxxxx",
      "filename": "xxxxxxxx.png",
      "url": "/api/file/xxxxxxxx.png",
      "width": 1536,
      "height": 2048
    }
  ]
}
FieldDescription
turn_idId of this generation
session_idThe session it belongs to; pass it back next time
credits_chargedCredits actually charged. On partial success this is already net of the refund
duration_msGeneration time
warningsParts of your request the vendor could not honor, see below
images[].idImage id, usable as ref_image_ids next time
images[].urlRelative path; request it with the same key, see image download
images[].width / heightActual pixels

The response carries an X-Request-Id header. Include it when reporting a problem.

warnings

An empty array means the images match your request exactly. A non-empty array deserves a look. It lists what you asked for that the vendor could not deliver:

{ "type": "downgraded", "feature": "resolution", "details": "Upstream returned only 1024×1365. Upscaled locally 1.50x to 1536×2048, so the detail is not native." }
FieldDescription
typeunsupported: the vendor doesn't support it at all; downgraded: supported, but not at the spec you asked for
featureWhich one: ratio / resolution / quality / n and so on
detailsHuman-readable explanation. It follows the language: the website uses the interface language, the API uses Accept-Language, and the default is Chinese

Asking for 4 and getting 2 also shows up here (feature: "n"), billed for 2.

Billing

  • Once validation passes, credits are reserved (estimated from n), then the model is called
  • Whole run failed: full refund, endpoint returns 500
  • Partial success: billed for the actual count, difference refunded automatically, credits_charged is the net figure
  • Insufficient balance: 402 insufficient_credits, nothing reserved, message states how much is needed and how to top up

Accounts younger than 7 days can spend at most 2000 credits in any 24 hours. Past that you get 429 new_user_daily_limit.

Errors

Every error uses the same body:

{
  "error": {
    "code": "invalid_model",
    "message": "Unsupported model.",
    "request_id": "req_xxxxxxxxxxxxxxxxxxxx"
  }
}

Common ones on this endpoint:

StatuscodeMeaning
400invalid_request and per-parameter sub-codesInvalid parameters, full list under error format
401unauthorized / invalid_api_keyNo key / key invalid, revoked or expired
402insufficient_creditsNot enough credits
403insufficient_scopeKey lacks generate:write
404session_not_foundsession_id doesn't exist or isn't yours
429rate_limited / new_user_daily_limitKey over its rate limit / new account over its daily spend cap
500internal_errorGeneration failed, credits refunded. Report it with the request_id

Full example

curl -X POST https://paitumao.com/api/v1/generate \
  -H "Authorization: Bearer sk_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "White-background T-shirt hero shot, model facing front, soft lighting",
    "model": "nano-banana-2",
    "ratio": "3:4",
    "resolution": "2K",
    "n": 2,
    "purpose_id": "main_white"
  }'

This reserves 32 credits (16 per 2K image, two images).

Credits

How credits are earned, charged and refunded

Overview

Integrating with the Photopurr API

Table of Contents

Request parametersModelsPurposesReference imagesSessionsResponsewarningsBillingErrorsFull example