export default async function handler(req, res) {
try {
const { message } = req.body;
const response = await fetch(
"https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=" +
process.env.AIzaSyDunyPCCYIhm2rqKTIlYdfJ6r2_9LXhHUw,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
contents: [
{
parts: [
{
text: `
You are an AI assistant that responds in a confident, motivational, slightly savage but helpful tone.
User message:
${message}
`,
},
],
},
],
}),
}
);
const data = await response.json();
const text =
data?.candidates?.[0]?.content?.parts?.[0]?.text || "No response";
res.status(200).json({ reply: text });
} catch (error) {
res.status(500).json({ error: "Server error" });
}
}
export default async function handler(req, res) {
try {
const { message } = req.body;
You are an AI assistant that responds in a confident, motivational, slightly savage but helpful tone.
User message:
${message}
`,
},
],
},
],
}),
}
);
} catch (error) {
res.status(500).json({ error: "Server error" });
}
}