const axios = require('axios');
async function aigptkeyboard(prompt, { model = 'gpt-4o-mini', max_tokens = 8000, ...options } = {}) {
try {
if (!prompt) throw new Error('Prompt is required.');
const { data } = await axios.post('https://us-central1-chatgpt-c1cfb.cloudfunctions.net/callTurbo', {
responseType: 'normal',
value: '',
osType: 'android',
model: model,
appName: 'AiKeyboard(Android)1.0',
max_tokens: parseInt(max_tokens),
search: prompt,
...options
}, {
headers: {
'content-type': 'application/json; charset=UTF-8',
'user-agent': 'okhttp/5.0.0-alpha.11'
}
});
const result = data?.choices?.[0]?.message?.content;
if (!result) throw new Error('No result found.');
return result;
} catch (error) {
throw new Error(error.message);
}
}
aigptkeyboard('hai! apa kabar?').then(console.log);