Sample - OpenAI API
POST/conversations

Create a conversation

Creates a conversation with optional metadata and initial context items. Supply items when you want to establish conversation context at creation time, with no more than 20 items in the request. The response includes the new conversation's identifier and creation timestamp.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

2 body fields

Optional conversation initialization data containing metadata and up to 20 initial items.

metadataobject | nulloptional
Up to 16 key-value pairs to associate with the conversation, or null.
itemsarray<InputMessage>optional
Initial items to include in the conversation context. You may provide up to 20 items or null.

2 status codes
200Returns the created conversation with its identifier, `conversation` object type, metadata, and Unix creation timestamp.
idstringrequired
The unique ID of the conversation.
objectstringrequired
The object type, which is always `conversation`.
Allowed:conversationDefault:conversation
metadataunknownrequired
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.
created_atintegerrequired
The time at which the conversation was created, measured in seconds since the Unix epoch.
429Returned when the request was rejected because a rate limit was exceeded.
errorobjectrequired

Error handling

items may contain no more than 20 initial items, and metadata supports up to 16 key-value pairs or null. A 429 is returned when the request exceeds the rate limit.