const prompt = "مرحبا ChatGPT، هل يمكنك مساعدتي في تحويل زري؟"; const apiKey = "YOUR_API_KEY"; const apiUrl = "https://api.openai.com/v1/engines/davinci/completions"; const headers = { "Content-Type": "application/json", "Authorization": `Bearer ${apiKey}` }; const data = { prompt, max_tokens: 60, n: 1, stop: "\n" }; const requestOptions = { method: "POST", headers, body: JSON.stringify(data) }; fetch(apiUrl, requestOptions) .then(response => response.json()) .then(data => { const text = data.choices[0].text.trim(); const button = document.getElementById("myButton"); button.innerHTML = text; button.onclick = function() { alert("تم النقر على الزر!"); } }) .catch(error => console.log(error));