| const axios = require('axios'); | |
| let currentAccount = null; | |
| let requestCount = 0; | |
| async function hackai(query) { | |
| if (!currentAccount || requestCount >= 5) { | |
| const tempMailResponse = await axios.post('https://api.internal.temp-mail.io/api/v3/email/new', { | |
| min_name_length: 10, | |
| max_name_length: 10 | |
| }, { | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| 'Application-Name': 'web', | |
| 'Application-Version': '4.0.0', | |
| 'X-CORS-Header': 'iaWg3pchvFx48fY' | |
| } | |
| }); | |
| const { email, token } = tempMailResponse.data; | |
| await axios.post('https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key=AIzaSyAaSg74fiq2FKPvfqo9QT55c5DmCmETKVY', { | |
| requestType: 'EMAIL_SIGNIN', | |
| email: email, | |
| clientType: 'CLIENT_TYPE_WEB', | |
| continueUrl: 'https://chat.hackaigc.com', | |
| canHandleCodeInApp: true | |
| }, { | |
| headers: { | |
| 'X-Client-Version': 'Chrome/JsCore/10.12.1/FirebaseCore-web', | |
| 'X-Firebase-gmpid': '1:1096968884444:web:346299d4d159d5f9d8e419', | |
| 'Content-Type': 'application/json' | |
| } | |
| }); | |
| await new Promise(resolve => setTimeout(resolve, 5000)); | |
| const messagesResponse = await axios.get(`https://api.internal.temp-mail.io/api/v3/email/${email}/messages`, { | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| 'Application-Name': 'web', | |
| 'Application-Version': '4.0.0', | |
| 'X-CORS-Header': 'iaWg3pchvFx48fY' | |
| } | |
| }); | |
| const message = messagesResponse.data[0]; | |
| const urlMatch = message.body_html.match(/href='([^']+)'/); | |
| const verifyUrl = urlMatch[1].replace(/&/g, '&'); | |
| const oobCodeMatch = verifyUrl.match(/oobCode=([^&]+)/); | |
| const oobCode = oobCodeMatch[1]; | |
| const signInResponse = await axios.post('https://identitytoolkit.googleapis.com/v1/accounts:signInWithEmailLink?key=AIzaSyAaSg74fiq2FKPvfqo9QT55c5DmCmETKVY', { | |
| email: email, | |
| oobCode: oobCode | |
| }, { | |
| headers: { | |
| 'Content-Type': 'application/json' | |
| } | |
| }); | |
| const bearerToken = signInResponse.data.idToken; | |
| const userId = signInResponse.data.localId; | |
| currentAccount = { | |
| email: email, | |
| otpUrl: verifyUrl, | |
| bearerToken: bearerToken, | |
| userId: userId | |
| }; | |
| requestCount = 0; | |
| } | |
| requestCount++; | |
| const chatResponse = await axios.post('https://chat.hackaigc.com/api/chat', { | |
| user_id: currentAccount.userId, | |
| user_level: 'free', | |
| model: 'gpt-4o', | |
| messages: [{ role: 'user', content: query }], | |
| prompt: '', | |
| temperature: 0.7, | |
| enableWebSearch: false, | |
| usedVoiceInput: false | |
| }, { | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| 'Authorization': `Bearer ${currentAccount.bearerToken}` | |
| } | |
| }); | |
| return { | |
| email: currentAccount.email, | |
| otpUrl: currentAccount.otpUrl, | |
| bearerToken: currentAccount.bearerToken, | |
| requestCount: requestCount, | |
| response: chatResponse.data | |
| }; | |
| } | |
| const accountLimits = new Map(); | |
| const handler = async (req, res) => { | |
| try { | |
| const { text, key } = req.query; | |
| if (!text || !key) { | |
| return res.status(400).json({ | |
| success: false, | |
| error: 'Missing required parameters: text and key' | |
| }); | |
| } | |
| const currentCount = accountLimits.get(key) || 0; | |
| if (currentCount >= 8) { | |
| return res.status(429).json({ | |
| success: false, | |
| error: 'API key limit reached. Maximum 8 requests per key.' | |
| }); | |
| } | |
| const result = await hackai(text); | |
| accountLimits.set(key, currentCount + 1); | |
| res.json({ | |
| author: "Herza", | |
| success: true, | |
| email: result.email, | |
| otpUrl: result.otpUrl, | |
| bearerToken: result.bearerToken, | |
| requestCount: result.requestCount, | |
| keyUsage: `${currentCount + 1}/8`, | |
| msg: result.response | |
| }); | |
| } catch (error) { | |
| res.status(500).json({ | |
| success: false, | |
| error: error.message | |
| }); | |
| } | |
| }; | |
| module.exports = { | |
| name: 'HackAI GPT-4o', | |
| description: 'Generate responses using HackAI GPT-4o with automatic account rotation', | |
| type: 'GET', | |
| routes: ['api/AI/hackai'], | |
| tags: ['ai', 'gpt4o', 'hackai'], | |
| main: ['AI'], | |
| parameters: ['text', 'key'], | |
| enabled: true, | |
| handler | |
| }; |