Skip to content

Assistants

List assistants
Deprecated
AssistantListPage beta().assistants().list(AssistantListParamsparams = AssistantListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
GET/assistants
Create assistant
Deprecated
Assistant beta().assistants().create(AssistantCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
POST/assistants
Retrieve assistant
Deprecated
Assistant beta().assistants().retrieve(AssistantRetrieveParamsparams = AssistantRetrieveParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
GET/assistants/{assistant_id}
Modify assistant
Deprecated
Assistant beta().assistants().update(AssistantUpdateParamsparams = AssistantUpdateParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
POST/assistants/{assistant_id}
Delete assistant
Deprecated
AssistantDeleted beta().assistants().delete(AssistantDeleteParamsparams = AssistantDeleteParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
DELETE/assistants/{assistant_id}
ModelsExpand Collapse
class Assistant:

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

String id

The identifier, which can be referenced in API endpoints.

long createdAt

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

Optional<String> description

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

maxLength512
Optional<String> instructions

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

maxLength256000
Optional<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.

String model

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.

Optional<String> name

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

maxLength256
JsonValue; object_ "assistant"constant"assistant"constant

The object type, which is always assistant.

List<AssistantTool> tools

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:
JsonValue; type "code_interpreter"constant"code_interpreter"constant

The type of tool being defined: code_interpreter

class FileSearchTool:
JsonValue; type "file_search"constant"file_search"constant

The type of tool being defined: file_search

Accepts one of the following:
class FunctionTool:
JsonValue; type "function"constant"function"constant

The type of tool being defined: function

Optional<AssistantResponseFormatOption> responseFormat

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.

Optional<Double> temperature

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
Optional<ToolResources> toolResources

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.

Optional<CodeInterpreter> codeInterpreter
Optional<List<String>> fileIds

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

Optional<Double> topP

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:
String id
boolean deleted
JsonValue; object_ "assistant.deleted"constant"assistant.deleted"constant
class AssistantStreamEvent: A class that can be one of several variants.union

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.

ThreadCreated
Thread data

Represents a thread that contains messages.

JsonValue; event "thread.created"constant"thread.created"constant
Optional<Boolean> enabled

Whether to enable input audio transcription.

ThreadRunCreated
Run data

Represents an execution run on a thread.

JsonValue; event "thread.run.created"constant"thread.run.created"constant
ThreadRunQueued
Run data

Represents an execution run on a thread.

JsonValue; event "thread.run.queued"constant"thread.run.queued"constant
ThreadRunInProgress
Run data

Represents an execution run on a thread.

JsonValue; event "thread.run.in_progress"constant"thread.run.in_progress"constant
ThreadRunRequiresAction
Run data

Represents an execution run on a thread.

JsonValue; event "thread.run.requires_action"constant"thread.run.requires_action"constant
ThreadRunCompleted
Run data

Represents an execution run on a thread.

JsonValue; event "thread.run.completed"constant"thread.run.completed"constant
ThreadRunIncomplete
Run data

Represents an execution run on a thread.

JsonValue; event "thread.run.incomplete"constant"thread.run.incomplete"constant
ThreadRunFailed
Run data

Represents an execution run on a thread.

JsonValue; event "thread.run.failed"constant"thread.run.failed"constant
ThreadRunCancelling
Run data

Represents an execution run on a thread.

JsonValue; event "thread.run.cancelling"constant"thread.run.cancelling"constant
ThreadRunCancelled
Run data

Represents an execution run on a thread.

JsonValue; event "thread.run.cancelled"constant"thread.run.cancelled"constant
ThreadRunExpired
Run data

Represents an execution run on a thread.

JsonValue; event "thread.run.expired"constant"thread.run.expired"constant
ThreadRunStepCreated
RunStep data

Represents a step in execution of a run.

JsonValue; event "thread.run.step.created"constant"thread.run.step.created"constant
ThreadRunStepInProgress
RunStep data

Represents a step in execution of a run.

JsonValue; event "thread.run.step.in_progress"constant"thread.run.step.in_progress"constant
ThreadRunStepDelta

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

JsonValue; event "thread.run.step.delta"constant"thread.run.step.delta"constant
ThreadRunStepCompleted
RunStep data

Represents a step in execution of a run.

JsonValue; event "thread.run.step.completed"constant"thread.run.step.completed"constant
ThreadRunStepFailed
RunStep data

Represents a step in execution of a run.

JsonValue; event "thread.run.step.failed"constant"thread.run.step.failed"constant
ThreadRunStepCancelled
RunStep data

Represents a step in execution of a run.

JsonValue; event "thread.run.step.cancelled"constant"thread.run.step.cancelled"constant
ThreadRunStepExpired
RunStep data

Represents a step in execution of a run.

JsonValue; event "thread.run.step.expired"constant"thread.run.step.expired"constant
ThreadMessageCreated
Message data

Represents a message within a thread.

JsonValue; event "thread.message.created"constant"thread.message.created"constant
ThreadMessageInProgress
Message data

Represents a message within a thread.

JsonValue; event "thread.message.in_progress"constant"thread.message.in_progress"constant
ThreadMessageDelta

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

JsonValue; event "thread.message.delta"constant"thread.message.delta"constant
ThreadMessageCompleted
Message data

Represents a message within a thread.

JsonValue; event "thread.message.completed"constant"thread.message.completed"constant
ThreadMessageIncomplete
Message data

Represents a message within a thread.

JsonValue; event "thread.message.incomplete"constant"thread.message.incomplete"constant
ErrorEvent
JsonValue; event "error"constant"error"constant
class AssistantTool: A class that can be one of several variants.union
class CodeInterpreterTool:
JsonValue; type "code_interpreter"constant"code_interpreter"constant

The type of tool being defined: code_interpreter

class FileSearchTool:
JsonValue; type "file_search"constant"file_search"constant

The type of tool being defined: file_search

Accepts one of the following:
class FunctionTool:
JsonValue; type "function"constant"function"constant

The type of tool being defined: function

class CodeInterpreterTool:
JsonValue; type "code_interpreter"constant"code_interpreter"constant

The type of tool being defined: code_interpreter

class FileSearchTool:
JsonValue; type "file_search"constant"file_search"constant

The type of tool being defined: file_search

Accepts one of the following:
class FunctionTool:
JsonValue; type "function"constant"function"constant

The type of tool being defined: function

class MessageStreamEvent: A class that can be one of several variants.union

Occurs when a message is created.

ThreadMessageCreated
Message data

Represents a message within a thread.

JsonValue; event "thread.message.created"constant"thread.message.created"constant
ThreadMessageInProgress
Message data

Represents a message within a thread.

JsonValue; event "thread.message.in_progress"constant"thread.message.in_progress"constant
ThreadMessageDelta

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

JsonValue; event "thread.message.delta"constant"thread.message.delta"constant
ThreadMessageCompleted
Message data

Represents a message within a thread.

JsonValue; event "thread.message.completed"constant"thread.message.completed"constant
ThreadMessageIncomplete
Message data

Represents a message within a thread.

JsonValue; event "thread.message.incomplete"constant"thread.message.incomplete"constant
class RunStepStreamEvent: A class that can be one of several variants.union

Occurs when a run step is created.

ThreadRunStepCreated
RunStep data

Represents a step in execution of a run.

JsonValue; event "thread.run.step.created"constant"thread.run.step.created"constant
ThreadRunStepInProgress
RunStep data

Represents a step in execution of a run.

JsonValue; event "thread.run.step.in_progress"constant"thread.run.step.in_progress"constant
ThreadRunStepDelta

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

JsonValue; event "thread.run.step.delta"constant"thread.run.step.delta"constant
ThreadRunStepCompleted
RunStep data

Represents a step in execution of a run.

JsonValue; event "thread.run.step.completed"constant"thread.run.step.completed"constant
ThreadRunStepFailed
RunStep data

Represents a step in execution of a run.

JsonValue; event "thread.run.step.failed"constant"thread.run.step.failed"constant
ThreadRunStepCancelled
RunStep data

Represents a step in execution of a run.

JsonValue; event "thread.run.step.cancelled"constant"thread.run.step.cancelled"constant
ThreadRunStepExpired
RunStep data

Represents a step in execution of a run.

JsonValue; event "thread.run.step.expired"constant"thread.run.step.expired"constant
class RunStreamEvent: A class that can be one of several variants.union

Occurs when a new run is created.

ThreadRunCreated
Run data

Represents an execution run on a thread.

JsonValue; event "thread.run.created"constant"thread.run.created"constant
ThreadRunQueued
Run data

Represents an execution run on a thread.

JsonValue; event "thread.run.queued"constant"thread.run.queued"constant
ThreadRunInProgress
Run data

Represents an execution run on a thread.

JsonValue; event "thread.run.in_progress"constant"thread.run.in_progress"constant
ThreadRunRequiresAction
Run data

Represents an execution run on a thread.

JsonValue; event "thread.run.requires_action"constant"thread.run.requires_action"constant
ThreadRunCompleted
Run data

Represents an execution run on a thread.

JsonValue; event "thread.run.completed"constant"thread.run.completed"constant
ThreadRunIncomplete
Run data

Represents an execution run on a thread.

JsonValue; event "thread.run.incomplete"constant"thread.run.incomplete"constant
ThreadRunFailed
Run data

Represents an execution run on a thread.

JsonValue; event "thread.run.failed"constant"thread.run.failed"constant
ThreadRunCancelling
Run data

Represents an execution run on a thread.

JsonValue; event "thread.run.cancelling"constant"thread.run.cancelling"constant
ThreadRunCancelled
Run data

Represents an execution run on a thread.

JsonValue; event "thread.run.cancelled"constant"thread.run.cancelled"constant
ThreadRunExpired
Run data

Represents an execution run on a thread.

JsonValue; event "thread.run.expired"constant"thread.run.expired"constant
class ThreadStreamEvent:

Occurs when a new thread is created.

Thread data

Represents a thread that contains messages.

JsonValue; event "thread.created"constant"thread.created"constant
Optional<Boolean> enabled

Whether to enable input audio transcription.