Mika Scraper / AIFreeboxImage
Function: AIFreeboxImage()
AIFreeboxImage(
prompt
,aspectRatio
,slug
):Promise
<string
>
Defined in: src/aifreebox/aifreebox.ts:31
Generates an image using the AI Freebox API based on the provided prompt, aspect ratio, and category. This function is crucial for developers looking to integrate AI-generated imagery into their applications.
Parameters
prompt
string
A descriptive text prompt that specifies the desired content of the generated image. This is a required parameter.
aspectRatio
SupportedAspectRatios
Default: '16:9'
This parameter determines the aspect ratio of the generated image. Acceptable values are defined in the SupportedAspectRatios
type alias.
slug
SupportedSlugs
Default: 'ai-art-generator'
This parameter specifies the category or model used for generating the image. Valid options are provided by the SupportedSlugs
type alias.
Returns
Promise
<string
>
A promise that resolves to the URL of the generated image. If the generation is successful, this URL can be used to display or access the image.
Throws
This function will throw an error under the following conditions:
- If the provided
aspectRatio
orslug
is invalid. - If there is a failure while communicating with the AI Freebox API.
Example
import { AIFreeboxImage } from 'mika-scraper';
async function generateImage() {
try {
const imageUrl = await AIFreeboxImage('A sunset over the mountains', '16:9', 'ai-art-generator');
console.log(imageUrl); // Outputs the URL of the generated image
} catch (error) {
console.error('Error generating image:', error);
}
}
generateImage();