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
Theme

Threads

Build Assistants that can call models and use tools.

Create thread
Deprecated
POST
/threads
Create thread and run
Deprecated
POST
/threads/runs
Delete thread
Deprecated
DELETE
/threads/{thread_id}
Retrieve thread
Deprecated
GET
/threads/{thread_id}
Modify thread
Deprecated
POST
/threads/{thread_id}
Models
AssistantResponseFormatOption = "auto" or ResponseFormatText { type } or ResponseFormatJSONObject { type } or ResponseFormatJSONSchema { json_schema, type }

Specifies the format that the model must output. Compatible with GPT-4o, GPT-4 Turbo, and all GPT-3.5 Turbo models since gpt-3.5-turbo-1106.

Setting to { "type": "json_schema", "json_schema": {...} } enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the Structured Outputs guide.

Setting to { "type": "json_object" } enables JSON mode, which ensures the message the model generates is valid JSON.

Important: when using JSON mode, you must also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly “stuck” request. Also note that the message content may be partially cut off if finish_reason="length", which indicates the generation exceeded max_tokens or the conversation exceeded the max context length.

AssistantToolChoice object { type, function }

Specifies a tool the model should use. Use to force the model to call a specific tool.

AssistantToolChoiceFunction object { name }
name: string

The name of the function to call.

AssistantToolChoiceOption = "none" or "auto" or "required" or AssistantToolChoice { type, function }

Controls which (if any) tool is called by the model. none means the model will not call any tools and instead generates a message. auto is the default value and means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools before responding to the user. Specifying a particular tool like {"type": "file_search"} or {"type": "function", "function": {"name": "my_function"}} forces the model to call that tool.

Thread object { id, created_at, metadata, 2 more }

Represents a thread that contains messages.

ThreadDeleted object { id, deleted, object }

ThreadsMessages

Build Assistants that can call models and use tools.

Create message
Deprecated
POST
/threads/{thread_id}/messages
Delete message
Deprecated
DELETE
/threads/{thread_id}/messages/{message_id}
List messages
Deprecated
GET
/threads/{thread_id}/messages
Retrieve message
Deprecated
GET
/threads/{thread_id}/messages/{message_id}
Modify message
Deprecated
POST
/threads/{thread_id}/messages/{message_id}
Models
FileCitationAnnotation object { end_index, file_citation, start_index, 2 more }

A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the “file_search” tool to search files.

FileCitationDeltaAnnotation object { index, type, end_index, 3 more }

A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the “file_search” tool to search files.

FilePathAnnotation object { end_index, file_path, start_index, 2 more }

A URL for the file that’s generated when the assistant used the code_interpreter tool to generate a file.

FilePathDeltaAnnotation object { index, type, end_index, 3 more }

A URL for the file that’s generated when the assistant used the code_interpreter tool to generate a file.

ImageFile object { file_id, detail }
ImageFileContentBlock object { image_file, type }

References an image File in the content of a message.

image_file: ImageFile { file_id, detail }
type: "image_file"

Always image_file.

ImageFileDelta object { detail, file_id }
ImageFileDeltaBlock object { index, type, image_file }

References an image File in the content of a message.

ImageURL object { url, detail }
ImageURLContentBlock object { image_url, type }

References an image URL in the content of a message.

image_url: ImageURL { url, detail }
type: "image_url"

The type of the content part.

ImageURLDelta object { detail, url }
ImageURLDeltaBlock object { index, type, image_url }

References an image URL in the content of a message.

Message object { id, assistant_id, attachments, 11 more }

Represents a message within a thread.

MessageDeleted object { id, deleted, object }
MessageDelta object { content, role }

The delta containing the fields that have changed on the Message.

MessageDeltaEvent object { id, delta, object }

Represents a message delta i.e. any changed fields on a message during streaming.

RefusalContentBlock object { refusal, type }

The refusal content generated by the assistant.

refusal: string
type: "refusal"

Always refusal.

RefusalDeltaBlock object { index, type, refusal }

The refusal content that is part of a message.

Text object { annotations, value }
TextContentBlock object { text, type }

The text content that is part of a message.

text: Text { annotations, value }
type: "text"

Always text.

TextContentBlockParam object { text, type }

The text content that is part of a message.

text: string

Text content to be sent to the model

type: "text"

Always text.

TextDelta object { annotations, value }
TextDeltaBlock object { index, type, text }

The text content that is part of a message.

ThreadsRuns

Build Assistants that can call models and use tools.

Cancel a run
Deprecated
POST
/threads/{thread_id}/runs/{run_id}/cancel
Create run
Deprecated
POST
/threads/{thread_id}/runs
List runs
Deprecated
GET
/threads/{thread_id}/runs
Retrieve run
Deprecated
GET
/threads/{thread_id}/runs/{run_id}
Submit tool outputs to run
Deprecated
POST
/threads/{thread_id}/runs/{run_id}/submit_tool_outputs
Modify run
Deprecated
POST
/threads/{thread_id}/runs/{run_id}
Models
RequiredActionFunctionToolCall object { id, function, type }

Tool call objects

Run object { id, assistant_id, cancelled_at, 24 more }

Represents an execution run on a thread.

ThreadsRunsSteps

Build Assistants that can call models and use tools.

List run steps
Deprecated
GET
/threads/{thread_id}/runs/{run_id}/steps
Retrieve run step
Deprecated
GET
/threads/{thread_id}/runs/{run_id}/steps/{step_id}
Models
CodeInterpreterLogs object { index, type, logs }

Text output from the Code Interpreter tool call as part of a run step.

CodeInterpreterOutputImage object { index, type, image }
CodeInterpreterToolCall object { id, code_interpreter, type }

Details of the Code Interpreter tool call the run step was involved in.

CodeInterpreterToolCallDelta object { index, type, id, code_interpreter }

Details of the Code Interpreter tool call the run step was involved in.

FileSearchToolCall object { id, file_search, type }
FileSearchToolCallDelta object { file_search, index, type, id }
FunctionToolCall object { id, function, type }
FunctionToolCallDelta object { index, type, id, function }
MessageCreationStepDetails object { message_creation, type }

Details of the message creation by the run step.

RunStep object { id, assistant_id, cancelled_at, 13 more }

Represents a step in execution of a run.

RunStepDeltaEvent object { id, delta, object }

Represents a run step delta i.e. any changed fields on a run step during streaming.

RunStepDeltaMessageDelta object { type, message_creation }

Details of the message creation by the run step.

RunStepInclude = "step_details.tool_calls[*].file_search.results[*].content"
ToolCallDeltaObject object { type, tool_calls }

Details of the tool call.

ToolCallsStepDetails object { tool_calls, type }

Details of the tool call.