
Image Generation API Reference
This page covers all steps to integrate image generation APIs with text-to-image and image-to-image into your system.
Get your API keys
Your API requests are authenticated using API keys. Any request that doesn't include an API key will return an error.
You can generate an API key from your user dashboard in Miragic website anytime.

Authentication
All requests must include the X-API-Key header containing your assigned API key.
How To Create Image Generation Task
POST /api/v1/image/generate
This API starts the Image Generation process by creating a task that generates a stunning art images.
Request
prompt
String
Yes
Input text to demonstrate output image.
model
String
Yes
AI model option for image generation. The values can be flux, turbo, gptimage, and kontext.
width
Number
Yes
The valid value range is 256-2048
height
Number
Yes
The valid value range is 256-2048.
image_url
String
Optional
This value represents the URL of the input image for image-to-image tasks. It is only available when the model is set to kontext.
Request Example (Text-To-Image)
Request Example (Image-To-Image)
Response
Response Field
jobId
String
A unique identifier used to track task status and retrieve results.
status
String
The initial status will be PENDING. Use the Get Task Status API to track progress.
message
String
To describe task status
success
Logic
true or false to indicate whether task is successful or not.
How To Get Task Status
GET /api/v1/image/jobs/:jobId
This API lets you check the status of a image generation task and retrieve the final result. Because the image generation process runs asynchronously, you’ll need to poll this endpoint until the task is finished.
Task Status:
PENDING
Task is currently being processed.
0~99%
Continue polling
COMPLETED
Task has finished successfully.
100%
Download result using download_signed_url
FAILED
Task processing failed.
N/A
Check error details and retry if needed
Request:
URL Parameters
JobId
String
Yes
This value indicates task ID assigned by requesting Image Generation process API
Request Example
Response Example
Completed Status (200):
Response Fields
id
String
Unique identifier of the task
status
String
Current status of the task (PENDING/COMPLETED/FAILED)
userId
String
Unique identifier of the user
processedImageUrl
String
URL to result image
createdAt
Number
Unix timestamp when processing is created
errorMessage
String
Error message
Full Code Example
The following code lines are quick example to use our API in multiple languages.
Case 1: Text-To-Image
Case 2: Image-To-Image
Last updated