@milcondev/free-ai
v3.0.0
Published
This will allow users of your npm package to generate images or ask questions through the `FreeAI` class, keeping both functionalities in one package.
Downloads
178
Maintainers
Readme
The Free AI is an npm package designed to help developers interact with the powerful AI-based image generation and question-answering functionalities provided by free-ai.xyz. This API is perfect for creating dynamic AI-driven content for websites, apps, or bots.
Get Started
To get started, install the package and obtain your API key from the dashboard.
Get your API Key
- Visit free-ai.xyz/dashboard to create an account or log in.
- Once logged in, click the generate API Key button to generate your API key.
- Use the provided API key in your application.
Installation
npm install @milcondev/free-ai
Features
- AI Image Generation: Create stunning AI-generated images with custom prompts.
- AI Question & Chat Handling: Submit questions or chat content and receive AI-generated responses.
- Moderation Filter: Check content for appropriateness using the moderation filter API.
- Changeable AI Models: Users can specify which AI model to use based on their needs.
- Easy Integration: Simple, lightweight, and well-documented API.
Usage
const FreeAI = require('@milcondev/free-ai');
const api = new FreeAI('YOUR_API_KEY'); // Get your API key from the dashboard
// Generate an image with a specified model
async function generateImage() {
try {
const imageUrl = await api.generateImage('Your Image Prompt', 'v3'); // You can change the model here
console.log('Generated Image URL:', imageUrl);
} catch (error) {
console.error('Error:', error.message);
}
}
// Ask a question with a specified model
async function askQuestion() {
try {
const response = await api.askQuestion('Your question or chat content', 'v3'); // You can change the model here
console.log('Question Response:', response);
} catch (error) {
console.error('Error:', error.message);
}
}
// Check content with the moderation filter
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);
}
}
generateImage();
askQuestion();
checkContent();
API Reference
generateImage(prompt, model = 'v3', negativePrompt = '')
- Description: Generates an AI-generated image based on the provided prompt and model.
- Parameters:
prompt
(string): The text prompt for image generation.model
(string, optional): The model to use for generation (default is'v3'
).negativePrompt
(string, optional): A prompt to specify what should be avoided in the image.
askQuestion(content, model = 'v3')
- Description: Submits a question or chat content and receives a response from the AI.
- Parameters:
content
(string): The question or chat content.model
(string, optional): The model to use for generating the response (default is'v3'
).
checkContent(content, model = 'v3')
- Description: Checks the provided content for appropriateness using the moderation filter.
- Parameters:
content
(string): The content to be checked.model
(string, optional): The model to use for the moderation check (default is'v3'
).
License
This project is licensed under the MIT License - see the LICENSE file for details.