Basic Usage

Now that you have installed the package and obtained your API key, you can start using Free AI in your project.

Example: Generating an Image

const FreeAI = require('@milcondev/free-ai');
const api = new FreeAI('YOUR_API_KEY'); // Replace with your API key

async function generateImage() {
    try {
        const imageUrl = await api.generateImage('A beautiful sunset', 'v3');
        console.log('Generated Image URL:', imageUrl);
    } catch (error) {
        console.error('Error:', error.message);
    }
}

generateImage();

Example: Asking a Question

async function askQuestion() {
    try {
        const response = await api.askQuestion('What is the capital of France?', 'v3');
        console.log('Question Response:', response);
    } catch (error) {
        console.error('Error:', error.message);
    }
}

askQuestion();

Example: check content

async function checkContent() {
    try {
        const contentResponse = await api.checkContent('Your content to check', 'v3'); // You can change the model here
        console.log('Moderation Filter Response:', contentResponse);
    } catch (error) {
        console.error('Error:', error.message);
    }
}

Last updated