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(conversation_id, **kwargs) -> ConversationItemList { data, first_id, has_more, 2 more }
POST/conversations/{conversation_id}/items

Create items in a conversation with the given ID.

ParametersExpand Collapse
conversation_id: String
items: Array[ResponseInputItem]

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

include: Array[ResponseIncludable]

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

ReturnsExpand Collapse
class ConversationItemList { data, first_id, has_more, 2 more }

A list of Conversation items.

data: Array[ConversationItem]

A list of conversation items.

first_id: String

The ID of the first item in the list.

has_more: bool

Whether there are more items available.

last_id: String

The ID of the last item in the list.

object: :list

The type of object returned, must be list.

Create items

require "openai"

openai = OpenAI::Client.new(api_key: "My API Key")

conversation_item_list = openai.conversations.items.create("conv_123", items: [{content: "string", role: :user, type: :message}])

puts(conversation_item_list)
{
  "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
}