local function fetchGeminiResponse(prompt)
-- Replace 'YOUR_GEMINI_API_KEY_HERE' with your actual key from Google AI Studio
local apiKey = "AQ.Ab8RN6IgHqAUAEkE8LSI8cGgYbmJxYzBa5k3bvemjeMoRmlgGQ"
local url = "https://[Log in to view URL]" .. apiKey
local payload = HttpService:JSONEncode({
contents = {{
parts = {{text = prompt}}
}}
})
local success, response = pcall(function()
return request({
Url = url,
Method = "POST",
Headers = {["Content-Type"] = "application/json"},
Body = payload
})
end)
if success and response.Status == 200 then
local data = HttpService:JSONDecode(response.Body)
-- Parsing Google's specific JSON response structure
local reply = data.candidates[1].content.parts[1].text
return reply
else
return "Connection failed. Status code: " .. tostring(response and response.Status or "Unknown")
end
end
To embed this project on your website, copy the following code and paste it into your website's HTML: