Skip to content
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
Primary navigation

Create items

conversations.items.create(strconversation_id, ItemCreateParams**kwargs) -> ConversationItemList
POST/conversations/{conversation_id}/items

Create items in a conversation with the given ID.

ParametersExpand Collapse
conversation_id: str
items: Iterable[ResponseInputItemParam]

The items to add to the conversation. You may add up to 20 items at a time.

include: Optional[List[ResponseIncludable]]

Additional fields to include in the response. See the include parameter for listing Conversation items above for more information.

ReturnsExpand Collapse
class ConversationItemList: …

A list of Conversation items.

data: List[ConversationItem]

A list of conversation items.

first_id: str

The ID of the first item in the list.

has_more: bool

Whether there are more items available.

last_id: str

The ID of the last item in the list.

object: Literal["list"]

The type of object returned, must be list.

Create items

from openai import OpenAI
client = OpenAI()

items = client.conversations.items.create(
  "conv_123",
  items=[
    {
      "type": "message",
      "role": "user",
      "content": [{"type": "input_text", "text": "Hello!"}],
    },
    {
      "type": "message",
      "role": "user",
      "content": [{"type": "input_text", "text": "How are you?"}],
    }
  ],
)
print(items.data)
{
  "object": "list",
  "data": [
    {
      "type": "message",
      "id": "msg_abc",
      "status": "completed",
      "role": "user",
      "content": [
        {"type": "input_text", "text": "Hello!"}
      ]
    },
    {
      "type": "message",
      "id": "msg_def",
      "status": "completed",
      "role": "user",
      "content": [
        {"type": "input_text", "text": "How are you?"}
      ]
    }
  ],
  "first_id": "msg_abc",
  "last_id": "msg_def",
  "has_more": false
}
Returns Examples
{
  "object": "list",
  "data": [
    {
      "type": "message",
      "id": "msg_abc",
      "status": "completed",
      "role": "user",
      "content": [
        {"type": "input_text", "text": "Hello!"}
      ]
    },
    {
      "type": "message",
      "id": "msg_def",
      "status": "completed",
      "role": "user",
      "content": [
        {"type": "input_text", "text": "How are you?"}
      ]
    }
  ],
  "first_id": "msg_abc",
  "last_id": "msg_def",
  "has_more": false
}