Introduction
This document provides a simple JavaScript client for interacting with the LuminAI API. The client allows you to send requests with various parameters and receive results from the API.
Installation
First, make sure you have Node.js installed. Then, install the necessary dependencies:
npm install axios
Usage
Create a file named lumin.js
with the following content:
const axios = require('axios');
async function lumin(q, username = null, logic = null, webSearchMode = false) {
try {
const payload = { content: q };
if (username !== null) payload.user = username;
if (logic !== null) payload.prompt = logic;
payload.webSearchMode = webSearchMode;
const response = await axios.post("https://ilhamdev-luminai.hf.space/", payload);
return response.data.result;
} catch (error) {
console.error('Error fetching:', error);
throw error;
}
}
module.exports = { lumin };
Example Usage
Below are some examples of how to use the lumin
function.
Basic Usage
Send a query to the LuminAI API using GET:
const axios = require('axios');
function getLuminaiResponse(q) {
const url = `https://ilhamdev-luminai.hf.space/api/ai?content=${encodeURIComponent(q)}`;
return axios.get(url)
.then(response => response.data)
.catch(error => {
console.error(`Error fetching data from ${url}:`, error);
throw error;
});
}
// Example usage:
getLuminaiResponse('example query')
.then(data => {
console.log('Data:', data);
})
.catch(error => {
console.error('Error:', error);
});
Send a query to the LuminAI API:
const { lumin } = require('./lumin');
lumin("query")
.then(result => console.log(result))
.catch(error => console.error(error));
Usage with Query and Username
Send a query along with a username:
const { lumin } = require('./lumin');
lumin("query", "username")
.then(result => console.log(result))
.catch(error => console.error(error));
Usage with Query, Username, and Logic
Send a query with a username and additional logic:
const { lumin } = require('./lumin');
lumin("query", "username", "logic")
.then(result => console.log(result))
.catch(error => console.error(error));
Usage with Query, Username, Logic, and Web Search Mode
Send a query with a username, additional logic, and enable web search mode:
const { lumin } = require('./lumin');
lumin("query", "username", "logic", true)
.then(result => console.log(result))
.catch(error => console.error(error));
Closing
Thank you to everyone who has used LuminAI. We hope this API will continue to provide positive impacts to its users.
Special Thanks
This API leverages the Blackbox.ai platform. We extend our deepest gratitude to the Blackbox.ai team for their incredible work.
Rps
0
Total Requests
0