Assistants
List assistants
AssistantListPage beta().assistants().list(AssistantListParamsparams = AssistantListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
get /assistants
List assistants
Parameters
-
AssistantListParams params-
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 Assistant:Represents an
assistantthat can call the model and use tools.-
String idThe identifier, which can be referenced in API endpoints.
-
long createdAtThe Unix timestamp (in seconds) for when the assistant was created.
-
Optional<String> descriptionThe description of the assistant. The maximum length is 512 characters.
-
Optional<String> instructionsThe system instructions that the assistant uses. The maximum length is 256,000 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.
-
String modelID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them.
-
Optional<String> nameThe name of the assistant. The maximum length is 256 characters.
-
JsonValue; object_ "assistant"constantThe object type, which is always
assistant.ASSISTANT("assistant")
-
List<JsonValue> toolsA list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types
code_interpreter,file_search, orfunction. -
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<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<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_interpreter`` tool. 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<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.
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.assistants.AssistantListPage;
import com.openai.models.beta.assistants.AssistantListParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
AssistantListPage page = client.beta().assistants().list();
}
}
Response
{
"data": [
{
"id": "id",
"created_at": 0,
"description": "description",
"instructions": "instructions",
"metadata": {
"foo": "string"
},
"model": "model",
"name": "name",
"object": "assistant",
"tools": [
{}
],
"response_format": "auto",
"temperature": 1,
"tool_resources": {
"code_interpreter": {
"file_ids": [
"string"
]
},
"file_search": {
"vector_store_ids": [
"string"
]
}
},
"top_p": 1
}
],
"first_id": "asst_abc123",
"has_more": false,
"last_id": "asst_abc456",
"object": "list"
}
Create assistant
Assistant beta().assistants().create(AssistantCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
post /assistants
Create assistant
Parameters
-
AssistantCreateParams params-
ChatModel modelID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them.
-
Optional<String> descriptionThe description of the assistant. The maximum length is 512 characters.
-
Optional<String> instructionsThe system instructions that the assistant uses. The maximum length is 256,000 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<String> nameThe name of the assistant. The maximum length is 256 characters.
-
Optional<ReasoningEffort> reasoningEffortConstrains effort on reasoning for reasoning models. Currently supported values are
none,minimal,low,medium,high,xhigh, andmax. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response. Not all reasoning models support every value. See the reasoning guide for model-specific support. -
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<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 vector store attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.
-
Optional<List<VectorStore>> vectorStoresA helper to create a vector store with file_ids and attach it to this assistant. There can be a maximum of 1 vector store attached to the assistant.
-
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<List<JsonValue>> toolsA list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types
code_interpreter,file_search, orfunction. -
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.
-
Returns
-
class Assistant:Represents an
assistantthat can call the model and use tools.-
String idThe identifier, which can be referenced in API endpoints.
-
long createdAtThe Unix timestamp (in seconds) for when the assistant was created.
-
Optional<String> descriptionThe description of the assistant. The maximum length is 512 characters.
-
Optional<String> instructionsThe system instructions that the assistant uses. The maximum length is 256,000 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.
-
String modelID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them.
-
Optional<String> nameThe name of the assistant. The maximum length is 256 characters.
-
JsonValue; object_ "assistant"constantThe object type, which is always
assistant.ASSISTANT("assistant")
-
List<JsonValue> toolsA list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types
code_interpreter,file_search, orfunction. -
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<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<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_interpreter`` tool. 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<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.
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.ChatModel;
import com.openai.models.beta.assistants.Assistant;
import com.openai.models.beta.assistants.AssistantCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
AssistantCreateParams params = AssistantCreateParams.builder()
.model(ChatModel.GPT_4O)
.build();
Assistant assistant = client.beta().assistants().create(params);
}
}
Response
{
"id": "id",
"created_at": 0,
"description": "description",
"instructions": "instructions",
"metadata": {
"foo": "string"
},
"model": "model",
"name": "name",
"object": "assistant",
"tools": [
{}
],
"response_format": "auto",
"temperature": 1,
"tool_resources": {
"code_interpreter": {
"file_ids": [
"string"
]
},
"file_search": {
"vector_store_ids": [
"string"
]
}
},
"top_p": 1
}
Retrieve assistant
Assistant beta().assistants().retrieve(AssistantRetrieveParamsparams = AssistantRetrieveParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
get /assistants/{assistant_id}
Retrieve assistant
Parameters
-
AssistantRetrieveParams paramsOptional<String> assistantId
Returns
-
class Assistant:Represents an
assistantthat can call the model and use tools.-
String idThe identifier, which can be referenced in API endpoints.
-
long createdAtThe Unix timestamp (in seconds) for when the assistant was created.
-
Optional<String> descriptionThe description of the assistant. The maximum length is 512 characters.
-
Optional<String> instructionsThe system instructions that the assistant uses. The maximum length is 256,000 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.
-
String modelID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them.
-
Optional<String> nameThe name of the assistant. The maximum length is 256 characters.
-
JsonValue; object_ "assistant"constantThe object type, which is always
assistant.ASSISTANT("assistant")
-
List<JsonValue> toolsA list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types
code_interpreter,file_search, orfunction. -
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<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<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_interpreter`` tool. 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<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.
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.assistants.Assistant;
import com.openai.models.beta.assistants.AssistantRetrieveParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
Assistant assistant = client.beta().assistants().retrieve("assistant_id");
}
}
Response
{
"id": "id",
"created_at": 0,
"description": "description",
"instructions": "instructions",
"metadata": {
"foo": "string"
},
"model": "model",
"name": "name",
"object": "assistant",
"tools": [
{}
],
"response_format": "auto",
"temperature": 1,
"tool_resources": {
"code_interpreter": {
"file_ids": [
"string"
]
},
"file_search": {
"vector_store_ids": [
"string"
]
}
},
"top_p": 1
}
Modify assistant
Assistant beta().assistants().update(AssistantUpdateParamsparams = AssistantUpdateParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
post /assistants/{assistant_id}
Modify assistant
Parameters
-
AssistantUpdateParams params-
Optional<String> assistantId -
Optional<String> descriptionThe description of the assistant. The maximum length is 512 characters.
-
Optional<String> instructionsThe system instructions that the assistant uses. The maximum length is 256,000 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<Model> modelID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them.
-
GPT_5("gpt-5") -
GPT_5_MINI("gpt-5-mini") -
GPT_5_NANO("gpt-5-nano") -
GPT_5_2025_08_07("gpt-5-2025-08-07") -
GPT_5_MINI_2025_08_07("gpt-5-mini-2025-08-07") -
GPT_5_NANO_2025_08_07("gpt-5-nano-2025-08-07") -
GPT_4_1("gpt-4.1") -
GPT_4_1_MINI("gpt-4.1-mini") -
GPT_4_1_NANO("gpt-4.1-nano") -
GPT_4_1_2025_04_14("gpt-4.1-2025-04-14") -
GPT_4_1_MINI_2025_04_14("gpt-4.1-mini-2025-04-14") -
GPT_4_1_NANO_2025_04_14("gpt-4.1-nano-2025-04-14") -
O3_MINI("o3-mini") -
O3_MINI_2025_01_31("o3-mini-2025-01-31") -
O1("o1") -
O1_2024_12_17("o1-2024-12-17") -
GPT_4O("gpt-4o") -
GPT_4O_2024_11_20("gpt-4o-2024-11-20") -
GPT_4O_2024_08_06("gpt-4o-2024-08-06") -
GPT_4O_2024_05_13("gpt-4o-2024-05-13") -
GPT_4O_MINI("gpt-4o-mini") -
GPT_4O_MINI_2024_07_18("gpt-4o-mini-2024-07-18") -
GPT_4_5_PREVIEW("gpt-4.5-preview") -
GPT_4_5_PREVIEW_2025_02_27("gpt-4.5-preview-2025-02-27") -
GPT_4_TURBO("gpt-4-turbo") -
GPT_4_TURBO_2024_04_09("gpt-4-turbo-2024-04-09") -
GPT_4_0125_PREVIEW("gpt-4-0125-preview") -
GPT_4_TURBO_PREVIEW("gpt-4-turbo-preview") -
GPT_4_1106_PREVIEW("gpt-4-1106-preview") -
GPT_4_VISION_PREVIEW("gpt-4-vision-preview") -
GPT_4("gpt-4") -
GPT_4_0314("gpt-4-0314") -
GPT_4_0613("gpt-4-0613") -
GPT_4_32K("gpt-4-32k") -
GPT_4_32K_0314("gpt-4-32k-0314") -
GPT_4_32K_0613("gpt-4-32k-0613") -
GPT_3_5_TURBO("gpt-3.5-turbo") -
GPT_3_5_TURBO_16K("gpt-3.5-turbo-16k") -
GPT_3_5_TURBO_0613("gpt-3.5-turbo-0613") -
GPT_3_5_TURBO_1106("gpt-3.5-turbo-1106") -
GPT_3_5_TURBO_0125("gpt-3.5-turbo-0125") -
GPT_3_5_TURBO_16K_0613("gpt-3.5-turbo-16k-0613")
-
-
Optional<String> nameThe name of the assistant. The maximum length is 256 characters.
-
Optional<ReasoningEffort> reasoningEffortConstrains effort on reasoning for reasoning models. Currently supported values are
none,minimal,low,medium,high,xhigh, andmax. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response. Not all reasoning models support every value. See the reasoning guide for model-specific support. -
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<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>> fileIdsOverrides the 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>> vectorStoreIdsOverrides the vector store attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.
-
-
-
Optional<List<JsonValue>> toolsA list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types
code_interpreter,file_search, orfunction. -
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.
-
Returns
-
class Assistant:Represents an
assistantthat can call the model and use tools.-
String idThe identifier, which can be referenced in API endpoints.
-
long createdAtThe Unix timestamp (in seconds) for when the assistant was created.
-
Optional<String> descriptionThe description of the assistant. The maximum length is 512 characters.
-
Optional<String> instructionsThe system instructions that the assistant uses. The maximum length is 256,000 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.
-
String modelID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them.
-
Optional<String> nameThe name of the assistant. The maximum length is 256 characters.
-
JsonValue; object_ "assistant"constantThe object type, which is always
assistant.ASSISTANT("assistant")
-
List<JsonValue> toolsA list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types
code_interpreter,file_search, orfunction. -
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<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<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_interpreter`` tool. 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<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.
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.assistants.Assistant;
import com.openai.models.beta.assistants.AssistantUpdateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
Assistant assistant = client.beta().assistants().update("assistant_id");
}
}
Response
{
"id": "id",
"created_at": 0,
"description": "description",
"instructions": "instructions",
"metadata": {
"foo": "string"
},
"model": "model",
"name": "name",
"object": "assistant",
"tools": [
{}
],
"response_format": "auto",
"temperature": 1,
"tool_resources": {
"code_interpreter": {
"file_ids": [
"string"
]
},
"file_search": {
"vector_store_ids": [
"string"
]
}
},
"top_p": 1
}
Delete assistant
AssistantDeleted beta().assistants().delete(AssistantDeleteParamsparams = AssistantDeleteParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
delete /assistants/{assistant_id}
Delete assistant
Parameters
-
AssistantDeleteParams paramsOptional<String> assistantId
Returns
-
class AssistantDeleted:-
String id -
boolean deleted -
JsonValue; object_ "assistant.deleted"constantASSISTANT_DELETED("assistant.deleted")
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.assistants.AssistantDeleteParams;
import com.openai.models.beta.assistants.AssistantDeleted;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
AssistantDeleted assistantDeleted = client.beta().assistants().delete("assistant_id");
}
}
Response
{
"id": "id",
"deleted": true,
"object": "assistant.deleted"
}
Domain Types
Assistant
-
class Assistant:Represents an
assistantthat can call the model and use tools.-
String idThe identifier, which can be referenced in API endpoints.
-
long createdAtThe Unix timestamp (in seconds) for when the assistant was created.
-
Optional<String> descriptionThe description of the assistant. The maximum length is 512 characters.
-
Optional<String> instructionsThe system instructions that the assistant uses. The maximum length is 256,000 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.
-
String modelID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them.
-
Optional<String> nameThe name of the assistant. The maximum length is 256 characters.
-
JsonValue; object_ "assistant"constantThe object type, which is always
assistant.ASSISTANT("assistant")
-
List<JsonValue> toolsA list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types
code_interpreter,file_search, orfunction. -
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<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<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_interpreter`` tool. 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<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.
-
Assistant Deleted
-
class AssistantDeleted:-
String id -
boolean deleted -
JsonValue; object_ "assistant.deleted"constantASSISTANT_DELETED("assistant.deleted")
-
Assistant Stream Event
-
class AssistantStreamEvent: A class that can be one of several variants.unionRepresents an event emitted when streaming a Run.
Each event in a server-sent events stream has an
eventanddataproperty:event: thread.created data: {"id": "thread_123", "object": "thread", ...}We emit events whenever a new object is created, transitions to a new state, or is being streamed in parts (deltas). For example, we emit
thread.run.createdwhen a new run is created,thread.run.completedwhen a run completes, and so on. When an Assistant chooses to create a message during a run, we emit athread.message.created event, athread.message.in_progressevent, manythread.message.deltaevents, and finally athread.message.completedevent.We may add additional events over time, so we recommend handling unknown events gracefully in your code. See the Assistants API quickstart to learn how to integrate the Assistants API with streaming.
-
ThreadCreated-
Thread dataRepresents 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.
-
-
-
-
JsonValue; event "thread.created"constantTHREAD_CREATED("thread.created")
-
Optional<Boolean> enabledWhether to enable input audio transcription.
-
-
ThreadRunCreated-
Run dataRepresents 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.
-
JsonValue status -
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<JsonValue> toolsThe list of tools that the assistant used for this run.
-
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.
-
-
JsonValue; event "thread.run.created"constantTHREAD_RUN_CREATED("thread.run.created")
-
-
ThreadRunQueued-
Run dataRepresents an execution run on a thread.
-
JsonValue; event "thread.run.queued"constantTHREAD_RUN_QUEUED("thread.run.queued")
-
-
ThreadRunInProgress-
Run dataRepresents an execution run on a thread.
-
JsonValue; event "thread.run.in_progress"constantTHREAD_RUN_IN_PROGRESS("thread.run.in_progress")
-
-
ThreadRunRequiresAction-
Run dataRepresents an execution run on a thread.
-
JsonValue; event "thread.run.requires_action"constantTHREAD_RUN_REQUIRES_ACTION("thread.run.requires_action")
-
-
ThreadRunCompleted-
Run dataRepresents an execution run on a thread.
-
JsonValue; event "thread.run.completed"constantTHREAD_RUN_COMPLETED("thread.run.completed")
-
-
ThreadRunIncomplete-
Run dataRepresents an execution run on a thread.
-
JsonValue; event "thread.run.incomplete"constantTHREAD_RUN_INCOMPLETE("thread.run.incomplete")
-
-
ThreadRunFailed-
Run dataRepresents an execution run on a thread.
-
JsonValue; event "thread.run.failed"constantTHREAD_RUN_FAILED("thread.run.failed")
-
-
ThreadRunCancelling-
Run dataRepresents an execution run on a thread.
-
JsonValue; event "thread.run.cancelling"constantTHREAD_RUN_CANCELLING("thread.run.cancelling")
-
-
ThreadRunCancelled-
Run dataRepresents an execution run on a thread.
-
JsonValue; event "thread.run.cancelled"constantTHREAD_RUN_CANCELLED("thread.run.cancelled")
-
-
ThreadRunExpired-
Run dataRepresents an execution run on a thread.
-
JsonValue; event "thread.run.expired"constantTHREAD_RUN_EXPIRED("thread.run.expired")
-
-
ThreadRunStepCreated-
RunStep dataRepresents 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<JsonValue> 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. -
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).
-
-
-
JsonValue; event "thread.run.step.created"constantTHREAD_RUN_STEP_CREATED("thread.run.step.created")
-
-
ThreadRunStepInProgress-
RunStep dataRepresents a step in execution of a run.
-
JsonValue; event "thread.run.step.in_progress"constantTHREAD_RUN_STEP_IN_PROGRESS("thread.run.step.in_progress")
-
-
ThreadRunStepDelta-
RunStepDeltaEvent dataRepresents 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.
-
JsonValue delta -
JsonValue; object_ "thread.run.step.delta"constantThe object type, which is always
thread.run.step.delta.THREAD_RUN_STEP_DELTA("thread.run.step.delta")
-
-
JsonValue; event "thread.run.step.delta"constantTHREAD_RUN_STEP_DELTA("thread.run.step.delta")
-
-
ThreadRunStepCompleted-
RunStep dataRepresents a step in execution of a run.
-
JsonValue; event "thread.run.step.completed"constantTHREAD_RUN_STEP_COMPLETED("thread.run.step.completed")
-
-
ThreadRunStepFailed-
RunStep dataRepresents a step in execution of a run.
-
JsonValue; event "thread.run.step.failed"constantTHREAD_RUN_STEP_FAILED("thread.run.step.failed")
-
-
ThreadRunStepCancelled-
RunStep dataRepresents a step in execution of a run.
-
JsonValue; event "thread.run.step.cancelled"constantTHREAD_RUN_STEP_CANCELLED("thread.run.step.cancelled")
-
-
ThreadRunStepExpired-
RunStep dataRepresents a step in execution of a run.
-
JsonValue; event "thread.run.step.expired"constantTHREAD_RUN_STEP_EXPIRED("thread.run.step.expired")
-
-
ThreadMessageCreated-
Message dataRepresents 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<JsonValue> contentThe content of the message in array of text and/or images.
-
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.
-
-
JsonValue; event "thread.message.created"constantTHREAD_MESSAGE_CREATED("thread.message.created")
-
-
ThreadMessageInProgress-
Message dataRepresents a message within a thread.
-
JsonValue; event "thread.message.in_progress"constantTHREAD_MESSAGE_IN_PROGRESS("thread.message.in_progress")
-
-
ThreadMessageDelta-
MessageDeltaEvent dataRepresents 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<JsonValue>> contentThe content of the message in array of text and/or images.
-
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")
-
-
JsonValue; event "thread.message.delta"constantTHREAD_MESSAGE_DELTA("thread.message.delta")
-
-
ThreadMessageCompleted-
Message dataRepresents a message within a thread.
-
JsonValue; event "thread.message.completed"constantTHREAD_MESSAGE_COMPLETED("thread.message.completed")
-
-
ThreadMessageIncomplete-
Message dataRepresents a message within a thread.
-
JsonValue; event "thread.message.incomplete"constantTHREAD_MESSAGE_INCOMPLETE("thread.message.incomplete")
-
-
ErrorEvent-
ErrorObject data-
Optional<String> code -
String message -
Optional<String> param -
String type
-
-
JsonValue; event "error"constantERROR("error")
-
-
Assistant Tool
class AssistantTool:
Code Interpreter Tool
-
class CodeInterpreterTool:-
JsonValue; type "code_interpreter"constantThe type of tool being defined:
code_interpreterCODE_INTERPRETER("code_interpreter")
-
File Search Tool
-
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")
-
-
-
-
Function Tool
-
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")
-
Message Stream Event
-
class MessageStreamEvent: A class that can be one of several variants.unionOccurs when a message is created.
-
ThreadMessageCreated-
Message dataRepresents 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<JsonValue> contentThe content of the message in array of text and/or images.
-
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.
-
-
JsonValue; event "thread.message.created"constantTHREAD_MESSAGE_CREATED("thread.message.created")
-
-
ThreadMessageInProgress-
Message dataRepresents a message within a thread.
-
JsonValue; event "thread.message.in_progress"constantTHREAD_MESSAGE_IN_PROGRESS("thread.message.in_progress")
-
-
ThreadMessageDelta-
MessageDeltaEvent dataRepresents 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<JsonValue>> contentThe content of the message in array of text and/or images.
-
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")
-
-
JsonValue; event "thread.message.delta"constantTHREAD_MESSAGE_DELTA("thread.message.delta")
-
-
ThreadMessageCompleted-
Message dataRepresents a message within a thread.
-
JsonValue; event "thread.message.completed"constantTHREAD_MESSAGE_COMPLETED("thread.message.completed")
-
-
ThreadMessageIncomplete-
Message dataRepresents a message within a thread.
-
JsonValue; event "thread.message.incomplete"constantTHREAD_MESSAGE_INCOMPLETE("thread.message.incomplete")
-
-
Run Step Stream Event
-
class RunStepStreamEvent: A class that can be one of several variants.unionOccurs when a run step is created.
-
ThreadRunStepCreated-
RunStep dataRepresents 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<JsonValue> 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. -
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).
-
-
-
JsonValue; event "thread.run.step.created"constantTHREAD_RUN_STEP_CREATED("thread.run.step.created")
-
-
ThreadRunStepInProgress-
RunStep dataRepresents a step in execution of a run.
-
JsonValue; event "thread.run.step.in_progress"constantTHREAD_RUN_STEP_IN_PROGRESS("thread.run.step.in_progress")
-
-
ThreadRunStepDelta-
RunStepDeltaEvent dataRepresents 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.
-
JsonValue delta -
JsonValue; object_ "thread.run.step.delta"constantThe object type, which is always
thread.run.step.delta.THREAD_RUN_STEP_DELTA("thread.run.step.delta")
-
-
JsonValue; event "thread.run.step.delta"constantTHREAD_RUN_STEP_DELTA("thread.run.step.delta")
-
-
ThreadRunStepCompleted-
RunStep dataRepresents a step in execution of a run.
-
JsonValue; event "thread.run.step.completed"constantTHREAD_RUN_STEP_COMPLETED("thread.run.step.completed")
-
-
ThreadRunStepFailed-
RunStep dataRepresents a step in execution of a run.
-
JsonValue; event "thread.run.step.failed"constantTHREAD_RUN_STEP_FAILED("thread.run.step.failed")
-
-
ThreadRunStepCancelled-
RunStep dataRepresents a step in execution of a run.
-
JsonValue; event "thread.run.step.cancelled"constantTHREAD_RUN_STEP_CANCELLED("thread.run.step.cancelled")
-
-
ThreadRunStepExpired-
RunStep dataRepresents a step in execution of a run.
-
JsonValue; event "thread.run.step.expired"constantTHREAD_RUN_STEP_EXPIRED("thread.run.step.expired")
-
-
Run Stream Event
-
class RunStreamEvent: A class that can be one of several variants.unionOccurs when a new run is created.
-
ThreadRunCreated-
Run dataRepresents 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.
-
JsonValue status -
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<JsonValue> toolsThe list of tools that the assistant used for this run.
-
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.
-
-
JsonValue; event "thread.run.created"constantTHREAD_RUN_CREATED("thread.run.created")
-
-
ThreadRunQueued-
Run dataRepresents an execution run on a thread.
-
JsonValue; event "thread.run.queued"constantTHREAD_RUN_QUEUED("thread.run.queued")
-
-
ThreadRunInProgress-
Run dataRepresents an execution run on a thread.
-
JsonValue; event "thread.run.in_progress"constantTHREAD_RUN_IN_PROGRESS("thread.run.in_progress")
-
-
ThreadRunRequiresAction-
Run dataRepresents an execution run on a thread.
-
JsonValue; event "thread.run.requires_action"constantTHREAD_RUN_REQUIRES_ACTION("thread.run.requires_action")
-
-
ThreadRunCompleted-
Run dataRepresents an execution run on a thread.
-
JsonValue; event "thread.run.completed"constantTHREAD_RUN_COMPLETED("thread.run.completed")
-
-
ThreadRunIncomplete-
Run dataRepresents an execution run on a thread.
-
JsonValue; event "thread.run.incomplete"constantTHREAD_RUN_INCOMPLETE("thread.run.incomplete")
-
-
ThreadRunFailed-
Run dataRepresents an execution run on a thread.
-
JsonValue; event "thread.run.failed"constantTHREAD_RUN_FAILED("thread.run.failed")
-
-
ThreadRunCancelling-
Run dataRepresents an execution run on a thread.
-
JsonValue; event "thread.run.cancelling"constantTHREAD_RUN_CANCELLING("thread.run.cancelling")
-
-
ThreadRunCancelled-
Run dataRepresents an execution run on a thread.
-
JsonValue; event "thread.run.cancelled"constantTHREAD_RUN_CANCELLED("thread.run.cancelled")
-
-
ThreadRunExpired-
Run dataRepresents an execution run on a thread.
-
JsonValue; event "thread.run.expired"constantTHREAD_RUN_EXPIRED("thread.run.expired")
-
-
Thread Stream Event
-
class ThreadStreamEvent:Occurs when a new thread is created.
-
Thread dataRepresents 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.
-
-
-
-
JsonValue; event "thread.created"constantTHREAD_CREATED("thread.created")
-
Optional<Boolean> enabledWhether to enable input audio transcription.
-