Create message
Deprecated
beta.threads.messages.create(strthread_id, MessageCreateParams**kwargs) -> Message
POST/threads/{thread_id}/messages
Create a message.
Parameters
thread_id: str
metadata: Optional[Metadata]
Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.
Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
Returns
Create message
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
)
message = client.beta.threads.messages.create(
thread_id="thread_id",
content="string",
role="user",
)
print(message.id){
"id": "id",
"assistant_id": "assistant_id",
"attachments": [
{
"file_id": "file_id",
"tools": [
{
"type": "code_interpreter"
}
]
}
],
"completed_at": 0,
"content": [
{
"image_file": {
"file_id": "file_id",
"detail": "auto"
},
"type": "image_file"
}
],
"created_at": 0,
"incomplete_at": 0,
"incomplete_details": {
"reason": "content_filter"
},
"metadata": {
"foo": "string"
},
"object": "thread.message",
"role": "user",
"run_id": "run_id",
"status": "in_progress",
"thread_id": "thread_id"
}Returns Examples
{
"id": "id",
"assistant_id": "assistant_id",
"attachments": [
{
"file_id": "file_id",
"tools": [
{
"type": "code_interpreter"
}
]
}
],
"completed_at": 0,
"content": [
{
"image_file": {
"file_id": "file_id",
"detail": "auto"
},
"type": "image_file"
}
],
"created_at": 0,
"incomplete_at": 0,
"incomplete_details": {
"reason": "content_filter"
},
"metadata": {
"foo": "string"
},
"object": "thread.message",
"role": "user",
"run_id": "run_id",
"status": "in_progress",
"thread_id": "thread_id"
}