Get startedAPI referenceGoing to productionExplore models

API reference

Image Generation

Generate images from a text prompt or edit an existing image through the PicoX API. Both endpoints return a complete JSON response.

Choose an image model

Use your API key to call GET /v1/models and select a model whose supported_endpoints includes images. Replace YOUR_IMAGE_MODEL_ID in the examples with its public ID.

Model support

Generation, editing, image sizes, quality levels, and output formats depend on the selected model. Image input support in a chat model does not imply image generation support.

Generate an image

POST/v1/images/generations

Authenticate with Authorization: Bearer YOUR_API_KEY. Use application/json for text-to-image requests.

modelstring · required

Public model ID from /v1/models.

promptstring · required

A description of the image to create, including its subject, style, and composition.

ninteger · optional

Number of images to generate. Supported counts and the default depend on the model.

sizestring · optional

Requested image dimensions, such as 1024x1024. Use a size supported by the model.

qualitystring · optional

Image quality setting. Accepted values depend on the model; omit it to use the model default.

response_formatstring · optional

Use url or b64_json only if the model supports that format. Some models always return Base64 image data.

Additional model-specific fields are forwarded subject to channel parameter rules. These endpoints are synchronous; stream is removed and no SSE events are returned.

Image generation request
curl "https://picox.ai/v1/images/generations" \
  -H "Authorization: Bearer $PICO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_IMAGE_MODEL_ID",
    "prompt": "A small glass greenhouse in a quiet garden, soft morning light",
    "n": 1
  }'

Read the image response

A typical successful response contains created and a data array. Each image contains a url or b64_json, depending on the model and requested format. A revised_prompt or usage object may also be present.

Example Base64 response
{
  "created": 1792972800,
  "data": [
    {"b64_json": "BASE64_ENCODED_IMAGE_DATA"}
  ]
}

Decode b64_json to bytes and save it in the returned image format. When the response contains a URL, download the image promptly because the URL may expire.

Edit an image

POST/v1/images/edits

For a model that supports editing, send model, prompt, and an image file as multipart/form-data. An optional mask selects the area to edit when supported. File formats, mask rules, and multiple-image support depend on the model.

Image editing request
curl "https://picox.ai/v1/images/edits" \
  -H "Authorization: Bearer $PICO_API_KEY" \
  -F "model=YOUR_IMAGE_MODEL_ID" \
  -F "prompt=Change the background to a sunny garden" \
  -F "[email protected]" \
  -F "n=1"

Let your HTTP client set the multipart Content-Type and boundary. Each request allows at most 16 files and 64 text fields, within the platform request body limit. JSON editing requests are also accepted when supported by the model.

Billing and errors

Generated and edited images are charged at the applicable image output rate per returned image, or per request for request-priced models. Check the model pricing before requesting multiple images; request logs show the final charge.

Errors use the standard PicoX error object. Check error.param for an invalid parameter, verify that the model is available to your API key, and confirm that it supports the requested image operation.

Errors · Usage & billing · Image inputs

Copied