Skip to content

Assistants

List assistants
Deprecated
beta.assistants.list(**kwargs) -> CursorPage<Assistant { id, created_at, description, 10 more } >
GET/assistants
Create assistant
Deprecated
beta.assistants.create(**kwargs) -> Assistant { id, created_at, description, 10 more }
POST/assistants
Retrieve assistant
Deprecated
beta.assistants.retrieve(assistant_id) -> Assistant { id, created_at, description, 10 more }
GET/assistants/{assistant_id}
Modify assistant
Deprecated
beta.assistants.update(assistant_id, **kwargs) -> Assistant { id, created_at, description, 10 more }
POST/assistants/{assistant_id}
Delete assistant
Deprecated
beta.assistants.delete(assistant_id) -> AssistantDeleted { id, deleted, object }
DELETE/assistants/{assistant_id}
ModelsExpand Collapse
class Assistant { id, created_at, description, 10 more }

Represents an assistant that can call the model and use tools.

id: String

The identifier, which can be referenced in API endpoints.

created_at: Integer

The Unix timestamp (in seconds) for when the assistant was created.

description: String

The description of the assistant. The maximum length is 512 characters.

maxLength512
instructions: String

The system instructions that the assistant uses. The maximum length is 256,000 characters.

maxLength256000
metadata: Metadata

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.

model: String

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.

name: String

The name of the assistant. The maximum length is 256 characters.

maxLength256
object: :assistant

The object type, which is always assistant.

tools: Array[AssistantTool]

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.

Accepts one of the following:
class CodeInterpreterTool { type }
type: :code_interpreter

The type of tool being defined: code_interpreter

class FileSearchTool { type, file_search }
type: :file_search

The type of tool being defined: file_search

Accepts one of the following:
class FunctionTool { function, type }
function: FunctionDefinition { name, description, parameters, strict }
type: :function

The type of tool being defined: function

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.

temperature: Float

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.

