const apiKey = 'open ai den aldığın api key';
const endpoint = 'https://api.openai.com/v1/engines/davinci-codex/completions';
document.getElementById('submitBtn').addEventListener('click', async function () {
const userText = document.getElementById('userInput').value;
const response = await fetch(endpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}`,
},
body: JSON.stringify({
prompt: userText,
max_tokens: 150,
}),
});
const data = await response.json();
const chatbotResponse = data.choices[0].text;
r
document.getElementById('chatbotOutput').innerText = chatbotResponse;
});