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
constFreeAI=require('@milcondev/free-ai');constapi=newFreeAI('YOUR_API_KEY'); // Replace with your API keyasyncfunctiongenerateImage() {try {constimageUrl=awaitapi.generateImage('A beautiful sunset','v3');console.log('Generated Image URL:', imageUrl); } catch (error) {console.error('Error:',error.message); }}generateImage();
Example: Asking a Question
asyncfunctionaskQuestion() {try {constresponse=awaitapi.askQuestion('What is the capital of France?','v3');console.log('Question Response:', response); } catch (error) {console.error('Error:',error.message); }}askQuestion();
Example: check content
asyncfunctioncheckContent() {try {constcontentResponse=awaitapi.checkContent('Your content to check','v3'); // You can change the model hereconsole.log('Moderation Filter Response:', contentResponse); } catch (error) {console.error('Error:',error.message); }}