Image AI API - Image Generation
The Image AI API allows you to generate high-quality images from text descriptions using state-of-the-art AI models.
This documentation covers the generate-image endpoint,
which is the core functionality of our service.
Quick Start
Generate your first image with this simple cURL request:
curl -X POST https://imageaiapi.com/api/generate-image \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_KEY" \ -d '{ "prompt": "A serene mountain lake at sunset", "style": "photorealistic", "width": 1024, "height": 1024 }'
Authentication
All API requests require authentication using an API key. You can obtain your API key by signing up for an account on the Image AI API website.
Include your API key in all requests by adding an Authorization
header with the value Bearer YOUR_API_KEY.
Keep your API key secret! Do not share it in public repositories or client-side code.
# Example of proper authentication curl -X POST https://imageaiapi.com/api/generate-image \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_KEY" \ -d '{ "prompt": "A serene mountain lake at sunset" }'
Rate Limits
Rate limits vary based on your subscription plan. The headers in the API response include information about your current rate limit status.
| Plan | Images per Month | Requests per Minute |
|---|---|---|
| Starter | 500 | 10 |
| Professional | 2,000 | 30 |
| Enterprise | 5,000+ | 100 |
When you exceed your rate limit, the API will return a 429 Too Many Requests status code.
Generate Image Endpoint
https://imageaiapi.com/api/generate-image
The generate-image endpoint creates an image based on your text prompt and additional parameters.
Headers
| Header | Value | Description |
|---|---|---|
| Content-Type | application/json | Specifies the format of the request body |
| Authorization | Bearer YOUR_API_KEY | Your API key for authentication |
Request Body
The request body should be a JSON object with the following parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| prompt | string | Yes | Text description of the image you want to generate. Max 1000 characters. |
| style | string | No | The artistic style to apply. Options: photorealistic, painting, cartoon, sketch, abstract. Default: photorealistic |
| width | integer | No | Width of the generated image in pixels. Valid options: 512, 768, 1024, 1536, 1920. Default: 1024 |
| height | integer | No | Height of the generated image in pixels. Valid options: 512, 768, 1024, 1536, 1920. Default: 1024 |
| seed | integer | No | Random seed for reproducible generations. Range: 0-2147483647 |
| guidance_scale | float | No | Controls how closely the image follows the prompt. Range: 1.0-20.0. Default: 7.5 |
| negative_prompt | string | No | Text description of elements to exclude from the generated image |
Example Request Body
{
"prompt": "A serene mountain lake at sunset, with pink and orange clouds reflected in the still water, surrounded by pine trees and snow-capped peaks",
"style": "photorealistic",
"width": 1024,
"height": 1024,
"seed": 42,
"guidance_scale": 7.5,
"negative_prompt": "blurry, distorted, low quality"
}
Response Object
A successful API call returns a JSON object with information about the generated image:
| Field | Type | Description |
|---|---|---|
| id | string | Unique identifier for the generated image |
| url | string | URL to access the generated image |
| width | integer | Width of the generated image in pixels |
| height | integer | Height of the generated image in pixels |
| created_at | string (ISO 8601) | Timestamp when the image was generated |
| prompt | string | The original prompt used to generate the image |
| seed | integer | The seed used for generation (useful for reproducibility) |
Example Response
{
"id": "img_7a9b2c3d",
"url": "https://cdn.imageaiapi.com/img_7a9b2c3d.png",
"width": 1024,
"height": 1024,
"created_at": "2025-04-21T15:23:48Z",
"prompt": "A serene mountain lake at sunset",
"seed": 42
}
Error Handling
The API uses standard HTTP status codes to indicate the success or failure of a request. In case of an error, the response will include a JSON object with more details.
| Status Code | Description |
|---|---|
| 200 OK | The request was successful |
| 400 Bad Request | The request could not be understood or was missing required parameters |
| 401 Unauthorized | Authentication failed, invalid API key |
| 403 Forbidden | The API key doesn't have permission to perform the request or contains prohibited content |
| 429 Too Many Requests | Rate limit exceeded |
| 500 Internal Server Error | An error occurred on the server |
Example Error Response
{
"error": {
"message": "Invalid parameter: width must be one of 512, 768, 1024, 1536, or 1920",
"type": "invalid_parameter",
"param": "width",
"code": "parameter_invalid"
}
}
Frequently Asked Questions
Find answers to common questions about using the Image AI API:
Image generation typically takes between 2-6 seconds, depending on the complexity of the prompt, image size, and current API load. For time-sensitive applications, we recommend using the asynchronous API with webhooks to receive notifications when images are ready.
Generated images are stored for 30 days by default. If you need longer storage, we recommend downloading and storing the images in your own storage system. Enterprise plans include options for extended storage periods.
Yes, Professional and Enterprise plans can use the n parameter to generate
multiple variations of an image in a single API call. You can request up to 10 images per call,
and each image counts toward your monthly usage.
{
"prompt": "A serene mountain lake at sunset",
"style": "photorealistic",
"n": 4, // Generate 4 variations
"width": 1024,
"height": 1024
}
You own all rights to the images generated through your Image AI API account. You're free to use them commercially, modify them, and incorporate them into your products and services in accordance with our Terms of Service. We don't claim any ownership of your generated content.
Yes, use the seed parameter to control the randomness of the generation
process. When you provide the same prompt and seed value, you'll get the same image. The API response
includes the seed value used for each generation, so you can save it for future reference.
Support
We're here to help you make the most of the Image AI API. If you have any questions or need assistance, here's how to reach us:
Enterprise Support
Enterprise customers receive dedicated support with priority response times:
enzolanne@gmail.comSupport Hours
Our support team is available Monday through Friday, 9:00 AM to 6:00 PM UTC.
Enterprise customers have access to extended support hours based on their service level agreement.
Ready to Get Started?
Now that you're familiar with the Image AI API, it's time to create your first image.