Identity API docs

From one upload to consistent images.

A REST API with JSON. Your server uploads a video or images, creates a reusable identity, and requests images. All jobs are asynchronous.

Base URL

https://api.pixelgenieai.com/api/v1

Specification

OpenAPI 3 (YAML)

API keys

Partner console

Quickstart

Your first image in five steps.

Run these commands on your server. You need an API key from the partner console and jq for the upload step.
01

Create a key and test it

Sign in to the partner console, open API keys, and create a key. The full key shows only once. Keep it in your server secret store.

Read your credit balance
export PIXELGENIE_API_KEY="pg_live_..."   # from the console, server side only
export BASE="https://api.pixelgenieai.com/api/v1"

curl "$BASE/partner-credits" \
  -H "Authorization: Bearer $PIXELGENIE_API_KEY"
200 OK
{
  "partner_account_id": "par_...",
  "available_credits": 998.25,
  "reserved_credits": 1.75,
  "updated_at": "2026-11-24T09:00:00Z"
}
02

Upload a video or images

Use kind: video for one guided video, or kind: reference_image once for each image. The upload URL is valid for 24 hours. If complete answers 413 (file too large), upload a smaller file to the same URL, then complete again with a new Idempotency-Key.

Create, send, and complete an upload
curl -X POST "$BASE/identity-uploads" \
  -H "Authorization: Bearer $PIXELGENIE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: upload-user-42-video-001" \
  -d '{
    "kind": "video",
    "file_name": "identity-scan.mp4",
    "content_type": "video/mp4"
  }' > upload.json

# Send the file to the signed URL, with the returned upload_headers.
curl -X PUT "$(jq -r '.upload_url' upload.json)" \
  -H "Content-Type: video/mp4" \
  --upload-file identity-scan.mp4

# Tell PixelGenie AI that the file is stored.
UPLOAD_ID="$(jq -r '.id' upload.json)"
curl -X POST "$BASE/identity-uploads/$UPLOAD_ID/complete" \
  -H "Authorization: Bearer $PIXELGENIE_API_KEY" \
  -H "Idempotency-Key: complete-$UPLOAD_ID"
03

Create the identity model

This reserves the one-time setup charge: 5 credits for video, 2 for images. Use source_type: images with the IDs of your completed image uploads.

Create and read an identity model
curl -X POST "$BASE/identity-models" \
  -H "Authorization: Bearer $PIXELGENIE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: model-user-42-001" \
  -d '{
    "external_user_id": "user-42",
    "source_type": "video",
    "upload_ids": ["'"$UPLOAD_ID"'"],
    "client_reference": "model-user-42-001"
  }'

# 202 Accepted: { "id": "idm_...", "status": "pending", "credits": 5, ... }
# Read it until "status" is "ready" (or "failed").
curl "$BASE/identity-models/idm_..." \
  -H "Authorization: Bearer $PIXELGENIE_API_KEY"
04

Request an image

The model must be ready. Choose the quality for each request. To edit an existing image, upload it with kind: target_image and send its ID as target_upload_id.

Create a generation
curl -X POST "$BASE/identity-generations" \
  -H "Authorization: Bearer $PIXELGENIE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: gen-user-42-0001" \
  -d '{
    "identity_model_id": "idm_...",
    "prompt": "A professional portrait with a blue shirt",
    "quality": "studio",
    "aspect_ratio": "3:4",
    "client_reference": "gen-user-42-0001"
  }'

# 202 Accepted: { "id": "gen_...", "status": "pending", "credits": 1.75, ... }

Each generation uses a PixelGenie AI engine, shown in the field engine. Without it, the current default engine is used, and the default can change. If you need one engine, send engine, for example identity-2. Responses omit engine while only one engine is available. A replay of a stored response (Idempotency-Key, 24 hours) returns it as it was stored, so it can show or omit engine.

05

Get the result

Reading the status needs generations:read. Downloading output_url also needs identity:read. A new console key has all four scopes.

Read the status and download
# Read the generation until "status" is "completed" (or "failed").
curl "$BASE/identity-generations/gen_..." \
  -H "Authorization: Bearer $PIXELGENIE_API_KEY"

