How to use openai API using javascript?

I want to use openai API but without node js. Is it possible? If yes, how can I do it? Thank You

Hi jtuluve. It’s definitely possible, but I would recommend using node js as there are many more resources out there should you ever get stuck.

Here’s an example of someone using NextJS and React to build their application.

1 Like

Hi Jtuluve,

This is my prompt that I tested in the playground and Codex gave me a 95% done code.

<!-- create a html web page that has input area for user to enter their requirement and API key to call OpenAI Codex to generate code for them.

The resposne from OpenAI Codex should be shown in a textarea on the web page.

Only HTML and Javascript can be used in the web page.-->

<!DOCTYPE html>

Go through contnet in the below link then you will understand how to use it.

If i understand well, you want to create a simple chatbot based on chatgpt using pure client javascript?
In case, see my github repository. Since the forum editor does not let me add links, look for the repository ‘VivacityGTP-Online’ by MisterCoder74

this also has context memory. if you change the model to ghatgpt-3.5turbo-16k you will have about 17000 chars for your interactions.
Please notice that you will have to insert your api key in this section:

headers: {
‘Content-Type’: ‘application/json’,
‘Authorization’: ‘Bearer yourapikeyhere
},

1 Like