Source: https://chat.openai.com/
API Key:
API url:
Ask Open AI ChatGPT
<!DOCTYPE html> <html> <head> <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/openai"></script> </head> <body> <p>Source: <a href="https://chat.openai.com/">https://chat.openai.com/</a></p> <p>API Key:<input type="text" id="openaiapikey" value="input your api key here"></p> <p>API url:<input type="text" id="openaiapiurl" value="https://api.openai.com/v1/completions"></p> <p>Ask Open AI ChatGPT</p> <textarea id="userinput" name="userinput" rows="4" cols="50"> </textarea> <button onclick="senduserinput()">Send</button> <div id="aichatresponse"></div> <script> async function sendMessage(message) { let API_KEY = document.getElementById("openaiapikey").value; let url = document.getElementById("openaiapiurl").value; const headers = { 'Content-Type': 'application/json', 'Authorization': `Bearer ${API_KEY}` }; const data = { prompt: message, temperature: 0.7, max_tokens: 256, top_p: 1, frequency_penalty: 0, presence_penalty: 0, model: 'text-davinci-003' // Use 'text-davinci-003' for GPT-3.5-turbo }; try { const response = await axios.post(url, data, { headers }); const reply = response.data.choices[0].text.trim(); return reply; } catch (error) { console.error('Error:', error.response.data); return error.response.data.error.message; } } async function senduserinput(){ let user_input = document.getElementById("userinput").value; let response = await sendMessage(user_input); document.getElementById("aichatresponse").innerHTML = response; } /* (async () => { while (true) { const user_input = prompt('User: '); const response = await sendMessage(user_input); console.log('ChatGPT: ' + response); } })(); */ </script> </body> </html>