# Download the image. output_url needs the same API key.
curl -L "<output_url>" \
  -H "Authorization: Bearer $PIXELGENIE_API_KEY" \
  -o result.png

The same flow in JavaScript (Node 18 or later):

generate.mjs
// Node 18+ on your server. Never ship the key in a mobile or web app.
const BASE = "https://api.pixelgenieai.com/api/v1";
const headers = {
  Authorization: `Bearer ${process.env.PIXELGENIE_API_KEY}`,
  "Content-Type": "application/json",
};

async function generate(identityModelId, prompt, requestId) {
  const created = await fetch(`${BASE}/identity-generations`, {
    method: "POST",
    headers: { ...headers, "Idempotency-Key": requestId },
    body: JSON.stringify({
      identity_model_id: identityModelId,
      prompt,
      quality: "studio",
      aspect_ratio: "3:4",
      client_reference: requestId,
    }),
  });
  if (!created.ok) throw new Error(`create failed: ${created.status}`);
  let generation = await created.json();
  const id = generation.id;

  // Poll with a growing delay until the job ends.
  for (let delay = 2000; !["completed", "failed"].includes(generation.status); ) {
    await new Promise((resolve) => setTimeout(resolve, delay));
    delay = Math.min(delay * 1.5, 15000);
    const answer = await fetch(`${BASE}/identity-generations/${id}`, { headers });
    if (answer.status >= 500) continue; // temporary: try again
    if (!answer.ok) throw new Error(`read failed: ${answer.status}`);
    generation = await answer.json();
  }
  return generation; // completed: generation.output_url
}

Authentication

One key per server, four scopes.

Send the key in the Authorization header of every request. Use the key only on your server, never in a mobile or web app. All keys of one partner account share its credits and media.
ScopeGives access to
identity:readCredit balance and packages, purchases, identity models, client references, and downloads of stored media and results (download_url, output_url).
identity:writeCredit purchases, uploads, and identity models (create and delete).
generations:readGeneration status. To download the result image, the key also needs identity:read.
generations:writeCreate and delete generations.

A key lives 1 to 365 days. To replace a key: create a new key, deploy it, test one request, then revoke the old key in the console.

Jobs and status

Every job is asynchronous.

A create request answers 202 Accepted at once. Read the resource until it reaches an end status. Start with a 2 second delay and make it longer up to about 15 seconds.

Identity model

pending→processing→readyorfailed

Use it for any number of generations. A failed job has error_code and error_message, and its credits go back to your balance.

Generation

pending→processing→completedorfailed

output_url contains the result. A failed job has error_code and error_message, and its credits go back to your balance.

Safe retries

Retry without paying twice.

Network errors happen. Two fields make a retry safe.

Idempotency-Key header

Required on every POST. 8 to 255 characters. The first character is a letter or digit; the others are letters, digits, or . _ : -. The same key and body in 24 hours return the first answer. The same key with a different body returns 409. A 402 or 5xx answer is not stored, so you can retry it with the same key. A 400 for an engine that is not available is not stored either: during a service update, the same request can return 400 and later 202.

client_reference field

Optional on uploads, identity models, and generations. It does not expire. The same reference returns the same resource and reserves no more credits. After an unclear answer, retry with the same reference, or read GET /identity-requests/{clientReference}.

Credits and pricing

Prepaid credits, charged per job.

PixelGenie AI reserves the credits when it accepts a job, takes them when the job succeeds, and gives them back when the job fails. Balances and charges can have two decimal places, so do not store them as integers.
Credits per job
Identity from video (once)5
Identity from images (once)2
Standard image1
Studio image1.75
Ultra image3.25
Credit packs
Launch1,000 credits$120
Growth5,000 credits$575
Scale10,000 credits$1,100

Buy packs by card in the console (Billing). The console also shows usage and sends low-credit emails. See the pricing overview for the cost per image in each pack.

Errors

Clear status codes.

