Beta Assistants API ERROR

Hello everybody!

Have there been any changes regarding the use of beta assistants? Because yesterday I used it normally, today it is giving the following error: TypeError: Cannot read properties of undefined (reading 'assistants')

Below is a snippet of the code, thanks in advance!

const OpenAI = require('openai');
const secretKey = process.env.OPENAI_API_KEY;
const openai = new OpenAI({
  apiKey: secretKey,
});

async function newAssAndThr() {
  try {
    const assistant = await openai.beta.assistants.create({})
[...]

The Libraries for both the python and js were updated recently, might be worth checking that you have the latest.

2 Likes

I am using Node.js 4.20.1, which AFAIK is the most recent sdk version, and still seeing this error. Anyone has solved it?

Can you share a code snippet that is causing the error? It would be useful to help debug.

1 Like

Sure. I have tried quite a few variations, but I am down to basically using a copy and paste from the documentation:

const assistant = await openai.beta.assistants.create({
      name: "Math Tutor",
      instructions: "You are a personal math tutor. Write and run code to answer math questions.",
      tools: [{ type: "code_interpreter" }],
      model: "gpt-4-1106-preview"
    });

Also, this is how I am creating the openai instance:

const openai = axios.create({
  baseURL: 'https://api.openai.com',
  headers: {
    'Authorization': `Bearer ${process.env.OPENAI_API_KEY}`,
    'Content-Type': 'application/json'
  }
});

Ok. Things worked as soon as I changed the baseURL to

baseURL: 'https://api.openai.com/v1',

Interesting that I had not seen that in the documentation, but I might have missed.