Example: Image Generation
This example shows you how to use Ikalas’ image generation API.
Using the Image Generation API
Here’s how to use the image generation API:
Code example for generating an image
const axios = require("axios");
// Request configuration for image generation
let data = JSON.stringify({
prompt: "Napoleon looking at the Battle of Austerlitz",
});
let config = {
method: "post",
maxBodyLength: Infinity,
url: "https://ikalas.com/api/v1/ai-image-generator",
headers: {
accept: "application/json",
apikey: "YOUR_API_KEY_HERE", // Replace with your actual API key
"content-type": "application/json",
},
data: data,
};
// Execute the request
axios
.request(config)
.then((response) => {
console.log("Image generated successfully!");
console.log("Image URL:", response.data.result[0].outputFileUrl);
console.log("Image ID:", response.data.result[0].outputFileId);
console.log("Remaining credits:", response.data.creditsUser);
})
.catch((error) => {
console.log(
"Error during generation:",
error.response?.data || error.message
);
});
Image Generation API Parameters
Parameter | Type | Description | Required |
---|---|---|---|
prompt | string | Description of the image to generate | âś… |
Response Structure
The API response contains the following information:
{
"success": true,
"id": "nod-cea660a2fe",
"date": "2025-08-08T19:15:06+00:00",
"typeOutput": "file",
"result": [
{
"outputFileId": "8c7cc75e-801e-431a-b3a7-e627ee88d186",
"outputFileName": "b7362c090d.png",
"outputFileExtension": "png",
"outputFileHasPreview": true,
"outputFileIsImage": true,
"outputFileUrl": "https://storage.googleapis.com/ikalas-public/8cbe1269-2072-4111-8a10-1e00ac511c64.png"
}
],
"creditsUser": 9676,
"uuidLogFunction": "911bff33-a48d-40fa-ae77-e818f449d664",
"ika_conversationId": "180a54ff-cea0-4734-9d86-7406af59075c"
}
Important fields:
result[0].outputFileUrl
: Direct URL to the generated imageresult[0].outputFileId
: Unique identifier of the imagecreditsUser
: Number of credits remaining on your account
Example of generated image
Here’s an example of an image generated with the prompt “Napoleon looking at the Battle of Austerlitz”:
Image generated by Ikalas’ image generation API
Last updated on