Skip to main content
Use CometAPI image model docs by choosing the request format that matches your workflow. OpenAI-compatible image endpoints cover common generation and editing flows; provider-specific pages cover task-based image systems.

Choose an image API

Image Generations

Generate images with an OpenAI-compatible request.

Image Editing

Edit images with an OpenAI-compatible request.

Gemini image generation

Generate or edit images with Gemini format.

Midjourney quick start

Submit and poll Midjourney image tasks.

Flux Generate Image

Generate Flux images through CometAPI.

Bria Generate Image

Use Bria image generation tools.

Generate an image

Use an image-capable model ID from the Models page or the model directory. The examples below call the OpenAI-compatible Image Generations API.
These examples use the placeholder your-image-model-id. Replace it with an available image model ID from the Models page or model directory before you run the request.
Open Image Generations to use the playground and endpoint schema.
import os
import requests

response = requests.post(
    "https://api.cometapi.com/v1/images/generations",
    headers={
        "Authorization": "Bearer " + os.environ["COMETAPI_KEY"],
        "Content-Type": "application/json",
    },
    json={
        "model": "your-image-model-id",
        "prompt": "A clean product photo of a glass teapot on a white table",
        "size": "1024x1024",
    },
    timeout=120,
)

response.raise_for_status()
result = response.json()
print(result["data"][0].keys())

Response example

A successful response can look like this. Depending on the selected model, each item can contain a base64 image or a result URL:
{
  "created": 1779872000,
  "background": "opaque",
  "data": [
    {
      "b64_json": "iVBORw0KGgo..."
    }
  ],
  "output_format": "png",
  "quality": "low",
  "size": "1024x1024",
  "usage": {
    "input_tokens": 19,
    "input_tokens_details": {
      "image_tokens": 0,
      "text_tokens": 19
    },
    "output_tokens": 196,
    "output_tokens_details": {
      "image_tokens": 196,
      "text_tokens": 0
    },
    "total_tokens": 215
  }
}

Example model records

This example model catalog response shows the /api/models envelope and one image model record shape. It is not a complete model list.
cURL
curl https://api.cometapi.com/api/models
{
  "success": true,
  "page": 1,
  "page_size": 20,
  "total": 302,
  "data": [
    {
      "created": 1776391310,
      "id": "your-image-model-id",
      "code": "your-image-model-id",
      "provider": "ExampleProvider",
      "provider_code": "example",
      "name": "Example image model",
      "model_type": "image",
      "features": [
        "text-to-image"
      ],
      "endpoints": "{\n  \"openai-image\": {\n    \"path\": \"/v1/images/generations\",\n    \"method\": \"POST\"\n  }\n}",
      "pricing": {
        "currency": "USD / M Tokens",
        "input": 4,
        "output": 24,
        "per_request": null,
        "per_second": null
      }
    }
  ]
}

Common errors

Choose an image-capable model from the Models page.
Use a size that the selected image endpoint accepts.
Download generated assets before provider links expire.
Use image URLs or smaller files instead of large base64 payloads.
Check both b64_json and url fields because output shape can differ by model.

Error codes and retry strategy

Do not retry until the prompt, size, or image input is fixed.
Do not retry until the API key is present and valid.
Check the base URL, path, and model ID before retrying.
Reduce upload size before retrying.
Retry with exponential backoff and reduce concurrency.
Retry with backoff for transient provider or service errors.
For implementation patterns, see Error codes and retry strategy and Rate limits and concurrency.

Pricing and model directory

Models page

Read how CometAPI exposes model IDs in the docs.

Model directory

Browse model availability and capabilities.

Pricing

Check pricing before you call a model.
Last modified on May 28, 2026