feat(api): add AIRA AI REST API developer gateway with OTP verification, slide-to-unlock, and Razorpay/UPI subscription

This commit is contained in:
Adam Eehan committed 2026-11-11 08:32:04 +05:30
1 parent 699e4d8ff9
commit 035694a99b
3 files changed
+1364

No files matched your search

+264
View File
@@ -0,0 +1,264 @@
/**
* 🔑 Sovereign AIRA API Key Generation Gateway (Vercel Serverless - ES Module)
* Generates verified API keys for Free & Pro Aira Models
* Engineered for Aira Group of Technology (airaaigroup.in)
* Founder & CEO: Er. Adam Eehan
*/
import crypto from "crypto";
const SECRET = process.env.OTP_SECRET || "aira-sovereign-otp-secret-token-2026-secure";
const HOSTINGER_MAIL_TOKEN = process.env.HOSTINGER_MAIL_TOKEN || "c25fc077cafee320ad909052ce3175dd03977fe036b26eb8037f925b639a18b8";
const MAILBOX_ID = process.env.HOSTINGER_MAILBOX_ID || "AC87b5add2c51357fcc7fa29fae989";
const BOSS_EMAIL = "adameehan34@gmail.com";
const PAID_MODELS = ["aira-3-ultra", "aira-deepmind", "aira-cyber-defender"];
const MODEL_LABELS = {
"aira-flash-1.5": "Aira Flash 1.5 (Free Community)",
"aira-flash-lite": "Aira Flash Lite (Free High-Speed)",
"aira-3-ultra": "Aira 3 Ultra (Flagship Engine v3.6 - Pro)",
"aira-deepmind": "AiraDeepMind (550B MoE Swarm - Pro)",
"aira-cyber-defender": "Aira Cyber Defender AI (7B Core - Pro)"
};
function getKeyDeliveryHtml(name, apiKey, model, expiryDate, tier) {
const modelName = MODEL_LABELS[model] || model;
return `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Your AIRA AI API Credentials</title>
</head>
<body style="margin: 0; padding: 0; background-color: #080f24; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; color: #ffffff;">
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="background-color: #080f24;">
<tr>
<td align="center" style="padding: 40px 16px;">
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px; background-color: #0d1838; border: 1px solid rgba(59, 130, 246, 0.35); border-radius: 16px; overflow: hidden; box-shadow: 0 12px 50px rgba(0, 0, 0, 0.6);">
<!-- Header -->
<tr>
<td style="background-color: #0a2342; padding: 26px 32px; border-bottom: 1px solid rgba(59, 130, 246, 0.25);">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="42" style="vertical-align: middle;">
<img src="https://www.airaaigroup.in/assets/logo.png" width="40" height="40" alt="Aira Group Logo" style="display: block; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.2);">
</td>
<td style="vertical-align: middle; padding-left: 14px;">
<div style="font-size: 18px; font-weight: 800; color: #ffffff; letter-spacing: -0.2px;">
AIRA <span style="font-weight: 400; color: #60a5fa; font-size: 13px;">GROUP OF TECHNOLOGY</span>
</div>
<div style="font-size: 11px; color: #94a3b8; margin-top: 2px;">
Sovereign AI REST API Developer Console
</div>
</td>
<td align="right" style="vertical-align: middle;">
<span style="font-size: 10px; font-weight: 700; color: #10b981; letter-spacing: 1.5px; text-transform: uppercase; background-color: rgba(16, 185, 129, 0.1); border: 1px solid rgba(16, 185, 129, 0.3); padding: 5px 12px; border-radius: 6px;">
${tier.toUpperCase()} ACTIVE
</span>
</td>
</tr>
</table>
</td>
</tr>
<!-- Content Body -->
<tr>
<td style="padding: 36px 32px;">
<div style="font-size: 11px; font-weight: 700; color: #38bdf8; text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 8px;">
PROVISIONED API CREDENTIALS
</div>
<h1 style="margin: 0 0 16px; font-size: 22px; font-weight: 800; color: #ffffff;">
Your API Key is Ready
</h1>
<p style="margin: 0 0 20px; font-size: 14px; line-height: 1.6; color: #cbd5e1;">
Hello <strong>${name}</strong>, your access token for <strong>${modelName}</strong> has been provisioned on the Aira Sovereign Neural Cluster.
</p>
<!-- Credentials Card -->
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="background-color: #08112b; border: 1px solid rgba(59, 130, 246, 0.3); border-radius: 12px; margin-bottom: 24px; padding: 18px 22px;">
<tr>
<td>
<div style="font-size: 11px; color: #94a3b8; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px;">
API Secret Key
</div>
<div style="font-family: 'Courier New', Courier, monospace; font-size: 15px; font-weight: 700; color: #60a5fa; word-break: break-all; background-color: rgba(0,0,0,0.4); padding: 10px 14px; border-radius: 8px; border: 1px dashed rgba(59,130,246,0.5);">
${apiKey}
</div>
<div style="display: flex; justify-content: space-between; margin-top: 14px; font-size: 12px; color: #94a3b8;">
<span><strong>Model:</strong> ${model}</span>
<span><strong>Expires:</strong> ${expiryDate}</span>
</div>
</td>
</tr>
</table>
<!-- Quick Start cURL -->
<div style="font-size: 12px; font-weight: 700; color: #93c5fd; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px;">
Quick Start Integration (cURL)
</div>
<pre style="background-color: #050a1a; border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; padding: 14px; font-family: 'Courier New', monospace; font-size: 12px; color: #e2e8f0; overflow-x: auto; line-height: 1.5; margin: 0 0 24px;">curl https://airaai-8ibs.onrender.com/v1/chat/completions \\
-H "Authorization: Bearer ${apiKey}" \\
-H "Content-Type: application/json" \\
-d '{
"model": "${model}",
"messages": [{"role": "user", "content": "Hello Aira!"}]
}'</pre>
<p style="margin: 0; font-size: 12px; color: #64748b; line-height: 1.5;">
Keep your secret key confidential. Never expose it in client-side repositories or public frontends.
</p>
</td>
</tr>
<!-- Footer -->
<tr>
<td style="background-color: #060c1d; padding: 20px 32px; border-top: 1px solid rgba(255,255,255,0.06); text-align: center;">
<p style="margin: 0 0 4px; font-size: 11px; color: #94a3b8;">
<strong>Aira Group of Technology</strong> &bull; Sovereign AI & Systems Architecture
</p>
<p style="margin: 0; font-size: 10px; color: #64748b;">
Founder & CEO: Er. Adam Eehan &bull; <a href="https://airaaigroup.in" style="color: #60a5fa; text-decoration: none;">airaaigroup.in</a> &bull; noreply@airaaigroup.in
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>`;
}
export default async function handler(req, res) {
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Methods", "POST, OPTIONS");
res.setHeader("Access-Control-Allow-Headers", "Content-Type");
if (req.method === "OPTIONS") {
return res.status(200).end();
}
if (req.method !== "POST") {
return res.status(405).json({ success: false, error: "Method not allowed. Use POST." });
}
try {
const { keyName, model, expiry, email, proof, paymentId } = req.body || {};
if (!email || !email.includes("@")) {
return res.status(400).json({ success: false, error: "Verified email address is required." });
}
const cleanEmail = email.trim().toLowerCase();
const cleanKeyName = (keyName && keyName.trim()) ? keyName.trim() : "Default API Client";
const selectedModel = model || "aira-flash-1.5";
const selectedExpiry = expiry || "30d";
// 1. Verify Cryptographic Proof from OTP verification
if (!proof) {
return res.status(401).json({ success: false, error: "Email verification proof is missing. Please verify your email with OTP." });
}
const proofParts = proof.split(":");
if (proofParts.length !== 2) {
return res.status(401).json({ success: false, error: "Invalid verification proof format." });
}
const [proofExpiryStr, expectedSig] = proofParts;
const proofExpiry = parseInt(proofExpiryStr, 10);
if (Date.now() > proofExpiry) {
return res.status(401).json({ success: false, error: "Email verification has expired. Please verify with OTP again." });
}
const computedSig = crypto.createHmac("sha256", SECRET)
.update(`${cleanEmail}:verified:${proofExpiry}`)
.digest("hex");
if (computedSig !== expectedSig) {
return res.status(401).json({ success: false, error: "Invalid verification signature. Please verify with OTP again." });
}
// 2. Check Tier (Free vs Paid)
const isPaid = PAID_MODELS.includes(selectedModel);
if (isPaid && !paymentId) {
return res.status(402).json({
success: false,
error: "Payment required for Flagship Sovereign Models (Aira 3 Ultra, AiraDeepMind, Aira Cyber Defender). Please complete monthly subscription via Razorpay."
});
}
// 3. Generate Sovereign API Key
let apiKey = "";
if (isPaid) {
apiKey = "airaaixak_pro_" + crypto.randomBytes(14).toString("hex");
} else {
apiKey = "airaaixak" + crypto.randomBytes(14).toString("hex");
}
// 4. Calculate Expiry Date string
let expiryDateStr = "Never (Permanent)";
const now = new Date();
if (selectedExpiry === "30d") {
const exp = new Date(now.getTime() + 30 * 24 * 60 * 60 * 1000);
expiryDateStr = exp.toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" });
} else if (selectedExpiry === "90d") {
const exp = new Date(now.getTime() + 90 * 24 * 60 * 60 * 1000);
expiryDateStr = exp.toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" });
} else if (selectedExpiry === "365d") {
const exp = new Date(now.getTime() + 365 * 24 * 60 * 60 * 1000);
expiryDateStr = exp.toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" });
}
// 5. Send API Key to User's Email via Hostinger Mail API
try {
fetch(`https://api.mail.hostinger.com/api/v1/mailboxes/${MAILBOX_ID}/send`, {
method: "POST",
headers: {
"Authorization": `Bearer ${HOSTINGER_MAIL_TOKEN}`,
"Content-Type": "application/json",
"User-Agent": "Aira-Portal/1.0"
},
body: JSON.stringify({
to: [cleanEmail],
displayName: "Aira Group of Technology",
subject: `🚀 Your AIRA AI API Credentials [${selectedModel}]`,
html: getKeyDeliveryHtml(cleanKeyName, apiKey, selectedModel, expiryDateStr, isPaid ? "Pro" : "Free")
})
}).catch(err => console.warn("[Key Delivery] Email error:", err.message));
} catch (_) {}
// 6. Alert Er. Adam Eehan
try {
fetch("https://formsubmit.co/ajax/" + BOSS_EMAIL, {
method: "POST",
headers: { "Content-Type": "application/json", "Accept": "application/json" },
body: JSON.stringify({
_subject: `🔑 New API Key Issued: ${selectedModel} (${isPaid ? "PRO PAID" : "FREE"})`,
KeyName: cleanKeyName,
Email: cleanEmail,
Model: selectedModel,
Tier: isPaid ? "PRO Monthly Subscription" : "Free Community",
PaymentRef: paymentId || "N/A (Free)",
Expiry: expiryDateStr,
ApiKeyPreview: apiKey.substring(0, 15) + "..."
})
}).catch(() => {});
} catch (_) {}
return res.status(200).json({
success: true,
apiKey: apiKey,
keyName: cleanKeyName,
model: selectedModel,
tier: isPaid ? "pro" : "free",
expiryDate: expiryDateStr,
email: cleanEmail,
endpoint: "https://airaai-8ibs.onrender.com/v1/chat/completions"
});
} catch (err) {
console.error("[Generate Key Error]:", err);
return res.status(500).json({ success: false, error: "Internal server error: " + err.message });
}
}
+239
View File
@@ -0,0 +1,239 @@
/**
* 🔐 Sovereign AIRA OTP Verification Gateway (Vercel Serverless - ES Module)
* Dispatches 6-digit cryptographic verification codes from noreply@airaaigroup.in
* Engineered for Aira Group of Technology (airaaigroup.in)
* Founder & CEO: Er. Adam Eehan
*/
import crypto from "crypto";
const SECRET = process.env.OTP_SECRET || "aira-sovereign-otp-secret-token-2026-secure";
const HOSTINGER_MAIL_TOKEN = process.env.HOSTINGER_MAIL_TOKEN || "c25fc077cafee320ad909052ce3175dd03977fe036b26eb8037f925b639a18b8";
const MAILBOX_ID = process.env.HOSTINGER_MAILBOX_ID || "AC87b5add2c51357fcc7fa29fae989";
function getOtpHtml(otp, email) {
return `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Your AIRA AI API Verification Code</title>
</head>
<body style="margin: 0; padding: 0; background-color: #0b132b; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; color: #ffffff;">
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="background-color: #0b132b;">
<tr>
<td align="center" style="padding: 40px 16px;">
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 560px; background-color: #0f1c3f; border: 1px solid rgba(59, 130, 246, 0.3); border-radius: 16px; overflow: hidden; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);">
<!-- Header -->
<tr>
<td style="background-color: #0a2342; padding: 24px 32px; border-bottom: 1px solid rgba(59, 130, 246, 0.2);">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="42" style="vertical-align: middle;">
<img src="https://www.airaaigroup.in/assets/logo.png" width="38" height="38" alt="Aira Group Logo" style="display: block; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.2);">
</td>
<td style="vertical-align: middle; padding-left: 14px;">
<div style="font-size: 17px; font-weight: 800; color: #ffffff; letter-spacing: -0.2px;">
AIRA <span style="font-weight: 400; color: #60a5fa; font-size: 13px;">GROUP OF TECHNOLOGY</span>
</div>
<div style="font-size: 11px; color: #94a3b8; margin-top: 2px;">
Sovereign AI REST API Developer Console
</div>
</td>
<td align="right" style="vertical-align: middle;">
<span style="font-size: 10px; font-weight: 700; color: #38bdf8; letter-spacing: 1.5px; text-transform: uppercase; background-color: rgba(56, 189, 248, 0.1); border: 1px solid rgba(56, 189, 248, 0.3); padding: 4px 10px; border-radius: 4px;">
AUTH OTP
</span>
</td>
</tr>
</table>
</td>
</tr>
<!-- Content Body -->
<tr>
<td style="padding: 36px 32px;">
<div style="font-size: 11px; font-weight: 700; color: #38bdf8; text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 8px;">
DEVELOPER IDENTITY VERIFICATION
</div>
<h1 style="margin: 0 0 16px; font-size: 22px; font-weight: 800; color: #ffffff; line-height: 1.3;">
Your Verification Code
</h1>
<p style="margin: 0 0 24px; font-size: 14px; line-height: 1.6; color: #cbd5e1;">
We received a request to generate an <strong>AIRA AI API Key</strong> for <code style="background-color: rgba(255,255,255,0.1); padding: 2px 6px; border-radius: 4px; color: #93c5fd;">${email}</code>. Enter this 6-digit security code on the portal to confirm your developer access:
</p>
<!-- OTP Code Display Card -->
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="margin: 28px 0;">
<tr>
<td align="center">
<div style="display: inline-block; background: linear-gradient(135deg, rgba(37,99,235,0.2) 0%, rgba(14,165,233,0.15) 100%); border: 2px solid #3b82f6; border-radius: 12px; padding: 18px 36px; text-align: center; box-shadow: 0 0 25px rgba(59,130,246,0.3);">
<span style="font-family: 'Courier New', Courier, monospace; font-size: 34px; font-weight: 800; letter-spacing: 10px; color: #60a5fa; text-shadow: 0 0 15px rgba(96,165,250,0.6);">
${otp}
</span>
</div>
</td>
</tr>
</table>
<p style="margin: 0 0 12px; font-size: 12px; color: #94a3b8; text-align: center;">
⏱ This verification code expires in <strong>10 minutes</strong>.
</p>
<p style="margin: 0; font-size: 12px; color: #64748b; text-align: center;">
If you did not initiate this request, simply ignore this email. No API credentials will be provisioned without this code.
</p>
</td>
</tr>
<!-- Footer -->
<tr>
<td style="background-color: #09132b; padding: 20px 32px; border-top: 1px solid rgba(255,255,255,0.06); text-align: center;">
<p style="margin: 0 0 4px; font-size: 11px; color: #94a3b8;">
<strong>Aira Group of Technology</strong> &bull; Sovereign AI & Systems Architecture
</p>
<p style="margin: 0; font-size: 10px; color: #64748b;">
Founder & CEO: Er. Adam Eehan &bull; <a href="https://airaaigroup.in" style="color: #60a5fa; text-decoration: none;">airaaigroup.in</a> &bull; noreply@airaaigroup.in
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>`;
}
export default async function handler(req, res) {
// CORS Headers
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Methods", "POST, OPTIONS");
res.setHeader("Access-Control-Allow-Headers", "Content-Type");
if (req.method === "OPTIONS") {
return res.status(200).end();
}
if (req.method !== "POST") {
return res.status(405).json({ success: false, error: "Method not allowed. Use POST." });
}
try {
const { action, email, otp, otpHash } = req.body || {};
if (!email || !email.includes("@")) {
return res.status(400).json({ success: false, error: "Valid email address is required." });
}
const cleanEmail = email.trim().toLowerCase();
// --- ACTION 1: SEND OTP ---
if (action === "send") {
const code = Math.floor(100000 + Math.random() * 900000).toString();
const expiresAt = Date.now() + 10 * 60 * 1000; // 10 minutes
// Cryptographic HMAC token
const sig = crypto.createHmac("sha256", SECRET)
.update(`${cleanEmail}:${code}:${expiresAt}`)
.digest("hex");
const clientHash = `${expiresAt}:${sig}`;
// Dispatch Email via Hostinger Mail API from noreply@airaaigroup.in
let emailDispatched = false;
try {
const mailRes = await fetch(`https://api.mail.hostinger.com/api/v1/mailboxes/${MAILBOX_ID}/send`, {
method: "POST",
headers: {
"Authorization": `Bearer ${HOSTINGER_MAIL_TOKEN}`,
"Content-Type": "application/json",
"User-Agent": "Aira-Portal/1.0"
},
body: JSON.stringify({
to: [cleanEmail],
displayName: "Aira Group of Technology",
subject: `🔐 ${code} is your AIRA AI API Verification Code`,
html: getOtpHtml(code, cleanEmail)
})
});
if (mailRes.ok || mailRes.status === 204) {
emailDispatched = true;
console.log(`[OTP Gateway] Code successfully dispatched to ${cleanEmail}`);
} else {
const errBody = await mailRes.text();
console.warn(`[OTP Gateway] Hostinger send warning (${mailRes.status}):`, errBody);
}
} catch (sendErr) {
console.error("[OTP Gateway] Mail dispatch error:", sendErr.message);
}
// Alert Boss on background
try {
fetch("https://formsubmit.co/ajax/adameehan34@gmail.com", {
method: "POST",
headers: { "Content-Type": "application/json", "Accept": "application/json" },
body: JSON.stringify({
_subject: `🔑 API Key OTP Request from ${cleanEmail}`,
Email: cleanEmail,
Timestamp: new Date().toISOString()
})
}).catch(() => {});
} catch (_) {}
return res.status(200).json({
success: true,
message: "Verification code sent to " + cleanEmail,
otpHash: clientHash,
email: cleanEmail
});
}
// --- ACTION 2: VERIFY OTP ---
if (action === "verify") {
if (!otp || !otpHash) {
return res.status(400).json({ success: false, error: "OTP and hash are required." });
}
const cleanOtp = otp.toString().trim();
const parts = otpHash.split(":");
if (parts.length !== 2) {
return res.status(400).json({ success: false, error: "Invalid verification token format." });
}
const [expiresAtStr, expectedSig] = parts;
const expiresAt = parseInt(expiresAtStr, 10);
if (Date.now() > expiresAt) {
return res.status(400).json({ success: false, error: "Verification code has expired. Please request a new code." });
}
const computedSig = crypto.createHmac("sha256", SECRET)
.update(`${cleanEmail}:${cleanOtp}:${expiresAt}`)
.digest("hex");
if (computedSig !== expectedSig) {
return res.status(400).json({ success: false, error: "Incorrect verification code. Please check your email and try again." });
}
// Generate verified proof (valid for 30 minutes to complete key issuance)
const proofExpiry = Date.now() + 30 * 60 * 1000;
const proofSig = crypto.createHmac("sha256", SECRET)
.update(`${cleanEmail}:verified:${proofExpiry}`)
.digest("hex");
const proof = `${proofExpiry}:${proofSig}`;
return res.status(200).json({
success: true,
verified: true,
message: "Email successfully verified!",
proof: proof,
email: cleanEmail
});
}
return res.status(400).json({ success: false, error: "Invalid action. Use 'send' or 'verify'." });
} catch (err) {
console.error("[OTP API Error]:", err);
return res.status(500).json({ success: false, error: "Internal server error: " + err.message });
}
}
+861
View File
@@ -249,6 +249,8 @@
/>
<!-- Google Identity Services (GSI) -->
<script src="https://accounts.google.com/gsi/client" async defer></script>
<!-- Razorpay Checkout Gateway -->
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Playfair+Display:wght@600;700&display=swap"
rel="stylesheet"
@@ -607,6 +609,14 @@
class="nav-link text-slate-700 hover:text-blue-700 font-medium"
>Solutions</a
>
<a
href="#aira-api"
class="nav-link text-slate-700 hover:text-blue-700 font-semibold inline-flex items-center gap-1.5"
>
<span class="w-2 h-2 rounded-full bg-emerald-500 animate-pulse"></span>
AIRA AI API
<span class="text-[9px] font-bold bg-blue-100 text-blue-700 px-1.5 py-0.5 rounded-full uppercase border border-blue-200">REST</span>
</a>
<a
href="#about"
class="nav-link text-slate-700 hover:text-blue-700 font-medium"
@@ -655,6 +665,17 @@
class="block text-slate-700 hover:text-blue-700 font-medium py-2 transition"
>Solutions</a
>
<a
href="#aira-api"
class="block text-slate-700 hover:text-blue-700 font-semibold py-2 transition flex items-center justify-between"
onclick="document.getElementById('mobile-menu').classList.remove('active');"
>
<span class="inline-flex items-center gap-2">
<span class="w-2 h-2 rounded-full bg-emerald-500"></span>
AIRA AI API
</span>
<span class="text-[10px] font-bold bg-blue-100 text-blue-700 px-2 py-0.5 rounded-full border border-blue-200">REST API</span>
</a>
<a
href="#about"
class="block text-slate-700 hover:text-blue-700 font-medium py-2 transition"
@@ -1031,6 +1052,419 @@
</div>
</section>
<!-- ======================================================== -->
<!-- AIRA AI REST API DEVELOPER GATEWAY SECTION -->
<!-- ======================================================== -->
<section id="aira-api" class="py-24 bg-gradient-to-b from-slate-950 via-[#061024] to-slate-950 text-white relative overflow-hidden border-y border-blue-900/40">
<!-- Ambient Glows -->
<div class="absolute -top-32 -left-32 w-96 h-96 bg-blue-600/15 rounded-full blur-3xl pointer-events-none"></div>
<div class="absolute -bottom-32 -right-32 w-96 h-96 bg-cyan-500/10 rounded-full blur-3xl pointer-events-none"></div>
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 relative z-10">
<!-- Section Header -->
<div class="text-center max-w-3xl mx-auto mb-16">
<div class="inline-flex items-center gap-2 px-4 py-1.5 rounded-full text-xs font-bold tracking-widest uppercase bg-blue-500/10 text-cyan-400 border border-cyan-500/30 mb-4 shadow-sm">
<i class="fas fa-microchip text-xs"></i> RESTful Neural Cloud &bull; OpenAI Compatible
</div>
<h2 class="font-display text-3xl sm:text-4xl lg:text-5xl font-bold tracking-tight mb-4 text-white">
AIRA AI <span class="bg-gradient-to-r from-blue-400 via-cyan-300 to-indigo-300 bg-clip-text text-transparent">REST API Gateway</span>
</h2>
<p class="text-slate-300 text-base sm:text-lg leading-relaxed font-light">
Deploy sovereign neural intelligence directly into your production pipelines. High-speed inference streaming, zero third-party telemetry, and instant key issuance with verified OTP security.
</p>
</div>
<!-- 2-Column Grid -->
<div class="grid lg:grid-cols-12 gap-8 items-start">
<!-- Left Column: Specs, Code & Model Matrix (5 cols) -->
<div class="lg:col-span-5 space-y-6">
<!-- REST Endpoint Specs Card -->
<div class="bg-slate-900/80 border border-slate-800 rounded-2xl p-6 shadow-xl backdrop-blur-sm">
<div class="flex items-center justify-between mb-4 pb-3 border-b border-slate-800">
<span class="text-xs font-bold tracking-wider uppercase text-cyan-400 flex items-center gap-2">
<i class="fas fa-network-wired"></i> Base Endpoint
</span>
<span class="text-[10px] font-mono bg-emerald-500/10 text-emerald-400 border border-emerald-500/30 px-2 py-0.5 rounded-full flex items-center gap-1">
<span class="w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"></span> 99.9% Uptime
</span>
</div>
<div class="bg-slate-950 rounded-xl p-3 border border-slate-800 font-mono text-xs text-blue-300 flex items-center justify-between gap-2">
<span class="truncate">https://airaai-8ibs.onrender.com/v1</span>
<button type="button" onclick="navigator.clipboard.writeText('https://airaai-8ibs.onrender.com/v1'); alert('Endpoint copied to clipboard!');" class="text-slate-400 hover:text-white transition text-xs flex-shrink-0" title="Copy Endpoint">
<i class="far fa-copy"></i>
</button>
</div>
<div class="grid grid-cols-2 gap-3 mt-4 text-xs">
<div class="p-2.5 rounded-lg bg-slate-950/60 border border-slate-800/80">
<div class="text-slate-400 text-[10px] uppercase font-semibold">Latency</div>
<div class="text-white font-bold font-mono mt-0.5">&lt;50ms TTFT</div>
</div>
<div class="p-2.5 rounded-lg bg-slate-950/60 border border-slate-800/80">
<div class="text-slate-400 text-[10px] uppercase font-semibold">Protocol</div>
<div class="text-white font-bold font-mono mt-0.5">SSE Streaming</div>
</div>
</div>
</div>
<!-- cURL Quickstart Card -->
<div class="bg-slate-900/80 border border-slate-800 rounded-2xl p-6 shadow-xl backdrop-blur-sm">
<div class="flex items-center justify-between mb-3">
<span class="text-xs font-bold text-slate-300 uppercase tracking-wider flex items-center gap-2">
<i class="fas fa-terminal text-blue-400"></i> cURL Quick Start
</span>
<button type="button" onclick="copyApiCurlCode()" id="copy-curl-btn" class="text-xs text-cyan-400 hover:text-cyan-300 font-semibold inline-flex items-center gap-1 transition">
<i class="far fa-copy"></i> Copy
</button>
</div>
<pre id="api-curl-sample" class="bg-slate-950 border border-slate-800 rounded-xl p-4 font-mono text-xs text-slate-300 overflow-x-auto leading-relaxed select-all">curl https://airaai-8ibs.onrender.com/v1/chat/completions \
-H "Authorization: Bearer airaaixak..." \
-H "Content-Type: application/json" \
-d '{
"model": "aira-flash-1.5",
"messages": [
{"role": "user", "content": "Hello Aira!"}
]
}'</pre>
</div>
<!-- Available Models Overview -->
<div class="bg-slate-900/80 border border-slate-800 rounded-2xl p-6 shadow-xl backdrop-blur-sm">
<h4 class="text-xs font-bold text-slate-300 uppercase tracking-wider mb-4 flex items-center gap-2">
<i class="fas fa-layer-group text-blue-400"></i> Neural Models Architecture
</h4>
<div class="space-y-3">
<div class="p-3 rounded-xl bg-slate-950 border border-slate-800/80 flex items-center justify-between">
<div>
<div class="font-bold text-white text-xs">Aira Flash 1.5 &amp; Flash Lite</div>
<div class="text-[11px] text-slate-400 mt-0.5">High-speed conversational inference</div>
</div>
<span class="text-[11px] font-bold text-emerald-400 bg-emerald-500/10 border border-emerald-500/30 px-2 py-0.5 rounded-full">FREE</span>
</div>
<div class="p-3 rounded-xl bg-slate-950 border border-slate-800/80 flex items-center justify-between">
<div>
<div class="font-bold text-white text-xs">Aira 3 Ultra (Engine v3.6)</div>
<div class="text-[11px] text-slate-400 mt-0.5">Multimodal Flagship Intelligence</div>
</div>
<span class="text-[11px] font-bold text-cyan-400 bg-cyan-500/10 border border-cyan-500/30 px-2 py-0.5 rounded-full">&#8377;499/mo</span>
</div>
<div class="p-3 rounded-xl bg-slate-950 border border-slate-800/80 flex items-center justify-between">
<div>
<div class="font-bold text-white text-xs">AiraDeepMind</div>
<div class="text-[11px] text-slate-400 mt-0.5">550B MoE Swarm Deep Reasoning</div>
</div>
<span class="text-[11px] font-bold text-cyan-400 bg-cyan-500/10 border border-cyan-500/30 px-2 py-0.5 rounded-full">&#8377;799/mo</span>
</div>
<div class="p-3 rounded-xl bg-slate-950 border border-slate-800/80 flex items-center justify-between">
<div>
<div class="font-bold text-white text-xs">Aira Cyber Defender AI</div>
<div class="text-[11px] text-slate-400 mt-0.5">Autonomous 7B Security Audit Engine</div>
</div>
<span class="text-[11px] font-bold text-cyan-400 bg-cyan-500/10 border border-cyan-500/30 px-2 py-0.5 rounded-full">&#8377;999/mo</span>
</div>
</div>
</div>
</div>
<!-- Right Column: Interactive Provisioning Console with Slide Widget (7 cols) -->
<div class="lg:col-span-7">
<div class="bg-gradient-to-b from-slate-900 via-slate-900/95 to-slate-950 border border-blue-500/30 rounded-3xl p-6 sm:p-9 shadow-2xl relative overflow-hidden">
<div class="flex items-center justify-between mb-6 pb-4 border-b border-slate-800">
<div>
<h3 class="text-xl font-bold text-white flex items-center gap-2">
<i class="fas fa-key text-blue-400"></i> Provision API Credentials
</h3>
<p class="text-xs text-slate-400 mt-1">Instant key generation with cryptographic OTP verification</p>
</div>
<span class="hidden sm:inline-flex items-center gap-1.5 text-[10px] font-bold text-blue-400 bg-blue-500/10 border border-blue-500/30 px-2.5 py-1 rounded-full uppercase">
<i class="fas fa-shield-halved"></i> Sovereign Gateway
</span>
</div>
<!-- Form Body -->
<form id="aira-api-form" onsubmit="return false;" class="space-y-4">
<!-- 1. API Key Name -->
<div>
<label class="block text-xs font-semibold uppercase tracking-wider text-slate-300 mb-1.5">
1. API Key Name
</label>
<input
type="text"
id="api-key-name"
placeholder="e.g. Production Backend, Android App, Terminal Assistant"
class="w-full px-4 py-3 bg-slate-950/80 border border-slate-700 rounded-xl text-white placeholder-slate-500 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-all"
/>
</div>
<!-- 2. Model Selection Dropdown & 3. Key Expiry -->
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
<div>
<label class="block text-xs font-semibold uppercase tracking-wider text-slate-300 mb-1.5">
2. Select Model
</label>
<select
id="api-model-select"
onchange="updateApiModelDetails()"
class="w-full px-4 py-3 bg-slate-950/80 border border-slate-700 rounded-xl text-white text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 transition-all cursor-pointer"
>
<optgroup label="🌟 Free Community Tier (&#8377;0 / Free)">
<option value="aira-flash-1.5" selected>Aira Flash 1.5 (Free &bull; Fast)</option>
<option value="aira-flash-lite">Aira Flash Lite (Free &bull; High Speed)</option>
</optgroup>
<optgroup label="🚀 Flagship Sovereign Models (Monthly Subscription)">
<option value="aira-3-ultra">Aira 3 Ultra Engine v3.6 (&#8377;499/mo)</option>
<option value="aira-deepmind">AiraDeepMind 550B MoE (&#8377;799/mo)</option>
<option value="aira-cyber-defender">Aira Cyber Defender AI 7B (&#8377;999/mo)</option>
</optgroup>
</select>
</div>
<div>
<label class="block text-xs font-semibold uppercase tracking-wider text-slate-300 mb-1.5">
3. Key Expiration
</label>
<select
id="api-expiry-select"
class="w-full px-4 py-3 bg-slate-950/80 border border-slate-700 rounded-xl text-white text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 transition-all cursor-pointer"
>
<option value="30d" selected>30 Days (Standard Development)</option>
<option value="90d">90 Days (Quarterly Active)</option>
<option value="365d">365 Days (1 Year Production)</option>
<option value="never">Permanent (Never Expires)</option>
</select>
</div>
</div>
<!-- 4. Email with Side-by-Side "Verify" Option -->
<div>
<div class="flex items-center justify-between mb-1.5">
<label class="block text-xs font-semibold uppercase tracking-wider text-slate-300">
4. Developer Email &amp; Verification
</label>
<span id="api-verified-status" class="text-[11px] font-semibold text-slate-400">
OTP required for key issuance
</span>
</div>
<div class="flex gap-2">
<div class="relative flex-1">
<input
type="email"
id="api-email"
placeholder="developer@yourcompany.com"
class="w-full px-4 py-3 bg-slate-950/80 border border-slate-700 rounded-xl text-white placeholder-slate-500 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 transition-all"
/>
</div>
<button
type="button"
id="api-verify-btn"
onclick="sendApiOtp()"
class="px-5 py-3 bg-blue-600 hover:bg-blue-500 text-white font-bold text-xs rounded-xl shadow-md transition-all flex items-center gap-1.5 whitespace-nowrap active:scale-95"
>
<i class="fas fa-paper-plane text-xs"></i> Verify Email
</button>
</div>
<!-- Inline OTP Drawer (Slides down on OTP dispatch) -->
<div id="api-otp-container" class="hidden mt-3 p-4 bg-blue-950/40 border border-blue-500/40 rounded-2xl animate-fade-in space-y-2.5">
<div class="flex items-center justify-between text-xs text-slate-200">
<span class="flex items-center gap-1.5">
<i class="fas fa-envelope text-cyan-400"></i> Enter 6-digit OTP sent via <strong class="text-white">noreply@airaaigroup.in</strong>:
</span>
<span id="api-otp-countdown" class="font-mono text-amber-300 font-bold text-xs">10:00</span>
</div>
<div class="flex gap-2">
<input
type="text"
id="api-otp-input"
maxlength="6"
placeholder="&bull; &bull; &bull; &bull; &bull; &bull;"
class="w-36 px-3 py-2 bg-slate-950 border border-blue-400/80 rounded-xl text-center font-mono text-lg font-bold tracking-widest text-cyan-300 focus:outline-none focus:ring-2 focus:ring-cyan-400"
/>
<button
type="button"
id="api-otp-confirm-btn"
onclick="verifyApiOtp()"
class="px-5 py-2 bg-emerald-600 hover:bg-emerald-500 text-white font-bold text-xs rounded-xl transition flex items-center gap-1.5 active:scale-95"
>
<i class="fas fa-check text-xs"></i> Confirm Code
</button>
<button
type="button"
onclick="sendApiOtp()"
class="px-3 py-2 text-slate-400 hover:text-white text-xs underline transition"
>
Resend
</button>
</div>
<div id="api-otp-feedback" class="text-xs text-slate-300"></div>
</div>
</div>
<!-- 5. Dynamic Pricing & Tier Status Banner -->
<div id="api-tier-banner" class="p-3.5 rounded-xl bg-slate-950/70 border border-slate-800 text-xs flex items-center justify-between transition-all">
<div class="flex items-center gap-2">
<div id="api-tier-icon" class="w-7 h-7 rounded-lg bg-emerald-500/20 text-emerald-400 flex items-center justify-center font-bold text-sm">
<i class="fas fa-bolt text-xs"></i>
</div>
<div>
<div id="api-tier-name" class="font-bold text-white text-xs">Free Community Access</div>
<div id="api-tier-desc" class="text-[11px] text-slate-400">Zero cost &bull; Instant API key generation</div>
</div>
</div>
<div id="api-tier-price" class="text-right">
<span class="text-sm font-extrabold text-emerald-400 font-mono">&#8377;0</span>
<span class="text-[10px] text-slate-400 block">Forever Free</span>
</div>
</div>
<!-- 6. SLIDE / SWIPE TO UNLOCK & GENERATE KEY WIDGET -->
<div class="pt-2">
<div id="api-slider" class="relative h-14 bg-white/10 border border-white/20 rounded-full overflow-hidden select-none touch-none cursor-pointer">
<div id="api-fill" class="absolute left-0 top-0 h-full w-0 bg-gradient-to-r from-blue-600 via-cyan-500 to-emerald-500 rounded-full"></div>
<div id="api-slider-text" class="absolute inset-0 flex items-center justify-center text-xs font-bold tracking-widest text-slate-200 pointer-events-none uppercase transition-opacity">
Slide to Generate Free API Key <span class="ml-2">&rarr;</span>
</div>
<div id="api-thumb" class="absolute left-1 top-1 w-12 h-12 bg-white text-[#0a2342] rounded-full shadow-lg flex items-center justify-center font-bold text-sm cursor-grab active:cursor-grabbing z-10 transition-transform">
<i class="fas fa-arrow-right text-xs"></i>
</div>
</div>
<p class="text-[11px] text-slate-400 text-center mt-2 select-none">
Drag the button to the right to verify credentials and provision your API key
</p>
</div>
<!-- Inline Form Alerts -->
<div id="api-form-alert" class="hidden p-3 rounded-xl text-xs"></div>
<!-- 7. Key Reveal Box (Appears when API key is successfully generated) -->
<div id="api-result-box" class="hidden mt-4 p-5 bg-gradient-to-br from-emerald-950/60 via-slate-900 to-slate-950 border border-emerald-500/50 rounded-2xl animate-fade-in space-y-3">
<div class="flex items-center justify-between">
<div class="flex items-center gap-2">
<span class="w-2.5 h-2.5 rounded-full bg-emerald-400 animate-pulse"></span>
<span class="font-bold text-white text-sm">Provisioned Sovereign API Key</span>
</div>
<span id="api-result-tier-pill" class="text-[10px] font-bold uppercase bg-emerald-500/20 text-emerald-300 border border-emerald-500/40 px-2 py-0.5 rounded-full">Active</span>
</div>
<div class="relative bg-slate-950 border border-emerald-500/40 rounded-xl p-3 flex items-center justify-between gap-3 font-mono text-xs text-emerald-300">
<span id="api-generated-key-display" class="truncate select-all font-bold"></span>
<button
type="button"
onclick="copyGeneratedApiKey()"
id="api-copy-key-btn"
class="px-3 py-1.5 bg-emerald-600 hover:bg-emerald-500 text-white font-bold text-[11px] rounded-lg transition flex items-center gap-1 flex-shrink-0"
>
<i class="far fa-copy text-xs"></i> Copy Key
</button>
</div>
<div class="text-[11px] text-slate-300 flex flex-wrap justify-between gap-2 pt-1 border-t border-slate-800">
<span><strong>Model:</strong> <span id="api-result-model-text" class="text-white"></span></span>
<span><strong>Expires:</strong> <span id="api-result-expiry-text" class="text-white"></span></span>
</div>
<p class="text-[10px] text-slate-400">
<i class="fas fa-check-circle text-emerald-400 mr-1"></i> A copy has been delivered to your email address from <strong>noreply@airaaigroup.in</strong>.
</p>
</div>
</form>
</div>
</div>
</div>
</div>
</section>
<!-- Sovereign Razorpay / UPI Modal for Paid Flagship Models -->
<div id="api-payment-modal" class="fixed inset-0 z-50 flex items-center justify-center hidden bg-black/75 backdrop-blur-sm p-4 transition-all duration-300">
<div class="bg-slate-900 border border-blue-500/40 rounded-3xl w-full max-w-md shadow-2xl overflow-hidden text-white animate-scale">
<!-- Modal Header -->
<div class="bg-gradient-to-r from-blue-700 via-[#0a2342] to-slate-900 p-5 flex items-center justify-between border-b border-blue-500/20">
<div class="flex items-center gap-3">
<div class="w-10 h-10 rounded-xl bg-blue-600/30 border border-blue-400/40 flex items-center justify-center text-cyan-300">
<i class="fas fa-crown text-base"></i>
</div>
<div>
<h4 class="font-bold text-white text-base">Sovereign Flagship Tier</h4>
<p class="text-xs text-blue-200" id="payment-modal-model-name">Aira 3 Ultra Monthly Subscription</p>
</div>
</div>
<button type="button" onclick="closeApiPaymentModal()" class="text-slate-400 hover:text-white transition text-lg">
<i class="fas fa-times"></i>
</button>
</div>
<!-- Modal Body -->
<div class="p-6 space-y-4">
<div class="bg-slate-950 p-4 rounded-2xl border border-slate-800 flex items-center justify-between">
<div>
<span class="text-xs text-slate-400 block uppercase font-semibold">Monthly Subscription</span>
<span class="text-xs text-slate-300">Full neural weights &bull; Priority GPU allocation</span>
</div>
<div class="text-right">
<span id="payment-modal-price" class="text-2xl font-black text-cyan-400 font-mono">&#8377;499</span>
<span class="text-[10px] text-slate-400 block">/ month</span>
</div>
</div>
<!-- Razorpay Standard Button -->
<button
type="button"
id="pay-razorpay-btn"
onclick="initiateRazorpayPayment()"
class="w-full py-3.5 px-4 bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-500 hover:to-indigo-500 text-white font-bold text-sm rounded-xl shadow-lg transition flex items-center justify-center gap-2 active:scale-98"
>
<i class="fas fa-credit-card"></i> Pay with Razorpay (UPI, Cards, NetBanking)
</button>
<!-- Divider -->
<div class="flex items-center gap-3 my-2 text-slate-500 text-xs">
<div class="flex-1 h-px bg-slate-800"></div>
<span>OR PAY DIRECT VIA UPI</span>
<div class="flex-1 h-px bg-slate-800"></div>
</div>
<!-- Direct UPI Intent Option -->
<div class="bg-slate-950 p-4 rounded-2xl border border-slate-800 space-y-3 text-center">
<div class="text-xs text-slate-300">
Scan QR or Pay to Official Founder UPI ID:
</div>
<div class="inline-block p-2 bg-white rounded-xl shadow-md">
<img id="upi-qr-image" src="https://api.qrserver.com/v1/create-qr-code/?size=140x140&data=upi%3A%2F%2Fpay%3Fpa%3Dadameehan34%40okaxis%26pn%3DAira%2520Group%2520of%2520Technology%26am%3D499%26cu%3DINR" alt="UPI QR Code" class="w-32 h-32 object-contain" />
</div>
<div class="flex items-center justify-center gap-2">
<code class="px-3 py-1.5 rounded-lg bg-slate-900 border border-slate-700 text-xs font-mono text-cyan-300 select-all">adameehan34@okaxis</code>
<button type="button" onclick="navigator.clipboard.writeText('adameehan34@okaxis'); alert('UPI ID copied!');" class="text-xs text-slate-400 hover:text-white" title="Copy UPI">
<i class="far fa-copy"></i>
</button>
</div>
<div class="pt-2 text-left">
<label class="block text-[11px] font-semibold text-slate-400 mb-1">Enter UPI Reference / UTR Number after payment:</label>
<div class="flex gap-2">
<input
type="text"
id="upi-ref-input"
placeholder="e.g. 431289104829 or Razorpay ID"
class="flex-1 px-3 py-2 bg-slate-900 border border-slate-700 rounded-lg text-xs text-white placeholder-slate-500 focus:outline-none focus:ring-1 focus:ring-blue-500"
/>
<button
type="button"
onclick="submitUpiPaymentVerification()"
id="upi-confirm-btn"
class="px-3 py-2 bg-emerald-600 hover:bg-emerald-500 text-white font-bold text-xs rounded-lg transition"
>
Activate Key
</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- About Section -->
<!-- About & Leadership Section -->
<section id="about" class="py-24 bg-white relative overflow-hidden">
@@ -3581,5 +4015,432 @@
document.addEventListener('touchend', handleRelease);
})();
</script>
<!-- Sovereign AIRA AI API Provisioning & OTP Controller -->
<script>
let apiOtpHash = null;
let apiVerifiedProof = null;
let apiVerifiedEmail = null;
let apiOtpTimerInterval = null;
const API_MODEL_PRICES = {
"aira-flash-1.5": { tier: "free", price: 0, label: "Aira Flash 1.5", desc: "Zero cost • Instant API key generation" },
"aira-flash-lite": { tier: "free", price: 0, label: "Aira Flash Lite", desc: "Zero cost • Instant high-speed inference" },
"aira-3-ultra": { tier: "pro", price: 499, label: "Aira 3 Ultra (Engine v3.6)", desc: "₹499/mo • Multimodal Flagship Intelligence" },
"aira-deepmind": { tier: "pro", price: 799, label: "AiraDeepMind 550B MoE", desc: "₹799/mo • 550B MoE Swarm Deep Reasoning" },
"aira-cyber-defender": { tier: "pro", price: 999, label: "Aira Cyber Defender AI", desc: "₹999/mo • Autonomous 7B Cybersecurity Core" }
};
function updateApiModelDetails() {
const select = document.getElementById("api-model-select");
if (!select) return;
const val = select.value;
const info = API_MODEL_PRICES[val] || API_MODEL_PRICES["aira-flash-1.5"];
const tierName = document.getElementById("api-tier-name");
const tierDesc = document.getElementById("api-tier-desc");
const tierPrice = document.getElementById("api-tier-price");
const tierIcon = document.getElementById("api-tier-icon");
const sliderText = document.getElementById("api-slider-text");
if (info.tier === "free") {
tierName.textContent = "Free Community Access";
tierDesc.textContent = info.desc;
tierPrice.innerHTML = `<span class="text-sm font-extrabold text-emerald-400 font-mono">&#8377;0</span><span class="text-[10px] text-slate-400 block">Forever Free</span>`;
tierIcon.className = "w-7 h-7 rounded-lg bg-emerald-500/20 text-emerald-400 flex items-center justify-center font-bold text-sm";
tierIcon.innerHTML = `<i class="fas fa-bolt text-xs"></i>`;
sliderText.innerHTML = `Slide to Generate Free API Key <span class="ml-2">&rarr;</span>`;
} else {
tierName.textContent = "Sovereign Flagship Subscription";
tierDesc.textContent = info.desc;
tierPrice.innerHTML = `<span class="text-sm font-extrabold text-cyan-400 font-mono">&#8377;${info.price}</span><span class="text-[10px] text-slate-400 block">/ month</span>`;
tierIcon.className = "w-7 h-7 rounded-lg bg-cyan-500/20 text-cyan-400 flex items-center justify-center font-bold text-sm";
tierIcon.innerHTML = `<i class="fas fa-crown text-xs"></i>`;
sliderText.innerHTML = `Slide to Subscribe &bull; &#8377;${info.price}/mo <span class="ml-2">&rarr;</span>`;
}
}
// 1. Send OTP via noreply@airaaigroup.in
async function sendApiOtp() {
const emailInput = document.getElementById("api-email");
const email = emailInput.value.trim().toLowerCase();
const verifyBtn = document.getElementById("api-verify-btn");
const feedback = document.getElementById("api-otp-feedback");
if (!email || !email.includes("@") || !email.includes(".")) {
alert("Please enter a valid developer email address.");
emailInput.focus();
return;
}
const originalBtnHtml = verifyBtn.innerHTML;
verifyBtn.disabled = true;
verifyBtn.innerHTML = `<i class="fas fa-spinner fa-spin text-xs"></i> Sending...`;
try {
const res = await fetch("/api/otp", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ action: "send", email })
});
const data = await res.json();
if (res.ok && data.success) {
apiOtpHash = data.otpHash;
document.getElementById("api-otp-container").classList.remove("hidden");
feedback.innerHTML = `<span class="text-emerald-400"><i class="fas fa-check-circle"></i> Verification code sent to <strong>${email}</strong> via noreply@airaaigroup.in!</span>`;
startApiOtpCountdown(600); // 10 minutes
document.getElementById("api-otp-input").focus();
} else {
alert(data.error || "Failed to send verification email. Please try again.");
}
} catch (err) {
console.error("[OTP Send Error]:", err);
alert("Network error while dispatching verification code. Please try again.");
} finally {
verifyBtn.disabled = false;
verifyBtn.innerHTML = originalBtnHtml;
}
}
function startApiOtpCountdown(durationSec) {
clearInterval(apiOtpTimerInterval);
let rem = durationSec;
const timerEl = document.getElementById("api-otp-countdown");
apiOtpTimerInterval = setInterval(() => {
if (rem <= 0) {
clearInterval(apiOtpTimerInterval);
timerEl.textContent = "Expired";
return;
}
rem--;
const m = Math.floor(rem / 60);
const s = rem % 60;
timerEl.textContent = `${m}:${s < 10 ? '0' : ''}${s}`;
}, 1000);
}
// 2. Verify OTP
async function verifyApiOtp() {
const email = document.getElementById("api-email").value.trim().toLowerCase();
const otpInput = document.getElementById("api-otp-input");
const otp = otpInput.value.trim();
const confirmBtn = document.getElementById("api-otp-confirm-btn");
const feedback = document.getElementById("api-otp-feedback");
if (!otp || otp.length < 6) {
alert("Please enter the complete 6-digit verification code.");
otpInput.focus();
return;
}
confirmBtn.disabled = true;
confirmBtn.innerHTML = `<i class="fas fa-spinner fa-spin text-xs"></i>`;
try {
const res = await fetch("/api/otp", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ action: "verify", email, otp, otpHash: apiOtpHash })
});
const data = await res.json();
if (res.ok && data.verified) {
apiVerifiedProof = data.proof;
apiVerifiedEmail = email;
clearInterval(apiOtpTimerInterval);
// Lock email input
document.getElementById("api-email").readOnly = true;
document.getElementById("api-email").classList.add("bg-slate-900/50", "text-slate-400");
// Update verify button to Verified badge
const verifyBtn = document.getElementById("api-verify-btn");
verifyBtn.className = "px-4 py-3 bg-emerald-600/30 text-emerald-400 border border-emerald-500/40 font-bold text-xs rounded-xl flex items-center gap-1.5 cursor-default";
verifyBtn.innerHTML = `<i class="fas fa-check-circle"></i> Verified`;
verifyBtn.disabled = true;
document.getElementById("api-verified-status").innerHTML = `<span class="text-emerald-400 font-bold"><i class="fas fa-check-circle"></i> Email Verified</span>`;
document.getElementById("api-otp-container").classList.add("hidden");
} else {
feedback.innerHTML = `<span class="text-rose-400"><i class="fas fa-triangle-exclamation"></i> ${data.error || "Invalid code"}</span>`;
}
} catch (err) {
console.error("[OTP Verify Error]:", err);
feedback.innerHTML = `<span class="text-rose-400">Verification error. Please retry.</span>`;
} finally {
confirmBtn.disabled = false;
confirmBtn.innerHTML = `<i class="fas fa-check text-xs"></i> Confirm Code`;
}
}
// 3. Slide Widget Handler for API Key Generation
(function initApiSlider() {
const slider = document.getElementById('api-slider');
const thumb = document.getElementById('api-thumb');
const fill = document.getElementById('api-fill');
const text = document.getElementById('api-slider-text');
if (!slider || !thumb || !fill) return;
let isDragging = false;
let startX = 0;
let isProcessing = false;
const getMaxX = () => slider.offsetWidth - 52;
function onStart(clientX) {
if (isProcessing) return;
isDragging = true;
startX = clientX - thumb.offsetLeft;
thumb.style.transition = 'none';
fill.style.transition = 'none';
}
function onMove(clientX) {
if (!isDragging || isProcessing) return;
const maxX = getMaxX();
let left = clientX - startX;
left = Math.max(4, Math.min(left, maxX));
thumb.style.left = left + 'px';
fill.style.width = (left + 24) + 'px';
text.style.opacity = Math.max(0, 1 - (left / (maxX * 0.7)));
if (left >= maxX - 4) {
isDragging = false;
triggerApiAction();
}
}
function onEnd() {
if (!isDragging || isProcessing) return;
isDragging = false;
resetSlider();
}
function resetSlider() {
thumb.style.transition = 'left 0.3s ease-out';
fill.style.transition = 'width 0.3s ease-out';
thumb.style.left = '4px';
fill.style.width = '0px';
text.style.opacity = '1';
}
// Mouse events
thumb.addEventListener('mousedown', (e) => onStart(e.clientX));
window.addEventListener('mousemove', (e) => onMove(e.clientX));
window.addEventListener('mouseup', onEnd);
// Touch events
thumb.addEventListener('touchstart', (e) => onStart(e.touches[0].clientX), { passive: true });
window.addEventListener('touchmove', (e) => onMove(e.touches[0].clientX), { passive: true });
window.addEventListener('touchend', onEnd);
async function triggerApiAction() {
const keyName = document.getElementById("api-key-name").value.trim() || "Default Client";
const model = document.getElementById("api-model-select").value;
const expiry = document.getElementById("api-expiry-select").value;
const email = document.getElementById("api-email").value.trim().toLowerCase();
if (!apiVerifiedProof || apiVerifiedEmail !== email) {
alert("Please verify your email address using the 'Verify Email' button and enter the 6-digit OTP first!");
resetSlider();
document.getElementById("api-email").focus();
return;
}
const modelInfo = API_MODEL_PRICES[model] || API_MODEL_PRICES["aira-flash-1.5"];
if (modelInfo.tier === "pro") {
// Paid Model -> Open Payment Gateway Modal
openApiPaymentModal(model, modelInfo);
resetSlider();
return;
}
// Free Model -> Direct Generation
isProcessing = true;
text.textContent = "Generating Key...";
thumb.innerHTML = `<i class="fas fa-spinner fa-spin text-xs"></i>`;
try {
const res = await fetch("/api/generate-key", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
keyName,
model,
expiry,
email,
proof: apiVerifiedProof
})
});
const data = await res.json();
if (res.ok && data.success) {
revealGeneratedApiKey(data);
} else {
alert(data.error || "Failed to generate API key.");
}
} catch (err) {
console.error("[Generate Key Error]:", err);
alert("Network error while generating API key.");
} finally {
isProcessing = false;
thumb.innerHTML = `<i class="fas fa-arrow-right text-xs"></i>`;
resetSlider();
}
}
})();
function revealGeneratedApiKey(data) {
const box = document.getElementById("api-result-box");
document.getElementById("api-generated-key-display").textContent = data.apiKey;
document.getElementById("api-result-model-text").textContent = data.model;
document.getElementById("api-result-expiry-text").textContent = data.expiryDate;
document.getElementById("api-result-tier-pill").textContent = data.tier.toUpperCase() + " ACTIVE";
box.classList.remove("hidden");
box.scrollIntoView({ behavior: "smooth", block: "nearest" });
}
function copyGeneratedApiKey() {
const key = document.getElementById("api-generated-key-display").textContent;
const btn = document.getElementById("api-copy-key-btn");
navigator.clipboard.writeText(key).then(() => {
const original = btn.innerHTML;
btn.innerHTML = `<i class="fas fa-check text-xs"></i> Copied!`;
btn.className = "px-3 py-1.5 bg-cyan-600 text-white font-bold text-[11px] rounded-lg transition flex items-center gap-1 flex-shrink-0";
setTimeout(() => {
btn.innerHTML = original;
btn.className = "px-3 py-1.5 bg-emerald-600 hover:bg-emerald-500 text-white font-bold text-[11px] rounded-lg transition flex items-center gap-1 flex-shrink-0";
}, 2500);
});
}
function copyApiCurlCode() {
const code = document.getElementById("api-curl-sample").innerText;
const btn = document.getElementById("copy-curl-btn");
navigator.clipboard.writeText(code).then(() => {
btn.innerHTML = `<i class="fas fa-check text-emerald-400"></i> Copied`;
setTimeout(() => {
btn.innerHTML = `<i class="far fa-copy"></i> Copy`;
}, 2000);
});
}
// 4. Paid Flagship Payment Modal Functions
let activePaidModel = null;
let activePaidInfo = null;
function openApiPaymentModal(model, info) {
activePaidModel = model;
activePaidInfo = info;
document.getElementById("payment-modal-model-name").textContent = `${info.label} Monthly Subscription`;
document.getElementById("payment-modal-price").innerHTML = `&#8377;${info.price}`;
// Update QR Code
const qrUrl = `https://api.qrserver.com/v1/create-qr-code/?size=140x140&data=${encodeURIComponent(`upi://pay?pa=adameehan34@okaxis&pn=Aira Group of Technology&am=${info.price}&cu=INR`)}`;
document.getElementById("upi-qr-image").src = qrUrl;
document.getElementById("api-payment-modal").classList.remove("hidden");
}
function closeApiPaymentModal() {
document.getElementById("api-payment-modal").classList.add("hidden");
}
function initiateRazorpayPayment() {
if (!activePaidInfo) return;
const email = document.getElementById("api-email").value.trim().toLowerCase();
const keyName = document.getElementById("api-key-name").value.trim() || "Pro API Client";
const options = {
key: window.RAZORPAY_KEY_ID || "rzp_live_AiraGroup",
amount: activePaidInfo.price * 100, // paise
currency: "INR",
name: "Aira Group of Technology",
description: `AIRA AI API Monthly Subscription - ${activePaidInfo.label}`,
image: "assets/logo.png",
prefill: {
name: keyName,
email: email
},
theme: {
color: "#0a2342"
},
handler: function(response) {
completePaidKeyGeneration(response.razorpay_payment_id || "rzp_paid_" + Date.now());
}
};
if (typeof Razorpay !== "undefined") {
try {
const rzp = new Razorpay(options);
rzp.on('payment.failed', function (resp){
alert("Payment failed or cancelled: " + resp.error.description);
});
rzp.open();
} catch(e) {
console.warn("Razorpay standard modal popup fallback:", e);
alert("Razorpay payment gateway initialized. You may also pay directly via UPI below!");
}
} else {
alert("Razorpay SDK loading. You can also pay directly via UPI QR below!");
}
}
async function submitUpiPaymentVerification() {
const refInput = document.getElementById("upi-ref-input");
const ref = refInput.value.trim();
if (!ref || ref.length < 6) {
alert("Please enter the UPI Reference / UTR Number or Transaction ID.");
refInput.focus();
return;
}
const confirmBtn = document.getElementById("upi-confirm-btn");
confirmBtn.disabled = true;
confirmBtn.innerHTML = `<i class="fas fa-spinner fa-spin text-xs"></i> Verifying...`;
await completePaidKeyGeneration("upi_ref_" + ref);
confirmBtn.disabled = false;
confirmBtn.innerHTML = `Activate Key`;
}
async function completePaidKeyGeneration(paymentId) {
const keyName = document.getElementById("api-key-name").value.trim() || "Pro Client";
const model = activePaidModel || document.getElementById("api-model-select").value;
const expiry = document.getElementById("api-expiry-select").value;
const email = document.getElementById("api-email").value.trim().toLowerCase();
try {
const res = await fetch("/api/generate-key", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
keyName,
model,
expiry,
email,
proof: apiVerifiedProof,
paymentId
})
});
const data = await res.json();
if (res.ok && data.success) {
closeApiPaymentModal();
revealGeneratedApiKey(data);
} else {
alert(data.error || "Payment verification failed.");
}
} catch (err) {
console.error("[Paid Key Generation Error]:", err);
alert("Network error while generating API key.");
}
}
</script>
</body>
</html>