const axios = require('axios'); const { v4: uuidv4 } = require('uuid'); async function aichat(question, { model = 'gpt-5-nano' } = {}) { try { const _model = { 'gpt-4o-mini': '25865', 'gpt-5-nano': '25871', 'gemini': '25874', 'deepseek': '25873', 'claude': '25875', 'grok': '25872', 'meta-ai': '25870', 'qwen': '25869' }; if (!question) throw new Error('Question is required.'); if (!_model[model]) throw new Error(`Available models: ${Object.keys(_model).join(', ')}.`); const { data: html } = await axios.post(`https://px.nekolabs.my.id/${encodeURIComponent('https://chatgptfree.ai/')}`); const nonce = html.data.content.match(/"nonce"\s*:\s*"([^&]+)"/); if (!nonce) throw new Error('Nonce not found.'); const { data } = await axios.post(`https://px.nekolabs.my.id/${encodeURIComponent('https://chatgptfree.ai/wp-admin/admin-ajax.php')}`, new URLSearchParams({ action: 'aipkit_frontend_chat_message', _ajax_nonce: nonce[1], bot_id: _model[model], session_id: uuidv4(), conversation_uuid: uuidv4(), post_id: '6', message: question }).toString(), { headers: { origin: 'https://chatgptfree.ai', referer: 'https://chatgptfree.ai/', 'user-agent': 'Mozilla/5.0 (Linux; Android 15; SM-F958 Build/AP3A.240905.015) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.86 Mobile Safari/537.36' } }); return data.data.content.data.reply; } catch (error) { throw new Error(error.message); } }; // Usage: const resp = await aichat('hai! model ai apa yang kamu gunakan?', { model: 'claude' }): console.log(resp);