Back to home

API Documentation

Integrate AI image generation into your product with the ImageAPI REST API. Use it from plain HTML, WordPress, mobile apps, or your own backend — same request format everywhere.

Quick start

Base URL

https://imageapi.org

Auth header

Authorization: Bearer YOUR_API_KEY

Generate an image with a single POST request. Replace YOUR_API_KEY with your key from Dashboard → API Keys.

curl -X POST https://imageapi.org/api/v1/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "a sunset over mountains", "width": 512, "height": 512 }'

Base URL for this deployment: https://imageapi.org. The HTML tab uses a full URL so it works when embedded on any domain. The API responds with CORS headers so browsers allow Authorization: Bearer from third-party pages. If you lock down origins, set CORS_PUBLIC_API_STRICT_ORIGINS=true on the server (default is open for public API routes). See WordPress & custom sites below.

WordPress, HTML, and your own tools

Use this API from anywhere you build
Same REST endpoint for WordPress plugins, theme snippets, static sites, or internal dashboards. Pick server-side (safest for keys) or browser (CORS enabled for /api/v1/ by default).

Recommended: call the API from your server (PHP, Node, etc.)

The API key stays on your server and never appears in the visitor's browser. WordPresswp_remote_post, a small PHP proxy, or your backend app can POST JSON to https://imageapi.org/api/v1/generate. No CORS is involved (CORS only applies to browser JavaScript).

WordPress (PHP — recommended)

Add your key in wp-config.php (or a secrets plugin), then call the API from a plugin or theme:

<?php
// define('IMAGEAPI_KEY', 'sk_...'); // in wp-config.php

$response = wp_remote_post('https://imageapi.org/api/v1/generate', array(
  'timeout' => 120,
  'headers' => array(
    'Authorization' => 'Bearer ' . IMAGEAPI_KEY,
    'Content-Type'  => 'application/json',
  ),
  'body' => wp_json_encode(array(
    'prompt' => 'cinematic mountain landscape at sunrise',
    'width'  => 512,
    'height' => 512,
  )),
));

if (is_wp_error($response)) {
  echo esc_html($response->get_error_message());
} else {
  $code = wp_remote_retrieve_response_code($response);
  $body = json_decode(wp_remote_retrieve_body($response), true);
  // Use $body['data']['image'] (URL or data URL) in your shortcode or template
}

Browser JavaScript (any site, including WordPress)

Use the full URL https://imageapi.org/api/v1/generate in fetch(). The API sends CORS headers so the browser allows the request from your domain. Only put the API key in frontend code if you accept the risk (key is visible to visitors); prefer a server-side shortcode or REST route that calls PHP above.

const res = await fetch("https://imageapi.org/api/v1/generate", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    prompt: "a sunset over mountains",
    width: 512,
    height: 512,
  }),
});
const data = await res.json();

Authentication

Bearer token
All API requests require your API key in the Authorization header
Authorization: Bearer YOUR_API_KEY

Create and manage API keys in your dashboard. Never expose keys in client-side code or public repositories.

Endpoints

POST /api/v1/generate
Generate an image from a text prompt

Object storage & URLs

If your plan includes storage and you enable it in Admin settings, the API returns a hosted image URL instead of base64. Stored images are visible in Dashboard → Gallery.

Users can also toggle storage on/off in Dashboard → Settings → Preferences.

Request body

FieldTypeDescription
promptstringRequired. Text description (1–2000 chars)
negative_promptstringOptional. What to avoid (max 1000 chars)
widthnumberOptional. 256–1024, default 512
heightnumberOptional. 256–1024, default 512
num_inference_stepsnumberOptional. 1–50
seednumberOptional. For reproducible results
modelstringOptional. Model slug: flux-schnell, flux-2-klein-9b, stable-diffusion, etc. See Models section.

Batch requests

You can generate multiple images in one request by sending items. Limits (batch size/concurrency) are enforced by your workspace configuration.

curl -X POST https://imageapi.org/api/v1/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "items": [
      { "prompt": "a futuristic city at night", "width": 512, "height": 512 },
      { "prompt": "a portrait photo, studio lighting", "width": 512, "height": 512 }
    ]
  }'

Example

curl -X POST https://imageapi.org/api/v1/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "a sunset over mountains",
    "negative_prompt": "blurry, low quality",
    "width": 512,
    "height": 512
  }'

