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
/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
Authorization: Bearer YOUR_API_KEYCreate and manage API keys in your dashboard. Never expose keys in client-side code or public repositories.
Endpoints
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
| Field | Type | Description |
|---|---|---|
| prompt | string | Required. Text description (1–2000 chars) |
| negative_prompt | string | Optional. What to avoid (max 1000 chars) |
| width | number | Optional. 256–1024, default 512 |
| height | number | Optional. 256–1024, default 512 |
| num_inference_steps | number | Optional. 1–50 |
| seed | number | Optional. For reproducible results |
| model | string | Optional. 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"
}Same request/response (including storage URLs and batch) as /api/v1/generate. Optimized for product images.
Same request/response (including storage URLs and batch) as /api/v1/generate. Optimized for logo creation.
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.
Returns all supported models with slug, name, and description. No auth required.
curl -X GET https://imageapi.org/api/v1/modelsReturns 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
}
}
}curl -X GET https://imageapi.org/api/v1/healthReturns 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.
| Slug | Name | Description |
|---|---|---|
| flux-schnell | FLUX.1 Schnell | 12B params, fast. Good default. |
| flux-2-klein-9b | FLUX.2 Klein 9B | Ultra-fast, high quality. |
| flux-2-klein-4b | FLUX.2 Klein 4B | Cost-effective, fast. |
| flux-2-dev | FLUX.2 Dev | High quality, multi-reference. |
| lucid-origin | Lucid Origin | Leonardo.AI – prompt-responsive. |
| phoenix-1 | Phoenix 1.0 | Leonardo.AI – text rendering. |
| stable-diffusion | Stable Diffusion XL | Stability AI – foundational. |
| sdxl-lightning | SDXL Lightning | ByteDance – fast 1024px. |
| dreamshaper-8-lcm | DreamShaper 8 LCM | Photorealism, 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
