Introduction
The Pixel Engine API gives you programmatic access to Pixel Engine. Submit an image and a prompt, poll until the job finishes, and download the result. POST /animate supports both pixel art animation and general-purpose frame animation. This page covers everything you need to make your first request.
Base URL
https://api.pixelengine.ai/functions/v1All requests and responses use application/json. All endpoints support CORS.
Authentication
Every request must include a Bearer token in the Authorization header. There are two kinds, and every endpoint accepts both:
| Credential | Use it when |
|---|---|
| API key | You are calling the API for your own account — scripts, a game build pipeline, your own backend. |
| OAuth access token | Your app acts for other Pixel Engine users, who sign in with their own account and spend their own credits. See below. |
Authorization: Bearer pe_sk_... # API key
Authorization: Bearer eyJhbGciOiJFUzI1... # OAuth access tokenCreating an API key
API keys are managed in your account under Account → API.
- Sign in and go to Account → API.
- Click Add key and optionally give it a name.
- Copy the full key immediately — it is only shown once.
pe_sk_ab12cd34…) is saved for identification. If you lose your key, delete it and create a new one.You can hold up to 10 keys per account. Keys can be renamed, deactivated (paused without deletion), or permanently deleted. A deactivated key returns 401 unauthorized on every request until it is reactivated.
OAuth access tokens (Sign in with Pixel Engine)
For desktop apps, tools and services whose users bring their own Pixel Engine account. Users sign in on pixelengine.ai and approve your app on a consent screen that names it; your app never sees their password or an API key. This is standard OAuth 2.1 with PKCE — use any OAuth client library.
Discover the endpoints from the authorization server metadata rather than hardcoding them:
GET https://api.pixelengine.ai/auth/v1/.well-known/oauth-authorization-server- Register your app once at the
registration_endpoint(dynamic client registration), as a public client:"token_endpoint_auth_method": "none", grant typesauthorization_codeandrefresh_token. Theclient_nameyou register is what users see on the consent screen. Redirect URIs must match exactly; loopback (http://127.0.0.1:8765/callback) and custom schemes (yourapp://callback) are both accepted. - Send the user to the
authorization_endpointin their system browser withresponse_type=code, yourclient_id, theredirect_uri, anS256PKCE challenge, and astatevalue. - Exchange the code returned to your redirect URI at the
token_endpointfor an access token and a refresh token. - Call any endpoint with
Authorization: Bearer <access_token>— requests and responses are identical to API-key use.
| Behaviour | Detail |
|---|---|
| Access token lifetime | One hour. Refresh with grant_type=refresh_token at the token endpoint before it expires or on a 401. |
| Refresh tokens rotate | Every refresh returns a new refresh token and invalidates the old one. Always store the new pair. |
| Sessions end | After a period of inactivity, after a maximum session length, or when the user revokes your app. The refresh call then fails; send the user through sign-in again. A user who already approved your app is not shown the consent screen a second time. |
| Revocation | Users see your app under Account → Connect an agent and can revoke it there. |
| Job visibility | Jobs belong to the user and your app. GET /jobs returns jobs your app submitted for that user — including through the /mcp server with the same token — and not jobs they ran elsewhere. |
| Billing | Charged to the user's own credits. On 402 insufficient_credits, send them to their billing page; never collect payment for Pixel Engine credits in your app. |
Credits
Pixel Engine uses a credit system. Your available balance is the sum of two pools:
| Pool | Description |
|---|---|
| Monthly credits | Refreshed on your billing date. Approximately 200 credits = $1. |
| Purchased credits | Bought explicitly. Approximately 100 credits = $1. |
Monthly credits are spent first. Purchased credits are only drawn down once your monthly pool is exhausted.
Before a job runs, a hold is placed on the required credits for up to 10 minutes. If the job fails or is cancelled via POST /cancel, the hold is released and no credits are consumed. Credits are only deducted on a successful generation.
Endpoint costs
| Endpoint | Cost |
|---|---|
POST /animate | 20 credits, or 26 on pixel-engine-v1.5 |
POST /animate-batch | 20 + 12 × (N − 1) credits (N = sub-jobs) — cheaper per job than submitting individually |
POST /keyframes | 24 credits |
POST /generate-image | 6–36 credits (varies by model) |
POST /pixelate | Free |
POST /remove-background | 2 credits |
POST /cancel | Free |
POST /enhance-prompt | Free |
GET /balance | Free |
GET /billing | Free |
GET /jobs | Free |
GET /batch-jobs | Free |
Check your current balance at any time with GET /balance.
Training opt-out
We may use prompts, uploads and generations to train our models (see the Privacy Policy). There are two ways to opt out:
| Scope | How |
|---|---|
| Your whole account | Turn on Opt out of AI training in Account → Settings. Covers the app, your API keys and connected apps, including past content we haven't trained on yet. |
| One request | Send "training_opt_out": true in the JSON body of any endpoint that creates a job. Useful when your app serves its own users and only some of them opt out. On /animate-batch it can go at the top level (the whole batch) or inside one entry of jobs. |
GET /jobs returns training_opt_out as sent on that request. A value that is not a boolean is rejected with 400 invalid_request.
Errors
All error responses share this shape, regardless of endpoint:
{
"error": {
"code": "string",
"message": "string"
}
}code is a stable, machine-readable string — safe to match in application code. message is human-readable and safe to surface to users.
Common error codes
| HTTP | Code | When |
|---|---|---|
| 401 | unauthorized | Missing, malformed, or inactive API key, or an expired access token. |
| 402 | insufficient_credits | Not enough available credits to cover the job. |
| 500 | internal_error | Server-side failure. |
Endpoint-specific errors are documented on the API Reference page.
Polling
POST /animate returns a job ID immediately — generation runs asynchronously in the background. Use GET /jobs to wait for the result.
Recommended pattern
- Submit with
POST /animate. Save the returnedapi_job_id. - Call
GET /jobs?id=<api_job_id>every 3–5 seconds whilestatusis"queued"or"pending". - Stop polling when
statusis"success","failure", or"cancelled". On success,output.urlcontains a temporary download URL.
Typical generation time is ~90 seconds.
# 1. Submit a job
curl -X POST https://api.pixelengine.ai/functions/v1/animate \
-H "Authorization: Bearer pe_sk_..." \
-H "Content-Type: application/json" \
-d '{
"image": "<base64-encoded PNG>",
"prompt": "a character walking left"
}'
# → { "api_job_id": "f47ac10b-...", "status": "queued", "error": null }
# 2. Poll every 3–5 seconds until a terminal status
curl "https://api.pixelengine.ai/functions/v1/jobs?id=f47ac10b-..." \
-H "Authorization: Bearer pe_sk_..."
# → on success: output.url holds the download URLSee also
The API Reference contains the full specification for every endpoint: request bodies, all accepted fields and their types, response shapes, status values, metadata formats, and the complete list of error codes per endpoint.