Error answers have a JSON body with an error text. Some answers also have a message with more detail. Always read error; use message when it is there.
  • 400Bad requestA field is missing or not valid. Read the error text, fix the request, then send it again. Exception: an engine that is not available is not stored, so the same request can succeed later.
  • 401UnauthorizedThe API key is missing, not valid, expired, or revoked.
  • 402Payment requiredNot enough available credits. Buy credits, then send the same request with the same Idempotency-Key.
  • 403ForbiddenThe API key does not have the scope for this endpoint.
  • 404Not foundThe resource does not exist, or another partner account owns it.
  • 409ConflictThe resource is not ready (for example a model that is still processing), or a key or client_reference was used for a different request.
  • 410GoneThe resource of this client_reference was deleted, or the upload session expired.
  • 413Too largeThe uploaded file is larger than the limit. Upload a smaller file to the same URL, then complete again with a new Idempotency-Key.
  • 5xxServer errorRetry with the same Idempotency-Key, with a growing delay.

Media and deletion

Your media stays until you delete it.

download_url and output_url do not expire, and they always need your API key. PixelGenie AI does not delete completed media automatically. Delete a generation, then its identity model, then the source uploads. A job that is still running cannot be deleted.

API reference

All endpoints.

This reference comes from the OpenAPI specification of the live API. All paths are relative to https://api.pixelgenieai.com/api/v1.

Credits

GET/partner-credits

Read the partner credit balance

Scope: identity:read

Response 200

Credit balance for the API key account

available_creditsnumberrequired

Available partner credits. Preserve fractional values; do not decode as an integer.

minimum: 0 · multipleOf: 0.01

partner_account_idstringrequired
reserved_creditsnumberrequired

Credits reserved by accepted jobs. Failed jobs release their saved reservation.

minimum: 0 · multipleOf: 0.01

updated_atstring (date-time)required

Error responses

  • 401Authentication failed
  • 403The key lacks access, or the account lacks required credits or entitlement
GET/partner-credit-packages

List server-priced partner credit packages

Scope: identity:read

Response 200 · array of objects

Available partner credit packages

amount_centsintegerrequired
codestringrequired

One of:launchgrowthscale

creditsintegerrequired
currencystringrequired
namestringrequired

Error responses

  • 401Authentication failed
  • 403The key lacks access, or the account lacks required credits or entitlement
POST/partner-credit-purchases

Create a Stripe checkout for a partner credit package

PixelGenie AI adds credits only after Stripe confirms payment through the verified webhook.

Scope: identity:write

Parameters

Idempotency-Keystringheaderrequired

Retry-safe key stored for 24 hours. API key requests require this header.

minLength: 8 · maxLength: 255 · pattern: ^[A-Za-z0-9][A-Za-z0-9._:-]{7,254}$

Request body · JSON

packagestringrequired

One of:launchgrowthscale

Response 200

The purchase of this Idempotency-Key already exists (an open checkout or a completed purchase)

amount_centsintegerrequired
created_atstring (date-time)required
creditsintegerrequired
currencystringrequired
idstringrequired
packagestringrequired

One of:launchgrowthscale

statusstringrequired

One of:pendingcompleted

updated_atstring (date-time)required
checkout_session_idstringoptional
completed_atstring (date-time)optional

Response 201

Checkout session created

amount_centsintegerrequired
created_atstring (date-time)required
creditsintegerrequired
currencystringrequired
idstringrequired
packagestringrequired

One of:launchgrowthscale

statusstringrequired

One of:pendingcompleted

updated_atstring (date-time)required
checkout_session_idstringoptional
completed_atstring (date-time)optional

Error responses

  • 400Invalid request
  • 401Authentication failed
  • 403The key lacks access, or the account lacks required credits or entitlement
  • 409The resource is not ready for this operation
GET/partner-credit-purchases/{purchaseId}

Read a partner credit purchase

Scope: identity:read

Parameters

purchaseIdstringpathrequired

Response 200

Partner credit purchase

amount_centsintegerrequired
created_atstring (date-time)required
creditsintegerrequired
currencystringrequired
idstringrequired
packagestringrequired

One of:launchgrowthscale

statusstringrequired

One of:pendingcompleted

updated_atstring (date-time)required
checkout_session_idstringoptional
completed_atstring (date-time)optional

