File size: 4,281 Bytes
aa2955d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
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
}; |