Skip to content

Create thread and run

Deprecated
Run beta().threads().createAndRun(ThreadCreateAndRunParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
POST/threads/runs

Create a thread and run it in one request.

ParametersExpand Collapse
ThreadCreateAndRunParams params
String assistantId

The ID of the assistant to use to execute this run.

Optional<String> instructions

Override the default system message of the assistant. This is useful for modifying the behavior on a per-run basis.

Optional<Long> maxCompletionTokens

The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens specified, the run will end with status incomplete. See incomplete_details for more info.

minimum256
Optional<Long> maxPromptTokens

The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status incomplete. See incomplete_details for more info.

minimum256
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.

Optional<ChatModel> model

The ID of the Model to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used.

GPT_5_2("gpt-5.2")
GPT_5_2_2025_12_11("gpt-5.2-2025-12-11")
GPT_5_2_CHAT_LATEST("gpt-5.2-chat-latest")
GPT_5_2_PRO("gpt-5.2-pro")
GPT_5_2_PRO_2025_12_11("gpt-5.2-pro-2025-12-11")
GPT_5_1("gpt-5.1")
GPT_5_1_2025_11_13("gpt-5.1-2025-11-13")
GPT_5_1_CODEX("gpt-5.1-codex")
GPT_5_1_MINI("gpt-5.1-mini")
GPT_5_1_CHAT_LATEST("gpt-5.1-chat-latest")
GPT_5("gpt-5")
GPT_5_MINI("gpt-5-mini")
GPT_5_NANO("gpt-5-nano")
GPT_5_2025_08_07("gpt-5-2025-08-07")
GPT_5_MINI_2025_08_07("gpt-5-mini-2025-08-07")
GPT_5_NANO_2025_08_07("gpt-5-nano-2025-08-07")
GPT_5_CHAT_LATEST("gpt-5-chat-latest")
GPT_4_1("gpt-4.1")
GPT_4_1_MINI("gpt-4.1-mini")
GPT_4_1_NANO("gpt-4.1-nano")
GPT_4_1_2025_04_14("gpt-4.1-2025-04-14")
GPT_4_1_MINI_2025_04_14("gpt-4.1-mini-2025-04-14")
GPT_4_1_NANO_2025_04_14("gpt-4.1-nano-2025-04-14")
O4_MINI("o4-mini")
O4_MINI_2025_04_16("o4-mini-2025-04-16")
O3("o3")
O3_2025_04_16("o3-2025-04-16")
O3_MINI("o3-mini")
O3_MINI_2025_01_31("o3-mini-2025-01-31")
O1("o1")
O1_2024_12_17("o1-2024-12-17")
O1_PREVIEW("o1-preview")
O1_PREVIEW_2024_09_12("o1-preview-2024-09-12")
O1_MINI("o1-mini")
O1_MINI_2024_09_12("o1-mini-2024-09-12")
GPT_4O("gpt-4o")
GPT_4O_2024_11_20("gpt-4o-2024-11-20")
GPT_4O_2024_08_06("gpt-4o-2024-08-06")
GPT_4O_2024_05_13("gpt-4o-2024-05-13")
GPT_4O_AUDIO_PREVIEW("gpt-4o-audio-preview")
GPT_4O_AUDIO_PREVIEW_2024_10_01("gpt-4o-audio-preview-2024-10-01")
GPT_4O_AUDIO_PREVIEW_2024_12_17("gpt-4o-audio-preview-2024-12-17")
GPT_4O_AUDIO_PREVIEW_2025_06_03("gpt-4o-audio-preview-2025-06-03")
GPT_4O_MINI_AUDIO_PREVIEW("gpt-4o-mini-audio-preview")
GPT_4O_MINI_AUDIO_PREVIEW_2024_12_17("gpt-4o-mini-audio-preview-2024-12-17")
GPT_4O_SEARCH_PREVIEW("gpt-4o-search-preview")
GPT_4O_MINI_SEARCH_PREVIEW("gpt-4o-mini-search-preview")
GPT_4O_SEARCH_PREVIEW_2025_03_11("gpt-4o-search-preview-2025-03-11")
GPT_4O_MINI_SEARCH_PREVIEW_2025_03_11("gpt-4o-mini-search-preview-2025-03-11")
CHATGPT_4O_LATEST("chatgpt-4o-latest")
CODEX_MINI_LATEST("codex-mini-latest")
GPT_4O_MINI("gpt-4o-mini")
GPT_4O_MINI_2024_07_18("gpt-4o-mini-2024-07-18")
GPT_4_TURBO("gpt-4-turbo")
GPT_4_TURBO_2024_04_09("gpt-4-turbo-2024-04-09")
GPT_4_0125_PREVIEW("gpt-4-0125-preview")
GPT_4_TURBO_PREVIEW("gpt-4-turbo-preview")
GPT_4_1106_PREVIEW("gpt-4-1106-preview")
GPT_4_VISION_PREVIEW("gpt-4-vision-preview")
GPT_4("gpt-4")
GPT_4_0314("gpt-4-0314")
GPT_4_0613("gpt-4-0613")
GPT_4_32K("gpt-4-32k")
GPT_4_32K_0314("gpt-4-32k-0314")
GPT_4_32K_0613("gpt-4-32k-0613")
GPT_3_5_TURBO("gpt-3.5-turbo")
GPT_3_5_TURBO_16K("gpt-3.5-turbo-16k")
GPT_3_5_TURBO_0301("gpt-3.5-turbo-0301")
GPT_3_5_TURBO_0613("gpt-3.5-turbo-0613")
GPT_3_5_TURBO_1106("gpt-3.5-turbo-1106")
GPT_3_5_TURBO_0125("gpt-3.5-turbo-0125")
GPT_3_5_TURBO_16K_0613("gpt-3.5-turbo-16k-0613")
Optional<Boolean> parallelToolCalls

Whether to enable parallel function calling during tool use.

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<Thread> thread

Options to create a new thread. If no thread is provided when running a request, an empty thread will be created.

Optional<List<Message>> messages

A list of messages to start the thread with.

Content content

The text contents of the message.

Accepts one of the following:
String
Accepts one of the following:
class ImageFileContentBlock:

References an image File in the content of a message.

ImageFile imageFile
String fileId

The File ID of the image in the message content. Set purpose="vision" when uploading the File if you need to later display the file content.

Optional<Detail> detail

Specifies the detail level of the image if specified by the user. low uses fewer tokens, you can opt in to high resolution using high.

Accepts one of the following:
AUTO("auto")
LOW("low")
HIGH("high")
JsonValue; type "image_file"constant"image_file"constant

Always image_file.

class ImageUrlContentBlock:

References an image URL in the content of a message.

ImageUrl imageUrl
String url

The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.

formaturi
Optional<Detail> detail

Specifies the detail level of the image. low uses fewer tokens, you can opt in to high resolution using high. Default value is auto

Accepts one of the following:
AUTO("auto")
LOW("low")
HIGH("high")
JsonValue; type "image_url"constant"image_url"constant

The type of the content part.

class TextContentBlockParam:

The text content that is part of a message.

String text

Text content to be sent to the model

JsonValue; type "text"constant"text"constant

Always text.

Role role

The role of the entity that is creating the message. Allowed values include:

  • user: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages.
  • assistant: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation.
Accepts one of the following:
USER("user")
ASSISTANT("assistant")
Optional<List<Attachment>> attachments

A list of files attached to the message, and the tools they should be added to.

Optional<String> fileId

The ID of the file to attach to the message.

Optional<List<Tool>> tools

The tools to add this file to.

Accepts one of the following:
class CodeInterpreterTool:
JsonValue; type "code_interpreter"constant"code_interpreter"constant

The type of tool being defined: code_interpreter

JsonValue;
JsonValue; type "file_search"constant"file_search"constant

The type of tool being defined: file_search

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.

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.

Optional<ToolResources> toolResources

A set of resources that are made available to the assistant's tools in this thread. 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.

Accepts one of the following:
Optional<AssistantToolChoiceOption> toolChoice

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.

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<List<AssistantTool>> tools

Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis.

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:
String name

The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

Optional<String> description

A description of what the function does, used by the model to choose when and how to call the function.

Optional<FunctionParameters> parameters

The parameters the functions accepts, described as a JSON Schema object. See the guide for examples, and the JSON Schema reference for documentation about the format.

Omitting parameters defines a function with an empty parameter list.

Optional<Boolean> strict

Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the parameters field. Only a subset of JSON Schema is supported when strict is true. Learn more about Structured Outputs in the function calling guide.

JsonValue; type "function"constant"function"constant

The type of tool being defined: function

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
Optional<TruncationStrategy> truncationStrategy

Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

Type type

The truncation strategy to use for the thread. The default is auto. If set to last_messages, the thread will be truncated to the n most recent messages in the thread. When set to auto, messages in the middle of the thread will be dropped to fit the context length of the model, max_prompt_tokens.

Accepts one of the following:
AUTO("auto")
LAST_MESSAGES("last_messages")
Optional<Long> lastMessages

The number of most recent messages from the thread when constructing the context for the run.

minimum1
ReturnsExpand Collapse
class Run:

Represents an execution run on a thread.

String id

The identifier, which can be referenced in API endpoints.

String assistantId

The ID of the assistant used for execution of this run.

Optional<Long> cancelledAt

The Unix timestamp (in seconds) for when the run was cancelled.

Optional<Long> completedAt

The Unix timestamp (in seconds) for when the run was completed.

long createdAt

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

Optional<Long> expiresAt

The Unix timestamp (in seconds) for when the run will expire.

Optional<Long> failedAt

The Unix timestamp (in seconds) for when the run failed.

Optional<IncompleteDetails> incompleteDetails

Details on why the run is incomplete. Will be null if the run is not incomplete.

Optional<Reason> reason

The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.

Accepts one of the following:
MAX_COMPLETION_TOKENS("max_completion_tokens")
MAX_PROMPT_TOKENS("max_prompt_tokens")
String instructions

The instructions that the assistant used for this run.

Optional<LastError> lastError

The last error associated with this run. Will be null if there are no errors.

Code code

One of server_error, rate_limit_exceeded, or invalid_prompt.

Accepts one of the following:
SERVER_ERROR("server_error")
RATE_LIMIT_EXCEEDED("rate_limit_exceeded")
INVALID_PROMPT("invalid_prompt")
String message

A human-readable description of the error.

Optional<Long> maxCompletionTokens

The maximum number of completion tokens specified to have been used over the course of the run.

minimum256
Optional<Long> maxPromptTokens

The maximum number of prompt tokens specified to have been used over the course of the run.

minimum256
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

The model that the assistant used for this run.

JsonValue; object_ "thread.run"constant"thread.run"constant

The object type, which is always thread.run.

boolean parallelToolCalls

Whether to enable parallel function calling during tool use.

Optional<RequiredAction> requiredAction

Details on the action required to continue the run. Will be null if no action is required.

SubmitToolOutputs submitToolOutputs

Details on the tool outputs needed for this run to continue.

A list of the relevant tool calls.

String id

The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the Submit tool outputs to run endpoint.

Function function

The function definition.

String arguments

The arguments that the model expects you to pass to the function.

String name

The name of the function.

JsonValue; type "function"constant"function"constant

The type of tool call the output is required for. For now, this is always function.

JsonValue; type "submit_tool_outputs"constant"submit_tool_outputs"constant

For now, this is always submit_tool_outputs.

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.

Accepts one of the following:
JsonValue;
class ResponseFormatText:

Default response format. Used to generate text responses.

JsonValue; type "text"constant"text"constant

The type of response format being defined. Always text.

class ResponseFormatJsonObject:

JSON object response format. An older method of generating JSON responses. Using json_schema is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so.

JsonValue; type "json_object"constant"json_object"constant

The type of response format being defined. Always json_object.

class ResponseFormatJsonSchema:

JSON Schema response format. Used to generate structured JSON responses. Learn more about Structured Outputs.

JsonSchema jsonSchema

Structured Outputs configuration options, including a JSON Schema.

String name

The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

Optional<String> description

A description of what the response format is for, used by the model to determine how to respond in the format.

Optional<Schema> schema

The schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas here.

Optional<Boolean> strict

Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the schema field. Only a subset of JSON Schema is supported when strict is true. To learn more, read the Structured Outputs guide.

JsonValue; type "json_schema"constant"json_schema"constant

The type of response format being defined. Always json_schema.

Optional<Long> startedAt

The Unix timestamp (in seconds) for when the run was started.

RunStatus status

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

Accepts one of the following:
QUEUED("queued")
IN_PROGRESS("in_progress")
REQUIRES_ACTION("requires_action")
CANCELLING("cancelling")
CANCELLED("cancelled")
FAILED("failed")
COMPLETED("completed")
INCOMPLETE("incomplete")
EXPIRED("expired")
String threadId

The ID of the thread that was executed on as a part of this run.

Optional<AssistantToolChoiceOption> toolChoice

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.

Accepts one of the following:
Auto
Accepts one of the following:
NONE("none")
AUTO("auto")
REQUIRED("required")
class AssistantToolChoice:

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

Type type

The type of the tool. If type is function, the function name must be set

Accepts one of the following:
FUNCTION("function")
CODE_INTERPRETER("code_interpreter")
FILE_SEARCH("file_search")
Optional<AssistantToolChoiceFunction> function
String name

The name of the function to call.

List<AssistantTool> tools

The list of tools that the assistant used for this run.

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:
String name

The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

Optional<String> description

A description of what the function does, used by the model to choose when and how to call the function.

Optional<FunctionParameters> parameters

The parameters the functions accepts, described as a JSON Schema object. See the guide for examples, and the JSON Schema reference for documentation about the format.

Omitting parameters defines a function with an empty parameter list.

Optional<Boolean> strict

Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the parameters field. Only a subset of JSON Schema is supported when strict is true. Learn more about Structured Outputs in the function calling guide.

JsonValue; type "function"constant"function"constant

The type of tool being defined: function

Optional<TruncationStrategy> truncationStrategy

Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

Type type

The truncation strategy to use for the thread. The default is auto. If set to last_messages, the thread will be truncated to the n most recent messages in the thread. When set to auto, messages in the middle of the thread will be dropped to fit the context length of the model, max_prompt_tokens.

Accepts one of the following:
AUTO("auto")
LAST_MESSAGES("last_messages")
Optional<Long> lastMessages

The number of most recent messages from the thread when constructing the context for the run.

minimum1
Optional<Usage> usage

Usage statistics related to the run. This value will be null if the run is not in a terminal state (i.e. in_progress, queued, etc.).

long completionTokens

Number of completion tokens used over the course of the run.

long promptTokens

Number of prompt tokens used over the course of the run.

long totalTokens

Total number of tokens used (prompt + completion).

Optional<Double> temperature

The sampling temperature used for this run. If not set, defaults to 1.

Optional<Double> topP

The nucleus sampling value used for this run. If not set, defaults to 1.

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.

String id

The identifier, which can be referenced in API endpoints.

long createdAt

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

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.

JsonValue; object_ "thread"constant"thread"constant

The object type, which is always thread.

Optional<ToolResources> toolResources

A set of resources that are made available to the assistant's tools in this thread. 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.

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.

String id

The identifier, which can be referenced in API endpoints.

String assistantId

The ID of the assistant used for execution of this run.

Optional<Long> cancelledAt

The Unix timestamp (in seconds) for when the run was cancelled.

Optional<Long> completedAt

The Unix timestamp (in seconds) for when the run was completed.

long createdAt

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

Optional<Long> expiresAt

The Unix timestamp (in seconds) for when the run will expire.

Optional<Long> failedAt

The Unix timestamp (in seconds) for when the run failed.

Optional<IncompleteDetails> incompleteDetails

Details on why the run is incomplete. Will be null if the run is not incomplete.

Optional<Reason> reason

The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.

Accepts one of the following:
MAX_COMPLETION_TOKENS("max_completion_tokens")
MAX_PROMPT_TOKENS("max_prompt_tokens")
String instructions

The instructions that the assistant used for this run.

Optional<LastError> lastError

The last error associated with this run. Will be null if there are no errors.

Code code

One of server_error, rate_limit_exceeded, or invalid_prompt.

Accepts one of the following:
SERVER_ERROR("server_error")
RATE_LIMIT_EXCEEDED("rate_limit_exceeded")
INVALID_PROMPT("invalid_prompt")
String message

A human-readable description of the error.

Optional<Long> maxCompletionTokens

The maximum number of completion tokens specified to have been used over the course of the run.

minimum256
Optional<Long> maxPromptTokens

The maximum number of prompt tokens specified to have been used over the course of the run.

minimum256
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

The model that the assistant used for this run.

JsonValue; object_ "thread.run"constant"thread.run"constant

The object type, which is always thread.run.

boolean parallelToolCalls

Whether to enable parallel function calling during tool use.

Optional<RequiredAction> requiredAction

Details on the action required to continue the run. Will be null if no action is required.

SubmitToolOutputs submitToolOutputs

Details on the tool outputs needed for this run to continue.

A list of the relevant tool calls.

String id

The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the Submit tool outputs to run endpoint.

Function function

The function definition.

String arguments

The arguments that the model expects you to pass to the function.

String name

The name of the function.

JsonValue; type "function"constant"function"constant

The type of tool call the output is required for. For now, this is always function.

JsonValue; type "submit_tool_outputs"constant"submit_tool_outputs"constant

For now, this is always submit_tool_outputs.

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.

Accepts one of the following:
JsonValue;
class ResponseFormatText:

Default response format. Used to generate text responses.

JsonValue; type "text"constant"text"constant

The type of response format being defined. Always text.

class ResponseFormatJsonObject:

JSON object response format. An older method of generating JSON responses. Using json_schema is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so.

JsonValue; type "json_object"constant"json_object"constant

The type of response format being defined. Always json_object.

class ResponseFormatJsonSchema:

JSON Schema response format. Used to generate structured JSON responses. Learn more about Structured Outputs.

JsonSchema jsonSchema

Structured Outputs configuration options, including a JSON Schema.

String name

The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

Optional<String> description

A description of what the response format is for, used by the model to determine how to respond in the format.

Optional<Schema> schema

The schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas here.

Optional<Boolean> strict

Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the schema field. Only a subset of JSON Schema is supported when strict is true. To learn more, read the Structured Outputs guide.

JsonValue; type "json_schema"constant"json_schema"constant

The type of response format being defined. Always json_schema.

Optional<Long> startedAt

The Unix timestamp (in seconds) for when the run was started.

RunStatus status

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

Accepts one of the following:
QUEUED("queued")
IN_PROGRESS("in_progress")
REQUIRES_ACTION("requires_action")
CANCELLING("cancelling")
CANCELLED("cancelled")
FAILED("failed")
COMPLETED("completed")
INCOMPLETE("incomplete")
EXPIRED("expired")
String threadId

The ID of the thread that was executed on as a part of this run.

Optional<AssistantToolChoiceOption> toolChoice

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.

Accepts one of the following:
Auto
Accepts one of the following:
NONE("none")
AUTO("auto")
REQUIRED("required")
class AssistantToolChoice:

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

Type type

The type of the tool. If type is function, the function name must be set

Accepts one of the following:
FUNCTION("function")
CODE_INTERPRETER("code_interpreter")
FILE_SEARCH("file_search")
Optional<AssistantToolChoiceFunction> function
String name

The name of the function to call.

List<AssistantTool> tools

The list of tools that the assistant used for this run.

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:
String name

The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

Optional<String> description

A description of what the function does, used by the model to choose when and how to call the function.

Optional<FunctionParameters> parameters

The parameters the functions accepts, described as a JSON Schema object. See the guide for examples, and the JSON Schema reference for documentation about the format.

Omitting parameters defines a function with an empty parameter list.

Optional<Boolean> strict

Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the parameters field. Only a subset of JSON Schema is supported when strict is true. Learn more about Structured Outputs in the function calling guide.

JsonValue; type "function"constant"function"constant

The type of tool being defined: function

Optional<TruncationStrategy> truncationStrategy

Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

Type type

The truncation strategy to use for the thread. The default is auto. If set to last_messages, the thread will be truncated to the n most recent messages in the thread. When set to auto, messages in the middle of the thread will be dropped to fit the context length of the model, max_prompt_tokens.

Accepts one of the following:
AUTO("auto")
LAST_MESSAGES("last_messages")
Optional<Long> lastMessages

The number of most recent messages from the thread when constructing the context for the run.

minimum1
Optional<Usage> usage

Usage statistics related to the run. This value will be null if the run is not in a terminal state (i.e. in_progress, queued, etc.).

long completionTokens

Number of completion tokens used over the course of the run.

long promptTokens

Number of prompt tokens used over the course of the run.

long totalTokens

Total number of tokens used (prompt + completion).

Optional<Double> temperature

The sampling temperature used for this run. If not set, defaults to 1.

Optional<Double> topP

The nucleus sampling value used for this run. If not set, defaults to 1.

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

Represents an execution run on a thread.

String id

The identifier, which can be referenced in API endpoints.

String assistantId

The ID of the assistant used for execution of this run.

Optional<Long> cancelledAt

The Unix timestamp (in seconds) for when the run was cancelled.

Optional<Long> completedAt

The Unix timestamp (in seconds) for when the run was completed.

long createdAt

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

Optional<Long> expiresAt

The Unix timestamp (in seconds) for when the run will expire.

Optional<Long> failedAt

The Unix timestamp (in seconds) for when the run failed.

Optional<IncompleteDetails> incompleteDetails

Details on why the run is incomplete. Will be null if the run is not incomplete.

Optional<Reason> reason

The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.

Accepts one of the following:
MAX_COMPLETION_TOKENS("max_completion_tokens")
MAX_PROMPT_TOKENS("max_prompt_tokens")
String instructions

The instructions that the assistant used for this run.

Optional<LastError> lastError

The last error associated with this run. Will be null if there are no errors.

Code code

One of server_error, rate_limit_exceeded, or invalid_prompt.

Accepts one of the following:
SERVER_ERROR("server_error")
RATE_LIMIT_EXCEEDED("rate_limit_exceeded")
INVALID_PROMPT("invalid_prompt")
String message

A human-readable description of the error.

Optional<Long> maxCompletionTokens

The maximum number of completion tokens specified to have been used over the course of the run.

minimum256
Optional<Long> maxPromptTokens

The maximum number of prompt tokens specified to have been used over the course of the run.

minimum256
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

The model that the assistant used for this run.

JsonValue; object_ "thread.run"constant"thread.run"constant

The object type, which is always thread.run.

boolean parallelToolCalls

Whether to enable parallel function calling during tool use.

Optional<RequiredAction> requiredAction

Details on the action required to continue the run. Will be null if no action is required.

SubmitToolOutputs submitToolOutputs

Details on the tool outputs needed for this run to continue.

A list of the relevant tool calls.

String id

The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the Submit tool outputs to run endpoint.

Function function

The function definition.

String arguments

The arguments that the model expects you to pass to the function.

String name

The name of the function.

JsonValue; type "function"constant"function"constant

The type of tool call the output is required for. For now, this is always function.

JsonValue; type "submit_tool_outputs"constant"submit_tool_outputs"constant

For now, this is always submit_tool_outputs.

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.

Accepts one of the following:
JsonValue;
class ResponseFormatText:

Default response format. Used to generate text responses.

JsonValue; type "text"constant"text"constant

The type of response format being defined. Always text.

class ResponseFormatJsonObject:

JSON object response format. An older method of generating JSON responses. Using json_schema is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so.

JsonValue; type "json_object"constant"json_object"constant

The type of response format being defined. Always json_object.

class ResponseFormatJsonSchema:

JSON Schema response format. Used to generate structured JSON responses. Learn more about Structured Outputs.

JsonSchema jsonSchema

Structured Outputs configuration options, including a JSON Schema.

String name

The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

Optional<String> description

A description of what the response format is for, used by the model to determine how to respond in the format.

Optional<Schema> schema

The schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas here.

Optional<Boolean> strict

Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the schema field. Only a subset of JSON Schema is supported when strict is true. To learn more, read the Structured Outputs guide.

JsonValue; type "json_schema"constant"json_schema"constant

The type of response format being defined. Always json_schema.

Optional<Long> startedAt

The Unix timestamp (in seconds) for when the run was started.

RunStatus status

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

Accepts one of the following:
QUEUED("queued")
IN_PROGRESS("in_progress")
REQUIRES_ACTION("requires_action")
CANCELLING("cancelling")
CANCELLED("cancelled")
FAILED("failed")
COMPLETED("completed")
INCOMPLETE("incomplete")
EXPIRED("expired")
String threadId

The ID of the thread that was executed on as a part of this run.

Optional<AssistantToolChoiceOption> toolChoice

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.

Accepts one of the following:
Auto
Accepts one of the following:
NONE("none")
AUTO("auto")
REQUIRED("required")
class AssistantToolChoice:

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

Type type

The type of the tool. If type is function, the function name must be set

Accepts one of the following:
FUNCTION("function")
CODE_INTERPRETER("code_interpreter")
FILE_SEARCH("file_search")
Optional<AssistantToolChoiceFunction> function
String name

The name of the function to call.

List<AssistantTool> tools

The list of tools that the assistant used for this run.

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:
String name

The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

Optional<String> description

A description of what the function does, used by the model to choose when and how to call the function.

Optional<FunctionParameters> parameters

The parameters the functions accepts, described as a JSON Schema object. See the guide for examples, and the JSON Schema reference for documentation about the format.

Omitting parameters defines a function with an empty parameter list.

Optional<Boolean> strict

Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the parameters field. Only a subset of JSON Schema is supported when strict is true. Learn more about Structured Outputs in the function calling guide.

JsonValue; type "function"constant"function"constant

The type of tool being defined: function

Optional<TruncationStrategy> truncationStrategy

Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

Type type

The truncation strategy to use for the thread. The default is auto. If set to last_messages, the thread will be truncated to the n most recent messages in the thread. When set to auto, messages in the middle of the thread will be dropped to fit the context length of the model, max_prompt_tokens.

Accepts one of the following:
AUTO("auto")
LAST_MESSAGES("last_messages")
Optional<Long> lastMessages

The number of most recent messages from the thread when constructing the context for the run.

minimum1
Optional<Usage> usage

Usage statistics related to the run. This value will be null if the run is not in a terminal state (i.e. in_progress, queued, etc.).

long completionTokens

Number of completion tokens used over the course of the run.

long promptTokens

Number of prompt tokens used over the course of the run.

long totalTokens

Total number of tokens used (prompt + completion).

Optional<Double> temperature

The sampling temperature used for this run. If not set, defaults to 1.

Optional<Double> topP

The nucleus sampling value used for this run. If not set, defaults to 1.

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

Represents an execution run on a thread.

String id

The identifier, which can be referenced in API endpoints.

String assistantId

The ID of the assistant used for execution of this run.

Optional<Long> cancelledAt

The Unix timestamp (in seconds) for when the run was cancelled.

Optional<Long> completedAt

The Unix timestamp (in seconds) for when the run was completed.

long createdAt

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

Optional<Long> expiresAt

The Unix timestamp (in seconds) for when the run will expire.

Optional<Long> failedAt

The Unix timestamp (in seconds) for when the run failed.

Optional<IncompleteDetails> incompleteDetails

Details on why the run is incomplete. Will be null if the run is not incomplete.

Optional<Reason> reason

The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.

Accepts one of the following:
MAX_COMPLETION_TOKENS("max_completion_tokens")
MAX_PROMPT_TOKENS("max_prompt_tokens")
String instructions

The instructions that the assistant used for this run.

Optional<LastError> lastError

The last error associated with this run. Will be null if there are no errors.

Code code

One of server_error, rate_limit_exceeded, or invalid_prompt.

Accepts one of the following:
SERVER_ERROR("server_error")
RATE_LIMIT_EXCEEDED("rate_limit_exceeded")
INVALID_PROMPT("invalid_prompt")
String message

A human-readable description of the error.

Optional<Long> maxCompletionTokens

The maximum number of completion tokens specified to have been used over the course of the run.

minimum256
Optional<Long> maxPromptTokens

The maximum number of prompt tokens specified to have been used over the course of the run.

minimum256
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

The model that the assistant used for this run.

JsonValue; object_ "thread.run"constant"thread.run"constant

The object type, which is always thread.run.

boolean parallelToolCalls

Whether to enable parallel function calling during tool use.

Optional<RequiredAction> requiredAction

Details on the action required to continue the run. Will be null if no action is required.

SubmitToolOutputs submitToolOutputs

Details on the tool outputs needed for this run to continue.

A list of the relevant tool calls.

String id

The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the Submit tool outputs to run endpoint.

Function function

The function definition.

String arguments

The arguments that the model expects you to pass to the function.

String name

The name of the function.

JsonValue; type "function"constant"function"constant

The type of tool call the output is required for. For now, this is always function.

JsonValue; type "submit_tool_outputs"constant"submit_tool_outputs"constant

For now, this is always submit_tool_outputs.

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.

Accepts one of the following:
JsonValue;
class ResponseFormatText:

Default response format. Used to generate text responses.

JsonValue; type "text"constant"text"constant

The type of response format being defined. Always text.

class ResponseFormatJsonObject:

JSON object response format. An older method of generating JSON responses. Using json_schema is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so.

JsonValue; type "json_object"constant"json_object"constant

The type of response format being defined. Always json_object.

class ResponseFormatJsonSchema:

JSON Schema response format. Used to generate structured JSON responses. Learn more about Structured Outputs.

JsonSchema jsonSchema

Structured Outputs configuration options, including a JSON Schema.

String name

The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

Optional<String> description

A description of what the response format is for, used by the model to determine how to respond in the format.

Optional<Schema> schema

The schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas here.

Optional<Boolean> strict

Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the schema field. Only a subset of JSON Schema is supported when strict is true. To learn more, read the Structured Outputs guide.

JsonValue; type "json_schema"constant"json_schema"constant

The type of response format being defined. Always json_schema.

Optional<Long> startedAt

The Unix timestamp (in seconds) for when the run was started.

RunStatus status

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

Accepts one of the following:
QUEUED("queued")
IN_PROGRESS("in_progress")
REQUIRES_ACTION("requires_action")
CANCELLING("cancelling")
CANCELLED("cancelled")
FAILED("failed")
COMPLETED("completed")
INCOMPLETE("incomplete")
EXPIRED("expired")
String threadId

The ID of the thread that was executed on as a part of this run.

Optional<AssistantToolChoiceOption> toolChoice

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.

Accepts one of the following:
Auto
Accepts one of the following:
NONE("none")
AUTO("auto")
REQUIRED("required")
class AssistantToolChoice:

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

Type type

The type of the tool. If type is function, the function name must be set

Accepts one of the following:
FUNCTION("function")
CODE_INTERPRETER("code_interpreter")
FILE_SEARCH("file_search")
Optional<AssistantToolChoiceFunction> function
String name

The name of the function to call.

List<AssistantTool> tools

The list of tools that the assistant used for this run.

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:
String name

The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

Optional<String> description

A description of what the function does, used by the model to choose when and how to call the function.

Optional<FunctionParameters> parameters

The parameters the functions accepts, described as a JSON Schema object. See the guide for examples, and the JSON Schema reference for documentation about the format.

Omitting parameters defines a function with an empty parameter list.

Optional<Boolean> strict

Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the parameters field. Only a subset of JSON Schema is supported when strict is true. Learn more about Structured Outputs in the function calling guide.

JsonValue; type "function"constant"function"constant

The type of tool being defined: function

Optional<TruncationStrategy> truncationStrategy

Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

Type type

The truncation strategy to use for the thread. The default is auto. If set to last_messages, the thread will be truncated to the n most recent messages in the thread. When set to auto, messages in the middle of the thread will be dropped to fit the context length of the model, max_prompt_tokens.

Accepts one of the following:
AUTO("auto")
LAST_MESSAGES("last_messages")
Optional<Long> lastMessages

The number of most recent messages from the thread when constructing the context for the run.

minimum1
Optional<Usage> usage

Usage statistics related to the run. This value will be null if the run is not in a terminal state (i.e. in_progress, queued, etc.).

long completionTokens

Number of completion tokens used over the course of the run.

long promptTokens

Number of prompt tokens used over the course of the run.

long totalTokens

Total number of tokens used (prompt + completion).

Optional<Double> temperature

The sampling temperature used for this run. If not set, defaults to 1.

Optional<Double> topP

The nucleus sampling value used for this run. If not set, defaults to 1.

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

Represents an execution run on a thread.

String id

The identifier, which can be referenced in API endpoints.

String assistantId

The ID of the assistant used for execution of this run.

Optional<Long> cancelledAt

The Unix timestamp (in seconds) for when the run was cancelled.

Optional<Long> completedAt

The Unix timestamp (in seconds) for when the run was completed.

long createdAt

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

Optional<Long> expiresAt

The Unix timestamp (in seconds) for when the run will expire.

Optional<Long> failedAt

The Unix timestamp (in seconds) for when the run failed.

Optional<IncompleteDetails> incompleteDetails

Details on why the run is incomplete. Will be null if the run is not incomplete.

Optional<Reason> reason

The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.

Accepts one of the following:
MAX_COMPLETION_TOKENS("max_completion_tokens")
MAX_PROMPT_TOKENS("max_prompt_tokens")
String instructions

The instructions that the assistant used for this run.

Optional<LastError> lastError

The last error associated with this run. Will be null if there are no errors.

Code code

One of server_error, rate_limit_exceeded, or invalid_prompt.

Accepts one of the following:
SERVER_ERROR("server_error")
RATE_LIMIT_EXCEEDED("rate_limit_exceeded")
INVALID_PROMPT("invalid_prompt")
String message

A human-readable description of the error.

Optional<Long> maxCompletionTokens

The maximum number of completion tokens specified to have been used over the course of the run.

minimum256
Optional<Long> maxPromptTokens

The maximum number of prompt tokens specified to have been used over the course of the run.

minimum256
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

The model that the assistant used for this run.

JsonValue; object_ "thread.run"constant"thread.run"constant

The object type, which is always thread.run.

boolean parallelToolCalls

Whether to enable parallel function calling during tool use.

Optional<RequiredAction> requiredAction

Details on the action required to continue the run. Will be null if no action is required.

SubmitToolOutputs submitToolOutputs

Details on the tool outputs needed for this run to continue.

A list of the relevant tool calls.

String id

The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the Submit tool outputs to run endpoint.

Function function

The function definition.

String arguments

The arguments that the model expects you to pass to the function.

String name

The name of the function.

JsonValue; type "function"constant"function"constant

The type of tool call the output is required for. For now, this is always function.

JsonValue; type "submit_tool_outputs"constant"submit_tool_outputs"constant

For now, this is always submit_tool_outputs.

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.

Accepts one of the following:
JsonValue;
class ResponseFormatText:

Default response format. Used to generate text responses.

JsonValue; type "text"constant"text"constant

The type of response format being defined. Always text.

class ResponseFormatJsonObject:

JSON object response format. An older method of generating JSON responses. Using json_schema is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so.

JsonValue; type "json_object"constant"json_object"constant

The type of response format being defined. Always json_object.

class ResponseFormatJsonSchema:

JSON Schema response format. Used to generate structured JSON responses. Learn more about Structured Outputs.

JsonSchema jsonSchema

Structured Outputs configuration options, including a JSON Schema.

String name

The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

Optional<String> description

A description of what the response format is for, used by the model to determine how to respond in the format.

Optional<Schema> schema

The schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas here.

Optional<Boolean> strict

Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the schema field. Only a subset of JSON Schema is supported when strict is true. To learn more, read the Structured Outputs guide.

JsonValue; type "json_schema"constant"json_schema"constant

The type of response format being defined. Always json_schema.

Optional<Long> startedAt

The Unix timestamp (in seconds) for when the run was started.

RunStatus status

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

Accepts one of the following:
QUEUED("queued")
IN_PROGRESS("in_progress")
REQUIRES_ACTION("requires_action")
CANCELLING("cancelling")
CANCELLED("cancelled")
FAILED("failed")
COMPLETED("completed")
INCOMPLETE("incomplete")
EXPIRED("expired")
String threadId

The ID of the thread that was executed on as a part of this run.

Optional<AssistantToolChoiceOption> toolChoice

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.

Accepts one of the following:
Auto
Accepts one of the following:
NONE("none")
AUTO("auto")
REQUIRED("required")
class AssistantToolChoice:

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

Type type

The type of the tool. If type is function, the function name must be set

Accepts one of the following:
FUNCTION("function")
CODE_INTERPRETER("code_interpreter")
FILE_SEARCH("file_search")
Optional<AssistantToolChoiceFunction> function
String name

The name of the function to call.

List<AssistantTool> tools

The list of tools that the assistant used for this run.

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:
String name

The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

Optional<String> description

A description of what the function does, used by the model to choose when and how to call the function.

Optional<FunctionParameters> parameters

The parameters the functions accepts, described as a JSON Schema object. See the guide for examples, and the JSON Schema reference for documentation about the format.

Omitting parameters defines a function with an empty parameter list.

Optional<Boolean> strict

Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the parameters field. Only a subset of JSON Schema is supported when strict is true. Learn more about Structured Outputs in the function calling guide.

JsonValue; type "function"constant"function"constant

The type of tool being defined: function

Optional<TruncationStrategy> truncationStrategy

Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

Type type

The truncation strategy to use for the thread. The default is auto. If set to last_messages, the thread will be truncated to the n most recent messages in the thread. When set to auto, messages in the middle of the thread will be dropped to fit the context length of the model, max_prompt_tokens.

Accepts one of the following:
AUTO("auto")
LAST_MESSAGES("last_messages")
Optional<Long> lastMessages

The number of most recent messages from the thread when constructing the context for the run.

minimum1
Optional<Usage> usage

Usage statistics related to the run. This value will be null if the run is not in a terminal state (i.e. in_progress, queued, etc.).

long completionTokens

Number of completion tokens used over the course of the run.

long promptTokens

Number of prompt tokens used over the course of the run.

long totalTokens

Total number of tokens used (prompt + completion).

Optional<Double> temperature

The sampling temperature used for this run. If not set, defaults to 1.

Optional<Double> topP

The nucleus sampling value used for this run. If not set, defaults to 1.

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

Represents an execution run on a thread.

String id

The identifier, which can be referenced in API endpoints.

String assistantId

The ID of the assistant used for execution of this run.

Optional<Long> cancelledAt

The Unix timestamp (in seconds) for when the run was cancelled.

Optional<Long> completedAt

The Unix timestamp (in seconds) for when the run was completed.

long createdAt

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

Optional<Long> expiresAt

The Unix timestamp (in seconds) for when the run will expire.

Optional<Long> failedAt

The Unix timestamp (in seconds) for when the run failed.

Optional<IncompleteDetails> incompleteDetails

Details on why the run is incomplete. Will be null if the run is not incomplete.

Optional<Reason> reason

The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.

Accepts one of the following:
MAX_COMPLETION_TOKENS("max_completion_tokens")
MAX_PROMPT_TOKENS("max_prompt_tokens")
String instructions

The instructions that the assistant used for this run.

Optional<LastError> lastError

The last error associated with this run. Will be null if there are no errors.

Code code

One of server_error, rate_limit_exceeded, or invalid_prompt.

Accepts one of the following:
SERVER_ERROR("server_error")
RATE_LIMIT_EXCEEDED("rate_limit_exceeded")
INVALID_PROMPT("invalid_prompt")
String message

A human-readable description of the error.

Optional<Long> maxCompletionTokens

The maximum number of completion tokens specified to have been used over the course of the run.

minimum256
Optional<Long> maxPromptTokens

The maximum number of prompt tokens specified to have been used over the course of the run.

minimum256
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

The model that the assistant used for this run.

JsonValue; object_ "thread.run"constant"thread.run"constant

The object type, which is always thread.run.

boolean parallelToolCalls

Whether to enable parallel function calling during tool use.

Optional<RequiredAction> requiredAction

Details on the action required to continue the run. Will be null if no action is required.

SubmitToolOutputs submitToolOutputs

Details on the tool outputs needed for this run to continue.

A list of the relevant tool calls.

String id

The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the Submit tool outputs to run endpoint.

Function function

The function definition.

String arguments

The arguments that the model expects you to pass to the function.

String name

The name of the function.

JsonValue; type "function"constant"function"constant

The type of tool call the output is required for. For now, this is always function.

JsonValue; type "submit_tool_outputs"constant"submit_tool_outputs"constant

For now, this is always submit_tool_outputs.

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.

Accepts one of the following:
JsonValue;
class ResponseFormatText:

Default response format. Used to generate text responses.

JsonValue; type "text"constant"text"constant

The type of response format being defined. Always text.

class ResponseFormatJsonObject:

JSON object response format. An older method of generating JSON responses. Using json_schema is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so.

JsonValue; type "json_object"constant"json_object"constant

The type of response format being defined. Always json_object.

class ResponseFormatJsonSchema:

JSON Schema response format. Used to generate structured JSON responses. Learn more about Structured Outputs.

JsonSchema jsonSchema

Structured Outputs configuration options, including a JSON Schema.

String name

The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

Optional<String> description

A description of what the response format is for, used by the model to determine how to respond in the format.

Optional<Schema> schema

The schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas here.

Optional<Boolean> strict

Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the schema field. Only a subset of JSON Schema is supported when strict is true. To learn more, read the Structured Outputs guide.

JsonValue; type "json_schema"constant"json_schema"constant

The type of response format being defined. Always json_schema.

Optional<Long> startedAt

The Unix timestamp (in seconds) for when the run was started.

RunStatus status

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

Accepts one of the following:
QUEUED("queued")
IN_PROGRESS("in_progress")
REQUIRES_ACTION("requires_action")
CANCELLING("cancelling")
CANCELLED("cancelled")
FAILED("failed")
COMPLETED("completed")
INCOMPLETE("incomplete")
EXPIRED("expired")
String threadId

The ID of the thread that was executed on as a part of this run.

Optional<AssistantToolChoiceOption> toolChoice

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.

Accepts one of the following:
Auto
Accepts one of the following:
NONE("none")
AUTO("auto")
REQUIRED("required")
class AssistantToolChoice:

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

Type type

The type of the tool. If type is function, the function name must be set

Accepts one of the following:
FUNCTION("function")
CODE_INTERPRETER("code_interpreter")
FILE_SEARCH("file_search")
Optional<AssistantToolChoiceFunction> function
String name

The name of the function to call.

List<AssistantTool> tools

The list of tools that the assistant used for this run.

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:
String name

The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

Optional<String> description

A description of what the function does, used by the model to choose when and how to call the function.

Optional<FunctionParameters> parameters

The parameters the functions accepts, described as a JSON Schema object. See the guide for examples, and the JSON Schema reference for documentation about the format.

Omitting parameters defines a function with an empty parameter list.

Optional<Boolean> strict

Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the parameters field. Only a subset of JSON Schema is supported when strict is true. Learn more about Structured Outputs in the function calling guide.

JsonValue; type "function"constant"function"constant

The type of tool being defined: function

Optional<TruncationStrategy> truncationStrategy

Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

Type type

The truncation strategy to use for the thread. The default is auto. If set to last_messages, the thread will be truncated to the n most recent messages in the thread. When set to auto, messages in the middle of the thread will be dropped to fit the context length of the model, max_prompt_tokens.

Accepts one of the following:
AUTO("auto")
LAST_MESSAGES("last_messages")
Optional<Long> lastMessages

The number of most recent messages from the thread when constructing the context for the run.

minimum1
Optional<Usage> usage

Usage statistics related to the run. This value will be null if the run is not in a terminal state (i.e. in_progress, queued, etc.).

long completionTokens

Number of completion tokens used over the course of the run.

long promptTokens

Number of prompt tokens used over the course of the run.

long totalTokens

Total number of tokens used (prompt + completion).

Optional<Double> temperature

The sampling temperature used for this run. If not set, defaults to 1.

Optional<Double> topP

The nucleus sampling value used for this run. If not set, defaults to 1.

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

Represents an execution run on a thread.

String id

The identifier, which can be referenced in API endpoints.

String assistantId

The ID of the assistant used for execution of this run.

Optional<Long> cancelledAt

The Unix timestamp (in seconds) for when the run was cancelled.

Optional<Long> completedAt

The Unix timestamp (in seconds) for when the run was completed.

long createdAt

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

Optional<Long> expiresAt

The Unix timestamp (in seconds) for when the run will expire.

Optional<Long> failedAt

The Unix timestamp (in seconds) for when the run failed.

Optional<IncompleteDetails> incompleteDetails

Details on why the run is incomplete. Will be null if the run is not incomplete.

Optional<Reason> reason

The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.

Accepts one of the following:
MAX_COMPLETION_TOKENS("max_completion_tokens")
MAX_PROMPT_TOKENS("max_prompt_tokens")
String instructions

The instructions that the assistant used for this run.

Optional<LastError> lastError

The last error associated with this run. Will be null if there are no errors.

Code code

One of server_error, rate_limit_exceeded, or invalid_prompt.

Accepts one of the following:
SERVER_ERROR("server_error")
RATE_LIMIT_EXCEEDED("rate_limit_exceeded")
INVALID_PROMPT("invalid_prompt")
String message

A human-readable description of the error.

Optional<Long> maxCompletionTokens

The maximum number of completion tokens specified to have been used over the course of the run.

minimum256
Optional<Long> maxPromptTokens

The maximum number of prompt tokens specified to have been used over the course of the run.

minimum256
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

The model that the assistant used for this run.

JsonValue; object_ "thread.run"constant"thread.run"constant

The object type, which is always thread.run.

boolean parallelToolCalls

Whether to enable parallel function calling during tool use.

Optional<RequiredAction> requiredAction

Details on the action required to continue the run. Will be null if no action is required.

SubmitToolOutputs submitToolOutputs

Details on the tool outputs needed for this run to continue.

A list of the relevant tool calls.

String id

The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the Submit tool outputs to run endpoint.

Function function

The function definition.

String arguments

The arguments that the model expects you to pass to the function.

String name

The name of the function.

JsonValue; type "function"constant"function"constant

The type of tool call the output is required for. For now, this is always function.

JsonValue; type "submit_tool_outputs"constant"submit_tool_outputs"constant

For now, this is always submit_tool_outputs.

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.

Accepts one of the following:
JsonValue;
class ResponseFormatText:

Default response format. Used to generate text responses.

JsonValue; type "text"constant"text"constant

The type of response format being defined. Always text.

class ResponseFormatJsonObject:

JSON object response format. An older method of generating JSON responses. Using json_schema is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so.

JsonValue; type "json_object"constant"json_object"constant

The type of response format being defined. Always json_object.

class ResponseFormatJsonSchema:

JSON Schema response format. Used to generate structured JSON responses. Learn more about Structured Outputs.

JsonSchema jsonSchema

Structured Outputs configuration options, including a JSON Schema.

String name

The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

Optional<String> description

A description of what the response format is for, used by the model to determine how to respond in the format.

Optional<Schema> schema

The schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas here.

Optional<Boolean> strict

Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the schema field. Only a subset of JSON Schema is supported when strict is true. To learn more, read the Structured Outputs guide.

JsonValue; type "json_schema"constant"json_schema"constant

The type of response format being defined. Always json_schema.

Optional<Long> startedAt

The Unix timestamp (in seconds) for when the run was started.

RunStatus status

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

Accepts one of the following:
QUEUED("queued")
IN_PROGRESS("in_progress")
REQUIRES_ACTION("requires_action")
CANCELLING("cancelling")
CANCELLED("cancelled")
FAILED("failed")
COMPLETED("completed")
INCOMPLETE("incomplete")
EXPIRED("expired")
String threadId

The ID of the thread that was executed on as a part of this run.

Optional<AssistantToolChoiceOption> toolChoice

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.

Accepts one of the following:
Auto
Accepts one of the following:
NONE("none")
AUTO("auto")
REQUIRED("required")
class AssistantToolChoice:

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

Type type

The type of the tool. If type is function, the function name must be set

Accepts one of the following:
FUNCTION("function")
CODE_INTERPRETER("code_interpreter")
FILE_SEARCH("file_search")
Optional<AssistantToolChoiceFunction> function
String name

The name of the function to call.

List<AssistantTool> tools

The list of tools that the assistant used for this run.

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:
String name

The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

Optional<String> description

A description of what the function does, used by the model to choose when and how to call the function.

Optional<FunctionParameters> parameters

The parameters the functions accepts, described as a JSON Schema object. See the guide for examples, and the JSON Schema reference for documentation about the format.

Omitting parameters defines a function with an empty parameter list.

Optional<Boolean> strict

Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the parameters field. Only a subset of JSON Schema is supported when strict is true. Learn more about Structured Outputs in the function calling guide.

JsonValue; type "function"constant"function"constant

The type of tool being defined: function

Optional<TruncationStrategy> truncationStrategy

Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

Type type

The truncation strategy to use for the thread. The default is auto. If set to last_messages, the thread will be truncated to the n most recent messages in the thread. When set to auto, messages in the middle of the thread will be dropped to fit the context length of the model, max_prompt_tokens.

Accepts one of the following:
AUTO("auto")
LAST_MESSAGES("last_messages")
Optional<Long> lastMessages

The number of most recent messages from the thread when constructing the context for the run.

minimum1
Optional<Usage> usage

Usage statistics related to the run. This value will be null if the run is not in a terminal state (i.e. in_progress, queued, etc.).

long completionTokens

Number of completion tokens used over the course of the run.

long promptTokens

Number of prompt tokens used over the course of the run.

long totalTokens

Total number of tokens used (prompt + completion).

Optional<Double> temperature

The sampling temperature used for this run. If not set, defaults to 1.

Optional<Double> topP

The nucleus sampling value used for this run. If not set, defaults to 1.

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

Represents an execution run on a thread.

String id

The identifier, which can be referenced in API endpoints.

String assistantId

The ID of the assistant used for execution of this run.

Optional<Long> cancelledAt

The Unix timestamp (in seconds) for when the run was cancelled.

Optional<Long> completedAt

The Unix timestamp (in seconds) for when the run was completed.

long createdAt

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

Optional<Long> expiresAt

The Unix timestamp (in seconds) for when the run will expire.

Optional<Long> failedAt

The Unix timestamp (in seconds) for when the run failed.

Optional<IncompleteDetails> incompleteDetails

Details on why the run is incomplete. Will be null if the run is not incomplete.

Optional<Reason> reason

The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.

Accepts one of the following:
MAX_COMPLETION_TOKENS("max_completion_tokens")
MAX_PROMPT_TOKENS("max_prompt_tokens")
String instructions

The instructions that the assistant used for this run.

Optional<LastError> lastError

The last error associated with this run. Will be null if there are no errors.

Code code

One of server_error, rate_limit_exceeded, or invalid_prompt.

Accepts one of the following:
SERVER_ERROR("server_error")
RATE_LIMIT_EXCEEDED("rate_limit_exceeded")
INVALID_PROMPT("invalid_prompt")
String message

A human-readable description of the error.

Optional<Long> maxCompletionTokens

The maximum number of completion tokens specified to have been used over the course of the run.

minimum256
Optional<Long> maxPromptTokens

The maximum number of prompt tokens specified to have been used over the course of the run.

minimum256
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

The model that the assistant used for this run.

JsonValue; object_ "thread.run"constant"thread.run"constant

The object type, which is always thread.run.

boolean parallelToolCalls

Whether to enable parallel function calling during tool use.

Optional<RequiredAction> requiredAction

Details on the action required to continue the run. Will be null if no action is required.

SubmitToolOutputs submitToolOutputs

Details on the tool outputs needed for this run to continue.

A list of the relevant tool calls.

String id

The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the Submit tool outputs to run endpoint.

Function function

The function definition.

String arguments

The arguments that the model expects you to pass to the function.

String name

The name of the function.

JsonValue; type "function"constant"function"constant

The type of tool call the output is required for. For now, this is always function.

JsonValue; type "submit_tool_outputs"constant"submit_tool_outputs"constant

For now, this is always submit_tool_outputs.

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.

Accepts one of the following:
JsonValue;
class ResponseFormatText:

Default response format. Used to generate text responses.

JsonValue; type "text"constant"text"constant

The type of response format being defined. Always text.

class ResponseFormatJsonObject:

JSON object response format. An older method of generating JSON responses. Using json_schema is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so.

JsonValue; type "json_object"constant"json_object"constant

The type of response format being defined. Always json_object.

class ResponseFormatJsonSchema:

JSON Schema response format. Used to generate structured JSON responses. Learn more about Structured Outputs.

JsonSchema jsonSchema

Structured Outputs configuration options, including a JSON Schema.

String name

The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

Optional<String> description

A description of what the response format is for, used by the model to determine how to respond in the format.

Optional<Schema> schema

The schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas here.

Optional<Boolean> strict

Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the schema field. Only a subset of JSON Schema is supported when strict is true. To learn more, read the Structured Outputs guide.

JsonValue; type "json_schema"constant"json_schema"constant

The type of response format being defined. Always json_schema.

Optional<Long> startedAt

The Unix timestamp (in seconds) for when the run was started.

RunStatus status

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

Accepts one of the following:
QUEUED("queued")
IN_PROGRESS("in_progress")
REQUIRES_ACTION("requires_action")
CANCELLING("cancelling")
CANCELLED("cancelled")
FAILED("failed")
COMPLETED("completed")
INCOMPLETE("incomplete")
EXPIRED("expired")
String threadId

The ID of the thread that was executed on as a part of this run.

Optional<AssistantToolChoiceOption> toolChoice

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.

Accepts one of the following:
Auto
Accepts one of the following:
NONE("none")
AUTO("auto")
REQUIRED("required")
class AssistantToolChoice:

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

Type type

The type of the tool. If type is function, the function name must be set

Accepts one of the following:
FUNCTION("function")
CODE_INTERPRETER("code_interpreter")
FILE_SEARCH("file_search")
Optional<AssistantToolChoiceFunction> function
String name

The name of the function to call.

List<AssistantTool> tools

The list of tools that the assistant used for this run.

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:
String name

The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

Optional<String> description

A description of what the function does, used by the model to choose when and how to call the function.

Optional<FunctionParameters> parameters

The parameters the functions accepts, described as a JSON Schema object. See the guide for examples, and the JSON Schema reference for documentation about the format.

Omitting parameters defines a function with an empty parameter list.

Optional<Boolean> strict

Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the parameters field. Only a subset of JSON Schema is supported when strict is true. Learn more about Structured Outputs in the function calling guide.

JsonValue; type "function"constant"function"constant

The type of tool being defined: function

Optional<TruncationStrategy> truncationStrategy

Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

Type type

The truncation strategy to use for the thread. The default is auto. If set to last_messages, the thread will be truncated to the n most recent messages in the thread. When set to auto, messages in the middle of the thread will be dropped to fit the context length of the model, max_prompt_tokens.

Accepts one of the following:
AUTO("auto")
LAST_MESSAGES("last_messages")
Optional<Long> lastMessages

The number of most recent messages from the thread when constructing the context for the run.

minimum1
Optional<Usage> usage

Usage statistics related to the run. This value will be null if the run is not in a terminal state (i.e. in_progress, queued, etc.).

long completionTokens

Number of completion tokens used over the course of the run.

long promptTokens

Number of prompt tokens used over the course of the run.

long totalTokens

Total number of tokens used (prompt + completion).

Optional<Double> temperature

The sampling temperature used for this run. If not set, defaults to 1.

Optional<Double> topP

The nucleus sampling value used for this run. If not set, defaults to 1.

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

Represents an execution run on a thread.

String id

The identifier, which can be referenced in API endpoints.

String assistantId

The ID of the assistant used for execution of this run.

Optional<Long> cancelledAt

The Unix timestamp (in seconds) for when the run was cancelled.

Optional<Long> completedAt

The Unix timestamp (in seconds) for when the run was completed.

long createdAt

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

Optional<Long> expiresAt

The Unix timestamp (in seconds) for when the run will expire.

Optional<Long> failedAt

The Unix timestamp (in seconds) for when the run failed.

Optional<IncompleteDetails> incompleteDetails

Details on why the run is incomplete. Will be null if the run is not incomplete.

Optional<Reason> reason

The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.

Accepts one of the following:
MAX_COMPLETION_TOKENS("max_completion_tokens")
MAX_PROMPT_TOKENS("max_prompt_tokens")
String instructions

The instructions that the assistant used for this run.

Optional<LastError> lastError

The last error associated with this run. Will be null if there are no errors.

Code code

One of server_error, rate_limit_exceeded, or invalid_prompt.

Accepts one of the following:
SERVER_ERROR("server_error")
RATE_LIMIT_EXCEEDED("rate_limit_exceeded")
INVALID_PROMPT("invalid_prompt")
String message

A human-readable description of the error.

Optional<Long> maxCompletionTokens

The maximum number of completion tokens specified to have been used over the course of the run.

minimum256
Optional<Long> maxPromptTokens

The maximum number of prompt tokens specified to have been used over the course of the run.

minimum256
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

The model that the assistant used for this run.

JsonValue; object_ "thread.run"constant"thread.run"constant

The object type, which is always thread.run.

boolean parallelToolCalls

Whether to enable parallel function calling during tool use.

Optional<RequiredAction> requiredAction

Details on the action required to continue the run. Will be null if no action is required.

SubmitToolOutputs submitToolOutputs

Details on the tool outputs needed for this run to continue.

A list of the relevant tool calls.

String id

The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the Submit tool outputs to run endpoint.

Function function

The function definition.

String arguments

The arguments that the model expects you to pass to the function.

String name

The name of the function.

JsonValue; type "function"constant"function"constant

The type of tool call the output is required for. For now, this is always function.

JsonValue; type "submit_tool_outputs"constant"submit_tool_outputs"constant

For now, this is always submit_tool_outputs.

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.

Accepts one of the following:
JsonValue;
class ResponseFormatText:

Default response format. Used to generate text responses.

JsonValue; type "text"constant"text"constant

The type of response format being defined. Always text.

class ResponseFormatJsonObject:

JSON object response format. An older method of generating JSON responses. Using json_schema is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so.

JsonValue; type "json_object"constant"json_object"constant

The type of response format being defined. Always json_object.

class ResponseFormatJsonSchema:

JSON Schema response format. Used to generate structured JSON responses. Learn more about Structured Outputs.

JsonSchema jsonSchema

Structured Outputs configuration options, including a JSON Schema.

String name

The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

Optional<String> description

A description of what the response format is for, used by the model to determine how to respond in the format.

Optional<Schema> schema

The schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas here.

Optional<Boolean> strict

Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the schema field. Only a subset of JSON Schema is supported when strict is true. To learn more, read the Structured Outputs guide.

JsonValue; type "json_schema"constant"json_schema"constant

The type of response format being defined. Always json_schema.

Optional<Long> startedAt

The Unix timestamp (in seconds) for when the run was started.

RunStatus status

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

Accepts one of the following:
QUEUED("queued")
IN_PROGRESS("in_progress")
REQUIRES_ACTION("requires_action")
CANCELLING("cancelling")
CANCELLED("cancelled")
FAILED("failed")
COMPLETED("completed")
INCOMPLETE("incomplete")
EXPIRED("expired")
String threadId

The ID of the thread that was executed on as a part of this run.

Optional<AssistantToolChoiceOption> toolChoice

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.

Accepts one of the following:
Auto
Accepts one of the following:
NONE("none")
AUTO("auto")
REQUIRED("required")
class AssistantToolChoice:

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

Type type

The type of the tool. If type is function, the function name must be set

Accepts one of the following:
FUNCTION("function")
CODE_INTERPRETER("code_interpreter")
FILE_SEARCH("file_search")
Optional<AssistantToolChoiceFunction> function
String name

The name of the function to call.

List<AssistantTool> tools

The list of tools that the assistant used for this run.

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:
String name

The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

Optional<String> description

A description of what the function does, used by the model to choose when and how to call the function.

Optional<FunctionParameters> parameters

The parameters the functions accepts, described as a JSON Schema object. See the guide for examples, and the JSON Schema reference for documentation about the format.

Omitting parameters defines a function with an empty parameter list.

Optional<Boolean> strict

Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the parameters field. Only a subset of JSON Schema is supported when strict is true. Learn more about Structured Outputs in the function calling guide.

JsonValue; type "function"constant"function"constant

The type of tool being defined: function

Optional<TruncationStrategy> truncationStrategy

Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

Type type

The truncation strategy to use for the thread. The default is auto. If set to last_messages, the thread will be truncated to the n most recent messages in the thread. When set to auto, messages in the middle of the thread will be dropped to fit the context length of the model, max_prompt_tokens.

Accepts one of the following:
AUTO("auto")
LAST_MESSAGES("last_messages")
Optional<Long> lastMessages

The number of most recent messages from the thread when constructing the context for the run.

minimum1
Optional<Usage> usage

Usage statistics related to the run. This value will be null if the run is not in a terminal state (i.e. in_progress, queued, etc.).

long completionTokens

Number of completion tokens used over the course of the run.

long promptTokens

Number of prompt tokens used over the course of the run.

long totalTokens

Total number of tokens used (prompt + completion).

Optional<Double> temperature

The sampling temperature used for this run. If not set, defaults to 1.

Optional<Double> topP

The nucleus sampling value used for this run. If not set, defaults to 1.

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

Represents an execution run on a thread.

String id

The identifier, which can be referenced in API endpoints.

String assistantId

The ID of the assistant used for execution of this run.

Optional<Long> cancelledAt

The Unix timestamp (in seconds) for when the run was cancelled.

Optional<Long> completedAt

The Unix timestamp (in seconds) for when the run was completed.

long createdAt

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

Optional<Long> expiresAt

The Unix timestamp (in seconds) for when the run will expire.

Optional<Long> failedAt

The Unix timestamp (in seconds) for when the run failed.

Optional<IncompleteDetails> incompleteDetails

Details on why the run is incomplete. Will be null if the run is not incomplete.

Optional<Reason> reason

The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.

Accepts one of the following:
MAX_COMPLETION_TOKENS("max_completion_tokens")
MAX_PROMPT_TOKENS("max_prompt_tokens")
String instructions

The instructions that the assistant used for this run.

Optional<LastError> lastError

The last error associated with this run. Will be null if there are no errors.

Code code

One of server_error, rate_limit_exceeded, or invalid_prompt.

Accepts one of the following:
SERVER_ERROR("server_error")
RATE_LIMIT_EXCEEDED("rate_limit_exceeded")
INVALID_PROMPT("invalid_prompt")
String message

A human-readable description of the error.

Optional<Long> maxCompletionTokens

The maximum number of completion tokens specified to have been used over the course of the run.

minimum256
Optional<Long> maxPromptTokens

The maximum number of prompt tokens specified to have been used over the course of the run.

minimum256
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

The model that the assistant used for this run.

JsonValue; object_ "thread.run"constant"thread.run"constant

The object type, which is always thread.run.

boolean parallelToolCalls

Whether to enable parallel function calling during tool use.

Optional<RequiredAction> requiredAction

Details on the action required to continue the run. Will be null if no action is required.

SubmitToolOutputs submitToolOutputs

Details on the tool outputs needed for this run to continue.

A list of the relevant tool calls.

String id

The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the Submit tool outputs to run endpoint.

Function function

The function definition.

String arguments

The arguments that the model expects you to pass to the function.

String name

The name of the function.

JsonValue; type "function"constant"function"constant

The type of tool call the output is required for. For now, this is always function.

JsonValue; type "submit_tool_outputs"constant"submit_tool_outputs"constant

For now, this is always submit_tool_outputs.

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.

Accepts one of the following:
JsonValue;
class ResponseFormatText:

Default response format. Used to generate text responses.

JsonValue; type "text"constant"text"constant

The type of response format being defined. Always text.

class ResponseFormatJsonObject:

JSON object response format. An older method of generating JSON responses. Using json_schema is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so.

JsonValue; type "json_object"constant"json_object"constant

The type of response format being defined. Always json_object.

class ResponseFormatJsonSchema:

JSON Schema response format. Used to generate structured JSON responses. Learn more about Structured Outputs.

JsonSchema jsonSchema

Structured Outputs configuration options, including a JSON Schema.

String name

The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

Optional<String> description

A description of what the response format is for, used by the model to determine how to respond in the format.

Optional<Schema> schema

The schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas here.

Optional<Boolean> strict

Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the schema field. Only a subset of JSON Schema is supported when strict is true. To learn more, read the Structured Outputs guide.

JsonValue; type "json_schema"constant"json_schema"constant

The type of response format being defined. Always json_schema.

Optional<Long> startedAt

The Unix timestamp (in seconds) for when the run was started.

RunStatus status

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

Accepts one of the following:
QUEUED("queued")
IN_PROGRESS("in_progress")
REQUIRES_ACTION("requires_action")
CANCELLING("cancelling")
CANCELLED("cancelled")
FAILED("failed")
COMPLETED("completed")
INCOMPLETE("incomplete")
EXPIRED("expired")
String threadId

The ID of the thread that was executed on as a part of this run.

Optional<AssistantToolChoiceOption> toolChoice

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.

Accepts one of the following:
Auto
Accepts one of the following:
NONE("none")
AUTO("auto")
REQUIRED("required")
class AssistantToolChoice:

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

Type type

The type of the tool. If type is function, the function name must be set

Accepts one of the following:
FUNCTION("function")
CODE_INTERPRETER("code_interpreter")
FILE_SEARCH("file_search")
Optional<AssistantToolChoiceFunction> function
String name

The name of the function to call.

List<AssistantTool> tools

The list of tools that the assistant used for this run.

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:
String name

The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

Optional<String> description

A description of what the function does, used by the model to choose when and how to call the function.

Optional<FunctionParameters> parameters

The parameters the functions accepts, described as a JSON Schema object. See the guide for examples, and the JSON Schema reference for documentation about the format.

Omitting parameters defines a function with an empty parameter list.

Optional<Boolean> strict

Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the parameters field. Only a subset of JSON Schema is supported when strict is true. Learn more about Structured Outputs in the function calling guide.

JsonValue; type "function"constant"function"constant

The type of tool being defined: function

Optional<TruncationStrategy> truncationStrategy

Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

Type type

The truncation strategy to use for the thread. The default is auto. If set to last_messages, the thread will be truncated to the n most recent messages in the thread. When set to auto, messages in the middle of the thread will be dropped to fit the context length of the model, max_prompt_tokens.

Accepts one of the following:
AUTO("auto")
LAST_MESSAGES("last_messages")
Optional<Long> lastMessages

The number of most recent messages from the thread when constructing the context for the run.

minimum1
Optional<Usage> usage

Usage statistics related to the run. This value will be null if the run is not in a terminal state (i.e. in_progress, queued, etc.).

long completionTokens

Number of completion tokens used over the course of the run.

long promptTokens

Number of prompt tokens used over the course of the run.

long totalTokens

Total number of tokens used (prompt + completion).

Optional<Double> temperature

The sampling temperature used for this run. If not set, defaults to 1.

Optional<Double> topP

The nucleus sampling value used for this run. If not set, defaults to 1.

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

Represents an execution run on a thread.

String id

The identifier, which can be referenced in API endpoints.

String assistantId

The ID of the assistant used for execution of this run.

Optional<Long> cancelledAt

The Unix timestamp (in seconds) for when the run was cancelled.

Optional<Long> completedAt

The Unix timestamp (in seconds) for when the run was completed.

long createdAt

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

Optional<Long> expiresAt

The Unix timestamp (in seconds) for when the run will expire.

Optional<Long> failedAt

The Unix timestamp (in seconds) for when the run failed.

Optional<IncompleteDetails> incompleteDetails

Details on why the run is incomplete. Will be null if the run is not incomplete.

Optional<Reason> reason

The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.

Accepts one of the following:
MAX_COMPLETION_TOKENS("max_completion_tokens")
MAX_PROMPT_TOKENS("max_prompt_tokens")
String instructions

The instructions that the assistant used for this run.

Optional<LastError> lastError

The last error associated with this run. Will be null if there are no errors.

Code code

One of server_error, rate_limit_exceeded, or invalid_prompt.

Accepts one of the following:
SERVER_ERROR("server_error")
RATE_LIMIT_EXCEEDED("rate_limit_exceeded")
INVALID_PROMPT("invalid_prompt")
String message

A human-readable description of the error.

Optional<Long> maxCompletionTokens

The maximum number of completion tokens specified to have been used over the course of the run.

minimum256
Optional<Long> maxPromptTokens

The maximum number of prompt tokens specified to have been used over the course of the run.

minimum256
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

The model that the assistant used for this run.

JsonValue; object_ "thread.run"constant"thread.run"constant

The object type, which is always thread.run.

boolean parallelToolCalls

Whether to enable parallel function calling during tool use.

Optional<RequiredAction> requiredAction

Details on the action required to continue the run. Will be null if no action is required.

SubmitToolOutputs submitToolOutputs

Details on the tool outputs needed for this run to continue.

A list of the relevant tool calls.

String id

The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the Submit tool outputs to run endpoint.

Function function

The function definition.

String arguments

The arguments that the model expects you to pass to the function.

String name

The name of the function.

JsonValue; type "function"constant"function"constant

The type of tool call the output is required for. For now, this is always function.

JsonValue; type "submit_tool_outputs"constant"submit_tool_outputs"constant

For now, this is always submit_tool_outputs.

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.

Accepts one of the following:
JsonValue;
class ResponseFormatText:

Default response format. Used to generate text responses.

JsonValue; type "text"constant"text"constant

The type of response format being defined. Always text.

class ResponseFormatJsonObject:

JSON object response format. An older method of generating JSON responses. Using json_schema is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so.

JsonValue; type "json_object"constant"json_object"constant

The type of response format being defined. Always json_object.

class ResponseFormatJsonSchema:

JSON Schema response format. Used to generate structured JSON responses. Learn more about Structured Outputs.

JsonSchema jsonSchema

Structured Outputs configuration options, including a JSON Schema.

String name

The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

Optional<String> description

A description of what the response format is for, used by the model to determine how to respond in the format.

Optional<Schema> schema

The schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas here.

Optional<Boolean> strict

Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the schema field. Only a subset of JSON Schema is supported when strict is true. To learn more, read the Structured Outputs guide.

JsonValue; type "json_schema"constant"json_schema"constant

The type of response format being defined. Always json_schema.

Optional<Long> startedAt

The Unix timestamp (in seconds) for when the run was started.

RunStatus status

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

Accepts one of the following:
QUEUED("queued")
IN_PROGRESS("in_progress")
REQUIRES_ACTION("requires_action")
CANCELLING("cancelling")
CANCELLED("cancelled")
FAILED("failed")
COMPLETED("completed")
INCOMPLETE("incomplete")
EXPIRED("expired")
String threadId

The ID of the thread that was executed on as a part of this run.

Optional<AssistantToolChoiceOption> toolChoice

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.

Accepts one of the following:
Auto
Accepts one of the following:
NONE("none")
AUTO("auto")
REQUIRED("required")
class AssistantToolChoice:

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

Type type

The type of the tool. If type is function, the function name must be set

Accepts one of the following:
FUNCTION("function")
CODE_INTERPRETER("code_interpreter")
FILE_SEARCH("file_search")
Optional<AssistantToolChoiceFunction> function
String name

The name of the function to call.

List<AssistantTool> tools

The list of tools that the assistant used for this run.

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:
String name

The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

Optional<String> description

A description of what the function does, used by the model to choose when and how to call the function.

Optional<FunctionParameters> parameters

The parameters the functions accepts, described as a JSON Schema object. See the guide for examples, and the JSON Schema reference for documentation about the format.

Omitting parameters defines a function with an empty parameter list.

Optional<Boolean> strict

Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the parameters field. Only a subset of JSON Schema is supported when strict is true. Learn more about Structured Outputs in the function calling guide.

JsonValue; type "function"constant"function"constant

The type of tool being defined: function

Optional<TruncationStrategy> truncationStrategy

Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

Type type

The truncation strategy to use for the thread. The default is auto. If set to last_messages, the thread will be truncated to the n most recent messages in the thread. When set to auto, messages in the middle of the thread will be dropped to fit the context length of the model, max_prompt_tokens.

Accepts one of the following:
AUTO("auto")
LAST_MESSAGES("last_messages")
Optional<Long> lastMessages

The number of most recent messages from the thread when constructing the context for the run.

minimum1
Optional<Usage> usage

Usage statistics related to the run. This value will be null if the run is not in a terminal state (i.e. in_progress, queued, etc.).

long completionTokens

Number of completion tokens used over the course of the run.

long promptTokens

Number of prompt tokens used over the course of the run.

long totalTokens

Total number of tokens used (prompt + completion).

Optional<Double> temperature

The sampling temperature used for this run. If not set, defaults to 1.

Optional<Double> topP

The nucleus sampling value used for this run. If not set, defaults to 1.

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

Represents a step in execution of a run.

String id

The identifier of the run step, which can be referenced in API endpoints.

String assistantId

The ID of the assistant associated with the run step.

Optional<Long> cancelledAt

The Unix timestamp (in seconds) for when the run step was cancelled.

Optional<Long> completedAt

The Unix timestamp (in seconds) for when the run step completed.

long createdAt

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

Optional<Long> expiredAt

The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired.

Optional<Long> failedAt

The Unix timestamp (in seconds) for when the run step failed.

Optional<LastError> lastError

The last error associated with this run step. Will be null if there are no errors.

Code code

One of server_error or rate_limit_exceeded.

Accepts one of the following:
SERVER_ERROR("server_error")
RATE_LIMIT_EXCEEDED("rate_limit_exceeded")
String message

A human-readable description of the error.

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.

JsonValue; object_ "thread.run.step"constant"thread.run.step"constant

The object type, which is always thread.run.step.

String runId

The ID of the run that this run step is a part of.

Status status

The status of the run step, which can be either in_progress, cancelled, failed, completed, or expired.

Accepts one of the following:
IN_PROGRESS("in_progress")
CANCELLED("cancelled")
FAILED("failed")
COMPLETED("completed")
EXPIRED("expired")
StepDetails stepDetails

The details of the run step.

Accepts one of the following:
class MessageCreationStepDetails:

Details of the message creation by the run step.

MessageCreation messageCreation
String messageId

The ID of the message that was created by this run step.

JsonValue; type "message_creation"constant"message_creation"constant

Always message_creation.

class ToolCallsStepDetails:

Details of the tool call.

List<ToolCall> toolCalls

An array of tool calls the run step was involved in. These can be associated with one of three types of tools: code_interpreter, file_search, or function.

Accepts one of the following:
class CodeInterpreterToolCall:

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

String id

The ID of the tool call.

CodeInterpreter codeInterpreter

The Code Interpreter tool call definition.

String input

The input to the Code Interpreter tool call.

List<Output> outputs

The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (logs) or images (image). Each of these are represented by a different object type.

Accepts one of the following:
class LogsOutput:

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

String logs

The text output from the Code Interpreter tool call.

JsonValue; type "logs"constant"logs"constant

Always logs.

class ImageOutput:
Image image
String fileId

The file ID of the image.

JsonValue; type "image"constant"image"constant

Always image.

JsonValue; type "code_interpreter"constant"code_interpreter"constant

The type of tool call. This is always going to be code_interpreter for this type of tool call.

class FileSearchToolCall:
String id

The ID of the tool call object.

Accepts one of the following:
JsonValue; type "file_search"constant"file_search"constant

The type of tool call. This is always going to be file_search for this type of tool call.

class FunctionToolCall:
String id

The ID of the tool call object.

Function function

The definition of the function that was called.

String arguments

The arguments passed to the function.

String name

The name of the function.

Optional<String> output

The output of the function. This will be null if the outputs have not been submitted yet.

JsonValue; type "function"constant"function"constant

The type of tool call. This is always going to be function for this type of tool call.

JsonValue; type "tool_calls"constant"tool_calls"constant

Always tool_calls.

String threadId

The ID of the thread that was run.

Type type

The type of run step, which can be either message_creation or tool_calls.

Accepts one of the following:
MESSAGE_CREATION("message_creation")
TOOL_CALLS("tool_calls")
Optional<Usage> usage

Usage statistics related to the run step. This value will be null while the run step's status is in_progress.

long completionTokens

Number of completion tokens used over the course of the run step.

long promptTokens

Number of prompt tokens used over the course of the run step.

long totalTokens

Total number of tokens used (prompt + completion).

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

Represents a step in execution of a run.

String id

The identifier of the run step, which can be referenced in API endpoints.

String assistantId

The ID of the assistant associated with the run step.

Optional<Long> cancelledAt

The Unix timestamp (in seconds) for when the run step was cancelled.

Optional<Long> completedAt

The Unix timestamp (in seconds) for when the run step completed.

long createdAt

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

Optional<Long> expiredAt

The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired.

Optional<Long> failedAt

The Unix timestamp (in seconds) for when the run step failed.

Optional<LastError> lastError

The last error associated with this run step. Will be null if there are no errors.

Code code

One of server_error or rate_limit_exceeded.

Accepts one of the following:
SERVER_ERROR("server_error")
RATE_LIMIT_EXCEEDED("rate_limit_exceeded")
String message

A human-readable description of the error.

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.

JsonValue; object_ "thread.run.step"constant"thread.run.step"constant

The object type, which is always thread.run.step.

String runId

The ID of the run that this run step is a part of.

Status status

The status of the run step, which can be either in_progress, cancelled, failed, completed, or expired.

Accepts one of the following:
IN_PROGRESS("in_progress")
CANCELLED("cancelled")
FAILED("failed")
COMPLETED("completed")
EXPIRED("expired")
StepDetails stepDetails

The details of the run step.

Accepts one of the following:
class MessageCreationStepDetails:

Details of the message creation by the run step.

MessageCreation messageCreation
String messageId

The ID of the message that was created by this run step.

JsonValue; type "message_creation"constant"message_creation"constant

Always message_creation.

class ToolCallsStepDetails:

Details of the tool call.

List<ToolCall> toolCalls

An array of tool calls the run step was involved in. These can be associated with one of three types of tools: code_interpreter, file_search, or function.

Accepts one of the following:
class CodeInterpreterToolCall:

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

String id

The ID of the tool call.

CodeInterpreter codeInterpreter

The Code Interpreter tool call definition.

String input

The input to the Code Interpreter tool call.

List<Output> outputs

The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (logs) or images (image). Each of these are represented by a different object type.

Accepts one of the following:
class LogsOutput:

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

String logs

The text output from the Code Interpreter tool call.

JsonValue; type "logs"constant"logs"constant

Always logs.

class ImageOutput:
Image image
String fileId

The file ID of the image.

JsonValue; type "image"constant"image"constant

Always image.

JsonValue; type "code_interpreter"constant"code_interpreter"constant

The type of tool call. This is always going to be code_interpreter for this type of tool call.

class FileSearchToolCall:
String id

The ID of the tool call object.

Accepts one of the following:
JsonValue; type "file_search"constant"file_search"constant

The type of tool call. This is always going to be file_search for this type of tool call.

class FunctionToolCall:
String id

The ID of the tool call object.

Function function

The definition of the function that was called.

String arguments

The arguments passed to the function.

String name

The name of the function.

Optional<String> output

The output of the function. This will be null if the outputs have not been submitted yet.

JsonValue; type "function"constant"function"constant

The type of tool call. This is always going to be function for this type of tool call.

JsonValue; type "tool_calls"constant"tool_calls"constant

Always tool_calls.

String threadId

The ID of the thread that was run.

Type type

The type of run step, which can be either message_creation or tool_calls.

Accepts one of the following:
MESSAGE_CREATION("message_creation")
TOOL_CALLS("tool_calls")
Optional<Usage> usage

Usage statistics related to the run step. This value will be null while the run step's status is in_progress.

long completionTokens

Number of completion tokens used over the course of the run step.

long promptTokens

Number of prompt tokens used over the course of the run step.

long totalTokens

Total number of tokens used (prompt + completion).

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.

String id

The identifier of the run step, which can be referenced in API endpoints.

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

Optional<StepDetails> stepDetails

The details of the run step.

Accepts one of the following:
class RunStepDeltaMessageDelta:

Details of the message creation by the run step.

JsonValue; type "message_creation"constant"message_creation"constant

Always message_creation.

Optional<MessageCreation> messageCreation
Optional<String> messageId

The ID of the message that was created by this run step.

class ToolCallDeltaObject:

Details of the tool call.

JsonValue; type "tool_calls"constant"tool_calls"constant

Always tool_calls.

Optional<List<ToolCallDelta>> toolCalls

An array of tool calls the run step was involved in. These can be associated with one of three types of tools: code_interpreter, file_search, or function.

Accepts one of the following:
class CodeInterpreterToolCallDelta:

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

long index

The index of the tool call in the tool calls array.

JsonValue; type "code_interpreter"constant"code_interpreter"constant

The type of tool call. This is always going to be code_interpreter for this type of tool call.

Optional<String> id

The ID of the tool call.

Optional<CodeInterpreter> codeInterpreter

The Code Interpreter tool call definition.

Optional<String> input

The input to the Code Interpreter tool call.

Optional<List<Output>> outputs

The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (logs) or images (image). Each of these are represented by a different object type.

Accepts one of the following:
class CodeInterpreterLogs:

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

long index

The index of the output in the outputs array.

JsonValue; type "logs"constant"logs"constant

Always logs.

Optional<String> logs

The text output from the Code Interpreter tool call.

class CodeInterpreterOutputImage:
long index

The index of the output in the outputs array.

JsonValue; type "image"constant"image"constant

Always image.

Optional<Image> image
Optional<String> fileId

The file ID of the image.

class FileSearchToolCallDelta:
long index

The index of the tool call in the tool calls array.

JsonValue; type "file_search"constant"file_search"constant

The type of tool call. This is always going to be file_search for this type of tool call.

Optional<String> id

The ID of the tool call object.

class FunctionToolCallDelta:
long index

The index of the tool call in the tool calls array.

JsonValue; type "function"constant"function"constant

The type of tool call. This is always going to be function for this type of tool call.

Optional<String> id

The ID of the tool call object.

Optional<Function> function

The definition of the function that was called.

Optional<String> arguments

The arguments passed to the function.

Optional<String> name

The name of the function.

Optional<String> output

The output of the function. This will be null if the outputs have not been submitted yet.

JsonValue; object_ "thread.run.step.delta"constant"thread.run.step.delta"constant

The object type, which is always thread.run.step.delta.

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

Represents a step in execution of a run.

String id

The identifier of the run step, which can be referenced in API endpoints.

String assistantId

The ID of the assistant associated with the run step.

Optional<Long> cancelledAt

The Unix timestamp (in seconds) for when the run step was cancelled.

Optional<Long> completedAt

The Unix timestamp (in seconds) for when the run step completed.

long createdAt

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

Optional<Long> expiredAt

The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired.

Optional<Long> failedAt

The Unix timestamp (in seconds) for when the run step failed.

Optional<LastError> lastError

The last error associated with this run step. Will be null if there are no errors.

Code code

One of server_error or rate_limit_exceeded.

Accepts one of the following:
SERVER_ERROR("server_error")
RATE_LIMIT_EXCEEDED("rate_limit_exceeded")
String message

A human-readable description of the error.

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.

JsonValue; object_ "thread.run.step"constant"thread.run.step"constant

The object type, which is always thread.run.step.

String runId

The ID of the run that this run step is a part of.

Status status

The status of the run step, which can be either in_progress, cancelled, failed, completed, or expired.

Accepts one of the following:
IN_PROGRESS("in_progress")
CANCELLED("cancelled")
FAILED("failed")
COMPLETED("completed")
EXPIRED("expired")
StepDetails stepDetails

The details of the run step.

Accepts one of the following:
class MessageCreationStepDetails:

Details of the message creation by the run step.

MessageCreation messageCreation
String messageId

The ID of the message that was created by this run step.

JsonValue; type "message_creation"constant"message_creation"constant

Always message_creation.

class ToolCallsStepDetails:

Details of the tool call.

List<ToolCall> toolCalls

An array of tool calls the run step was involved in. These can be associated with one of three types of tools: code_interpreter, file_search, or function.

Accepts one of the following:
class CodeInterpreterToolCall:

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

String id

The ID of the tool call.

CodeInterpreter codeInterpreter

The Code Interpreter tool call definition.

String input

The input to the Code Interpreter tool call.

List<Output> outputs

The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (logs) or images (image). Each of these are represented by a different object type.

Accepts one of the following:
class LogsOutput:

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

String logs

The text output from the Code Interpreter tool call.

JsonValue; type "logs"constant"logs"constant

Always logs.

class ImageOutput:
Image image
String fileId

The file ID of the image.

JsonValue; type "image"constant"image"constant

Always image.

JsonValue; type "code_interpreter"constant"code_interpreter"constant

The type of tool call. This is always going to be code_interpreter for this type of tool call.

class FileSearchToolCall:
String id

The ID of the tool call object.

Accepts one of the following:
JsonValue; type "file_search"constant"file_search"constant

The type of tool call. This is always going to be file_search for this type of tool call.

class FunctionToolCall:
String id

The ID of the tool call object.

Function function

The definition of the function that was called.

String arguments

The arguments passed to the function.

String name

The name of the function.

Optional<String> output

The output of the function. This will be null if the outputs have not been submitted yet.

JsonValue; type "function"constant"function"constant

The type of tool call. This is always going to be function for this type of tool call.

JsonValue; type "tool_calls"constant"tool_calls"constant

Always tool_calls.

String threadId

The ID of the thread that was run.

Type type

The type of run step, which can be either message_creation or tool_calls.

Accepts one of the following:
MESSAGE_CREATION("message_creation")
TOOL_CALLS("tool_calls")
Optional<Usage> usage

Usage statistics related to the run step. This value will be null while the run step's status is in_progress.

long completionTokens

Number of completion tokens used over the course of the run step.

long promptTokens

Number of prompt tokens used over the course of the run step.

long totalTokens

Total number of tokens used (prompt + completion).

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

Represents a step in execution of a run.

String id

The identifier of the run step, which can be referenced in API endpoints.

String assistantId

The ID of the assistant associated with the run step.

Optional<Long> cancelledAt

The Unix timestamp (in seconds) for when the run step was cancelled.

Optional<Long> completedAt

The Unix timestamp (in seconds) for when the run step completed.

long createdAt

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

Optional<Long> expiredAt

The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired.

Optional<Long> failedAt

The Unix timestamp (in seconds) for when the run step failed.

Optional<LastError> lastError

The last error associated with this run step. Will be null if there are no errors.

Code code

One of server_error or rate_limit_exceeded.

Accepts one of the following:
SERVER_ERROR("server_error")
RATE_LIMIT_EXCEEDED("rate_limit_exceeded")
String message

A human-readable description of the error.

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.

JsonValue; object_ "thread.run.step"constant"thread.run.step"constant

The object type, which is always thread.run.step.

String runId

The ID of the run that this run step is a part of.

Status status

The status of the run step, which can be either in_progress, cancelled, failed, completed, or expired.

Accepts one of the following:
IN_PROGRESS("in_progress")
CANCELLED("cancelled")
FAILED("failed")
COMPLETED("completed")
EXPIRED("expired")
StepDetails stepDetails

The details of the run step.

Accepts one of the following:
class MessageCreationStepDetails:

Details of the message creation by the run step.

MessageCreation messageCreation
String messageId

The ID of the message that was created by this run step.

JsonValue; type "message_creation"constant"message_creation"constant

Always message_creation.

class ToolCallsStepDetails:

Details of the tool call.

List<ToolCall> toolCalls

An array of tool calls the run step was involved in. These can be associated with one of three types of tools: code_interpreter, file_search, or function.

Accepts one of the following:
class CodeInterpreterToolCall:

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

String id

The ID of the tool call.

CodeInterpreter codeInterpreter

The Code Interpreter tool call definition.

String input

The input to the Code Interpreter tool call.

List<Output> outputs

The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (logs) or images (image). Each of these are represented by a different object type.

Accepts one of the following:
class LogsOutput:

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

String logs

The text output from the Code Interpreter tool call.

JsonValue; type "logs"constant"logs"constant

Always logs.

class ImageOutput:
Image image
String fileId

The file ID of the image.

JsonValue; type "image"constant"image"constant

Always image.

JsonValue; type "code_interpreter"constant"code_interpreter"constant

The type of tool call. This is always going to be code_interpreter for this type of tool call.

class FileSearchToolCall:
String id

The ID of the tool call object.

Accepts one of the following:
JsonValue; type "file_search"constant"file_search"constant

The type of tool call. This is always going to be file_search for this type of tool call.

class FunctionToolCall:
String id

The ID of the tool call object.

Function function

The definition of the function that was called.

String arguments

The arguments passed to the function.

String name

The name of the function.

Optional<String> output

The output of the function. This will be null if the outputs have not been submitted yet.

JsonValue; type "function"constant"function"constant

The type of tool call. This is always going to be function for this type of tool call.

JsonValue; type "tool_calls"constant"tool_calls"constant

Always tool_calls.

String threadId

The ID of the thread that was run.

Type type

The type of run step, which can be either message_creation or tool_calls.

Accepts one of the following:
MESSAGE_CREATION("message_creation")
TOOL_CALLS("tool_calls")
Optional<Usage> usage

Usage statistics related to the run step. This value will be null while the run step's status is in_progress.

long completionTokens

Number of completion tokens used over the course of the run step.

long promptTokens

Number of prompt tokens used over the course of the run step.

long totalTokens

Total number of tokens used (prompt + completion).

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

Represents a step in execution of a run.

String id

The identifier of the run step, which can be referenced in API endpoints.

String assistantId

The ID of the assistant associated with the run step.

Optional<Long> cancelledAt

The Unix timestamp (in seconds) for when the run step was cancelled.

Optional<Long> completedAt

The Unix timestamp (in seconds) for when the run step completed.

long createdAt

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

Optional<Long> expiredAt

The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired.

Optional<Long> failedAt

The Unix timestamp (in seconds) for when the run step failed.

Optional<LastError> lastError

The last error associated with this run step. Will be null if there are no errors.

Code code

One of server_error or rate_limit_exceeded.

Accepts one of the following:
SERVER_ERROR("server_error")
RATE_LIMIT_EXCEEDED("rate_limit_exceeded")
String message

A human-readable description of the error.

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.

JsonValue; object_ "thread.run.step"constant"thread.run.step"constant

The object type, which is always thread.run.step.

String runId

The ID of the run that this run step is a part of.

Status status

The status of the run step, which can be either in_progress, cancelled, failed, completed, or expired.

Accepts one of the following:
IN_PROGRESS("in_progress")
CANCELLED("cancelled")
FAILED("failed")
COMPLETED("completed")
EXPIRED("expired")
StepDetails stepDetails

The details of the run step.

Accepts one of the following:
class MessageCreationStepDetails:

Details of the message creation by the run step.

MessageCreation messageCreation
String messageId

The ID of the message that was created by this run step.

JsonValue; type "message_creation"constant"message_creation"constant

Always message_creation.

class ToolCallsStepDetails:

Details of the tool call.

List<ToolCall> toolCalls

An array of tool calls the run step was involved in. These can be associated with one of three types of tools: code_interpreter, file_search, or function.

Accepts one of the following:
class CodeInterpreterToolCall:

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

String id

The ID of the tool call.

CodeInterpreter codeInterpreter

The Code Interpreter tool call definition.

String input

The input to the Code Interpreter tool call.

List<Output> outputs

The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (logs) or images (image). Each of these are represented by a different object type.

Accepts one of the following:
class LogsOutput:

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

String logs

The text output from the Code Interpreter tool call.

JsonValue; type "logs"constant"logs"constant

Always logs.

class ImageOutput:
Image image
String fileId

The file ID of the image.

JsonValue; type "image"constant"image"constant

Always image.

JsonValue; type "code_interpreter"constant"code_interpreter"constant

The type of tool call. This is always going to be code_interpreter for this type of tool call.

class FileSearchToolCall:
String id

The ID of the tool call object.

Accepts one of the following:
JsonValue; type "file_search"constant"file_search"constant

The type of tool call. This is always going to be file_search for this type of tool call.

class FunctionToolCall:
String id

The ID of the tool call object.

Function function

The definition of the function that was called.

String arguments

The arguments passed to the function.

String name

The name of the function.

Optional<String> output

The output of the function. This will be null if the outputs have not been submitted yet.

JsonValue; type "function"constant"function"constant

The type of tool call. This is always going to be function for this type of tool call.

JsonValue; type "tool_calls"constant"tool_calls"constant

Always tool_calls.

String threadId

The ID of the thread that was run.

Type type

The type of run step, which can be either message_creation or tool_calls.

Accepts one of the following:
MESSAGE_CREATION("message_creation")
TOOL_CALLS("tool_calls")
Optional<Usage> usage

Usage statistics related to the run step. This value will be null while the run step's status is in_progress.

long completionTokens

Number of completion tokens used over the course of the run step.

long promptTokens

Number of prompt tokens used over the course of the run step.

long totalTokens

Total number of tokens used (prompt + completion).

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

Represents a step in execution of a run.

String id

The identifier of the run step, which can be referenced in API endpoints.

String assistantId

The ID of the assistant associated with the run step.

Optional<Long> cancelledAt

The Unix timestamp (in seconds) for when the run step was cancelled.

Optional<Long> completedAt

The Unix timestamp (in seconds) for when the run step completed.

long createdAt

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

Optional<Long> expiredAt

The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired.

Optional<Long> failedAt

The Unix timestamp (in seconds) for when the run step failed.

Optional<LastError> lastError

The last error associated with this run step. Will be null if there are no errors.

Code code

One of server_error or rate_limit_exceeded.

Accepts one of the following:
SERVER_ERROR("server_error")
RATE_LIMIT_EXCEEDED("rate_limit_exceeded")
String message

A human-readable description of the error.

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.

JsonValue; object_ "thread.run.step"constant"thread.run.step"constant

The object type, which is always thread.run.step.

String runId

The ID of the run that this run step is a part of.

Status status

The status of the run step, which can be either in_progress, cancelled, failed, completed, or expired.

Accepts one of the following:
IN_PROGRESS("in_progress")
CANCELLED("cancelled")
FAILED("failed")
COMPLETED("completed")
EXPIRED("expired")
StepDetails stepDetails

The details of the run step.

Accepts one of the following:
class MessageCreationStepDetails:

Details of the message creation by the run step.

MessageCreation messageCreation
String messageId

The ID of the message that was created by this run step.

JsonValue; type "message_creation"constant"message_creation"constant

Always message_creation.

class ToolCallsStepDetails:

Details of the tool call.

List<ToolCall> toolCalls

An array of tool calls the run step was involved in. These can be associated with one of three types of tools: code_interpreter, file_search, or function.

Accepts one of the following:
class CodeInterpreterToolCall:

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

String id

The ID of the tool call.

CodeInterpreter codeInterpreter

The Code Interpreter tool call definition.

String input

The input to the Code Interpreter tool call.

List<Output> outputs

The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (logs) or images (image). Each of these are represented by a different object type.

Accepts one of the following:
class LogsOutput:

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

String logs

The text output from the Code Interpreter tool call.

JsonValue; type "logs"constant"logs"constant

Always logs.

class ImageOutput:
Image image
String fileId

The file ID of the image.

JsonValue; type "image"constant"image"constant

Always image.

JsonValue; type "code_interpreter"constant"code_interpreter"constant

The type of tool call. This is always going to be code_interpreter for this type of tool call.

class FileSearchToolCall:
String id

The ID of the tool call object.

Accepts one of the following:
JsonValue; type "file_search"constant"file_search"constant

The type of tool call. This is always going to be file_search for this type of tool call.

class FunctionToolCall:
String id

The ID of the tool call object.

Function function

The definition of the function that was called.

String arguments

The arguments passed to the function.

String name

The name of the function.

Optional<String> output

The output of the function. This will be null if the outputs have not been submitted yet.

JsonValue; type "function"constant"function"constant

The type of tool call. This is always going to be function for this type of tool call.

JsonValue; type "tool_calls"constant"tool_calls"constant

Always tool_calls.

String threadId

The ID of the thread that was run.

Type type

The type of run step, which can be either message_creation or tool_calls.

Accepts one of the following:
MESSAGE_CREATION("message_creation")
TOOL_CALLS("tool_calls")
Optional<Usage> usage

Usage statistics related to the run step. This value will be null while the run step's status is in_progress.

long completionTokens

Number of completion tokens used over the course of the run step.

long promptTokens

Number of prompt tokens used over the course of the run step.

long totalTokens

Total number of tokens used (prompt + completion).

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

Represents a message within a thread.

String id

The identifier, which can be referenced in API endpoints.

Optional<String> assistantId

If applicable, the ID of the assistant that authored this message.

Optional<List<Attachment>> attachments

A list of files attached to the message, and the tools they were added to.

Optional<String> fileId

The ID of the file to attach to the message.

Optional<List<Tool>> tools

The tools to add this file to.

Accepts one of the following:
class CodeInterpreterTool:
JsonValue; type "code_interpreter"constant"code_interpreter"constant

The type of tool being defined: code_interpreter

JsonValue;
JsonValue; type "file_search"constant"file_search"constant

The type of tool being defined: file_search

Optional<Long> completedAt

The Unix timestamp (in seconds) for when the message was completed.

List<MessageContent> content

The content of the message in array of text and/or images.

Accepts one of the following:
class ImageFileContentBlock:

References an image File in the content of a message.

ImageFile imageFile
String fileId

The File ID of the image in the message content. Set purpose="vision" when uploading the File if you need to later display the file content.

Optional<Detail> detail

Specifies the detail level of the image if specified by the user. low uses fewer tokens, you can opt in to high resolution using high.

Accepts one of the following:
AUTO("auto")
LOW("low")
HIGH("high")
JsonValue; type "image_file"constant"image_file"constant

Always image_file.

class ImageUrlContentBlock:

References an image URL in the content of a message.

ImageUrl imageUrl
String url

The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.

formaturi
Optional<Detail> detail

Specifies the detail level of the image. low uses fewer tokens, you can opt in to high resolution using high. Default value is auto

Accepts one of the following:
AUTO("auto")
LOW("low")
HIGH("high")
JsonValue; type "image_url"constant"image_url"constant

The type of the content part.

class TextContentBlock:

The text content that is part of a message.

Text text
List<Annotation> annotations
Accepts one of the following:
class FileCitationAnnotation:

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.

long endIndex
minimum0
FileCitation fileCitation
String fileId

The ID of the specific File the citation is from.

long startIndex
minimum0
String text

The text in the message content that needs to be replaced.

JsonValue; type "file_citation"constant"file_citation"constant

Always file_citation.

class FilePathAnnotation:

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

long endIndex
minimum0
FilePath filePath
String fileId

The ID of the file that was generated.

long startIndex
minimum0
String text

The text in the message content that needs to be replaced.

JsonValue; type "file_path"constant"file_path"constant

Always file_path.

String value

The data that makes up the text.

JsonValue; type "text"constant"text"constant

Always text.

class RefusalContentBlock:

The refusal content generated by the assistant.

String refusal
JsonValue; type "refusal"constant"refusal"constant

Always refusal.

long createdAt

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

Optional<Long> incompleteAt

The Unix timestamp (in seconds) for when the message was marked as incomplete.

Optional<IncompleteDetails> incompleteDetails

On an incomplete message, details about why the message is incomplete.

Reason reason

The reason the message is incomplete.

Accepts one of the following:
CONTENT_FILTER("content_filter")
MAX_TOKENS("max_tokens")
RUN_CANCELLED("run_cancelled")
RUN_EXPIRED("run_expired")
RUN_FAILED("run_failed")
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.

JsonValue; object_ "thread.message"constant"thread.message"constant

The object type, which is always thread.message.

Role role

The entity that produced the message. One of user or assistant.

Accepts one of the following:
USER("user")
ASSISTANT("assistant")
Optional<String> runId

The ID of the run associated with the creation of this message. Value is null when messages are created manually using the create message or create thread endpoints.

Status status

The status of the message, which can be either in_progress, incomplete, or completed.

Accepts one of the following:
IN_PROGRESS("in_progress")
INCOMPLETE("incomplete")
COMPLETED("completed")
String threadId

The thread ID that this message belongs to.

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

Represents a message within a thread.

String id

The identifier, which can be referenced in API endpoints.

Optional<String> assistantId

If applicable, the ID of the assistant that authored this message.

Optional<List<Attachment>> attachments

A list of files attached to the message, and the tools they were added to.

Optional<String> fileId

The ID of the file to attach to the message.

Optional<List<Tool>> tools

The tools to add this file to.

Accepts one of the following:
class CodeInterpreterTool:
JsonValue; type "code_interpreter"constant"code_interpreter"constant

The type of tool being defined: code_interpreter

JsonValue;
JsonValue; type "file_search"constant"file_search"constant

The type of tool being defined: file_search

Optional<Long> completedAt

The Unix timestamp (in seconds) for when the message was completed.

List<MessageContent> content

The content of the message in array of text and/or images.

Accepts one of the following:
class ImageFileContentBlock:

References an image File in the content of a message.

ImageFile imageFile
String fileId

The File ID of the image in the message content. Set purpose="vision" when uploading the File if you need to later display the file content.

Optional<Detail> detail

Specifies the detail level of the image if specified by the user. low uses fewer tokens, you can opt in to high resolution using high.

Accepts one of the following:
AUTO("auto")
LOW("low")
HIGH("high")
JsonValue; type "image_file"constant"image_file"constant

Always image_file.

class ImageUrlContentBlock:

References an image URL in the content of a message.

ImageUrl imageUrl
String url

The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.

formaturi
Optional<Detail> detail

Specifies the detail level of the image. low uses fewer tokens, you can opt in to high resolution using high. Default value is auto

Accepts one of the following:
AUTO("auto")
LOW("low")
HIGH("high")
JsonValue; type "image_url"constant"image_url"constant

The type of the content part.

class TextContentBlock:

The text content that is part of a message.

Text text
List<Annotation> annotations
Accepts one of the following:
class FileCitationAnnotation:

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.

long endIndex
minimum0
FileCitation fileCitation
String fileId

The ID of the specific File the citation is from.

long startIndex
minimum0
String text

The text in the message content that needs to be replaced.

JsonValue; type "file_citation"constant"file_citation"constant

Always file_citation.

class FilePathAnnotation:

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

long endIndex
minimum0
FilePath filePath
String fileId

The ID of the file that was generated.

long startIndex
minimum0
String text

The text in the message content that needs to be replaced.

JsonValue; type "file_path"constant"file_path"constant

Always file_path.

String value

The data that makes up the text.

JsonValue; type "text"constant"text"constant

Always text.

class RefusalContentBlock:

The refusal content generated by the assistant.

String refusal
JsonValue; type "refusal"constant"refusal"constant

Always refusal.

long createdAt

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

Optional<Long> incompleteAt

The Unix timestamp (in seconds) for when the message was marked as incomplete.

Optional<IncompleteDetails> incompleteDetails

On an incomplete message, details about why the message is incomplete.

Reason reason

The reason the message is incomplete.

Accepts one of the following:
CONTENT_FILTER("content_filter")
MAX_TOKENS("max_tokens")
RUN_CANCELLED("run_cancelled")
RUN_EXPIRED("run_expired")
RUN_FAILED("run_failed")
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.

JsonValue; object_ "thread.message"constant"thread.message"constant

The object type, which is always thread.message.

Role role

The entity that produced the message. One of user or assistant.

Accepts one of the following:
USER("user")
ASSISTANT("assistant")
Optional<String> runId

The ID of the run associated with the creation of this message. Value is null when messages are created manually using the create message or create thread endpoints.

Status status

The status of the message, which can be either in_progress, incomplete, or completed.

Accepts one of the following:
IN_PROGRESS("in_progress")
INCOMPLETE("incomplete")
COMPLETED("completed")
String threadId

The thread ID that this message belongs to.

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.

String id

The identifier of the message, which can be referenced in API endpoints.

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

Optional<List<MessageContentDelta>> content

The content of the message in array of text and/or images.

Accepts one of the following:
class ImageFileDeltaBlock:

References an image File in the content of a message.

long index

The index of the content part in the message.

JsonValue; type "image_file"constant"image_file"constant

Always image_file.

Optional<ImageFileDelta> imageFile
Optional<Detail> detail

Specifies the detail level of the image if specified by the user. low uses fewer tokens, you can opt in to high resolution using high.

Accepts one of the following:
AUTO("auto")
LOW("low")
HIGH("high")
Optional<String> fileId

The File ID of the image in the message content. Set purpose="vision" when uploading the File if you need to later display the file content.

class TextDeltaBlock:

The text content that is part of a message.

long index

The index of the content part in the message.

JsonValue; type "text"constant"text"constant

Always text.

Optional<TextDelta> text
Optional<List<AnnotationDelta>> annotations
Accepts one of the following:
class FileCitationDeltaAnnotation:

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.

long index

The index of the annotation in the text content part.

JsonValue; type "file_citation"constant"file_citation"constant

Always file_citation.

Optional<Long> endIndex
minimum0
Optional<FileCitation> fileCitation
Optional<String> fileId

The ID of the specific File the citation is from.

Optional<String> quote

The specific quote in the file.

Optional<Long> startIndex
minimum0
Optional<String> text

The text in the message content that needs to be replaced.

class FilePathDeltaAnnotation:

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

long index

The index of the annotation in the text content part.

JsonValue; type "file_path"constant"file_path"constant

Always file_path.

Optional<Long> endIndex
minimum0
Optional<FilePath> filePath
Optional<String> fileId

The ID of the file that was generated.

Optional<Long> startIndex
minimum0
Optional<String> text

The text in the message content that needs to be replaced.

Optional<String> value

The data that makes up the text.

class RefusalDeltaBlock:

The refusal content that is part of a message.

long index

The index of the refusal part in the message.

JsonValue; type "refusal"constant"refusal"constant

Always refusal.

Optional<String> refusal
class ImageUrlDeltaBlock:

References an image URL in the content of a message.

long index

The index of the content part in the message.

JsonValue; type "image_url"constant"image_url"constant

Always image_url.

Optional<ImageUrlDelta> imageUrl
Optional<Detail> detail

Specifies the detail level of the image. low uses fewer tokens, you can opt in to high resolution using high.

Accepts one of the following:
AUTO("auto")
LOW("low")
HIGH("high")
Optional<String> url

The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.

Optional<Role> role

The entity that produced the message. One of user or assistant.

Accepts one of the following:
USER("user")
ASSISTANT("assistant")
JsonValue; object_ "thread.message.delta"constant"thread.message.delta"constant

The object type, which is always thread.message.delta.

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

Represents a message within a thread.

String id

The identifier, which can be referenced in API endpoints.

Optional<String> assistantId

If applicable, the ID of the assistant that authored this message.

Optional<List<Attachment>> attachments

A list of files attached to the message, and the tools they were added to.

Optional<String> fileId

The ID of the file to attach to the message.

Optional<List<Tool>> tools

The tools to add this file to.

Accepts one of the following:
class CodeInterpreterTool:
JsonValue; type "code_interpreter"constant"code_interpreter"constant

The type of tool being defined: code_interpreter

JsonValue;
JsonValue; type "file_search"constant"file_search"constant

The type of tool being defined: file_search

Optional<Long> completedAt

The Unix timestamp (in seconds) for when the message was completed.

List<MessageContent> content

The content of the message in array of text and/or images.

Accepts one of the following:
class ImageFileContentBlock:

References an image File in the content of a message.

ImageFile imageFile
String fileId

The File ID of the image in the message content. Set purpose="vision" when uploading the File if you need to later display the file content.

Optional<Detail> detail

Specifies the detail level of the image if specified by the user. low uses fewer tokens, you can opt in to high resolution using high.

Accepts one of the following:
AUTO("auto")
LOW("low")
HIGH("high")
JsonValue; type "image_file"constant"image_file"constant

Always image_file.

class ImageUrlContentBlock:

References an image URL in the content of a message.

ImageUrl imageUrl
String url

The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.

formaturi
Optional<Detail> detail

Specifies the detail level of the image. low uses fewer tokens, you can opt in to high resolution using high. Default value is auto

Accepts one of the following:
AUTO("auto")
LOW("low")
HIGH("high")
JsonValue; type "image_url"constant"image_url"constant

The type of the content part.

class TextContentBlock:

The text content that is part of a message.

Text text
List<Annotation> annotations
Accepts one of the following:
class FileCitationAnnotation:

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.

long endIndex
minimum0
FileCitation fileCitation
String fileId

The ID of the specific File the citation is from.

long startIndex
minimum0
String text

The text in the message content that needs to be replaced.

JsonValue; type "file_citation"constant"file_citation"constant

Always file_citation.

class FilePathAnnotation:

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

long endIndex
minimum0
FilePath filePath
String fileId

The ID of the file that was generated.

long startIndex
minimum0
String text

The text in the message content that needs to be replaced.

JsonValue; type "file_path"constant"file_path"constant

Always file_path.

String value

The data that makes up the text.

JsonValue; type "text"constant"text"constant

Always text.

class RefusalContentBlock:

The refusal content generated by the assistant.

String refusal
JsonValue; type "refusal"constant"refusal"constant

Always refusal.

long createdAt

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

Optional<Long> incompleteAt

The Unix timestamp (in seconds) for when the message was marked as incomplete.

Optional<IncompleteDetails> incompleteDetails

On an incomplete message, details about why the message is incomplete.

Reason reason

The reason the message is incomplete.

Accepts one of the following:
CONTENT_FILTER("content_filter")
MAX_TOKENS("max_tokens")
RUN_CANCELLED("run_cancelled")
RUN_EXPIRED("run_expired")
RUN_FAILED("run_failed")
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.

JsonValue; object_ "thread.message"constant"thread.message"constant

The object type, which is always thread.message.

Role role

The entity that produced the message. One of user or assistant.

Accepts one of the following:
USER("user")
ASSISTANT("assistant")
Optional<String> runId

The ID of the run associated with the creation of this message. Value is null when messages are created manually using the create message or create thread endpoints.

Status status

The status of the message, which can be either in_progress, incomplete, or completed.

Accepts one of the following:
IN_PROGRESS("in_progress")
INCOMPLETE("incomplete")
COMPLETED("completed")
String threadId

The thread ID that this message belongs to.

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

Represents a message within a thread.

String id

The identifier, which can be referenced in API endpoints.

Optional<String> assistantId

If applicable, the ID of the assistant that authored this message.

Optional<List<Attachment>> attachments

A list of files attached to the message, and the tools they were added to.

Optional<String> fileId

The ID of the file to attach to the message.

Optional<List<Tool>> tools

The tools to add this file to.

Accepts one of the following:
class CodeInterpreterTool:
JsonValue; type "code_interpreter"constant"code_interpreter"constant

The type of tool being defined: code_interpreter

JsonValue;
JsonValue; type "file_search"constant"file_search"constant

The type of tool being defined: file_search

Optional<Long> completedAt

The Unix timestamp (in seconds) for when the message was completed.

List<MessageContent> content

The content of the message in array of text and/or images.

Accepts one of the following:
class ImageFileContentBlock:

References an image File in the content of a message.

ImageFile imageFile
String fileId

The File ID of the image in the message content. Set purpose="vision" when uploading the File if you need to later display the file content.

Optional<Detail> detail

Specifies the detail level of the image if specified by the user. low uses fewer tokens, you can opt in to high resolution using high.

Accepts one of the following:
AUTO("auto")
LOW("low")
HIGH("high")
JsonValue; type "image_file"constant"image_file"constant

Always image_file.

class ImageUrlContentBlock:

References an image URL in the content of a message.

ImageUrl imageUrl
String url

The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.

formaturi
Optional<Detail> detail

Specifies the detail level of the image. low uses fewer tokens, you can opt in to high resolution using high. Default value is auto

Accepts one of the following:
AUTO("auto")
LOW("low")
HIGH("high")
JsonValue; type "image_url"constant"image_url"constant

The type of the content part.

class TextContentBlock:

The text content that is part of a message.

Text text
List<Annotation> annotations
Accepts one of the following:
class FileCitationAnnotation:

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.

long endIndex
minimum0
FileCitation fileCitation
String fileId

The ID of the specific File the citation is from.

long startIndex
minimum0
String text

The text in the message content that needs to be replaced.

JsonValue; type "file_citation"constant"file_citation"constant

Always file_citation.

class FilePathAnnotation:

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

long endIndex
minimum0
FilePath filePath
String fileId

The ID of the file that was generated.

long startIndex
minimum0
String text

The text in the message content that needs to be replaced.

JsonValue; type "file_path"constant"file_path"constant

Always file_path.

String value

The data that makes up the text.

JsonValue; type "text"constant"text"constant

Always text.

class RefusalContentBlock:

The refusal content generated by the assistant.

String refusal
JsonValue; type "refusal"constant"refusal"constant

Always refusal.

long createdAt

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

Optional<Long> incompleteAt

The Unix timestamp (in seconds) for when the message was marked as incomplete.

Optional<IncompleteDetails> incompleteDetails

On an incomplete message, details about why the message is incomplete.

Reason reason

The reason the message is incomplete.

Accepts one of the following:
CONTENT_FILTER("content_filter")
MAX_TOKENS("max_tokens")
RUN_CANCELLED("run_cancelled")
RUN_EXPIRED("run_expired")
RUN_FAILED("run_failed")
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.

JsonValue; object_ "thread.message"constant"thread.message"constant

The object type, which is always thread.message.

Role role

The entity that produced the message. One of user or assistant.

Accepts one of the following:
USER("user")
ASSISTANT("assistant")
Optional<String> runId

The ID of the run associated with the creation of this message. Value is null when messages are created manually using the create message or create thread endpoints.

Status status

The status of the message, which can be either in_progress, incomplete, or completed.

Accepts one of the following:
IN_PROGRESS("in_progress")
INCOMPLETE("incomplete")
COMPLETED("completed")
String threadId

The thread ID that this message belongs to.

JsonValue; event "thread.message.incomplete"constant"thread.message.incomplete"constant
ErrorEvent
Optional<String> code
String message
Optional<String> param
String type
JsonValue; event "error"constant"error"constant

Create thread and run

package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.threads.ThreadCreateAndRunParams;
import com.openai.models.beta.threads.runs.Run;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        ThreadCreateAndRunParams params = ThreadCreateAndRunParams.builder()
            .assistantId("assistant_id")
            .build();
        Run run = client.beta().threads().createAndRun(params);
    }
}
{
  "id": "id",
  "assistant_id": "assistant_id",
  "cancelled_at": 0,
  "completed_at": 0,
  "created_at": 0,
  "expires_at": 0,
  "failed_at": 0,
  "incomplete_details": {
    "reason": "max_completion_tokens"
  },
  "instructions": "instructions",
  "last_error": {
    "code": "server_error",
    "message": "message"
  },
  "max_completion_tokens": 256,
  "max_prompt_tokens": 256,
  "metadata": {
    "foo": "string"
  },
  "model": "model",
  "object": "thread.run",
  "parallel_tool_calls": true,
  "required_action": {
    "submit_tool_outputs": {
      "tool_calls": [
        {
          "id": "id",
          "function": {
            "arguments": "arguments",
            "name": "name"
          },
          "type": "function"
        }
      ]
    },
    "type": "submit_tool_outputs"
  },
  "response_format": "auto",
  "started_at": 0,
  "status": "queued",
  "thread_id": "thread_id",
  "tool_choice": "none",
  "tools": [
    {
      "type": "code_interpreter"
    }
  ],
  "truncation_strategy": {
    "type": "auto",
    "last_messages": 1
  },
  "usage": {
    "completion_tokens": 0,
    "prompt_tokens": 0,
    "total_tokens": 0
  },
  "temperature": 0,
  "top_p": 0
}
Returns Examples
{
  "id": "id",
  "assistant_id": "assistant_id",
  "cancelled_at": 0,
  "completed_at": 0,
  "created_at": 0,
  "expires_at": 0,
  "failed_at": 0,
  "incomplete_details": {
    "reason": "max_completion_tokens"
  },
  "instructions": "instructions",
  "last_error": {
    "code": "server_error",
    "message": "message"
  },
  "max_completion_tokens": 256,
  "max_prompt_tokens": 256,
  "metadata": {
    "foo": "string"
  },
  "model": "model",
  "object": "thread.run",
  "parallel_tool_calls": true,
  "required_action": {
    "submit_tool_outputs": {
      "tool_calls": [
        {
          "id": "id",
          "function": {
            "arguments": "arguments",
            "name": "name"
          },
          "type": "function"
        }
      ]
    },
    "type": "submit_tool_outputs"
  },
  "response_format": "auto",
  "started_at": 0,
  "status": "queued",
  "thread_id": "thread_id",
  "tool_choice": "none",
  "tools": [
    {
      "type": "code_interpreter"
    }
  ],
  "truncation_strategy": {
    "type": "auto",
    "last_messages": 1
  },
  "usage": {
    "completion_tokens": 0,
    "prompt_tokens": 0,
    "total_tokens": 0
  },
  "temperature": 0,
  "top_p": 0
}