Create message (v1)
POST
https://api.openai.com/v1/threads/thread_abc123/messagesRequest
Header Params
Content-Type
string
required
Example:
application/json
Authorization
string
required
Example:
Bearer $OPENAI_API_KEY
OpenAI-Beta
string
required
Example:
assistants=v1
Body Params application/json
role
string
required
The role of the entity that is creating the message. Allowed values include:
user
: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages.assistant
: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation.
content
string
required
The content of the message.
Example
{
"role": "user",
"content": "How does AI work? Explain it in simple terms."
}
Request samples
Responses
Success(200)
HTTP Code: 200
Content Type : JSONapplication/json
Data Schema
id
string
required
object
string
required
created_at
integer
required
thread_id
string
required
role
string
required
content
array [object {2}]
required
type
string
optional
text
object
optional
file_ids
array[string]
required
assistant_id
null
required
run_id
null
required
metadata
object
required
Example
{
"id": "msg_abc123",
"object": "thread.message",
"created_at": 1699017614,
"thread_id": "thread_abc123",
"role": "user",
"content": [
{
"type": "text",
"text": {
"value": "How does AI work? Explain it in simple terms.",
"annotations": []
}
}
],
"file_ids": [],
"assistant_id": null,
"run_id": null,
"metadata": {}
}
Last modified: 14 days ago