Skip to content

Assistants

List assistants
Deprecated
client.Beta.Assistants.List(ctx, query) (*CursorPage[Assistant], error)
GET/assistants
Create assistant
Deprecated
client.Beta.Assistants.New(ctx, body) (*Assistant, error)
POST/assistants
Retrieve assistant
Deprecated
client.Beta.Assistants.Get(ctx, assistantID) (*Assistant, error)
GET/assistants/{assistant_id}
Modify assistant
Deprecated
client.Beta.Assistants.Update(ctx, assistantID, body) (*Assistant, error)
POST/assistants/{assistant_id}
Delete assistant
Deprecated
client.Beta.Assistants.Delete(ctx, assistantID) (*AssistantDeleted, error)
DELETE/assistants/{assistant_id}
ModelsExpand Collapse
type Assistant struct{…}

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

ID string

The identifier, which can be referenced in API endpoints.

CreatedAt int64

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.

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:
type CodeInterpreterTool struct{…}
Type CodeInterpreter

The type of tool being defined: code_interpreter

type FileSearchTool struct{…}
Type FileSearch

The type of tool being defined: file_search

Accepts one of the following:
type FunctionTool struct{…}
Type Function

The type of tool being defined: function

ResponseFormat AssistantResponseFormatOptionUnionoptional

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 float64optional

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
ToolResources AssistantToolResourcesoptional

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.

CodeInterpreter AssistantToolResourcesCodeInterpreteroptional
FileIDs []stringoptional

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

TopP float64optional

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
type AssistantDeleted struct{…}
ID string
Deleted bool
Object AssistantDeleted
type AssistantStreamEventUnion interface{…}

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:
type AssistantStreamEventThreadCreated struct{…}

Occurs when a new thread is created.

Data Thread

Represents a thread that contains messages.

Event ThreadCreated
Enabled booloptional

Whether to enable input audio transcription.

type AssistantStreamEventThreadRunCreated struct{…}

Occurs when a new run is created.

Data Run

Represents an execution run on a thread.

Event ThreadRunCreated
type AssistantStreamEventThreadRunQueued struct{…}

Occurs when a run moves to a queued status.

Data Run

Represents an execution run on a thread.

Event ThreadRunQueued
type AssistantStreamEventThreadRunInProgress struct{…}

Occurs when a run moves to an in_progress status.

Data Run

Represents an execution run on a thread.

Event ThreadRunInProgress
type AssistantStreamEventThreadRunRequiresAction struct{…}

Occurs when a run moves to a requires_action status.

Data Run

Represents an execution run on a thread.

Event ThreadRunRequiresAction
type AssistantStreamEventThreadRunCompleted struct{…}

Occurs when a run is completed.

Data Run

Represents an execution run on a thread.

Event ThreadRunCompleted
type AssistantStreamEventThreadRunIncomplete struct{…}

Occurs when a run ends with status incomplete.

Data Run

Represents an execution run on a thread.

Event ThreadRunIncomplete
type AssistantStreamEventThreadRunFailed struct{…}

Occurs when a run fails.

Data Run

Represents an execution run on a thread.

Event ThreadRunFailed
type AssistantStreamEventThreadRunCancelling struct{…}

Occurs when a run moves to a cancelling status.

Data Run

Represents an execution run on a thread.

Event ThreadRunCancelling
type AssistantStreamEventThreadRunCancelled struct{…}

Occurs when a run is cancelled.

Data Run

Represents an execution run on a thread.

Event ThreadRunCancelled
type AssistantStreamEventThreadRunExpired struct{…}

Occurs when a run expires.

Data Run

Represents an execution run on a thread.

Event ThreadRunExpired
type AssistantStreamEventThreadRunStepCreated struct{…}

Occurs when a run step is created.

Data RunStep

Represents a step in execution of a run.

Event ThreadRunStepCreated
type AssistantStreamEventThreadRunStepInProgress struct{…}

Occurs when a run step moves to an in_progress state.

Data RunStep

Represents a step in execution of a run.

Event ThreadRunStepInProgress
type AssistantStreamEventThreadRunStepDelta struct{…}

Occurs when parts of a run step are being streamed.

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

Event ThreadRunStepDelta
type AssistantStreamEventThreadRunStepCompleted struct{…}

Occurs when a run step is completed.

Data RunStep

Represents a step in execution of a run.

Event ThreadRunStepCompleted
type AssistantStreamEventThreadRunStepFailed struct{…}

Occurs when a run step fails.

Data RunStep

Represents a step in execution of a run.

Event ThreadRunStepFailed
type AssistantStreamEventThreadRunStepCancelled struct{…}

Occurs when a run step is cancelled.

Data RunStep

Represents a step in execution of a run.

Event ThreadRunStepCancelled
type AssistantStreamEventThreadRunStepExpired struct{…}

Occurs when a run step expires.

Data RunStep

