Assistants
Build Assistants that can call models and use tools.
ModelsExpand Collapse
Assistant = object { id, created_at, description, 10 more } Represents an assistant that can call the model and use tools.
Represents an assistant that can call the model and use tools.
The description of the assistant. The maximum length is 512 characters.
The system instructions that the assistant uses. The maximum length is 256,000 characters.
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.
ID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them.
tools: array of CodeInterpreterTool { type } or FileSearchTool { type, file_search } or FunctionTool { function, type } A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types code_interpreter, file_search, or function.
A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types code_interpreter, file_search, or function.
FileSearchTool = object { type, file_search }
file_search: optional object { max_num_results, ranking_options } Overrides for the file search tool.
Overrides for the file search tool.
The maximum number of results the file search tool should output. The default is 20 for gpt-4* models and 5 for gpt-3.5-turbo. This number should be between 1 and 50 inclusive.
Note that the file search tool may output fewer than max_num_results results. See the file search tool documentation for more information.
ranking_options: optional object { score_threshold, ranker } The ranking options for the file search. If not specified, the file search tool will use the auto ranker and a score_threshold of 0.
See the file search tool documentation for more information.
The ranking options for the file search. If not specified, the file search tool will use the auto ranker and a score_threshold of 0.
See the file search tool documentation for more information.
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.
What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
tool_resources: optional object { code_interpreter, file_search } A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the code_interpreter tool requires a list of file IDs, while the file_search tool requires a list of vector store IDs.
A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the code_interpreter tool requires a list of file IDs, while the file_search tool requires a list of vector store IDs.
code_interpreter: optional object { file_ids }
A list of file IDs made available to the `code_interpreter`` tool. There can be a maximum of 20 files associated with the tool.
file_search: optional object { vector_store_ids }
The ID of the vector store attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.
An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
We generally recommend altering this or temperature but not both.
AssistantStreamEvent = object { data, event, enabled } or object { data, event } or object { data, event } or 22 moreRepresents an event emitted when streaming a Run.
Each event in a server-sent events stream has an event and data property:
event: thread.created
data: {"id": "thread_123", "object": "thread", ...}
We emit events whenever a new object is created, transitions to a new state, or is being
streamed in parts (deltas). For example, we emit thread.run.created when a new run
is created, thread.run.completed when a run completes, and so on. When an Assistant chooses
to create a message during a run, we emit a thread.message.created event, a
thread.message.in_progress event, many thread.message.delta events, and finally a
thread.message.completed event.
We may add additional events over time, so we recommend handling unknown events gracefully
in your code. See the Assistants API quickstart to learn how to
integrate the Assistants API with streaming.
Represents an event emitted when streaming a Run.
Each event in a server-sent events stream has an event and data property:
event: thread.created
data: {"id": "thread_123", "object": "thread", ...}We emit events whenever a new object is created, transitions to a new state, or is being
streamed in parts (deltas). For example, we emit thread.run.created when a new run
is created, thread.run.completed when a run completes, and so on. When an Assistant chooses
to create a message during a run, we emit a thread.message.created event, a
thread.message.in_progress event, many thread.message.delta events, and finally a
thread.message.completed event.
We may add additional events over time, so we recommend handling unknown events gracefully in your code. See the Assistants API quickstart to learn how to integrate the Assistants API with streaming.
object { data, event, enabled } Occurs when a new thread is created.
Occurs when a new thread is created.
object { data, event } Occurs when a new run is created.
Occurs when a new run is created.
object { data, event } Occurs when a run moves to a queued status.
Occurs when a run moves to a queued status.
object { data, event } Occurs when a run moves to an in_progress status.
Occurs when a run moves to an in_progress status.
object { data, event } Occurs when a run moves to a requires_action status.
Occurs when a run moves to a requires_action status.
object { data, event } Occurs when a run is completed.
Occurs when a run is completed.
object { data, event } Occurs when a run ends with status incomplete.
Occurs when a run ends with status incomplete.
object { data, event } Occurs when a run fails.
Occurs when a run fails.
object { data, event } Occurs when a run moves to a cancelling status.
Occurs when a run moves to a cancelling status.
object { data, event } Occurs when a run is cancelled.
Occurs when a run is cancelled.
object { data, event } Occurs when a run expires.
Occurs when a run expires.
object { data, event } Occurs when a run step is created.
Occurs when a run step is created.
object { data, event } Occurs when a run step moves to an in_progress state.
Occurs when a run step moves to an in_progress state.
object { data, event } Occurs when parts of a run step are being streamed.
Occurs when parts of a run step are being streamed.
object { data, event } Occurs when a run step is completed.
Occurs when a run step is completed.
object { data, event } Occurs when a run step fails.
Occurs when a run step fails.
object { data, event } Occurs when a run step is cancelled.
Occurs when a run step is cancelled.
object { data, event } Occurs when a run step expires.
Occurs when a run step expires.
object { data, event } Occurs when a message is created.
Occurs when a message is created.
object { data, event } Occurs when a message moves to an in_progress state.
Occurs when a message moves to an in_progress state.
object { data, event } Occurs when parts of a Message are being streamed.
Occurs when parts of a Message are being streamed.
object { data, event } Occurs when a message is completed.
Occurs when a message is completed.
object { data, event } Occurs when a message ends before it is completed.
Occurs when a message ends before it is completed.
ErrorEvent = object { data, event } Occurs when an error occurs. This can happen due to an internal server error or a timeout.
Occurs when an error occurs. This can happen due to an internal server error or a timeout.
FileSearchTool = object { type, file_search }
file_search: optional object { max_num_results, ranking_options } Overrides for the file search tool.
Overrides for the file search tool.
The maximum number of results the file search tool should output. The default is 20 for gpt-4* models and 5 for gpt-3.5-turbo. This number should be between 1 and 50 inclusive.
Note that the file search tool may output fewer than max_num_results results. See the file search tool documentation for more information.
ranking_options: optional object { score_threshold, ranker } The ranking options for the file search. If not specified, the file search tool will use the auto ranker and a score_threshold of 0.
See the file search tool documentation for more information.
The ranking options for the file search. If not specified, the file search tool will use the auto ranker and a score_threshold of 0.
See the file search tool documentation for more information.
MessageStreamEvent = object { data, event } or object { data, event } or object { data, event } or 2 moreOccurs when a message is created.
Occurs when a message is created.
object { data, event } Occurs when a message is created.
Occurs when a message is created.
object { data, event } Occurs when a message moves to an in_progress state.
Occurs when a message moves to an in_progress state.
object { data, event } Occurs when parts of a Message are being streamed.
Occurs when parts of a Message are being streamed.
object { data, event } Occurs when a message is completed.
Occurs when a message is completed.
RunStepStreamEvent = object { data, event } or object { data, event } or object { data, event } or 4 moreOccurs when a run step is created.
Occurs when a run step is created.
object { data, event } Occurs when a run step is created.
Occurs when a run step is created.
object { data, event } Occurs when a run step moves to an in_progress state.
Occurs when a run step moves to an in_progress state.
object { data, event } Occurs when parts of a run step are being streamed.
Occurs when parts of a run step are being streamed.
object { data, event } Occurs when a run step is completed.
Occurs when a run step is completed.
object { data, event } Occurs when a run step fails.
Occurs when a run step fails.
object { data, event } Occurs when a run step is cancelled.
Occurs when a run step is cancelled.
RunStreamEvent = object { data, event } or object { data, event } or object { data, event } or 7 moreOccurs when a new run is created.
Occurs when a new run is created.
object { data, event } Occurs when a new run is created.
Occurs when a new run is created.
object { data, event } Occurs when a run moves to a queued status.
Occurs when a run moves to a queued status.
object { data, event } Occurs when a run moves to an in_progress status.
Occurs when a run moves to an in_progress status.
object { data, event } Occurs when a run moves to a requires_action status.
Occurs when a run moves to a requires_action status.
object { data, event } Occurs when a run is completed.
Occurs when a run is completed.
object { data, event } Occurs when a run ends with status incomplete.
Occurs when a run ends with status incomplete.
object { data, event } Occurs when a run fails.
Occurs when a run fails.
object { data, event } Occurs when a run moves to a cancelling status.
Occurs when a run moves to a cancelling status.
object { data, event } Occurs when a run is cancelled.
Occurs when a run is cancelled.