How do I resolve this error with Typescript Property 'beta' does not exist on type 'OpenAI'

The openai library reports Typescript errors but I am following the official documentation on Node.

import OpenAI from "openai";

const openai = new OpenAI();

async function main() {
  const messageThread = await openai.beta.threads.create({
    messages: [
        role: "user",
        content: "Hello, what is AI?",
        file_ids: ["file-abc123"],
        role: "user",
        content: "How does AI work? Explain it in simple terms.",


1 Like