API Reference

1. generateImage(prompt, model = 'v3', negativePrompt = '')

  • Description: Generates an image based on the provided prompt.

  • Parameters:

    • prompt (string): The text prompt that describes the desired image.

    • model (string, optional): The AI model to use for generation (default is 'v3').

    • negativePrompt (string, optional): Descriptions of what to avoid in the generated image (e.g., unwanted objects or styles).

  • Returns: A URL string pointing to the generated image.

  • Example:

    const imageUrl = await api.generateImage('A futuristic city skyline', 'v3');
    console.log('Generated Image URL:', imageUrl);

2. askQuestion(content, model = 'v3')

  • Description: Submits a question or chat content to receive an AI-generated response.

  • Parameters:

    • content (string): The question or content to send to the AI.

    • model (string, optional): The AI model to use for generating the response (default is 'v3').

  • Returns: The AI-generated response (usually an object containing the answer).

  • Example:

    const response = await api.askQuestion('What is the capital of France?', 'v3');
    console.log('Question Response:', response);

3. checkContent(content)

  • Description: Checks the provided content against a moderation filter to determine its appropriateness.

  • Parameters:

    • content (string): The text content to be checked for moderation.

  • Returns: An object containing the moderation result, which typically includes flags for inappropriate content and categories of concern.

  • Example:

    const moderationResponse = await api.checkContent('Some potentially inappropriate content');
    console.log('Moderation Response:', moderationResponse);

Error Handling

All methods may throw an error if the request fails. Be sure to implement error handling in your code:

try {
    const imageUrl = await api.generateImage('A beautiful landscape');
} catch (error) {
    console.error('Error:', error.message);
}

The Free AI package provides powerful tools for image generation, question answering, and content moderation, all easily accessible through its well-defined API. Users can customize their interactions based on their specific needs, ensuring flexibility and utility across various applications.

Last updated