Image Generation

Generate images from a text prompt with Qubax's image generation endpoint. It mirrors the OpenAI Images API, so any client built for /v1/images/generations works unchanged when pointed at the Qubax base URL.

Endpoint

Text
POST https://api.qubax.ai/v1/images/generations

All requests require an API key passed as a Bearer token in the Authorization header:

Text
Authorization: Bearer qbx_live_...
Content-Type: application/json

Request Body

The request body is a JSON object with the parameters below.

ParameterTypeRequiredDescription
modelstringYesID of the model to use (e.g. flux-1.1-pro — see /v1/models for all image models).
promptstringYesA text description of the desired image. Max 4,000 chars.
nintegerNoNumber of images to generate. Default 1.
sizestringNoDimensions of the image, e.g. 1024x1024. Defaults vary by model.
response_formatstringNoAlways b64_json — images are returned inline as base64-encoded PNG. There is no URL mode.

Available Image Models

Qubax routes image generation through several state-of-the-art model families. The table below lists the most commonly used models (all available via /v1/models).

Model IDProvider / Notes
flux-1.1-proBlack Forest Labs Flux 1.1 — fast, high quality. Recommended default.
flux-2-maxBlack Forest Labs Flux 2 Max — highest fidelity.
nano-banana-2Google Nano Banana 2 — strong prompt adherence.
gpt-image-2OpenAI GPT Image 2 — integrated captions, edits.
seedream-4.5ByteDance Seedream V4.5 — photorealistic.
Note: Not every model supports every size or n value. When a combination is unsupported the API returns a 400 describing the constraint.

Python SDK Example

Using the OpenAI Python SDK pointed at the Qubax base URL:

Python
from openai import OpenAI

client = OpenAI(
    api_key="qbx_live_...",
    base_url="https://api.qubax.ai/v1",
)

response = client.images.generate(
    model="flux-1.1-pro",
    prompt="a cat in space, photorealistic",
    n=1,
    size="1024x1024",
)

# Images are returned inline as base64 — decode and save
import base64
from pathlib import Path
Path("cat.png").write_bytes(base64.b64decode(response.data[0].b64_json))
print("Wrote cat.png")

cURL Example

Shell
curl https://api.qubax.ai/v1/images/generations \
  -H "Authorization: Bearer qbx_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "flux-1.1-pro",
    "prompt": "a cat in space, photorealistic",
    "n": 1,
    "size": "1024x1024"
  }'

Response Format

A successful request returns a JSON object with a data array. Each entry contains a b64_json field holding the base64-encoded PNG image (there is no URL mode — images always come back inline).

JSON
{
  "created": 1719792000,
  "data": [
    {
      "b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."
    }
  ]
}

Saving the Image

Decode the base64 string and write the bytes to disk — in Python use base64.b64decode(response.data[0].b64_json), in shell pipe the JSON through jq -r '.data[0].b64_json' | base64 -d > image.png.

Ready to build?

400+ models through one OpenAI-compatible API, up to 99% below OpenRouter.

Get your API key →