Learn Vue JS course Learn Javascript and Vue JS Learn VueJS course Learn VueJS Tutorial

AI Chat Bot with Vue.js and GPT-4

Your First Request to OpenAI API thumbnail image

Get access to the most comprehensive Vue.js video library in the world. Over 300 video lessons including the newest Vue 3 features.

Your First Request to OpenAI API

In this lesson, we perform the necessary “Hello world” step of any new technology by making our first request to the Open AI Chat API.

If you’re using the VS Code Rest client, here’s the setup for the request if you’d like to quickly copy paste.

POST https://api.openai.com/v1/chat/completions
Content-Type: application/json
Authorization: Bearer {{$dotenv NUXT_OPENAI_API_KEY}}

  "model": "gpt-3.5-turbo",
  "messages": [{"role": "user", "content": "Say this is a test!"}],
  "temperature": 0,
  "n": 1