Authentication
To use the ImagiNext API, you need an API key. You can generate and manage your API key from your Profile Page.
Authenticate your API requests by including your API key in the Authorization header using the Bearer token scheme.
Authorization: Bearer YOUR_API_KEYNote for Prototype
Currently, the /api/generate endpoint is unauthenticated for demonstration purposes. However, this is how authentication would work in a production environment.
Endpoints
/api/generateRequest Body:
application/json
prompt(string, required): The text description of the image you want to generate.
{
"prompt": "A majestic lion in a snowy forest, hyperrealistic"
}Headers:
Content-Type: application/json
Authorization: Bearer YOUR_API_KEYSuccess Response (200 OK):
{
"imageDataUri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
}Returns an object containing the imageDataUri of the generated image. This is a Base64 encoded string with a MIME type.
Error Responses:
400 Bad RequestInvalid request payload (e.g., missing prompt, invalid JSON).
401 Unauthorized(Future implementation) API key is missing, invalid, or inactive.
402 Payment Required / 429 Too Many Requests(Future implementation) User has insufficient tokens or has exceeded rate limits.
500 Internal Server ErrorAn error occurred on the server during image generation.
Example Usage (cURL)
Here's how you can call the API using cURL:
curl -X POST \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A futuristic cityscape at night, neon lights, cyberpunk style"
}' \
/api/generateRate Limiting & Token Usage
API usage is subject to your account's subscription plan and token balance. Each API call to generate an image will consume tokens similar to generating images through the web interface.
Note for Prototype
Token deduction and rate limiting are not enforced on the /api/generate endpoint in the current prototype version.
If you have any questions or need further assistance, please contact us.