Skip to content

Media & data

Image generation

Generate images from text prompts or transform existing images. Requests are synchronous: the response contains the generated images.

Endpoint

POSThttps://api.ppq.ai/v1/images/generations

Edits endpoint

POSThttps://api.ppq.ai/v1/images/edits

For clients that follow the OpenAI Images API. See OpenAI clients.

Parameters

Parameter support varies by model. The image models reference lists the parameters each model accepts, which of them it requires, and its allowed quality and resolution values.

ParameterTypeRequiredDescription
model
string
Yes
The model to use. See Available models.
prompt
string
No
Text description of the image you want. Required for generation models; not used by upscalers and background-removal models.
image_url
string
No
Source image URL. Required for upscalers, background removal and image-to-image models; optional on many generation models for edits or variations.
n
integer
No
Number of images, 1–4. Default: 1. Also accepted as num_images.
quality
string
No
Quality tier. Allowed values differ per model, for example low, medium, high.
size
string
No
Aspect ratio, for example "1:1", "16:9" or "9:16". Also accepted as aspect_ratio.
resolution
string
No
Output resolution, on models that support it. Allowed values differ per model, for example 1K, 2K, 4K.
negative_prompt
string
No
What to keep out of the image.
output_format
string
No
Output file format. One of "png", "jpeg", "webp".
response_format
string
No
"url" returns a signed data[].url; "b64_json" returns each image inline as data[].b64_json. Default: "url".

OpenAI clients

Clients that follow the OpenAI Images API, such as OpenWebUI, LibreChat and the OpenAI SDKs, work with PPQ without a proxy in between. If you call PPQ from your own code, use /v1/images/generations.

  • Edits endpoint. These clients expect a separate /v1/images/edits endpoint. It accepts multipart/form-data with an image file, prompt and model. The image[] field name some clients send also works; a single image is used. Like OpenAI's edit endpoint, it returns base64 (data[].b64_json) by default unless you set response_format. Pricing is the same as /v1/images/generations.
  • Extra parameters are ignored, not rejected. Some clients always send OpenAI-specific fields such as background or moderation. If a model doesn't support a parameter you send, PPQ drops it and still generates the image. Parameters a model does support are always applied.
  • Base64 responses. response_format: "b64_json" returns images inline as data[].b64_json, the format LibreChat and the OpenAI SDKs expect.

Available models

The examples on this page use nano-banana-2-1. Browse all image models with their parameters and code examples.

Code examples

import requests

api_key = "YOUR_API_KEY"
url = "https://api.ppq.ai/v1/images/generations"

headers = {
    "Content-Type": "application/json",
    "Authorization": f"Bearer {api_key}"
}

data = {
    "model": "nano-banana-2-1",
    "prompt": "A futuristic cityscape at sunset",
    "resolution": "1K",
    "n": 1
}

response = requests.post(url, json=data, headers=headers)
result = response.json()

for image in result["data"]:
    print(image["url"])  # signed URL served by PPQ (valid 24h)

Response

{
  "created": 1709234567,
  "model": "nano-banana-2-1",
  "cost": 0.046,
  "data": [
    {
      "url": "https://api.ppq.ai/v1/media/gen_abc123/0?sig=...&exp=...",
      "content_type": "image/png"
    }
  ]
}

data[].url is a signed URL served by PPQ and is valid for 24 hours. Download the file before it expires if you need to keep it.