Error responses

  • 401Authentication failed
  • 403The key lacks access, or the account lacks required credits or entitlement
  • 404Resource not found

Uploads

POST/identity-uploads

Create an identity media upload

The returned upload URL expires after 24 hours. Completed media remains until explicit deletion. A repeated client_reference returns the same upload with a newly signed URL while it is pending.

Scope: identity:write

Parameters

Idempotency-Keystringheaderrequired

Retry-safe key stored for 24 hours. API key requests require this header.

minLength: 8 · maxLength: 255 · pattern: ^[A-Za-z0-9][A-Za-z0-9._:-]{7,254}$

Request body · JSON

content_typestringrequired

One of:video/mp4video/quicktimeimage/jpegimage/pngimage/webp

file_namestringrequired

maxLength: 255

kindstringrequired

One of:videoreference_imagetarget_image

client_referencestringoptional

Optional durable creation identity. PixelGenie AI keeps it while the resource exists and as a tombstone after deletion. The same reference and payload return the same resource. A different payload returns 409. Without this field, only the 24-hour Idempotency-Key replay applies.

minLength: 8 · maxLength: 255 · pattern: ^[A-Za-z0-9][A-Za-z0-9._:-]{7,254}$

Response 201

Upload session created

content_typestringrequired
created_atstring (date-time)required
file_namestringrequired
idstringrequired
kindstringrequired

One of:videoreference_imagetarget_image

statusstringrequired

One of:pendinguploadedexpireddeleted

download_urlstring (uri)optional

Stable PixelGenie AI URL. It requires the owning API key and does not expire.

expires_atstring (date-time)optional

The end of the upload session. Present while the upload is pending or after it expired; removed when the upload completes.

upload_headersobject (string values)optional
upload_urlstring (uri)optional
uploaded_atstring (date-time)optional

Error responses

  • 400Invalid request
  • 401Authentication failed
  • 403The key lacks access, or the account lacks required credits or entitlement
  • 409The client_reference was already used for a different request
  • 410The resource created for this client_reference was deleted. No new resource is created and no credits are reserved.
POST/identity-uploads/{uploadId}/complete

Complete an identity media upload

PixelGenie AI verifies the stored object type and size, then creates a permanent asset record. Images and videos have separate configured byte limits.

Scope: identity:write

Parameters

Idempotency-Keystringheaderrequired

Retry-safe key stored for 24 hours. API key requests require this header.

minLength: 8 · maxLength: 255 · pattern: ^[A-Za-z0-9][A-Za-z0-9._:-]{7,254}$

uploadIdstringpathrequired

Response 200

Upload completed

content_typestringrequired
created_atstring (date-time)required
file_namestringrequired
idstringrequired
kindstringrequired

One of:videoreference_imagetarget_image

statusstringrequired

One of:pendinguploadedexpireddeleted

download_urlstring (uri)optional

Stable PixelGenie AI URL. It requires the owning API key and does not expire.

expires_atstring (date-time)optional

The end of the upload session. Present while the upload is pending or after it expired; removed when the upload completes.

upload_headersobject (string values)optional
upload_urlstring (uri)optional
uploaded_atstring (date-time)optional

Error responses

  • 400Invalid request
  • 404Resource not found
  • 410The upload session expired
  • 413The stored file exceeds the byte limit for its upload kind. Upload a smaller file to the same URL, then complete again.
DELETE/identity-uploads/{uploadId}

Delete an identity upload

This permanently deletes stored source media. An upload in use cannot be deleted.

Scope: identity:write

Parameters

uploadIdstringpathrequired

Response 204

Upload deleted

No body.

Error responses

  • 404Resource not found
  • 409The resource is not ready for this operation
GET/identity-assets/{assetId}/content

Download stored identity media

This stable URL does not expire. The request always requires the owning API key.

Scope: identity:read

Parameters

assetIdstringpathrequired

Response 200

Stored image or video content

Body: binary file.

Error responses

  • 404Resource not found

Identity models

POST/identity-models

Create an identity model

PixelGenie AI creates a reusable identity from completed video or image uploads. The credit reservation, model, and processing job are stored together. A repeated client_reference returns the existing model and reserves no more credits.

