OpenAI (opens new window) has made it really easy to get started using ChatGPT (opens new window) and provides documentation (opens new window) and libraries (opens new window) for a wide variety of languages (Python, Javacript, C#/.NET, Crystal, Go, Java, Kotlin, PHP, R, Ruby, Scala, Swift, Unity, Unreal Engine). You'll need to signup (opens new window) for an account and then create an API key. Once you have an API key, you can start making requests to ChatGPT and then the possibilities are limitless as far as what you can do with it.
$ npm install openai
Then create a file
index.js with the following code:
You'll need to update the following placeholders:
[PUT YOUR API KEY HERE] and
[ENTER PROMPT FOR CHATGPT HERE] with your API key and whatever prompt you want to send to ChatGPT. Then you'll run the following in your terminal:
$ node index.js
And congratulations, you have now written your first piece of code communicating with ChatGPT.