// No backend (backend/gptApi.jsw)
import {fetch} from 'wix-fetch';
export async function getGPTResponse(prompt) {
const apiKey = "SUA_CHAVE_DE_API_OPENAI";
const response = await fetch("https://api.openai.com/v1/chat/completions", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${apiKey}`
},
body: JSON.stringify({
model: "gpt-4", // ou gpt-3.5-turbo
messages: [{ role: "user", content: prompt }],
max_tokens: 100,
})
});
const data = await response.json();
return data.choices[0].message.content;
}
top of page
bottom of page