scrimba
AI Engineering
OpenAI's Assistants API
Run your assistant
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

AboutCommentsNotes
Run your assistant
Expand for more info
index.js
run
preview
console
import { openai } from './config.js';

// Assistant variables
const asstID = "asst_AlAOsigm1nQkGnahv2eMJBdK";
const threadID = "thread_XBZNFmOmZvmVWrIHCIfWBU2x";

// Create a message for the thread
async function createMessage() {
const threadMessages = await openai.beta.threads.messages.create(
threadID,
{ role: "user", content: "Can you recommend a comedy?" }
);
console.log(threadMessages);
}
Console
{id:
"msg_MZxitVXfpheAE5oIhoGFH4le"
, object:
"thread.message"
, created_at:
1699798922
, thread_id:
"thread_XBZNFmOmZvmVWrIHCIfWBU2x"
, role:
"user"
, content:
[
{type:
"text"
, text:
{value:
"Can you recommend a comedy?"
, annotations:
[]
}
}
]
, file_ids:
[]
, assistant_id:
null
, run_id:
null
, metadata:
{}
}
,
/index.html
-5:44