Create message
Deprecated
client.beta.threads.messages.create(stringthreadID, MessageCreateParams { content, role, attachments, metadata } body, RequestOptionsoptions?): Message { id, assistant_id, attachments, 11 more }
POST/threads/{thread_id}/messages
Create message
import OpenAI from "openai";
const openai = new OpenAI();
async function main() {
const threadMessages = await openai.beta.threads.messages.create(
"thread_abc123",
{ role: "user", content: "How does AI work? Explain it in simple terms." }
);
console.log(threadMessages);
}
main();{
"id": "msg_abc123",
"object": "thread.message",
"created_at": 1713226573,
"assistant_id": null,
"thread_id": "thread_abc123",
"run_id": null,
"role": "user",
"content": [
{
"type": "text",
"text": {
"value": "How does AI work? Explain it in simple terms.",
"annotations": []
}
}
],
"attachments": [],
"metadata": {}
}
Returns Examples
{
"id": "msg_abc123",
"object": "thread.message",
"created_at": 1713226573,
"assistant_id": null,
"thread_id": "thread_abc123",
"run_id": null,
"role": "user",
"content": [
{
"type": "text",
"text": {
"value": "How does AI work? Explain it in simple terms.",
"annotations": []
}
}
],
"attachments": [],
"metadata": {}
}