minimum0
maximum2
tool_resources: { 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.

code_interpreter: { file_ids}
file_ids: Array[String]

A list of file IDs made available to the `code_interpreter`` tool. There can be a maximum of 20 files associated with the tool.

top_p: Float

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.

minimum0
maximum1
class AssistantDeleted { id, deleted, object }
id: String
deleted: bool
object: :"assistant.deleted"
AssistantStreamEvent = { data, event, enabled} | { data, event} | { data, event} | 21 more

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.

Accepts one of the following:
class ThreadCreated { data, event, enabled }

Occurs when a new thread is created.

data: Thread { id, created_at, metadata, 2 more }

Represents a thread that contains messages.

event: :"thread.created"
enabled: bool

Whether to enable input audio transcription.

class ThreadRunCreated { data, event }

Occurs when a new run is created.

data: Run { id, assistant_id, cancelled_at, 24 more }

Represents an execution run on a thread.

event: :"thread.run.created"
class ThreadRunQueued { data, event }

Occurs when a run moves to a queued status.

data: Run { id, assistant_id, cancelled_at, 24 more }

Represents an execution run on a thread.

event: :"thread.run.queued"
class ThreadRunInProgress { data, event }

Occurs when a run moves to an in_progress status.

data: Run { id, assistant_id, cancelled_at, 24 more }

Represents an execution run on a thread.

event: :"thread.run.in_progress"
class ThreadRunRequiresAction { data, event }

Occurs when a run moves to a requires_action status.

data: Run { id, assistant_id, cancelled_at, 24 more }

Represents an execution run on a thread.

event: :"thread.run.requires_action"
class ThreadRunCompleted { data, event }

Occurs when a run is completed.

data: Run { id, assistant_id, cancelled_at, 24 more }

Represents an execution run on a thread.

event: :"thread.run.completed"
class ThreadRunIncomplete { data, event }

Occurs when a run ends with status incomplete.

data: Run { id, assistant_id, cancelled_at, 24 more }

Represents an execution run on a thread.

event: :"thread.run.incomplete"
class ThreadRunFailed { data, event }

Occurs when a run fails.

data: Run { id, assistant_id, cancelled_at, 24 more }

Represents an execution run on a thread.

event: :"thread.run.failed"
class ThreadRunCancelling { data, event }

Occurs when a run moves to a cancelling status.

data: Run { id, assistant_id, cancelled_at, 24 more }

Represents an execution run on a thread.

event: :"thread.run.cancelling"
class ThreadRunCancelled { data, event }

Occurs when a run is cancelled.

data: Run { id, assistant_id, cancelled_at, 24 more }

Represents an execution run on a thread.

event: :"thread.run.cancelled"
class ThreadRunExpired { data, event }

Occurs when a run expires.

data: Run { id, assistant_id, cancelled_at, 24 more }

Represents an execution run on a thread.

event: :"thread.run.expired"
class ThreadRunStepCreated { data, event }

Occurs when a run step is created.

data: RunStep { id, assistant_id, cancelled_at, 13 more }

Represents a step in execution of a run.

event: :"thread.run.step.created"
class ThreadRunStepInProgress { data, event }

Occurs when a run step moves to an in_progress state.

data: RunStep { id, assistant_id, cancelled_at, 13 more }

Represents a step in execution of a run.

event: :"thread.run.step.in_progress"
class ThreadRunStepDelta { data, event }

Occurs when parts of a run step are being streamed.

data: RunStepDeltaEvent { id, delta, object }

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

event: :"thread.run.step.delta"
class ThreadRunStepCompleted { data, event }

Occurs when a run step is completed.

data: RunStep { id, assistant_id, cancelled_at, 13 more }

Represents a step in execution of a run.

event: :"thread.run.step.completed"
class ThreadRunStepFailed { data, event }

Occurs when a run step fails.

data: RunStep { id, assistant_id, cancelled_at, 13 more }

Represents a step in execution of a run.

event: :"thread.run.step.failed"
class ThreadRunStepCancelled { data, event }

Occurs when a run step is cancelled.

data: RunStep { id, assistant_id, cancelled_at, 13 more }

Represents a step in execution of a run.

event: :"thread.run.step.cancelled"
class ThreadRunStepExpired { data, event }

Occurs when a run step expires.

data: RunStep { id, assistant_id, cancelled_at, 13 more }

Represents a step in execution of a run.

event: :"thread.run.step.expired"
class ThreadMessageCreated { data, event }

Occurs when a message is created.

data: Message { id, assistant_id, attachments, 11 more }

Represents a message within a thread.

event: :"thread.message.created"
class ThreadMessageInProgress { data, event }

Occurs when a message moves to an in_progress state.

data: Message { id, assistant_id, attachments, 11 more }

Represents a message within a thread.

event: :"thread.message.in_progress"
class ThreadMessageDelta { data, event }

Occurs when parts of a Message are being streamed.

data: MessageDeltaEvent { id, delta, object }

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

event: :"thread.message.delta"
class ThreadMessageCompleted { data, event }

Occurs when a message is completed.

data: Message { id, assistant_id, attachments, 11 more }

Represents a message within a thread.

event: :"thread.message.completed"
class ThreadMessageIncomplete { data, event }

Occurs when a message ends before it is completed.

data: Message { id, assistant_id, attachments, 11 more }

Represents a message within a thread.

event: :"thread.message.incomplete"
class ErrorEvent { data, event }

Occurs when an error occurs. This can happen due to an internal server error or a timeout.

data: ErrorObject { code, message, param, type }
event: :error
AssistantTool = CodeInterpreterTool { type } | FileSearchTool { type, file_search } | FunctionTool { function, type }
Accepts one of the following:
class CodeInterpreterTool { type }
type: :code_interpreter

The type of tool being defined: code_interpreter

class FileSearchTool { type, file_search }
type: :file_search

The type of tool being defined: file_search

Accepts one of the following:
class FunctionTool { function, type }
function: FunctionDefinition { name, description, parameters, strict }
type: :function

The type of tool being defined: function

class CodeInterpreterTool { type }
type: :code_interpreter

The type of tool being defined: code_interpreter

class FileSearchTool { type, file_search }
type: :file_search

The type of tool being defined: file_search

Accepts one of the following:
class FunctionTool { function, type }
function: FunctionDefinition { name, description, parameters, strict }
type: :function

The type of tool being defined: function

MessageStreamEvent = { data, event} | { data, event} | { data, event} | 2 more

Occurs when a message is created.

Accepts one of the following:
class ThreadMessageCreated { data, event }

Occurs when a message is created.

data: Message { id, assistant_id, attachments, 11 more }

Represents a message within a thread.

event: :"thread.message.created"
class ThreadMessageInProgress { data, event }

Occurs when a message moves to an in_progress state.

data: Message { id, assistant_id, attachments, 11 more }

Represents a message within a thread.

event: :"thread.message.in_progress"
class ThreadMessageDelta { data, event }

Occurs when parts of a Message are being streamed.

data: MessageDeltaEvent { id, delta, object }

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

event: :"thread.message.delta"
class ThreadMessageCompleted { data, event }

Occurs when a message is completed.

data: Message { id, assistant_id, attachments, 11 more }

Represents a message within a thread.

event: :"thread.message.completed"
class ThreadMessageIncomplete { data, event }

Occurs when a message ends before it is completed.

data: Message { id, assistant_id, attachments, 11 more }

Represents a message within a thread.

event: :"thread.message.incomplete"
RunStepStreamEvent = { data, event} | { data, event} | { data, event} | 4 more

Occurs when a run step is created.

Accepts one of the following:
class ThreadRunStepCreated { data, event }

Occurs when a run step is created.

data: RunStep { id, assistant_id, cancelled_at, 13 more }

Represents a step in execution of a run.

event: :"thread.run.step.created"
class ThreadRunStepInProgress { data, event }

Occurs when a run step moves to an in_progress state.

data: RunStep { id, assistant_id, cancelled_at, 13 more }

Represents a step in execution of a run.

event: :"thread.run.step.in_progress"
class ThreadRunStepDelta { data, event }

Occurs when parts of a run step are being streamed.

data: RunStepDeltaEvent { id, delta, object }

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

event: :"thread.run.step.delta"
class ThreadRunStepCompleted { data, event }

Occurs when a run step is completed.

data: RunStep { id, assistant_id, cancelled_at, 13 more }

Represents a step in execution of a run.

event: :"thread.run.step.completed"
class ThreadRunStepFailed { data, event }

Occurs when a run step fails.

data: RunStep { id, assistant_id, cancelled_at, 13 more }

Represents a step in execution of a run.

event: :"thread.run.step.failed"
class ThreadRunStepCancelled { data, event }

Occurs when a run step is cancelled.

data: RunStep { id, assistant_id, cancelled_at, 13 more }

Represents a step in execution of a run.

event: :"thread.run.step.cancelled"
class ThreadRunStepExpired { data, event }

Occurs when a run step expires.

data: RunStep { id, assistant_id, cancelled_at, 13 more }

Represents a step in execution of a run.

event: :"thread.run.step.expired"
RunStreamEvent = { data, event} | { data, event} | { data, event} | 7 more

Occurs when a new run is created.

Accepts one of the following:
class ThreadRunCreated { data, event }

Occurs when a new run is created.

data: Run { id, assistant_id, cancelled_at, 24 more }

Represents an execution run on a thread.

event: :"thread.run.created"
class ThreadRunQueued { data, event }

Occurs when a run moves to a queued status.

data: Run { id, assistant_id, cancelled_at, 24 more }

Represents an execution run on a thread.

event: :"thread.run.queued"
class ThreadRunInProgress { data, event }

Occurs when a run moves to an in_progress status.

data: Run { id, assistant_id, cancelled_at, 24 more }

Represents an execution run on a thread.

event: :"thread.run.in_progress"
class ThreadRunRequiresAction { data, event }

Occurs when a run moves to a requires_action status.

data: Run { id, assistant_id, cancelled_at, 24 more }

Represents an execution run on a thread.

event: :"thread.run.requires_action"
class ThreadRunCompleted { data, event }

Occurs when a run is completed.

data: Run { id, assistant_id, cancelled_at, 24 more }

Represents an execution run on a thread.

event: :"thread.run.completed"
class ThreadRunIncomplete { data, event }

Occurs when a run ends with status incomplete.

data: Run { id, assistant_id, cancelled_at, 24 more }

Represents an execution run on a thread.

event: :"thread.run.incomplete"
class ThreadRunFailed { data, event }

Occurs when a run fails.

data: Run { id, assistant_id, cancelled_at, 24 more }

Represents an execution run on a thread.

event: :"thread.run.failed"
class ThreadRunCancelling { data, event }

Occurs when a run moves to a cancelling status.

data: Run { id, assistant_id, cancelled_at, 24 more }

Represents an execution run on a thread.

event: :"thread.run.cancelling"
class ThreadRunCancelled { data, event }

Occurs when a run is cancelled.

data: Run { id, assistant_id, cancelled_at, 24 more }

Represents an execution run on a thread.

event: :"thread.run.cancelled"
class ThreadRunExpired { data, event }

Occurs when a run expires.

data: Run { id, assistant_id, cancelled_at, 24 more }

Represents an execution run on a thread.

event: :"thread.run.expired"
class ThreadStreamEvent { data, event, enabled }

Occurs when a new thread is created.

data: Thread { id, created_at, metadata, 2 more }

Represents a thread that contains messages.

event: :"thread.created"
enabled: bool

Whether to enable input audio transcription.