Threads
Build Assistants that can call models and use tools.
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.
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.
Specifies a tool the model should use. Use to force the model to call a specific tool.
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.
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.
Represents a thread that contains messages.
ThreadsMessages
Build Assistants that can call models and use tools.
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.
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.
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.
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.
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 }
ImageFileDelta object { detail, file_id }
ImageFileDeltaBlock object { index, type, image_file } References an image File in the content of a message.
References an image File in the content of a message.
ImageURL object { url, detail }
ImageURLDelta object { detail, url }
Message object { id, assistant_id, attachments, 11 more } Represents a message within a thread.
Represents a message within a thread.
MessageDelta object { content, role } The delta containing the fields that have changed on the Message.
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.
Represents a message delta i.e. any changed fields on a message during streaming.
Text object { annotations, value }
TextDelta object { annotations, value }
ThreadsRuns
Build Assistants that can call models and use tools.
Models
RequiredActionFunctionToolCall object { id, function, type } Tool call objects
Tool call objects
Run object { id, assistant_id, cancelled_at, 24 more } Represents an execution run on a thread.
Represents an execution run on a thread.
ThreadsRunsSteps
Build Assistants that can call models and use tools.
Models
CodeInterpreterToolCall object { id, code_interpreter, type } Details of the Code Interpreter tool call the run step was involved in.
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.
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 }
RunStep object { id, assistant_id, cancelled_at, 13 more } Represents a step in execution of a run.
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.
Represents a run step delta i.e. any changed fields on a run step during streaming.
ToolCallDeltaObject object { type, tool_calls } Details of the tool call.
Details of the tool call.
ToolCallsStepDetails object { tool_calls, type } Details of the tool call.
Details of the tool call.