Can't access openai.beta.assistants.create

Hi everyone. I am trying to create an assistant by assistant API. But it seems like the openai.beta doesn’t exist. I have checked if it’s problem with the set up but the openai.chat.completions run successfully.

Here is my code:

const assistant = await openai.beta.assistants.create({
    name: "math tutor",
    instructions: `You are a math tutor`,
    tools: [{ type: "code_interpreter" },
    model: "gpt-4-1106-preview"
});

And here is the error message

[0] const assistant = await openai.beta.assistants.create({
[0]                                     ^
[0] 
[0] TypeError: Cannot read properties of undefined (reading 'assistants')

Do you have the latest library from OpenAI?

same issue in my code @PaulBellow … with latest OpenAI and Node.js libraries

 const {OpenAI} = require ('openai');

//create OpenAI const
const openai = new OpenAI({
apiKey: "sk-8i4mGLctxxxxxxxxxxxxxc6RJaLa",

});
console.log("1. This is my openai object:", openai);

main();

async function main() {
  // Step 1: Create an Assistant
  const myAssistant = await openai.beta.assistants.create({
    model: "gpt-4",
    instructions:
      "You are a personal math tutor. When asked a question, write and run Python code to answer the question.",
    name: "Math Tutor",
    tools: [{ type: "code_interpreter" }],
  });
  console.log("This is the assistant object: ", myAssistant, "\n");


} //END

ERROR:

  const myAssistant = await openai.beta.assistants.create({
                                        ^

TypeError: Cannot read properties of undefined (reading ‘assistants’)

Any idea?

Thank you!

I executed “npm install --upgrade openai” and finally worked!

1 Like

Narrator: turns out, he wasn’t on the latest version

2 Likes