openai-node icon indicating copy to clipboard operation
openai-node copied to clipboard

Help! can not run the default example from npm

Open cu8code opened this issue 6 months ago • 1 comments

Confirm this is a Node library issue and not an underlying OpenAI API issue

  • [X] This is an issue with the Node library

Describe the bug

i tried to run the default example after installing the package and i get this error which is hard to belive image

my package.json

{
  "dependencies": {
    "@types/clipboardy": "^2.0.1",
    "@types/cors": "^2.8.17",
    "@types/fluent-ffmpeg": "^2.1.25",
    "cors": "^2.8.5",
    "fluent-ffmpeg": "^2.1.3",
    "form-data": "^4.0.0",
    "keydb": "^0.1.10",
    "openai": "^4.56.0"
  },
  "name": "blogforge",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "dev:f": "cd frontend && next dev",
    "dev:s": "cd server && ts-node src/index.ts"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "description": "",
  "workspaces": [
    "./frontend",
    "./share",
    "./server"
  ]
}

To Reproduce

install the openai package in your project

Code snippets

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env['OPENAI_API_KEY']!, // This is the default and can be omitted
});

async function main() {
  const chatCompletion = await client.chat.completions.create({
    messages: [{ role: 'user', content: 'Say this is a test' }],
    model: 'gpt-3.5-turbo',
  });
}

main();

OS

linux fedora

Node version

v20.12.2

Library version

^4.56.0

cu8code avatar Aug 22 '24 09:08 cu8code