Scope: identity:write

Parameters

Idempotency-Keystringheaderrequired

Retry-safe key stored for 24 hours. API key requests require this header.

minLength: 8 · maxLength: 255 · pattern: ^[A-Za-z0-9][A-Za-z0-9._:-]{7,254}$

Request body · JSON

external_user_idstringrequired

The partner's stable user identifier. It does not create a PixelGenie AI login.

maxLength: 160

source_typestringrequired

One of:videoimages

upload_idsstring[]required

minItems: 1 · uniqueItems

client_referencestringoptional

Optional durable creation identity. PixelGenie AI keeps it while the resource exists and as a tombstone after deletion. The same reference and payload return the same resource. A different payload returns 409. Without this field, only the 24-hour Idempotency-Key replay applies.

minLength: 8 · maxLength: 255 · pattern: ^[A-Za-z0-9][A-Za-z0-9._:-]{7,254}$

Response 202

Identity processing accepted

created_atstring (date-time)required
creditsnumberrequired

One-time setup charge for this identity. Photos cost 2 credits and video costs 5. Reusing this identity does not repeat setup.

minimum: 0 · multipleOf: 0.01

external_user_idstringrequired
idstringrequired
reference_countintegerrequired

minimum: 0

source_typestringrequired

One of:videoimages

statusstringrequired

One of:pendingprocessingreadyfaileddeleted

updated_atstring (date-time)required
error_codestringoptional
error_messagestringoptional
ready_atstring (date-time)optional

Error responses

  • 400Invalid request
  • 402The account needs more credits
  • 403The key lacks access, or the account lacks required credits or entitlement
  • 409The client_reference was already used for a different request
  • 410The resource created for this client_reference was deleted. No new resource is created and no credits are reserved.
GET/identity-models/{identityModelId}

Read an identity model

Scope: identity:read

Parameters

identityModelIdstringpathrequired

Response 200

Identity model status

created_atstring (date-time)required
creditsnumberrequired

One-time setup charge for this identity. Photos cost 2 credits and video costs 5. Reusing this identity does not repeat setup.

minimum: 0 · multipleOf: 0.01

external_user_idstringrequired
idstringrequired
reference_countintegerrequired

minimum: 0

source_typestringrequired

One of:videoimages

statusstringrequired

One of:pendingprocessingreadyfaileddeleted

updated_atstring (date-time)required
error_codestringoptional
error_messagestringoptional
ready_atstring (date-time)optional

Error responses

  • 404Resource not found
DELETE/identity-models/{identityModelId}

Delete an identity model

This permanently deletes extracted reference media. Source uploads and completed generations remain separate resources. Active generations must finish first.

Scope: identity:write

Parameters

identityModelIdstringpathrequired

Response 204

Identity model deleted

No body.

Error responses

  • 404Resource not found
  • 409The resource is not ready for this operation

Generations

POST/identity-generations

Create an identity image

PixelGenie AI creates a new image or edits a target image with a ready identity model. The credit reservation, generation, and processing job are stored together. A repeated client_reference returns the existing generation and reserves no more credits.

Scope: generations:write

Parameters

Idempotency-Keystringheaderrequired

Retry-safe key stored for 24 hours. API key requests require this header.

minLength: 8 · maxLength: 255 · pattern: ^[A-Za-z0-9][A-Za-z0-9._:-]{7,254}$

Request body · JSON

aspect_ratiostringrequired

One of:1:13:44:39:1616:92:33:2

identity_model_idstringrequired

maxLength: 64

promptstringrequired

minLength: 1 · maxLength: 30000

qualitystringrequired

One of:standardstudioultra

client_referencestringoptional

Optional durable creation identity. PixelGenie AI keeps it while the resource exists and as a tombstone after deletion. The same reference and payload return the same resource. A different payload returns 409. Without this field, only the 24-hour Idempotency-Key replay applies.

minLength: 8 · maxLength: 255 · pattern: ^[A-Za-z0-9][A-Za-z0-9._:-]{7,254}$

enginestringoptional

