Threads
Create thread
Thread beta().threads().create(ThreadCreateParamsparams = ThreadCreateParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
post /threads
Create a thread.
Parameters
-
ThreadCreateParams params-
Optional<List<Message>> messagesA list of messages to start the thread with.
-
Content contentThe text contents of the message.
-
String -
List<MessageContentPartParam>-
class ImageFileContentBlock:References an image File in the content of a message.
-
ImageFile imageFile-
String fileIdThe 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> detailSpecifies the detail level of the image if specified by the user.
lowuses fewer tokens, you can opt in to high resolution usinghigh.-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
-
JsonValue; type "image_file"constantAlways
image_file.IMAGE_FILE("image_file")
-
-
class ImageUrlContentBlock:References an image URL in the content of a message.
-
ImageUrl imageUrl-
String urlThe external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.
-
Optional<Detail> detailSpecifies the detail level of the image.
lowuses fewer tokens, you can opt in to high resolution usinghigh. Default value isauto-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
-
JsonValue; type "image_url"constantThe type of the content part.
IMAGE_URL("image_url")
-
-
class TextContentBlockParam:The text content that is part of a message.
-
String textText content to be sent to the model
-
JsonValue; type "text"constantAlways
text.TEXT("text")
-
-
-
-
Role roleThe 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. -
USER("user") -
ASSISTANT("assistant")
-
-
Optional<List<Attachment>> attachmentsA list of files attached to the message, and the tools they should be added to.
-
Optional<String> fileIdThe ID of the file to attach to the message.
-
Optional<List<Tool>> toolsThe tools to add this file to.
-
class CodeInterpreterTool:-
JsonValue; type "code_interpreter"constantThe type of tool being defined:
code_interpreterCODE_INTERPRETER("code_interpreter")
-
-
JsonValue;-
JsonValue; type "file_search"constantThe type of tool being defined:
file_searchFILE_SEARCH("file_search")
-
-
-
-
Optional<Metadata> metadataSet 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> metadataSet 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> toolResourcesA 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_interpretertool requires a list of file IDs, while thefile_searchtool requires a list of vector store IDs.-
Optional<CodeInterpreter> codeInterpreter-
Optional<List<String>> fileIdsA list of file IDs made available to the
code_interpretertool. There can be a maximum of 20 files associated with the tool.
-
-
Optional<FileSearch> fileSearch-
Optional<List<String>> vectorStoreIdsThe vector store attached to this thread. There can be a maximum of 1 vector store attached to the thread.
-
Optional<List<VectorStore>> vectorStoresA helper to create a vector store with file_ids and attach it to this thread. There can be a maximum of 1 vector store attached to the thread.
-
Optional<ChunkingStrategy> chunkingStrategyThe chunking strategy used to chunk the file(s). If not set, will use the
autostrategy.-
JsonValue;-
JsonValue; type "auto"constantAlways
auto.AUTO("auto")
-
-
class Static:-
InnerStatic static_-
long chunkOverlapTokensThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
long maxChunkSizeTokensThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
JsonValue; type "static"constantAlways
static.STATIC("static")
-
-
-
Optional<List<String>> fileIdsA list of file IDs to add to the vector store. For vector stores created before Nov 2025, there can be a maximum of 10,000 files in a vector store. For vector stores created starting in Nov 2025, the limit is 100,000,000 files.
-
Optional<Metadata> metadataSet 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.
-
-
-
-
Returns
-
class Thread:Represents a thread that contains messages.
-
String idThe identifier, which can be referenced in API endpoints.
-
long createdAtThe Unix timestamp (in seconds) for when the thread was created.
-
Optional<Metadata> metadataSet 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"constantThe object type, which is always
thread.THREAD("thread")
-
Optional<ToolResources> toolResourcesA 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_interpretertool requires a list of file IDs, while thefile_searchtool requires a list of vector store IDs.-
Optional<CodeInterpreter> codeInterpreter-
Optional<List<String>> fileIdsA list of file IDs made available to the
code_interpretertool. There can be a maximum of 20 files associated with the tool.
-
-
Optional<FileSearch> fileSearch-
Optional<List<String>> vectorStoreIdsThe vector store attached to this thread. There can be a maximum of 1 vector store attached to the thread.
-
-
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.threads.Thread;
import com.openai.models.beta.threads.ThreadCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
Thread thread = client.beta().threads().create();
}
}
Response
{
"id": "id",
"created_at": 0,
"metadata": {
"foo": "string"
},
"object": "thread",
"tool_resources": {
"code_interpreter": {
"file_ids": [
"string"
]
},
"file_search": {
"vector_store_ids": [
"string"
]
}
}
}
Create thread and run
Run beta().threads().createAndRun(ThreadCreateAndRunParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
post /threads/runs
Create a thread and run it in one request.
Parameters
-
ThreadCreateAndRunParams params-
String assistantIdThe ID of the assistant to use to execute this run.
-
Optional<String> instructionsOverride the default system message of the assistant. This is useful for modifying the behavior on a per-run basis.
-
Optional<Long> maxCompletionTokensThe 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. Seeincomplete_detailsfor more info. -
Optional<Long> maxPromptTokensThe 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. Seeincomplete_detailsfor more info. -
Optional<Metadata> metadataSet 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> modelThe 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.
-
Optional<Boolean> parallelToolCallsWhether to enable parallel function calling during tool use.
-
Optional<AssistantResponseFormatOption> responseFormatSpecifies 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 exceededmax_tokensor the conversation exceeded the max context length. -
Optional<Double> temperatureWhat 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.
-
Optional<Thread> threadOptions to create a new thread. If no thread is provided when running a request, an empty thread will be created.
-
Optional<List<Message>> messagesA list of messages to start the thread with.
-
Content contentThe text contents of the message.
-
String -
List<MessageContentPartParam>-
class ImageFileContentBlock:References an image File in the content of a message.
-
ImageFile imageFile-
String fileIdThe 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> detailSpecifies the detail level of the image if specified by the user.
lowuses fewer tokens, you can opt in to high resolution usinghigh.-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
-
JsonValue; type "image_file"constantAlways
image_file.IMAGE_FILE("image_file")
-
-
class ImageUrlContentBlock:References an image URL in the content of a message.
-
ImageUrl imageUrl-
String urlThe external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.
-
Optional<Detail> detailSpecifies the detail level of the image.
lowuses fewer tokens, you can opt in to high resolution usinghigh. Default value isauto-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
-
JsonValue; type "image_url"constantThe type of the content part.
IMAGE_URL("image_url")
-
-
class TextContentBlockParam:The text content that is part of a message.
-
String textText content to be sent to the model
-
JsonValue; type "text"constantAlways
text.TEXT("text")
-
-
-
-
Role roleThe 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. -
USER("user") -
ASSISTANT("assistant")
-
-
Optional<List<Attachment>> attachmentsA list of files attached to the message, and the tools they should be added to.
-
Optional<String> fileIdThe ID of the file to attach to the message.
-
Optional<List<Tool>> toolsThe tools to add this file to.
-
class CodeInterpreterTool:-
JsonValue; type "code_interpreter"constantThe type of tool being defined:
code_interpreterCODE_INTERPRETER("code_interpreter")
-
-
JsonValue;-
JsonValue; type "file_search"constantThe type of tool being defined:
file_searchFILE_SEARCH("file_search")
-
-
-
-
Optional<Metadata> metadataSet 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> metadataSet 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> toolResourcesA 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_interpretertool requires a list of file IDs, while thefile_searchtool requires a list of vector store IDs.-
Optional<CodeInterpreter> codeInterpreter-
Optional<List<String>> fileIdsA list of file IDs made available to the
code_interpretertool. There can be a maximum of 20 files associated with the tool.
-
-
Optional<FileSearch> fileSearch-
Optional<List<String>> vectorStoreIdsThe vector store attached to this thread. There can be a maximum of 1 vector store attached to the thread.
-
Optional<List<VectorStore>> vectorStoresA helper to create a vector store with file_ids and attach it to this thread. There can be a maximum of 1 vector store attached to the thread.
-
Optional<ChunkingStrategy> chunkingStrategyThe chunking strategy used to chunk the file(s). If not set, will use the
autostrategy.-
JsonValue;-
JsonValue; type "auto"constantAlways
auto.AUTO("auto")
-
-
class Static:-
InnerStatic static_-
long chunkOverlapTokensThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
long maxChunkSizeTokensThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
JsonValue; type "static"constantAlways
static.STATIC("static")
-
-
-
Optional<List<String>> fileIdsA list of file IDs to add to the vector store. For vector stores created before Nov 2025, there can be a maximum of 10,000 files in a vector store. For vector stores created starting in Nov 2025, the limit is 100,000,000 files.
-
Optional<Metadata> metadataSet 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<AssistantToolChoiceOption> toolChoiceControls which (if any) tool is called by the model.
nonemeans the model will not call any tools and instead generates a message.autois the default value and means the model can pick between generating a message or calling one or more tools.requiredmeans 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> toolResourcesA set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the
code_interpretertool requires a list of file IDs, while thefile_searchtool requires a list of vector store IDs.-
Optional<CodeInterpreter> codeInterpreter-
Optional<List<String>> fileIdsA list of file IDs made available to the
code_interpretertool. There can be a maximum of 20 files associated with the tool.
-
-
Optional<FileSearch> fileSearch-
Optional<List<String>> vectorStoreIdsThe ID of the vector store attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.
-
-
-
Optional<List<AssistantTool>> toolsOverride the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis.
-
class CodeInterpreterTool: -
class FileSearchTool:-
JsonValue; type "file_search"constantThe type of tool being defined:
file_searchFILE_SEARCH("file_search")
-
Optional<FileSearch> fileSearchOverrides for the file search tool.
-
Optional<Long> maxNumResultsThe maximum number of results the file search tool should output. The default is 20 for
gpt-4*models and 5 forgpt-3.5-turbo. This number should be between 1 and 50 inclusive.Note that the file search tool may output fewer than
max_num_resultsresults. See the file search tool documentation for more information. -
Optional<RankingOptions> rankingOptionsThe ranking options for the file search. If not specified, the file search tool will use the
autoranker and a score_threshold of 0.See the file search tool documentation for more information.
-
double scoreThresholdThe score threshold for the file search. All values must be a floating point number between 0 and 1.
-
Optional<Ranker> rankerThe ranker to use for the file search. If not specified will use the
autoranker.-
AUTO("auto") -
DEFAULT_2024_08_21("default_2024_08_21")
-
-
-
-
-
class FunctionTool:-
FunctionDefinition function-
String nameThe 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> descriptionA description of what the function does, used by the model to choose when and how to call the function.
-
Optional<FunctionParameters> parametersThe 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
parametersdefines a function with an empty parameter list. -
Optional<Boolean> strictWhether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the
parametersfield. Only a subset of JSON Schema is supported whenstrictistrue. Learn more about Structured Outputs in the function calling guide.
-
-
JsonValue; type "function"constantThe type of tool being defined:
functionFUNCTION("function")
-
-
-
Optional<Double> topPAn 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.
-
Optional<TruncationStrategy> truncationStrategyControls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.
-
Type typeThe truncation strategy to use for the thread. The default is
auto. If set tolast_messages, the thread will be truncated to the n most recent messages in the thread. When set toauto, messages in the middle of the thread will be dropped to fit the context length of the model,max_prompt_tokens.-
AUTO("auto") -
LAST_MESSAGES("last_messages")
-
-
Optional<Long> lastMessagesThe number of most recent messages from the thread when constructing the context for the run.
-
-
Returns
-
class Run:Represents an execution run on a thread.
-
String idThe identifier, which can be referenced in API endpoints.
-
String assistantIdThe ID of the assistant used for execution of this run.
-
Optional<Long> cancelledAtThe Unix timestamp (in seconds) for when the run was cancelled.
-
Optional<Long> completedAtThe Unix timestamp (in seconds) for when the run was completed.
-
long createdAtThe Unix timestamp (in seconds) for when the run was created.
-
Optional<Long> expiresAtThe Unix timestamp (in seconds) for when the run will expire.
-
Optional<Long> failedAtThe Unix timestamp (in seconds) for when the run failed.
-
Optional<IncompleteDetails> incompleteDetailsDetails on why the run is incomplete. Will be
nullif the run is not incomplete.-
Optional<Reason> reasonThe reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.
-
MAX_COMPLETION_TOKENS("max_completion_tokens") -
MAX_PROMPT_TOKENS("max_prompt_tokens")
-
-
-
String instructionsThe instructions that the assistant used for this run.
-
Optional<LastError> lastErrorThe last error associated with this run. Will be
nullif there are no errors.-
Code codeOne of
server_error,rate_limit_exceeded, orinvalid_prompt.-
SERVER_ERROR("server_error") -
RATE_LIMIT_EXCEEDED("rate_limit_exceeded") -
INVALID_PROMPT("invalid_prompt")
-
-
String messageA human-readable description of the error.
-
-
Optional<Long> maxCompletionTokensThe maximum number of completion tokens specified to have been used over the course of the run.
-
Optional<Long> maxPromptTokensThe maximum number of prompt tokens specified to have been used over the course of the run.
-
Optional<Metadata> metadataSet 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 modelThe model that the assistant used for this run.
-
JsonValue; object_ "thread.run"constantThe object type, which is always
thread.run.THREAD_RUN("thread.run")
-
boolean parallelToolCallsWhether to enable parallel function calling during tool use.
-
Optional<RequiredAction> requiredActionDetails on the action required to continue the run. Will be
nullif no action is required.-
SubmitToolOutputs submitToolOutputsDetails on the tool outputs needed for this run to continue.
-
List<RequiredActionFunctionToolCall> toolCallsA list of the relevant tool calls.
-
String idThe 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 functionThe function definition.
-
String argumentsThe arguments that the model expects you to pass to the function.
-
String nameThe name of the function.
-
-
JsonValue; type "function"constantThe type of tool call the output is required for. For now, this is always
function.FUNCTION("function")
-
-
-
JsonValue; type "submit_tool_outputs"constantFor now, this is always
submit_tool_outputs.SUBMIT_TOOL_OUTPUTS("submit_tool_outputs")
-
-
Optional<AssistantResponseFormatOption> responseFormatSpecifies 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 exceededmax_tokensor the conversation exceeded the max context length.-
JsonValue;AUTO("auto")
-
class ResponseFormatText:Default response format. Used to generate text responses.
-
JsonValue; type "text"constantThe type of response format being defined. Always
text.TEXT("text")
-
-
class ResponseFormatJsonObject:JSON object response format. An older method of generating JSON responses. Using
json_schemais 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"constantThe type of response format being defined. Always
json_object.JSON_OBJECT("json_object")
-
-
class ResponseFormatJsonSchema:JSON Schema response format. Used to generate structured JSON responses. Learn more about Structured Outputs.
-
JsonSchema jsonSchemaStructured Outputs configuration options, including a JSON Schema.
-
String nameThe 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> descriptionA description of what the response format is for, used by the model to determine how to respond in the format.
-
Optional<Schema> schemaThe schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas here.
-
Optional<Boolean> strictWhether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the
schemafield. Only a subset of JSON Schema is supported whenstrictistrue. To learn more, read the Structured Outputs guide.
-
-
JsonValue; type "json_schema"constantThe type of response format being defined. Always
json_schema.JSON_SCHEMA("json_schema")
-
-
-
Optional<Long> startedAtThe Unix timestamp (in seconds) for when the run was started.
-
RunStatus statusThe status of the run, which can be either
queued,in_progress,requires_action,cancelling,cancelled,failed,completed,incomplete, orexpired.-
QUEUED("queued") -
IN_PROGRESS("in_progress") -
REQUIRES_ACTION("requires_action") -
CANCELLING("cancelling") -
CANCELLED("cancelled") -
FAILED("failed") -
COMPLETED("completed") -
INCOMPLETE("incomplete") -
EXPIRED("expired")
-
-
String threadIdThe ID of the thread that was executed on as a part of this run.
-
Optional<AssistantToolChoiceOption> toolChoiceControls which (if any) tool is called by the model.
nonemeans the model will not call any tools and instead generates a message.autois the default value and means the model can pick between generating a message or calling one or more tools.requiredmeans 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.-
Auto-
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 typeThe type of the tool. If type is
function, the function name must be set-
FUNCTION("function") -
CODE_INTERPRETER("code_interpreter") -
FILE_SEARCH("file_search")
-
-
Optional<AssistantToolChoiceFunction> function-
String nameThe name of the function to call.
-
-
-
-
List<AssistantTool> toolsThe list of tools that the assistant used for this run.
-
class CodeInterpreterTool:-
JsonValue; type "code_interpreter"constantThe type of tool being defined:
code_interpreterCODE_INTERPRETER("code_interpreter")
-
-
class FileSearchTool:-
JsonValue; type "file_search"constantThe type of tool being defined:
file_searchFILE_SEARCH("file_search")
-
Optional<FileSearch> fileSearchOverrides for the file search tool.
-
Optional<Long> maxNumResultsThe maximum number of results the file search tool should output. The default is 20 for
gpt-4*models and 5 forgpt-3.5-turbo. This number should be between 1 and 50 inclusive.Note that the file search tool may output fewer than
max_num_resultsresults. See the file search tool documentation for more information. -
Optional<RankingOptions> rankingOptionsThe ranking options for the file search. If not specified, the file search tool will use the
autoranker and a score_threshold of 0.See the file search tool documentation for more information.
-
double scoreThresholdThe score threshold for the file search. All values must be a floating point number between 0 and 1.
-
Optional<Ranker> rankerThe ranker to use for the file search. If not specified will use the
autoranker.-
AUTO("auto") -
DEFAULT_2024_08_21("default_2024_08_21")
-
-
-
-
-
class FunctionTool:-
FunctionDefinition function-
String nameThe 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> descriptionA description of what the function does, used by the model to choose when and how to call the function.
-
Optional<FunctionParameters> parametersThe 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
parametersdefines a function with an empty parameter list. -
Optional<Boolean> strictWhether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the
parametersfield. Only a subset of JSON Schema is supported whenstrictistrue. Learn more about Structured Outputs in the function calling guide.
-
-
JsonValue; type "function"constantThe type of tool being defined:
functionFUNCTION("function")
-
-
-
Optional<TruncationStrategy> truncationStrategyControls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.
-
Type typeThe truncation strategy to use for the thread. The default is
auto. If set tolast_messages, the thread will be truncated to the n most recent messages in the thread. When set toauto, messages in the middle of the thread will be dropped to fit the context length of the model,max_prompt_tokens.-
AUTO("auto") -
LAST_MESSAGES("last_messages")
-
-
Optional<Long> lastMessagesThe number of most recent messages from the thread when constructing the context for the run.
-
-
Optional<Usage> usageUsage statistics related to the run. This value will be
nullif the run is not in a terminal state (i.e.in_progress,queued, etc.).-
long completionTokensNumber of completion tokens used over the course of the run.
-
long promptTokensNumber of prompt tokens used over the course of the run.
-
long totalTokensTotal number of tokens used (prompt + completion).
-
-
Optional<Double> temperatureThe sampling temperature used for this run. If not set, defaults to 1.
-
Optional<Double> topPThe nucleus sampling value used for this run. If not set, defaults to 1.
-
Example
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);
}
}
Response
{
"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
}
Retrieve thread
Thread beta().threads().retrieve(ThreadRetrieveParamsparams = ThreadRetrieveParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
get /threads/{thread_id}
Retrieves a thread.
Parameters
-
ThreadRetrieveParams paramsOptional<String> threadId
Returns
-
class Thread:Represents a thread that contains messages.
-
String idThe identifier, which can be referenced in API endpoints.
-
long createdAtThe Unix timestamp (in seconds) for when the thread was created.
-
Optional<Metadata> metadataSet 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"constantThe object type, which is always
thread.THREAD("thread")
-
Optional<ToolResources> toolResourcesA 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_interpretertool requires a list of file IDs, while thefile_searchtool requires a list of vector store IDs.-
Optional<CodeInterpreter> codeInterpreter-
Optional<List<String>> fileIdsA list of file IDs made available to the
code_interpretertool. There can be a maximum of 20 files associated with the tool.
-
-
Optional<FileSearch> fileSearch-
Optional<List<String>> vectorStoreIdsThe vector store attached to this thread. There can be a maximum of 1 vector store attached to the thread.
-
-
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.threads.Thread;
import com.openai.models.beta.threads.ThreadRetrieveParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
Thread thread = client.beta().threads().retrieve("thread_id");
}
}
Response
{
"id": "id",
"created_at": 0,
"metadata": {
"foo": "string"
},
"object": "thread",
"tool_resources": {
"code_interpreter": {
"file_ids": [
"string"
]
},
"file_search": {
"vector_store_ids": [
"string"
]
}
}
}
Modify thread
Thread beta().threads().update(ThreadUpdateParamsparams = ThreadUpdateParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
post /threads/{thread_id}
Modifies a thread.
Parameters
-
ThreadUpdateParams params-
Optional<String> threadId -
Optional<Metadata> metadataSet 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> toolResourcesA 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_interpretertool requires a list of file IDs, while thefile_searchtool requires a list of vector store IDs.-
Optional<CodeInterpreter> codeInterpreter-
Optional<List<String>> fileIdsA list of file IDs made available to the
code_interpretertool. There can be a maximum of 20 files associated with the tool.
-
-
Optional<FileSearch> fileSearch-
Optional<List<String>> vectorStoreIdsThe vector store attached to this thread. There can be a maximum of 1 vector store attached to the thread.
-
-
-
Returns
-
class Thread:Represents a thread that contains messages.
-
String idThe identifier, which can be referenced in API endpoints.
-
long createdAtThe Unix timestamp (in seconds) for when the thread was created.
-
Optional<Metadata> metadataSet 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"constantThe object type, which is always
thread.THREAD("thread")
-
Optional<ToolResources> toolResourcesA 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_interpretertool requires a list of file IDs, while thefile_searchtool requires a list of vector store IDs.-
Optional<CodeInterpreter> codeInterpreter-
Optional<List<String>> fileIdsA list of file IDs made available to the
code_interpretertool. There can be a maximum of 20 files associated with the tool.
-
-
Optional<FileSearch> fileSearch-
Optional<List<String>> vectorStoreIdsThe vector store attached to this thread. There can be a maximum of 1 vector store attached to the thread.
-
-
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.threads.Thread;
import com.openai.models.beta.threads.ThreadUpdateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
Thread thread = client.beta().threads().update("thread_id");
}
}
Response
{
"id": "id",
"created_at": 0,
"metadata": {
"foo": "string"
},
"object": "thread",
"tool_resources": {
"code_interpreter": {
"file_ids": [
"string"
]
},
"file_search": {
"vector_store_ids": [
"string"
]
}
}
}
Delete thread
ThreadDeleted beta().threads().delete(ThreadDeleteParamsparams = ThreadDeleteParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
delete /threads/{thread_id}
Delete a thread.
Parameters
-
ThreadDeleteParams paramsOptional<String> threadId
Returns
-
class ThreadDeleted:-
String id -
boolean deleted -
JsonValue; object_ "thread.deleted"constantTHREAD_DELETED("thread.deleted")
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.threads.ThreadDeleteParams;
import com.openai.models.beta.threads.ThreadDeleted;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
ThreadDeleted threadDeleted = client.beta().threads().delete("thread_id");
}
}
Response
{
"id": "id",
"deleted": true,
"object": "thread.deleted"
}
Domain Types
Assistant Response Format Option
-
class AssistantResponseFormatOption: A class that can be one of several variants.unionSpecifies 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 exceededmax_tokensor the conversation exceeded the max context length.-
JsonValue;AUTO("auto")
-
class ResponseFormatText:Default response format. Used to generate text responses.
-
JsonValue; type "text"constantThe type of response format being defined. Always
text.TEXT("text")
-
-
class ResponseFormatJsonObject:JSON object response format. An older method of generating JSON responses. Using
json_schemais 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"constantThe type of response format being defined. Always
json_object.JSON_OBJECT("json_object")
-
-
class ResponseFormatJsonSchema:JSON Schema response format. Used to generate structured JSON responses. Learn more about Structured Outputs.
-
JsonSchema jsonSchemaStructured Outputs configuration options, including a JSON Schema.
-
String nameThe 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> descriptionA description of what the response format is for, used by the model to determine how to respond in the format.
-
Optional<Schema> schemaThe schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas here.
-
Optional<Boolean> strictWhether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the
schemafield. Only a subset of JSON Schema is supported whenstrictistrue. To learn more, read the Structured Outputs guide.
-
-
JsonValue; type "json_schema"constantThe type of response format being defined. Always
json_schema.JSON_SCHEMA("json_schema")
-
-
Assistant Tool Choice
-
class AssistantToolChoice:Specifies a tool the model should use. Use to force the model to call a specific tool.
-
Type typeThe type of the tool. If type is
function, the function name must be set-
FUNCTION("function") -
CODE_INTERPRETER("code_interpreter") -
FILE_SEARCH("file_search")
-
-
Optional<AssistantToolChoiceFunction> function-
String nameThe name of the function to call.
-
-
Assistant Tool Choice Function
-
class AssistantToolChoiceFunction:-
String nameThe name of the function to call.
-
Assistant Tool Choice Option
-
class AssistantToolChoiceOption: A class that can be one of several variants.unionControls which (if any) tool is called by the model.
nonemeans the model will not call any tools and instead generates a message.autois the default value and means the model can pick between generating a message or calling one or more tools.requiredmeans 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.-
Auto-
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 typeThe type of the tool. If type is
function, the function name must be set-
FUNCTION("function") -
CODE_INTERPRETER("code_interpreter") -
FILE_SEARCH("file_search")
-
-
Optional<AssistantToolChoiceFunction> function-
String nameThe name of the function to call.
-
-
-
Thread
-
class Thread:Represents a thread that contains messages.
-
String idThe identifier, which can be referenced in API endpoints.
-
long createdAtThe Unix timestamp (in seconds) for when the thread was created.
-
Optional<Metadata> metadataSet 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"constantThe object type, which is always
thread.THREAD("thread")
-
Optional<ToolResources> toolResourcesA 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_interpretertool requires a list of file IDs, while thefile_searchtool requires a list of vector store IDs.-
Optional<CodeInterpreter> codeInterpreter-
Optional<List<String>> fileIdsA list of file IDs made available to the
code_interpretertool. There can be a maximum of 20 files associated with the tool.
-
-
Optional<FileSearch> fileSearch-
Optional<List<String>> vectorStoreIdsThe vector store attached to this thread. There can be a maximum of 1 vector store attached to the thread.
-
-
-
Thread Deleted
-
class ThreadDeleted:-
String id -
boolean deleted -
JsonValue; object_ "thread.deleted"constantTHREAD_DELETED("thread.deleted")
-
Runs
List runs
RunListPage beta().threads().runs().list(RunListParamsparams = RunListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
get /threads/{thread_id}/runs
Returns a list of runs belonging to a thread.
Parameters
-
RunListParams params-
Optional<String> threadId -
Optional<String> afterA cursor for use in pagination.
afteris an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. -
Optional<String> beforeA cursor for use in pagination.
beforeis an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. -
Optional<Long> limitA limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
-
Optional<Order> orderSort order by the
created_attimestamp of the objects.ascfor ascending order anddescfor descending order.-
ASC("asc") -
DESC("desc")
-
-
Returns
-
class Run:Represents an execution run on a thread.
-
String idThe identifier, which can be referenced in API endpoints.
-
String assistantIdThe ID of the assistant used for execution of this run.
-
Optional<Long> cancelledAtThe Unix timestamp (in seconds) for when the run was cancelled.
-
Optional<Long> completedAtThe Unix timestamp (in seconds) for when the run was completed.
-
long createdAtThe Unix timestamp (in seconds) for when the run was created.
-
Optional<Long> expiresAtThe Unix timestamp (in seconds) for when the run will expire.
-
Optional<Long> failedAtThe Unix timestamp (in seconds) for when the run failed.
-
Optional<IncompleteDetails> incompleteDetailsDetails on why the run is incomplete. Will be
nullif the run is not incomplete.-
Optional<Reason> reasonThe reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.
-
MAX_COMPLETION_TOKENS("max_completion_tokens") -
MAX_PROMPT_TOKENS("max_prompt_tokens")
-
-
-
String instructionsThe instructions that the assistant used for this run.
-
Optional<LastError> lastErrorThe last error associated with this run. Will be
nullif there are no errors.-
Code codeOne of
server_error,rate_limit_exceeded, orinvalid_prompt.-
SERVER_ERROR("server_error") -
RATE_LIMIT_EXCEEDED("rate_limit_exceeded") -
INVALID_PROMPT("invalid_prompt")
-
-
String messageA human-readable description of the error.
-
-
Optional<Long> maxCompletionTokensThe maximum number of completion tokens specified to have been used over the course of the run.
-
Optional<Long> maxPromptTokensThe maximum number of prompt tokens specified to have been used over the course of the run.
-
Optional<Metadata> metadataSet 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 modelThe model that the assistant used for this run.
-
JsonValue; object_ "thread.run"constantThe object type, which is always
thread.run.THREAD_RUN("thread.run")
-
boolean parallelToolCallsWhether to enable parallel function calling during tool use.
-
Optional<RequiredAction> requiredActionDetails on the action required to continue the run. Will be
nullif no action is required.-
SubmitToolOutputs submitToolOutputsDetails on the tool outputs needed for this run to continue.
-
List<RequiredActionFunctionToolCall> toolCallsA list of the relevant tool calls.
-
String idThe 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 functionThe function definition.
-
String argumentsThe arguments that the model expects you to pass to the function.
-
String nameThe name of the function.
-
-
JsonValue; type "function"constantThe type of tool call the output is required for. For now, this is always
function.FUNCTION("function")
-
-
-
JsonValue; type "submit_tool_outputs"constantFor now, this is always
submit_tool_outputs.SUBMIT_TOOL_OUTPUTS("submit_tool_outputs")
-
-
Optional<AssistantResponseFormatOption> responseFormatSpecifies 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 exceededmax_tokensor the conversation exceeded the max context length.-
JsonValue;AUTO("auto")
-
class ResponseFormatText:Default response format. Used to generate text responses.
-
JsonValue; type "text"constantThe type of response format being defined. Always
text.TEXT("text")
-
-
class ResponseFormatJsonObject:JSON object response format. An older method of generating JSON responses. Using
json_schemais 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"constantThe type of response format being defined. Always
json_object.JSON_OBJECT("json_object")
-
-
class ResponseFormatJsonSchema:JSON Schema response format. Used to generate structured JSON responses. Learn more about Structured Outputs.
-
JsonSchema jsonSchemaStructured Outputs configuration options, including a JSON Schema.
-
String nameThe 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> descriptionA description of what the response format is for, used by the model to determine how to respond in the format.
-
Optional<Schema> schemaThe schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas here.
-
Optional<Boolean> strictWhether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the
schemafield. Only a subset of JSON Schema is supported whenstrictistrue. To learn more, read the Structured Outputs guide.
-
-
JsonValue; type "json_schema"constantThe type of response format being defined. Always
json_schema.JSON_SCHEMA("json_schema")
-
-
-
Optional<Long> startedAtThe Unix timestamp (in seconds) for when the run was started.
-
RunStatus statusThe status of the run, which can be either
queued,in_progress,requires_action,cancelling,cancelled,failed,completed,incomplete, orexpired.-
QUEUED("queued") -
IN_PROGRESS("in_progress") -
REQUIRES_ACTION("requires_action") -
CANCELLING("cancelling") -
CANCELLED("cancelled") -
FAILED("failed") -
COMPLETED("completed") -
INCOMPLETE("incomplete") -
EXPIRED("expired")
-
-
String threadIdThe ID of the thread that was executed on as a part of this run.
-
Optional<AssistantToolChoiceOption> toolChoiceControls which (if any) tool is called by the model.
nonemeans the model will not call any tools and instead generates a message.autois the default value and means the model can pick between generating a message or calling one or more tools.requiredmeans 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.-
Auto-
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 typeThe type of the tool. If type is
function, the function name must be set-
FUNCTION("function") -
CODE_INTERPRETER("code_interpreter") -
FILE_SEARCH("file_search")
-
-
Optional<AssistantToolChoiceFunction> function-
String nameThe name of the function to call.
-
-
-
-
List<AssistantTool> toolsThe list of tools that the assistant used for this run.
-
class CodeInterpreterTool:-
JsonValue; type "code_interpreter"constantThe type of tool being defined:
code_interpreterCODE_INTERPRETER("code_interpreter")
-
-
class FileSearchTool:-
JsonValue; type "file_search"constantThe type of tool being defined:
file_searchFILE_SEARCH("file_search")
-
Optional<FileSearch> fileSearchOverrides for the file search tool.
-
Optional<Long> maxNumResultsThe maximum number of results the file search tool should output. The default is 20 for
gpt-4*models and 5 forgpt-3.5-turbo. This number should be between 1 and 50 inclusive.Note that the file search tool may output fewer than
max_num_resultsresults. See the file search tool documentation for more information. -
Optional<RankingOptions> rankingOptionsThe ranking options for the file search. If not specified, the file search tool will use the
autoranker and a score_threshold of 0.See the file search tool documentation for more information.
-
double scoreThresholdThe score threshold for the file search. All values must be a floating point number between 0 and 1.
-
Optional<Ranker> rankerThe ranker to use for the file search. If not specified will use the
autoranker.-
AUTO("auto") -
DEFAULT_2024_08_21("default_2024_08_21")
-
-
-
-
-
class FunctionTool:-
FunctionDefinition function-
String nameThe 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> descriptionA description of what the function does, used by the model to choose when and how to call the function.
-
Optional<FunctionParameters> parametersThe 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
parametersdefines a function with an empty parameter list. -
Optional<Boolean> strictWhether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the
parametersfield. Only a subset of JSON Schema is supported whenstrictistrue. Learn more about Structured Outputs in the function calling guide.
-
-
JsonValue; type "function"constantThe type of tool being defined:
functionFUNCTION("function")
-
-
-
Optional<TruncationStrategy> truncationStrategyControls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.
-
Type typeThe truncation strategy to use for the thread. The default is
auto. If set tolast_messages, the thread will be truncated to the n most recent messages in the thread. When set toauto, messages in the middle of the thread will be dropped to fit the context length of the model,max_prompt_tokens.-
AUTO("auto") -
LAST_MESSAGES("last_messages")
-
-
Optional<Long> lastMessagesThe number of most recent messages from the thread when constructing the context for the run.
-
-
Optional<Usage> usageUsage statistics related to the run. This value will be
nullif the run is not in a terminal state (i.e.in_progress,queued, etc.).-
long completionTokensNumber of completion tokens used over the course of the run.
-
long promptTokensNumber of prompt tokens used over the course of the run.
-
long totalTokensTotal number of tokens used (prompt + completion).
-
-
Optional<Double> temperatureThe sampling temperature used for this run. If not set, defaults to 1.
-
Optional<Double> topPThe nucleus sampling value used for this run. If not set, defaults to 1.
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.threads.runs.RunListPage;
import com.openai.models.beta.threads.runs.RunListParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
RunListPage page = client.beta().threads().runs().list("thread_id");
}
}
Response
{
"data": [
{
"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
}
],
"first_id": "run_abc123",
"has_more": false,
"last_id": "run_abc456",
"object": "list"
}
Create run
Run beta().threads().runs().create(RunCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
post /threads/{thread_id}/runs
Create a run.
Parameters
-
RunCreateParams params-
Optional<String> threadId -
Optional<List<RunStepInclude>> includeA list of additional fields to include in the response. Currently the only supported value is
step_details.tool_calls[*].file_search.results[*].contentto fetch the file search result content.See the file search tool documentation for more information.
STEP_DETAILS_TOOL_CALLS_FILE_SEARCH_RESULTS_CONTENT("step_details.tool_calls[*].file_search.results[*].content")
-
String assistantIdThe ID of the assistant to use to execute this run.
-
Optional<String> additionalInstructionsAppends additional instructions at the end of the instructions for the run. This is useful for modifying the behavior on a per-run basis without overriding other instructions.
-
Optional<List<AdditionalMessage>> additionalMessagesAdds additional messages to the thread before creating the run.
-
Content contentThe text contents of the message.
-
String -
List<MessageContentPartParam>-
class ImageFileContentBlock:References an image File in the content of a message.
-
ImageFile imageFile-
String fileIdThe 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> detailSpecifies the detail level of the image if specified by the user.
lowuses fewer tokens, you can opt in to high resolution usinghigh.-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
-
JsonValue; type "image_file"constantAlways
image_file.IMAGE_FILE("image_file")
-
-
class ImageUrlContentBlock:References an image URL in the content of a message.
-
ImageUrl imageUrl-
String urlThe external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.
-
Optional<Detail> detailSpecifies the detail level of the image.
lowuses fewer tokens, you can opt in to high resolution usinghigh. Default value isauto-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
-
JsonValue; type "image_url"constantThe type of the content part.
IMAGE_URL("image_url")
-
-
class TextContentBlockParam:The text content that is part of a message.
-
String textText content to be sent to the model
-
JsonValue; type "text"constantAlways
text.TEXT("text")
-
-
-
-
Role roleThe 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. -
USER("user") -
ASSISTANT("assistant")
-
-
Optional<List<Attachment>> attachmentsA list of files attached to the message, and the tools they should be added to.
-
Optional<String> fileIdThe ID of the file to attach to the message.
-
Optional<List<Tool>> toolsThe tools to add this file to.
-
class CodeInterpreterTool:-
JsonValue; type "code_interpreter"constantThe type of tool being defined:
code_interpreterCODE_INTERPRETER("code_interpreter")
-
-
JsonValue;-
JsonValue; type "file_search"constantThe type of tool being defined:
file_searchFILE_SEARCH("file_search")
-
-
-
-
Optional<Metadata> metadataSet 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<String> instructionsOverrides the instructions of the assistant. This is useful for modifying the behavior on a per-run basis.
-
Optional<Long> maxCompletionTokensThe 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. Seeincomplete_detailsfor more info. -
Optional<Long> maxPromptTokensThe 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. Seeincomplete_detailsfor more info. -
Optional<Metadata> metadataSet 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> modelThe 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.
-
Optional<Boolean> parallelToolCallsWhether to enable parallel function calling during tool use.
-
Optional<ReasoningEffort> reasoningEffortConstrains effort on reasoning for reasoning models. Currently supported values are
none,minimal,low,medium,high, andxhigh. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.gpt-5.1defaults tonone, which does not perform reasoning. The supported reasoning values forgpt-5.1arenone,low,medium, andhigh. Tool calls are supported for all reasoning values in gpt-5.1.- All models before
gpt-5.1default tomediumreasoning effort, and do not supportnone. - The
gpt-5-promodel defaults to (and only supports)highreasoning effort. xhighis supported for all models aftergpt-5.1-codex-max.
-
Optional<AssistantResponseFormatOption> responseFormatSpecifies 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 exceededmax_tokensor the conversation exceeded the max context length. -
Optional<Double> temperatureWhat 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.
-
Optional<AssistantToolChoiceOption> toolChoiceControls which (if any) tool is called by the model.
nonemeans the model will not call any tools and instead generates a message.autois the default value and means the model can pick between generating a message or calling one or more tools.requiredmeans 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<List<AssistantTool>> toolsOverride the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis.
-
class CodeInterpreterTool: -
class FileSearchTool:-
JsonValue; type "file_search"constantThe type of tool being defined:
file_searchFILE_SEARCH("file_search")
-
Optional<FileSearch> fileSearchOverrides for the file search tool.
-
Optional<Long> maxNumResultsThe maximum number of results the file search tool should output. The default is 20 for
gpt-4*models and 5 forgpt-3.5-turbo. This number should be between 1 and 50 inclusive.Note that the file search tool may output fewer than
max_num_resultsresults. See the file search tool documentation for more information. -
Optional<RankingOptions> rankingOptionsThe ranking options for the file search. If not specified, the file search tool will use the
autoranker and a score_threshold of 0.See the file search tool documentation for more information.
-
double scoreThresholdThe score threshold for the file search. All values must be a floating point number between 0 and 1.
-
Optional<Ranker> rankerThe ranker to use for the file search. If not specified will use the
autoranker.-
AUTO("auto") -
DEFAULT_2024_08_21("default_2024_08_21")
-
-
-
-
-
class FunctionTool:-
FunctionDefinition function-
String nameThe 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> descriptionA description of what the function does, used by the model to choose when and how to call the function.
-
Optional<FunctionParameters> parametersThe 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
parametersdefines a function with an empty parameter list. -
Optional<Boolean> strictWhether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the
parametersfield. Only a subset of JSON Schema is supported whenstrictistrue. Learn more about Structured Outputs in the function calling guide.
-
-
JsonValue; type "function"constantThe type of tool being defined:
functionFUNCTION("function")
-
-
-
Optional<Double> topPAn 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.
-
Optional<TruncationStrategy> truncationStrategyControls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.
-
Type typeThe truncation strategy to use for the thread. The default is
auto. If set tolast_messages, the thread will be truncated to the n most recent messages in the thread. When set toauto, messages in the middle of the thread will be dropped to fit the context length of the model,max_prompt_tokens.-
AUTO("auto") -
LAST_MESSAGES("last_messages")
-
-
Optional<Long> lastMessagesThe number of most recent messages from the thread when constructing the context for the run.
-
-
Returns
-
class Run:Represents an execution run on a thread.
-
String idThe identifier, which can be referenced in API endpoints.
-
String assistantIdThe ID of the assistant used for execution of this run.
-
Optional<Long> cancelledAtThe Unix timestamp (in seconds) for when the run was cancelled.
-
Optional<Long> completedAtThe Unix timestamp (in seconds) for when the run was completed.
-
long createdAtThe Unix timestamp (in seconds) for when the run was created.
-
Optional<Long> expiresAtThe Unix timestamp (in seconds) for when the run will expire.
-
Optional<Long> failedAtThe Unix timestamp (in seconds) for when the run failed.
-
Optional<IncompleteDetails> incompleteDetailsDetails on why the run is incomplete. Will be
nullif the run is not incomplete.-
Optional<Reason> reasonThe reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.
-
MAX_COMPLETION_TOKENS("max_completion_tokens") -
MAX_PROMPT_TOKENS("max_prompt_tokens")
-
-
-
String instructionsThe instructions that the assistant used for this run.
-
Optional<LastError> lastErrorThe last error associated with this run. Will be
nullif there are no errors.-
Code codeOne of
server_error,rate_limit_exceeded, orinvalid_prompt.-
SERVER_ERROR("server_error") -
RATE_LIMIT_EXCEEDED("rate_limit_exceeded") -
INVALID_PROMPT("invalid_prompt")
-
-
String messageA human-readable description of the error.
-
-
Optional<Long> maxCompletionTokensThe maximum number of completion tokens specified to have been used over the course of the run.
-
Optional<Long> maxPromptTokensThe maximum number of prompt tokens specified to have been used over the course of the run.
-
Optional<Metadata> metadataSet 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 modelThe model that the assistant used for this run.
-
JsonValue; object_ "thread.run"constantThe object type, which is always
thread.run.THREAD_RUN("thread.run")
-
boolean parallelToolCallsWhether to enable parallel function calling during tool use.
-
Optional<RequiredAction> requiredActionDetails on the action required to continue the run. Will be
nullif no action is required.-
SubmitToolOutputs submitToolOutputsDetails on the tool outputs needed for this run to continue.
-
List<RequiredActionFunctionToolCall> toolCallsA list of the relevant tool calls.
-
String idThe 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 functionThe function definition.
-
String argumentsThe arguments that the model expects you to pass to the function.
-
String nameThe name of the function.
-
-
JsonValue; type "function"constantThe type of tool call the output is required for. For now, this is always
function.FUNCTION("function")
-
-
-
JsonValue; type "submit_tool_outputs"constantFor now, this is always
submit_tool_outputs.SUBMIT_TOOL_OUTPUTS("submit_tool_outputs")
-
-
Optional<AssistantResponseFormatOption> responseFormatSpecifies 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 exceededmax_tokensor the conversation exceeded the max context length.-
JsonValue;AUTO("auto")
-
class ResponseFormatText:Default response format. Used to generate text responses.
-
JsonValue; type "text"constantThe type of response format being defined. Always
text.TEXT("text")
-
-
class ResponseFormatJsonObject:JSON object response format. An older method of generating JSON responses. Using
json_schemais 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"constantThe type of response format being defined. Always
json_object.JSON_OBJECT("json_object")
-
-
class ResponseFormatJsonSchema:JSON Schema response format. Used to generate structured JSON responses. Learn more about Structured Outputs.
-
JsonSchema jsonSchemaStructured Outputs configuration options, including a JSON Schema.
-
String nameThe 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> descriptionA description of what the response format is for, used by the model to determine how to respond in the format.
-
Optional<Schema> schemaThe schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas here.
-
Optional<Boolean> strictWhether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the
schemafield. Only a subset of JSON Schema is supported whenstrictistrue. To learn more, read the Structured Outputs guide.
-
-
JsonValue; type "json_schema"constantThe type of response format being defined. Always
json_schema.JSON_SCHEMA("json_schema")
-
-
-
Optional<Long> startedAtThe Unix timestamp (in seconds) for when the run was started.
-
RunStatus statusThe status of the run, which can be either
queued,in_progress,requires_action,cancelling,cancelled,failed,completed,incomplete, orexpired.-
QUEUED("queued") -
IN_PROGRESS("in_progress") -
REQUIRES_ACTION("requires_action") -
CANCELLING("cancelling") -
CANCELLED("cancelled") -
FAILED("failed") -
COMPLETED("completed") -
INCOMPLETE("incomplete") -
EXPIRED("expired")
-
-
String threadIdThe ID of the thread that was executed on as a part of this run.
-
Optional<AssistantToolChoiceOption> toolChoiceControls which (if any) tool is called by the model.
nonemeans the model will not call any tools and instead generates a message.autois the default value and means the model can pick between generating a message or calling one or more tools.requiredmeans 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.-
Auto-
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 typeThe type of the tool. If type is
function, the function name must be set-
FUNCTION("function") -
CODE_INTERPRETER("code_interpreter") -
FILE_SEARCH("file_search")
-
-
Optional<AssistantToolChoiceFunction> function-
String nameThe name of the function to call.
-
-
-
-
List<AssistantTool> toolsThe list of tools that the assistant used for this run.
-
class CodeInterpreterTool:-
JsonValue; type "code_interpreter"constantThe type of tool being defined:
code_interpreterCODE_INTERPRETER("code_interpreter")
-
-
class FileSearchTool:-
JsonValue; type "file_search"constantThe type of tool being defined:
file_searchFILE_SEARCH("file_search")
-
Optional<FileSearch> fileSearchOverrides for the file search tool.
-
Optional<Long> maxNumResultsThe maximum number of results the file search tool should output. The default is 20 for
gpt-4*models and 5 forgpt-3.5-turbo. This number should be between 1 and 50 inclusive.Note that the file search tool may output fewer than
max_num_resultsresults. See the file search tool documentation for more information. -
Optional<RankingOptions> rankingOptionsThe ranking options for the file search. If not specified, the file search tool will use the
autoranker and a score_threshold of 0.See the file search tool documentation for more information.
-
double scoreThresholdThe score threshold for the file search. All values must be a floating point number between 0 and 1.
-
Optional<Ranker> rankerThe ranker to use for the file search. If not specified will use the
autoranker.-
AUTO("auto") -
DEFAULT_2024_08_21("default_2024_08_21")
-
-
-
-
-
class FunctionTool:-
FunctionDefinition function-
String nameThe 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> descriptionA description of what the function does, used by the model to choose when and how to call the function.
-
Optional<FunctionParameters> parametersThe 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
parametersdefines a function with an empty parameter list. -
Optional<Boolean> strictWhether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the
parametersfield. Only a subset of JSON Schema is supported whenstrictistrue. Learn more about Structured Outputs in the function calling guide.
-
-
JsonValue; type "function"constantThe type of tool being defined:
functionFUNCTION("function")
-
-
-
Optional<TruncationStrategy> truncationStrategyControls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.
-
Type typeThe truncation strategy to use for the thread. The default is
auto. If set tolast_messages, the thread will be truncated to the n most recent messages in the thread. When set toauto, messages in the middle of the thread will be dropped to fit the context length of the model,max_prompt_tokens.-
AUTO("auto") -
LAST_MESSAGES("last_messages")
-
-
Optional<Long> lastMessagesThe number of most recent messages from the thread when constructing the context for the run.
-
-
Optional<Usage> usageUsage statistics related to the run. This value will be
nullif the run is not in a terminal state (i.e.in_progress,queued, etc.).-
long completionTokensNumber of completion tokens used over the course of the run.
-
long promptTokensNumber of prompt tokens used over the course of the run.
-
long totalTokensTotal number of tokens used (prompt + completion).
-
-
Optional<Double> temperatureThe sampling temperature used for this run. If not set, defaults to 1.
-
Optional<Double> topPThe nucleus sampling value used for this run. If not set, defaults to 1.
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.threads.runs.Run;
import com.openai.models.beta.threads.runs.RunCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
RunCreateParams params = RunCreateParams.builder()
.threadId("thread_id")
.assistantId("assistant_id")
.build();
Run run = client.beta().threads().runs().create(params);
}
}
Response
{
"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
}
Retrieve run
Run beta().threads().runs().retrieve(RunRetrieveParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
get /threads/{thread_id}/runs/{run_id}
Retrieves a run.
Parameters
-
RunRetrieveParams params-
String threadId -
Optional<String> runId
-
Returns
-
class Run:Represents an execution run on a thread.
-
String idThe identifier, which can be referenced in API endpoints.
-
String assistantIdThe ID of the assistant used for execution of this run.
-
Optional<Long> cancelledAtThe Unix timestamp (in seconds) for when the run was cancelled.
-
Optional<Long> completedAtThe Unix timestamp (in seconds) for when the run was completed.
-
long createdAtThe Unix timestamp (in seconds) for when the run was created.
-
Optional<Long> expiresAtThe Unix timestamp (in seconds) for when the run will expire.
-
Optional<Long> failedAtThe Unix timestamp (in seconds) for when the run failed.
-
Optional<IncompleteDetails> incompleteDetailsDetails on why the run is incomplete. Will be
nullif the run is not incomplete.-
Optional<Reason> reasonThe reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.
-
MAX_COMPLETION_TOKENS("max_completion_tokens") -
MAX_PROMPT_TOKENS("max_prompt_tokens")
-
-
-
String instructionsThe instructions that the assistant used for this run.
-
Optional<LastError> lastErrorThe last error associated with this run. Will be
nullif there are no errors.-
Code codeOne of
server_error,rate_limit_exceeded, orinvalid_prompt.-
SERVER_ERROR("server_error") -
RATE_LIMIT_EXCEEDED("rate_limit_exceeded") -
INVALID_PROMPT("invalid_prompt")
-
-
String messageA human-readable description of the error.
-
-
Optional<Long> maxCompletionTokensThe maximum number of completion tokens specified to have been used over the course of the run.
-
Optional<Long> maxPromptTokensThe maximum number of prompt tokens specified to have been used over the course of the run.
-
Optional<Metadata> metadataSet 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 modelThe model that the assistant used for this run.
-
JsonValue; object_ "thread.run"constantThe object type, which is always
thread.run.THREAD_RUN("thread.run")
-
boolean parallelToolCallsWhether to enable parallel function calling during tool use.
-
Optional<RequiredAction> requiredActionDetails on the action required to continue the run. Will be
nullif no action is required.-
SubmitToolOutputs submitToolOutputsDetails on the tool outputs needed for this run to continue.
-
List<RequiredActionFunctionToolCall> toolCallsA list of the relevant tool calls.
-
String idThe 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 functionThe function definition.
-
String argumentsThe arguments that the model expects you to pass to the function.
-
String nameThe name of the function.
-
-
JsonValue; type "function"constantThe type of tool call the output is required for. For now, this is always
function.FUNCTION("function")
-
-
-
JsonValue; type "submit_tool_outputs"constantFor now, this is always
submit_tool_outputs.SUBMIT_TOOL_OUTPUTS("submit_tool_outputs")
-
-
Optional<AssistantResponseFormatOption> responseFormatSpecifies 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 exceededmax_tokensor the conversation exceeded the max context length.-
JsonValue;AUTO("auto")
-
class ResponseFormatText:Default response format. Used to generate text responses.
-
JsonValue; type "text"constantThe type of response format being defined. Always
text.TEXT("text")
-
-
class ResponseFormatJsonObject:JSON object response format. An older method of generating JSON responses. Using
json_schemais 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"constantThe type of response format being defined. Always
json_object.JSON_OBJECT("json_object")
-
-
class ResponseFormatJsonSchema:JSON Schema response format. Used to generate structured JSON responses. Learn more about Structured Outputs.
-
JsonSchema jsonSchemaStructured Outputs configuration options, including a JSON Schema.
-
String nameThe 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> descriptionA description of what the response format is for, used by the model to determine how to respond in the format.
-
Optional<Schema> schemaThe schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas here.
-
Optional<Boolean> strictWhether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the
schemafield. Only a subset of JSON Schema is supported whenstrictistrue. To learn more, read the Structured Outputs guide.
-
-
JsonValue; type "json_schema"constantThe type of response format being defined. Always
json_schema.JSON_SCHEMA("json_schema")
-
-
-
Optional<Long> startedAtThe Unix timestamp (in seconds) for when the run was started.
-
RunStatus statusThe status of the run, which can be either
queued,in_progress,requires_action,cancelling,cancelled,failed,completed,incomplete, orexpired.-
QUEUED("queued") -
IN_PROGRESS("in_progress") -
REQUIRES_ACTION("requires_action") -
CANCELLING("cancelling") -
CANCELLED("cancelled") -
FAILED("failed") -
COMPLETED("completed") -
INCOMPLETE("incomplete") -
EXPIRED("expired")
-
-
String threadIdThe ID of the thread that was executed on as a part of this run.
-
Optional<AssistantToolChoiceOption> toolChoiceControls which (if any) tool is called by the model.
nonemeans the model will not call any tools and instead generates a message.autois the default value and means the model can pick between generating a message or calling one or more tools.requiredmeans 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.-
Auto-
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 typeThe type of the tool. If type is
function, the function name must be set-
FUNCTION("function") -
CODE_INTERPRETER("code_interpreter") -
FILE_SEARCH("file_search")
-
-
Optional<AssistantToolChoiceFunction> function-
String nameThe name of the function to call.
-
-
-
-
List<AssistantTool> toolsThe list of tools that the assistant used for this run.
-
class CodeInterpreterTool:-
JsonValue; type "code_interpreter"constantThe type of tool being defined:
code_interpreterCODE_INTERPRETER("code_interpreter")
-
-
class FileSearchTool:-
JsonValue; type "file_search"constantThe type of tool being defined:
file_searchFILE_SEARCH("file_search")
-
Optional<FileSearch> fileSearchOverrides for the file search tool.
-
Optional<Long> maxNumResultsThe maximum number of results the file search tool should output. The default is 20 for
gpt-4*models and 5 forgpt-3.5-turbo. This number should be between 1 and 50 inclusive.Note that the file search tool may output fewer than
max_num_resultsresults. See the file search tool documentation for more information. -
Optional<RankingOptions> rankingOptionsThe ranking options for the file search. If not specified, the file search tool will use the
autoranker and a score_threshold of 0.See the file search tool documentation for more information.
-
double scoreThresholdThe score threshold for the file search. All values must be a floating point number between 0 and 1.
-
Optional<Ranker> rankerThe ranker to use for the file search. If not specified will use the
autoranker.-
AUTO("auto") -
DEFAULT_2024_08_21("default_2024_08_21")
-
-
-
-
-
class FunctionTool:-
FunctionDefinition function-
String nameThe 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> descriptionA description of what the function does, used by the model to choose when and how to call the function.
-
Optional<FunctionParameters> parametersThe 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
parametersdefines a function with an empty parameter list. -
Optional<Boolean> strictWhether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the
parametersfield. Only a subset of JSON Schema is supported whenstrictistrue. Learn more about Structured Outputs in the function calling guide.
-
-
JsonValue; type "function"constantThe type of tool being defined:
functionFUNCTION("function")
-
-
-
Optional<TruncationStrategy> truncationStrategyControls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.
-
Type typeThe truncation strategy to use for the thread. The default is
auto. If set tolast_messages, the thread will be truncated to the n most recent messages in the thread. When set toauto, messages in the middle of the thread will be dropped to fit the context length of the model,max_prompt_tokens.-
AUTO("auto") -
LAST_MESSAGES("last_messages")
-
-
Optional<Long> lastMessagesThe number of most recent messages from the thread when constructing the context for the run.
-
-
Optional<Usage> usageUsage statistics related to the run. This value will be
nullif the run is not in a terminal state (i.e.in_progress,queued, etc.).-
long completionTokensNumber of completion tokens used over the course of the run.
-
long promptTokensNumber of prompt tokens used over the course of the run.
-
long totalTokensTotal number of tokens used (prompt + completion).
-
-
Optional<Double> temperatureThe sampling temperature used for this run. If not set, defaults to 1.
-
Optional<Double> topPThe nucleus sampling value used for this run. If not set, defaults to 1.
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.threads.runs.Run;
import com.openai.models.beta.threads.runs.RunRetrieveParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
RunRetrieveParams params = RunRetrieveParams.builder()
.threadId("thread_id")
.runId("run_id")
.build();
Run run = client.beta().threads().runs().retrieve(params);
}
}
Response
{
"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
}
Modify run
Run beta().threads().runs().update(RunUpdateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
post /threads/{thread_id}/runs/{run_id}
Modifies a run.
Parameters
-
RunUpdateParams params-
String threadId -
Optional<String> runId -
Optional<Metadata> metadataSet 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.
-
Returns
-
class Run:Represents an execution run on a thread.
-
String idThe identifier, which can be referenced in API endpoints.
-
String assistantIdThe ID of the assistant used for execution of this run.
-
Optional<Long> cancelledAtThe Unix timestamp (in seconds) for when the run was cancelled.
-
Optional<Long> completedAtThe Unix timestamp (in seconds) for when the run was completed.
-
long createdAtThe Unix timestamp (in seconds) for when the run was created.
-
Optional<Long> expiresAtThe Unix timestamp (in seconds) for when the run will expire.
-
Optional<Long> failedAtThe Unix timestamp (in seconds) for when the run failed.
-
Optional<IncompleteDetails> incompleteDetailsDetails on why the run is incomplete. Will be
nullif the run is not incomplete.-
Optional<Reason> reasonThe reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.
-
MAX_COMPLETION_TOKENS("max_completion_tokens") -
MAX_PROMPT_TOKENS("max_prompt_tokens")
-
-
-
String instructionsThe instructions that the assistant used for this run.
-
Optional<LastError> lastErrorThe last error associated with this run. Will be
nullif there are no errors.-
Code codeOne of
server_error,rate_limit_exceeded, orinvalid_prompt.-
SERVER_ERROR("server_error") -
RATE_LIMIT_EXCEEDED("rate_limit_exceeded") -
INVALID_PROMPT("invalid_prompt")
-
-
String messageA human-readable description of the error.
-
-
Optional<Long> maxCompletionTokensThe maximum number of completion tokens specified to have been used over the course of the run.
-
Optional<Long> maxPromptTokensThe maximum number of prompt tokens specified to have been used over the course of the run.
-
Optional<Metadata> metadataSet 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 modelThe model that the assistant used for this run.
-
JsonValue; object_ "thread.run"constantThe object type, which is always
thread.run.THREAD_RUN("thread.run")
-
boolean parallelToolCallsWhether to enable parallel function calling during tool use.
-
Optional<RequiredAction> requiredActionDetails on the action required to continue the run. Will be
nullif no action is required.-
SubmitToolOutputs submitToolOutputsDetails on the tool outputs needed for this run to continue.
-
List<RequiredActionFunctionToolCall> toolCallsA list of the relevant tool calls.
-
String idThe 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 functionThe function definition.
-
String argumentsThe arguments that the model expects you to pass to the function.
-
String nameThe name of the function.
-
-
JsonValue; type "function"constantThe type of tool call the output is required for. For now, this is always
function.FUNCTION("function")
-
-
-
JsonValue; type "submit_tool_outputs"constantFor now, this is always
submit_tool_outputs.SUBMIT_TOOL_OUTPUTS("submit_tool_outputs")
-
-
Optional<AssistantResponseFormatOption> responseFormatSpecifies 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 exceededmax_tokensor the conversation exceeded the max context length.-
JsonValue;AUTO("auto")
-
class ResponseFormatText:Default response format. Used to generate text responses.
-
JsonValue; type "text"constantThe type of response format being defined. Always
text.TEXT("text")
-
-
class ResponseFormatJsonObject:JSON object response format. An older method of generating JSON responses. Using
json_schemais 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"constantThe type of response format being defined. Always
json_object.JSON_OBJECT("json_object")
-
-
class ResponseFormatJsonSchema:JSON Schema response format. Used to generate structured JSON responses. Learn more about Structured Outputs.
-
JsonSchema jsonSchemaStructured Outputs configuration options, including a JSON Schema.
-
String nameThe 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> descriptionA description of what the response format is for, used by the model to determine how to respond in the format.
-
Optional<Schema> schemaThe schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas here.
-
Optional<Boolean> strictWhether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the
schemafield. Only a subset of JSON Schema is supported whenstrictistrue. To learn more, read the Structured Outputs guide.
-
-
JsonValue; type "json_schema"constantThe type of response format being defined. Always
json_schema.JSON_SCHEMA("json_schema")
-
-
-
Optional<Long> startedAtThe Unix timestamp (in seconds) for when the run was started.
-
RunStatus statusThe status of the run, which can be either
queued,in_progress,requires_action,cancelling,cancelled,failed,completed,incomplete, orexpired.-
QUEUED("queued") -
IN_PROGRESS("in_progress") -
REQUIRES_ACTION("requires_action") -
CANCELLING("cancelling") -
CANCELLED("cancelled") -
FAILED("failed") -
COMPLETED("completed") -
INCOMPLETE("incomplete") -
EXPIRED("expired")
-
-
String threadIdThe ID of the thread that was executed on as a part of this run.
-
Optional<AssistantToolChoiceOption> toolChoiceControls which (if any) tool is called by the model.
nonemeans the model will not call any tools and instead generates a message.autois the default value and means the model can pick between generating a message or calling one or more tools.requiredmeans 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.-
Auto-
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 typeThe type of the tool. If type is
function, the function name must be set-
FUNCTION("function") -
CODE_INTERPRETER("code_interpreter") -
FILE_SEARCH("file_search")
-
-
Optional<AssistantToolChoiceFunction> function-
String nameThe name of the function to call.
-
-
-
-
List<AssistantTool> toolsThe list of tools that the assistant used for this run.
-
class CodeInterpreterTool:-
JsonValue; type "code_interpreter"constantThe type of tool being defined:
code_interpreterCODE_INTERPRETER("code_interpreter")
-
-
class FileSearchTool:-
JsonValue; type "file_search"constantThe type of tool being defined:
file_searchFILE_SEARCH("file_search")
-
Optional<FileSearch> fileSearchOverrides for the file search tool.
-
Optional<Long> maxNumResultsThe maximum number of results the file search tool should output. The default is 20 for
gpt-4*models and 5 forgpt-3.5-turbo. This number should be between 1 and 50 inclusive.Note that the file search tool may output fewer than
max_num_resultsresults. See the file search tool documentation for more information. -
Optional<RankingOptions> rankingOptionsThe ranking options for the file search. If not specified, the file search tool will use the
autoranker and a score_threshold of 0.See the file search tool documentation for more information.
-
double scoreThresholdThe score threshold for the file search. All values must be a floating point number between 0 and 1.
-
Optional<Ranker> rankerThe ranker to use for the file search. If not specified will use the
autoranker.-
AUTO("auto") -
DEFAULT_2024_08_21("default_2024_08_21")
-
-
-
-
-
class FunctionTool:-
FunctionDefinition function-
String nameThe 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> descriptionA description of what the function does, used by the model to choose when and how to call the function.
-
Optional<FunctionParameters> parametersThe 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
parametersdefines a function with an empty parameter list. -
Optional<Boolean> strictWhether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the
parametersfield. Only a subset of JSON Schema is supported whenstrictistrue. Learn more about Structured Outputs in the function calling guide.
-
-
JsonValue; type "function"constantThe type of tool being defined:
functionFUNCTION("function")
-
-
-
Optional<TruncationStrategy> truncationStrategyControls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.
-
Type typeThe truncation strategy to use for the thread. The default is
auto. If set tolast_messages, the thread will be truncated to the n most recent messages in the thread. When set toauto, messages in the middle of the thread will be dropped to fit the context length of the model,max_prompt_tokens.-
AUTO("auto") -
LAST_MESSAGES("last_messages")
-
-
Optional<Long> lastMessagesThe number of most recent messages from the thread when constructing the context for the run.
-
-
Optional<Usage> usageUsage statistics related to the run. This value will be
nullif the run is not in a terminal state (i.e.in_progress,queued, etc.).-
long completionTokensNumber of completion tokens used over the course of the run.
-
long promptTokensNumber of prompt tokens used over the course of the run.
-
long totalTokensTotal number of tokens used (prompt + completion).
-
-
Optional<Double> temperatureThe sampling temperature used for this run. If not set, defaults to 1.
-
Optional<Double> topPThe nucleus sampling value used for this run. If not set, defaults to 1.
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.threads.runs.Run;
import com.openai.models.beta.threads.runs.RunUpdateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
RunUpdateParams params = RunUpdateParams.builder()
.threadId("thread_id")
.runId("run_id")
.build();
Run run = client.beta().threads().runs().update(params);
}
}
Response
{
"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
}
Submit tool outputs to run
Run beta().threads().runs().submitToolOutputs(RunSubmitToolOutputsParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
post /threads/{thread_id}/runs/{run_id}/submit_tool_outputs
When a run has the status: "requires_action" and required_action.type is submit_tool_outputs, this endpoint can be used to submit the outputs from the tool calls once they're all completed. All outputs must be submitted in a single request.
Parameters
-
RunSubmitToolOutputsParams params-
String threadId -
Optional<String> runId -
List<ToolOutput> toolOutputsA list of tools for which the outputs are being submitted.
-
Optional<String> outputThe output of the tool call to be submitted to continue the run.
-
Optional<String> toolCallIdThe ID of the tool call in the
required_actionobject within the run object the output is being submitted for.
-
-
Returns
-
class Run:Represents an execution run on a thread.
-
String idThe identifier, which can be referenced in API endpoints.
-
String assistantIdThe ID of the assistant used for execution of this run.
-
Optional<Long> cancelledAtThe Unix timestamp (in seconds) for when the run was cancelled.
-
Optional<Long> completedAtThe Unix timestamp (in seconds) for when the run was completed.
-
long createdAtThe Unix timestamp (in seconds) for when the run was created.
-
Optional<Long> expiresAtThe Unix timestamp (in seconds) for when the run will expire.
-
Optional<Long> failedAtThe Unix timestamp (in seconds) for when the run failed.
-
Optional<IncompleteDetails> incompleteDetailsDetails on why the run is incomplete. Will be
nullif the run is not incomplete.-
Optional<Reason> reasonThe reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.
-
MAX_COMPLETION_TOKENS("max_completion_tokens") -
MAX_PROMPT_TOKENS("max_prompt_tokens")
-
-
-
String instructionsThe instructions that the assistant used for this run.
-
Optional<LastError> lastErrorThe last error associated with this run. Will be
nullif there are no errors.-
Code codeOne of
server_error,rate_limit_exceeded, orinvalid_prompt.-
SERVER_ERROR("server_error") -
RATE_LIMIT_EXCEEDED("rate_limit_exceeded") -
INVALID_PROMPT("invalid_prompt")
-
-
String messageA human-readable description of the error.
-
-
Optional<Long> maxCompletionTokensThe maximum number of completion tokens specified to have been used over the course of the run.
-
Optional<Long> maxPromptTokensThe maximum number of prompt tokens specified to have been used over the course of the run.
-
Optional<Metadata> metadataSet 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 modelThe model that the assistant used for this run.
-
JsonValue; object_ "thread.run"constantThe object type, which is always
thread.run.THREAD_RUN("thread.run")
-
boolean parallelToolCallsWhether to enable parallel function calling during tool use.
-
Optional<RequiredAction> requiredActionDetails on the action required to continue the run. Will be
nullif no action is required.-
SubmitToolOutputs submitToolOutputsDetails on the tool outputs needed for this run to continue.
-
List<RequiredActionFunctionToolCall> toolCallsA list of the relevant tool calls.
-
String idThe 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 functionThe function definition.
-
String argumentsThe arguments that the model expects you to pass to the function.
-
String nameThe name of the function.
-
-
JsonValue; type "function"constantThe type of tool call the output is required for. For now, this is always
function.FUNCTION("function")
-
-
-
JsonValue; type "submit_tool_outputs"constantFor now, this is always
submit_tool_outputs.SUBMIT_TOOL_OUTPUTS("submit_tool_outputs")
-
-
Optional<AssistantResponseFormatOption> responseFormatSpecifies 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 exceededmax_tokensor the conversation exceeded the max context length.-
JsonValue;AUTO("auto")
-
class ResponseFormatText:Default response format. Used to generate text responses.
-
JsonValue; type "text"constantThe type of response format being defined. Always
text.TEXT("text")
-
-
class ResponseFormatJsonObject:JSON object response format. An older method of generating JSON responses. Using
json_schemais 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"constantThe type of response format being defined. Always
json_object.JSON_OBJECT("json_object")
-
-
class ResponseFormatJsonSchema:JSON Schema response format. Used to generate structured JSON responses. Learn more about Structured Outputs.
-
JsonSchema jsonSchemaStructured Outputs configuration options, including a JSON Schema.
-
String nameThe 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> descriptionA description of what the response format is for, used by the model to determine how to respond in the format.
-
Optional<Schema> schemaThe schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas here.
-
Optional<Boolean> strictWhether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the
schemafield. Only a subset of JSON Schema is supported whenstrictistrue. To learn more, read the Structured Outputs guide.
-
-
JsonValue; type "json_schema"constantThe type of response format being defined. Always
json_schema.JSON_SCHEMA("json_schema")
-
-
-
Optional<Long> startedAtThe Unix timestamp (in seconds) for when the run was started.
-
RunStatus statusThe status of the run, which can be either
queued,in_progress,requires_action,cancelling,cancelled,failed,completed,incomplete, orexpired.-
QUEUED("queued") -
IN_PROGRESS("in_progress") -
REQUIRES_ACTION("requires_action") -
CANCELLING("cancelling") -
CANCELLED("cancelled") -
FAILED("failed") -
COMPLETED("completed") -
INCOMPLETE("incomplete") -
EXPIRED("expired")
-
-
String threadIdThe ID of the thread that was executed on as a part of this run.
-
Optional<AssistantToolChoiceOption> toolChoiceControls which (if any) tool is called by the model.
nonemeans the model will not call any tools and instead generates a message.autois the default value and means the model can pick between generating a message or calling one or more tools.requiredmeans 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.-
Auto-
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 typeThe type of the tool. If type is
function, the function name must be set-
FUNCTION("function") -
CODE_INTERPRETER("code_interpreter") -
FILE_SEARCH("file_search")
-
-
Optional<AssistantToolChoiceFunction> function-
String nameThe name of the function to call.
-
-
-
-
List<AssistantTool> toolsThe list of tools that the assistant used for this run.
-
class CodeInterpreterTool:-
JsonValue; type "code_interpreter"constantThe type of tool being defined:
code_interpreterCODE_INTERPRETER("code_interpreter")
-
-
class FileSearchTool:-
JsonValue; type "file_search"constantThe type of tool being defined:
file_searchFILE_SEARCH("file_search")
-
Optional<FileSearch> fileSearchOverrides for the file search tool.
-
Optional<Long> maxNumResultsThe maximum number of results the file search tool should output. The default is 20 for
gpt-4*models and 5 forgpt-3.5-turbo. This number should be between 1 and 50 inclusive.Note that the file search tool may output fewer than
max_num_resultsresults. See the file search tool documentation for more information. -
Optional<RankingOptions> rankingOptionsThe ranking options for the file search. If not specified, the file search tool will use the
autoranker and a score_threshold of 0.See the file search tool documentation for more information.
-
double scoreThresholdThe score threshold for the file search. All values must be a floating point number between 0 and 1.
-
Optional<Ranker> rankerThe ranker to use for the file search. If not specified will use the
autoranker.-
AUTO("auto") -
DEFAULT_2024_08_21("default_2024_08_21")
-
-
-
-
-
class FunctionTool:-
FunctionDefinition function-
String nameThe 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> descriptionA description of what the function does, used by the model to choose when and how to call the function.
-
Optional<FunctionParameters> parametersThe 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
parametersdefines a function with an empty parameter list. -
Optional<Boolean> strictWhether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the
parametersfield. Only a subset of JSON Schema is supported whenstrictistrue. Learn more about Structured Outputs in the function calling guide.
-
-
JsonValue; type "function"constantThe type of tool being defined:
functionFUNCTION("function")
-
-
-
Optional<TruncationStrategy> truncationStrategyControls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.
-
Type typeThe truncation strategy to use for the thread. The default is
auto. If set tolast_messages, the thread will be truncated to the n most recent messages in the thread. When set toauto, messages in the middle of the thread will be dropped to fit the context length of the model,max_prompt_tokens.-
AUTO("auto") -
LAST_MESSAGES("last_messages")
-
-
Optional<Long> lastMessagesThe number of most recent messages from the thread when constructing the context for the run.
-
-
Optional<Usage> usageUsage statistics related to the run. This value will be
nullif the run is not in a terminal state (i.e.in_progress,queued, etc.).-
long completionTokensNumber of completion tokens used over the course of the run.
-
long promptTokensNumber of prompt tokens used over the course of the run.
-
long totalTokensTotal number of tokens used (prompt + completion).
-
-
Optional<Double> temperatureThe sampling temperature used for this run. If not set, defaults to 1.
-
Optional<Double> topPThe nucleus sampling value used for this run. If not set, defaults to 1.
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.threads.runs.Run;
import com.openai.models.beta.threads.runs.RunSubmitToolOutputsParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
RunSubmitToolOutputsParams params = RunSubmitToolOutputsParams.builder()
.threadId("thread_id")
.runId("run_id")
.addToolOutput(RunSubmitToolOutputsParams.ToolOutput.builder().build())
.build();
Run run = client.beta().threads().runs().submitToolOutputs(params);
}
}
Response
{
"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
}
Cancel a run
Run beta().threads().runs().cancel(RunCancelParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
post /threads/{thread_id}/runs/{run_id}/cancel
Cancels a run that is in_progress.
Parameters
-
RunCancelParams params-
String threadId -
Optional<String> runId
-
Returns
-
class Run:Represents an execution run on a thread.
-
String idThe identifier, which can be referenced in API endpoints.
-
String assistantIdThe ID of the assistant used for execution of this run.
-
Optional<Long> cancelledAtThe Unix timestamp (in seconds) for when the run was cancelled.
-
Optional<Long> completedAtThe Unix timestamp (in seconds) for when the run was completed.
-
long createdAtThe Unix timestamp (in seconds) for when the run was created.
-
Optional<Long> expiresAtThe Unix timestamp (in seconds) for when the run will expire.
-
Optional<Long> failedAtThe Unix timestamp (in seconds) for when the run failed.
-
Optional<IncompleteDetails> incompleteDetailsDetails on why the run is incomplete. Will be
nullif the run is not incomplete.-
Optional<Reason> reasonThe reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.
-
MAX_COMPLETION_TOKENS("max_completion_tokens") -
MAX_PROMPT_TOKENS("max_prompt_tokens")
-
-
-
String instructionsThe instructions that the assistant used for this run.
-
Optional<LastError> lastErrorThe last error associated with this run. Will be
nullif there are no errors.-
Code codeOne of
server_error,rate_limit_exceeded, orinvalid_prompt.-
SERVER_ERROR("server_error") -
RATE_LIMIT_EXCEEDED("rate_limit_exceeded") -
INVALID_PROMPT("invalid_prompt")
-
-
String messageA human-readable description of the error.
-
-
Optional<Long> maxCompletionTokensThe maximum number of completion tokens specified to have been used over the course of the run.
-
Optional<Long> maxPromptTokensThe maximum number of prompt tokens specified to have been used over the course of the run.
-
Optional<Metadata> metadataSet 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 modelThe model that the assistant used for this run.
-
JsonValue; object_ "thread.run"constantThe object type, which is always
thread.run.THREAD_RUN("thread.run")
-
boolean parallelToolCallsWhether to enable parallel function calling during tool use.
-
Optional<RequiredAction> requiredActionDetails on the action required to continue the run. Will be
nullif no action is required.-
SubmitToolOutputs submitToolOutputsDetails on the tool outputs needed for this run to continue.
-
List<RequiredActionFunctionToolCall> toolCallsA list of the relevant tool calls.
-
String idThe 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 functionThe function definition.
-
String argumentsThe arguments that the model expects you to pass to the function.
-
String nameThe name of the function.
-
-
JsonValue; type "function"constantThe type of tool call the output is required for. For now, this is always
function.FUNCTION("function")
-
-
-
JsonValue; type "submit_tool_outputs"constantFor now, this is always
submit_tool_outputs.SUBMIT_TOOL_OUTPUTS("submit_tool_outputs")
-
-
Optional<AssistantResponseFormatOption> responseFormatSpecifies 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 exceededmax_tokensor the conversation exceeded the max context length.-
JsonValue;AUTO("auto")
-
class ResponseFormatText:Default response format. Used to generate text responses.
-
JsonValue; type "text"constantThe type of response format being defined. Always
text.TEXT("text")
-
-
class ResponseFormatJsonObject:JSON object response format. An older method of generating JSON responses. Using
json_schemais 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"constantThe type of response format being defined. Always
json_object.JSON_OBJECT("json_object")
-
-
class ResponseFormatJsonSchema:JSON Schema response format. Used to generate structured JSON responses. Learn more about Structured Outputs.
-
JsonSchema jsonSchemaStructured Outputs configuration options, including a JSON Schema.
-
String nameThe 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> descriptionA description of what the response format is for, used by the model to determine how to respond in the format.
-
Optional<Schema> schemaThe schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas here.
-
Optional<Boolean> strictWhether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the
schemafield. Only a subset of JSON Schema is supported whenstrictistrue. To learn more, read the Structured Outputs guide.
-
-
JsonValue; type "json_schema"constantThe type of response format being defined. Always
json_schema.JSON_SCHEMA("json_schema")
-
-
-
Optional<Long> startedAtThe Unix timestamp (in seconds) for when the run was started.
-
RunStatus statusThe status of the run, which can be either
queued,in_progress,requires_action,cancelling,cancelled,failed,completed,incomplete, orexpired.-
QUEUED("queued") -
IN_PROGRESS("in_progress") -
REQUIRES_ACTION("requires_action") -
CANCELLING("cancelling") -
CANCELLED("cancelled") -
FAILED("failed") -
COMPLETED("completed") -
INCOMPLETE("incomplete") -
EXPIRED("expired")
-
-
String threadIdThe ID of the thread that was executed on as a part of this run.
-
Optional<AssistantToolChoiceOption> toolChoiceControls which (if any) tool is called by the model.
nonemeans the model will not call any tools and instead generates a message.autois the default value and means the model can pick between generating a message or calling one or more tools.requiredmeans 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.-
Auto-
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 typeThe type of the tool. If type is
function, the function name must be set-
FUNCTION("function") -
CODE_INTERPRETER("code_interpreter") -
FILE_SEARCH("file_search")
-
-
Optional<AssistantToolChoiceFunction> function-
String nameThe name of the function to call.
-
-
-
-
List<AssistantTool> toolsThe list of tools that the assistant used for this run.
-
class CodeInterpreterTool:-
JsonValue; type "code_interpreter"constantThe type of tool being defined:
code_interpreterCODE_INTERPRETER("code_interpreter")
-
-
class FileSearchTool:-
JsonValue; type "file_search"constantThe type of tool being defined:
file_searchFILE_SEARCH("file_search")
-
Optional<FileSearch> fileSearchOverrides for the file search tool.
-
Optional<Long> maxNumResultsThe maximum number of results the file search tool should output. The default is 20 for
gpt-4*models and 5 forgpt-3.5-turbo. This number should be between 1 and 50 inclusive.Note that the file search tool may output fewer than
max_num_resultsresults. See the file search tool documentation for more information. -
Optional<RankingOptions> rankingOptionsThe ranking options for the file search. If not specified, the file search tool will use the
autoranker and a score_threshold of 0.See the file search tool documentation for more information.
-
double scoreThresholdThe score threshold for the file search. All values must be a floating point number between 0 and 1.
-
Optional<Ranker> rankerThe ranker to use for the file search. If not specified will use the
autoranker.-
AUTO("auto") -
DEFAULT_2024_08_21("default_2024_08_21")
-
-
-
-
-
class FunctionTool:-
FunctionDefinition function-
String nameThe 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> descriptionA description of what the function does, used by the model to choose when and how to call the function.
-
Optional<FunctionParameters> parametersThe 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
parametersdefines a function with an empty parameter list. -
Optional<Boolean> strictWhether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the
parametersfield. Only a subset of JSON Schema is supported whenstrictistrue. Learn more about Structured Outputs in the function calling guide.
-
-
JsonValue; type "function"constantThe type of tool being defined:
functionFUNCTION("function")
-
-
-
Optional<TruncationStrategy> truncationStrategyControls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.
-
Type typeThe truncation strategy to use for the thread. The default is
auto. If set tolast_messages, the thread will be truncated to the n most recent messages in the thread. When set toauto, messages in the middle of the thread will be dropped to fit the context length of the model,max_prompt_tokens.-
AUTO("auto") -
LAST_MESSAGES("last_messages")
-
-
Optional<Long> lastMessagesThe number of most recent messages from the thread when constructing the context for the run.
-
-
Optional<Usage> usageUsage statistics related to the run. This value will be
nullif the run is not in a terminal state (i.e.in_progress,queued, etc.).-
long completionTokensNumber of completion tokens used over the course of the run.
-
long promptTokensNumber of prompt tokens used over the course of the run.
-
long totalTokensTotal number of tokens used (prompt + completion).
-
-
Optional<Double> temperatureThe sampling temperature used for this run. If not set, defaults to 1.
-
Optional<Double> topPThe nucleus sampling value used for this run. If not set, defaults to 1.
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.threads.runs.Run;
import com.openai.models.beta.threads.runs.RunCancelParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
RunCancelParams params = RunCancelParams.builder()
.threadId("thread_id")
.runId("run_id")
.build();
Run run = client.beta().threads().runs().cancel(params);
}
}
Response
{
"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
}
Domain Types
Required Action Function Tool Call
-
class RequiredActionFunctionToolCall:Tool call objects
-
String idThe 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 functionThe function definition.
-
String argumentsThe arguments that the model expects you to pass to the function.
-
String nameThe name of the function.
-
-
JsonValue; type "function"constantThe type of tool call the output is required for. For now, this is always
function.FUNCTION("function")
-
Run
-
class Run:Represents an execution run on a thread.
-
String idThe identifier, which can be referenced in API endpoints.
-
String assistantIdThe ID of the assistant used for execution of this run.
-
Optional<Long> cancelledAtThe Unix timestamp (in seconds) for when the run was cancelled.
-
Optional<Long> completedAtThe Unix timestamp (in seconds) for when the run was completed.
-
long createdAtThe Unix timestamp (in seconds) for when the run was created.
-
Optional<Long> expiresAtThe Unix timestamp (in seconds) for when the run will expire.
-
Optional<Long> failedAtThe Unix timestamp (in seconds) for when the run failed.
-
Optional<IncompleteDetails> incompleteDetailsDetails on why the run is incomplete. Will be
nullif the run is not incomplete.-
Optional<Reason> reasonThe reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.
-
MAX_COMPLETION_TOKENS("max_completion_tokens") -
MAX_PROMPT_TOKENS("max_prompt_tokens")
-
-
-
String instructionsThe instructions that the assistant used for this run.
-
Optional<LastError> lastErrorThe last error associated with this run. Will be
nullif there are no errors.-
Code codeOne of
server_error,rate_limit_exceeded, orinvalid_prompt.-
SERVER_ERROR("server_error") -
RATE_LIMIT_EXCEEDED("rate_limit_exceeded") -
INVALID_PROMPT("invalid_prompt")
-
-
String messageA human-readable description of the error.
-
-
Optional<Long> maxCompletionTokensThe maximum number of completion tokens specified to have been used over the course of the run.
-
Optional<Long> maxPromptTokensThe maximum number of prompt tokens specified to have been used over the course of the run.
-
Optional<Metadata> metadataSet 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 modelThe model that the assistant used for this run.
-
JsonValue; object_ "thread.run"constantThe object type, which is always
thread.run.THREAD_RUN("thread.run")
-
boolean parallelToolCallsWhether to enable parallel function calling during tool use.
-
Optional<RequiredAction> requiredActionDetails on the action required to continue the run. Will be
nullif no action is required.-
SubmitToolOutputs submitToolOutputsDetails on the tool outputs needed for this run to continue.
-
List<RequiredActionFunctionToolCall> toolCallsA list of the relevant tool calls.
-
String idThe 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 functionThe function definition.
-
String argumentsThe arguments that the model expects you to pass to the function.
-
String nameThe name of the function.
-
-
JsonValue; type "function"constantThe type of tool call the output is required for. For now, this is always
function.FUNCTION("function")
-
-
-
JsonValue; type "submit_tool_outputs"constantFor now, this is always
submit_tool_outputs.SUBMIT_TOOL_OUTPUTS("submit_tool_outputs")
-
-
Optional<AssistantResponseFormatOption> responseFormatSpecifies 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 exceededmax_tokensor the conversation exceeded the max context length.-
JsonValue;AUTO("auto")
-
class ResponseFormatText:Default response format. Used to generate text responses.
-
JsonValue; type "text"constantThe type of response format being defined. Always
text.TEXT("text")
-
-
class ResponseFormatJsonObject:JSON object response format. An older method of generating JSON responses. Using
json_schemais 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"constantThe type of response format being defined. Always
json_object.JSON_OBJECT("json_object")
-
-
class ResponseFormatJsonSchema:JSON Schema response format. Used to generate structured JSON responses. Learn more about Structured Outputs.
-
JsonSchema jsonSchemaStructured Outputs configuration options, including a JSON Schema.
-
String nameThe 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> descriptionA description of what the response format is for, used by the model to determine how to respond in the format.
-
Optional<Schema> schemaThe schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas here.
-
Optional<Boolean> strictWhether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the
schemafield. Only a subset of JSON Schema is supported whenstrictistrue. To learn more, read the Structured Outputs guide.
-
-
JsonValue; type "json_schema"constantThe type of response format being defined. Always
json_schema.JSON_SCHEMA("json_schema")
-
-
-
Optional<Long> startedAtThe Unix timestamp (in seconds) for when the run was started.
-
RunStatus statusThe status of the run, which can be either
queued,in_progress,requires_action,cancelling,cancelled,failed,completed,incomplete, orexpired.-
QUEUED("queued") -
IN_PROGRESS("in_progress") -
REQUIRES_ACTION("requires_action") -
CANCELLING("cancelling") -
CANCELLED("cancelled") -
FAILED("failed") -
COMPLETED("completed") -
INCOMPLETE("incomplete") -
EXPIRED("expired")
-
-
String threadIdThe ID of the thread that was executed on as a part of this run.
-
Optional<AssistantToolChoiceOption> toolChoiceControls which (if any) tool is called by the model.
nonemeans the model will not call any tools and instead generates a message.autois the default value and means the model can pick between generating a message or calling one or more tools.requiredmeans 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.-
Auto-
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 typeThe type of the tool. If type is
function, the function name must be set-
FUNCTION("function") -
CODE_INTERPRETER("code_interpreter") -
FILE_SEARCH("file_search")
-
-
Optional<AssistantToolChoiceFunction> function-
String nameThe name of the function to call.
-
-
-
-
List<AssistantTool> toolsThe list of tools that the assistant used for this run.
-
class CodeInterpreterTool:-
JsonValue; type "code_interpreter"constantThe type of tool being defined:
code_interpreterCODE_INTERPRETER("code_interpreter")
-
-
class FileSearchTool:-
JsonValue; type "file_search"constantThe type of tool being defined:
file_searchFILE_SEARCH("file_search")
-
Optional<FileSearch> fileSearchOverrides for the file search tool.
-
Optional<Long> maxNumResultsThe maximum number of results the file search tool should output. The default is 20 for
gpt-4*models and 5 forgpt-3.5-turbo. This number should be between 1 and 50 inclusive.Note that the file search tool may output fewer than
max_num_resultsresults. See the file search tool documentation for more information. -
Optional<RankingOptions> rankingOptionsThe ranking options for the file search. If not specified, the file search tool will use the
autoranker and a score_threshold of 0.See the file search tool documentation for more information.
-
double scoreThresholdThe score threshold for the file search. All values must be a floating point number between 0 and 1.
-
Optional<Ranker> rankerThe ranker to use for the file search. If not specified will use the
autoranker.-
AUTO("auto") -
DEFAULT_2024_08_21("default_2024_08_21")
-
-
-
-
-
class FunctionTool:-
FunctionDefinition function-
String nameThe 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> descriptionA description of what the function does, used by the model to choose when and how to call the function.
-
Optional<FunctionParameters> parametersThe 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
parametersdefines a function with an empty parameter list. -
Optional<Boolean> strictWhether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the
parametersfield. Only a subset of JSON Schema is supported whenstrictistrue. Learn more about Structured Outputs in the function calling guide.
-
-
JsonValue; type "function"constantThe type of tool being defined:
functionFUNCTION("function")
-
-
-
Optional<TruncationStrategy> truncationStrategyControls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.
-
Type typeThe truncation strategy to use for the thread. The default is
auto. If set tolast_messages, the thread will be truncated to the n most recent messages in the thread. When set toauto, messages in the middle of the thread will be dropped to fit the context length of the model,max_prompt_tokens.-
AUTO("auto") -
LAST_MESSAGES("last_messages")
-
-
Optional<Long> lastMessagesThe number of most recent messages from the thread when constructing the context for the run.
-
-
Optional<Usage> usageUsage statistics related to the run. This value will be
nullif the run is not in a terminal state (i.e.in_progress,queued, etc.).-
long completionTokensNumber of completion tokens used over the course of the run.
-
long promptTokensNumber of prompt tokens used over the course of the run.
-
long totalTokensTotal number of tokens used (prompt + completion).
-
-
Optional<Double> temperatureThe sampling temperature used for this run. If not set, defaults to 1.
-
Optional<Double> topPThe nucleus sampling value used for this run. If not set, defaults to 1.
-
Run Status
-
enum RunStatus:The status of the run, which can be either
queued,in_progress,requires_action,cancelling,cancelled,failed,completed,incomplete, orexpired.-
QUEUED("queued") -
IN_PROGRESS("in_progress") -
REQUIRES_ACTION("requires_action") -
CANCELLING("cancelling") -
CANCELLED("cancelled") -
FAILED("failed") -
COMPLETED("completed") -
INCOMPLETE("incomplete") -
EXPIRED("expired")
-
Steps
List run steps
StepListPage beta().threads().runs().steps().list(StepListParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
get /threads/{thread_id}/runs/{run_id}/steps
Returns a list of run steps belonging to a run.
Parameters
-
StepListParams params-
String threadId -
Optional<String> runId -
Optional<String> afterA cursor for use in pagination.
afteris an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. -
Optional<String> beforeA cursor for use in pagination.
beforeis an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. -
Optional<List<RunStepInclude>> includeA list of additional fields to include in the response. Currently the only supported value is
step_details.tool_calls[*].file_search.results[*].contentto fetch the file search result content.See the file search tool documentation for more information.
STEP_DETAILS_TOOL_CALLS_FILE_SEARCH_RESULTS_CONTENT("step_details.tool_calls[*].file_search.results[*].content")
-
Optional<Long> limitA limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
-
Optional<Order> orderSort order by the
created_attimestamp of the objects.ascfor ascending order anddescfor descending order.-
ASC("asc") -
DESC("desc")
-
-
Returns
-
class RunStep:Represents a step in execution of a run.
-
String idThe identifier of the run step, which can be referenced in API endpoints.
-
String assistantIdThe ID of the assistant associated with the run step.
-
Optional<Long> cancelledAtThe Unix timestamp (in seconds) for when the run step was cancelled.
-
Optional<Long> completedAtThe Unix timestamp (in seconds) for when the run step completed.
-
long createdAtThe Unix timestamp (in seconds) for when the run step was created.
-
Optional<Long> expiredAtThe Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired.
-
Optional<Long> failedAtThe Unix timestamp (in seconds) for when the run step failed.
-
Optional<LastError> lastErrorThe last error associated with this run step. Will be
nullif there are no errors.-
Code codeOne of
server_errororrate_limit_exceeded.-
SERVER_ERROR("server_error") -
RATE_LIMIT_EXCEEDED("rate_limit_exceeded")
-
-
String messageA human-readable description of the error.
-
-
Optional<Metadata> metadataSet 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"constantThe object type, which is always
thread.run.step.THREAD_RUN_STEP("thread.run.step")
-
String runIdThe ID of the run that this run step is a part of.
-
Status statusThe status of the run step, which can be either
in_progress,cancelled,failed,completed, orexpired.-
IN_PROGRESS("in_progress") -
CANCELLED("cancelled") -
FAILED("failed") -
COMPLETED("completed") -
EXPIRED("expired")
-
-
StepDetails stepDetailsThe details of the run step.
-
class MessageCreationStepDetails:Details of the message creation by the run step.
-
MessageCreation messageCreation-
String messageIdThe ID of the message that was created by this run step.
-
-
JsonValue; type "message_creation"constantAlways
message_creation.MESSAGE_CREATION("message_creation")
-
-
class ToolCallsStepDetails:Details of the tool call.
-
List<ToolCall> toolCallsAn 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, orfunction.-
class CodeInterpreterToolCall:Details of the Code Interpreter tool call the run step was involved in.
-
String idThe ID of the tool call.
-
CodeInterpreter codeInterpreterThe Code Interpreter tool call definition.
-
String inputThe input to the Code Interpreter tool call.
-
List<Output> outputsThe 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.-
class LogsOutput:Text output from the Code Interpreter tool call as part of a run step.
-
String logsThe text output from the Code Interpreter tool call.
-
JsonValue; type "logs"constantAlways
logs.LOGS("logs")
-
-
class ImageOutput:-
Image image-
String fileIdThe file ID of the image.
-
-
JsonValue; type "image"constantAlways
image.IMAGE("image")
-
-
-
-
JsonValue; type "code_interpreter"constantThe type of tool call. This is always going to be
code_interpreterfor this type of tool call.CODE_INTERPRETER("code_interpreter")
-
-
class FileSearchToolCall:-
String idThe ID of the tool call object.
-
FileSearch fileSearchFor now, this is always going to be an empty object.
-
Optional<RankingOptions> rankingOptionsThe ranking options for the file search.
-
Ranker rankerThe ranker to use for the file search. If not specified will use the
autoranker.-
AUTO("auto") -
DEFAULT_2024_08_21("default_2024_08_21")
-
-
double scoreThresholdThe score threshold for the file search. All values must be a floating point number between 0 and 1.
-
-
Optional<List<Result>> resultsThe results of the file search.
-
String fileIdThe ID of the file that result was found in.
-
String fileNameThe name of the file that result was found in.
-
double scoreThe score of the result. All values must be a floating point number between 0 and 1.
-
Optional<List<Content>> contentThe content of the result that was found. The content is only included if requested via the include query parameter.
-
Optional<String> textThe text content of the file.
-
Optional<Type> typeThe type of the content.
TEXT("text")
-
-
-
-
JsonValue; type "file_search"constantThe type of tool call. This is always going to be
file_searchfor this type of tool call.FILE_SEARCH("file_search")
-
-
class FunctionToolCall:-
String idThe ID of the tool call object.
-
Function functionThe definition of the function that was called.
-
String argumentsThe arguments passed to the function.
-
String nameThe name of the function.
-
Optional<String> outputThe output of the function. This will be
nullif the outputs have not been submitted yet.
-
-
JsonValue; type "function"constantThe type of tool call. This is always going to be
functionfor this type of tool call.FUNCTION("function")
-
-
-
JsonValue; type "tool_calls"constantAlways
tool_calls.TOOL_CALLS("tool_calls")
-
-
-
String threadIdThe ID of the thread that was run.
-
Type typeThe type of run step, which can be either
message_creationortool_calls.-
MESSAGE_CREATION("message_creation") -
TOOL_CALLS("tool_calls")
-
-
Optional<Usage> usageUsage statistics related to the run step. This value will be
nullwhile the run step's status isin_progress.-
long completionTokensNumber of completion tokens used over the course of the run step.
-
long promptTokensNumber of prompt tokens used over the course of the run step.
-
long totalTokensTotal number of tokens used (prompt + completion).
-
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.threads.runs.steps.StepListPage;
import com.openai.models.beta.threads.runs.steps.StepListParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
StepListParams params = StepListParams.builder()
.threadId("thread_id")
.runId("run_id")
.build();
StepListPage page = client.beta().threads().runs().steps().list(params);
}
}
Response
{
"data": [
{
"id": "id",
"assistant_id": "assistant_id",
"cancelled_at": 0,
"completed_at": 0,
"created_at": 0,
"expired_at": 0,
"failed_at": 0,
"last_error": {
"code": "server_error",
"message": "message"
},
"metadata": {
"foo": "string"
},
"object": "thread.run.step",
"run_id": "run_id",
"status": "in_progress",
"step_details": {
"message_creation": {
"message_id": "message_id"
},
"type": "message_creation"
},
"thread_id": "thread_id",
"type": "message_creation",
"usage": {
"completion_tokens": 0,
"prompt_tokens": 0,
"total_tokens": 0
}
}
],
"first_id": "step_abc123",
"has_more": false,
"last_id": "step_abc456",
"object": "list"
}
Retrieve run step
RunStep beta().threads().runs().steps().retrieve(StepRetrieveParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
get /threads/{thread_id}/runs/{run_id}/steps/{step_id}
Retrieves a run step.
Parameters
-
StepRetrieveParams params-
String threadId -
String runId -
Optional<String> stepId -
Optional<List<RunStepInclude>> includeA list of additional fields to include in the response. Currently the only supported value is
step_details.tool_calls[*].file_search.results[*].contentto fetch the file search result content.See the file search tool documentation for more information.
STEP_DETAILS_TOOL_CALLS_FILE_SEARCH_RESULTS_CONTENT("step_details.tool_calls[*].file_search.results[*].content")
-
Returns
-
class RunStep:Represents a step in execution of a run.
-
String idThe identifier of the run step, which can be referenced in API endpoints.
-
String assistantIdThe ID of the assistant associated with the run step.
-
Optional<Long> cancelledAtThe Unix timestamp (in seconds) for when the run step was cancelled.
-
Optional<Long> completedAtThe Unix timestamp (in seconds) for when the run step completed.
-
long createdAtThe Unix timestamp (in seconds) for when the run step was created.
-
Optional<Long> expiredAtThe Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired.
-
Optional<Long> failedAtThe Unix timestamp (in seconds) for when the run step failed.
-
Optional<LastError> lastErrorThe last error associated with this run step. Will be
nullif there are no errors.-
Code codeOne of
server_errororrate_limit_exceeded.-
SERVER_ERROR("server_error") -
RATE_LIMIT_EXCEEDED("rate_limit_exceeded")
-
-
String messageA human-readable description of the error.
-
-
Optional<Metadata> metadataSet 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"constantThe object type, which is always
thread.run.step.THREAD_RUN_STEP("thread.run.step")
-
String runIdThe ID of the run that this run step is a part of.
-
Status statusThe status of the run step, which can be either
in_progress,cancelled,failed,completed, orexpired.-
IN_PROGRESS("in_progress") -
CANCELLED("cancelled") -
FAILED("failed") -
COMPLETED("completed") -
EXPIRED("expired")
-
-
StepDetails stepDetailsThe details of the run step.
-
class MessageCreationStepDetails:Details of the message creation by the run step.
-
MessageCreation messageCreation-
String messageIdThe ID of the message that was created by this run step.
-
-
JsonValue; type "message_creation"constantAlways
message_creation.MESSAGE_CREATION("message_creation")
-
-
class ToolCallsStepDetails:Details of the tool call.
-
List<ToolCall> toolCallsAn 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, orfunction.-
class CodeInterpreterToolCall:Details of the Code Interpreter tool call the run step was involved in.
-
String idThe ID of the tool call.
-
CodeInterpreter codeInterpreterThe Code Interpreter tool call definition.
-
String inputThe input to the Code Interpreter tool call.
-
List<Output> outputsThe 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.-
class LogsOutput:Text output from the Code Interpreter tool call as part of a run step.
-
String logsThe text output from the Code Interpreter tool call.
-
JsonValue; type "logs"constantAlways
logs.LOGS("logs")
-
-
class ImageOutput:-
Image image-
String fileIdThe file ID of the image.
-
-
JsonValue; type "image"constantAlways
image.IMAGE("image")
-
-
-
-
JsonValue; type "code_interpreter"constantThe type of tool call. This is always going to be
code_interpreterfor this type of tool call.CODE_INTERPRETER("code_interpreter")
-
-
class FileSearchToolCall:-
String idThe ID of the tool call object.
-
FileSearch fileSearchFor now, this is always going to be an empty object.
-
Optional<RankingOptions> rankingOptionsThe ranking options for the file search.
-
Ranker rankerThe ranker to use for the file search. If not specified will use the
autoranker.-
AUTO("auto") -
DEFAULT_2024_08_21("default_2024_08_21")
-
-
double scoreThresholdThe score threshold for the file search. All values must be a floating point number between 0 and 1.
-
-
Optional<List<Result>> resultsThe results of the file search.
-
String fileIdThe ID of the file that result was found in.
-
String fileNameThe name of the file that result was found in.
-
double scoreThe score of the result. All values must be a floating point number between 0 and 1.
-
Optional<List<Content>> contentThe content of the result that was found. The content is only included if requested via the include query parameter.
-
Optional<String> textThe text content of the file.
-
Optional<Type> typeThe type of the content.
TEXT("text")
-
-
-
-
JsonValue; type "file_search"constantThe type of tool call. This is always going to be
file_searchfor this type of tool call.FILE_SEARCH("file_search")
-
-
class FunctionToolCall:-
String idThe ID of the tool call object.
-
Function functionThe definition of the function that was called.
-
String argumentsThe arguments passed to the function.
-
String nameThe name of the function.
-
Optional<String> outputThe output of the function. This will be
nullif the outputs have not been submitted yet.
-
-
JsonValue; type "function"constantThe type of tool call. This is always going to be
functionfor this type of tool call.FUNCTION("function")
-
-
-
JsonValue; type "tool_calls"constantAlways
tool_calls.TOOL_CALLS("tool_calls")
-
-
-
String threadIdThe ID of the thread that was run.
-
Type typeThe type of run step, which can be either
message_creationortool_calls.-
MESSAGE_CREATION("message_creation") -
TOOL_CALLS("tool_calls")
-
-
Optional<Usage> usageUsage statistics related to the run step. This value will be
nullwhile the run step's status isin_progress.-
long completionTokensNumber of completion tokens used over the course of the run step.
-
long promptTokensNumber of prompt tokens used over the course of the run step.
-
long totalTokensTotal number of tokens used (prompt + completion).
-
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.threads.runs.steps.RunStep;
import com.openai.models.beta.threads.runs.steps.StepRetrieveParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
StepRetrieveParams params = StepRetrieveParams.builder()
.threadId("thread_id")
.runId("run_id")
.stepId("step_id")
.build();
RunStep runStep = client.beta().threads().runs().steps().retrieve(params);
}
}
Response
{
"id": "id",
"assistant_id": "assistant_id",
"cancelled_at": 0,
"completed_at": 0,
"created_at": 0,
"expired_at": 0,
"failed_at": 0,
"last_error": {
"code": "server_error",
"message": "message"
},
"metadata": {
"foo": "string"
},
"object": "thread.run.step",
"run_id": "run_id",
"status": "in_progress",
"step_details": {
"message_creation": {
"message_id": "message_id"
},
"type": "message_creation"
},
"thread_id": "thread_id",
"type": "message_creation",
"usage": {
"completion_tokens": 0,
"prompt_tokens": 0,
"total_tokens": 0
}
}
Domain Types
Code Interpreter Logs
-
class CodeInterpreterLogs:Text output from the Code Interpreter tool call as part of a run step.
-
long indexThe index of the output in the outputs array.
-
JsonValue; type "logs"constantAlways
logs.LOGS("logs")
-
Optional<String> logsThe text output from the Code Interpreter tool call.
-
Code Interpreter Output Image
-
class CodeInterpreterOutputImage:-
long indexThe index of the output in the outputs array.
-
JsonValue; type "image"constantAlways
image.IMAGE("image")
-
Optional<Image> image-
Optional<String> fileIdThe file ID of the image.
-
-
Code Interpreter Tool Call
-
class CodeInterpreterToolCall:Details of the Code Interpreter tool call the run step was involved in.
-
String idThe ID of the tool call.
-
CodeInterpreter codeInterpreterThe Code Interpreter tool call definition.
-
String inputThe input to the Code Interpreter tool call.
-
List<Output> outputsThe 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.-
class LogsOutput:Text output from the Code Interpreter tool call as part of a run step.
-
String logsThe text output from the Code Interpreter tool call.
-
JsonValue; type "logs"constantAlways
logs.LOGS("logs")
-
-
class ImageOutput:-
Image image-
String fileIdThe file ID of the image.
-
-
JsonValue; type "image"constantAlways
image.IMAGE("image")
-
-
-
-
JsonValue; type "code_interpreter"constantThe type of tool call. This is always going to be
code_interpreterfor this type of tool call.CODE_INTERPRETER("code_interpreter")
-
Code Interpreter Tool Call Delta
-
class CodeInterpreterToolCallDelta:Details of the Code Interpreter tool call the run step was involved in.
-
long indexThe index of the tool call in the tool calls array.
-
JsonValue; type "code_interpreter"constantThe type of tool call. This is always going to be
code_interpreterfor this type of tool call.CODE_INTERPRETER("code_interpreter")
-
Optional<String> idThe ID of the tool call.
-
Optional<CodeInterpreter> codeInterpreterThe Code Interpreter tool call definition.
-
Optional<String> inputThe input to the Code Interpreter tool call.
-
Optional<List<Output>> outputsThe 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.-
class CodeInterpreterLogs:Text output from the Code Interpreter tool call as part of a run step.
-
long indexThe index of the output in the outputs array.
-
JsonValue; type "logs"constantAlways
logs.LOGS("logs")
-
Optional<String> logsThe text output from the Code Interpreter tool call.
-
-
class CodeInterpreterOutputImage:-
long indexThe index of the output in the outputs array.
-
JsonValue; type "image"constantAlways
image.IMAGE("image")
-
Optional<Image> image-
Optional<String> fileIdThe file ID of the image.
-
-
-
-
-
File Search Tool Call
-
class FileSearchToolCall:-
String idThe ID of the tool call object.
-
FileSearch fileSearchFor now, this is always going to be an empty object.
-
Optional<RankingOptions> rankingOptionsThe ranking options for the file search.
-
Ranker rankerThe ranker to use for the file search. If not specified will use the
autoranker.-
AUTO("auto") -
DEFAULT_2024_08_21("default_2024_08_21")
-
-
double scoreThresholdThe score threshold for the file search. All values must be a floating point number between 0 and 1.
-
-
Optional<List<Result>> resultsThe results of the file search.
-
String fileIdThe ID of the file that result was found in.
-
String fileNameThe name of the file that result was found in.
-
double scoreThe score of the result. All values must be a floating point number between 0 and 1.
-
Optional<List<Content>> contentThe content of the result that was found. The content is only included if requested via the include query parameter.
-
Optional<String> textThe text content of the file.
-
Optional<Type> typeThe type of the content.
TEXT("text")
-
-
-
-
JsonValue; type "file_search"constantThe type of tool call. This is always going to be
file_searchfor this type of tool call.FILE_SEARCH("file_search")
-
File Search Tool Call Delta
-
class FileSearchToolCallDelta:-
JsonValue fileSearchFor now, this is always going to be an empty object.
-
long indexThe index of the tool call in the tool calls array.
-
JsonValue; type "file_search"constantThe type of tool call. This is always going to be
file_searchfor this type of tool call.FILE_SEARCH("file_search")
-
Optional<String> idThe ID of the tool call object.
-
Function Tool Call
-
class FunctionToolCall:-
String idThe ID of the tool call object.
-
Function functionThe definition of the function that was called.
-
String argumentsThe arguments passed to the function.
-
String nameThe name of the function.
-
Optional<String> outputThe output of the function. This will be
nullif the outputs have not been submitted yet.
-
-
JsonValue; type "function"constantThe type of tool call. This is always going to be
functionfor this type of tool call.FUNCTION("function")
-
Function Tool Call Delta
-
class FunctionToolCallDelta:-
long indexThe index of the tool call in the tool calls array.
-
JsonValue; type "function"constantThe type of tool call. This is always going to be
functionfor this type of tool call.FUNCTION("function")
-
Optional<String> idThe ID of the tool call object.
-
Optional<Function> functionThe definition of the function that was called.
-
Optional<String> argumentsThe arguments passed to the function.
-
Optional<String> nameThe name of the function.
-
Optional<String> outputThe output of the function. This will be
nullif the outputs have not been submitted yet.
-
-
Message Creation Step Details
-
class MessageCreationStepDetails:Details of the message creation by the run step.
-
MessageCreation messageCreation-
String messageIdThe ID of the message that was created by this run step.
-
-
JsonValue; type "message_creation"constantAlways
message_creation.MESSAGE_CREATION("message_creation")
-
Run Step
-
class RunStep:Represents a step in execution of a run.
-
String idThe identifier of the run step, which can be referenced in API endpoints.
-
String assistantIdThe ID of the assistant associated with the run step.
-
Optional<Long> cancelledAtThe Unix timestamp (in seconds) for when the run step was cancelled.
-
Optional<Long> completedAtThe Unix timestamp (in seconds) for when the run step completed.
-
long createdAtThe Unix timestamp (in seconds) for when the run step was created.
-
Optional<Long> expiredAtThe Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired.
-
Optional<Long> failedAtThe Unix timestamp (in seconds) for when the run step failed.
-
Optional<LastError> lastErrorThe last error associated with this run step. Will be
nullif there are no errors.-
Code codeOne of
server_errororrate_limit_exceeded.-
SERVER_ERROR("server_error") -
RATE_LIMIT_EXCEEDED("rate_limit_exceeded")
-
-
String messageA human-readable description of the error.
-
-
Optional<Metadata> metadataSet 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"constantThe object type, which is always
thread.run.step.THREAD_RUN_STEP("thread.run.step")
-
String runIdThe ID of the run that this run step is a part of.
-
Status statusThe status of the run step, which can be either
in_progress,cancelled,failed,completed, orexpired.-
IN_PROGRESS("in_progress") -
CANCELLED("cancelled") -
FAILED("failed") -
COMPLETED("completed") -
EXPIRED("expired")
-
-
StepDetails stepDetailsThe details of the run step.
-
class MessageCreationStepDetails:Details of the message creation by the run step.
-
MessageCreation messageCreation-
String messageIdThe ID of the message that was created by this run step.
-
-
JsonValue; type "message_creation"constantAlways
message_creation.MESSAGE_CREATION("message_creation")
-
-
class ToolCallsStepDetails:Details of the tool call.
-
List<ToolCall> toolCallsAn 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, orfunction.-
class CodeInterpreterToolCall:Details of the Code Interpreter tool call the run step was involved in.
-
String idThe ID of the tool call.
-
CodeInterpreter codeInterpreterThe Code Interpreter tool call definition.
-
String inputThe input to the Code Interpreter tool call.
-
List<Output> outputsThe 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.-
class LogsOutput:Text output from the Code Interpreter tool call as part of a run step.
-
String logsThe text output from the Code Interpreter tool call.
-
JsonValue; type "logs"constantAlways
logs.LOGS("logs")
-
-
class ImageOutput:-
Image image-
String fileIdThe file ID of the image.
-
-
JsonValue; type "image"constantAlways
image.IMAGE("image")
-
-
-
-
JsonValue; type "code_interpreter"constantThe type of tool call. This is always going to be
code_interpreterfor this type of tool call.CODE_INTERPRETER("code_interpreter")
-
-
class FileSearchToolCall:-
String idThe ID of the tool call object.
-
FileSearch fileSearchFor now, this is always going to be an empty object.
-
Optional<RankingOptions> rankingOptionsThe ranking options for the file search.
-
Ranker rankerThe ranker to use for the file search. If not specified will use the
autoranker.-
AUTO("auto") -
DEFAULT_2024_08_21("default_2024_08_21")
-
-
double scoreThresholdThe score threshold for the file search. All values must be a floating point number between 0 and 1.
-
-
Optional<List<Result>> resultsThe results of the file search.
-
String fileIdThe ID of the file that result was found in.
-
String fileNameThe name of the file that result was found in.
-
double scoreThe score of the result. All values must be a floating point number between 0 and 1.
-
Optional<List<Content>> contentThe content of the result that was found. The content is only included if requested via the include query parameter.
-
Optional<String> textThe text content of the file.
-
Optional<Type> typeThe type of the content.
TEXT("text")
-
-
-
-
JsonValue; type "file_search"constantThe type of tool call. This is always going to be
file_searchfor this type of tool call.FILE_SEARCH("file_search")
-
-
class FunctionToolCall:-
String idThe ID of the tool call object.
-
Function functionThe definition of the function that was called.
-
String argumentsThe arguments passed to the function.
-
String nameThe name of the function.
-
Optional<String> outputThe output of the function. This will be
nullif the outputs have not been submitted yet.
-
-
JsonValue; type "function"constantThe type of tool call. This is always going to be
functionfor this type of tool call.FUNCTION("function")
-
-
-
JsonValue; type "tool_calls"constantAlways
tool_calls.TOOL_CALLS("tool_calls")
-
-
-
String threadIdThe ID of the thread that was run.
-
Type typeThe type of run step, which can be either
message_creationortool_calls.-
MESSAGE_CREATION("message_creation") -
TOOL_CALLS("tool_calls")
-
-
Optional<Usage> usageUsage statistics related to the run step. This value will be
nullwhile the run step's status isin_progress.-
long completionTokensNumber of completion tokens used over the course of the run step.
-
long promptTokensNumber of prompt tokens used over the course of the run step.
-
long totalTokensTotal number of tokens used (prompt + completion).
-
-
Run Step Delta
-
class RunStepDelta:The delta containing the fields that have changed on the run step.
-
Optional<StepDetails> stepDetailsThe details of the run step.
-
class RunStepDeltaMessageDelta:Details of the message creation by the run step.
-
JsonValue; type "message_creation"constantAlways
message_creation.MESSAGE_CREATION("message_creation")
-
Optional<MessageCreation> messageCreation-
Optional<String> messageIdThe ID of the message that was created by this run step.
-
-
-
class ToolCallDeltaObject:Details of the tool call.
-
JsonValue; type "tool_calls"constantAlways
tool_calls.TOOL_CALLS("tool_calls")
-
Optional<List<ToolCallDelta>> toolCallsAn 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, orfunction.-
class CodeInterpreterToolCallDelta:Details of the Code Interpreter tool call the run step was involved in.
-
long indexThe index of the tool call in the tool calls array.
-
JsonValue; type "code_interpreter"constantThe type of tool call. This is always going to be
code_interpreterfor this type of tool call.CODE_INTERPRETER("code_interpreter")
-
Optional<String> idThe ID of the tool call.
-
Optional<CodeInterpreter> codeInterpreterThe Code Interpreter tool call definition.
-
Optional<String> inputThe input to the Code Interpreter tool call.
-
Optional<List<Output>> outputsThe 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.-
class CodeInterpreterLogs:Text output from the Code Interpreter tool call as part of a run step.
-
long indexThe index of the output in the outputs array.
-
JsonValue; type "logs"constantAlways
logs.LOGS("logs")
-
Optional<String> logsThe text output from the Code Interpreter tool call.
-
-
class CodeInterpreterOutputImage:-
long indexThe index of the output in the outputs array.
-
JsonValue; type "image"constantAlways
image.IMAGE("image")
-
Optional<Image> image-
Optional<String> fileIdThe file ID of the image.
-
-
-
-
-
-
class FileSearchToolCallDelta:-
JsonValue fileSearchFor now, this is always going to be an empty object.
-
long indexThe index of the tool call in the tool calls array.
-
JsonValue; type "file_search"constantThe type of tool call. This is always going to be
file_searchfor this type of tool call.FILE_SEARCH("file_search")
-
Optional<String> idThe ID of the tool call object.
-
-
class FunctionToolCallDelta:-
long indexThe index of the tool call in the tool calls array.
-
JsonValue; type "function"constantThe type of tool call. This is always going to be
functionfor this type of tool call.FUNCTION("function")
-
Optional<String> idThe ID of the tool call object.
-
Optional<Function> functionThe definition of the function that was called.
-
Optional<String> argumentsThe arguments passed to the function.
-
Optional<String> nameThe name of the function.
-
Optional<String> outputThe output of the function. This will be
nullif the outputs have not been submitted yet.
-
-
-
-
-
-
Run Step Delta Event
-
class RunStepDeltaEvent:Represents a run step delta i.e. any changed fields on a run step during streaming.
-
String idThe identifier of the run step, which can be referenced in API endpoints.
-
RunStepDelta deltaThe delta containing the fields that have changed on the run step.
-
Optional<StepDetails> stepDetailsThe details of the run step.
-
class RunStepDeltaMessageDelta:Details of the message creation by the run step.
-
JsonValue; type "message_creation"constantAlways
message_creation.MESSAGE_CREATION("message_creation")
-
Optional<MessageCreation> messageCreation-
Optional<String> messageIdThe ID of the message that was created by this run step.
-
-
-
class ToolCallDeltaObject:Details of the tool call.
-
JsonValue; type "tool_calls"constantAlways
tool_calls.TOOL_CALLS("tool_calls")
-
Optional<List<ToolCallDelta>> toolCallsAn 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, orfunction.-
class CodeInterpreterToolCallDelta:Details of the Code Interpreter tool call the run step was involved in.
-
long indexThe index of the tool call in the tool calls array.
-
JsonValue; type "code_interpreter"constantThe type of tool call. This is always going to be
code_interpreterfor this type of tool call.CODE_INTERPRETER("code_interpreter")
-
Optional<String> idThe ID of the tool call.
-
Optional<CodeInterpreter> codeInterpreterThe Code Interpreter tool call definition.
-
Optional<String> inputThe input to the Code Interpreter tool call.
-
Optional<List<Output>> outputsThe 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.-
class CodeInterpreterLogs:Text output from the Code Interpreter tool call as part of a run step.
-
long indexThe index of the output in the outputs array.
-
JsonValue; type "logs"constantAlways
logs.LOGS("logs")
-
Optional<String> logsThe text output from the Code Interpreter tool call.
-
-
class CodeInterpreterOutputImage:-
long indexThe index of the output in the outputs array.
-
JsonValue; type "image"constantAlways
image.IMAGE("image")
-
Optional<Image> image-
Optional<String> fileIdThe file ID of the image.
-
-
-
-
-
-
class FileSearchToolCallDelta:-
JsonValue fileSearchFor now, this is always going to be an empty object.
-
long indexThe index of the tool call in the tool calls array.
-
JsonValue; type "file_search"constantThe type of tool call. This is always going to be
file_searchfor this type of tool call.FILE_SEARCH("file_search")
-
Optional<String> idThe ID of the tool call object.
-
-
class FunctionToolCallDelta:-
long indexThe index of the tool call in the tool calls array.
-
JsonValue; type "function"constantThe type of tool call. This is always going to be
functionfor this type of tool call.FUNCTION("function")
-
Optional<String> idThe ID of the tool call object.
-
Optional<Function> functionThe definition of the function that was called.
-
Optional<String> argumentsThe arguments passed to the function.
-
Optional<String> nameThe name of the function.
-
Optional<String> outputThe output of the function. This will be
nullif the outputs have not been submitted yet.
-
-
-
-
-
-
-
JsonValue; object_ "thread.run.step.delta"constantThe object type, which is always
thread.run.step.delta.THREAD_RUN_STEP_DELTA("thread.run.step.delta")
-
Run Step Delta Message Delta
-
class RunStepDeltaMessageDelta:Details of the message creation by the run step.
-
JsonValue; type "message_creation"constantAlways
message_creation.MESSAGE_CREATION("message_creation")
-
Optional<MessageCreation> messageCreation-
Optional<String> messageIdThe ID of the message that was created by this run step.
-
-
Run Step Include
-
enum RunStepInclude:STEP_DETAILS_TOOL_CALLS_FILE_SEARCH_RESULTS_CONTENT("step_details.tool_calls[*].file_search.results[*].content")
Tool Call
-
class ToolCall: A class that can be one of several variants.unionDetails of the Code Interpreter tool call the run step was involved in.
-
class CodeInterpreterToolCall:Details of the Code Interpreter tool call the run step was involved in.
-
String idThe ID of the tool call.
-
CodeInterpreter codeInterpreterThe Code Interpreter tool call definition.
-
String inputThe input to the Code Interpreter tool call.
-
List<Output> outputsThe 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.-
class LogsOutput:Text output from the Code Interpreter tool call as part of a run step.
-
String logsThe text output from the Code Interpreter tool call.
-
JsonValue; type "logs"constantAlways
logs.LOGS("logs")
-
-
class ImageOutput:-
Image image-
String fileIdThe file ID of the image.
-
-
JsonValue; type "image"constantAlways
image.IMAGE("image")
-
-
-
-
JsonValue; type "code_interpreter"constantThe type of tool call. This is always going to be
code_interpreterfor this type of tool call.CODE_INTERPRETER("code_interpreter")
-
-
class FileSearchToolCall:-
String idThe ID of the tool call object.
-
FileSearch fileSearchFor now, this is always going to be an empty object.
-
Optional<RankingOptions> rankingOptionsThe ranking options for the file search.
-
Ranker rankerThe ranker to use for the file search. If not specified will use the
autoranker.-
AUTO("auto") -
DEFAULT_2024_08_21("default_2024_08_21")
-
-
double scoreThresholdThe score threshold for the file search. All values must be a floating point number between 0 and 1.
-
-
Optional<List<Result>> resultsThe results of the file search.
-
String fileIdThe ID of the file that result was found in.
-
String fileNameThe name of the file that result was found in.
-
double scoreThe score of the result. All values must be a floating point number between 0 and 1.
-
Optional<List<Content>> contentThe content of the result that was found. The content is only included if requested via the include query parameter.
-
Optional<String> textThe text content of the file.
-
Optional<Type> typeThe type of the content.
TEXT("text")
-
-
-
-
JsonValue; type "file_search"constantThe type of tool call. This is always going to be
file_searchfor this type of tool call.FILE_SEARCH("file_search")
-
-
class FunctionToolCall:-
String idThe ID of the tool call object.
-
Function functionThe definition of the function that was called.
-
String argumentsThe arguments passed to the function.
-
String nameThe name of the function.
-
Optional<String> outputThe output of the function. This will be
nullif the outputs have not been submitted yet.
-
-
JsonValue; type "function"constantThe type of tool call. This is always going to be
functionfor this type of tool call.FUNCTION("function")
-
-
Tool Call Delta
-
class ToolCallDelta: A class that can be one of several variants.unionDetails of the Code Interpreter tool call the run step was involved in.
-
class CodeInterpreterToolCallDelta:Details of the Code Interpreter tool call the run step was involved in.
-
long indexThe index of the tool call in the tool calls array.
-
JsonValue; type "code_interpreter"constantThe type of tool call. This is always going to be
code_interpreterfor this type of tool call.CODE_INTERPRETER("code_interpreter")
-
Optional<String> idThe ID of the tool call.
-
Optional<CodeInterpreter> codeInterpreterThe Code Interpreter tool call definition.
-
Optional<String> inputThe input to the Code Interpreter tool call.
-
Optional<List<Output>> outputsThe 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.-
class CodeInterpreterLogs:Text output from the Code Interpreter tool call as part of a run step.
-
long indexThe index of the output in the outputs array.
-
JsonValue; type "logs"constantAlways
logs.LOGS("logs")
-
Optional<String> logsThe text output from the Code Interpreter tool call.
-
-
class CodeInterpreterOutputImage:-
long indexThe index of the output in the outputs array.
-
JsonValue; type "image"constantAlways
image.IMAGE("image")
-
Optional<Image> image-
Optional<String> fileIdThe file ID of the image.
-
-
-
-
-
-
class FileSearchToolCallDelta:-
JsonValue fileSearchFor now, this is always going to be an empty object.
-
long indexThe index of the tool call in the tool calls array.
-
JsonValue; type "file_search"constantThe type of tool call. This is always going to be
file_searchfor this type of tool call.FILE_SEARCH("file_search")
-
Optional<String> idThe ID of the tool call object.
-
-
class FunctionToolCallDelta:-
long indexThe index of the tool call in the tool calls array.
-
JsonValue; type "function"constantThe type of tool call. This is always going to be
functionfor this type of tool call.FUNCTION("function")
-
Optional<String> idThe ID of the tool call object.
-
Optional<Function> functionThe definition of the function that was called.
-
Optional<String> argumentsThe arguments passed to the function.
-
Optional<String> nameThe name of the function.
-
Optional<String> outputThe output of the function. This will be
nullif the outputs have not been submitted yet.
-
-
-
Tool Call Delta Object
-
class ToolCallDeltaObject:Details of the tool call.
-
JsonValue; type "tool_calls"constantAlways
tool_calls.TOOL_CALLS("tool_calls")
-
Optional<List<ToolCallDelta>> toolCallsAn 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, orfunction.-
class CodeInterpreterToolCallDelta:Details of the Code Interpreter tool call the run step was involved in.
-
long indexThe index of the tool call in the tool calls array.
-
JsonValue; type "code_interpreter"constantThe type of tool call. This is always going to be
code_interpreterfor this type of tool call.CODE_INTERPRETER("code_interpreter")
-
Optional<String> idThe ID of the tool call.
-
Optional<CodeInterpreter> codeInterpreterThe Code Interpreter tool call definition.
-
Optional<String> inputThe input to the Code Interpreter tool call.
-
Optional<List<Output>> outputsThe 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.-
class CodeInterpreterLogs:Text output from the Code Interpreter tool call as part of a run step.
-
long indexThe index of the output in the outputs array.
-
JsonValue; type "logs"constantAlways
logs.LOGS("logs")
-
Optional<String> logsThe text output from the Code Interpreter tool call.
-
-
class CodeInterpreterOutputImage:-
long indexThe index of the output in the outputs array.
-
JsonValue; type "image"constantAlways
image.IMAGE("image")
-
Optional<Image> image-
Optional<String> fileIdThe file ID of the image.
-
-
-
-
-
-
class FileSearchToolCallDelta:-
JsonValue fileSearchFor now, this is always going to be an empty object.
-
long indexThe index of the tool call in the tool calls array.
-
JsonValue; type "file_search"constantThe type of tool call. This is always going to be
file_searchfor this type of tool call.FILE_SEARCH("file_search")
-
Optional<String> idThe ID of the tool call object.
-
-
class FunctionToolCallDelta:-
long indexThe index of the tool call in the tool calls array.
-
JsonValue; type "function"constantThe type of tool call. This is always going to be
functionfor this type of tool call.FUNCTION("function")
-
Optional<String> idThe ID of the tool call object.
-
Optional<Function> functionThe definition of the function that was called.
-
Optional<String> argumentsThe arguments passed to the function.
-
Optional<String> nameThe name of the function.
-
Optional<String> outputThe output of the function. This will be
nullif the outputs have not been submitted yet.
-
-
-
-
Tool Calls Step Details
-
class ToolCallsStepDetails:Details of the tool call.
-
List<ToolCall> toolCallsAn 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, orfunction.-
class CodeInterpreterToolCall:Details of the Code Interpreter tool call the run step was involved in.
-
String idThe ID of the tool call.
-
CodeInterpreter codeInterpreterThe Code Interpreter tool call definition.
-
String inputThe input to the Code Interpreter tool call.
-
List<Output> outputsThe 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.-
class LogsOutput:Text output from the Code Interpreter tool call as part of a run step.
-
String logsThe text output from the Code Interpreter tool call.
-
JsonValue; type "logs"constantAlways
logs.LOGS("logs")
-
-
class ImageOutput:-
Image image-
String fileIdThe file ID of the image.
-
-
JsonValue; type "image"constantAlways
image.IMAGE("image")
-
-
-
-
JsonValue; type "code_interpreter"constantThe type of tool call. This is always going to be
code_interpreterfor this type of tool call.CODE_INTERPRETER("code_interpreter")
-
-
class FileSearchToolCall:-
String idThe ID of the tool call object.
-
FileSearch fileSearchFor now, this is always going to be an empty object.
-
Optional<RankingOptions> rankingOptionsThe ranking options for the file search.
-
Ranker rankerThe ranker to use for the file search. If not specified will use the
autoranker.-
AUTO("auto") -
DEFAULT_2024_08_21("default_2024_08_21")
-
-
double scoreThresholdThe score threshold for the file search. All values must be a floating point number between 0 and 1.
-
-
Optional<List<Result>> resultsThe results of the file search.
-
String fileIdThe ID of the file that result was found in.
-
String fileNameThe name of the file that result was found in.
-
double scoreThe score of the result. All values must be a floating point number between 0 and 1.
-
Optional<List<Content>> contentThe content of the result that was found. The content is only included if requested via the include query parameter.
-
Optional<String> textThe text content of the file.
-
Optional<Type> typeThe type of the content.
TEXT("text")
-
-
-
-
JsonValue; type "file_search"constantThe type of tool call. This is always going to be
file_searchfor this type of tool call.FILE_SEARCH("file_search")
-
-
class FunctionToolCall:-
String idThe ID of the tool call object.
-
Function functionThe definition of the function that was called.
-
String argumentsThe arguments passed to the function.
-
String nameThe name of the function.
-
Optional<String> outputThe output of the function. This will be
nullif the outputs have not been submitted yet.
-
-
JsonValue; type "function"constantThe type of tool call. This is always going to be
functionfor this type of tool call.FUNCTION("function")
-
-
-
JsonValue; type "tool_calls"constantAlways
tool_calls.TOOL_CALLS("tool_calls")
-
Messages
List messages
MessageListPage beta().threads().messages().list(MessageListParamsparams = MessageListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
get /threads/{thread_id}/messages
Returns a list of messages for a given thread.
Parameters
-
MessageListParams params-
Optional<String> threadId -
Optional<String> afterA cursor for use in pagination.
afteris an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. -
Optional<String> beforeA cursor for use in pagination.
beforeis an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. -
Optional<Long> limitA limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
-
Optional<Order> orderSort order by the
created_attimestamp of the objects.ascfor ascending order anddescfor descending order.-
ASC("asc") -
DESC("desc")
-
-
Optional<String> runIdFilter messages by the run ID that generated them.
-
Returns
-
class Message:Represents a message within a thread.
-
String idThe identifier, which can be referenced in API endpoints.
-
Optional<String> assistantIdIf applicable, the ID of the assistant that authored this message.
-
Optional<List<Attachment>> attachmentsA list of files attached to the message, and the tools they were added to.
-
Optional<String> fileIdThe ID of the file to attach to the message.
-
Optional<List<Tool>> toolsThe tools to add this file to.
-
class CodeInterpreterTool:-
JsonValue; type "code_interpreter"constantThe type of tool being defined:
code_interpreterCODE_INTERPRETER("code_interpreter")
-
-
JsonValue;-
JsonValue; type "file_search"constantThe type of tool being defined:
file_searchFILE_SEARCH("file_search")
-
-
-
-
Optional<Long> completedAtThe Unix timestamp (in seconds) for when the message was completed.
-
List<MessageContent> contentThe content of the message in array of text and/or images.
-
class ImageFileContentBlock:References an image File in the content of a message.
-
ImageFile imageFile-
String fileIdThe 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> detailSpecifies the detail level of the image if specified by the user.
lowuses fewer tokens, you can opt in to high resolution usinghigh.-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
-
JsonValue; type "image_file"constantAlways
image_file.IMAGE_FILE("image_file")
-
-
class ImageUrlContentBlock:References an image URL in the content of a message.
-
ImageUrl imageUrl-
String urlThe external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.
-
Optional<Detail> detailSpecifies the detail level of the image.
lowuses fewer tokens, you can opt in to high resolution usinghigh. Default value isauto-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
-
JsonValue; type "image_url"constantThe type of the content part.
IMAGE_URL("image_url")
-
-
class TextContentBlock:The text content that is part of a message.
-
Text text-
List<Annotation> annotations-
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 -
FileCitation fileCitation-
String fileIdThe ID of the specific File the citation is from.
-
-
long startIndex -
String textThe text in the message content that needs to be replaced.
-
JsonValue; type "file_citation"constantAlways
file_citation.FILE_CITATION("file_citation")
-
-
class FilePathAnnotation:A URL for the file that's generated when the assistant used the
code_interpretertool to generate a file.-
long endIndex -
FilePath filePath-
String fileIdThe ID of the file that was generated.
-
-
long startIndex -
String textThe text in the message content that needs to be replaced.
-
JsonValue; type "file_path"constantAlways
file_path.FILE_PATH("file_path")
-
-
-
String valueThe data that makes up the text.
-
-
JsonValue; type "text"constantAlways
text.TEXT("text")
-
-
class RefusalContentBlock:The refusal content generated by the assistant.
-
String refusal -
JsonValue; type "refusal"constantAlways
refusal.REFUSAL("refusal")
-
-
-
long createdAtThe Unix timestamp (in seconds) for when the message was created.
-
Optional<Long> incompleteAtThe Unix timestamp (in seconds) for when the message was marked as incomplete.
-
Optional<IncompleteDetails> incompleteDetailsOn an incomplete message, details about why the message is incomplete.
-
Reason reasonThe reason the message is incomplete.
-
CONTENT_FILTER("content_filter") -
MAX_TOKENS("max_tokens") -
RUN_CANCELLED("run_cancelled") -
RUN_EXPIRED("run_expired") -
RUN_FAILED("run_failed")
-
-
-
Optional<Metadata> metadataSet 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"constantThe object type, which is always
thread.message.THREAD_MESSAGE("thread.message")
-
Role roleThe entity that produced the message. One of
userorassistant.-
USER("user") -
ASSISTANT("assistant")
-
-
Optional<String> runIdThe ID of the run associated with the creation of this message. Value is
nullwhen messages are created manually using the create message or create thread endpoints. -
Status statusThe status of the message, which can be either
in_progress,incomplete, orcompleted.-
IN_PROGRESS("in_progress") -
INCOMPLETE("incomplete") -
COMPLETED("completed")
-
-
String threadIdThe thread ID that this message belongs to.
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.threads.messages.MessageListPage;
import com.openai.models.beta.threads.messages.MessageListParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
MessageListPage page = client.beta().threads().messages().list("thread_id");
}
}
Response
{
"data": [
{
"id": "id",
"assistant_id": "assistant_id",
"attachments": [
{
"file_id": "file_id",
"tools": [
{
"type": "code_interpreter"
}
]
}
],
"completed_at": 0,
"content": [
{
"image_file": {
"file_id": "file_id",
"detail": "auto"
},
"type": "image_file"
}
],
"created_at": 0,
"incomplete_at": 0,
"incomplete_details": {
"reason": "content_filter"
},
"metadata": {
"foo": "string"
},
"object": "thread.message",
"role": "user",
"run_id": "run_id",
"status": "in_progress",
"thread_id": "thread_id"
}
],
"first_id": "msg_abc123",
"has_more": false,
"last_id": "msg_abc123",
"object": "list"
}
Create message
Message beta().threads().messages().create(MessageCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
post /threads/{thread_id}/messages
Create a message.
Parameters
-
MessageCreateParams params-
Optional<String> threadId -
Content contentThe text contents of the message.
-
String -
List<MessageContentPartParam>-
class ImageFileContentBlock:References an image File in the content of a message.
-
ImageFile imageFile-
String fileIdThe 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> detailSpecifies the detail level of the image if specified by the user.
lowuses fewer tokens, you can opt in to high resolution usinghigh.-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
-
JsonValue; type "image_file"constantAlways
image_file.IMAGE_FILE("image_file")
-
-
class ImageUrlContentBlock:References an image URL in the content of a message.
-
ImageUrl imageUrl-
String urlThe external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.
-
Optional<Detail> detailSpecifies the detail level of the image.
lowuses fewer tokens, you can opt in to high resolution usinghigh. Default value isauto-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
-
JsonValue; type "image_url"constantThe type of the content part.
IMAGE_URL("image_url")
-
-
class TextContentBlockParam:The text content that is part of a message.
-
String textText content to be sent to the model
-
JsonValue; type "text"constantAlways
text.TEXT("text")
-
-
-
-
Role roleThe 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. -
USER("user") -
ASSISTANT("assistant")
-
-
Optional<List<Attachment>> attachmentsA list of files attached to the message, and the tools they should be added to.
-
Optional<String> fileIdThe ID of the file to attach to the message.
-
Optional<List<Tool>> toolsThe tools to add this file to.
-
class CodeInterpreterTool:-
JsonValue; type "code_interpreter"constantThe type of tool being defined:
code_interpreterCODE_INTERPRETER("code_interpreter")
-
-
JsonValue;-
JsonValue; type "file_search"constantThe type of tool being defined:
file_searchFILE_SEARCH("file_search")
-
-
-
-
Optional<Metadata> metadataSet 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.
-
Returns
-
class Message:Represents a message within a thread.
-
String idThe identifier, which can be referenced in API endpoints.
-
Optional<String> assistantIdIf applicable, the ID of the assistant that authored this message.
-
Optional<List<Attachment>> attachmentsA list of files attached to the message, and the tools they were added to.
-
Optional<String> fileIdThe ID of the file to attach to the message.
-
Optional<List<Tool>> toolsThe tools to add this file to.
-
class CodeInterpreterTool:-
JsonValue; type "code_interpreter"constantThe type of tool being defined:
code_interpreterCODE_INTERPRETER("code_interpreter")
-
-
JsonValue;-
JsonValue; type "file_search"constantThe type of tool being defined:
file_searchFILE_SEARCH("file_search")
-
-
-
-
Optional<Long> completedAtThe Unix timestamp (in seconds) for when the message was completed.
-
List<MessageContent> contentThe content of the message in array of text and/or images.
-
class ImageFileContentBlock:References an image File in the content of a message.
-
ImageFile imageFile-
String fileIdThe 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> detailSpecifies the detail level of the image if specified by the user.
lowuses fewer tokens, you can opt in to high resolution usinghigh.-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
-
JsonValue; type "image_file"constantAlways
image_file.IMAGE_FILE("image_file")
-
-
class ImageUrlContentBlock:References an image URL in the content of a message.
-
ImageUrl imageUrl-
String urlThe external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.
-
Optional<Detail> detailSpecifies the detail level of the image.
lowuses fewer tokens, you can opt in to high resolution usinghigh. Default value isauto-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
-
JsonValue; type "image_url"constantThe type of the content part.
IMAGE_URL("image_url")
-
-
class TextContentBlock:The text content that is part of a message.
-
Text text-
List<Annotation> annotations-
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 -
FileCitation fileCitation-
String fileIdThe ID of the specific File the citation is from.
-
-
long startIndex -
String textThe text in the message content that needs to be replaced.
-
JsonValue; type "file_citation"constantAlways
file_citation.FILE_CITATION("file_citation")
-
-
class FilePathAnnotation:A URL for the file that's generated when the assistant used the
code_interpretertool to generate a file.-
long endIndex -
FilePath filePath-
String fileIdThe ID of the file that was generated.
-
-
long startIndex -
String textThe text in the message content that needs to be replaced.
-
JsonValue; type "file_path"constantAlways
file_path.FILE_PATH("file_path")
-
-
-
String valueThe data that makes up the text.
-
-
JsonValue; type "text"constantAlways
text.TEXT("text")
-
-
class RefusalContentBlock:The refusal content generated by the assistant.
-
String refusal -
JsonValue; type "refusal"constantAlways
refusal.REFUSAL("refusal")
-
-
-
long createdAtThe Unix timestamp (in seconds) for when the message was created.
-
Optional<Long> incompleteAtThe Unix timestamp (in seconds) for when the message was marked as incomplete.
-
Optional<IncompleteDetails> incompleteDetailsOn an incomplete message, details about why the message is incomplete.
-
Reason reasonThe reason the message is incomplete.
-
CONTENT_FILTER("content_filter") -
MAX_TOKENS("max_tokens") -
RUN_CANCELLED("run_cancelled") -
RUN_EXPIRED("run_expired") -
RUN_FAILED("run_failed")
-
-
-
Optional<Metadata> metadataSet 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"constantThe object type, which is always
thread.message.THREAD_MESSAGE("thread.message")
-
Role roleThe entity that produced the message. One of
userorassistant.-
USER("user") -
ASSISTANT("assistant")
-
-
Optional<String> runIdThe ID of the run associated with the creation of this message. Value is
nullwhen messages are created manually using the create message or create thread endpoints. -
Status statusThe status of the message, which can be either
in_progress,incomplete, orcompleted.-
IN_PROGRESS("in_progress") -
INCOMPLETE("incomplete") -
COMPLETED("completed")
-
-
String threadIdThe thread ID that this message belongs to.
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.threads.messages.Message;
import com.openai.models.beta.threads.messages.MessageCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
MessageCreateParams params = MessageCreateParams.builder()
.threadId("thread_id")
.content("string")
.role(MessageCreateParams.Role.USER)
.build();
Message message = client.beta().threads().messages().create(params);
}
}
Response
{
"id": "id",
"assistant_id": "assistant_id",
"attachments": [
{
"file_id": "file_id",
"tools": [
{
"type": "code_interpreter"
}
]
}
],
"completed_at": 0,
"content": [
{
"image_file": {
"file_id": "file_id",
"detail": "auto"
},
"type": "image_file"
}
],
"created_at": 0,
"incomplete_at": 0,
"incomplete_details": {
"reason": "content_filter"
},
"metadata": {
"foo": "string"
},
"object": "thread.message",
"role": "user",
"run_id": "run_id",
"status": "in_progress",
"thread_id": "thread_id"
}
Modify message
Message beta().threads().messages().update(MessageUpdateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
post /threads/{thread_id}/messages/{message_id}
Modifies a message.
Parameters
-
MessageUpdateParams params-
String threadId -
Optional<String> messageId -
Optional<Metadata> metadataSet 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.
-
Returns
-
class Message:Represents a message within a thread.
-
String idThe identifier, which can be referenced in API endpoints.
-
Optional<String> assistantIdIf applicable, the ID of the assistant that authored this message.
-
Optional<List<Attachment>> attachmentsA list of files attached to the message, and the tools they were added to.
-
Optional<String> fileIdThe ID of the file to attach to the message.
-
Optional<List<Tool>> toolsThe tools to add this file to.
-
class CodeInterpreterTool:-
JsonValue; type "code_interpreter"constantThe type of tool being defined:
code_interpreterCODE_INTERPRETER("code_interpreter")
-
-
JsonValue;-
JsonValue; type "file_search"constantThe type of tool being defined:
file_searchFILE_SEARCH("file_search")
-
-
-
-
Optional<Long> completedAtThe Unix timestamp (in seconds) for when the message was completed.
-
List<MessageContent> contentThe content of the message in array of text and/or images.
-
class ImageFileContentBlock:References an image File in the content of a message.
-
ImageFile imageFile-
String fileIdThe 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> detailSpecifies the detail level of the image if specified by the user.
lowuses fewer tokens, you can opt in to high resolution usinghigh.-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
-
JsonValue; type "image_file"constantAlways
image_file.IMAGE_FILE("image_file")
-
-
class ImageUrlContentBlock:References an image URL in the content of a message.
-
ImageUrl imageUrl-
String urlThe external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.
-
Optional<Detail> detailSpecifies the detail level of the image.
lowuses fewer tokens, you can opt in to high resolution usinghigh. Default value isauto-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
-
JsonValue; type "image_url"constantThe type of the content part.
IMAGE_URL("image_url")
-
-
class TextContentBlock:The text content that is part of a message.
-
Text text-
List<Annotation> annotations-
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 -
FileCitation fileCitation-
String fileIdThe ID of the specific File the citation is from.
-
-
long startIndex -
String textThe text in the message content that needs to be replaced.
-
JsonValue; type "file_citation"constantAlways
file_citation.FILE_CITATION("file_citation")
-
-
class FilePathAnnotation:A URL for the file that's generated when the assistant used the
code_interpretertool to generate a file.-
long endIndex -
FilePath filePath-
String fileIdThe ID of the file that was generated.
-
-
long startIndex -
String textThe text in the message content that needs to be replaced.
-
JsonValue; type "file_path"constantAlways
file_path.FILE_PATH("file_path")
-
-
-
String valueThe data that makes up the text.
-
-
JsonValue; type "text"constantAlways
text.TEXT("text")
-
-
class RefusalContentBlock:The refusal content generated by the assistant.
-
String refusal -
JsonValue; type "refusal"constantAlways
refusal.REFUSAL("refusal")
-
-
-
long createdAtThe Unix timestamp (in seconds) for when the message was created.
-
Optional<Long> incompleteAtThe Unix timestamp (in seconds) for when the message was marked as incomplete.
-
Optional<IncompleteDetails> incompleteDetailsOn an incomplete message, details about why the message is incomplete.
-
Reason reasonThe reason the message is incomplete.
-
CONTENT_FILTER("content_filter") -
MAX_TOKENS("max_tokens") -
RUN_CANCELLED("run_cancelled") -
RUN_EXPIRED("run_expired") -
RUN_FAILED("run_failed")
-
-
-
Optional<Metadata> metadataSet 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"constantThe object type, which is always
thread.message.THREAD_MESSAGE("thread.message")
-
Role roleThe entity that produced the message. One of
userorassistant.-
USER("user") -
ASSISTANT("assistant")
-
-
Optional<String> runIdThe ID of the run associated with the creation of this message. Value is
nullwhen messages are created manually using the create message or create thread endpoints. -
Status statusThe status of the message, which can be either
in_progress,incomplete, orcompleted.-
IN_PROGRESS("in_progress") -
INCOMPLETE("incomplete") -
COMPLETED("completed")
-
-
String threadIdThe thread ID that this message belongs to.
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.threads.messages.Message;
import com.openai.models.beta.threads.messages.MessageUpdateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
MessageUpdateParams params = MessageUpdateParams.builder()
.threadId("thread_id")
.messageId("message_id")
.build();
Message message = client.beta().threads().messages().update(params);
}
}
Response
{
"id": "id",
"assistant_id": "assistant_id",
"attachments": [
{
"file_id": "file_id",
"tools": [
{
"type": "code_interpreter"
}
]
}
],
"completed_at": 0,
"content": [
{
"image_file": {
"file_id": "file_id",
"detail": "auto"
},
"type": "image_file"
}
],
"created_at": 0,
"incomplete_at": 0,
"incomplete_details": {
"reason": "content_filter"
},
"metadata": {
"foo": "string"
},
"object": "thread.message",
"role": "user",
"run_id": "run_id",
"status": "in_progress",
"thread_id": "thread_id"
}
Retrieve message
Message beta().threads().messages().retrieve(MessageRetrieveParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
get /threads/{thread_id}/messages/{message_id}
Retrieve a message.
Parameters
-
MessageRetrieveParams params-
String threadId -
Optional<String> messageId
-
Returns
-
class Message:Represents a message within a thread.
-
String idThe identifier, which can be referenced in API endpoints.
-
Optional<String> assistantIdIf applicable, the ID of the assistant that authored this message.
-
Optional<List<Attachment>> attachmentsA list of files attached to the message, and the tools they were added to.
-
Optional<String> fileIdThe ID of the file to attach to the message.
-
Optional<List<Tool>> toolsThe tools to add this file to.
-
class CodeInterpreterTool:-
JsonValue; type "code_interpreter"constantThe type of tool being defined:
code_interpreterCODE_INTERPRETER("code_interpreter")
-
-
JsonValue;-
JsonValue; type "file_search"constantThe type of tool being defined:
file_searchFILE_SEARCH("file_search")
-
-
-
-
Optional<Long> completedAtThe Unix timestamp (in seconds) for when the message was completed.
-
List<MessageContent> contentThe content of the message in array of text and/or images.
-
class ImageFileContentBlock:References an image File in the content of a message.
-
ImageFile imageFile-
String fileIdThe 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> detailSpecifies the detail level of the image if specified by the user.
lowuses fewer tokens, you can opt in to high resolution usinghigh.-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
-
JsonValue; type "image_file"constantAlways
image_file.IMAGE_FILE("image_file")
-
-
class ImageUrlContentBlock:References an image URL in the content of a message.
-
ImageUrl imageUrl-
String urlThe external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.
-
Optional<Detail> detailSpecifies the detail level of the image.
lowuses fewer tokens, you can opt in to high resolution usinghigh. Default value isauto-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
-
JsonValue; type "image_url"constantThe type of the content part.
IMAGE_URL("image_url")
-
-
class TextContentBlock:The text content that is part of a message.
-
Text text-
List<Annotation> annotations-
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 -
FileCitation fileCitation-
String fileIdThe ID of the specific File the citation is from.
-
-
long startIndex -
String textThe text in the message content that needs to be replaced.
-
JsonValue; type "file_citation"constantAlways
file_citation.FILE_CITATION("file_citation")
-
-
class FilePathAnnotation:A URL for the file that's generated when the assistant used the
code_interpretertool to generate a file.-
long endIndex -
FilePath filePath-
String fileIdThe ID of the file that was generated.
-
-
long startIndex -
String textThe text in the message content that needs to be replaced.
-
JsonValue; type "file_path"constantAlways
file_path.FILE_PATH("file_path")
-
-
-
String valueThe data that makes up the text.
-
-
JsonValue; type "text"constantAlways
text.TEXT("text")
-
-
class RefusalContentBlock:The refusal content generated by the assistant.
-
String refusal -
JsonValue; type "refusal"constantAlways
refusal.REFUSAL("refusal")
-
-
-
long createdAtThe Unix timestamp (in seconds) for when the message was created.
-
Optional<Long> incompleteAtThe Unix timestamp (in seconds) for when the message was marked as incomplete.
-
Optional<IncompleteDetails> incompleteDetailsOn an incomplete message, details about why the message is incomplete.
-
Reason reasonThe reason the message is incomplete.
-
CONTENT_FILTER("content_filter") -
MAX_TOKENS("max_tokens") -
RUN_CANCELLED("run_cancelled") -
RUN_EXPIRED("run_expired") -
RUN_FAILED("run_failed")
-
-
-
Optional<Metadata> metadataSet 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"constantThe object type, which is always
thread.message.THREAD_MESSAGE("thread.message")
-
Role roleThe entity that produced the message. One of
userorassistant.-
USER("user") -
ASSISTANT("assistant")
-
-
Optional<String> runIdThe ID of the run associated with the creation of this message. Value is
nullwhen messages are created manually using the create message or create thread endpoints. -
Status statusThe status of the message, which can be either
in_progress,incomplete, orcompleted.-
IN_PROGRESS("in_progress") -
INCOMPLETE("incomplete") -
COMPLETED("completed")
-
-
String threadIdThe thread ID that this message belongs to.
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.threads.messages.Message;
import com.openai.models.beta.threads.messages.MessageRetrieveParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
MessageRetrieveParams params = MessageRetrieveParams.builder()
.threadId("thread_id")
.messageId("message_id")
.build();
Message message = client.beta().threads().messages().retrieve(params);
}
}
Response
{
"id": "id",
"assistant_id": "assistant_id",
"attachments": [
{
"file_id": "file_id",
"tools": [
{
"type": "code_interpreter"
}
]
}
],
"completed_at": 0,
"content": [
{
"image_file": {
"file_id": "file_id",
"detail": "auto"
},
"type": "image_file"
}
],
"created_at": 0,
"incomplete_at": 0,
"incomplete_details": {
"reason": "content_filter"
},
"metadata": {
"foo": "string"
},
"object": "thread.message",
"role": "user",
"run_id": "run_id",
"status": "in_progress",
"thread_id": "thread_id"
}
Delete message
MessageDeleted beta().threads().messages().delete(MessageDeleteParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
delete /threads/{thread_id}/messages/{message_id}
Deletes a message.
Parameters
-
MessageDeleteParams params-
String threadId -
Optional<String> messageId
-
Returns
-
class MessageDeleted:-
String id -
boolean deleted -
JsonValue; object_ "thread.message.deleted"constantTHREAD_MESSAGE_DELETED("thread.message.deleted")
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.threads.messages.MessageDeleteParams;
import com.openai.models.beta.threads.messages.MessageDeleted;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
MessageDeleteParams params = MessageDeleteParams.builder()
.threadId("thread_id")
.messageId("message_id")
.build();
MessageDeleted messageDeleted = client.beta().threads().messages().delete(params);
}
}
Response
{
"id": "id",
"deleted": true,
"object": "thread.message.deleted"
}
Domain Types
Annotation
-
class Annotation: A class that can be one of several variants.unionA 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.
-
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 -
FileCitation fileCitation-
String fileIdThe ID of the specific File the citation is from.
-
-
long startIndex -
String textThe text in the message content that needs to be replaced.
-
JsonValue; type "file_citation"constantAlways
file_citation.FILE_CITATION("file_citation")
-
-
class FilePathAnnotation:A URL for the file that's generated when the assistant used the
code_interpretertool to generate a file.-
long endIndex -
FilePath filePath-
String fileIdThe ID of the file that was generated.
-
-
long startIndex -
String textThe text in the message content that needs to be replaced.
-
JsonValue; type "file_path"constantAlways
file_path.FILE_PATH("file_path")
-
-
Annotation Delta
-
class AnnotationDelta: A class that can be one of several variants.unionA 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.
-
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 indexThe index of the annotation in the text content part.
-
JsonValue; type "file_citation"constantAlways
file_citation.FILE_CITATION("file_citation")
-
Optional<Long> endIndex -
Optional<FileCitation> fileCitation-
Optional<String> fileIdThe ID of the specific File the citation is from.
-
Optional<String> quoteThe specific quote in the file.
-
-
Optional<Long> startIndex -
Optional<String> textThe 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_interpretertool to generate a file.-
long indexThe index of the annotation in the text content part.
-
JsonValue; type "file_path"constantAlways
file_path.FILE_PATH("file_path")
-
Optional<Long> endIndex -
Optional<FilePath> filePath-
Optional<String> fileIdThe ID of the file that was generated.
-
-
Optional<Long> startIndex -
Optional<String> textThe text in the message content that needs to be replaced.
-
-
File Citation Annotation
-
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 -
FileCitation fileCitation-
String fileIdThe ID of the specific File the citation is from.
-
-
long startIndex -
String textThe text in the message content that needs to be replaced.
-
JsonValue; type "file_citation"constantAlways
file_citation.FILE_CITATION("file_citation")
-
File Citation Delta Annotation
-
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 indexThe index of the annotation in the text content part.
-
JsonValue; type "file_citation"constantAlways
file_citation.FILE_CITATION("file_citation")
-
Optional<Long> endIndex -
Optional<FileCitation> fileCitation-
Optional<String> fileIdThe ID of the specific File the citation is from.
-
Optional<String> quoteThe specific quote in the file.
-
-
Optional<Long> startIndex -
Optional<String> textThe text in the message content that needs to be replaced.
-
File Path Annotation
-
class FilePathAnnotation:A URL for the file that's generated when the assistant used the
code_interpretertool to generate a file.-
long endIndex -
FilePath filePath-
String fileIdThe ID of the file that was generated.
-
-
long startIndex -
String textThe text in the message content that needs to be replaced.
-
JsonValue; type "file_path"constantAlways
file_path.FILE_PATH("file_path")
-
File Path Delta Annotation
-
class FilePathDeltaAnnotation:A URL for the file that's generated when the assistant used the
code_interpretertool to generate a file.-
long indexThe index of the annotation in the text content part.
-
JsonValue; type "file_path"constantAlways
file_path.FILE_PATH("file_path")
-
Optional<Long> endIndex -
Optional<FilePath> filePath-
Optional<String> fileIdThe ID of the file that was generated.
-
-
Optional<Long> startIndex -
Optional<String> textThe text in the message content that needs to be replaced.
-
Image File
-
class ImageFile:-
String fileIdThe 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> detailSpecifies the detail level of the image if specified by the user.
lowuses fewer tokens, you can opt in to high resolution usinghigh.-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
Image File Content Block
-
class ImageFileContentBlock:References an image File in the content of a message.
-
ImageFile imageFile-
String fileIdThe 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> detailSpecifies the detail level of the image if specified by the user.
lowuses fewer tokens, you can opt in to high resolution usinghigh.-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
-
JsonValue; type "image_file"constantAlways
image_file.IMAGE_FILE("image_file")
-
Image File Delta
-
class ImageFileDelta:-
Optional<Detail> detailSpecifies the detail level of the image if specified by the user.
lowuses fewer tokens, you can opt in to high resolution usinghigh.-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
Optional<String> fileIdThe 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.
-
Image File Delta Block
-
class ImageFileDeltaBlock:References an image File in the content of a message.
-
long indexThe index of the content part in the message.
-
JsonValue; type "image_file"constantAlways
image_file.IMAGE_FILE("image_file")
-
Optional<ImageFileDelta> imageFile-
Optional<Detail> detailSpecifies the detail level of the image if specified by the user.
lowuses fewer tokens, you can opt in to high resolution usinghigh.-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
Optional<String> fileIdThe 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.
-
-
Image URL
-
class ImageUrl:-
String urlThe external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.
-
Optional<Detail> detailSpecifies the detail level of the image.
lowuses fewer tokens, you can opt in to high resolution usinghigh. Default value isauto-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
Image URL Content Block
-
class ImageUrlContentBlock:References an image URL in the content of a message.
-
ImageUrl imageUrl-
String urlThe external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.
-
Optional<Detail> detailSpecifies the detail level of the image.
lowuses fewer tokens, you can opt in to high resolution usinghigh. Default value isauto-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
-
JsonValue; type "image_url"constantThe type of the content part.
IMAGE_URL("image_url")
-
Image URL Delta
-
class ImageUrlDelta:-
Optional<Detail> detailSpecifies the detail level of the image.
lowuses fewer tokens, you can opt in to high resolution usinghigh.-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
Optional<String> urlThe URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.
-
Image URL Delta Block
-
class ImageUrlDeltaBlock:References an image URL in the content of a message.
-
long indexThe index of the content part in the message.
-
JsonValue; type "image_url"constantAlways
image_url.IMAGE_URL("image_url")
-
Optional<ImageUrlDelta> imageUrl-
Optional<Detail> detailSpecifies the detail level of the image.
lowuses fewer tokens, you can opt in to high resolution usinghigh.-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
Optional<String> urlThe URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.
-
-
Message
-
class Message:Represents a message within a thread.
-
String idThe identifier, which can be referenced in API endpoints.
-
Optional<String> assistantIdIf applicable, the ID of the assistant that authored this message.
-
Optional<List<Attachment>> attachmentsA list of files attached to the message, and the tools they were added to.
-
Optional<String> fileIdThe ID of the file to attach to the message.
-
Optional<List<Tool>> toolsThe tools to add this file to.
-
class CodeInterpreterTool:-
JsonValue; type "code_interpreter"constantThe type of tool being defined:
code_interpreterCODE_INTERPRETER("code_interpreter")
-
-
JsonValue;-
JsonValue; type "file_search"constantThe type of tool being defined:
file_searchFILE_SEARCH("file_search")
-
-
-
-
Optional<Long> completedAtThe Unix timestamp (in seconds) for when the message was completed.
-
List<MessageContent> contentThe content of the message in array of text and/or images.
-
class ImageFileContentBlock:References an image File in the content of a message.
-
ImageFile imageFile-
String fileIdThe 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> detailSpecifies the detail level of the image if specified by the user.
lowuses fewer tokens, you can opt in to high resolution usinghigh.-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
-
JsonValue; type "image_file"constantAlways
image_file.IMAGE_FILE("image_file")
-
-
class ImageUrlContentBlock:References an image URL in the content of a message.
-
ImageUrl imageUrl-
String urlThe external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.
-
Optional<Detail> detailSpecifies the detail level of the image.
lowuses fewer tokens, you can opt in to high resolution usinghigh. Default value isauto-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
-
JsonValue; type "image_url"constantThe type of the content part.
IMAGE_URL("image_url")
-
-
class TextContentBlock:The text content that is part of a message.
-
Text text-
List<Annotation> annotations-
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 -
FileCitation fileCitation-
String fileIdThe ID of the specific File the citation is from.
-
-
long startIndex -
String textThe text in the message content that needs to be replaced.
-
JsonValue; type "file_citation"constantAlways
file_citation.FILE_CITATION("file_citation")
-
-
class FilePathAnnotation:A URL for the file that's generated when the assistant used the
code_interpretertool to generate a file.-
long endIndex -
FilePath filePath-
String fileIdThe ID of the file that was generated.
-
-
long startIndex -
String textThe text in the message content that needs to be replaced.
-
JsonValue; type "file_path"constantAlways
file_path.FILE_PATH("file_path")
-
-
-
String valueThe data that makes up the text.
-
-
JsonValue; type "text"constantAlways
text.TEXT("text")
-
-
class RefusalContentBlock:The refusal content generated by the assistant.
-
String refusal -
JsonValue; type "refusal"constantAlways
refusal.REFUSAL("refusal")
-
-
-
long createdAtThe Unix timestamp (in seconds) for when the message was created.
-
Optional<Long> incompleteAtThe Unix timestamp (in seconds) for when the message was marked as incomplete.
-
Optional<IncompleteDetails> incompleteDetailsOn an incomplete message, details about why the message is incomplete.
-
Reason reasonThe reason the message is incomplete.
-
CONTENT_FILTER("content_filter") -
MAX_TOKENS("max_tokens") -
RUN_CANCELLED("run_cancelled") -
RUN_EXPIRED("run_expired") -
RUN_FAILED("run_failed")
-
-
-
Optional<Metadata> metadataSet 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"constantThe object type, which is always
thread.message.THREAD_MESSAGE("thread.message")
-
Role roleThe entity that produced the message. One of
userorassistant.-
USER("user") -
ASSISTANT("assistant")
-
-
Optional<String> runIdThe ID of the run associated with the creation of this message. Value is
nullwhen messages are created manually using the create message or create thread endpoints. -
Status statusThe status of the message, which can be either
in_progress,incomplete, orcompleted.-
IN_PROGRESS("in_progress") -
INCOMPLETE("incomplete") -
COMPLETED("completed")
-
-
String threadIdThe thread ID that this message belongs to.
-
Message Content
-
class MessageContent: A class that can be one of several variants.unionReferences an image File in the content of a message.
-
class ImageFileContentBlock:References an image File in the content of a message.
-
ImageFile imageFile-
String fileIdThe 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> detailSpecifies the detail level of the image if specified by the user.
lowuses fewer tokens, you can opt in to high resolution usinghigh.-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
-
JsonValue; type "image_file"constantAlways
image_file.IMAGE_FILE("image_file")
-
-
class ImageUrlContentBlock:References an image URL in the content of a message.
-
ImageUrl imageUrl-
String urlThe external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.
-
Optional<Detail> detailSpecifies the detail level of the image.
lowuses fewer tokens, you can opt in to high resolution usinghigh. Default value isauto-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
-
JsonValue; type "image_url"constantThe type of the content part.
IMAGE_URL("image_url")
-
-
class TextContentBlock:The text content that is part of a message.
-
Text text-
List<Annotation> annotations-
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 -
FileCitation fileCitation-
String fileIdThe ID of the specific File the citation is from.
-
-
long startIndex -
String textThe text in the message content that needs to be replaced.
-
JsonValue; type "file_citation"constantAlways
file_citation.FILE_CITATION("file_citation")
-
-
class FilePathAnnotation:A URL for the file that's generated when the assistant used the
code_interpretertool to generate a file.-
long endIndex -
FilePath filePath-
String fileIdThe ID of the file that was generated.
-
-
long startIndex -
String textThe text in the message content that needs to be replaced.
-
JsonValue; type "file_path"constantAlways
file_path.FILE_PATH("file_path")
-
-
-
String valueThe data that makes up the text.
-
-
JsonValue; type "text"constantAlways
text.TEXT("text")
-
-
class RefusalContentBlock:The refusal content generated by the assistant.
-
String refusal -
JsonValue; type "refusal"constantAlways
refusal.REFUSAL("refusal")
-
-
Message Content Delta
-
class MessageContentDelta: A class that can be one of several variants.unionReferences an image File in the content of a message.
-
class ImageFileDeltaBlock:References an image File in the content of a message.
-
long indexThe index of the content part in the message.
-
JsonValue; type "image_file"constantAlways
image_file.IMAGE_FILE("image_file")
-
Optional<ImageFileDelta> imageFile-
Optional<Detail> detailSpecifies the detail level of the image if specified by the user.
lowuses fewer tokens, you can opt in to high resolution usinghigh.-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
Optional<String> fileIdThe 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 indexThe index of the content part in the message.
-
JsonValue; type "text"constantAlways
text.TEXT("text")
-
Optional<TextDelta> text-
Optional<List<AnnotationDelta>> annotations-
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 indexThe index of the annotation in the text content part.
-
JsonValue; type "file_citation"constantAlways
file_citation.FILE_CITATION("file_citation")
-
Optional<Long> endIndex -
Optional<FileCitation> fileCitation-
Optional<String> fileIdThe ID of the specific File the citation is from.
-
Optional<String> quoteThe specific quote in the file.
-
-
Optional<Long> startIndex -
Optional<String> textThe 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_interpretertool to generate a file.-
long indexThe index of the annotation in the text content part.
-
JsonValue; type "file_path"constantAlways
file_path.FILE_PATH("file_path")
-
Optional<Long> endIndex -
Optional<FilePath> filePath-
Optional<String> fileIdThe ID of the file that was generated.
-
-
Optional<Long> startIndex -
Optional<String> textThe text in the message content that needs to be replaced.
-
-
-
Optional<String> valueThe data that makes up the text.
-
-
-
class RefusalDeltaBlock:The refusal content that is part of a message.
-
long indexThe index of the refusal part in the message.
-
JsonValue; type "refusal"constantAlways
refusal.REFUSAL("refusal")
-
Optional<String> refusal
-
-
class ImageUrlDeltaBlock:References an image URL in the content of a message.
-
long indexThe index of the content part in the message.
-
JsonValue; type "image_url"constantAlways
image_url.IMAGE_URL("image_url")
-
Optional<ImageUrlDelta> imageUrl-
Optional<Detail> detailSpecifies the detail level of the image.
lowuses fewer tokens, you can opt in to high resolution usinghigh.-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
Optional<String> urlThe URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.
-
-
-
Message Content Part Param
-
class MessageContentPartParam: A class that can be one of several variants.unionReferences an image File in the content of a message.
-
class ImageFileContentBlock:References an image File in the content of a message.
-
ImageFile imageFile-
String fileIdThe 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> detailSpecifies the detail level of the image if specified by the user.
lowuses fewer tokens, you can opt in to high resolution usinghigh.-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
-
JsonValue; type "image_file"constantAlways
image_file.IMAGE_FILE("image_file")
-
-
class ImageUrlContentBlock:References an image URL in the content of a message.
-
ImageUrl imageUrl-
String urlThe external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.
-
Optional<Detail> detailSpecifies the detail level of the image.
lowuses fewer tokens, you can opt in to high resolution usinghigh. Default value isauto-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
-
JsonValue; type "image_url"constantThe type of the content part.
IMAGE_URL("image_url")
-
-
class TextContentBlockParam:The text content that is part of a message.
-
String textText content to be sent to the model
-
JsonValue; type "text"constantAlways
text.TEXT("text")
-
-
Message Deleted
-
class MessageDeleted:-
String id -
boolean deleted -
JsonValue; object_ "thread.message.deleted"constantTHREAD_MESSAGE_DELETED("thread.message.deleted")
-
Message Delta
-
class MessageDelta:The delta containing the fields that have changed on the Message.
-
Optional<List<MessageContentDelta>> contentThe content of the message in array of text and/or images.
-
class ImageFileDeltaBlock:References an image File in the content of a message.
-
long indexThe index of the content part in the message.
-
JsonValue; type "image_file"constantAlways
image_file.IMAGE_FILE("image_file")
-
Optional<ImageFileDelta> imageFile-
Optional<Detail> detailSpecifies the detail level of the image if specified by the user.
lowuses fewer tokens, you can opt in to high resolution usinghigh.-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
Optional<String> fileIdThe 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 indexThe index of the content part in the message.
-
JsonValue; type "text"constantAlways
text.TEXT("text")
-
Optional<TextDelta> text-
Optional<List<AnnotationDelta>> annotations-
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 indexThe index of the annotation in the text content part.
-
JsonValue; type "file_citation"constantAlways
file_citation.FILE_CITATION("file_citation")
-
Optional<Long> endIndex -
Optional<FileCitation> fileCitation-
Optional<String> fileIdThe ID of the specific File the citation is from.
-
Optional<String> quoteThe specific quote in the file.
-
-
Optional<Long> startIndex -
Optional<String> textThe 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_interpretertool to generate a file.-
long indexThe index of the annotation in the text content part.
-
JsonValue; type "file_path"constantAlways
file_path.FILE_PATH("file_path")
-
Optional<Long> endIndex -
Optional<FilePath> filePath-
Optional<String> fileIdThe ID of the file that was generated.
-
-
Optional<Long> startIndex -
Optional<String> textThe text in the message content that needs to be replaced.
-
-
-
Optional<String> valueThe data that makes up the text.
-
-
-
class RefusalDeltaBlock:The refusal content that is part of a message.
-
long indexThe index of the refusal part in the message.
-
JsonValue; type "refusal"constantAlways
refusal.REFUSAL("refusal")
-
Optional<String> refusal
-
-
class ImageUrlDeltaBlock:References an image URL in the content of a message.
-
long indexThe index of the content part in the message.
-
JsonValue; type "image_url"constantAlways
image_url.IMAGE_URL("image_url")
-
Optional<ImageUrlDelta> imageUrl-
Optional<Detail> detailSpecifies the detail level of the image.
lowuses fewer tokens, you can opt in to high resolution usinghigh.-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
Optional<String> urlThe URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.
-
-
-
-
Optional<Role> roleThe entity that produced the message. One of
userorassistant.-
USER("user") -
ASSISTANT("assistant")
-
-
Message Delta Event
-
class MessageDeltaEvent:Represents a message delta i.e. any changed fields on a message during streaming.
-
String idThe identifier of the message, which can be referenced in API endpoints.
-
MessageDelta deltaThe delta containing the fields that have changed on the Message.
-
Optional<List<MessageContentDelta>> contentThe content of the message in array of text and/or images.
-
class ImageFileDeltaBlock:References an image File in the content of a message.
-
long indexThe index of the content part in the message.
-
JsonValue; type "image_file"constantAlways
image_file.IMAGE_FILE("image_file")
-
Optional<ImageFileDelta> imageFile-
Optional<Detail> detailSpecifies the detail level of the image if specified by the user.
lowuses fewer tokens, you can opt in to high resolution usinghigh.-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
Optional<String> fileIdThe 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 indexThe index of the content part in the message.
-
JsonValue; type "text"constantAlways
text.TEXT("text")
-
Optional<TextDelta> text-
Optional<List<AnnotationDelta>> annotations-
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 indexThe index of the annotation in the text content part.
-
JsonValue; type "file_citation"constantAlways
file_citation.FILE_CITATION("file_citation")
-
Optional<Long> endIndex -
Optional<FileCitation> fileCitation-
Optional<String> fileIdThe ID of the specific File the citation is from.
-
Optional<String> quoteThe specific quote in the file.
-
-
Optional<Long> startIndex -
Optional<String> textThe 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_interpretertool to generate a file.-
long indexThe index of the annotation in the text content part.
-
JsonValue; type "file_path"constantAlways
file_path.FILE_PATH("file_path")
-
Optional<Long> endIndex -
Optional<FilePath> filePath-
Optional<String> fileIdThe ID of the file that was generated.
-
-
Optional<Long> startIndex -
Optional<String> textThe text in the message content that needs to be replaced.
-
-
-
Optional<String> valueThe data that makes up the text.
-
-
-
class RefusalDeltaBlock:The refusal content that is part of a message.
-
long indexThe index of the refusal part in the message.
-
JsonValue; type "refusal"constantAlways
refusal.REFUSAL("refusal")
-
Optional<String> refusal
-
-
class ImageUrlDeltaBlock:References an image URL in the content of a message.
-
long indexThe index of the content part in the message.
-
JsonValue; type "image_url"constantAlways
image_url.IMAGE_URL("image_url")
-
Optional<ImageUrlDelta> imageUrl-
Optional<Detail> detailSpecifies the detail level of the image.
lowuses fewer tokens, you can opt in to high resolution usinghigh.-
AUTO("auto") -
LOW("low") -
HIGH("high")
-
-
Optional<String> urlThe URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.
-
-
-
-
Optional<Role> roleThe entity that produced the message. One of
userorassistant.-
USER("user") -
ASSISTANT("assistant")
-
-
-
JsonValue; object_ "thread.message.delta"constantThe object type, which is always
thread.message.delta.THREAD_MESSAGE_DELTA("thread.message.delta")
-
Refusal Content Block
-
class RefusalContentBlock:The refusal content generated by the assistant.
-
String refusal -
JsonValue; type "refusal"constantAlways
refusal.REFUSAL("refusal")
-
Refusal Delta Block
-
class RefusalDeltaBlock:The refusal content that is part of a message.
-
long indexThe index of the refusal part in the message.
-
JsonValue; type "refusal"constantAlways
refusal.REFUSAL("refusal")
-
Optional<String> refusal
-
Text
-
class Text:-
List<Annotation> annotations-
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 -
FileCitation fileCitation-
String fileIdThe ID of the specific File the citation is from.
-
-
long startIndex -
String textThe text in the message content that needs to be replaced.
-
JsonValue; type "file_citation"constantAlways
file_citation.FILE_CITATION("file_citation")
-
-
class FilePathAnnotation:A URL for the file that's generated when the assistant used the
code_interpretertool to generate a file.-
long endIndex -
FilePath filePath-
String fileIdThe ID of the file that was generated.
-
-
long startIndex -
String textThe text in the message content that needs to be replaced.
-
JsonValue; type "file_path"constantAlways
file_path.FILE_PATH("file_path")
-
-
-
String valueThe data that makes up the text.
-
Text Content Block
-
class TextContentBlock:The text content that is part of a message.
-
Text text-
List<Annotation> annotations-
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 -
FileCitation fileCitation-
String fileIdThe ID of the specific File the citation is from.
-
-
long startIndex -
String textThe text in the message content that needs to be replaced.
-
JsonValue; type "file_citation"constantAlways
file_citation.FILE_CITATION("file_citation")
-
-
class FilePathAnnotation:A URL for the file that's generated when the assistant used the
code_interpretertool to generate a file.-
long endIndex -
FilePath filePath-
String fileIdThe ID of the file that was generated.
-
-
long startIndex -
String textThe text in the message content that needs to be replaced.
-
JsonValue; type "file_path"constantAlways
file_path.FILE_PATH("file_path")
-
-
-
String valueThe data that makes up the text.
-
-
JsonValue; type "text"constantAlways
text.TEXT("text")
-
Text Content Block Param
-
class TextContentBlockParam:The text content that is part of a message.
-
String textText content to be sent to the model
-
JsonValue; type "text"constantAlways
text.TEXT("text")
-
Text Delta
-
class TextDelta:-
Optional<List<AnnotationDelta>> annotations-
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 indexThe index of the annotation in the text content part.
-
JsonValue; type "file_citation"constantAlways
file_citation.FILE_CITATION("file_citation")
-
Optional<Long> endIndex -
Optional<FileCitation> fileCitation-
Optional<String> fileIdThe ID of the specific File the citation is from.
-
Optional<String> quoteThe specific quote in the file.
-
-
Optional<Long> startIndex -
Optional<String> textThe 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_interpretertool to generate a file.-
long indexThe index of the annotation in the text content part.
-
JsonValue; type "file_path"constantAlways
file_path.FILE_PATH("file_path")
-
Optional<Long> endIndex -
Optional<FilePath> filePath-
Optional<String> fileIdThe ID of the file that was generated.
-
-
Optional<Long> startIndex -
Optional<String> textThe text in the message content that needs to be replaced.
-
-
-
Optional<String> valueThe data that makes up the text.
-
Text Delta Block
-
class TextDeltaBlock:The text content that is part of a message.
-
long indexThe index of the content part in the message.
-
JsonValue; type "text"constantAlways
text.TEXT("text")
-
Optional<TextDelta> text-
Optional<List<AnnotationDelta>> annotations-
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 indexThe index of the annotation in the text content part.
-
JsonValue; type "file_citation"constantAlways
file_citation.FILE_CITATION("file_citation")
-
Optional<Long> endIndex -
Optional<FileCitation> fileCitation-
Optional<String> fileIdThe ID of the specific File the citation is from.
-
Optional<String> quoteThe specific quote in the file.
-
-
Optional<Long> startIndex -
Optional<String> textThe 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_interpretertool to generate a file.-
long indexThe index of the annotation in the text content part.
-
JsonValue; type "file_path"constantAlways
file_path.FILE_PATH("file_path")
-
Optional<Long> endIndex -
Optional<FilePath> filePath-
Optional<String> fileIdThe ID of the file that was generated.
-
-
Optional<Long> startIndex -
Optional<String> textThe text in the message content that needs to be replaced.
-
-
-
Optional<String> valueThe data that makes up the text.
-
-