Skip to content

API Reference

Base URL

txt
https://api.pixapi.ai

Shared headers

HeaderRequiredDescription
AuthorizationYesBearer $PIXAPI_KEY
Content-TypeYes for JSON bodiesUse application/json for generation requests. Use multipart/form-data for image edits with file uploads.

Pixapi model requests follow OpenAI-compatible field names. Use model, prompt, n, size, and optional model controls such as quality. The older Nano Banana-compatible request format is documented only in Legacy transition format.

Synchronous and async modes

Image requests support the standard OpenAI-compatible synchronous endpoints: POST /v1/images/generations and POST /v1/images/edits.

Long-running image work can also use dedicated async endpoints under /v1/async/*. Video generation is async-only and must be submitted through POST /v1/async/videos/generations. Pixapi returns a task id immediately. Poll GET /v1/tasks/{id} until the task reaches completed or failed.

WorkloadSynchronous endpointAsync endpoint
Text-to-imagePOST /v1/images/generationsPOST /v1/async/images/generations
Image editingPOST /v1/images/editsPOST /v1/async/images/edits
WorkloadAsync-only endpoint
Video generationPOST /v1/async/videos/generations

Do not use ?async=true or "async": true. See Async Media Tasks for the full integration pattern.

Request examples

bash
curl https://api.pixapi.ai/v1/images/generations \
  -H "Authorization: Bearer $PIXAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-3-pro-image-preview",
    "prompt": "A cinematic product photo of a ceramic coffee cup",
    "n": 1,
    "size": "1024x1024"
  }'
py
import os
import requests

response = requests.post(
    "https://api.pixapi.ai/v1/images/generations",
    headers={
        "Authorization": f"Bearer {os.environ['PIXAPI_KEY']}",
        "Content-Type": "application/json",
    },
    json={
        "model": "gemini-3-pro-image-preview",
        "prompt": "A cinematic product photo of a ceramic coffee cup",
        "n": 1,
        "size": "1024x1024",
    },
)

response.raise_for_status()
result = response.json()
print(result["data"][0]["url"])
js
const response = await fetch('https://api.pixapi.ai/v1/images/generations', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.PIXAPI_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'gemini-3-pro-image-preview',
    prompt: 'A cinematic product photo of a ceramic coffee cup',
    n: 1,
    size: '1024x1024',
  }),
});

if (!response.ok) {
  throw new Error(await response.text());
}

const result = await response.json();
console.log(result.data?.[0]?.url ?? result);
go
package main

import (
  "bytes"
  "fmt"
  "io"
  "net/http"
  "os"
)

func main() {
  body := []byte(`{
    "model": "gemini-3-pro-image-preview",
    "prompt": "A cinematic product photo of a ceramic coffee cup",
    "n": 1,
    "size": "1024x1024"
  }`)

  req, err := http.NewRequest(
    "POST",
    "https://api.pixapi.ai/v1/images/generations",
    bytes.NewBuffer(body),
  )
  if err != nil {
    panic(err)
  }
  req.Header.Set("Authorization", "Bearer "+os.Getenv("PIXAPI_KEY"))
  req.Header.Set("Content-Type", "application/json")

  resp, err := http.DefaultClient.Do(req)
  if err != nil {
    panic(err)
  }
  defer resp.Body.Close()

  result, _ := io.ReadAll(resp.Body)
  fmt.Println(string(result))
}
java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

class PixapiExample {
  public static void main(String[] args) throws Exception {
    String body = """
      {
        "model": "gemini-3-pro-image-preview",
        "prompt": "A cinematic product photo of a ceramic coffee cup",
        "n": 1,
        "size": "1024x1024"
      }
      """;

    HttpRequest request = HttpRequest.newBuilder()
      .uri(URI.create("https://api.pixapi.ai/v1/images/generations"))
      .header("Authorization", "Bearer " + System.getenv("PIXAPI_KEY"))
      .header("Content-Type", "application/json")
      .POST(HttpRequest.BodyPublishers.ofString(body))
      .build();

    HttpResponse<String> response = HttpClient.newHttpClient()
      .send(request, HttpResponse.BodyHandlers.ofString());

    System.out.println(response.body());
  }
}
php
<?php
$payload = json_encode([
  "model" => "gemini-3-pro-image-preview",
  "prompt" => "A cinematic product photo of a ceramic coffee cup",
  "n" => 1,
  "size" => "1024x1024",
]);

$ch = curl_init("https://api.pixapi.ai/v1/images/generations");
curl_setopt_array($ch, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . getenv("PIXAPI_KEY"),
    "Content-Type: application/json",
  ],
  CURLOPT_POSTFIELDS => $payload,
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;

Image generations

http
POST /v1/images/generations

Generate one or more images from a prompt using OpenAI-compatible request fields.

FieldTypeRequiredDescription
modelstringYesImage model id, such as gemini-3-pro-image-preview or gpt-image-2. Supported aliases such as nano-banana, nano-banana-2, and nano-banana-pro are accepted.
promptstringYesText prompt describing the desired image.
nnumberNoNumber of images to return. Defaults to 1 when omitted.
sizestringNoOutput size such as auto, 1024x1024, 1536x1024, 1024x1536, or another model-supported WIDTHxHEIGHT value.
qualitystringNoQuality tier when supported, such as low, medium, high, or auto.
response_formatstringNourl or b64_json when supported by the selected model.

Image edits

http
POST /v1/images/edits

Edit one or more input images using OpenAI-compatible multipart form fields.

FieldTypeRequiredDescription
modelstringYesEditing-capable image model id, such as gemini-3-pro-image-preview or gpt-image-2. Supported aliases such as nano-banana, nano-banana-2, and nano-banana-pro are accepted.
promptstringYesText instruction describing the edit.
imagefile or file[]YesInput image file. Send multiple image fields when the model supports multiple references.
nnumberNoNumber of images to return.
sizestringNoOutput size such as 1024x1024 or auto.
qualitystringNoQuality tier when supported.
response_formatstringNourl or b64_json when supported.
bash
curl https://api.pixapi.ai/v1/images/edits \
  -H "Authorization: Bearer $PIXAPI_KEY" \
  -F "model=gemini-3-pro-image-preview" \
  -F "prompt=Place the product on a warm studio background" \
  -F "image=@product.png" \
  -F "n=1" \
  -F "size=1024x1024"

Successful image responses follow the OpenAI image shape:

json
{
  "created": 1766880000,
  "data": [
    {
      "url": "https://cdn.pixapi.ai/generated/image.png"
    }
  ]
}

When response_format is b64_json, each item contains b64_json instead of url.

Async media submissions

http
POST /v1/async/images/generations
POST /v1/async/images/edits
POST /v1/async/videos/generations

Submit long-running media work as a background task. Async image endpoints accept the same request fields as the matching image generation and edit endpoints. Video generation is only available through the async video endpoint.

Video submissions use an OpenAI-style JSON payload:

FieldTypeRequiredDescription
modelstringYesVideo model id, such as veo or wan.
promptstringYesText prompt describing the scene and motion.
durationnumberNoRequested video duration in seconds.
sizestringNoOutput size or ratio preset such as 1280x720, 720x1280, or 16:9.
input_imagestringNoOptional input image URL for image-to-video.
json
{
  "status": "submitted",
  "id": "task_01KPQ7J7DWB7QZ3WCEK3YVPBRA",
  "progress": 0,
  "created_at": 1703884800,
  "model": "gemini-3.1-flash-image-preview"
}
FieldDescription
statussubmitted after Pixapi accepts the task.
idTask id used with GET /v1/tasks/{id}.
progressInteger progress value from 0 to 100.
created_atUnix timestamp for when the task was submitted.
modelModel id from the request.

Media tasks

http
GET /v1/tasks/{id}

Retrieve an asynchronous image or video task.

json
{
  "id": "xxx",
  "status": "completed",
  "credits_cost": 1.5,
  "model": "sora-2",
  "progress": 100,
  "result": {
    "type": "video",
    "data": [
      {
        "url": "https://xxx.xxx"
      }
    ]
  },
  "created": 1763088289,
  "completed": 1763088308
}
FieldDescription
idTask id returned by the async creation request.
statussubmitted, processing, completed, or failed.
credits_costCredits charged after task completion.
modelModel id used by the task.
progressInteger progress value from 0 to 100.
result.typeOutput media type, such as image or video.
result.dataGenerated media items. Each item includes a url when available.
createdUnix timestamp for when the task was created.
completedUnix timestamp for when the task completed.

Error format

json
{
  "error": {
    "code": 400,
    "message": "xxx",
    "type": "invalid_request_error"
  }
}

List models

http
GET /v1/models

Returns model ids and capabilities available for the current account.

Model list responses use canonical model ids. Alias ids such as nano-banana-2 can still be used in generation and edit requests when documented by a model page.

json
{
  "object": "list",
  "data": [
    {
      "id": "gemini-3-pro-image-preview",
      "object": "model",
      "category": "image",
      "capabilities": ["text-to-image", "image-to-image"]
    }
  ]
}