Response (200)

{
  "success": true,
  "data": {
    "image": "https://... (or data:image/png;base64,...)",
    "seed": 12345,
    "model": "flux-schnell",
    "storage": {
      "enabled": true,
      "stored": true,
      "plan": "10 GB cloud storage"
    }
  },
  "request_id": "req_xxx"
}

If storage is disabled for your user/plan, image returns a data URL (data:image/png;base64,...) instead of a hosted link.

Batch response (200)

{
  "success": true,
  "data": {
    "results": [
      {
        "success": true,
        "image": "https://...",
        "seed": 12345,
        "model": "flux-schnell",
        "storage": { "enabled": true, "stored": true, "plan": "10 GB cloud storage" }
      },
      {
        "success": false,
        "error": "Rate limit exceeded"
      }
    ]
  },
  "request_id": "req_xxx"
}
POST /api/v1/generate/product
Product photography style generation

Same request/response (including storage URLs and batch) as /api/v1/generate. Optimized for product images.

POST /api/v1/generate/logo
Logo design style generation

Same request/response (including storage URLs and batch) as /api/v1/generate. Optimized for logo creation.

Prompt helpers (AI text model)
Same auth as generate: Authorization: Bearer. Uses the text model configured in Admin → AI Tools.

POST /api/v1/prompt/enhance

Expand a short idea into a richer image prompt.

curl -X POST https://imageapi.org/api/v1/prompt/enhance \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt":"robot reading a book","tone":"anime, cozy"}'

Body: prompt (required), tone (optional). Response: { "success": true, "data": { "prompt": "..." } }

POST /api/v1/prompt/build

Build one prompt from structured fields (all optional; send at least one).

curl -X POST https://imageapi.org/api/v1/prompt/build \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"subject":"fox in a scarf","setting":"snowy forest","mood":"cozy","art_style":"watercolor"}'

Fields: subject, setting, mood, art_style, lighting, camera, extras.

GET /api/v1/models
List available image generation models

Returns all supported models with slug, name, and description. No auth required.

curl -X GET https://imageapi.org/api/v1/models
GET /api/v1/usage
Check usage and quota

Returns current usage (today, this month) and plan limits. Requires authentication.

curl -X GET https://imageapi.org/api/v1/usage \
  -H "Authorization: Bearer YOUR_API_KEY"

Response (200)

{
  "success": true,
  "data": {
    "usage": {
      "today": { "requestCount": 10, "imageCount": 10 },
      "this_month": { "requestCount": 150, "imageCount": 150 }
    },
    "plan": {
      "name": "Free",
      "slug": "free",
      "requests_per_month": 1500,
      "requests_per_day": 50,
      "remaining_today": 40,
      "remaining_month": 1350
    }
  }
}
GET /api/v1/health
Health check (no auth required)
curl -X GET https://imageapi.org/api/v1/health

Returns status: "healthy" or "degraded" with component checks.

Error responses

401 Unauthorized

Missing or invalid API key

403 Forbidden

Account suspended or no plan

429 Too Many Requests

Rate limit or quota exceeded. Response includes retry_after seconds.

500 Internal Server Error

Image generation failed. Use request_id for support.

All errors include a request_id for debugging. Check your API logs for details.

Models

Pass the model field in your request to select a model. Default is flux-schnell.

SlugNameDescription
flux-schnellFLUX.1 Schnell12B params, fast. Good default.
flux-2-klein-9bFLUX.2 Klein 9BUltra-fast, high quality.
flux-2-klein-4bFLUX.2 Klein 4BCost-effective, fast.
flux-2-devFLUX.2 DevHigh quality, multi-reference.
lucid-originLucid OriginLeonardo.AI – prompt-responsive.
phoenix-1Phoenix 1.0Leonardo.AI – text rendering.
stable-diffusionStable Diffusion XLStability AI – foundational.
sdxl-lightningSDXL LightningByteDance – fast 1024px.
dreamshaper-8-lcmDreamShaper 8 LCMPhotorealism, wide range.

Model availability may vary by plan and workspace configuration.

Rate limits

• Per-minute, daily, monthly, and concurrency limits are enforced server-side

• Daily and monthly quotas depend on your active subscription plan

• 429 responses include a Retry-After header