Represents a step in execution of a run.

Event ThreadRunStepExpired
type AssistantStreamEventThreadMessageCreated struct{…}

Occurs when a message is created.

Data Message

Represents a message within a thread.

Event ThreadMessageCreated
type AssistantStreamEventThreadMessageInProgress struct{…}

Occurs when a message moves to an in_progress state.

Data Message

Represents a message within a thread.

Event ThreadMessageInProgress
type AssistantStreamEventThreadMessageDelta struct{…}

Occurs when parts of a Message are being streamed.

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

Event ThreadMessageDelta
type AssistantStreamEventThreadMessageCompleted struct{…}

Occurs when a message is completed.

Data Message

Represents a message within a thread.

Event ThreadMessageCompleted
type AssistantStreamEventThreadMessageIncomplete struct{…}

Occurs when a message ends before it is completed.

Data Message

Represents a message within a thread.

Event ThreadMessageIncomplete
type AssistantStreamEventErrorEvent struct{…}

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

Event Error
type AssistantToolUnion interface{…}
Accepts one of the following:
type CodeInterpreterTool struct{…}
Type CodeInterpreter

The type of tool being defined: code_interpreter

type FileSearchTool struct{…}
Type FileSearch

The type of tool being defined: file_search

Accepts one of the following:
type FunctionTool struct{…}
Type Function

The type of tool being defined: function

type CodeInterpreterTool struct{…}
Type CodeInterpreter

The type of tool being defined: code_interpreter

type FileSearchTool struct{…}
Type FileSearch

The type of tool being defined: file_search

Accepts one of the following:
type FunctionTool struct{…}
Type Function

The type of tool being defined: function

type MessageStreamEventUnion interface{…}

Occurs when a message is created.

Accepts one of the following:
MessageStreamEventThreadMessageCreated
Data Message

Represents a message within a thread.

Event ThreadMessageCreated
MessageStreamEventThreadMessageInProgress
Data Message

Represents a message within a thread.

Event ThreadMessageInProgress
MessageStreamEventThreadMessageDelta

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

Event ThreadMessageDelta
MessageStreamEventThreadMessageCompleted
Data Message

Represents a message within a thread.

Event ThreadMessageCompleted
MessageStreamEventThreadMessageIncomplete
Data Message

Represents a message within a thread.

Event ThreadMessageIncomplete
type RunStepStreamEventUnion interface{…}

Occurs when a run step is created.

Accepts one of the following:
RunStepStreamEventThreadRunStepCreated
Data RunStep

Represents a step in execution of a run.

Event ThreadRunStepCreated
RunStepStreamEventThreadRunStepInProgress
Data RunStep

Represents a step in execution of a run.

Event ThreadRunStepInProgress
RunStepStreamEventThreadRunStepDelta

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

Event ThreadRunStepDelta
RunStepStreamEventThreadRunStepCompleted
Data RunStep

Represents a step in execution of a run.

Event ThreadRunStepCompleted
RunStepStreamEventThreadRunStepFailed
Data RunStep

Represents a step in execution of a run.

Event ThreadRunStepFailed
RunStepStreamEventThreadRunStepCancelled
Data RunStep

Represents a step in execution of a run.

Event ThreadRunStepCancelled
RunStepStreamEventThreadRunStepExpired
Data RunStep

Represents a step in execution of a run.

Event ThreadRunStepExpired
type RunStreamEventUnion interface{…}

Occurs when a new run is created.

Accepts one of the following:
RunStreamEventThreadRunCreated
Data Run

Represents an execution run on a thread.

Event ThreadRunCreated
RunStreamEventThreadRunQueued
Data Run

Represents an execution run on a thread.

Event ThreadRunQueued
RunStreamEventThreadRunInProgress
Data Run

Represents an execution run on a thread.

Event ThreadRunInProgress
RunStreamEventThreadRunRequiresAction
Data Run

Represents an execution run on a thread.

Event ThreadRunRequiresAction
RunStreamEventThreadRunCompleted
Data Run

Represents an execution run on a thread.

Event ThreadRunCompleted
RunStreamEventThreadRunIncomplete
Data Run

Represents an execution run on a thread.

Event ThreadRunIncomplete
RunStreamEventThreadRunFailed
Data Run

Represents an execution run on a thread.

Event ThreadRunFailed
RunStreamEventThreadRunCancelling
Data Run

Represents an execution run on a thread.

Event ThreadRunCancelling
RunStreamEventThreadRunCancelled
Data Run

Represents an execution run on a thread.

Event ThreadRunCancelled
RunStreamEventThreadRunExpired
Data Run

Represents an execution run on a thread.

Event ThreadRunExpired
type ThreadStreamEvent struct{…}

Occurs when a new thread is created.

Data Thread

Represents a thread that contains messages.

Event ThreadCreated
Enabled booloptional

Whether to enable input audio transcription.