Optional PixelGenie AI image engine. Without it, the current default engine is used, and the default can change. Send an engine if you need one. The engine is fixed when the request is accepted. A new request that names an engine that is not available returns 400. A retry with the same client_reference returns its accepted generation.

One of:identity-1identity-2

target_upload_idstringoptional

A completed target_image upload. When present, PixelGenie AI edits that image.

maxLength: 64

Response 202

Identity generation accepted

aspect_ratiostringrequired
created_atstring (date-time)required
creditsnumberrequired

Saved charge for this result. New Standard requests cost 1 credit, Studio 1.75, and Ultra 3.25. Existing requests and retries retain their original charge. Success commits it; failure releases it.

minimum: 0 · multipleOf: 0.01

idstringrequired
identity_model_idstringrequired
operationstringrequired
qualitystringrequired

One of:standardstudioultra

statusstringrequired

One of:pendingprocessingcompletedfailed

updated_atstring (date-time)required
completed_atstring (date-time)optional
enginestringoptional

The PixelGenie AI image engine of this generation. Generations from before engines existed show identity-1. While only one engine is available, responses omit it. A replay of a stored response (Idempotency-Key, 24 hours) returns that response as it was stored, so it can show or omit engine.

One of:identity-1identity-2

error_codestringoptional
error_messagestringoptional
output_urlstring (uri)optional

Stable PixelGenie AI URL. It requires the owning API key and does not expire.

started_atstring (date-time)optional

Error responses

  • 400Invalid request
  • 402The account needs more credits
  • 404Resource not found
  • 409The identity model is not ready, or the client_reference was already used for another request
  • 410The resource created for this client_reference was deleted. No new resource is created and no credits are reserved.
GET/identity-generations/{generationId}

Read an identity generation

Scope: generations:read

Parameters

generationIdstringpathrequired

Response 200

Identity generation status

aspect_ratiostringrequired
created_atstring (date-time)required
creditsnumberrequired

Saved charge for this result. New Standard requests cost 1 credit, Studio 1.75, and Ultra 3.25. Existing requests and retries retain their original charge. Success commits it; failure releases it.

minimum: 0 · multipleOf: 0.01

idstringrequired
identity_model_idstringrequired
operationstringrequired
qualitystringrequired

One of:standardstudioultra

statusstringrequired

One of:pendingprocessingcompletedfailed

updated_atstring (date-time)required
completed_atstring (date-time)optional
enginestringoptional

The PixelGenie AI image engine of this generation. Generations from before engines existed show identity-1. While only one engine is available, responses omit it. A replay of a stored response (Idempotency-Key, 24 hours) returns that response as it was stored, so it can show or omit engine.

One of:identity-1identity-2

error_codestringoptional
error_messagestringoptional
output_urlstring (uri)optional

Stable PixelGenie AI URL. It requires the owning API key and does not expire.

started_atstring (date-time)optional

Error responses

  • 404Resource not found
DELETE/identity-generations/{generationId}

Delete an identity generation

This permanently deletes the completed output media.

Scope: generations:write

Parameters

generationIdstringpathrequired

Response 204

Identity generation deleted

No body.

Error responses

  • 404Resource not found
  • 409The resource is not ready for this operation

Client references

GET/identity-requests/{clientReference}

Find the resource created for a client reference

Use this after an uncertain creation response. A 404 means no committed creation is visible now. It does not prove that an in-flight request cannot commit later, so retry creation with the same client_reference instead of a new one.

Scope: identity:read

Parameters

clientReferencestringpathrequired

minLength: 8 · maxLength: 255 · pattern: ^[A-Za-z0-9][A-Za-z0-9._:-]{7,254}$

Response 200

The resource created for this client reference

client_referencestringrequired
created_atstring (date-time)required
resource_idstringrequired

The PixelGenie AI ID of the upload, identity model, or generation.

resource_kindstringrequired

One of:uploadidentity_modelgeneration

submission_statusstringrequired

accepted means the creation committed. Read the resource for its processing status. deleted means the resource was deleted later.

One of:accepteddeleted

resource_deleted_atstring (date-time)optional

Error responses

  • 404Resource not found