Skip to content
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
Primary navigation

Threads

Build Assistants that can call models and use tools.

Create thread
Deprecated
client.Beta.Threads.New(ctx, body) (*Thread, error)
POST/threads
Create thread and run
Deprecated
client.Beta.Threads.NewAndRun(ctx, body) (*Run, error)
POST/threads/runs
Delete thread
Deprecated
client.Beta.Threads.Delete(ctx, threadID) (*ThreadDeleted, error)
DELETE/threads/{thread_id}
Retrieve thread
Deprecated
client.Beta.Threads.Get(ctx, threadID) (*Thread, error)
GET/threads/{thread_id}
Modify thread
Deprecated
client.Beta.Threads.Update(ctx, threadID, body) (*Thread, error)
POST/threads/{thread_id}
ModelsExpand Collapse
type AssistantResponseFormatOptionUnion interface{…}

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.

type AssistantToolChoice struct{…}

Specifies a tool the model should use. Use to force the model to call a specific tool.

type AssistantToolChoiceFunction struct{…}
type AssistantToolChoiceOptionUnion interface{…}

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.

type Thread struct{…}

Represents a thread that contains messages.

type ThreadDeleted struct{…}

ThreadsMessages

Build Assistants that can call models and use tools.

Create message
Deprecated
client.Beta.Threads.Messages.New(ctx, threadID, body) (*Message, error)
POST/threads/{thread_id}/messages
Delete message
Deprecated
client.Beta.Threads.Messages.Delete(ctx, threadID, messageID) (*MessageDeleted, error)
DELETE/threads/{thread_id}/messages/{message_id}
List messages
Deprecated
client.Beta.Threads.Messages.List(ctx, threadID, query) (*CursorPage[Message], error)
GET/threads/{thread_id}/messages
Retrieve message
Deprecated
client.Beta.Threads.Messages.Get(ctx, threadID, messageID) (*Message, error)
GET/threads/{thread_id}/messages/{message_id}
Modify message
Deprecated
client.Beta.Threads.Messages.Update(ctx, threadID, messageID, body) (*Message, error)
POST/threads/{thread_id}/messages/{message_id}
ModelsExpand Collapse
type AnnotationUnion interface{…}

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.

type AnnotationDeltaUnion interface{…}

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.

type FileCitationAnnotation struct{…}

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.

type FileCitationDeltaAnnotation struct{…}

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.

type FilePathAnnotation struct{…}

A URL for the file that’s generated when the assistant used the code_interpreter tool to generate a file.

type FilePathDeltaAnnotation struct{…}

A URL for the file that’s generated when the assistant used the code_interpreter tool to generate a file.

type ImageFile struct{…}
type ImageFileContentBlock struct{…}

References an image File in the content of a message.

type ImageFileDelta struct{…}
type ImageFileDeltaBlock struct{…}

References an image File in the content of a message.

type ImageURL struct{…}
type ImageURLContentBlock struct{…}

References an image URL in the content of a message.

type ImageURLDelta struct{…}
type ImageURLDeltaBlock struct{…}

References an image URL in the content of a message.

type Message struct{…}

Represents a message within a thread.

type MessageContentUnion interface{…}

References an image File in the content of a message.

type MessageContentDeltaUnion interface{…}

References an image File in the content of a message.

type MessageContentPartParamUnionResp interface{…}

References an image File in the content of a message.

type MessageDeleted struct{…}
type MessageDelta struct{…}

The delta containing the fields that have changed on the Message.

type MessageDeltaEvent struct{…}

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

type RefusalContentBlock struct{…}

The refusal content generated by the assistant.

type RefusalDeltaBlock struct{…}

The refusal content that is part of a message.

type Text struct{…}
type TextContentBlock struct{…}

The text content that is part of a message.

type TextContentBlockParam struct{…}

The text content that is part of a message.

type TextDelta struct{…}
type TextDeltaBlock struct{…}

The text content that is part of a message.

ThreadsRuns

Build Assistants that can call models and use tools.

Cancel a run
Deprecated
client.Beta.Threads.Runs.Cancel(ctx, threadID, runID) (*Run, error)
POST/threads/{thread_id}/runs/{run_id}/cancel
Create run
Deprecated
client.Beta.Threads.Runs.New(ctx, threadID, params) (*Run, error)
POST/threads/{thread_id}/runs
List runs
Deprecated
client.Beta.Threads.Runs.List(ctx, threadID, query) (*CursorPage[Run], error)
GET/threads/{thread_id}/runs
Retrieve run
Deprecated
client.Beta.Threads.Runs.Get(ctx, threadID, runID) (*Run, error)
GET/threads/{thread_id}/runs/{run_id}
Submit tool outputs to run
Deprecated
client.Beta.Threads.Runs.SubmitToolOutputs(ctx, threadID, runID, body) (*Run, error)
POST/threads/{thread_id}/runs/{run_id}/submit_tool_outputs
Modify run
Deprecated
client.Beta.Threads.Runs.Update(ctx, threadID, runID, body) (*Run, error)
POST/threads/{thread_id}/runs/{run_id}
ModelsExpand Collapse
type RequiredActionFunctionToolCall struct{…}

Tool call objects

type Run struct{…}

Represents an execution run on a thread.

type RunStatus string

The status of the run, which can be either queued, in_progress, requires_action, cancelling, cancelled, failed, completed, incomplete, or expired.

ThreadsRunsSteps

Build Assistants that can call models and use tools.

List run steps
Deprecated
client.Beta.Threads.Runs.Steps.List(ctx, threadID, runID, query) (*CursorPage[RunStep], error)
GET/threads/{thread_id}/runs/{run_id}/steps
Retrieve run step
Deprecated
client.Beta.Threads.Runs.Steps.Get(ctx, threadID, runID, stepID, query) (*RunStep, error)
GET/threads/{thread_id}/runs/{run_id}/steps/{step_id}
ModelsExpand Collapse
type CodeInterpreterLogs struct{…}

Text output from the Code Interpreter tool call as part of a run step.

type CodeInterpreterOutputImage struct{…}
type CodeInterpreterToolCall struct{…}

Details of the Code Interpreter tool call the run step was involved in.

type CodeInterpreterToolCallDelta struct{…}

Details of the Code Interpreter tool call the run step was involved in.

type FileSearchToolCall struct{…}
type FileSearchToolCallDelta struct{…}
type FunctionToolCall struct{…}
type FunctionToolCallDelta struct{…}
type MessageCreationStepDetails struct{…}

Details of the message creation by the run step.

type RunStep struct{…}

Represents a step in execution of a run.

type RunStepDelta struct{…}

The delta containing the fields that have changed on the run step.

type RunStepDeltaEvent struct{…}

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

type RunStepDeltaMessageDelta struct{…}

Details of the message creation by the run step.

type RunStepInclude string
type ToolCallUnion interface{…}

Details of the Code Interpreter tool call the run step was involved in.

type ToolCallDeltaUnion interface{…}

Details of the Code Interpreter tool call the run step was involved in.

type ToolCallDeltaObject struct{…}

Details of the tool call.

type ToolCallsStepDetails struct{…}

Details of the tool call.