diff --git a/en/resources/beta/subresources/assistants/index.md b/en/resources/beta/subresources/assistants/index.md index a2365d1..59e3372 100644 --- a/en/resources/beta/subresources/assistants/index.md +++ b/en/resources/beta/subresources/assistants/index.md @@ -75,7 +75,7 @@ Returns a list of assistants. A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. - - `CodeInterpreterTool = object { type }` + - `CodeInterpreterTool object { type }` - `type: "code_interpreter"` @@ -83,7 +83,7 @@ Returns a list of assistants. - `"code_interpreter"` - - `FileSearchTool = object { type, file_search }` + - `FileSearchTool object { type, file_search }` - `type: "file_search"` @@ -119,7 +119,7 @@ Returns a list of assistants. - `"default_2024_08_21"` - - `FunctionTool = object { function, type }` + - `FunctionTool object { function, type }` - `function: FunctionDefinition` @@ -163,7 +163,7 @@ Returns a list of assistants. - `"auto"` - - `ResponseFormatText = object { type }` + - `ResponseFormatText object { type }` Default response format. Used to generate text responses. @@ -173,7 +173,7 @@ Returns a list of assistants. - `"text"` - - `ResponseFormatJSONObject = object { type }` + - `ResponseFormatJSONObject object { type }` JSON object response format. An older method of generating JSON responses. Using `json_schema` is recommended for models that support it. Note that the @@ -186,7 +186,7 @@ Returns a list of assistants. - `"json_object"` - - `ResponseFormatJSONSchema = object { json_schema, type }` + - `ResponseFormatJSONSchema object { json_schema, type }` JSON Schema response format. Used to generate structured JSON responses. Learn more about [Structured Outputs](/docs/guides/structured-outputs). @@ -542,7 +542,7 @@ Create an assistant with a model and instructions. - `"auto"` - - `ResponseFormatText = object { type }` + - `ResponseFormatText object { type }` Default response format. Used to generate text responses. @@ -552,7 +552,7 @@ Create an assistant with a model and instructions. - `"text"` - - `ResponseFormatJSONObject = object { type }` + - `ResponseFormatJSONObject object { type }` JSON object response format. An older method of generating JSON responses. Using `json_schema` is recommended for models that support it. Note that the @@ -565,7 +565,7 @@ Create an assistant with a model and instructions. - `"json_object"` - - `ResponseFormatJSONSchema = object { json_schema, type }` + - `ResponseFormatJSONSchema object { json_schema, type }` JSON Schema response format. Used to generate structured JSON responses. Learn more about [Structured Outputs](/docs/guides/structured-outputs). @@ -631,7 +631,7 @@ Create an assistant with a model and instructions. The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. - - `AutoChunkingStrategy = object { type }` + - `AutoChunkingStrategy object { type }` The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`. @@ -641,7 +641,7 @@ Create an assistant with a model and instructions. - `"auto"` - - `StaticChunkingStrategy = object { static, type }` + - `StaticChunkingStrategy object { static, type }` - `static: object { chunk_overlap_tokens, max_chunk_size_tokens }` @@ -678,7 +678,7 @@ Create an assistant with a model and instructions. A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. - - `CodeInterpreterTool = object { type }` + - `CodeInterpreterTool object { type }` - `type: "code_interpreter"` @@ -686,7 +686,7 @@ Create an assistant with a model and instructions. - `"code_interpreter"` - - `FileSearchTool = object { type, file_search }` + - `FileSearchTool object { type, file_search }` - `type: "file_search"` @@ -722,7 +722,7 @@ Create an assistant with a model and instructions. - `"default_2024_08_21"` - - `FunctionTool = object { function, type }` + - `FunctionTool object { function, type }` - `function: FunctionDefinition` @@ -758,7 +758,7 @@ Create an assistant with a model and instructions. ### Returns -- `Assistant = object { id, created_at, description, 10 more }` +- `Assistant object { id, created_at, description, 10 more }` Represents an `assistant` that can call the model and use tools. @@ -805,7 +805,7 @@ Create an assistant with a model and instructions. A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. - - `CodeInterpreterTool = object { type }` + - `CodeInterpreterTool object { type }` - `type: "code_interpreter"` @@ -813,7 +813,7 @@ Create an assistant with a model and instructions. - `"code_interpreter"` - - `FileSearchTool = object { type, file_search }` + - `FileSearchTool object { type, file_search }` - `type: "file_search"` @@ -849,7 +849,7 @@ Create an assistant with a model and instructions. - `"default_2024_08_21"` - - `FunctionTool = object { function, type }` + - `FunctionTool object { function, type }` - `function: FunctionDefinition` @@ -893,7 +893,7 @@ Create an assistant with a model and instructions. - `"auto"` - - `ResponseFormatText = object { type }` + - `ResponseFormatText object { type }` Default response format. Used to generate text responses. @@ -903,7 +903,7 @@ Create an assistant with a model and instructions. - `"text"` - - `ResponseFormatJSONObject = object { type }` + - `ResponseFormatJSONObject object { type }` JSON object response format. An older method of generating JSON responses. Using `json_schema` is recommended for models that support it. Note that the @@ -916,7 +916,7 @@ Create an assistant with a model and instructions. - `"json_object"` - - `ResponseFormatJSONSchema = object { json_schema, type }` + - `ResponseFormatJSONSchema object { json_schema, type }` JSON Schema response format. Used to generate structured JSON responses. Learn more about [Structured Outputs](/docs/guides/structured-outputs). @@ -1124,7 +1124,7 @@ Retrieves an assistant. ### Returns -- `Assistant = object { id, created_at, description, 10 more }` +- `Assistant object { id, created_at, description, 10 more }` Represents an `assistant` that can call the model and use tools. @@ -1171,7 +1171,7 @@ Retrieves an assistant. A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. - - `CodeInterpreterTool = object { type }` + - `CodeInterpreterTool object { type }` - `type: "code_interpreter"` @@ -1179,7 +1179,7 @@ Retrieves an assistant. - `"code_interpreter"` - - `FileSearchTool = object { type, file_search }` + - `FileSearchTool object { type, file_search }` - `type: "file_search"` @@ -1215,7 +1215,7 @@ Retrieves an assistant. - `"default_2024_08_21"` - - `FunctionTool = object { function, type }` + - `FunctionTool object { function, type }` - `function: FunctionDefinition` @@ -1259,7 +1259,7 @@ Retrieves an assistant. - `"auto"` - - `ResponseFormatText = object { type }` + - `ResponseFormatText object { type }` Default response format. Used to generate text responses. @@ -1269,7 +1269,7 @@ Retrieves an assistant. - `"text"` - - `ResponseFormatJSONObject = object { type }` + - `ResponseFormatJSONObject object { type }` JSON object response format. An older method of generating JSON responses. Using `json_schema` is recommended for models that support it. Note that the @@ -1282,7 +1282,7 @@ Retrieves an assistant. - `"json_object"` - - `ResponseFormatJSONSchema = object { json_schema, type }` + - `ResponseFormatJSONSchema object { json_schema, type }` JSON Schema response format. Used to generate structured JSON responses. Learn more about [Structured Outputs](/docs/guides/structured-outputs). @@ -1591,7 +1591,7 @@ Modifies an assistant. - `"auto"` - - `ResponseFormatText = object { type }` + - `ResponseFormatText object { type }` Default response format. Used to generate text responses. @@ -1601,7 +1601,7 @@ Modifies an assistant. - `"text"` - - `ResponseFormatJSONObject = object { type }` + - `ResponseFormatJSONObject object { type }` JSON object response format. An older method of generating JSON responses. Using `json_schema` is recommended for models that support it. Note that the @@ -1614,7 +1614,7 @@ Modifies an assistant. - `"json_object"` - - `ResponseFormatJSONSchema = object { json_schema, type }` + - `ResponseFormatJSONSchema object { json_schema, type }` JSON Schema response format. Used to generate structured JSON responses. Learn more about [Structured Outputs](/docs/guides/structured-outputs). @@ -1676,7 +1676,7 @@ Modifies an assistant. A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. - - `CodeInterpreterTool = object { type }` + - `CodeInterpreterTool object { type }` - `type: "code_interpreter"` @@ -1684,7 +1684,7 @@ Modifies an assistant. - `"code_interpreter"` - - `FileSearchTool = object { type, file_search }` + - `FileSearchTool object { type, file_search }` - `type: "file_search"` @@ -1720,7 +1720,7 @@ Modifies an assistant. - `"default_2024_08_21"` - - `FunctionTool = object { function, type }` + - `FunctionTool object { function, type }` - `function: FunctionDefinition` @@ -1756,7 +1756,7 @@ Modifies an assistant. ### Returns -- `Assistant = object { id, created_at, description, 10 more }` +- `Assistant object { id, created_at, description, 10 more }` Represents an `assistant` that can call the model and use tools. @@ -1803,7 +1803,7 @@ Modifies an assistant. A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. - - `CodeInterpreterTool = object { type }` + - `CodeInterpreterTool object { type }` - `type: "code_interpreter"` @@ -1811,7 +1811,7 @@ Modifies an assistant. - `"code_interpreter"` - - `FileSearchTool = object { type, file_search }` + - `FileSearchTool object { type, file_search }` - `type: "file_search"` @@ -1847,7 +1847,7 @@ Modifies an assistant. - `"default_2024_08_21"` - - `FunctionTool = object { function, type }` + - `FunctionTool object { function, type }` - `function: FunctionDefinition` @@ -1891,7 +1891,7 @@ Modifies an assistant. - `"auto"` - - `ResponseFormatText = object { type }` + - `ResponseFormatText object { type }` Default response format. Used to generate text responses. @@ -1901,7 +1901,7 @@ Modifies an assistant. - `"text"` - - `ResponseFormatJSONObject = object { type }` + - `ResponseFormatJSONObject object { type }` JSON object response format. An older method of generating JSON responses. Using `json_schema` is recommended for models that support it. Note that the @@ -1914,7 +1914,7 @@ Modifies an assistant. - `"json_object"` - - `ResponseFormatJSONSchema = object { json_schema, type }` + - `ResponseFormatJSONSchema object { json_schema, type }` JSON Schema response format. Used to generate structured JSON responses. Learn more about [Structured Outputs](/docs/guides/structured-outputs). @@ -2082,7 +2082,7 @@ Delete an assistant. ### Returns -- `AssistantDeleted = object { id, deleted, object }` +- `AssistantDeleted object { id, deleted, object }` - `id: string` @@ -2135,7 +2135,7 @@ curl https://api.openai.com/v1/assistants/asst_abc123 \ ### Assistant -- `Assistant = object { id, created_at, description, 10 more }` +- `Assistant object { id, created_at, description, 10 more }` Represents an `assistant` that can call the model and use tools. @@ -2182,7 +2182,7 @@ curl https://api.openai.com/v1/assistants/asst_abc123 \ A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. - - `CodeInterpreterTool = object { type }` + - `CodeInterpreterTool object { type }` - `type: "code_interpreter"` @@ -2190,7 +2190,7 @@ curl https://api.openai.com/v1/assistants/asst_abc123 \ - `"code_interpreter"` - - `FileSearchTool = object { type, file_search }` + - `FileSearchTool object { type, file_search }` - `type: "file_search"` @@ -2226,7 +2226,7 @@ curl https://api.openai.com/v1/assistants/asst_abc123 \ - `"default_2024_08_21"` - - `FunctionTool = object { function, type }` + - `FunctionTool object { function, type }` - `function: FunctionDefinition` @@ -2270,7 +2270,7 @@ curl https://api.openai.com/v1/assistants/asst_abc123 \ - `"auto"` - - `ResponseFormatText = object { type }` + - `ResponseFormatText object { type }` Default response format. Used to generate text responses. @@ -2280,7 +2280,7 @@ curl https://api.openai.com/v1/assistants/asst_abc123 \ - `"text"` - - `ResponseFormatJSONObject = object { type }` + - `ResponseFormatJSONObject object { type }` JSON object response format. An older method of generating JSON responses. Using `json_schema` is recommended for models that support it. Note that the @@ -2293,7 +2293,7 @@ curl https://api.openai.com/v1/assistants/asst_abc123 \ - `"json_object"` - - `ResponseFormatJSONSchema = object { json_schema, type }` + - `ResponseFormatJSONSchema object { json_schema, type }` JSON Schema response format. Used to generate structured JSON responses. Learn more about [Structured Outputs](/docs/guides/structured-outputs). @@ -2359,7 +2359,7 @@ curl https://api.openai.com/v1/assistants/asst_abc123 \ ### Assistant Deleted -- `AssistantDeleted = object { id, deleted, object }` +- `AssistantDeleted object { id, deleted, object }` - `id: string` @@ -2605,7 +2605,7 @@ curl https://api.openai.com/v1/assistants/asst_abc123 \ - `"auto"` - - `ResponseFormatText = object { type }` + - `ResponseFormatText object { type }` Default response format. Used to generate text responses. @@ -2615,7 +2615,7 @@ curl https://api.openai.com/v1/assistants/asst_abc123 \ - `"text"` - - `ResponseFormatJSONObject = object { type }` + - `ResponseFormatJSONObject object { type }` JSON object response format. An older method of generating JSON responses. Using `json_schema` is recommended for models that support it. Note that the @@ -2628,7 +2628,7 @@ curl https://api.openai.com/v1/assistants/asst_abc123 \ - `"json_object"` - - `ResponseFormatJSONSchema = object { json_schema, type }` + - `ResponseFormatJSONSchema object { json_schema, type }` JSON Schema response format. Used to generate structured JSON responses. Learn more about [Structured Outputs](/docs/guides/structured-outputs). @@ -2714,7 +2714,7 @@ curl https://api.openai.com/v1/assistants/asst_abc123 \ - `"required"` - - `AssistantToolChoice = object { type, function }` + - `AssistantToolChoice object { type, function }` Specifies a tool the model should use. Use to force the model to call a specific tool. @@ -2738,7 +2738,7 @@ curl https://api.openai.com/v1/assistants/asst_abc123 \ The list of tools that the [assistant](/docs/api-reference/assistants) used for this run. - - `CodeInterpreterTool = object { type }` + - `CodeInterpreterTool object { type }` - `type: "code_interpreter"` @@ -2746,7 +2746,7 @@ curl https://api.openai.com/v1/assistants/asst_abc123 \ - `"code_interpreter"` - - `FileSearchTool = object { type, file_search }` + - `FileSearchTool object { type, file_search }` - `type: "file_search"` @@ -2782,7 +2782,7 @@ curl https://api.openai.com/v1/assistants/asst_abc123 \ - `"default_2024_08_21"` - - `FunctionTool = object { function, type }` + - `FunctionTool object { function, type }` - `function: FunctionDefinition` @@ -2862,11303 +2862,17 @@ curl https://api.openai.com/v1/assistants/asst_abc123 \ Represents an execution run on a [thread](/docs/api-reference/threads). - - `id: string` - - The identifier, which can be referenced in API endpoints. - - - `assistant_id: string` - - The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run. - - - `cancelled_at: number` - - The Unix timestamp (in seconds) for when the run was cancelled. - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the run was completed. - - - `created_at: number` - - The Unix timestamp (in seconds) for when the run was created. - - - `expires_at: number` - - The Unix timestamp (in seconds) for when the run will expire. - - - `failed_at: number` - - The Unix timestamp (in seconds) for when the run failed. - - - `incomplete_details: object { reason }` - - Details on why the run is incomplete. Will be `null` if the run is not incomplete. - - - `reason: optional "max_completion_tokens" or "max_prompt_tokens"` - - The 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_prompt_tokens"` - - - `instructions: string` - - The instructions that the [assistant](/docs/api-reference/assistants) used for this run. - - - `last_error: object { code, message }` - - The last error associated with this run. Will be `null` if there are no errors. - - - `code: "server_error" or "rate_limit_exceeded" or "invalid_prompt"` - - One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. - - - `"server_error"` - - - `"rate_limit_exceeded"` - - - `"invalid_prompt"` - - - `message: string` - - A human-readable description of the error. - - - `max_completion_tokens: number` - - The maximum number of completion tokens specified to have been used over the course of the run. - - - `max_prompt_tokens: number` - - The maximum number of prompt tokens specified to have been used over the course of the run. - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `model: string` - - The model that the [assistant](/docs/api-reference/assistants) used for this run. - - - `object: "thread.run"` - - The object type, which is always `thread.run`. - - - `"thread.run"` - - - `parallel_tool_calls: boolean` - - Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. - - - `required_action: object { submit_tool_outputs, type }` - - Details on the action required to continue the run. Will be `null` if no action is required. - - - `submit_tool_outputs: object { tool_calls }` - - Details on the tool outputs needed for this run to continue. - - - `tool_calls: array of RequiredActionFunctionToolCall` - - A list of the relevant tool calls. - - - `id: string` - - The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint. - - - `function: object { arguments, name }` - - The function definition. - - - `arguments: string` - - The arguments that the model expects you to pass to the function. - - - `name: string` - - The name of the function. - - - `type: "function"` - - The type of tool call the output is required for. For now, this is always `function`. - - - `"function"` - - - `type: "submit_tool_outputs"` - - For now, this is always `submit_tool_outputs`. - - - `"submit_tool_outputs"` - - - `response_format: AssistantResponseFormatOption` - - Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), 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](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - - - `"auto"` - - `auto` is the default value - - - `"auto"` - - - `ResponseFormatText = object { type }` - - Default response format. Used to generate text responses. - - - `type: "text"` - - The type of response format being defined. Always `text`. - - - `"text"` - - - `ResponseFormatJSONObject = object { type }` - - JSON object response format. An older method of generating JSON responses. - Using `json_schema` is recommended for models that support it. Note that the - model will not generate JSON without a system or user message instructing it - to do so. - - - `type: "json_object"` - - The type of response format being defined. Always `json_object`. - - - `"json_object"` - - - `ResponseFormatJSONSchema = object { json_schema, type }` - - JSON Schema response format. Used to generate structured JSON responses. - Learn more about [Structured Outputs](/docs/guides/structured-outputs). - - - `json_schema: object { name, description, schema, strict }` - - Structured Outputs configuration options, including a JSON Schema. - - - `name: string` - - The name of the response format. Must be a-z, A-Z, 0-9, or contain - underscores and dashes, with a maximum length of 64. - - - `description: optional string` - - A description of what the response format is for, used by the model to - determine how to respond in the format. - - - `schema: optional map[unknown]` - - The schema for the response format, described as a JSON Schema object. - Learn how to build JSON schemas [here](https://json-schema.org/). - - - `strict: optional boolean` - - Whether to enable strict schema adherence when generating the output. - If set to true, the model will always follow the exact schema defined - in the `schema` field. Only a subset of JSON Schema is supported when - `strict` is `true`. To learn more, read the [Structured Outputs - guide](/docs/guides/structured-outputs). - - - `type: "json_schema"` - - The type of response format being defined. Always `json_schema`. - - - `"json_schema"` - - - `started_at: number` - - The Unix timestamp (in seconds) for when the run was started. - - - `status: "queued" or "in_progress" or "requires_action" or 6 more` - - The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. - - - `"queued"` - - - `"in_progress"` - - - `"requires_action"` - - - `"cancelling"` - - - `"cancelled"` - - - `"failed"` - - - `"completed"` - - - `"incomplete"` - - - `"expired"` - - - `thread_id: string` - - The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run. - - - `tool_choice: AssistantToolChoiceOption` - - Controls which (if any) tool is called by the model. - `none` means the model will not call any tools and instead generates a message. - `auto` is the default value and means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools before responding to the user. - Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. - - - `"none" or "auto" or "required"` - - `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user. - - - `"none"` - - - `"auto"` - - - `"required"` - - - `AssistantToolChoice = object { type, function }` - - Specifies a tool the model should use. Use to force the model to call a specific tool. - - - `type: "function" or "code_interpreter" or "file_search"` - - The type of the tool. If type is `function`, the function name must be set - - - `"function"` - - - `"code_interpreter"` - - - `"file_search"` - - - `function: optional AssistantToolChoiceFunction` - - - `name: string` - - The name of the function to call. - - - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool` - - The list of tools that the [assistant](/docs/api-reference/assistants) used for this run. - - - `CodeInterpreterTool = object { type }` - - - `type: "code_interpreter"` - - The type of tool being defined: `code_interpreter` - - - `"code_interpreter"` - - - `FileSearchTool = object { type, file_search }` - - - `type: "file_search"` - - The type of tool being defined: `file_search` - - - `"file_search"` - - - `file_search: optional object { max_num_results, ranking_options }` - - Overrides for the file search tool. - - - `max_num_results: optional number` - - The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. - - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `ranking_options: optional object { score_threshold, ranker }` - - The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. - - See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `score_threshold: number` - - The score threshold for the file search. All values must be a floating point number between 0 and 1. - - - `ranker: optional "auto" or "default_2024_08_21"` - - The ranker to use for the file search. If not specified will use the `auto` ranker. - - - `"auto"` - - - `"default_2024_08_21"` - - - `FunctionTool = object { function, type }` - - - `function: FunctionDefinition` - - - `name: string` - - The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - - - `description: optional string` - - A description of what the function does, used by the model to choose when and how to call the function. - - - `parameters: optional FunctionParameters` - - The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. - - Omitting `parameters` defines a function with an empty parameter list. - - - `strict: optional boolean` - - Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling). - - - `type: "function"` - - The type of tool being defined: `function` - - - `"function"` - - - `truncation_strategy: object { type, last_messages }` - - Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. - - - `type: "auto" or "last_messages"` - - The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`. - - - `"auto"` - - - `"last_messages"` - - - `last_messages: optional number` - - The number of most recent messages from the thread when constructing the context for the run. - - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - - Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). - - - `completion_tokens: number` - - Number of completion tokens used over the course of the run. - - - `prompt_tokens: number` - - Number of prompt tokens used over the course of the run. - - - `total_tokens: number` - - Total number of tokens used (prompt + completion). - - - `temperature: optional number` - - The sampling temperature used for this run. If not set, defaults to 1. - - - `top_p: optional number` - - The nucleus sampling value used for this run. If not set, defaults to 1. - - - `event: "thread.run.queued"` - - - `"thread.run.queued"` - - - `object { data, event }` - - Occurs when a [run](/docs/api-reference/runs/object) moves to an `in_progress` status. - - - `data: Run` - - Represents an execution run on a [thread](/docs/api-reference/threads). - - - `id: string` - - The identifier, which can be referenced in API endpoints. - - - `assistant_id: string` - - The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run. - - - `cancelled_at: number` - - The Unix timestamp (in seconds) for when the run was cancelled. - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the run was completed. - - - `created_at: number` - - The Unix timestamp (in seconds) for when the run was created. - - - `expires_at: number` - - The Unix timestamp (in seconds) for when the run will expire. - - - `failed_at: number` - - The Unix timestamp (in seconds) for when the run failed. - - - `incomplete_details: object { reason }` - - Details on why the run is incomplete. Will be `null` if the run is not incomplete. - - - `reason: optional "max_completion_tokens" or "max_prompt_tokens"` - - The 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_prompt_tokens"` - - - `instructions: string` - - The instructions that the [assistant](/docs/api-reference/assistants) used for this run. - - - `last_error: object { code, message }` - - The last error associated with this run. Will be `null` if there are no errors. - - - `code: "server_error" or "rate_limit_exceeded" or "invalid_prompt"` - - One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. - - - `"server_error"` - - - `"rate_limit_exceeded"` - - - `"invalid_prompt"` - - - `message: string` - - A human-readable description of the error. - - - `max_completion_tokens: number` - - The maximum number of completion tokens specified to have been used over the course of the run. - - - `max_prompt_tokens: number` - - The maximum number of prompt tokens specified to have been used over the course of the run. - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `model: string` - - The model that the [assistant](/docs/api-reference/assistants) used for this run. - - - `object: "thread.run"` - - The object type, which is always `thread.run`. - - - `"thread.run"` - - - `parallel_tool_calls: boolean` - - Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. - - - `required_action: object { submit_tool_outputs, type }` - - Details on the action required to continue the run. Will be `null` if no action is required. - - - `submit_tool_outputs: object { tool_calls }` - - Details on the tool outputs needed for this run to continue. - - - `tool_calls: array of RequiredActionFunctionToolCall` - - A list of the relevant tool calls. - - - `id: string` - - The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint. - - - `function: object { arguments, name }` - - The function definition. - - - `arguments: string` - - The arguments that the model expects you to pass to the function. - - - `name: string` - - The name of the function. - - - `type: "function"` - - The type of tool call the output is required for. For now, this is always `function`. - - - `"function"` - - - `type: "submit_tool_outputs"` - - For now, this is always `submit_tool_outputs`. - - - `"submit_tool_outputs"` - - - `response_format: AssistantResponseFormatOption` - - Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), 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](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - - - `"auto"` - - `auto` is the default value - - - `"auto"` - - - `ResponseFormatText = object { type }` - - Default response format. Used to generate text responses. - - - `type: "text"` - - The type of response format being defined. Always `text`. - - - `"text"` - - - `ResponseFormatJSONObject = object { type }` - - JSON object response format. An older method of generating JSON responses. - Using `json_schema` is recommended for models that support it. Note that the - model will not generate JSON without a system or user message instructing it - to do so. - - - `type: "json_object"` - - The type of response format being defined. Always `json_object`. - - - `"json_object"` - - - `ResponseFormatJSONSchema = object { json_schema, type }` - - JSON Schema response format. Used to generate structured JSON responses. - Learn more about [Structured Outputs](/docs/guides/structured-outputs). - - - `json_schema: object { name, description, schema, strict }` - - Structured Outputs configuration options, including a JSON Schema. - - - `name: string` - - The name of the response format. Must be a-z, A-Z, 0-9, or contain - underscores and dashes, with a maximum length of 64. - - - `description: optional string` - - A description of what the response format is for, used by the model to - determine how to respond in the format. - - - `schema: optional map[unknown]` - - The schema for the response format, described as a JSON Schema object. - Learn how to build JSON schemas [here](https://json-schema.org/). - - - `strict: optional boolean` - - Whether to enable strict schema adherence when generating the output. - If set to true, the model will always follow the exact schema defined - in the `schema` field. Only a subset of JSON Schema is supported when - `strict` is `true`. To learn more, read the [Structured Outputs - guide](/docs/guides/structured-outputs). - - - `type: "json_schema"` - - The type of response format being defined. Always `json_schema`. - - - `"json_schema"` - - - `started_at: number` - - The Unix timestamp (in seconds) for when the run was started. - - - `status: "queued" or "in_progress" or "requires_action" or 6 more` - - The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. - - - `"queued"` - - - `"in_progress"` - - - `"requires_action"` - - - `"cancelling"` - - - `"cancelled"` - - - `"failed"` - - - `"completed"` - - - `"incomplete"` - - - `"expired"` - - - `thread_id: string` - - The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run. - - - `tool_choice: AssistantToolChoiceOption` - - Controls which (if any) tool is called by the model. - `none` means the model will not call any tools and instead generates a message. - `auto` is the default value and means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools before responding to the user. - Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. - - - `"none" or "auto" or "required"` - - `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user. - - - `"none"` - - - `"auto"` - - - `"required"` - - - `AssistantToolChoice = object { type, function }` - - Specifies a tool the model should use. Use to force the model to call a specific tool. - - - `type: "function" or "code_interpreter" or "file_search"` - - The type of the tool. If type is `function`, the function name must be set - - - `"function"` - - - `"code_interpreter"` - - - `"file_search"` - - - `function: optional AssistantToolChoiceFunction` - - - `name: string` - - The name of the function to call. - - - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool` - - The list of tools that the [assistant](/docs/api-reference/assistants) used for this run. - - - `CodeInterpreterTool = object { type }` - - - `type: "code_interpreter"` - - The type of tool being defined: `code_interpreter` - - - `"code_interpreter"` - - - `FileSearchTool = object { type, file_search }` - - - `type: "file_search"` - - The type of tool being defined: `file_search` - - - `"file_search"` - - - `file_search: optional object { max_num_results, ranking_options }` - - Overrides for the file search tool. - - - `max_num_results: optional number` - - The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. - - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `ranking_options: optional object { score_threshold, ranker }` - - The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. - - See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `score_threshold: number` - - The score threshold for the file search. All values must be a floating point number between 0 and 1. - - - `ranker: optional "auto" or "default_2024_08_21"` - - The ranker to use for the file search. If not specified will use the `auto` ranker. - - - `"auto"` - - - `"default_2024_08_21"` - - - `FunctionTool = object { function, type }` - - - `function: FunctionDefinition` - - - `name: string` - - The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - - - `description: optional string` - - A description of what the function does, used by the model to choose when and how to call the function. - - - `parameters: optional FunctionParameters` - - The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. - - Omitting `parameters` defines a function with an empty parameter list. - - - `strict: optional boolean` - - Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling). - - - `type: "function"` - - The type of tool being defined: `function` - - - `"function"` - - - `truncation_strategy: object { type, last_messages }` - - Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. - - - `type: "auto" or "last_messages"` - - The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`. - - - `"auto"` - - - `"last_messages"` - - - `last_messages: optional number` - - The number of most recent messages from the thread when constructing the context for the run. - - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - - Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). - - - `completion_tokens: number` - - Number of completion tokens used over the course of the run. - - - `prompt_tokens: number` - - Number of prompt tokens used over the course of the run. - - - `total_tokens: number` - - Total number of tokens used (prompt + completion). - - - `temperature: optional number` - - The sampling temperature used for this run. If not set, defaults to 1. - - - `top_p: optional number` - - The nucleus sampling value used for this run. If not set, defaults to 1. - - - `event: "thread.run.in_progress"` - - - `"thread.run.in_progress"` - - - `object { data, event }` - - Occurs when a [run](/docs/api-reference/runs/object) moves to a `requires_action` status. - - - `data: Run` - - Represents an execution run on a [thread](/docs/api-reference/threads). - - - `id: string` - - The identifier, which can be referenced in API endpoints. - - - `assistant_id: string` - - The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run. - - - `cancelled_at: number` - - The Unix timestamp (in seconds) for when the run was cancelled. - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the run was completed. - - - `created_at: number` - - The Unix timestamp (in seconds) for when the run was created. - - - `expires_at: number` - - The Unix timestamp (in seconds) for when the run will expire. - - - `failed_at: number` - - The Unix timestamp (in seconds) for when the run failed. - - - `incomplete_details: object { reason }` - - Details on why the run is incomplete. Will be `null` if the run is not incomplete. - - - `reason: optional "max_completion_tokens" or "max_prompt_tokens"` - - The 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_prompt_tokens"` - - - `instructions: string` - - The instructions that the [assistant](/docs/api-reference/assistants) used for this run. - - - `last_error: object { code, message }` - - The last error associated with this run. Will be `null` if there are no errors. - - - `code: "server_error" or "rate_limit_exceeded" or "invalid_prompt"` - - One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. - - - `"server_error"` - - - `"rate_limit_exceeded"` - - - `"invalid_prompt"` - - - `message: string` - - A human-readable description of the error. - - - `max_completion_tokens: number` - - The maximum number of completion tokens specified to have been used over the course of the run. - - - `max_prompt_tokens: number` - - The maximum number of prompt tokens specified to have been used over the course of the run. - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `model: string` - - The model that the [assistant](/docs/api-reference/assistants) used for this run. - - - `object: "thread.run"` - - The object type, which is always `thread.run`. - - - `"thread.run"` - - - `parallel_tool_calls: boolean` - - Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. - - - `required_action: object { submit_tool_outputs, type }` - - Details on the action required to continue the run. Will be `null` if no action is required. - - - `submit_tool_outputs: object { tool_calls }` - - Details on the tool outputs needed for this run to continue. - - - `tool_calls: array of RequiredActionFunctionToolCall` - - A list of the relevant tool calls. - - - `id: string` - - The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint. - - - `function: object { arguments, name }` - - The function definition. - - - `arguments: string` - - The arguments that the model expects you to pass to the function. - - - `name: string` - - The name of the function. - - - `type: "function"` - - The type of tool call the output is required for. For now, this is always `function`. - - - `"function"` - - - `type: "submit_tool_outputs"` - - For now, this is always `submit_tool_outputs`. - - - `"submit_tool_outputs"` - - - `response_format: AssistantResponseFormatOption` - - Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), 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](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - - - `"auto"` - - `auto` is the default value - - - `"auto"` - - - `ResponseFormatText = object { type }` - - Default response format. Used to generate text responses. - - - `type: "text"` - - The type of response format being defined. Always `text`. - - - `"text"` - - - `ResponseFormatJSONObject = object { type }` - - JSON object response format. An older method of generating JSON responses. - Using `json_schema` is recommended for models that support it. Note that the - model will not generate JSON without a system or user message instructing it - to do so. - - - `type: "json_object"` - - The type of response format being defined. Always `json_object`. - - - `"json_object"` - - - `ResponseFormatJSONSchema = object { json_schema, type }` - - JSON Schema response format. Used to generate structured JSON responses. - Learn more about [Structured Outputs](/docs/guides/structured-outputs). - - - `json_schema: object { name, description, schema, strict }` - - Structured Outputs configuration options, including a JSON Schema. - - - `name: string` - - The name of the response format. Must be a-z, A-Z, 0-9, or contain - underscores and dashes, with a maximum length of 64. - - - `description: optional string` - - A description of what the response format is for, used by the model to - determine how to respond in the format. - - - `schema: optional map[unknown]` - - The schema for the response format, described as a JSON Schema object. - Learn how to build JSON schemas [here](https://json-schema.org/). - - - `strict: optional boolean` - - Whether to enable strict schema adherence when generating the output. - If set to true, the model will always follow the exact schema defined - in the `schema` field. Only a subset of JSON Schema is supported when - `strict` is `true`. To learn more, read the [Structured Outputs - guide](/docs/guides/structured-outputs). - - - `type: "json_schema"` - - The type of response format being defined. Always `json_schema`. - - - `"json_schema"` - - - `started_at: number` - - The Unix timestamp (in seconds) for when the run was started. - - - `status: "queued" or "in_progress" or "requires_action" or 6 more` - - The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. - - - `"queued"` - - - `"in_progress"` - - - `"requires_action"` - - - `"cancelling"` - - - `"cancelled"` - - - `"failed"` - - - `"completed"` - - - `"incomplete"` - - - `"expired"` - - - `thread_id: string` - - The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run. - - - `tool_choice: AssistantToolChoiceOption` - - Controls which (if any) tool is called by the model. - `none` means the model will not call any tools and instead generates a message. - `auto` is the default value and means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools before responding to the user. - Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. - - - `"none" or "auto" or "required"` - - `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user. - - - `"none"` - - - `"auto"` - - - `"required"` - - - `AssistantToolChoice = object { type, function }` - - Specifies a tool the model should use. Use to force the model to call a specific tool. - - - `type: "function" or "code_interpreter" or "file_search"` - - The type of the tool. If type is `function`, the function name must be set - - - `"function"` - - - `"code_interpreter"` - - - `"file_search"` - - - `function: optional AssistantToolChoiceFunction` - - - `name: string` - - The name of the function to call. - - - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool` - - The list of tools that the [assistant](/docs/api-reference/assistants) used for this run. - - - `CodeInterpreterTool = object { type }` - - - `type: "code_interpreter"` - - The type of tool being defined: `code_interpreter` - - - `"code_interpreter"` - - - `FileSearchTool = object { type, file_search }` - - - `type: "file_search"` - - The type of tool being defined: `file_search` - - - `"file_search"` - - - `file_search: optional object { max_num_results, ranking_options }` - - Overrides for the file search tool. - - - `max_num_results: optional number` - - The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. - - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `ranking_options: optional object { score_threshold, ranker }` - - The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. - - See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `score_threshold: number` - - The score threshold for the file search. All values must be a floating point number between 0 and 1. - - - `ranker: optional "auto" or "default_2024_08_21"` - - The ranker to use for the file search. If not specified will use the `auto` ranker. - - - `"auto"` - - - `"default_2024_08_21"` - - - `FunctionTool = object { function, type }` - - - `function: FunctionDefinition` - - - `name: string` - - The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - - - `description: optional string` - - A description of what the function does, used by the model to choose when and how to call the function. - - - `parameters: optional FunctionParameters` - - The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. - - Omitting `parameters` defines a function with an empty parameter list. - - - `strict: optional boolean` - - Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling). - - - `type: "function"` - - The type of tool being defined: `function` - - - `"function"` - - - `truncation_strategy: object { type, last_messages }` - - Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. - - - `type: "auto" or "last_messages"` - - The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`. - - - `"auto"` - - - `"last_messages"` - - - `last_messages: optional number` - - The number of most recent messages from the thread when constructing the context for the run. - - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - - Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). - - - `completion_tokens: number` - - Number of completion tokens used over the course of the run. - - - `prompt_tokens: number` - - Number of prompt tokens used over the course of the run. - - - `total_tokens: number` - - Total number of tokens used (prompt + completion). - - - `temperature: optional number` - - The sampling temperature used for this run. If not set, defaults to 1. - - - `top_p: optional number` - - The nucleus sampling value used for this run. If not set, defaults to 1. - - - `event: "thread.run.requires_action"` - - - `"thread.run.requires_action"` - - - `object { data, event }` - - Occurs when a [run](/docs/api-reference/runs/object) is completed. - - - `data: Run` - - Represents an execution run on a [thread](/docs/api-reference/threads). - - - `id: string` - - The identifier, which can be referenced in API endpoints. - - - `assistant_id: string` - - The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run. - - - `cancelled_at: number` - - The Unix timestamp (in seconds) for when the run was cancelled. - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the run was completed. - - - `created_at: number` - - The Unix timestamp (in seconds) for when the run was created. - - - `expires_at: number` - - The Unix timestamp (in seconds) for when the run will expire. - - - `failed_at: number` - - The Unix timestamp (in seconds) for when the run failed. - - - `incomplete_details: object { reason }` - - Details on why the run is incomplete. Will be `null` if the run is not incomplete. - - - `reason: optional "max_completion_tokens" or "max_prompt_tokens"` - - The 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_prompt_tokens"` - - - `instructions: string` - - The instructions that the [assistant](/docs/api-reference/assistants) used for this run. - - - `last_error: object { code, message }` - - The last error associated with this run. Will be `null` if there are no errors. - - - `code: "server_error" or "rate_limit_exceeded" or "invalid_prompt"` - - One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. - - - `"server_error"` - - - `"rate_limit_exceeded"` - - - `"invalid_prompt"` - - - `message: string` - - A human-readable description of the error. - - - `max_completion_tokens: number` - - The maximum number of completion tokens specified to have been used over the course of the run. - - - `max_prompt_tokens: number` - - The maximum number of prompt tokens specified to have been used over the course of the run. - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `model: string` - - The model that the [assistant](/docs/api-reference/assistants) used for this run. - - - `object: "thread.run"` - - The object type, which is always `thread.run`. - - - `"thread.run"` - - - `parallel_tool_calls: boolean` - - Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. - - - `required_action: object { submit_tool_outputs, type }` - - Details on the action required to continue the run. Will be `null` if no action is required. - - - `submit_tool_outputs: object { tool_calls }` - - Details on the tool outputs needed for this run to continue. - - - `tool_calls: array of RequiredActionFunctionToolCall` - - A list of the relevant tool calls. - - - `id: string` - - The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint. - - - `function: object { arguments, name }` - - The function definition. - - - `arguments: string` - - The arguments that the model expects you to pass to the function. - - - `name: string` - - The name of the function. - - - `type: "function"` - - The type of tool call the output is required for. For now, this is always `function`. - - - `"function"` - - - `type: "submit_tool_outputs"` - - For now, this is always `submit_tool_outputs`. - - - `"submit_tool_outputs"` - - - `response_format: AssistantResponseFormatOption` - - Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), 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](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - - - `"auto"` - - `auto` is the default value - - - `"auto"` - - - `ResponseFormatText = object { type }` - - Default response format. Used to generate text responses. - - - `type: "text"` - - The type of response format being defined. Always `text`. - - - `"text"` - - - `ResponseFormatJSONObject = object { type }` - - JSON object response format. An older method of generating JSON responses. - Using `json_schema` is recommended for models that support it. Note that the - model will not generate JSON without a system or user message instructing it - to do so. - - - `type: "json_object"` - - The type of response format being defined. Always `json_object`. - - - `"json_object"` - - - `ResponseFormatJSONSchema = object { json_schema, type }` - - JSON Schema response format. Used to generate structured JSON responses. - Learn more about [Structured Outputs](/docs/guides/structured-outputs). - - - `json_schema: object { name, description, schema, strict }` - - Structured Outputs configuration options, including a JSON Schema. - - - `name: string` - - The name of the response format. Must be a-z, A-Z, 0-9, or contain - underscores and dashes, with a maximum length of 64. - - - `description: optional string` - - A description of what the response format is for, used by the model to - determine how to respond in the format. - - - `schema: optional map[unknown]` - - The schema for the response format, described as a JSON Schema object. - Learn how to build JSON schemas [here](https://json-schema.org/). - - - `strict: optional boolean` - - Whether to enable strict schema adherence when generating the output. - If set to true, the model will always follow the exact schema defined - in the `schema` field. Only a subset of JSON Schema is supported when - `strict` is `true`. To learn more, read the [Structured Outputs - guide](/docs/guides/structured-outputs). - - - `type: "json_schema"` - - The type of response format being defined. Always `json_schema`. - - - `"json_schema"` - - - `started_at: number` - - The Unix timestamp (in seconds) for when the run was started. - - - `status: "queued" or "in_progress" or "requires_action" or 6 more` - - The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. - - - `"queued"` - - - `"in_progress"` - - - `"requires_action"` - - - `"cancelling"` - - - `"cancelled"` - - - `"failed"` - - - `"completed"` - - - `"incomplete"` - - - `"expired"` - - - `thread_id: string` - - The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run. - - - `tool_choice: AssistantToolChoiceOption` - - Controls which (if any) tool is called by the model. - `none` means the model will not call any tools and instead generates a message. - `auto` is the default value and means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools before responding to the user. - Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. - - - `"none" or "auto" or "required"` - - `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user. - - - `"none"` - - - `"auto"` - - - `"required"` - - - `AssistantToolChoice = object { type, function }` - - Specifies a tool the model should use. Use to force the model to call a specific tool. - - - `type: "function" or "code_interpreter" or "file_search"` - - The type of the tool. If type is `function`, the function name must be set - - - `"function"` - - - `"code_interpreter"` - - - `"file_search"` - - - `function: optional AssistantToolChoiceFunction` - - - `name: string` - - The name of the function to call. - - - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool` - - The list of tools that the [assistant](/docs/api-reference/assistants) used for this run. - - - `CodeInterpreterTool = object { type }` - - - `type: "code_interpreter"` - - The type of tool being defined: `code_interpreter` - - - `"code_interpreter"` - - - `FileSearchTool = object { type, file_search }` - - - `type: "file_search"` - - The type of tool being defined: `file_search` - - - `"file_search"` - - - `file_search: optional object { max_num_results, ranking_options }` - - Overrides for the file search tool. - - - `max_num_results: optional number` - - The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. - - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `ranking_options: optional object { score_threshold, ranker }` - - The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. - - See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `score_threshold: number` - - The score threshold for the file search. All values must be a floating point number between 0 and 1. - - - `ranker: optional "auto" or "default_2024_08_21"` - - The ranker to use for the file search. If not specified will use the `auto` ranker. - - - `"auto"` - - - `"default_2024_08_21"` - - - `FunctionTool = object { function, type }` - - - `function: FunctionDefinition` - - - `name: string` - - The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - - - `description: optional string` - - A description of what the function does, used by the model to choose when and how to call the function. - - - `parameters: optional FunctionParameters` - - The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. - - Omitting `parameters` defines a function with an empty parameter list. - - - `strict: optional boolean` - - Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling). - - - `type: "function"` - - The type of tool being defined: `function` - - - `"function"` - - - `truncation_strategy: object { type, last_messages }` - - Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. - - - `type: "auto" or "last_messages"` - - The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`. - - - `"auto"` - - - `"last_messages"` - - - `last_messages: optional number` - - The number of most recent messages from the thread when constructing the context for the run. - - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - - Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). - - - `completion_tokens: number` - - Number of completion tokens used over the course of the run. - - - `prompt_tokens: number` - - Number of prompt tokens used over the course of the run. - - - `total_tokens: number` - - Total number of tokens used (prompt + completion). - - - `temperature: optional number` - - The sampling temperature used for this run. If not set, defaults to 1. - - - `top_p: optional number` - - The nucleus sampling value used for this run. If not set, defaults to 1. - - - `event: "thread.run.completed"` - - - `"thread.run.completed"` - - - `object { data, event }` - - Occurs when a [run](/docs/api-reference/runs/object) ends with status `incomplete`. - - - `data: Run` - - Represents an execution run on a [thread](/docs/api-reference/threads). - - - `id: string` - - The identifier, which can be referenced in API endpoints. - - - `assistant_id: string` - - The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run. - - - `cancelled_at: number` - - The Unix timestamp (in seconds) for when the run was cancelled. - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the run was completed. - - - `created_at: number` - - The Unix timestamp (in seconds) for when the run was created. - - - `expires_at: number` - - The Unix timestamp (in seconds) for when the run will expire. - - - `failed_at: number` - - The Unix timestamp (in seconds) for when the run failed. - - - `incomplete_details: object { reason }` - - Details on why the run is incomplete. Will be `null` if the run is not incomplete. - - - `reason: optional "max_completion_tokens" or "max_prompt_tokens"` - - The 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_prompt_tokens"` - - - `instructions: string` - - The instructions that the [assistant](/docs/api-reference/assistants) used for this run. - - - `last_error: object { code, message }` - - The last error associated with this run. Will be `null` if there are no errors. - - - `code: "server_error" or "rate_limit_exceeded" or "invalid_prompt"` - - One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. - - - `"server_error"` - - - `"rate_limit_exceeded"` - - - `"invalid_prompt"` - - - `message: string` - - A human-readable description of the error. - - - `max_completion_tokens: number` - - The maximum number of completion tokens specified to have been used over the course of the run. - - - `max_prompt_tokens: number` - - The maximum number of prompt tokens specified to have been used over the course of the run. - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `model: string` - - The model that the [assistant](/docs/api-reference/assistants) used for this run. - - - `object: "thread.run"` - - The object type, which is always `thread.run`. - - - `"thread.run"` - - - `parallel_tool_calls: boolean` - - Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. - - - `required_action: object { submit_tool_outputs, type }` - - Details on the action required to continue the run. Will be `null` if no action is required. - - - `submit_tool_outputs: object { tool_calls }` - - Details on the tool outputs needed for this run to continue. - - - `tool_calls: array of RequiredActionFunctionToolCall` - - A list of the relevant tool calls. - - - `id: string` - - The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint. - - - `function: object { arguments, name }` - - The function definition. - - - `arguments: string` - - The arguments that the model expects you to pass to the function. - - - `name: string` - - The name of the function. - - - `type: "function"` - - The type of tool call the output is required for. For now, this is always `function`. - - - `"function"` - - - `type: "submit_tool_outputs"` - - For now, this is always `submit_tool_outputs`. - - - `"submit_tool_outputs"` - - - `response_format: AssistantResponseFormatOption` - - Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), 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](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - - - `"auto"` - - `auto` is the default value - - - `"auto"` - - - `ResponseFormatText = object { type }` - - Default response format. Used to generate text responses. - - - `type: "text"` - - The type of response format being defined. Always `text`. - - - `"text"` - - - `ResponseFormatJSONObject = object { type }` - - JSON object response format. An older method of generating JSON responses. - Using `json_schema` is recommended for models that support it. Note that the - model will not generate JSON without a system or user message instructing it - to do so. - - - `type: "json_object"` - - The type of response format being defined. Always `json_object`. - - - `"json_object"` - - - `ResponseFormatJSONSchema = object { json_schema, type }` - - JSON Schema response format. Used to generate structured JSON responses. - Learn more about [Structured Outputs](/docs/guides/structured-outputs). - - - `json_schema: object { name, description, schema, strict }` - - Structured Outputs configuration options, including a JSON Schema. - - - `name: string` - - The name of the response format. Must be a-z, A-Z, 0-9, or contain - underscores and dashes, with a maximum length of 64. - - - `description: optional string` - - A description of what the response format is for, used by the model to - determine how to respond in the format. - - - `schema: optional map[unknown]` - - The schema for the response format, described as a JSON Schema object. - Learn how to build JSON schemas [here](https://json-schema.org/). - - - `strict: optional boolean` - - Whether to enable strict schema adherence when generating the output. - If set to true, the model will always follow the exact schema defined - in the `schema` field. Only a subset of JSON Schema is supported when - `strict` is `true`. To learn more, read the [Structured Outputs - guide](/docs/guides/structured-outputs). - - - `type: "json_schema"` - - The type of response format being defined. Always `json_schema`. - - - `"json_schema"` - - - `started_at: number` - - The Unix timestamp (in seconds) for when the run was started. - - - `status: "queued" or "in_progress" or "requires_action" or 6 more` - - The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. - - - `"queued"` - - - `"in_progress"` - - - `"requires_action"` - - - `"cancelling"` - - - `"cancelled"` - - - `"failed"` - - - `"completed"` - - - `"incomplete"` - - - `"expired"` - - - `thread_id: string` - - The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run. - - - `tool_choice: AssistantToolChoiceOption` - - Controls which (if any) tool is called by the model. - `none` means the model will not call any tools and instead generates a message. - `auto` is the default value and means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools before responding to the user. - Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. - - - `"none" or "auto" or "required"` - - `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user. - - - `"none"` - - - `"auto"` - - - `"required"` - - - `AssistantToolChoice = object { type, function }` - - Specifies a tool the model should use. Use to force the model to call a specific tool. - - - `type: "function" or "code_interpreter" or "file_search"` - - The type of the tool. If type is `function`, the function name must be set - - - `"function"` - - - `"code_interpreter"` - - - `"file_search"` - - - `function: optional AssistantToolChoiceFunction` - - - `name: string` - - The name of the function to call. - - - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool` - - The list of tools that the [assistant](/docs/api-reference/assistants) used for this run. - - - `CodeInterpreterTool = object { type }` - - - `type: "code_interpreter"` - - The type of tool being defined: `code_interpreter` - - - `"code_interpreter"` - - - `FileSearchTool = object { type, file_search }` - - - `type: "file_search"` - - The type of tool being defined: `file_search` - - - `"file_search"` - - - `file_search: optional object { max_num_results, ranking_options }` - - Overrides for the file search tool. - - - `max_num_results: optional number` - - The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. - - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `ranking_options: optional object { score_threshold, ranker }` - - The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. - - See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `score_threshold: number` - - The score threshold for the file search. All values must be a floating point number between 0 and 1. - - - `ranker: optional "auto" or "default_2024_08_21"` - - The ranker to use for the file search. If not specified will use the `auto` ranker. - - - `"auto"` - - - `"default_2024_08_21"` - - - `FunctionTool = object { function, type }` - - - `function: FunctionDefinition` - - - `name: string` - - The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - - - `description: optional string` - - A description of what the function does, used by the model to choose when and how to call the function. - - - `parameters: optional FunctionParameters` - - The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. - - Omitting `parameters` defines a function with an empty parameter list. - - - `strict: optional boolean` - - Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling). - - - `type: "function"` - - The type of tool being defined: `function` - - - `"function"` - - - `truncation_strategy: object { type, last_messages }` - - Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. - - - `type: "auto" or "last_messages"` - - The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`. - - - `"auto"` - - - `"last_messages"` - - - `last_messages: optional number` - - The number of most recent messages from the thread when constructing the context for the run. - - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - - Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). - - - `completion_tokens: number` - - Number of completion tokens used over the course of the run. - - - `prompt_tokens: number` - - Number of prompt tokens used over the course of the run. - - - `total_tokens: number` - - Total number of tokens used (prompt + completion). - - - `temperature: optional number` - - The sampling temperature used for this run. If not set, defaults to 1. - - - `top_p: optional number` - - The nucleus sampling value used for this run. If not set, defaults to 1. - - - `event: "thread.run.incomplete"` - - - `"thread.run.incomplete"` - - - `object { data, event }` - - Occurs when a [run](/docs/api-reference/runs/object) fails. - - - `data: Run` - - Represents an execution run on a [thread](/docs/api-reference/threads). - - - `id: string` - - The identifier, which can be referenced in API endpoints. - - - `assistant_id: string` - - The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run. - - - `cancelled_at: number` - - The Unix timestamp (in seconds) for when the run was cancelled. - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the run was completed. - - - `created_at: number` - - The Unix timestamp (in seconds) for when the run was created. - - - `expires_at: number` - - The Unix timestamp (in seconds) for when the run will expire. - - - `failed_at: number` - - The Unix timestamp (in seconds) for when the run failed. - - - `incomplete_details: object { reason }` - - Details on why the run is incomplete. Will be `null` if the run is not incomplete. - - - `reason: optional "max_completion_tokens" or "max_prompt_tokens"` - - The 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_prompt_tokens"` - - - `instructions: string` - - The instructions that the [assistant](/docs/api-reference/assistants) used for this run. - - - `last_error: object { code, message }` - - The last error associated with this run. Will be `null` if there are no errors. - - - `code: "server_error" or "rate_limit_exceeded" or "invalid_prompt"` - - One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. - - - `"server_error"` - - - `"rate_limit_exceeded"` - - - `"invalid_prompt"` - - - `message: string` - - A human-readable description of the error. - - - `max_completion_tokens: number` - - The maximum number of completion tokens specified to have been used over the course of the run. - - - `max_prompt_tokens: number` - - The maximum number of prompt tokens specified to have been used over the course of the run. - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `model: string` - - The model that the [assistant](/docs/api-reference/assistants) used for this run. - - - `object: "thread.run"` - - The object type, which is always `thread.run`. - - - `"thread.run"` - - - `parallel_tool_calls: boolean` - - Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. - - - `required_action: object { submit_tool_outputs, type }` - - Details on the action required to continue the run. Will be `null` if no action is required. - - - `submit_tool_outputs: object { tool_calls }` - - Details on the tool outputs needed for this run to continue. - - - `tool_calls: array of RequiredActionFunctionToolCall` - - A list of the relevant tool calls. - - - `id: string` - - The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint. - - - `function: object { arguments, name }` - - The function definition. - - - `arguments: string` - - The arguments that the model expects you to pass to the function. - - - `name: string` - - The name of the function. - - - `type: "function"` - - The type of tool call the output is required for. For now, this is always `function`. - - - `"function"` - - - `type: "submit_tool_outputs"` - - For now, this is always `submit_tool_outputs`. - - - `"submit_tool_outputs"` - - - `response_format: AssistantResponseFormatOption` - - Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), 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](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - - - `"auto"` - - `auto` is the default value - - - `"auto"` - - - `ResponseFormatText = object { type }` - - Default response format. Used to generate text responses. - - - `type: "text"` - - The type of response format being defined. Always `text`. - - - `"text"` - - - `ResponseFormatJSONObject = object { type }` - - JSON object response format. An older method of generating JSON responses. - Using `json_schema` is recommended for models that support it. Note that the - model will not generate JSON without a system or user message instructing it - to do so. - - - `type: "json_object"` - - The type of response format being defined. Always `json_object`. - - - `"json_object"` - - - `ResponseFormatJSONSchema = object { json_schema, type }` - - JSON Schema response format. Used to generate structured JSON responses. - Learn more about [Structured Outputs](/docs/guides/structured-outputs). - - - `json_schema: object { name, description, schema, strict }` - - Structured Outputs configuration options, including a JSON Schema. - - - `name: string` - - The name of the response format. Must be a-z, A-Z, 0-9, or contain - underscores and dashes, with a maximum length of 64. - - - `description: optional string` - - A description of what the response format is for, used by the model to - determine how to respond in the format. - - - `schema: optional map[unknown]` - - The schema for the response format, described as a JSON Schema object. - Learn how to build JSON schemas [here](https://json-schema.org/). - - - `strict: optional boolean` - - Whether to enable strict schema adherence when generating the output. - If set to true, the model will always follow the exact schema defined - in the `schema` field. Only a subset of JSON Schema is supported when - `strict` is `true`. To learn more, read the [Structured Outputs - guide](/docs/guides/structured-outputs). - - - `type: "json_schema"` - - The type of response format being defined. Always `json_schema`. - - - `"json_schema"` - - - `started_at: number` - - The Unix timestamp (in seconds) for when the run was started. - - - `status: "queued" or "in_progress" or "requires_action" or 6 more` - - The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. - - - `"queued"` - - - `"in_progress"` - - - `"requires_action"` - - - `"cancelling"` - - - `"cancelled"` - - - `"failed"` - - - `"completed"` - - - `"incomplete"` - - - `"expired"` - - - `thread_id: string` - - The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run. - - - `tool_choice: AssistantToolChoiceOption` - - Controls which (if any) tool is called by the model. - `none` means the model will not call any tools and instead generates a message. - `auto` is the default value and means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools before responding to the user. - Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. - - - `"none" or "auto" or "required"` - - `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user. - - - `"none"` - - - `"auto"` - - - `"required"` - - - `AssistantToolChoice = object { type, function }` - - Specifies a tool the model should use. Use to force the model to call a specific tool. - - - `type: "function" or "code_interpreter" or "file_search"` - - The type of the tool. If type is `function`, the function name must be set - - - `"function"` - - - `"code_interpreter"` - - - `"file_search"` - - - `function: optional AssistantToolChoiceFunction` - - - `name: string` - - The name of the function to call. - - - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool` - - The list of tools that the [assistant](/docs/api-reference/assistants) used for this run. - - - `CodeInterpreterTool = object { type }` - - - `type: "code_interpreter"` - - The type of tool being defined: `code_interpreter` - - - `"code_interpreter"` - - - `FileSearchTool = object { type, file_search }` - - - `type: "file_search"` - - The type of tool being defined: `file_search` - - - `"file_search"` - - - `file_search: optional object { max_num_results, ranking_options }` - - Overrides for the file search tool. - - - `max_num_results: optional number` - - The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. - - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `ranking_options: optional object { score_threshold, ranker }` - - The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. - - See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `score_threshold: number` - - The score threshold for the file search. All values must be a floating point number between 0 and 1. - - - `ranker: optional "auto" or "default_2024_08_21"` - - The ranker to use for the file search. If not specified will use the `auto` ranker. - - - `"auto"` - - - `"default_2024_08_21"` - - - `FunctionTool = object { function, type }` - - - `function: FunctionDefinition` - - - `name: string` - - The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - - - `description: optional string` - - A description of what the function does, used by the model to choose when and how to call the function. - - - `parameters: optional FunctionParameters` - - The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. - - Omitting `parameters` defines a function with an empty parameter list. - - - `strict: optional boolean` - - Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling). - - - `type: "function"` - - The type of tool being defined: `function` - - - `"function"` - - - `truncation_strategy: object { type, last_messages }` - - Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. - - - `type: "auto" or "last_messages"` - - The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`. - - - `"auto"` - - - `"last_messages"` - - - `last_messages: optional number` - - The number of most recent messages from the thread when constructing the context for the run. - - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - - Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). - - - `completion_tokens: number` - - Number of completion tokens used over the course of the run. - - - `prompt_tokens: number` - - Number of prompt tokens used over the course of the run. - - - `total_tokens: number` - - Total number of tokens used (prompt + completion). - - - `temperature: optional number` - - The sampling temperature used for this run. If not set, defaults to 1. - - - `top_p: optional number` - - The nucleus sampling value used for this run. If not set, defaults to 1. - - - `event: "thread.run.failed"` - - - `"thread.run.failed"` - - - `object { data, event }` - - Occurs when a [run](/docs/api-reference/runs/object) moves to a `cancelling` status. - - - `data: Run` - - Represents an execution run on a [thread](/docs/api-reference/threads). - - - `id: string` - - The identifier, which can be referenced in API endpoints. - - - `assistant_id: string` - - The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run. - - - `cancelled_at: number` - - The Unix timestamp (in seconds) for when the run was cancelled. - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the run was completed. - - - `created_at: number` - - The Unix timestamp (in seconds) for when the run was created. - - - `expires_at: number` - - The Unix timestamp (in seconds) for when the run will expire. - - - `failed_at: number` - - The Unix timestamp (in seconds) for when the run failed. - - - `incomplete_details: object { reason }` - - Details on why the run is incomplete. Will be `null` if the run is not incomplete. - - - `reason: optional "max_completion_tokens" or "max_prompt_tokens"` - - The 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_prompt_tokens"` - - - `instructions: string` - - The instructions that the [assistant](/docs/api-reference/assistants) used for this run. - - - `last_error: object { code, message }` - - The last error associated with this run. Will be `null` if there are no errors. - - - `code: "server_error" or "rate_limit_exceeded" or "invalid_prompt"` - - One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. - - - `"server_error"` - - - `"rate_limit_exceeded"` - - - `"invalid_prompt"` - - - `message: string` - - A human-readable description of the error. - - - `max_completion_tokens: number` - - The maximum number of completion tokens specified to have been used over the course of the run. - - - `max_prompt_tokens: number` - - The maximum number of prompt tokens specified to have been used over the course of the run. - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `model: string` - - The model that the [assistant](/docs/api-reference/assistants) used for this run. - - - `object: "thread.run"` - - The object type, which is always `thread.run`. - - - `"thread.run"` - - - `parallel_tool_calls: boolean` - - Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. - - - `required_action: object { submit_tool_outputs, type }` - - Details on the action required to continue the run. Will be `null` if no action is required. - - - `submit_tool_outputs: object { tool_calls }` - - Details on the tool outputs needed for this run to continue. - - - `tool_calls: array of RequiredActionFunctionToolCall` - - A list of the relevant tool calls. - - - `id: string` - - The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint. - - - `function: object { arguments, name }` - - The function definition. - - - `arguments: string` - - The arguments that the model expects you to pass to the function. - - - `name: string` - - The name of the function. - - - `type: "function"` - - The type of tool call the output is required for. For now, this is always `function`. - - - `"function"` - - - `type: "submit_tool_outputs"` - - For now, this is always `submit_tool_outputs`. - - - `"submit_tool_outputs"` - - - `response_format: AssistantResponseFormatOption` - - Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), 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](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - - - `"auto"` - - `auto` is the default value - - - `"auto"` - - - `ResponseFormatText = object { type }` - - Default response format. Used to generate text responses. - - - `type: "text"` - - The type of response format being defined. Always `text`. - - - `"text"` - - - `ResponseFormatJSONObject = object { type }` - - JSON object response format. An older method of generating JSON responses. - Using `json_schema` is recommended for models that support it. Note that the - model will not generate JSON without a system or user message instructing it - to do so. - - - `type: "json_object"` - - The type of response format being defined. Always `json_object`. - - - `"json_object"` - - - `ResponseFormatJSONSchema = object { json_schema, type }` - - JSON Schema response format. Used to generate structured JSON responses. - Learn more about [Structured Outputs](/docs/guides/structured-outputs). - - - `json_schema: object { name, description, schema, strict }` - - Structured Outputs configuration options, including a JSON Schema. - - - `name: string` - - The name of the response format. Must be a-z, A-Z, 0-9, or contain - underscores and dashes, with a maximum length of 64. - - - `description: optional string` - - A description of what the response format is for, used by the model to - determine how to respond in the format. - - - `schema: optional map[unknown]` - - The schema for the response format, described as a JSON Schema object. - Learn how to build JSON schemas [here](https://json-schema.org/). - - - `strict: optional boolean` - - Whether to enable strict schema adherence when generating the output. - If set to true, the model will always follow the exact schema defined - in the `schema` field. Only a subset of JSON Schema is supported when - `strict` is `true`. To learn more, read the [Structured Outputs - guide](/docs/guides/structured-outputs). - - - `type: "json_schema"` - - The type of response format being defined. Always `json_schema`. - - - `"json_schema"` - - - `started_at: number` - - The Unix timestamp (in seconds) for when the run was started. - - - `status: "queued" or "in_progress" or "requires_action" or 6 more` - - The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. - - - `"queued"` - - - `"in_progress"` - - - `"requires_action"` - - - `"cancelling"` - - - `"cancelled"` - - - `"failed"` - - - `"completed"` - - - `"incomplete"` - - - `"expired"` - - - `thread_id: string` - - The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run. - - - `tool_choice: AssistantToolChoiceOption` - - Controls which (if any) tool is called by the model. - `none` means the model will not call any tools and instead generates a message. - `auto` is the default value and means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools before responding to the user. - Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. - - - `"none" or "auto" or "required"` - - `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user. - - - `"none"` - - - `"auto"` - - - `"required"` - - - `AssistantToolChoice = object { type, function }` - - Specifies a tool the model should use. Use to force the model to call a specific tool. - - - `type: "function" or "code_interpreter" or "file_search"` - - The type of the tool. If type is `function`, the function name must be set - - - `"function"` - - - `"code_interpreter"` - - - `"file_search"` - - - `function: optional AssistantToolChoiceFunction` - - - `name: string` - - The name of the function to call. - - - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool` - - The list of tools that the [assistant](/docs/api-reference/assistants) used for this run. - - - `CodeInterpreterTool = object { type }` - - - `type: "code_interpreter"` - - The type of tool being defined: `code_interpreter` - - - `"code_interpreter"` - - - `FileSearchTool = object { type, file_search }` - - - `type: "file_search"` - - The type of tool being defined: `file_search` - - - `"file_search"` - - - `file_search: optional object { max_num_results, ranking_options }` - - Overrides for the file search tool. - - - `max_num_results: optional number` - - The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. - - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `ranking_options: optional object { score_threshold, ranker }` - - The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. - - See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `score_threshold: number` - - The score threshold for the file search. All values must be a floating point number between 0 and 1. - - - `ranker: optional "auto" or "default_2024_08_21"` - - The ranker to use for the file search. If not specified will use the `auto` ranker. - - - `"auto"` - - - `"default_2024_08_21"` - - - `FunctionTool = object { function, type }` - - - `function: FunctionDefinition` - - - `name: string` - - The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - - - `description: optional string` - - A description of what the function does, used by the model to choose when and how to call the function. - - - `parameters: optional FunctionParameters` - - The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. - - Omitting `parameters` defines a function with an empty parameter list. - - - `strict: optional boolean` - - Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling). - - - `type: "function"` - - The type of tool being defined: `function` - - - `"function"` - - - `truncation_strategy: object { type, last_messages }` - - Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. - - - `type: "auto" or "last_messages"` - - The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`. - - - `"auto"` - - - `"last_messages"` - - - `last_messages: optional number` - - The number of most recent messages from the thread when constructing the context for the run. - - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - - Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). - - - `completion_tokens: number` - - Number of completion tokens used over the course of the run. - - - `prompt_tokens: number` - - Number of prompt tokens used over the course of the run. - - - `total_tokens: number` - - Total number of tokens used (prompt + completion). - - - `temperature: optional number` - - The sampling temperature used for this run. If not set, defaults to 1. - - - `top_p: optional number` - - The nucleus sampling value used for this run. If not set, defaults to 1. - - - `event: "thread.run.cancelling"` - - - `"thread.run.cancelling"` - - - `object { data, event }` - - Occurs when a [run](/docs/api-reference/runs/object) is cancelled. - - - `data: Run` - - Represents an execution run on a [thread](/docs/api-reference/threads). - - - `id: string` - - The identifier, which can be referenced in API endpoints. - - - `assistant_id: string` - - The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run. - - - `cancelled_at: number` - - The Unix timestamp (in seconds) for when the run was cancelled. - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the run was completed. - - - `created_at: number` - - The Unix timestamp (in seconds) for when the run was created. - - - `expires_at: number` - - The Unix timestamp (in seconds) for when the run will expire. - - - `failed_at: number` - - The Unix timestamp (in seconds) for when the run failed. - - - `incomplete_details: object { reason }` - - Details on why the run is incomplete. Will be `null` if the run is not incomplete. - - - `reason: optional "max_completion_tokens" or "max_prompt_tokens"` - - The 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_prompt_tokens"` - - - `instructions: string` - - The instructions that the [assistant](/docs/api-reference/assistants) used for this run. - - - `last_error: object { code, message }` - - The last error associated with this run. Will be `null` if there are no errors. - - - `code: "server_error" or "rate_limit_exceeded" or "invalid_prompt"` - - One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. - - - `"server_error"` - - - `"rate_limit_exceeded"` - - - `"invalid_prompt"` - - - `message: string` - - A human-readable description of the error. - - - `max_completion_tokens: number` - - The maximum number of completion tokens specified to have been used over the course of the run. - - - `max_prompt_tokens: number` - - The maximum number of prompt tokens specified to have been used over the course of the run. - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `model: string` - - The model that the [assistant](/docs/api-reference/assistants) used for this run. - - - `object: "thread.run"` - - The object type, which is always `thread.run`. - - - `"thread.run"` - - - `parallel_tool_calls: boolean` - - Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. - - - `required_action: object { submit_tool_outputs, type }` - - Details on the action required to continue the run. Will be `null` if no action is required. - - - `submit_tool_outputs: object { tool_calls }` - - Details on the tool outputs needed for this run to continue. - - - `tool_calls: array of RequiredActionFunctionToolCall` - - A list of the relevant tool calls. - - - `id: string` - - The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint. - - - `function: object { arguments, name }` - - The function definition. - - - `arguments: string` - - The arguments that the model expects you to pass to the function. - - - `name: string` - - The name of the function. - - - `type: "function"` - - The type of tool call the output is required for. For now, this is always `function`. - - - `"function"` - - - `type: "submit_tool_outputs"` - - For now, this is always `submit_tool_outputs`. - - - `"submit_tool_outputs"` - - - `response_format: AssistantResponseFormatOption` - - Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), 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](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - - - `"auto"` - - `auto` is the default value - - - `"auto"` - - - `ResponseFormatText = object { type }` - - Default response format. Used to generate text responses. - - - `type: "text"` - - The type of response format being defined. Always `text`. - - - `"text"` - - - `ResponseFormatJSONObject = object { type }` - - JSON object response format. An older method of generating JSON responses. - Using `json_schema` is recommended for models that support it. Note that the - model will not generate JSON without a system or user message instructing it - to do so. - - - `type: "json_object"` - - The type of response format being defined. Always `json_object`. - - - `"json_object"` - - - `ResponseFormatJSONSchema = object { json_schema, type }` - - JSON Schema response format. Used to generate structured JSON responses. - Learn more about [Structured Outputs](/docs/guides/structured-outputs). - - - `json_schema: object { name, description, schema, strict }` - - Structured Outputs configuration options, including a JSON Schema. - - - `name: string` - - The name of the response format. Must be a-z, A-Z, 0-9, or contain - underscores and dashes, with a maximum length of 64. - - - `description: optional string` - - A description of what the response format is for, used by the model to - determine how to respond in the format. - - - `schema: optional map[unknown]` - - The schema for the response format, described as a JSON Schema object. - Learn how to build JSON schemas [here](https://json-schema.org/). - - - `strict: optional boolean` - - Whether to enable strict schema adherence when generating the output. - If set to true, the model will always follow the exact schema defined - in the `schema` field. Only a subset of JSON Schema is supported when - `strict` is `true`. To learn more, read the [Structured Outputs - guide](/docs/guides/structured-outputs). - - - `type: "json_schema"` - - The type of response format being defined. Always `json_schema`. - - - `"json_schema"` - - - `started_at: number` - - The Unix timestamp (in seconds) for when the run was started. - - - `status: "queued" or "in_progress" or "requires_action" or 6 more` - - The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. - - - `"queued"` - - - `"in_progress"` - - - `"requires_action"` - - - `"cancelling"` - - - `"cancelled"` - - - `"failed"` - - - `"completed"` - - - `"incomplete"` - - - `"expired"` - - - `thread_id: string` - - The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run. - - - `tool_choice: AssistantToolChoiceOption` - - Controls which (if any) tool is called by the model. - `none` means the model will not call any tools and instead generates a message. - `auto` is the default value and means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools before responding to the user. - Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. - - - `"none" or "auto" or "required"` - - `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user. - - - `"none"` - - - `"auto"` - - - `"required"` - - - `AssistantToolChoice = object { type, function }` - - Specifies a tool the model should use. Use to force the model to call a specific tool. - - - `type: "function" or "code_interpreter" or "file_search"` - - The type of the tool. If type is `function`, the function name must be set - - - `"function"` - - - `"code_interpreter"` - - - `"file_search"` - - - `function: optional AssistantToolChoiceFunction` - - - `name: string` - - The name of the function to call. - - - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool` - - The list of tools that the [assistant](/docs/api-reference/assistants) used for this run. - - - `CodeInterpreterTool = object { type }` - - - `type: "code_interpreter"` - - The type of tool being defined: `code_interpreter` - - - `"code_interpreter"` - - - `FileSearchTool = object { type, file_search }` - - - `type: "file_search"` - - The type of tool being defined: `file_search` - - - `"file_search"` - - - `file_search: optional object { max_num_results, ranking_options }` - - Overrides for the file search tool. - - - `max_num_results: optional number` - - The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. - - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `ranking_options: optional object { score_threshold, ranker }` - - The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. - - See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `score_threshold: number` - - The score threshold for the file search. All values must be a floating point number between 0 and 1. - - - `ranker: optional "auto" or "default_2024_08_21"` - - The ranker to use for the file search. If not specified will use the `auto` ranker. - - - `"auto"` - - - `"default_2024_08_21"` - - - `FunctionTool = object { function, type }` - - - `function: FunctionDefinition` - - - `name: string` - - The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - - - `description: optional string` - - A description of what the function does, used by the model to choose when and how to call the function. - - - `parameters: optional FunctionParameters` - - The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. - - Omitting `parameters` defines a function with an empty parameter list. - - - `strict: optional boolean` - - Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling). - - - `type: "function"` - - The type of tool being defined: `function` - - - `"function"` - - - `truncation_strategy: object { type, last_messages }` - - Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. - - - `type: "auto" or "last_messages"` - - The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`. - - - `"auto"` - - - `"last_messages"` - - - `last_messages: optional number` - - The number of most recent messages from the thread when constructing the context for the run. - - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - - Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). - - - `completion_tokens: number` - - Number of completion tokens used over the course of the run. - - - `prompt_tokens: number` - - Number of prompt tokens used over the course of the run. - - - `total_tokens: number` - - Total number of tokens used (prompt + completion). - - - `temperature: optional number` - - The sampling temperature used for this run. If not set, defaults to 1. - - - `top_p: optional number` - - The nucleus sampling value used for this run. If not set, defaults to 1. - - - `event: "thread.run.cancelled"` - - - `"thread.run.cancelled"` - - - `object { data, event }` - - Occurs when a [run](/docs/api-reference/runs/object) expires. - - - `data: Run` - - Represents an execution run on a [thread](/docs/api-reference/threads). - - - `id: string` - - The identifier, which can be referenced in API endpoints. - - - `assistant_id: string` - - The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run. - - - `cancelled_at: number` - - The Unix timestamp (in seconds) for when the run was cancelled. - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the run was completed. - - - `created_at: number` - - The Unix timestamp (in seconds) for when the run was created. - - - `expires_at: number` - - The Unix timestamp (in seconds) for when the run will expire. - - - `failed_at: number` - - The Unix timestamp (in seconds) for when the run failed. - - - `incomplete_details: object { reason }` - - Details on why the run is incomplete. Will be `null` if the run is not incomplete. - - - `reason: optional "max_completion_tokens" or "max_prompt_tokens"` - - The 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_prompt_tokens"` - - - `instructions: string` - - The instructions that the [assistant](/docs/api-reference/assistants) used for this run. - - - `last_error: object { code, message }` - - The last error associated with this run. Will be `null` if there are no errors. - - - `code: "server_error" or "rate_limit_exceeded" or "invalid_prompt"` - - One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. - - - `"server_error"` - - - `"rate_limit_exceeded"` - - - `"invalid_prompt"` - - - `message: string` - - A human-readable description of the error. - - - `max_completion_tokens: number` - - The maximum number of completion tokens specified to have been used over the course of the run. - - - `max_prompt_tokens: number` - - The maximum number of prompt tokens specified to have been used over the course of the run. - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `model: string` - - The model that the [assistant](/docs/api-reference/assistants) used for this run. - - - `object: "thread.run"` - - The object type, which is always `thread.run`. - - - `"thread.run"` - - - `parallel_tool_calls: boolean` - - Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. - - - `required_action: object { submit_tool_outputs, type }` - - Details on the action required to continue the run. Will be `null` if no action is required. - - - `submit_tool_outputs: object { tool_calls }` - - Details on the tool outputs needed for this run to continue. - - - `tool_calls: array of RequiredActionFunctionToolCall` - - A list of the relevant tool calls. - - - `id: string` - - The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint. - - - `function: object { arguments, name }` - - The function definition. - - - `arguments: string` - - The arguments that the model expects you to pass to the function. - - - `name: string` - - The name of the function. - - - `type: "function"` - - The type of tool call the output is required for. For now, this is always `function`. - - - `"function"` - - - `type: "submit_tool_outputs"` - - For now, this is always `submit_tool_outputs`. - - - `"submit_tool_outputs"` - - - `response_format: AssistantResponseFormatOption` - - Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), 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](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - - - `"auto"` - - `auto` is the default value - - - `"auto"` - - - `ResponseFormatText = object { type }` - - Default response format. Used to generate text responses. - - - `type: "text"` - - The type of response format being defined. Always `text`. - - - `"text"` - - - `ResponseFormatJSONObject = object { type }` - - JSON object response format. An older method of generating JSON responses. - Using `json_schema` is recommended for models that support it. Note that the - model will not generate JSON without a system or user message instructing it - to do so. - - - `type: "json_object"` - - The type of response format being defined. Always `json_object`. - - - `"json_object"` - - - `ResponseFormatJSONSchema = object { json_schema, type }` - - JSON Schema response format. Used to generate structured JSON responses. - Learn more about [Structured Outputs](/docs/guides/structured-outputs). - - - `json_schema: object { name, description, schema, strict }` - - Structured Outputs configuration options, including a JSON Schema. - - - `name: string` - - The name of the response format. Must be a-z, A-Z, 0-9, or contain - underscores and dashes, with a maximum length of 64. - - - `description: optional string` - - A description of what the response format is for, used by the model to - determine how to respond in the format. - - - `schema: optional map[unknown]` - - The schema for the response format, described as a JSON Schema object. - Learn how to build JSON schemas [here](https://json-schema.org/). - - - `strict: optional boolean` - - Whether to enable strict schema adherence when generating the output. - If set to true, the model will always follow the exact schema defined - in the `schema` field. Only a subset of JSON Schema is supported when - `strict` is `true`. To learn more, read the [Structured Outputs - guide](/docs/guides/structured-outputs). - - - `type: "json_schema"` - - The type of response format being defined. Always `json_schema`. - - - `"json_schema"` - - - `started_at: number` - - The Unix timestamp (in seconds) for when the run was started. - - - `status: "queued" or "in_progress" or "requires_action" or 6 more` - - The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. - - - `"queued"` - - - `"in_progress"` - - - `"requires_action"` - - - `"cancelling"` - - - `"cancelled"` - - - `"failed"` - - - `"completed"` - - - `"incomplete"` - - - `"expired"` - - - `thread_id: string` - - The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run. - - - `tool_choice: AssistantToolChoiceOption` - - Controls which (if any) tool is called by the model. - `none` means the model will not call any tools and instead generates a message. - `auto` is the default value and means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools before responding to the user. - Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. - - - `"none" or "auto" or "required"` - - `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user. - - - `"none"` - - - `"auto"` - - - `"required"` - - - `AssistantToolChoice = object { type, function }` - - Specifies a tool the model should use. Use to force the model to call a specific tool. - - - `type: "function" or "code_interpreter" or "file_search"` - - The type of the tool. If type is `function`, the function name must be set - - - `"function"` - - - `"code_interpreter"` - - - `"file_search"` - - - `function: optional AssistantToolChoiceFunction` - - - `name: string` - - The name of the function to call. - - - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool` - - The list of tools that the [assistant](/docs/api-reference/assistants) used for this run. - - - `CodeInterpreterTool = object { type }` - - - `type: "code_interpreter"` - - The type of tool being defined: `code_interpreter` - - - `"code_interpreter"` - - - `FileSearchTool = object { type, file_search }` - - - `type: "file_search"` - - The type of tool being defined: `file_search` - - - `"file_search"` - - - `file_search: optional object { max_num_results, ranking_options }` - - Overrides for the file search tool. - - - `max_num_results: optional number` - - The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. - - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `ranking_options: optional object { score_threshold, ranker }` - - The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. - - See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `score_threshold: number` - - The score threshold for the file search. All values must be a floating point number between 0 and 1. - - - `ranker: optional "auto" or "default_2024_08_21"` - - The ranker to use for the file search. If not specified will use the `auto` ranker. - - - `"auto"` - - - `"default_2024_08_21"` - - - `FunctionTool = object { function, type }` - - - `function: FunctionDefinition` - - - `name: string` - - The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - - - `description: optional string` - - A description of what the function does, used by the model to choose when and how to call the function. - - - `parameters: optional FunctionParameters` - - The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. - - Omitting `parameters` defines a function with an empty parameter list. - - - `strict: optional boolean` - - Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling). - - - `type: "function"` - - The type of tool being defined: `function` - - - `"function"` - - - `truncation_strategy: object { type, last_messages }` - - Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. - - - `type: "auto" or "last_messages"` - - The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`. - - - `"auto"` - - - `"last_messages"` - - - `last_messages: optional number` - - The number of most recent messages from the thread when constructing the context for the run. - - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - - Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). - - - `completion_tokens: number` - - Number of completion tokens used over the course of the run. - - - `prompt_tokens: number` - - Number of prompt tokens used over the course of the run. - - - `total_tokens: number` - - Total number of tokens used (prompt + completion). - - - `temperature: optional number` - - The sampling temperature used for this run. If not set, defaults to 1. - - - `top_p: optional number` - - The nucleus sampling value used for this run. If not set, defaults to 1. - - - `event: "thread.run.expired"` - - - `"thread.run.expired"` - - - `object { data, event }` - - Occurs when a [run step](/docs/api-reference/run-steps/step-object) is created. - - - `data: RunStep` - - Represents a step in execution of a run. - - - `id: string` - - The identifier of the run step, which can be referenced in API endpoints. - - - `assistant_id: string` - - The ID of the [assistant](/docs/api-reference/assistants) associated with the run step. - - - `cancelled_at: number` - - The Unix timestamp (in seconds) for when the run step was cancelled. - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the run step completed. - - - `created_at: number` - - The Unix timestamp (in seconds) for when the run step was created. - - - `expired_at: number` - - The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired. - - - `failed_at: number` - - The Unix timestamp (in seconds) for when the run step failed. - - - `last_error: object { code, message }` - - The last error associated with this run step. Will be `null` if there are no errors. - - - `code: "server_error" or "rate_limit_exceeded"` - - One of `server_error` or `rate_limit_exceeded`. - - - `"server_error"` - - - `"rate_limit_exceeded"` - - - `message: string` - - A human-readable description of the error. - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `object: "thread.run.step"` - - The object type, which is always `thread.run.step`. - - - `"thread.run.step"` - - - `run_id: string` - - The ID of the [run](/docs/api-reference/runs) that this run step is a part of. - - - `status: "in_progress" or "cancelled" or "failed" or 2 more` - - The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`. - - - `"in_progress"` - - - `"cancelled"` - - - `"failed"` - - - `"completed"` - - - `"expired"` - - - `step_details: MessageCreationStepDetails or ToolCallsStepDetails` - - The details of the run step. - - - `MessageCreationStepDetails = object { message_creation, type }` - - Details of the message creation by the run step. - - - `message_creation: object { message_id }` - - - `message_id: string` - - The ID of the message that was created by this run step. - - - `type: "message_creation"` - - Always `message_creation`. - - - `"message_creation"` - - - `ToolCallsStepDetails = object { tool_calls, type }` - - Details of the tool call. - - - `tool_calls: array of CodeInterpreterToolCall or FileSearchToolCall or FunctionToolCall` - - An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. - - - `CodeInterpreterToolCall = object { id, code_interpreter, type }` - - Details of the Code Interpreter tool call the run step was involved in. - - - `id: string` - - The ID of the tool call. - - - `code_interpreter: object { input, outputs }` - - The Code Interpreter tool call definition. - - - `input: string` - - The input to the Code Interpreter tool call. - - - `outputs: array of object { logs, type } or object { image, type }` - - The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. - - - `CodeInterpreterLogOutput = object { logs, type }` - - Text output from the Code Interpreter tool call as part of a run step. - - - `logs: string` - - The text output from the Code Interpreter tool call. - - - `type: "logs"` - - Always `logs`. - - - `"logs"` - - - `CodeInterpreterImageOutput = object { image, type }` - - - `image: object { file_id }` - - - `file_id: string` - - The [file](/docs/api-reference/files) ID of the image. - - - `type: "image"` - - Always `image`. - - - `"image"` - - - `type: "code_interpreter"` - - The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - - - `"code_interpreter"` - - - `FileSearchToolCall = object { id, file_search, type }` - - - `id: string` - - The ID of the tool call object. - - - `file_search: object { ranking_options, results }` - - For now, this is always going to be an empty object. - - - `ranking_options: optional object { ranker, score_threshold }` - - The ranking options for the file search. - - - `ranker: "auto" or "default_2024_08_21"` - - The ranker to use for the file search. If not specified will use the `auto` ranker. - - - `"auto"` - - - `"default_2024_08_21"` - - - `score_threshold: number` - - The score threshold for the file search. All values must be a floating point number between 0 and 1. - - - `results: optional array of object { file_id, file_name, score, content }` - - The results of the file search. - - - `file_id: string` - - The ID of the file that result was found in. - - - `file_name: string` - - The name of the file that result was found in. - - - `score: number` - - The score of the result. All values must be a floating point number between 0 and 1. - - - `content: optional array of object { text, type }` - - The content of the result that was found. The content is only included if requested via the include query parameter. - - - `text: optional string` - - The text content of the file. - - - `type: optional "text"` - - The type of the content. - - - `"text"` - - - `type: "file_search"` - - The type of tool call. This is always going to be `file_search` for this type of tool call. - - - `"file_search"` - - - `FunctionToolCall = object { id, function, type }` - - - `id: string` - - The ID of the tool call object. - - - `function: object { arguments, name, output }` - - The definition of the function that was called. - - - `arguments: string` - - The arguments passed to the function. - - - `name: string` - - The name of the function. - - - `output: string` - - The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. - - - `type: "function"` - - The type of tool call. This is always going to be `function` for this type of tool call. - - - `"function"` - - - `type: "tool_calls"` - - Always `tool_calls`. - - - `"tool_calls"` - - - `thread_id: string` - - The ID of the [thread](/docs/api-reference/threads) that was run. - - - `type: "message_creation" or "tool_calls"` - - The type of run step, which can be either `message_creation` or `tool_calls`. - - - `"message_creation"` - - - `"tool_calls"` - - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - - Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. - - - `completion_tokens: number` - - Number of completion tokens used over the course of the run step. - - - `prompt_tokens: number` - - Number of prompt tokens used over the course of the run step. - - - `total_tokens: number` - - Total number of tokens used (prompt + completion). - - - `event: "thread.run.step.created"` - - - `"thread.run.step.created"` - - - `object { data, event }` - - Occurs when a [run step](/docs/api-reference/run-steps/step-object) moves to an `in_progress` state. - - - `data: RunStep` - - Represents a step in execution of a run. - - - `id: string` - - The identifier of the run step, which can be referenced in API endpoints. - - - `assistant_id: string` - - The ID of the [assistant](/docs/api-reference/assistants) associated with the run step. - - - `cancelled_at: number` - - The Unix timestamp (in seconds) for when the run step was cancelled. - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the run step completed. - - - `created_at: number` - - The Unix timestamp (in seconds) for when the run step was created. - - - `expired_at: number` - - The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired. - - - `failed_at: number` - - The Unix timestamp (in seconds) for when the run step failed. - - - `last_error: object { code, message }` - - The last error associated with this run step. Will be `null` if there are no errors. - - - `code: "server_error" or "rate_limit_exceeded"` - - One of `server_error` or `rate_limit_exceeded`. - - - `"server_error"` - - - `"rate_limit_exceeded"` - - - `message: string` - - A human-readable description of the error. - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `object: "thread.run.step"` - - The object type, which is always `thread.run.step`. - - - `"thread.run.step"` - - - `run_id: string` - - The ID of the [run](/docs/api-reference/runs) that this run step is a part of. - - - `status: "in_progress" or "cancelled" or "failed" or 2 more` - - The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`. - - - `"in_progress"` - - - `"cancelled"` - - - `"failed"` - - - `"completed"` - - - `"expired"` - - - `step_details: MessageCreationStepDetails or ToolCallsStepDetails` - - The details of the run step. - - - `MessageCreationStepDetails = object { message_creation, type }` - - Details of the message creation by the run step. - - - `message_creation: object { message_id }` - - - `message_id: string` - - The ID of the message that was created by this run step. - - - `type: "message_creation"` - - Always `message_creation`. - - - `"message_creation"` - - - `ToolCallsStepDetails = object { tool_calls, type }` - - Details of the tool call. - - - `tool_calls: array of CodeInterpreterToolCall or FileSearchToolCall or FunctionToolCall` - - An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. - - - `CodeInterpreterToolCall = object { id, code_interpreter, type }` - - Details of the Code Interpreter tool call the run step was involved in. - - - `id: string` - - The ID of the tool call. - - - `code_interpreter: object { input, outputs }` - - The Code Interpreter tool call definition. - - - `input: string` - - The input to the Code Interpreter tool call. - - - `outputs: array of object { logs, type } or object { image, type }` - - The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. - - - `CodeInterpreterLogOutput = object { logs, type }` - - Text output from the Code Interpreter tool call as part of a run step. - - - `logs: string` - - The text output from the Code Interpreter tool call. - - - `type: "logs"` - - Always `logs`. - - - `"logs"` - - - `CodeInterpreterImageOutput = object { image, type }` - - - `image: object { file_id }` - - - `file_id: string` - - The [file](/docs/api-reference/files) ID of the image. - - - `type: "image"` - - Always `image`. - - - `"image"` - - - `type: "code_interpreter"` - - The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - - - `"code_interpreter"` - - - `FileSearchToolCall = object { id, file_search, type }` - - - `id: string` - - The ID of the tool call object. - - - `file_search: object { ranking_options, results }` - - For now, this is always going to be an empty object. - - - `ranking_options: optional object { ranker, score_threshold }` - - The ranking options for the file search. - - - `ranker: "auto" or "default_2024_08_21"` - - The ranker to use for the file search. If not specified will use the `auto` ranker. - - - `"auto"` - - - `"default_2024_08_21"` - - - `score_threshold: number` - - The score threshold for the file search. All values must be a floating point number between 0 and 1. - - - `results: optional array of object { file_id, file_name, score, content }` - - The results of the file search. - - - `file_id: string` - - The ID of the file that result was found in. - - - `file_name: string` - - The name of the file that result was found in. - - - `score: number` - - The score of the result. All values must be a floating point number between 0 and 1. - - - `content: optional array of object { text, type }` - - The content of the result that was found. The content is only included if requested via the include query parameter. - - - `text: optional string` - - The text content of the file. - - - `type: optional "text"` - - The type of the content. - - - `"text"` - - - `type: "file_search"` - - The type of tool call. This is always going to be `file_search` for this type of tool call. - - - `"file_search"` - - - `FunctionToolCall = object { id, function, type }` - - - `id: string` - - The ID of the tool call object. - - - `function: object { arguments, name, output }` - - The definition of the function that was called. - - - `arguments: string` - - The arguments passed to the function. - - - `name: string` - - The name of the function. - - - `output: string` - - The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. - - - `type: "function"` - - The type of tool call. This is always going to be `function` for this type of tool call. - - - `"function"` - - - `type: "tool_calls"` - - Always `tool_calls`. - - - `"tool_calls"` - - - `thread_id: string` - - The ID of the [thread](/docs/api-reference/threads) that was run. - - - `type: "message_creation" or "tool_calls"` - - The type of run step, which can be either `message_creation` or `tool_calls`. - - - `"message_creation"` - - - `"tool_calls"` - - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - - Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. - - - `completion_tokens: number` - - Number of completion tokens used over the course of the run step. - - - `prompt_tokens: number` - - Number of prompt tokens used over the course of the run step. - - - `total_tokens: number` - - Total number of tokens used (prompt + completion). - - - `event: "thread.run.step.in_progress"` - - - `"thread.run.step.in_progress"` - - - `object { data, event }` - - Occurs when parts of a [run step](/docs/api-reference/run-steps/step-object) are being streamed. - - - `data: RunStepDeltaEvent` - - Represents a run step delta i.e. any changed fields on a run step during streaming. - - - `id: string` - - The identifier of the run step, which can be referenced in API endpoints. - - - `delta: object { step_details }` - - The delta containing the fields that have changed on the run step. - - - `step_details: optional RunStepDeltaMessageDelta or ToolCallDeltaObject` - - The details of the run step. - - - `RunStepDeltaMessageDelta = object { type, message_creation }` - - Details of the message creation by the run step. - - - `type: "message_creation"` - - Always `message_creation`. - - - `"message_creation"` - - - `message_creation: optional object { message_id }` - - - `message_id: optional string` - - The ID of the message that was created by this run step. - - - `ToolCallDeltaObject = object { type, tool_calls }` - - Details of the tool call. - - - `type: "tool_calls"` - - Always `tool_calls`. - - - `"tool_calls"` - - - `tool_calls: optional array of CodeInterpreterToolCallDelta or FileSearchToolCallDelta or FunctionToolCallDelta` - - An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. - - - `CodeInterpreterToolCallDelta = object { index, type, id, code_interpreter }` - - Details of the Code Interpreter tool call the run step was involved in. - - - `index: number` - - The index of the tool call in the tool calls array. - - - `type: "code_interpreter"` - - The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - - - `"code_interpreter"` - - - `id: optional string` - - The ID of the tool call. - - - `code_interpreter: optional object { input, outputs }` - - The Code Interpreter tool call definition. - - - `input: optional string` - - The input to the Code Interpreter tool call. - - - `outputs: optional array of CodeInterpreterLogs or CodeInterpreterOutputImage` - - The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. - - - `CodeInterpreterLogs = object { index, type, logs }` - - Text output from the Code Interpreter tool call as part of a run step. - - - `index: number` - - The index of the output in the outputs array. - - - `type: "logs"` - - Always `logs`. - - - `"logs"` - - - `logs: optional string` - - The text output from the Code Interpreter tool call. - - - `CodeInterpreterOutputImage = object { index, type, image }` - - - `index: number` - - The index of the output in the outputs array. - - - `type: "image"` - - Always `image`. - - - `"image"` - - - `image: optional object { file_id }` - - - `file_id: optional string` - - The [file](/docs/api-reference/files) ID of the image. - - - `FileSearchToolCallDelta = object { file_search, index, type, id }` - - - `file_search: unknown` - - For now, this is always going to be an empty object. - - - `index: number` - - The index of the tool call in the tool calls array. - - - `type: "file_search"` - - The type of tool call. This is always going to be `file_search` for this type of tool call. - - - `"file_search"` - - - `id: optional string` - - The ID of the tool call object. - - - `FunctionToolCallDelta = object { index, type, id, function }` - - - `index: number` - - The index of the tool call in the tool calls array. - - - `type: "function"` - - The type of tool call. This is always going to be `function` for this type of tool call. - - - `"function"` - - - `id: optional string` - - The ID of the tool call object. - - - `function: optional object { arguments, name, output }` - - The definition of the function that was called. - - - `arguments: optional string` - - The arguments passed to the function. - - - `name: optional string` - - The name of the function. - - - `output: optional string` - - The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. - - - `object: "thread.run.step.delta"` - - The object type, which is always `thread.run.step.delta`. - - - `"thread.run.step.delta"` - - - `event: "thread.run.step.delta"` - - - `"thread.run.step.delta"` - - - `object { data, event }` - - Occurs when a [run step](/docs/api-reference/run-steps/step-object) is completed. - - - `data: RunStep` - - Represents a step in execution of a run. - - - `id: string` - - The identifier of the run step, which can be referenced in API endpoints. - - - `assistant_id: string` - - The ID of the [assistant](/docs/api-reference/assistants) associated with the run step. - - - `cancelled_at: number` - - The Unix timestamp (in seconds) for when the run step was cancelled. - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the run step completed. - - - `created_at: number` - - The Unix timestamp (in seconds) for when the run step was created. - - - `expired_at: number` - - The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired. - - - `failed_at: number` - - The Unix timestamp (in seconds) for when the run step failed. - - - `last_error: object { code, message }` - - The last error associated with this run step. Will be `null` if there are no errors. - - - `code: "server_error" or "rate_limit_exceeded"` - - One of `server_error` or `rate_limit_exceeded`. - - - `"server_error"` - - - `"rate_limit_exceeded"` - - - `message: string` - - A human-readable description of the error. - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `object: "thread.run.step"` - - The object type, which is always `thread.run.step`. - - - `"thread.run.step"` - - - `run_id: string` - - The ID of the [run](/docs/api-reference/runs) that this run step is a part of. - - - `status: "in_progress" or "cancelled" or "failed" or 2 more` - - The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`. - - - `"in_progress"` - - - `"cancelled"` - - - `"failed"` - - - `"completed"` - - - `"expired"` - - - `step_details: MessageCreationStepDetails or ToolCallsStepDetails` - - The details of the run step. - - - `MessageCreationStepDetails = object { message_creation, type }` - - Details of the message creation by the run step. - - - `message_creation: object { message_id }` - - - `message_id: string` - - The ID of the message that was created by this run step. - - - `type: "message_creation"` - - Always `message_creation`. - - - `"message_creation"` - - - `ToolCallsStepDetails = object { tool_calls, type }` - - Details of the tool call. - - - `tool_calls: array of CodeInterpreterToolCall or FileSearchToolCall or FunctionToolCall` - - An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. - - - `CodeInterpreterToolCall = object { id, code_interpreter, type }` - - Details of the Code Interpreter tool call the run step was involved in. - - - `id: string` - - The ID of the tool call. - - - `code_interpreter: object { input, outputs }` - - The Code Interpreter tool call definition. - - - `input: string` - - The input to the Code Interpreter tool call. - - - `outputs: array of object { logs, type } or object { image, type }` - - The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. - - - `CodeInterpreterLogOutput = object { logs, type }` - - Text output from the Code Interpreter tool call as part of a run step. - - - `logs: string` - - The text output from the Code Interpreter tool call. - - - `type: "logs"` - - Always `logs`. - - - `"logs"` - - - `CodeInterpreterImageOutput = object { image, type }` - - - `image: object { file_id }` - - - `file_id: string` - - The [file](/docs/api-reference/files) ID of the image. - - - `type: "image"` - - Always `image`. - - - `"image"` - - - `type: "code_interpreter"` - - The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - - - `"code_interpreter"` - - - `FileSearchToolCall = object { id, file_search, type }` - - - `id: string` - - The ID of the tool call object. - - - `file_search: object { ranking_options, results }` - - For now, this is always going to be an empty object. - - - `ranking_options: optional object { ranker, score_threshold }` - - The ranking options for the file search. - - - `ranker: "auto" or "default_2024_08_21"` - - The ranker to use for the file search. If not specified will use the `auto` ranker. - - - `"auto"` - - - `"default_2024_08_21"` - - - `score_threshold: number` - - The score threshold for the file search. All values must be a floating point number between 0 and 1. - - - `results: optional array of object { file_id, file_name, score, content }` - - The results of the file search. - - - `file_id: string` - - The ID of the file that result was found in. - - - `file_name: string` - - The name of the file that result was found in. - - - `score: number` - - The score of the result. All values must be a floating point number between 0 and 1. - - - `content: optional array of object { text, type }` - - The content of the result that was found. The content is only included if requested via the include query parameter. - - - `text: optional string` - - The text content of the file. - - - `type: optional "text"` - - The type of the content. - - - `"text"` - - - `type: "file_search"` - - The type of tool call. This is always going to be `file_search` for this type of tool call. - - - `"file_search"` - - - `FunctionToolCall = object { id, function, type }` - - - `id: string` - - The ID of the tool call object. - - - `function: object { arguments, name, output }` - - The definition of the function that was called. - - - `arguments: string` - - The arguments passed to the function. - - - `name: string` - - The name of the function. - - - `output: string` - - The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. - - - `type: "function"` - - The type of tool call. This is always going to be `function` for this type of tool call. - - - `"function"` - - - `type: "tool_calls"` - - Always `tool_calls`. - - - `"tool_calls"` - - - `thread_id: string` - - The ID of the [thread](/docs/api-reference/threads) that was run. - - - `type: "message_creation" or "tool_calls"` - - The type of run step, which can be either `message_creation` or `tool_calls`. - - - `"message_creation"` - - - `"tool_calls"` - - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - - Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. - - - `completion_tokens: number` - - Number of completion tokens used over the course of the run step. - - - `prompt_tokens: number` - - Number of prompt tokens used over the course of the run step. - - - `total_tokens: number` - - Total number of tokens used (prompt + completion). - - - `event: "thread.run.step.completed"` - - - `"thread.run.step.completed"` - - - `object { data, event }` - - Occurs when a [run step](/docs/api-reference/run-steps/step-object) fails. - - - `data: RunStep` - - Represents a step in execution of a run. - - - `id: string` - - The identifier of the run step, which can be referenced in API endpoints. - - - `assistant_id: string` - - The ID of the [assistant](/docs/api-reference/assistants) associated with the run step. - - - `cancelled_at: number` - - The Unix timestamp (in seconds) for when the run step was cancelled. - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the run step completed. - - - `created_at: number` - - The Unix timestamp (in seconds) for when the run step was created. - - - `expired_at: number` - - The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired. - - - `failed_at: number` - - The Unix timestamp (in seconds) for when the run step failed. - - - `last_error: object { code, message }` - - The last error associated with this run step. Will be `null` if there are no errors. - - - `code: "server_error" or "rate_limit_exceeded"` - - One of `server_error` or `rate_limit_exceeded`. - - - `"server_error"` - - - `"rate_limit_exceeded"` - - - `message: string` - - A human-readable description of the error. - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `object: "thread.run.step"` - - The object type, which is always `thread.run.step`. - - - `"thread.run.step"` - - - `run_id: string` - - The ID of the [run](/docs/api-reference/runs) that this run step is a part of. - - - `status: "in_progress" or "cancelled" or "failed" or 2 more` - - The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`. - - - `"in_progress"` - - - `"cancelled"` - - - `"failed"` - - - `"completed"` - - - `"expired"` - - - `step_details: MessageCreationStepDetails or ToolCallsStepDetails` - - The details of the run step. - - - `MessageCreationStepDetails = object { message_creation, type }` - - Details of the message creation by the run step. - - - `message_creation: object { message_id }` - - - `message_id: string` - - The ID of the message that was created by this run step. - - - `type: "message_creation"` - - Always `message_creation`. - - - `"message_creation"` - - - `ToolCallsStepDetails = object { tool_calls, type }` - - Details of the tool call. - - - `tool_calls: array of CodeInterpreterToolCall or FileSearchToolCall or FunctionToolCall` - - An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. - - - `CodeInterpreterToolCall = object { id, code_interpreter, type }` - - Details of the Code Interpreter tool call the run step was involved in. - - - `id: string` - - The ID of the tool call. - - - `code_interpreter: object { input, outputs }` - - The Code Interpreter tool call definition. - - - `input: string` - - The input to the Code Interpreter tool call. - - - `outputs: array of object { logs, type } or object { image, type }` - - The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. - - - `CodeInterpreterLogOutput = object { logs, type }` - - Text output from the Code Interpreter tool call as part of a run step. - - - `logs: string` - - The text output from the Code Interpreter tool call. - - - `type: "logs"` - - Always `logs`. - - - `"logs"` - - - `CodeInterpreterImageOutput = object { image, type }` - - - `image: object { file_id }` - - - `file_id: string` - - The [file](/docs/api-reference/files) ID of the image. - - - `type: "image"` - - Always `image`. - - - `"image"` - - - `type: "code_interpreter"` - - The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - - - `"code_interpreter"` - - - `FileSearchToolCall = object { id, file_search, type }` - - - `id: string` - - The ID of the tool call object. - - - `file_search: object { ranking_options, results }` - - For now, this is always going to be an empty object. - - - `ranking_options: optional object { ranker, score_threshold }` - - The ranking options for the file search. - - - `ranker: "auto" or "default_2024_08_21"` - - The ranker to use for the file search. If not specified will use the `auto` ranker. - - - `"auto"` - - - `"default_2024_08_21"` - - - `score_threshold: number` - - The score threshold for the file search. All values must be a floating point number between 0 and 1. - - - `results: optional array of object { file_id, file_name, score, content }` - - The results of the file search. - - - `file_id: string` - - The ID of the file that result was found in. - - - `file_name: string` - - The name of the file that result was found in. - - - `score: number` - - The score of the result. All values must be a floating point number between 0 and 1. - - - `content: optional array of object { text, type }` - - The content of the result that was found. The content is only included if requested via the include query parameter. - - - `text: optional string` - - The text content of the file. - - - `type: optional "text"` - - The type of the content. - - - `"text"` - - - `type: "file_search"` - - The type of tool call. This is always going to be `file_search` for this type of tool call. - - - `"file_search"` - - - `FunctionToolCall = object { id, function, type }` - - - `id: string` - - The ID of the tool call object. - - - `function: object { arguments, name, output }` - - The definition of the function that was called. - - - `arguments: string` - - The arguments passed to the function. - - - `name: string` - - The name of the function. - - - `output: string` - - The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. - - - `type: "function"` - - The type of tool call. This is always going to be `function` for this type of tool call. - - - `"function"` - - - `type: "tool_calls"` - - Always `tool_calls`. - - - `"tool_calls"` - - - `thread_id: string` - - The ID of the [thread](/docs/api-reference/threads) that was run. - - - `type: "message_creation" or "tool_calls"` - - The type of run step, which can be either `message_creation` or `tool_calls`. - - - `"message_creation"` - - - `"tool_calls"` - - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - - Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. - - - `completion_tokens: number` - - Number of completion tokens used over the course of the run step. - - - `prompt_tokens: number` - - Number of prompt tokens used over the course of the run step. - - - `total_tokens: number` - - Total number of tokens used (prompt + completion). - - - `event: "thread.run.step.failed"` - - - `"thread.run.step.failed"` - - - `object { data, event }` - - Occurs when a [run step](/docs/api-reference/run-steps/step-object) is cancelled. - - - `data: RunStep` - - Represents a step in execution of a run. - - - `id: string` - - The identifier of the run step, which can be referenced in API endpoints. - - - `assistant_id: string` - - The ID of the [assistant](/docs/api-reference/assistants) associated with the run step. - - - `cancelled_at: number` - - The Unix timestamp (in seconds) for when the run step was cancelled. - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the run step completed. - - - `created_at: number` - - The Unix timestamp (in seconds) for when the run step was created. - - - `expired_at: number` - - The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired. - - - `failed_at: number` - - The Unix timestamp (in seconds) for when the run step failed. - - - `last_error: object { code, message }` - - The last error associated with this run step. Will be `null` if there are no errors. - - - `code: "server_error" or "rate_limit_exceeded"` - - One of `server_error` or `rate_limit_exceeded`. - - - `"server_error"` - - - `"rate_limit_exceeded"` - - - `message: string` - - A human-readable description of the error. - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `object: "thread.run.step"` - - The object type, which is always `thread.run.step`. - - - `"thread.run.step"` - - - `run_id: string` - - The ID of the [run](/docs/api-reference/runs) that this run step is a part of. - - - `status: "in_progress" or "cancelled" or "failed" or 2 more` - - The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`. - - - `"in_progress"` - - - `"cancelled"` - - - `"failed"` - - - `"completed"` - - - `"expired"` - - - `step_details: MessageCreationStepDetails or ToolCallsStepDetails` - - The details of the run step. - - - `MessageCreationStepDetails = object { message_creation, type }` - - Details of the message creation by the run step. - - - `message_creation: object { message_id }` - - - `message_id: string` - - The ID of the message that was created by this run step. - - - `type: "message_creation"` - - Always `message_creation`. - - - `"message_creation"` - - - `ToolCallsStepDetails = object { tool_calls, type }` - - Details of the tool call. - - - `tool_calls: array of CodeInterpreterToolCall or FileSearchToolCall or FunctionToolCall` - - An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. - - - `CodeInterpreterToolCall = object { id, code_interpreter, type }` - - Details of the Code Interpreter tool call the run step was involved in. - - - `id: string` - - The ID of the tool call. - - - `code_interpreter: object { input, outputs }` - - The Code Interpreter tool call definition. - - - `input: string` - - The input to the Code Interpreter tool call. - - - `outputs: array of object { logs, type } or object { image, type }` - - The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. - - - `CodeInterpreterLogOutput = object { logs, type }` - - Text output from the Code Interpreter tool call as part of a run step. - - - `logs: string` - - The text output from the Code Interpreter tool call. - - - `type: "logs"` - - Always `logs`. - - - `"logs"` - - - `CodeInterpreterImageOutput = object { image, type }` - - - `image: object { file_id }` - - - `file_id: string` - - The [file](/docs/api-reference/files) ID of the image. - - - `type: "image"` - - Always `image`. - - - `"image"` - - - `type: "code_interpreter"` - - The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - - - `"code_interpreter"` - - - `FileSearchToolCall = object { id, file_search, type }` - - - `id: string` - - The ID of the tool call object. - - - `file_search: object { ranking_options, results }` - - For now, this is always going to be an empty object. - - - `ranking_options: optional object { ranker, score_threshold }` - - The ranking options for the file search. - - - `ranker: "auto" or "default_2024_08_21"` - - The ranker to use for the file search. If not specified will use the `auto` ranker. - - - `"auto"` - - - `"default_2024_08_21"` - - - `score_threshold: number` - - The score threshold for the file search. All values must be a floating point number between 0 and 1. - - - `results: optional array of object { file_id, file_name, score, content }` - - The results of the file search. - - - `file_id: string` - - The ID of the file that result was found in. - - - `file_name: string` - - The name of the file that result was found in. - - - `score: number` - - The score of the result. All values must be a floating point number between 0 and 1. - - - `content: optional array of object { text, type }` - - The content of the result that was found. The content is only included if requested via the include query parameter. - - - `text: optional string` - - The text content of the file. - - - `type: optional "text"` - - The type of the content. - - - `"text"` - - - `type: "file_search"` - - The type of tool call. This is always going to be `file_search` for this type of tool call. - - - `"file_search"` - - - `FunctionToolCall = object { id, function, type }` - - - `id: string` - - The ID of the tool call object. - - - `function: object { arguments, name, output }` - - The definition of the function that was called. - - - `arguments: string` - - The arguments passed to the function. - - - `name: string` - - The name of the function. - - - `output: string` - - The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. - - - `type: "function"` - - The type of tool call. This is always going to be `function` for this type of tool call. - - - `"function"` - - - `type: "tool_calls"` - - Always `tool_calls`. - - - `"tool_calls"` - - - `thread_id: string` - - The ID of the [thread](/docs/api-reference/threads) that was run. - - - `type: "message_creation" or "tool_calls"` - - The type of run step, which can be either `message_creation` or `tool_calls`. - - - `"message_creation"` - - - `"tool_calls"` - - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - - Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. - - - `completion_tokens: number` - - Number of completion tokens used over the course of the run step. - - - `prompt_tokens: number` - - Number of prompt tokens used over the course of the run step. - - - `total_tokens: number` - - Total number of tokens used (prompt + completion). - - - `event: "thread.run.step.cancelled"` - - - `"thread.run.step.cancelled"` - - - `object { data, event }` - - Occurs when a [run step](/docs/api-reference/run-steps/step-object) expires. - - - `data: RunStep` - - Represents a step in execution of a run. - - - `id: string` - - The identifier of the run step, which can be referenced in API endpoints. - - - `assistant_id: string` - - The ID of the [assistant](/docs/api-reference/assistants) associated with the run step. - - - `cancelled_at: number` - - The Unix timestamp (in seconds) for when the run step was cancelled. - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the run step completed. - - - `created_at: number` - - The Unix timestamp (in seconds) for when the run step was created. - - - `expired_at: number` - - The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired. - - - `failed_at: number` - - The Unix timestamp (in seconds) for when the run step failed. - - - `last_error: object { code, message }` - - The last error associated with this run step. Will be `null` if there are no errors. - - - `code: "server_error" or "rate_limit_exceeded"` - - One of `server_error` or `rate_limit_exceeded`. - - - `"server_error"` - - - `"rate_limit_exceeded"` - - - `message: string` - - A human-readable description of the error. - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `object: "thread.run.step"` - - The object type, which is always `thread.run.step`. - - - `"thread.run.step"` - - - `run_id: string` - - The ID of the [run](/docs/api-reference/runs) that this run step is a part of. - - - `status: "in_progress" or "cancelled" or "failed" or 2 more` - - The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`. - - - `"in_progress"` - - - `"cancelled"` - - - `"failed"` - - - `"completed"` - - - `"expired"` - - - `step_details: MessageCreationStepDetails or ToolCallsStepDetails` - - The details of the run step. - - - `MessageCreationStepDetails = object { message_creation, type }` - - Details of the message creation by the run step. - - - `message_creation: object { message_id }` - - - `message_id: string` - - The ID of the message that was created by this run step. - - - `type: "message_creation"` - - Always `message_creation`. - - - `"message_creation"` - - - `ToolCallsStepDetails = object { tool_calls, type }` - - Details of the tool call. - - - `tool_calls: array of CodeInterpreterToolCall or FileSearchToolCall or FunctionToolCall` - - An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. - - - `CodeInterpreterToolCall = object { id, code_interpreter, type }` - - Details of the Code Interpreter tool call the run step was involved in. - - - `id: string` - - The ID of the tool call. - - - `code_interpreter: object { input, outputs }` - - The Code Interpreter tool call definition. - - - `input: string` - - The input to the Code Interpreter tool call. - - - `outputs: array of object { logs, type } or object { image, type }` - - The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. - - - `CodeInterpreterLogOutput = object { logs, type }` - - Text output from the Code Interpreter tool call as part of a run step. - - - `logs: string` - - The text output from the Code Interpreter tool call. - - - `type: "logs"` - - Always `logs`. - - - `"logs"` - - - `CodeInterpreterImageOutput = object { image, type }` - - - `image: object { file_id }` - - - `file_id: string` - - The [file](/docs/api-reference/files) ID of the image. - - - `type: "image"` - - Always `image`. - - - `"image"` - - - `type: "code_interpreter"` - - The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - - - `"code_interpreter"` - - - `FileSearchToolCall = object { id, file_search, type }` - - - `id: string` - - The ID of the tool call object. - - - `file_search: object { ranking_options, results }` - - For now, this is always going to be an empty object. - - - `ranking_options: optional object { ranker, score_threshold }` - - The ranking options for the file search. - - - `ranker: "auto" or "default_2024_08_21"` - - The ranker to use for the file search. If not specified will use the `auto` ranker. - - - `"auto"` - - - `"default_2024_08_21"` - - - `score_threshold: number` - - The score threshold for the file search. All values must be a floating point number between 0 and 1. - - - `results: optional array of object { file_id, file_name, score, content }` - - The results of the file search. - - - `file_id: string` - - The ID of the file that result was found in. - - - `file_name: string` - - The name of the file that result was found in. - - - `score: number` - - The score of the result. All values must be a floating point number between 0 and 1. - - - `content: optional array of object { text, type }` - - The content of the result that was found. The content is only included if requested via the include query parameter. - - - `text: optional string` - - The text content of the file. - - - `type: optional "text"` - - The type of the content. - - - `"text"` - - - `type: "file_search"` - - The type of tool call. This is always going to be `file_search` for this type of tool call. - - - `"file_search"` - - - `FunctionToolCall = object { id, function, type }` - - - `id: string` - - The ID of the tool call object. - - - `function: object { arguments, name, output }` - - The definition of the function that was called. - - - `arguments: string` - - The arguments passed to the function. - - - `name: string` - - The name of the function. - - - `output: string` - - The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. - - - `type: "function"` - - The type of tool call. This is always going to be `function` for this type of tool call. - - - `"function"` - - - `type: "tool_calls"` - - Always `tool_calls`. - - - `"tool_calls"` - - - `thread_id: string` - - The ID of the [thread](/docs/api-reference/threads) that was run. - - - `type: "message_creation" or "tool_calls"` - - The type of run step, which can be either `message_creation` or `tool_calls`. - - - `"message_creation"` - - - `"tool_calls"` - - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - - Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. - - - `completion_tokens: number` - - Number of completion tokens used over the course of the run step. - - - `prompt_tokens: number` - - Number of prompt tokens used over the course of the run step. - - - `total_tokens: number` - - Total number of tokens used (prompt + completion). - - - `event: "thread.run.step.expired"` - - - `"thread.run.step.expired"` - - - `object { data, event }` - - Occurs when a [message](/docs/api-reference/messages/object) is created. - - - `data: Message` - - Represents a message within a [thread](/docs/api-reference/threads). - - - `id: string` - - The identifier, which can be referenced in API endpoints. - - - `assistant_id: string` - - If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message. - - - `attachments: array of object { file_id, tools }` - - A list of files attached to the message, and the tools they were added to. - - - `file_id: optional string` - - The ID of the file to attach to the message. - - - `tools: optional array of CodeInterpreterTool or object { type }` - - The tools to add this file to. - - - `CodeInterpreterTool = object { type }` - - - `type: "code_interpreter"` - - The type of tool being defined: `code_interpreter` - - - `"code_interpreter"` - - - `FileSearchTool = object { type }` - - - `type: "file_search"` - - The type of tool being defined: `file_search` - - - `"file_search"` - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the message was completed. - - - `content: array of ImageFileContentBlock or ImageURLContentBlock or TextContentBlock or RefusalContentBlock` - - The content of the message in array of text and/or images. - - - `ImageFileContentBlock = object { image_file, type }` - - References an image [File](/docs/api-reference/files) in the content of a message. - - - `image_file: ImageFile` - - - `file_id: string` - - The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. - - - `detail: optional "auto" or "low" or "high"` - - Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. - - - `"auto"` - - - `"low"` - - - `"high"` - - - `type: "image_file"` - - Always `image_file`. - - - `"image_file"` - - - `ImageURLContentBlock = object { image_url, type }` - - References an image URL in the content of a message. - - - `image_url: ImageURL` - - - `url: string` - - The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. - - - `detail: optional "auto" or "low" or "high"` - - Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` - - - `"auto"` - - - `"low"` - - - `"high"` - - - `type: "image_url"` - - The type of the content part. - - - `"image_url"` - - - `TextContentBlock = object { text, type }` - - The text content that is part of a message. - - - `text: Text` - - - `annotations: array of FileCitationAnnotation or FilePathAnnotation` - - - `FileCitationAnnotation = object { end_index, file_citation, start_index, 2 more }` - - 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. - - - `end_index: number` - - - `file_citation: object { file_id }` - - - `file_id: string` - - The ID of the specific File the citation is from. - - - `start_index: number` - - - `text: string` - - The text in the message content that needs to be replaced. - - - `type: "file_citation"` - - Always `file_citation`. - - - `"file_citation"` - - - `FilePathAnnotation = object { end_index, file_path, start_index, 2 more }` - - A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - - - `end_index: number` - - - `file_path: object { file_id }` - - - `file_id: string` - - The ID of the file that was generated. - - - `start_index: number` - - - `text: string` - - The text in the message content that needs to be replaced. - - - `type: "file_path"` - - Always `file_path`. - - - `"file_path"` - - - `value: string` - - The data that makes up the text. - - - `type: "text"` - - Always `text`. - - - `"text"` - - - `RefusalContentBlock = object { refusal, type }` - - The refusal content generated by the assistant. - - - `refusal: string` - - - `type: "refusal"` - - Always `refusal`. - - - `"refusal"` - - - `created_at: number` - - The Unix timestamp (in seconds) for when the message was created. - - - `incomplete_at: number` - - The Unix timestamp (in seconds) for when the message was marked as incomplete. - - - `incomplete_details: object { reason }` - - On an incomplete message, details about why the message is incomplete. - - - `reason: "content_filter" or "max_tokens" or "run_cancelled" or 2 more` - - The reason the message is incomplete. - - - `"content_filter"` - - - `"max_tokens"` - - - `"run_cancelled"` - - - `"run_expired"` - - - `"run_failed"` - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `object: "thread.message"` - - The object type, which is always `thread.message`. - - - `"thread.message"` - - - `role: "user" or "assistant"` - - The entity that produced the message. One of `user` or `assistant`. - - - `"user"` - - - `"assistant"` - - - `run_id: string` - - The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. - - - `status: "in_progress" or "incomplete" or "completed"` - - The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. - - - `"in_progress"` - - - `"incomplete"` - - - `"completed"` - - - `thread_id: string` - - The [thread](/docs/api-reference/threads) ID that this message belongs to. - - - `event: "thread.message.created"` - - - `"thread.message.created"` - - - `object { data, event }` - - Occurs when a [message](/docs/api-reference/messages/object) moves to an `in_progress` state. - - - `data: Message` - - Represents a message within a [thread](/docs/api-reference/threads). - - - `id: string` - - The identifier, which can be referenced in API endpoints. - - - `assistant_id: string` - - If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message. - - - `attachments: array of object { file_id, tools }` - - A list of files attached to the message, and the tools they were added to. - - - `file_id: optional string` - - The ID of the file to attach to the message. - - - `tools: optional array of CodeInterpreterTool or object { type }` - - The tools to add this file to. - - - `CodeInterpreterTool = object { type }` - - - `type: "code_interpreter"` - - The type of tool being defined: `code_interpreter` - - - `"code_interpreter"` - - - `FileSearchTool = object { type }` - - - `type: "file_search"` - - The type of tool being defined: `file_search` - - - `"file_search"` - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the message was completed. - - - `content: array of ImageFileContentBlock or ImageURLContentBlock or TextContentBlock or RefusalContentBlock` - - The content of the message in array of text and/or images. - - - `ImageFileContentBlock = object { image_file, type }` - - References an image [File](/docs/api-reference/files) in the content of a message. - - - `image_file: ImageFile` - - - `file_id: string` - - The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. - - - `detail: optional "auto" or "low" or "high"` - - Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. - - - `"auto"` - - - `"low"` - - - `"high"` - - - `type: "image_file"` - - Always `image_file`. - - - `"image_file"` - - - `ImageURLContentBlock = object { image_url, type }` - - References an image URL in the content of a message. - - - `image_url: ImageURL` - - - `url: string` - - The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. - - - `detail: optional "auto" or "low" or "high"` - - Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` - - - `"auto"` - - - `"low"` - - - `"high"` - - - `type: "image_url"` - - The type of the content part. - - - `"image_url"` - - - `TextContentBlock = object { text, type }` - - The text content that is part of a message. - - - `text: Text` - - - `annotations: array of FileCitationAnnotation or FilePathAnnotation` - - - `FileCitationAnnotation = object { end_index, file_citation, start_index, 2 more }` - - 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. - - - `end_index: number` - - - `file_citation: object { file_id }` - - - `file_id: string` - - The ID of the specific File the citation is from. - - - `start_index: number` - - - `text: string` - - The text in the message content that needs to be replaced. - - - `type: "file_citation"` - - Always `file_citation`. - - - `"file_citation"` - - - `FilePathAnnotation = object { end_index, file_path, start_index, 2 more }` - - A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - - - `end_index: number` - - - `file_path: object { file_id }` - - - `file_id: string` - - The ID of the file that was generated. - - - `start_index: number` - - - `text: string` - - The text in the message content that needs to be replaced. - - - `type: "file_path"` - - Always `file_path`. - - - `"file_path"` - - - `value: string` - - The data that makes up the text. - - - `type: "text"` - - Always `text`. - - - `"text"` - - - `RefusalContentBlock = object { refusal, type }` - - The refusal content generated by the assistant. - - - `refusal: string` - - - `type: "refusal"` - - Always `refusal`. - - - `"refusal"` - - - `created_at: number` - - The Unix timestamp (in seconds) for when the message was created. - - - `incomplete_at: number` - - The Unix timestamp (in seconds) for when the message was marked as incomplete. - - - `incomplete_details: object { reason }` - - On an incomplete message, details about why the message is incomplete. - - - `reason: "content_filter" or "max_tokens" or "run_cancelled" or 2 more` - - The reason the message is incomplete. - - - `"content_filter"` - - - `"max_tokens"` - - - `"run_cancelled"` - - - `"run_expired"` - - - `"run_failed"` - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `object: "thread.message"` - - The object type, which is always `thread.message`. - - - `"thread.message"` - - - `role: "user" or "assistant"` - - The entity that produced the message. One of `user` or `assistant`. - - - `"user"` - - - `"assistant"` - - - `run_id: string` - - The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. - - - `status: "in_progress" or "incomplete" or "completed"` - - The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. - - - `"in_progress"` - - - `"incomplete"` - - - `"completed"` - - - `thread_id: string` - - The [thread](/docs/api-reference/threads) ID that this message belongs to. - - - `event: "thread.message.in_progress"` - - - `"thread.message.in_progress"` - - - `object { data, event }` - - Occurs when parts of a [Message](/docs/api-reference/messages/object) are being streamed. - - - `data: MessageDeltaEvent` - - Represents a message delta i.e. any changed fields on a message during streaming. - - - `id: string` - - The identifier of the message, which can be referenced in API endpoints. - - - `delta: MessageDelta` - - The delta containing the fields that have changed on the Message. - - - `content: optional array of ImageFileDeltaBlock or TextDeltaBlock or RefusalDeltaBlock or ImageURLDeltaBlock` - - The content of the message in array of text and/or images. - - - `ImageFileDeltaBlock = object { index, type, image_file }` - - References an image [File](/docs/api-reference/files) in the content of a message. - - - `index: number` - - The index of the content part in the message. - - - `type: "image_file"` - - Always `image_file`. - - - `"image_file"` - - - `image_file: optional ImageFileDelta` - - - `detail: optional "auto" or "low" or "high"` - - Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. - - - `"auto"` - - - `"low"` - - - `"high"` - - - `file_id: optional string` - - The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. - - - `TextDeltaBlock = object { index, type, text }` - - The text content that is part of a message. - - - `index: number` - - The index of the content part in the message. - - - `type: "text"` - - Always `text`. - - - `"text"` - - - `text: optional TextDelta` - - - `annotations: optional array of FileCitationDeltaAnnotation or FilePathDeltaAnnotation` - - - `FileCitationDeltaAnnotation = object { index, type, end_index, 3 more }` - - 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. - - - `index: number` - - The index of the annotation in the text content part. - - - `type: "file_citation"` - - Always `file_citation`. - - - `"file_citation"` - - - `end_index: optional number` - - - `file_citation: optional object { file_id, quote }` - - - `file_id: optional string` - - The ID of the specific File the citation is from. - - - `quote: optional string` - - The specific quote in the file. - - - `start_index: optional number` - - - `text: optional string` - - The text in the message content that needs to be replaced. - - - `FilePathDeltaAnnotation = object { index, type, end_index, 3 more }` - - A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - - - `index: number` - - The index of the annotation in the text content part. - - - `type: "file_path"` - - Always `file_path`. - - - `"file_path"` - - - `end_index: optional number` - - - `file_path: optional object { file_id }` - - - `file_id: optional string` - - The ID of the file that was generated. - - - `start_index: optional number` - - - `text: optional string` - - The text in the message content that needs to be replaced. - - - `value: optional string` - - The data that makes up the text. - - - `RefusalDeltaBlock = object { index, type, refusal }` - - The refusal content that is part of a message. - - - `index: number` - - The index of the refusal part in the message. - - - `type: "refusal"` - - Always `refusal`. - - - `"refusal"` - - - `refusal: optional string` - - - `ImageURLDeltaBlock = object { index, type, image_url }` - - References an image URL in the content of a message. - - - `index: number` - - The index of the content part in the message. - - - `type: "image_url"` - - Always `image_url`. - - - `"image_url"` - - - `image_url: optional ImageURLDelta` - - - `detail: optional "auto" or "low" or "high"` - - Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. - - - `"auto"` - - - `"low"` - - - `"high"` - - - `url: optional string` - - The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. - - - `role: optional "user" or "assistant"` - - The entity that produced the message. One of `user` or `assistant`. - - - `"user"` - - - `"assistant"` - - - `object: "thread.message.delta"` - - The object type, which is always `thread.message.delta`. - - - `"thread.message.delta"` - - - `event: "thread.message.delta"` - - - `"thread.message.delta"` - - - `object { data, event }` - - Occurs when a [message](/docs/api-reference/messages/object) is completed. - - - `data: Message` - - Represents a message within a [thread](/docs/api-reference/threads). - - - `id: string` - - The identifier, which can be referenced in API endpoints. - - - `assistant_id: string` - - If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message. - - - `attachments: array of object { file_id, tools }` - - A list of files attached to the message, and the tools they were added to. - - - `file_id: optional string` - - The ID of the file to attach to the message. - - - `tools: optional array of CodeInterpreterTool or object { type }` - - The tools to add this file to. - - - `CodeInterpreterTool = object { type }` - - - `type: "code_interpreter"` - - The type of tool being defined: `code_interpreter` - - - `"code_interpreter"` - - - `FileSearchTool = object { type }` - - - `type: "file_search"` - - The type of tool being defined: `file_search` - - - `"file_search"` - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the message was completed. - - - `content: array of ImageFileContentBlock or ImageURLContentBlock or TextContentBlock or RefusalContentBlock` - - The content of the message in array of text and/or images. - - - `ImageFileContentBlock = object { image_file, type }` - - References an image [File](/docs/api-reference/files) in the content of a message. - - - `image_file: ImageFile` - - - `file_id: string` - - The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. - - - `detail: optional "auto" or "low" or "high"` - - Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. - - - `"auto"` - - - `"low"` - - - `"high"` - - - `type: "image_file"` - - Always `image_file`. - - - `"image_file"` - - - `ImageURLContentBlock = object { image_url, type }` - - References an image URL in the content of a message. - - - `image_url: ImageURL` - - - `url: string` - - The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. - - - `detail: optional "auto" or "low" or "high"` - - Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` - - - `"auto"` - - - `"low"` - - - `"high"` - - - `type: "image_url"` - - The type of the content part. - - - `"image_url"` - - - `TextContentBlock = object { text, type }` - - The text content that is part of a message. - - - `text: Text` - - - `annotations: array of FileCitationAnnotation or FilePathAnnotation` - - - `FileCitationAnnotation = object { end_index, file_citation, start_index, 2 more }` - - 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. - - - `end_index: number` - - - `file_citation: object { file_id }` - - - `file_id: string` - - The ID of the specific File the citation is from. - - - `start_index: number` - - - `text: string` - - The text in the message content that needs to be replaced. - - - `type: "file_citation"` - - Always `file_citation`. - - - `"file_citation"` - - - `FilePathAnnotation = object { end_index, file_path, start_index, 2 more }` - - A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - - - `end_index: number` - - - `file_path: object { file_id }` - - - `file_id: string` - - The ID of the file that was generated. - - - `start_index: number` - - - `text: string` - - The text in the message content that needs to be replaced. - - - `type: "file_path"` - - Always `file_path`. - - - `"file_path"` - - - `value: string` - - The data that makes up the text. - - - `type: "text"` - - Always `text`. - - - `"text"` - - - `RefusalContentBlock = object { refusal, type }` - - The refusal content generated by the assistant. - - - `refusal: string` - - - `type: "refusal"` - - Always `refusal`. - - - `"refusal"` - - - `created_at: number` - - The Unix timestamp (in seconds) for when the message was created. - - - `incomplete_at: number` - - The Unix timestamp (in seconds) for when the message was marked as incomplete. - - - `incomplete_details: object { reason }` - - On an incomplete message, details about why the message is incomplete. - - - `reason: "content_filter" or "max_tokens" or "run_cancelled" or 2 more` - - The reason the message is incomplete. - - - `"content_filter"` - - - `"max_tokens"` - - - `"run_cancelled"` - - - `"run_expired"` - - - `"run_failed"` - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `object: "thread.message"` - - The object type, which is always `thread.message`. - - - `"thread.message"` - - - `role: "user" or "assistant"` - - The entity that produced the message. One of `user` or `assistant`. - - - `"user"` - - - `"assistant"` - - - `run_id: string` - - The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. - - - `status: "in_progress" or "incomplete" or "completed"` - - The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. - - - `"in_progress"` - - - `"incomplete"` - - - `"completed"` - - - `thread_id: string` - - The [thread](/docs/api-reference/threads) ID that this message belongs to. - - - `event: "thread.message.completed"` - - - `"thread.message.completed"` - - - `object { data, event }` - - Occurs when a [message](/docs/api-reference/messages/object) ends before it is completed. - - - `data: Message` - - Represents a message within a [thread](/docs/api-reference/threads). - - - `id: string` - - The identifier, which can be referenced in API endpoints. - - - `assistant_id: string` - - If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message. - - - `attachments: array of object { file_id, tools }` - - A list of files attached to the message, and the tools they were added to. - - - `file_id: optional string` - - The ID of the file to attach to the message. - - - `tools: optional array of CodeInterpreterTool or object { type }` - - The tools to add this file to. - - - `CodeInterpreterTool = object { type }` - - - `type: "code_interpreter"` - - The type of tool being defined: `code_interpreter` - - - `"code_interpreter"` - - - `FileSearchTool = object { type }` - - - `type: "file_search"` - - The type of tool being defined: `file_search` - - - `"file_search"` - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the message was completed. - - - `content: array of ImageFileContentBlock or ImageURLContentBlock or TextContentBlock or RefusalContentBlock` - - The content of the message in array of text and/or images. - - - `ImageFileContentBlock = object { image_file, type }` - - References an image [File](/docs/api-reference/files) in the content of a message. - - - `image_file: ImageFile` - - - `file_id: string` - - The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. - - - `detail: optional "auto" or "low" or "high"` - - Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. - - - `"auto"` - - - `"low"` - - - `"high"` - - - `type: "image_file"` - - Always `image_file`. - - - `"image_file"` - - - `ImageURLContentBlock = object { image_url, type }` - - References an image URL in the content of a message. - - - `image_url: ImageURL` - - - `url: string` - - The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. - - - `detail: optional "auto" or "low" or "high"` - - Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` - - - `"auto"` - - - `"low"` - - - `"high"` - - - `type: "image_url"` - - The type of the content part. - - - `"image_url"` - - - `TextContentBlock = object { text, type }` - - The text content that is part of a message. - - - `text: Text` - - - `annotations: array of FileCitationAnnotation or FilePathAnnotation` - - - `FileCitationAnnotation = object { end_index, file_citation, start_index, 2 more }` - - 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. - - - `end_index: number` - - - `file_citation: object { file_id }` - - - `file_id: string` - - The ID of the specific File the citation is from. - - - `start_index: number` - - - `text: string` - - The text in the message content that needs to be replaced. - - - `type: "file_citation"` - - Always `file_citation`. - - - `"file_citation"` - - - `FilePathAnnotation = object { end_index, file_path, start_index, 2 more }` - - A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - - - `end_index: number` - - - `file_path: object { file_id }` - - - `file_id: string` - - The ID of the file that was generated. - - - `start_index: number` - - - `text: string` - - The text in the message content that needs to be replaced. - - - `type: "file_path"` - - Always `file_path`. - - - `"file_path"` - - - `value: string` - - The data that makes up the text. - - - `type: "text"` - - Always `text`. - - - `"text"` - - - `RefusalContentBlock = object { refusal, type }` - - The refusal content generated by the assistant. - - - `refusal: string` - - - `type: "refusal"` - - Always `refusal`. - - - `"refusal"` - - - `created_at: number` - - The Unix timestamp (in seconds) for when the message was created. - - - `incomplete_at: number` - - The Unix timestamp (in seconds) for when the message was marked as incomplete. - - - `incomplete_details: object { reason }` - - On an incomplete message, details about why the message is incomplete. - - - `reason: "content_filter" or "max_tokens" or "run_cancelled" or 2 more` - - The reason the message is incomplete. - - - `"content_filter"` - - - `"max_tokens"` - - - `"run_cancelled"` - - - `"run_expired"` - - - `"run_failed"` - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `object: "thread.message"` - - The object type, which is always `thread.message`. - - - `"thread.message"` - - - `role: "user" or "assistant"` - - The entity that produced the message. One of `user` or `assistant`. - - - `"user"` - - - `"assistant"` - - - `run_id: string` - - The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. - - - `status: "in_progress" or "incomplete" or "completed"` - - The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. - - - `"in_progress"` - - - `"incomplete"` - - - `"completed"` - - - `thread_id: string` - - The [thread](/docs/api-reference/threads) ID that this message belongs to. - - - `event: "thread.message.incomplete"` - - - `"thread.message.incomplete"` - - - `ErrorEvent = object { data, event }` - - Occurs when an [error](/docs/guides/error-codes#api-errors) occurs. This can happen due to an internal server error or a timeout. - - - `data: ErrorObject` - - - `code: string` - - - `message: string` - - - `param: string` - - - `type: string` - - - `event: "error"` - - - `"error"` - - - `DoneEvent = object { data, event }` - - Occurs when a stream ends. - - - `data: "[DONE]"` - - - `"[DONE]"` - - - `event: "done"` - - - `"done"` - -### Code Interpreter Tool - -- `CodeInterpreterTool = object { type }` - - - `type: "code_interpreter"` - - The type of tool being defined: `code_interpreter` - - - `"code_interpreter"` - -### File Search Tool - -- `FileSearchTool = object { type, file_search }` - - - `type: "file_search"` - - The type of tool being defined: `file_search` - - - `"file_search"` - - - `file_search: optional object { max_num_results, ranking_options }` - - Overrides for the file search tool. - - - `max_num_results: optional number` - - The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. - - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `ranking_options: optional object { score_threshold, ranker }` - - The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. - - See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `score_threshold: number` - - The score threshold for the file search. All values must be a floating point number between 0 and 1. - - - `ranker: optional "auto" or "default_2024_08_21"` - - The ranker to use for the file search. If not specified will use the `auto` ranker. - - - `"auto"` - - - `"default_2024_08_21"` - -### Function Tool - -- `FunctionTool = object { function, type }` - - - `function: FunctionDefinition` - - - `name: string` - - The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - - - `description: optional string` - - A description of what the function does, used by the model to choose when and how to call the function. - - - `parameters: optional FunctionParameters` - - The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. - - Omitting `parameters` defines a function with an empty parameter list. - - - `strict: optional boolean` - - Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling). - - - `type: "function"` - - The type of tool being defined: `function` - - - `"function"` - -### Message Stream Event - -- `MessageStreamEvent = object { data, event } or object { data, event } or object { data, event } or 2 more` - - Occurs when a [message](/docs/api-reference/messages/object) is created. - - - `object { data, event }` - - Occurs when a [message](/docs/api-reference/messages/object) is created. - - - `data: Message` - - Represents a message within a [thread](/docs/api-reference/threads). - - - `id: string` - - The identifier, which can be referenced in API endpoints. - - - `assistant_id: string` - - If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message. - - - `attachments: array of object { file_id, tools }` - - A list of files attached to the message, and the tools they were added to. - - - `file_id: optional string` - - The ID of the file to attach to the message. - - - `tools: optional array of CodeInterpreterTool or object { type }` - - The tools to add this file to. - - - `CodeInterpreterTool = object { type }` - - - `type: "code_interpreter"` - - The type of tool being defined: `code_interpreter` - - - `"code_interpreter"` - - - `FileSearchTool = object { type }` - - - `type: "file_search"` - - The type of tool being defined: `file_search` - - - `"file_search"` - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the message was completed. - - - `content: array of ImageFileContentBlock or ImageURLContentBlock or TextContentBlock or RefusalContentBlock` - - The content of the message in array of text and/or images. - - - `ImageFileContentBlock = object { image_file, type }` - - References an image [File](/docs/api-reference/files) in the content of a message. - - - `image_file: ImageFile` - - - `file_id: string` - - The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. - - - `detail: optional "auto" or "low" or "high"` - - Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. - - - `"auto"` - - - `"low"` - - - `"high"` - - - `type: "image_file"` - - Always `image_file`. - - - `"image_file"` - - - `ImageURLContentBlock = object { image_url, type }` - - References an image URL in the content of a message. - - - `image_url: ImageURL` - - - `url: string` - - The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. - - - `detail: optional "auto" or "low" or "high"` - - Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` - - - `"auto"` - - - `"low"` - - - `"high"` - - - `type: "image_url"` - - The type of the content part. - - - `"image_url"` - - - `TextContentBlock = object { text, type }` - - The text content that is part of a message. - - - `text: Text` - - - `annotations: array of FileCitationAnnotation or FilePathAnnotation` - - - `FileCitationAnnotation = object { end_index, file_citation, start_index, 2 more }` - - 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. - - - `end_index: number` - - - `file_citation: object { file_id }` - - - `file_id: string` - - The ID of the specific File the citation is from. - - - `start_index: number` - - - `text: string` - - The text in the message content that needs to be replaced. - - - `type: "file_citation"` - - Always `file_citation`. - - - `"file_citation"` - - - `FilePathAnnotation = object { end_index, file_path, start_index, 2 more }` - - A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - - - `end_index: number` - - - `file_path: object { file_id }` - - - `file_id: string` - - The ID of the file that was generated. - - - `start_index: number` - - - `text: string` - - The text in the message content that needs to be replaced. - - - `type: "file_path"` - - Always `file_path`. - - - `"file_path"` - - - `value: string` - - The data that makes up the text. - - - `type: "text"` - - Always `text`. - - - `"text"` - - - `RefusalContentBlock = object { refusal, type }` - - The refusal content generated by the assistant. - - - `refusal: string` - - - `type: "refusal"` - - Always `refusal`. - - - `"refusal"` - - - `created_at: number` - - The Unix timestamp (in seconds) for when the message was created. - - - `incomplete_at: number` - - The Unix timestamp (in seconds) for when the message was marked as incomplete. - - - `incomplete_details: object { reason }` - - On an incomplete message, details about why the message is incomplete. - - - `reason: "content_filter" or "max_tokens" or "run_cancelled" or 2 more` - - The reason the message is incomplete. - - - `"content_filter"` - - - `"max_tokens"` - - - `"run_cancelled"` - - - `"run_expired"` - - - `"run_failed"` - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `object: "thread.message"` - - The object type, which is always `thread.message`. - - - `"thread.message"` - - - `role: "user" or "assistant"` - - The entity that produced the message. One of `user` or `assistant`. - - - `"user"` - - - `"assistant"` - - - `run_id: string` - - The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. - - - `status: "in_progress" or "incomplete" or "completed"` - - The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. - - - `"in_progress"` - - - `"incomplete"` - - - `"completed"` - - - `thread_id: string` - - The [thread](/docs/api-reference/threads) ID that this message belongs to. - - - `event: "thread.message.created"` - - - `"thread.message.created"` - - - `object { data, event }` - - Occurs when a [message](/docs/api-reference/messages/object) moves to an `in_progress` state. - - - `data: Message` - - Represents a message within a [thread](/docs/api-reference/threads). - - - `id: string` - - The identifier, which can be referenced in API endpoints. - - - `assistant_id: string` - - If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message. - - - `attachments: array of object { file_id, tools }` - - A list of files attached to the message, and the tools they were added to. - - - `file_id: optional string` - - The ID of the file to attach to the message. - - - `tools: optional array of CodeInterpreterTool or object { type }` - - The tools to add this file to. - - - `CodeInterpreterTool = object { type }` - - - `type: "code_interpreter"` - - The type of tool being defined: `code_interpreter` - - - `"code_interpreter"` - - - `FileSearchTool = object { type }` - - - `type: "file_search"` - - The type of tool being defined: `file_search` - - - `"file_search"` - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the message was completed. - - - `content: array of ImageFileContentBlock or ImageURLContentBlock or TextContentBlock or RefusalContentBlock` - - The content of the message in array of text and/or images. - - - `ImageFileContentBlock = object { image_file, type }` - - References an image [File](/docs/api-reference/files) in the content of a message. - - - `image_file: ImageFile` - - - `file_id: string` - - The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. - - - `detail: optional "auto" or "low" or "high"` - - Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. - - - `"auto"` - - - `"low"` - - - `"high"` - - - `type: "image_file"` - - Always `image_file`. - - - `"image_file"` - - - `ImageURLContentBlock = object { image_url, type }` - - References an image URL in the content of a message. - - - `image_url: ImageURL` - - - `url: string` - - The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. - - - `detail: optional "auto" or "low" or "high"` - - Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` - - - `"auto"` - - - `"low"` - - - `"high"` - - - `type: "image_url"` - - The type of the content part. - - - `"image_url"` - - - `TextContentBlock = object { text, type }` - - The text content that is part of a message. - - - `text: Text` - - - `annotations: array of FileCitationAnnotation or FilePathAnnotation` - - - `FileCitationAnnotation = object { end_index, file_citation, start_index, 2 more }` - - 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. - - - `end_index: number` - - - `file_citation: object { file_id }` - - - `file_id: string` - - The ID of the specific File the citation is from. - - - `start_index: number` - - - `text: string` - - The text in the message content that needs to be replaced. - - - `type: "file_citation"` - - Always `file_citation`. - - - `"file_citation"` - - - `FilePathAnnotation = object { end_index, file_path, start_index, 2 more }` - - A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - - - `end_index: number` - - - `file_path: object { file_id }` - - - `file_id: string` - - The ID of the file that was generated. - - - `start_index: number` - - - `text: string` - - The text in the message content that needs to be replaced. - - - `type: "file_path"` - - Always `file_path`. - - - `"file_path"` - - - `value: string` - - The data that makes up the text. - - - `type: "text"` - - Always `text`. - - - `"text"` - - - `RefusalContentBlock = object { refusal, type }` - - The refusal content generated by the assistant. - - - `refusal: string` - - - `type: "refusal"` - - Always `refusal`. - - - `"refusal"` - - - `created_at: number` - - The Unix timestamp (in seconds) for when the message was created. - - - `incomplete_at: number` - - The Unix timestamp (in seconds) for when the message was marked as incomplete. - - - `incomplete_details: object { reason }` - - On an incomplete message, details about why the message is incomplete. - - - `reason: "content_filter" or "max_tokens" or "run_cancelled" or 2 more` - - The reason the message is incomplete. - - - `"content_filter"` - - - `"max_tokens"` - - - `"run_cancelled"` - - - `"run_expired"` - - - `"run_failed"` - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `object: "thread.message"` - - The object type, which is always `thread.message`. - - - `"thread.message"` - - - `role: "user" or "assistant"` - - The entity that produced the message. One of `user` or `assistant`. - - - `"user"` - - - `"assistant"` - - - `run_id: string` - - The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. - - - `status: "in_progress" or "incomplete" or "completed"` - - The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. - - - `"in_progress"` - - - `"incomplete"` - - - `"completed"` - - - `thread_id: string` - - The [thread](/docs/api-reference/threads) ID that this message belongs to. - - - `event: "thread.message.in_progress"` - - - `"thread.message.in_progress"` - - - `object { data, event }` - - Occurs when parts of a [Message](/docs/api-reference/messages/object) are being streamed. - - - `data: MessageDeltaEvent` - - Represents a message delta i.e. any changed fields on a message during streaming. - - - `id: string` - - The identifier of the message, which can be referenced in API endpoints. - - - `delta: MessageDelta` - - The delta containing the fields that have changed on the Message. - - - `content: optional array of ImageFileDeltaBlock or TextDeltaBlock or RefusalDeltaBlock or ImageURLDeltaBlock` - - The content of the message in array of text and/or images. - - - `ImageFileDeltaBlock = object { index, type, image_file }` - - References an image [File](/docs/api-reference/files) in the content of a message. - - - `index: number` - - The index of the content part in the message. - - - `type: "image_file"` - - Always `image_file`. - - - `"image_file"` - - - `image_file: optional ImageFileDelta` - - - `detail: optional "auto" or "low" or "high"` - - Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. - - - `"auto"` - - - `"low"` - - - `"high"` - - - `file_id: optional string` - - The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. - - - `TextDeltaBlock = object { index, type, text }` - - The text content that is part of a message. - - - `index: number` - - The index of the content part in the message. - - - `type: "text"` - - Always `text`. - - - `"text"` - - - `text: optional TextDelta` - - - `annotations: optional array of FileCitationDeltaAnnotation or FilePathDeltaAnnotation` - - - `FileCitationDeltaAnnotation = object { index, type, end_index, 3 more }` - - 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. - - - `index: number` - - The index of the annotation in the text content part. - - - `type: "file_citation"` - - Always `file_citation`. - - - `"file_citation"` - - - `end_index: optional number` - - - `file_citation: optional object { file_id, quote }` - - - `file_id: optional string` - - The ID of the specific File the citation is from. - - - `quote: optional string` - - The specific quote in the file. - - - `start_index: optional number` - - - `text: optional string` - - The text in the message content that needs to be replaced. - - - `FilePathDeltaAnnotation = object { index, type, end_index, 3 more }` - - A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - - - `index: number` - - The index of the annotation in the text content part. - - - `type: "file_path"` - - Always `file_path`. - - - `"file_path"` - - - `end_index: optional number` - - - `file_path: optional object { file_id }` - - - `file_id: optional string` - - The ID of the file that was generated. - - - `start_index: optional number` - - - `text: optional string` - - The text in the message content that needs to be replaced. - - - `value: optional string` - - The data that makes up the text. - - - `RefusalDeltaBlock = object { index, type, refusal }` - - The refusal content that is part of a message. - - - `index: number` - - The index of the refusal part in the message. - - - `type: "refusal"` - - Always `refusal`. - - - `"refusal"` - - - `refusal: optional string` - - - `ImageURLDeltaBlock = object { index, type, image_url }` - - References an image URL in the content of a message. - - - `index: number` - - The index of the content part in the message. - - - `type: "image_url"` - - Always `image_url`. - - - `"image_url"` - - - `image_url: optional ImageURLDelta` - - - `detail: optional "auto" or "low" or "high"` - - Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. - - - `"auto"` - - - `"low"` - - - `"high"` - - - `url: optional string` - - The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. - - - `role: optional "user" or "assistant"` - - The entity that produced the message. One of `user` or `assistant`. - - - `"user"` - - - `"assistant"` - - - `object: "thread.message.delta"` - - The object type, which is always `thread.message.delta`. - - - `"thread.message.delta"` - - - `event: "thread.message.delta"` - - - `"thread.message.delta"` - - - `object { data, event }` - - Occurs when a [message](/docs/api-reference/messages/object) is completed. - - - `data: Message` - - Represents a message within a [thread](/docs/api-reference/threads). - - - `id: string` - - The identifier, which can be referenced in API endpoints. - - - `assistant_id: string` - - If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message. - - - `attachments: array of object { file_id, tools }` - - A list of files attached to the message, and the tools they were added to. - - - `file_id: optional string` - - The ID of the file to attach to the message. - - - `tools: optional array of CodeInterpreterTool or object { type }` - - The tools to add this file to. - - - `CodeInterpreterTool = object { type }` - - - `type: "code_interpreter"` - - The type of tool being defined: `code_interpreter` - - - `"code_interpreter"` - - - `FileSearchTool = object { type }` - - - `type: "file_search"` - - The type of tool being defined: `file_search` - - - `"file_search"` - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the message was completed. - - - `content: array of ImageFileContentBlock or ImageURLContentBlock or TextContentBlock or RefusalContentBlock` - - The content of the message in array of text and/or images. - - - `ImageFileContentBlock = object { image_file, type }` - - References an image [File](/docs/api-reference/files) in the content of a message. - - - `image_file: ImageFile` - - - `file_id: string` - - The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. - - - `detail: optional "auto" or "low" or "high"` - - Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. - - - `"auto"` - - - `"low"` - - - `"high"` - - - `type: "image_file"` - - Always `image_file`. - - - `"image_file"` - - - `ImageURLContentBlock = object { image_url, type }` - - References an image URL in the content of a message. - - - `image_url: ImageURL` - - - `url: string` - - The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. - - - `detail: optional "auto" or "low" or "high"` - - Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` - - - `"auto"` - - - `"low"` - - - `"high"` - - - `type: "image_url"` - - The type of the content part. - - - `"image_url"` - - - `TextContentBlock = object { text, type }` - - The text content that is part of a message. - - - `text: Text` - - - `annotations: array of FileCitationAnnotation or FilePathAnnotation` - - - `FileCitationAnnotation = object { end_index, file_citation, start_index, 2 more }` - - 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. - - - `end_index: number` - - - `file_citation: object { file_id }` - - - `file_id: string` - - The ID of the specific File the citation is from. - - - `start_index: number` - - - `text: string` - - The text in the message content that needs to be replaced. - - - `type: "file_citation"` - - Always `file_citation`. - - - `"file_citation"` - - - `FilePathAnnotation = object { end_index, file_path, start_index, 2 more }` - - A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - - - `end_index: number` - - - `file_path: object { file_id }` - - - `file_id: string` - - The ID of the file that was generated. - - - `start_index: number` - - - `text: string` - - The text in the message content that needs to be replaced. - - - `type: "file_path"` - - Always `file_path`. - - - `"file_path"` - - - `value: string` - - The data that makes up the text. - - - `type: "text"` - - Always `text`. - - - `"text"` - - - `RefusalContentBlock = object { refusal, type }` - - The refusal content generated by the assistant. - - - `refusal: string` - - - `type: "refusal"` - - Always `refusal`. - - - `"refusal"` - - - `created_at: number` - - The Unix timestamp (in seconds) for when the message was created. - - - `incomplete_at: number` - - The Unix timestamp (in seconds) for when the message was marked as incomplete. - - - `incomplete_details: object { reason }` - - On an incomplete message, details about why the message is incomplete. - - - `reason: "content_filter" or "max_tokens" or "run_cancelled" or 2 more` - - The reason the message is incomplete. - - - `"content_filter"` - - - `"max_tokens"` - - - `"run_cancelled"` - - - `"run_expired"` - - - `"run_failed"` - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `object: "thread.message"` - - The object type, which is always `thread.message`. - - - `"thread.message"` - - - `role: "user" or "assistant"` - - The entity that produced the message. One of `user` or `assistant`. - - - `"user"` - - - `"assistant"` - - - `run_id: string` - - The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. - - - `status: "in_progress" or "incomplete" or "completed"` - - The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. - - - `"in_progress"` - - - `"incomplete"` - - - `"completed"` - - - `thread_id: string` - - The [thread](/docs/api-reference/threads) ID that this message belongs to. - - - `event: "thread.message.completed"` - - - `"thread.message.completed"` - - - `object { data, event }` - - Occurs when a [message](/docs/api-reference/messages/object) ends before it is completed. - - - `data: Message` - - Represents a message within a [thread](/docs/api-reference/threads). - - - `id: string` - - The identifier, which can be referenced in API endpoints. - - - `assistant_id: string` - - If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message. - - - `attachments: array of object { file_id, tools }` - - A list of files attached to the message, and the tools they were added to. - - - `file_id: optional string` - - The ID of the file to attach to the message. - - - `tools: optional array of CodeInterpreterTool or object { type }` - - The tools to add this file to. - - - `CodeInterpreterTool = object { type }` - - - `type: "code_interpreter"` - - The type of tool being defined: `code_interpreter` - - - `"code_interpreter"` - - - `FileSearchTool = object { type }` - - - `type: "file_search"` - - The type of tool being defined: `file_search` - - - `"file_search"` - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the message was completed. - - - `content: array of ImageFileContentBlock or ImageURLContentBlock or TextContentBlock or RefusalContentBlock` - - The content of the message in array of text and/or images. - - - `ImageFileContentBlock = object { image_file, type }` - - References an image [File](/docs/api-reference/files) in the content of a message. - - - `image_file: ImageFile` - - - `file_id: string` - - The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. - - - `detail: optional "auto" or "low" or "high"` - - Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. - - - `"auto"` - - - `"low"` - - - `"high"` - - - `type: "image_file"` - - Always `image_file`. - - - `"image_file"` - - - `ImageURLContentBlock = object { image_url, type }` - - References an image URL in the content of a message. - - - `image_url: ImageURL` - - - `url: string` - - The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. - - - `detail: optional "auto" or "low" or "high"` - - Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` - - - `"auto"` - - - `"low"` - - - `"high"` - - - `type: "image_url"` - - The type of the content part. - - - `"image_url"` - - - `TextContentBlock = object { text, type }` - - The text content that is part of a message. - - - `text: Text` - - - `annotations: array of FileCitationAnnotation or FilePathAnnotation` - - - `FileCitationAnnotation = object { end_index, file_citation, start_index, 2 more }` - - 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. - - - `end_index: number` - - - `file_citation: object { file_id }` - - - `file_id: string` - - The ID of the specific File the citation is from. - - - `start_index: number` - - - `text: string` - - The text in the message content that needs to be replaced. - - - `type: "file_citation"` - - Always `file_citation`. - - - `"file_citation"` - - - `FilePathAnnotation = object { end_index, file_path, start_index, 2 more }` - - A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - - - `end_index: number` - - - `file_path: object { file_id }` - - - `file_id: string` - - The ID of the file that was generated. - - - `start_index: number` - - - `text: string` - - The text in the message content that needs to be replaced. - - - `type: "file_path"` - - Always `file_path`. - - - `"file_path"` - - - `value: string` - - The data that makes up the text. - - - `type: "text"` - - Always `text`. - - - `"text"` - - - `RefusalContentBlock = object { refusal, type }` - - The refusal content generated by the assistant. - - - `refusal: string` - - - `type: "refusal"` - - Always `refusal`. - - - `"refusal"` - - - `created_at: number` - - The Unix timestamp (in seconds) for when the message was created. - - - `incomplete_at: number` - - The Unix timestamp (in seconds) for when the message was marked as incomplete. - - - `incomplete_details: object { reason }` - - On an incomplete message, details about why the message is incomplete. - - - `reason: "content_filter" or "max_tokens" or "run_cancelled" or 2 more` - - The reason the message is incomplete. - - - `"content_filter"` - - - `"max_tokens"` - - - `"run_cancelled"` - - - `"run_expired"` - - - `"run_failed"` - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `object: "thread.message"` - - The object type, which is always `thread.message`. - - - `"thread.message"` - - - `role: "user" or "assistant"` - - The entity that produced the message. One of `user` or `assistant`. - - - `"user"` - - - `"assistant"` - - - `run_id: string` - - The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. - - - `status: "in_progress" or "incomplete" or "completed"` - - The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. - - - `"in_progress"` - - - `"incomplete"` - - - `"completed"` - - - `thread_id: string` - - The [thread](/docs/api-reference/threads) ID that this message belongs to. - - - `event: "thread.message.incomplete"` - - - `"thread.message.incomplete"` - -### Run Step Stream Event - -- `RunStepStreamEvent = object { data, event } or object { data, event } or object { data, event } or 4 more` - - Occurs when a [run step](/docs/api-reference/run-steps/step-object) is created. - - - `object { data, event }` - - Occurs when a [run step](/docs/api-reference/run-steps/step-object) is created. - - - `data: RunStep` - - Represents a step in execution of a run. - - - `id: string` - - The identifier of the run step, which can be referenced in API endpoints. - - - `assistant_id: string` - - The ID of the [assistant](/docs/api-reference/assistants) associated with the run step. - - - `cancelled_at: number` - - The Unix timestamp (in seconds) for when the run step was cancelled. - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the run step completed. - - - `created_at: number` - - The Unix timestamp (in seconds) for when the run step was created. - - - `expired_at: number` - - The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired. - - - `failed_at: number` - - The Unix timestamp (in seconds) for when the run step failed. - - - `last_error: object { code, message }` - - The last error associated with this run step. Will be `null` if there are no errors. - - - `code: "server_error" or "rate_limit_exceeded"` - - One of `server_error` or `rate_limit_exceeded`. - - - `"server_error"` - - - `"rate_limit_exceeded"` - - - `message: string` - - A human-readable description of the error. - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `object: "thread.run.step"` - - The object type, which is always `thread.run.step`. - - - `"thread.run.step"` - - - `run_id: string` - - The ID of the [run](/docs/api-reference/runs) that this run step is a part of. - - - `status: "in_progress" or "cancelled" or "failed" or 2 more` - - The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`. - - - `"in_progress"` - - - `"cancelled"` - - - `"failed"` - - - `"completed"` - - - `"expired"` - - - `step_details: MessageCreationStepDetails or ToolCallsStepDetails` - - The details of the run step. - - - `MessageCreationStepDetails = object { message_creation, type }` - - Details of the message creation by the run step. - - - `message_creation: object { message_id }` - - - `message_id: string` - - The ID of the message that was created by this run step. - - - `type: "message_creation"` - - Always `message_creation`. - - - `"message_creation"` - - - `ToolCallsStepDetails = object { tool_calls, type }` - - Details of the tool call. - - - `tool_calls: array of CodeInterpreterToolCall or FileSearchToolCall or FunctionToolCall` - - An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. - - - `CodeInterpreterToolCall = object { id, code_interpreter, type }` - - Details of the Code Interpreter tool call the run step was involved in. - - - `id: string` - - The ID of the tool call. - - - `code_interpreter: object { input, outputs }` - - The Code Interpreter tool call definition. - - - `input: string` - - The input to the Code Interpreter tool call. - - - `outputs: array of object { logs, type } or object { image, type }` - - The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. - - - `CodeInterpreterLogOutput = object { logs, type }` - - Text output from the Code Interpreter tool call as part of a run step. - - - `logs: string` - - The text output from the Code Interpreter tool call. - - - `type: "logs"` - - Always `logs`. - - - `"logs"` - - - `CodeInterpreterImageOutput = object { image, type }` - - - `image: object { file_id }` - - - `file_id: string` - - The [file](/docs/api-reference/files) ID of the image. - - - `type: "image"` - - Always `image`. - - - `"image"` - - - `type: "code_interpreter"` - - The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - - - `"code_interpreter"` - - - `FileSearchToolCall = object { id, file_search, type }` - - - `id: string` - - The ID of the tool call object. - - - `file_search: object { ranking_options, results }` - - For now, this is always going to be an empty object. - - - `ranking_options: optional object { ranker, score_threshold }` - - The ranking options for the file search. - - - `ranker: "auto" or "default_2024_08_21"` - - The ranker to use for the file search. If not specified will use the `auto` ranker. - - - `"auto"` - - - `"default_2024_08_21"` - - - `score_threshold: number` - - The score threshold for the file search. All values must be a floating point number between 0 and 1. - - - `results: optional array of object { file_id, file_name, score, content }` - - The results of the file search. - - - `file_id: string` - - The ID of the file that result was found in. - - - `file_name: string` - - The name of the file that result was found in. - - - `score: number` - - The score of the result. All values must be a floating point number between 0 and 1. - - - `content: optional array of object { text, type }` - - The content of the result that was found. The content is only included if requested via the include query parameter. - - - `text: optional string` - - The text content of the file. - - - `type: optional "text"` - - The type of the content. - - - `"text"` - - - `type: "file_search"` - - The type of tool call. This is always going to be `file_search` for this type of tool call. - - - `"file_search"` - - - `FunctionToolCall = object { id, function, type }` - - - `id: string` - - The ID of the tool call object. - - - `function: object { arguments, name, output }` - - The definition of the function that was called. - - - `arguments: string` - - The arguments passed to the function. - - - `name: string` - - The name of the function. - - - `output: string` - - The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. - - - `type: "function"` - - The type of tool call. This is always going to be `function` for this type of tool call. - - - `"function"` - - - `type: "tool_calls"` - - Always `tool_calls`. - - - `"tool_calls"` - - - `thread_id: string` - - The ID of the [thread](/docs/api-reference/threads) that was run. - - - `type: "message_creation" or "tool_calls"` - - The type of run step, which can be either `message_creation` or `tool_calls`. - - - `"message_creation"` - - - `"tool_calls"` - - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - - Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. - - - `completion_tokens: number` - - Number of completion tokens used over the course of the run step. - - - `prompt_tokens: number` - - Number of prompt tokens used over the course of the run step. - - - `total_tokens: number` - - Total number of tokens used (prompt + completion). - - - `event: "thread.run.step.created"` - - - `"thread.run.step.created"` - - - `object { data, event }` - - Occurs when a [run step](/docs/api-reference/run-steps/step-object) moves to an `in_progress` state. - - - `data: RunStep` - - Represents a step in execution of a run. - - - `id: string` - - The identifier of the run step, which can be referenced in API endpoints. - - - `assistant_id: string` - - The ID of the [assistant](/docs/api-reference/assistants) associated with the run step. - - - `cancelled_at: number` - - The Unix timestamp (in seconds) for when the run step was cancelled. - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the run step completed. - - - `created_at: number` - - The Unix timestamp (in seconds) for when the run step was created. - - - `expired_at: number` - - The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired. - - - `failed_at: number` - - The Unix timestamp (in seconds) for when the run step failed. - - - `last_error: object { code, message }` - - The last error associated with this run step. Will be `null` if there are no errors. - - - `code: "server_error" or "rate_limit_exceeded"` - - One of `server_error` or `rate_limit_exceeded`. - - - `"server_error"` - - - `"rate_limit_exceeded"` - - - `message: string` - - A human-readable description of the error. - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `object: "thread.run.step"` - - The object type, which is always `thread.run.step`. - - - `"thread.run.step"` - - - `run_id: string` - - The ID of the [run](/docs/api-reference/runs) that this run step is a part of. - - - `status: "in_progress" or "cancelled" or "failed" or 2 more` - - The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`. - - - `"in_progress"` - - - `"cancelled"` - - - `"failed"` - - - `"completed"` - - - `"expired"` - - - `step_details: MessageCreationStepDetails or ToolCallsStepDetails` - - The details of the run step. - - - `MessageCreationStepDetails = object { message_creation, type }` - - Details of the message creation by the run step. - - - `message_creation: object { message_id }` - - - `message_id: string` - - The ID of the message that was created by this run step. - - - `type: "message_creation"` - - Always `message_creation`. - - - `"message_creation"` - - - `ToolCallsStepDetails = object { tool_calls, type }` - - Details of the tool call. - - - `tool_calls: array of CodeInterpreterToolCall or FileSearchToolCall or FunctionToolCall` - - An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. - - - `CodeInterpreterToolCall = object { id, code_interpreter, type }` - - Details of the Code Interpreter tool call the run step was involved in. - - - `id: string` - - The ID of the tool call. - - - `code_interpreter: object { input, outputs }` - - The Code Interpreter tool call definition. - - - `input: string` - - The input to the Code Interpreter tool call. - - - `outputs: array of object { logs, type } or object { image, type }` - - The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. - - - `CodeInterpreterLogOutput = object { logs, type }` - - Text output from the Code Interpreter tool call as part of a run step. - - - `logs: string` - - The text output from the Code Interpreter tool call. - - - `type: "logs"` - - Always `logs`. - - - `"logs"` - - - `CodeInterpreterImageOutput = object { image, type }` - - - `image: object { file_id }` - - - `file_id: string` - - The [file](/docs/api-reference/files) ID of the image. - - - `type: "image"` - - Always `image`. - - - `"image"` - - - `type: "code_interpreter"` - - The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - - - `"code_interpreter"` - - - `FileSearchToolCall = object { id, file_search, type }` - - - `id: string` - - The ID of the tool call object. - - - `file_search: object { ranking_options, results }` - - For now, this is always going to be an empty object. - - - `ranking_options: optional object { ranker, score_threshold }` - - The ranking options for the file search. - - - `ranker: "auto" or "default_2024_08_21"` - - The ranker to use for the file search. If not specified will use the `auto` ranker. - - - `"auto"` - - - `"default_2024_08_21"` - - - `score_threshold: number` - - The score threshold for the file search. All values must be a floating point number between 0 and 1. - - - `results: optional array of object { file_id, file_name, score, content }` - - The results of the file search. - - - `file_id: string` - - The ID of the file that result was found in. - - - `file_name: string` - - The name of the file that result was found in. - - - `score: number` - - The score of the result. All values must be a floating point number between 0 and 1. - - - `content: optional array of object { text, type }` - - The content of the result that was found. The content is only included if requested via the include query parameter. - - - `text: optional string` - - The text content of the file. - - - `type: optional "text"` - - The type of the content. - - - `"text"` - - - `type: "file_search"` - - The type of tool call. This is always going to be `file_search` for this type of tool call. - - - `"file_search"` - - - `FunctionToolCall = object { id, function, type }` - - - `id: string` - - The ID of the tool call object. - - - `function: object { arguments, name, output }` - - The definition of the function that was called. - - - `arguments: string` - - The arguments passed to the function. - - - `name: string` - - The name of the function. - - - `output: string` - - The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. - - - `type: "function"` - - The type of tool call. This is always going to be `function` for this type of tool call. - - - `"function"` - - - `type: "tool_calls"` - - Always `tool_calls`. - - - `"tool_calls"` - - - `thread_id: string` - - The ID of the [thread](/docs/api-reference/threads) that was run. - - - `type: "message_creation" or "tool_calls"` - - The type of run step, which can be either `message_creation` or `tool_calls`. - - - `"message_creation"` - - - `"tool_calls"` - - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - - Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. - - - `completion_tokens: number` - - Number of completion tokens used over the course of the run step. - - - `prompt_tokens: number` - - Number of prompt tokens used over the course of the run step. - - - `total_tokens: number` - - Total number of tokens used (prompt + completion). - - - `event: "thread.run.step.in_progress"` - - - `"thread.run.step.in_progress"` - - - `object { data, event }` - - Occurs when parts of a [run step](/docs/api-reference/run-steps/step-object) are being streamed. - - - `data: RunStepDeltaEvent` - - Represents a run step delta i.e. any changed fields on a run step during streaming. - - - `id: string` - - The identifier of the run step, which can be referenced in API endpoints. - - - `delta: object { step_details }` - - The delta containing the fields that have changed on the run step. - - - `step_details: optional RunStepDeltaMessageDelta or ToolCallDeltaObject` - - The details of the run step. - - - `RunStepDeltaMessageDelta = object { type, message_creation }` - - Details of the message creation by the run step. - - - `type: "message_creation"` - - Always `message_creation`. - - - `"message_creation"` - - - `message_creation: optional object { message_id }` - - - `message_id: optional string` - - The ID of the message that was created by this run step. - - - `ToolCallDeltaObject = object { type, tool_calls }` - - Details of the tool call. - - - `type: "tool_calls"` - - Always `tool_calls`. - - - `"tool_calls"` - - - `tool_calls: optional array of CodeInterpreterToolCallDelta or FileSearchToolCallDelta or FunctionToolCallDelta` - - An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. - - - `CodeInterpreterToolCallDelta = object { index, type, id, code_interpreter }` - - Details of the Code Interpreter tool call the run step was involved in. - - - `index: number` - - The index of the tool call in the tool calls array. - - - `type: "code_interpreter"` - - The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - - - `"code_interpreter"` - - - `id: optional string` - - The ID of the tool call. - - - `code_interpreter: optional object { input, outputs }` - - The Code Interpreter tool call definition. - - - `input: optional string` - - The input to the Code Interpreter tool call. - - - `outputs: optional array of CodeInterpreterLogs or CodeInterpreterOutputImage` - - The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. - - - `CodeInterpreterLogs = object { index, type, logs }` - - Text output from the Code Interpreter tool call as part of a run step. - - - `index: number` - - The index of the output in the outputs array. - - - `type: "logs"` - - Always `logs`. - - - `"logs"` - - - `logs: optional string` - - The text output from the Code Interpreter tool call. - - - `CodeInterpreterOutputImage = object { index, type, image }` - - - `index: number` - - The index of the output in the outputs array. - - - `type: "image"` - - Always `image`. - - - `"image"` - - - `image: optional object { file_id }` - - - `file_id: optional string` - - The [file](/docs/api-reference/files) ID of the image. - - - `FileSearchToolCallDelta = object { file_search, index, type, id }` - - - `file_search: unknown` - - For now, this is always going to be an empty object. - - - `index: number` - - The index of the tool call in the tool calls array. - - - `type: "file_search"` - - The type of tool call. This is always going to be `file_search` for this type of tool call. - - - `"file_search"` - - - `id: optional string` - - The ID of the tool call object. - - - `FunctionToolCallDelta = object { index, type, id, function }` - - - `index: number` - - The index of the tool call in the tool calls array. - - - `type: "function"` - - The type of tool call. This is always going to be `function` for this type of tool call. - - - `"function"` - - - `id: optional string` - - The ID of the tool call object. - - - `function: optional object { arguments, name, output }` - - The definition of the function that was called. - - - `arguments: optional string` - - The arguments passed to the function. - - - `name: optional string` - - The name of the function. - - - `output: optional string` - - The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. - - - `object: "thread.run.step.delta"` - - The object type, which is always `thread.run.step.delta`. - - - `"thread.run.step.delta"` - - - `event: "thread.run.step.delta"` - - - `"thread.run.step.delta"` - - - `object { data, event }` - - Occurs when a [run step](/docs/api-reference/run-steps/step-object) is completed. - - - `data: RunStep` - - Represents a step in execution of a run. - - - `id: string` - - The identifier of the run step, which can be referenced in API endpoints. - - - `assistant_id: string` - - The ID of the [assistant](/docs/api-reference/assistants) associated with the run step. - - - `cancelled_at: number` - - The Unix timestamp (in seconds) for when the run step was cancelled. - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the run step completed. - - - `created_at: number` - - The Unix timestamp (in seconds) for when the run step was created. - - - `expired_at: number` - - The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired. - - - `failed_at: number` - - The Unix timestamp (in seconds) for when the run step failed. - - - `last_error: object { code, message }` - - The last error associated with this run step. Will be `null` if there are no errors. - - - `code: "server_error" or "rate_limit_exceeded"` - - One of `server_error` or `rate_limit_exceeded`. - - - `"server_error"` - - - `"rate_limit_exceeded"` - - - `message: string` - - A human-readable description of the error. - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `object: "thread.run.step"` - - The object type, which is always `thread.run.step`. - - - `"thread.run.step"` - - - `run_id: string` - - The ID of the [run](/docs/api-reference/runs) that this run step is a part of. - - - `status: "in_progress" or "cancelled" or "failed" or 2 more` - - The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`. - - - `"in_progress"` - - - `"cancelled"` - - - `"failed"` - - - `"completed"` - - - `"expired"` - - - `step_details: MessageCreationStepDetails or ToolCallsStepDetails` - - The details of the run step. - - - `MessageCreationStepDetails = object { message_creation, type }` - - Details of the message creation by the run step. - - - `message_creation: object { message_id }` - - - `message_id: string` - - The ID of the message that was created by this run step. - - - `type: "message_creation"` - - Always `message_creation`. - - - `"message_creation"` - - - `ToolCallsStepDetails = object { tool_calls, type }` - - Details of the tool call. - - - `tool_calls: array of CodeInterpreterToolCall or FileSearchToolCall or FunctionToolCall` - - An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. - - - `CodeInterpreterToolCall = object { id, code_interpreter, type }` - - Details of the Code Interpreter tool call the run step was involved in. - - - `id: string` - - The ID of the tool call. - - - `code_interpreter: object { input, outputs }` - - The Code Interpreter tool call definition. - - - `input: string` - - The input to the Code Interpreter tool call. - - - `outputs: array of object { logs, type } or object { image, type }` - - The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. - - - `CodeInterpreterLogOutput = object { logs, type }` - - Text output from the Code Interpreter tool call as part of a run step. - - - `logs: string` - - The text output from the Code Interpreter tool call. - - - `type: "logs"` - - Always `logs`. - - - `"logs"` - - - `CodeInterpreterImageOutput = object { image, type }` - - - `image: object { file_id }` - - - `file_id: string` - - The [file](/docs/api-reference/files) ID of the image. - - - `type: "image"` - - Always `image`. - - - `"image"` - - - `type: "code_interpreter"` - - The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - - - `"code_interpreter"` - - - `FileSearchToolCall = object { id, file_search, type }` - - - `id: string` - - The ID of the tool call object. - - - `file_search: object { ranking_options, results }` - - For now, this is always going to be an empty object. - - - `ranking_options: optional object { ranker, score_threshold }` - - The ranking options for the file search. - - - `ranker: "auto" or "default_2024_08_21"` - - The ranker to use for the file search. If not specified will use the `auto` ranker. - - - `"auto"` - - - `"default_2024_08_21"` - - - `score_threshold: number` - - The score threshold for the file search. All values must be a floating point number between 0 and 1. - - - `results: optional array of object { file_id, file_name, score, content }` - - The results of the file search. - - - `file_id: string` - - The ID of the file that result was found in. - - - `file_name: string` - - The name of the file that result was found in. - - - `score: number` - - The score of the result. All values must be a floating point number between 0 and 1. - - - `content: optional array of object { text, type }` - - The content of the result that was found. The content is only included if requested via the include query parameter. - - - `text: optional string` - - The text content of the file. - - - `type: optional "text"` - - The type of the content. - - - `"text"` - - - `type: "file_search"` - - The type of tool call. This is always going to be `file_search` for this type of tool call. - - - `"file_search"` - - - `FunctionToolCall = object { id, function, type }` - - - `id: string` - - The ID of the tool call object. - - - `function: object { arguments, name, output }` - - The definition of the function that was called. - - - `arguments: string` - - The arguments passed to the function. - - - `name: string` - - The name of the function. - - - `output: string` - - The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. - - - `type: "function"` - - The type of tool call. This is always going to be `function` for this type of tool call. - - - `"function"` - - - `type: "tool_calls"` - - Always `tool_calls`. - - - `"tool_calls"` - - - `thread_id: string` - - The ID of the [thread](/docs/api-reference/threads) that was run. - - - `type: "message_creation" or "tool_calls"` - - The type of run step, which can be either `message_creation` or `tool_calls`. - - - `"message_creation"` - - - `"tool_calls"` - - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - - Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. - - - `completion_tokens: number` - - Number of completion tokens used over the course of the run step. - - - `prompt_tokens: number` - - Number of prompt tokens used over the course of the run step. - - - `total_tokens: number` - - Total number of tokens used (prompt + completion). - - - `event: "thread.run.step.completed"` - - - `"thread.run.step.completed"` - - - `object { data, event }` - - Occurs when a [run step](/docs/api-reference/run-steps/step-object) fails. - - - `data: RunStep` - - Represents a step in execution of a run. - - - `id: string` - - The identifier of the run step, which can be referenced in API endpoints. - - - `assistant_id: string` - - The ID of the [assistant](/docs/api-reference/assistants) associated with the run step. - - - `cancelled_at: number` - - The Unix timestamp (in seconds) for when the run step was cancelled. - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the run step completed. - - - `created_at: number` - - The Unix timestamp (in seconds) for when the run step was created. - - - `expired_at: number` - - The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired. - - - `failed_at: number` - - The Unix timestamp (in seconds) for when the run step failed. - - - `last_error: object { code, message }` - - The last error associated with this run step. Will be `null` if there are no errors. - - - `code: "server_error" or "rate_limit_exceeded"` - - One of `server_error` or `rate_limit_exceeded`. - - - `"server_error"` - - - `"rate_limit_exceeded"` - - - `message: string` - - A human-readable description of the error. - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `object: "thread.run.step"` - - The object type, which is always `thread.run.step`. - - - `"thread.run.step"` - - - `run_id: string` - - The ID of the [run](/docs/api-reference/runs) that this run step is a part of. - - - `status: "in_progress" or "cancelled" or "failed" or 2 more` - - The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`. - - - `"in_progress"` - - - `"cancelled"` - - - `"failed"` - - - `"completed"` - - - `"expired"` - - - `step_details: MessageCreationStepDetails or ToolCallsStepDetails` - - The details of the run step. - - - `MessageCreationStepDetails = object { message_creation, type }` - - Details of the message creation by the run step. - - - `message_creation: object { message_id }` - - - `message_id: string` - - The ID of the message that was created by this run step. - - - `type: "message_creation"` - - Always `message_creation`. - - - `"message_creation"` - - - `ToolCallsStepDetails = object { tool_calls, type }` - - Details of the tool call. - - - `tool_calls: array of CodeInterpreterToolCall or FileSearchToolCall or FunctionToolCall` - - An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. - - - `CodeInterpreterToolCall = object { id, code_interpreter, type }` - - Details of the Code Interpreter tool call the run step was involved in. - - - `id: string` - - The ID of the tool call. - - - `code_interpreter: object { input, outputs }` - - The Code Interpreter tool call definition. - - - `input: string` - - The input to the Code Interpreter tool call. - - - `outputs: array of object { logs, type } or object { image, type }` - - The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. - - - `CodeInterpreterLogOutput = object { logs, type }` - - Text output from the Code Interpreter tool call as part of a run step. - - - `logs: string` - - The text output from the Code Interpreter tool call. - - - `type: "logs"` - - Always `logs`. - - - `"logs"` - - - `CodeInterpreterImageOutput = object { image, type }` - - - `image: object { file_id }` - - - `file_id: string` - - The [file](/docs/api-reference/files) ID of the image. - - - `type: "image"` - - Always `image`. - - - `"image"` - - - `type: "code_interpreter"` - - The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - - - `"code_interpreter"` - - - `FileSearchToolCall = object { id, file_search, type }` - - - `id: string` - - The ID of the tool call object. - - - `file_search: object { ranking_options, results }` - - For now, this is always going to be an empty object. - - - `ranking_options: optional object { ranker, score_threshold }` - - The ranking options for the file search. - - - `ranker: "auto" or "default_2024_08_21"` - - The ranker to use for the file search. If not specified will use the `auto` ranker. - - - `"auto"` - - - `"default_2024_08_21"` - - - `score_threshold: number` - - The score threshold for the file search. All values must be a floating point number between 0 and 1. - - - `results: optional array of object { file_id, file_name, score, content }` - - The results of the file search. - - - `file_id: string` - - The ID of the file that result was found in. - - - `file_name: string` - - The name of the file that result was found in. - - - `score: number` - - The score of the result. All values must be a floating point number between 0 and 1. - - - `content: optional array of object { text, type }` - - The content of the result that was found. The content is only included if requested via the include query parameter. - - - `text: optional string` - - The text content of the file. - - - `type: optional "text"` - - The type of the content. - - - `"text"` - - - `type: "file_search"` - - The type of tool call. This is always going to be `file_search` for this type of tool call. - - - `"file_search"` - - - `FunctionToolCall = object { id, function, type }` - - - `id: string` - - The ID of the tool call object. - - - `function: object { arguments, name, output }` - - The definition of the function that was called. - - - `arguments: string` - - The arguments passed to the function. - - - `name: string` - - The name of the function. - - - `output: string` - - The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. - - - `type: "function"` - - The type of tool call. This is always going to be `function` for this type of tool call. - - - `"function"` - - - `type: "tool_calls"` - - Always `tool_calls`. - - - `"tool_calls"` - - - `thread_id: string` - - The ID of the [thread](/docs/api-reference/threads) that was run. - - - `type: "message_creation" or "tool_calls"` - - The type of run step, which can be either `message_creation` or `tool_calls`. - - - `"message_creation"` - - - `"tool_calls"` - - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - - Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. - - - `completion_tokens: number` - - Number of completion tokens used over the course of the run step. - - - `prompt_tokens: number` - - Number of prompt tokens used over the course of the run step. - - - `total_tokens: number` - - Total number of tokens used (prompt + completion). - - - `event: "thread.run.step.failed"` - - - `"thread.run.step.failed"` - - - `object { data, event }` - - Occurs when a [run step](/docs/api-reference/run-steps/step-object) is cancelled. - - - `data: RunStep` - - Represents a step in execution of a run. - - - `id: string` - - The identifier of the run step, which can be referenced in API endpoints. - - - `assistant_id: string` - - The ID of the [assistant](/docs/api-reference/assistants) associated with the run step. - - - `cancelled_at: number` - - The Unix timestamp (in seconds) for when the run step was cancelled. - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the run step completed. - - - `created_at: number` - - The Unix timestamp (in seconds) for when the run step was created. - - - `expired_at: number` - - The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired. - - - `failed_at: number` - - The Unix timestamp (in seconds) for when the run step failed. - - - `last_error: object { code, message }` - - The last error associated with this run step. Will be `null` if there are no errors. - - - `code: "server_error" or "rate_limit_exceeded"` - - One of `server_error` or `rate_limit_exceeded`. - - - `"server_error"` - - - `"rate_limit_exceeded"` - - - `message: string` - - A human-readable description of the error. - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `object: "thread.run.step"` - - The object type, which is always `thread.run.step`. - - - `"thread.run.step"` - - - `run_id: string` - - The ID of the [run](/docs/api-reference/runs) that this run step is a part of. - - - `status: "in_progress" or "cancelled" or "failed" or 2 more` - - The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`. - - - `"in_progress"` - - - `"cancelled"` - - - `"failed"` - - - `"completed"` - - - `"expired"` - - - `step_details: MessageCreationStepDetails or ToolCallsStepDetails` - - The details of the run step. - - - `MessageCreationStepDetails = object { message_creation, type }` - - Details of the message creation by the run step. - - - `message_creation: object { message_id }` - - - `message_id: string` - - The ID of the message that was created by this run step. - - - `type: "message_creation"` - - Always `message_creation`. - - - `"message_creation"` - - - `ToolCallsStepDetails = object { tool_calls, type }` - - Details of the tool call. - - - `tool_calls: array of CodeInterpreterToolCall or FileSearchToolCall or FunctionToolCall` - - An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. - - - `CodeInterpreterToolCall = object { id, code_interpreter, type }` - - Details of the Code Interpreter tool call the run step was involved in. - - - `id: string` - - The ID of the tool call. - - - `code_interpreter: object { input, outputs }` - - The Code Interpreter tool call definition. - - - `input: string` - - The input to the Code Interpreter tool call. - - - `outputs: array of object { logs, type } or object { image, type }` - - The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. - - - `CodeInterpreterLogOutput = object { logs, type }` - - Text output from the Code Interpreter tool call as part of a run step. - - - `logs: string` - - The text output from the Code Interpreter tool call. - - - `type: "logs"` - - Always `logs`. - - - `"logs"` - - - `CodeInterpreterImageOutput = object { image, type }` - - - `image: object { file_id }` - - - `file_id: string` - - The [file](/docs/api-reference/files) ID of the image. - - - `type: "image"` - - Always `image`. - - - `"image"` - - - `type: "code_interpreter"` - - The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - - - `"code_interpreter"` - - - `FileSearchToolCall = object { id, file_search, type }` - - - `id: string` - - The ID of the tool call object. - - - `file_search: object { ranking_options, results }` - - For now, this is always going to be an empty object. - - - `ranking_options: optional object { ranker, score_threshold }` - - The ranking options for the file search. - - - `ranker: "auto" or "default_2024_08_21"` - - The ranker to use for the file search. If not specified will use the `auto` ranker. - - - `"auto"` - - - `"default_2024_08_21"` - - - `score_threshold: number` - - The score threshold for the file search. All values must be a floating point number between 0 and 1. - - - `results: optional array of object { file_id, file_name, score, content }` - - The results of the file search. - - - `file_id: string` - - The ID of the file that result was found in. - - - `file_name: string` - - The name of the file that result was found in. - - - `score: number` - - The score of the result. All values must be a floating point number between 0 and 1. - - - `content: optional array of object { text, type }` - - The content of the result that was found. The content is only included if requested via the include query parameter. - - - `text: optional string` - - The text content of the file. - - - `type: optional "text"` - - The type of the content. - - - `"text"` - - - `type: "file_search"` - - The type of tool call. This is always going to be `file_search` for this type of tool call. - - - `"file_search"` - - - `FunctionToolCall = object { id, function, type }` - - - `id: string` - - The ID of the tool call object. - - - `function: object { arguments, name, output }` - - The definition of the function that was called. - - - `arguments: string` - - The arguments passed to the function. - - - `name: string` - - The name of the function. - - - `output: string` - - The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. - - - `type: "function"` - - The type of tool call. This is always going to be `function` for this type of tool call. - - - `"function"` - - - `type: "tool_calls"` - - Always `tool_calls`. - - - `"tool_calls"` - - - `thread_id: string` - - The ID of the [thread](/docs/api-reference/threads) that was run. - - - `type: "message_creation" or "tool_calls"` - - The type of run step, which can be either `message_creation` or `tool_calls`. - - - `"message_creation"` - - - `"tool_calls"` - - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - - Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. - - - `completion_tokens: number` - - Number of completion tokens used over the course of the run step. - - - `prompt_tokens: number` - - Number of prompt tokens used over the course of the run step. - - - `total_tokens: number` - - Total number of tokens used (prompt + completion). - - - `event: "thread.run.step.cancelled"` - - - `"thread.run.step.cancelled"` - - - `object { data, event }` - - Occurs when a [run step](/docs/api-reference/run-steps/step-object) expires. - - - `data: RunStep` - - Represents a step in execution of a run. - - - `id: string` - - The identifier of the run step, which can be referenced in API endpoints. - - - `assistant_id: string` - - The ID of the [assistant](/docs/api-reference/assistants) associated with the run step. - - - `cancelled_at: number` - - The Unix timestamp (in seconds) for when the run step was cancelled. - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the run step completed. - - - `created_at: number` - - The Unix timestamp (in seconds) for when the run step was created. - - - `expired_at: number` - - The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired. - - - `failed_at: number` - - The Unix timestamp (in seconds) for when the run step failed. - - - `last_error: object { code, message }` - - The last error associated with this run step. Will be `null` if there are no errors. - - - `code: "server_error" or "rate_limit_exceeded"` - - One of `server_error` or `rate_limit_exceeded`. - - - `"server_error"` - - - `"rate_limit_exceeded"` - - - `message: string` - - A human-readable description of the error. - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `object: "thread.run.step"` - - The object type, which is always `thread.run.step`. - - - `"thread.run.step"` - - - `run_id: string` - - The ID of the [run](/docs/api-reference/runs) that this run step is a part of. - - - `status: "in_progress" or "cancelled" or "failed" or 2 more` - - The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`. - - - `"in_progress"` - - - `"cancelled"` - - - `"failed"` - - - `"completed"` - - - `"expired"` - - - `step_details: MessageCreationStepDetails or ToolCallsStepDetails` - - The details of the run step. - - - `MessageCreationStepDetails = object { message_creation, type }` - - Details of the message creation by the run step. - - - `message_creation: object { message_id }` - - - `message_id: string` - - The ID of the message that was created by this run step. - - - `type: "message_creation"` - - Always `message_creation`. - - - `"message_creation"` - - - `ToolCallsStepDetails = object { tool_calls, type }` - - Details of the tool call. - - - `tool_calls: array of CodeInterpreterToolCall or FileSearchToolCall or FunctionToolCall` - - An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. - - - `CodeInterpreterToolCall = object { id, code_interpreter, type }` - - Details of the Code Interpreter tool call the run step was involved in. - - - `id: string` - - The ID of the tool call. - - - `code_interpreter: object { input, outputs }` - - The Code Interpreter tool call definition. - - - `input: string` - - The input to the Code Interpreter tool call. - - - `outputs: array of object { logs, type } or object { image, type }` - - The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. - - - `CodeInterpreterLogOutput = object { logs, type }` - - Text output from the Code Interpreter tool call as part of a run step. - - - `logs: string` - - The text output from the Code Interpreter tool call. - - - `type: "logs"` - - Always `logs`. - - - `"logs"` - - - `CodeInterpreterImageOutput = object { image, type }` - - - `image: object { file_id }` - - - `file_id: string` - - The [file](/docs/api-reference/files) ID of the image. - - - `type: "image"` - - Always `image`. - - - `"image"` - - - `type: "code_interpreter"` - - The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - - - `"code_interpreter"` - - - `FileSearchToolCall = object { id, file_search, type }` - - - `id: string` - - The ID of the tool call object. - - - `file_search: object { ranking_options, results }` - - For now, this is always going to be an empty object. - - - `ranking_options: optional object { ranker, score_threshold }` - - The ranking options for the file search. - - - `ranker: "auto" or "default_2024_08_21"` - - The ranker to use for the file search. If not specified will use the `auto` ranker. - - - `"auto"` - - - `"default_2024_08_21"` - - - `score_threshold: number` - - The score threshold for the file search. All values must be a floating point number between 0 and 1. - - - `results: optional array of object { file_id, file_name, score, content }` - - The results of the file search. - - - `file_id: string` - - The ID of the file that result was found in. - - - `file_name: string` - - The name of the file that result was found in. - - - `score: number` - - The score of the result. All values must be a floating point number between 0 and 1. - - - `content: optional array of object { text, type }` - - The content of the result that was found. The content is only included if requested via the include query parameter. - - - `text: optional string` - - The text content of the file. - - - `type: optional "text"` - - The type of the content. - - - `"text"` - - - `type: "file_search"` - - The type of tool call. This is always going to be `file_search` for this type of tool call. - - - `"file_search"` - - - `FunctionToolCall = object { id, function, type }` - - - `id: string` - - The ID of the tool call object. - - - `function: object { arguments, name, output }` - - The definition of the function that was called. - - - `arguments: string` - - The arguments passed to the function. - - - `name: string` - - The name of the function. - - - `output: string` - - The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. - - - `type: "function"` - - The type of tool call. This is always going to be `function` for this type of tool call. - - - `"function"` - - - `type: "tool_calls"` - - Always `tool_calls`. - - - `"tool_calls"` - - - `thread_id: string` - - The ID of the [thread](/docs/api-reference/threads) that was run. - - - `type: "message_creation" or "tool_calls"` - - The type of run step, which can be either `message_creation` or `tool_calls`. - - - `"message_creation"` - - - `"tool_calls"` - - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - - Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. - - - `completion_tokens: number` - - Number of completion tokens used over the course of the run step. - - - `prompt_tokens: number` - - Number of prompt tokens used over the course of the run step. - - - `total_tokens: number` - - Total number of tokens used (prompt + completion). - - - `event: "thread.run.step.expired"` - - - `"thread.run.step.expired"` - -### Run Stream Event - -- `RunStreamEvent = object { data, event } or object { data, event } or object { data, event } or 7 more` - - Occurs when a new [run](/docs/api-reference/runs/object) is created. - - - `object { data, event }` - - Occurs when a new [run](/docs/api-reference/runs/object) is created. - - - `data: Run` - - Represents an execution run on a [thread](/docs/api-reference/threads). - - - `id: string` - - The identifier, which can be referenced in API endpoints. - - - `assistant_id: string` - - The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run. - - - `cancelled_at: number` - - The Unix timestamp (in seconds) for when the run was cancelled. - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the run was completed. - - - `created_at: number` - - The Unix timestamp (in seconds) for when the run was created. - - - `expires_at: number` - - The Unix timestamp (in seconds) for when the run will expire. - - - `failed_at: number` - - The Unix timestamp (in seconds) for when the run failed. - - - `incomplete_details: object { reason }` - - Details on why the run is incomplete. Will be `null` if the run is not incomplete. - - - `reason: optional "max_completion_tokens" or "max_prompt_tokens"` - - The 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_prompt_tokens"` - - - `instructions: string` - - The instructions that the [assistant](/docs/api-reference/assistants) used for this run. - - - `last_error: object { code, message }` - - The last error associated with this run. Will be `null` if there are no errors. - - - `code: "server_error" or "rate_limit_exceeded" or "invalid_prompt"` - - One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. - - - `"server_error"` - - - `"rate_limit_exceeded"` - - - `"invalid_prompt"` - - - `message: string` - - A human-readable description of the error. - - - `max_completion_tokens: number` - - The maximum number of completion tokens specified to have been used over the course of the run. - - - `max_prompt_tokens: number` - - The maximum number of prompt tokens specified to have been used over the course of the run. - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `model: string` - - The model that the [assistant](/docs/api-reference/assistants) used for this run. - - - `object: "thread.run"` - - The object type, which is always `thread.run`. - - - `"thread.run"` - - - `parallel_tool_calls: boolean` - - Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. - - - `required_action: object { submit_tool_outputs, type }` - - Details on the action required to continue the run. Will be `null` if no action is required. - - - `submit_tool_outputs: object { tool_calls }` - - Details on the tool outputs needed for this run to continue. - - - `tool_calls: array of RequiredActionFunctionToolCall` - - A list of the relevant tool calls. - - - `id: string` - - The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint. - - - `function: object { arguments, name }` - - The function definition. - - - `arguments: string` - - The arguments that the model expects you to pass to the function. - - - `name: string` - - The name of the function. - - - `type: "function"` - - The type of tool call the output is required for. For now, this is always `function`. - - - `"function"` - - - `type: "submit_tool_outputs"` - - For now, this is always `submit_tool_outputs`. - - - `"submit_tool_outputs"` - - - `response_format: AssistantResponseFormatOption` - - Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), 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](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - - - `"auto"` - - `auto` is the default value - - - `"auto"` - - - `ResponseFormatText = object { type }` - - Default response format. Used to generate text responses. - - - `type: "text"` - - The type of response format being defined. Always `text`. - - - `"text"` - - - `ResponseFormatJSONObject = object { type }` - - JSON object response format. An older method of generating JSON responses. - Using `json_schema` is recommended for models that support it. Note that the - model will not generate JSON without a system or user message instructing it - to do so. - - - `type: "json_object"` - - The type of response format being defined. Always `json_object`. - - - `"json_object"` - - - `ResponseFormatJSONSchema = object { json_schema, type }` - - JSON Schema response format. Used to generate structured JSON responses. - Learn more about [Structured Outputs](/docs/guides/structured-outputs). - - - `json_schema: object { name, description, schema, strict }` - - Structured Outputs configuration options, including a JSON Schema. - - - `name: string` - - The name of the response format. Must be a-z, A-Z, 0-9, or contain - underscores and dashes, with a maximum length of 64. - - - `description: optional string` - - A description of what the response format is for, used by the model to - determine how to respond in the format. - - - `schema: optional map[unknown]` - - The schema for the response format, described as a JSON Schema object. - Learn how to build JSON schemas [here](https://json-schema.org/). - - - `strict: optional boolean` - - Whether to enable strict schema adherence when generating the output. - If set to true, the model will always follow the exact schema defined - in the `schema` field. Only a subset of JSON Schema is supported when - `strict` is `true`. To learn more, read the [Structured Outputs - guide](/docs/guides/structured-outputs). - - - `type: "json_schema"` - - The type of response format being defined. Always `json_schema`. - - - `"json_schema"` - - - `started_at: number` - - The Unix timestamp (in seconds) for when the run was started. - - - `status: "queued" or "in_progress" or "requires_action" or 6 more` - - The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. - - - `"queued"` - - - `"in_progress"` - - - `"requires_action"` - - - `"cancelling"` - - - `"cancelled"` - - - `"failed"` - - - `"completed"` - - - `"incomplete"` - - - `"expired"` - - - `thread_id: string` - - The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run. - - - `tool_choice: AssistantToolChoiceOption` - - Controls which (if any) tool is called by the model. - `none` means the model will not call any tools and instead generates a message. - `auto` is the default value and means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools before responding to the user. - Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. - - - `"none" or "auto" or "required"` - - `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user. - - - `"none"` - - - `"auto"` - - - `"required"` - - - `AssistantToolChoice = object { type, function }` - - Specifies a tool the model should use. Use to force the model to call a specific tool. - - - `type: "function" or "code_interpreter" or "file_search"` - - The type of the tool. If type is `function`, the function name must be set - - - `"function"` - - - `"code_interpreter"` - - - `"file_search"` - - - `function: optional AssistantToolChoiceFunction` - - - `name: string` - - The name of the function to call. - - - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool` - - The list of tools that the [assistant](/docs/api-reference/assistants) used for this run. - - - `CodeInterpreterTool = object { type }` - - - `type: "code_interpreter"` - - The type of tool being defined: `code_interpreter` - - - `"code_interpreter"` - - - `FileSearchTool = object { type, file_search }` - - - `type: "file_search"` - - The type of tool being defined: `file_search` - - - `"file_search"` - - - `file_search: optional object { max_num_results, ranking_options }` - - Overrides for the file search tool. - - - `max_num_results: optional number` - - The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. - - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `ranking_options: optional object { score_threshold, ranker }` - - The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. - - See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `score_threshold: number` - - The score threshold for the file search. All values must be a floating point number between 0 and 1. - - - `ranker: optional "auto" or "default_2024_08_21"` - - The ranker to use for the file search. If not specified will use the `auto` ranker. - - - `"auto"` - - - `"default_2024_08_21"` - - - `FunctionTool = object { function, type }` - - - `function: FunctionDefinition` - - - `name: string` - - The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - - - `description: optional string` - - A description of what the function does, used by the model to choose when and how to call the function. - - - `parameters: optional FunctionParameters` - - The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. - - Omitting `parameters` defines a function with an empty parameter list. - - - `strict: optional boolean` - - Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling). - - - `type: "function"` - - The type of tool being defined: `function` - - - `"function"` - - - `truncation_strategy: object { type, last_messages }` - - Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. - - - `type: "auto" or "last_messages"` - - The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`. - - - `"auto"` - - - `"last_messages"` - - - `last_messages: optional number` - - The number of most recent messages from the thread when constructing the context for the run. - - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - - Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). - - - `completion_tokens: number` - - Number of completion tokens used over the course of the run. - - - `prompt_tokens: number` - - Number of prompt tokens used over the course of the run. - - - `total_tokens: number` - - Total number of tokens used (prompt + completion). - - - `temperature: optional number` - - The sampling temperature used for this run. If not set, defaults to 1. - - - `top_p: optional number` - - The nucleus sampling value used for this run. If not set, defaults to 1. - - - `event: "thread.run.created"` - - - `"thread.run.created"` - - - `object { data, event }` - - Occurs when a [run](/docs/api-reference/runs/object) moves to a `queued` status. - - - `data: Run` - - Represents an execution run on a [thread](/docs/api-reference/threads). - - - `id: string` - - The identifier, which can be referenced in API endpoints. - - - `assistant_id: string` - - The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run. - - - `cancelled_at: number` - - The Unix timestamp (in seconds) for when the run was cancelled. - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the run was completed. - - - `created_at: number` - - The Unix timestamp (in seconds) for when the run was created. - - - `expires_at: number` - - The Unix timestamp (in seconds) for when the run will expire. - - - `failed_at: number` - - The Unix timestamp (in seconds) for when the run failed. - - - `incomplete_details: object { reason }` - - Details on why the run is incomplete. Will be `null` if the run is not incomplete. - - - `reason: optional "max_completion_tokens" or "max_prompt_tokens"` - - The 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_prompt_tokens"` - - - `instructions: string` - - The instructions that the [assistant](/docs/api-reference/assistants) used for this run. - - - `last_error: object { code, message }` - - The last error associated with this run. Will be `null` if there are no errors. - - - `code: "server_error" or "rate_limit_exceeded" or "invalid_prompt"` - - One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. - - - `"server_error"` - - - `"rate_limit_exceeded"` - - - `"invalid_prompt"` - - - `message: string` - - A human-readable description of the error. - - - `max_completion_tokens: number` - - The maximum number of completion tokens specified to have been used over the course of the run. - - - `max_prompt_tokens: number` - - The maximum number of prompt tokens specified to have been used over the course of the run. - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `model: string` - - The model that the [assistant](/docs/api-reference/assistants) used for this run. - - - `object: "thread.run"` - - The object type, which is always `thread.run`. - - - `"thread.run"` - - - `parallel_tool_calls: boolean` - - Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. - - - `required_action: object { submit_tool_outputs, type }` - - Details on the action required to continue the run. Will be `null` if no action is required. - - - `submit_tool_outputs: object { tool_calls }` - - Details on the tool outputs needed for this run to continue. - - - `tool_calls: array of RequiredActionFunctionToolCall` - - A list of the relevant tool calls. - - - `id: string` - - The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint. - - - `function: object { arguments, name }` - - The function definition. - - - `arguments: string` - - The arguments that the model expects you to pass to the function. - - - `name: string` - - The name of the function. - - - `type: "function"` - - The type of tool call the output is required for. For now, this is always `function`. - - - `"function"` - - - `type: "submit_tool_outputs"` - - For now, this is always `submit_tool_outputs`. - - - `"submit_tool_outputs"` - - - `response_format: AssistantResponseFormatOption` - - Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), 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](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - - - `"auto"` - - `auto` is the default value - - - `"auto"` - - - `ResponseFormatText = object { type }` - - Default response format. Used to generate text responses. - - - `type: "text"` - - The type of response format being defined. Always `text`. - - - `"text"` - - - `ResponseFormatJSONObject = object { type }` - - JSON object response format. An older method of generating JSON responses. - Using `json_schema` is recommended for models that support it. Note that the - model will not generate JSON without a system or user message instructing it - to do so. - - - `type: "json_object"` - - The type of response format being defined. Always `json_object`. - - - `"json_object"` - - - `ResponseFormatJSONSchema = object { json_schema, type }` - - JSON Schema response format. Used to generate structured JSON responses. - Learn more about [Structured Outputs](/docs/guides/structured-outputs). - - - `json_schema: object { name, description, schema, strict }` - - Structured Outputs configuration options, including a JSON Schema. - - - `name: string` - - The name of the response format. Must be a-z, A-Z, 0-9, or contain - underscores and dashes, with a maximum length of 64. - - - `description: optional string` - - A description of what the response format is for, used by the model to - determine how to respond in the format. - - - `schema: optional map[unknown]` - - The schema for the response format, described as a JSON Schema object. - Learn how to build JSON schemas [here](https://json-schema.org/). - - - `strict: optional boolean` - - Whether to enable strict schema adherence when generating the output. - If set to true, the model will always follow the exact schema defined - in the `schema` field. Only a subset of JSON Schema is supported when - `strict` is `true`. To learn more, read the [Structured Outputs - guide](/docs/guides/structured-outputs). - - - `type: "json_schema"` - - The type of response format being defined. Always `json_schema`. - - - `"json_schema"` - - - `started_at: number` - - The Unix timestamp (in seconds) for when the run was started. - - - `status: "queued" or "in_progress" or "requires_action" or 6 more` - - The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. - - - `"queued"` - - - `"in_progress"` - - - `"requires_action"` - - - `"cancelling"` - - - `"cancelled"` - - - `"failed"` - - - `"completed"` - - - `"incomplete"` - - - `"expired"` - - - `thread_id: string` - - The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run. - - - `tool_choice: AssistantToolChoiceOption` - - Controls which (if any) tool is called by the model. - `none` means the model will not call any tools and instead generates a message. - `auto` is the default value and means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools before responding to the user. - Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. - - - `"none" or "auto" or "required"` - - `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user. - - - `"none"` - - - `"auto"` - - - `"required"` - - - `AssistantToolChoice = object { type, function }` - - Specifies a tool the model should use. Use to force the model to call a specific tool. - - - `type: "function" or "code_interpreter" or "file_search"` - - The type of the tool. If type is `function`, the function name must be set - - - `"function"` - - - `"code_interpreter"` - - - `"file_search"` - - - `function: optional AssistantToolChoiceFunction` - - - `name: string` - - The name of the function to call. - - - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool` - - The list of tools that the [assistant](/docs/api-reference/assistants) used for this run. - - - `CodeInterpreterTool = object { type }` - - - `type: "code_interpreter"` - - The type of tool being defined: `code_interpreter` - - - `"code_interpreter"` - - - `FileSearchTool = object { type, file_search }` - - - `type: "file_search"` - - The type of tool being defined: `file_search` - - - `"file_search"` - - - `file_search: optional object { max_num_results, ranking_options }` - - Overrides for the file search tool. - - - `max_num_results: optional number` - - The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. - - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `ranking_options: optional object { score_threshold, ranker }` - - The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. - - See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `score_threshold: number` - - The score threshold for the file search. All values must be a floating point number between 0 and 1. - - - `ranker: optional "auto" or "default_2024_08_21"` - - The ranker to use for the file search. If not specified will use the `auto` ranker. - - - `"auto"` - - - `"default_2024_08_21"` - - - `FunctionTool = object { function, type }` - - - `function: FunctionDefinition` - - - `name: string` - - The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - - - `description: optional string` - - A description of what the function does, used by the model to choose when and how to call the function. - - - `parameters: optional FunctionParameters` - - The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. - - Omitting `parameters` defines a function with an empty parameter list. - - - `strict: optional boolean` - - Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling). - - - `type: "function"` - - The type of tool being defined: `function` - - - `"function"` - - - `truncation_strategy: object { type, last_messages }` - - Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. - - - `type: "auto" or "last_messages"` - - The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`. - - - `"auto"` - - - `"last_messages"` - - - `last_messages: optional number` - - The number of most recent messages from the thread when constructing the context for the run. - - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - - Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). - - - `completion_tokens: number` - - Number of completion tokens used over the course of the run. - - - `prompt_tokens: number` - - Number of prompt tokens used over the course of the run. - - - `total_tokens: number` - - Total number of tokens used (prompt + completion). - - - `temperature: optional number` - - The sampling temperature used for this run. If not set, defaults to 1. - - - `top_p: optional number` - - The nucleus sampling value used for this run. If not set, defaults to 1. - - - `event: "thread.run.queued"` - - - `"thread.run.queued"` - - - `object { data, event }` - - Occurs when a [run](/docs/api-reference/runs/object) moves to an `in_progress` status. - - - `data: Run` - - Represents an execution run on a [thread](/docs/api-reference/threads). - - - `id: string` - - The identifier, which can be referenced in API endpoints. - - - `assistant_id: string` - - The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run. - - - `cancelled_at: number` - - The Unix timestamp (in seconds) for when the run was cancelled. - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the run was completed. - - - `created_at: number` - - The Unix timestamp (in seconds) for when the run was created. - - - `expires_at: number` - - The Unix timestamp (in seconds) for when the run will expire. - - - `failed_at: number` - - The Unix timestamp (in seconds) for when the run failed. - - - `incomplete_details: object { reason }` - - Details on why the run is incomplete. Will be `null` if the run is not incomplete. - - - `reason: optional "max_completion_tokens" or "max_prompt_tokens"` - - The 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_prompt_tokens"` - - - `instructions: string` - - The instructions that the [assistant](/docs/api-reference/assistants) used for this run. - - - `last_error: object { code, message }` - - The last error associated with this run. Will be `null` if there are no errors. - - - `code: "server_error" or "rate_limit_exceeded" or "invalid_prompt"` - - One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. - - - `"server_error"` - - - `"rate_limit_exceeded"` - - - `"invalid_prompt"` - - - `message: string` - - A human-readable description of the error. - - - `max_completion_tokens: number` - - The maximum number of completion tokens specified to have been used over the course of the run. - - - `max_prompt_tokens: number` - - The maximum number of prompt tokens specified to have been used over the course of the run. - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `model: string` - - The model that the [assistant](/docs/api-reference/assistants) used for this run. - - - `object: "thread.run"` - - The object type, which is always `thread.run`. - - - `"thread.run"` - - - `parallel_tool_calls: boolean` - - Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. - - - `required_action: object { submit_tool_outputs, type }` - - Details on the action required to continue the run. Will be `null` if no action is required. - - - `submit_tool_outputs: object { tool_calls }` - - Details on the tool outputs needed for this run to continue. - - - `tool_calls: array of RequiredActionFunctionToolCall` - - A list of the relevant tool calls. - - - `id: string` - - The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint. - - - `function: object { arguments, name }` - - The function definition. - - - `arguments: string` - - The arguments that the model expects you to pass to the function. - - - `name: string` - - The name of the function. - - - `type: "function"` - - The type of tool call the output is required for. For now, this is always `function`. - - - `"function"` - - - `type: "submit_tool_outputs"` - - For now, this is always `submit_tool_outputs`. - - - `"submit_tool_outputs"` - - - `response_format: AssistantResponseFormatOption` - - Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), 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](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - - - `"auto"` - - `auto` is the default value - - - `"auto"` - - - `ResponseFormatText = object { type }` - - Default response format. Used to generate text responses. - - - `type: "text"` - - The type of response format being defined. Always `text`. - - - `"text"` - - - `ResponseFormatJSONObject = object { type }` - - JSON object response format. An older method of generating JSON responses. - Using `json_schema` is recommended for models that support it. Note that the - model will not generate JSON without a system or user message instructing it - to do so. - - - `type: "json_object"` - - The type of response format being defined. Always `json_object`. - - - `"json_object"` - - - `ResponseFormatJSONSchema = object { json_schema, type }` - - JSON Schema response format. Used to generate structured JSON responses. - Learn more about [Structured Outputs](/docs/guides/structured-outputs). - - - `json_schema: object { name, description, schema, strict }` - - Structured Outputs configuration options, including a JSON Schema. - - - `name: string` - - The name of the response format. Must be a-z, A-Z, 0-9, or contain - underscores and dashes, with a maximum length of 64. - - - `description: optional string` - - A description of what the response format is for, used by the model to - determine how to respond in the format. - - - `schema: optional map[unknown]` - - The schema for the response format, described as a JSON Schema object. - Learn how to build JSON schemas [here](https://json-schema.org/). - - - `strict: optional boolean` - - Whether to enable strict schema adherence when generating the output. - If set to true, the model will always follow the exact schema defined - in the `schema` field. Only a subset of JSON Schema is supported when - `strict` is `true`. To learn more, read the [Structured Outputs - guide](/docs/guides/structured-outputs). - - - `type: "json_schema"` - - The type of response format being defined. Always `json_schema`. - - - `"json_schema"` - - - `started_at: number` - - The Unix timestamp (in seconds) for when the run was started. - - - `status: "queued" or "in_progress" or "requires_action" or 6 more` - - The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. - - - `"queued"` - - - `"in_progress"` - - - `"requires_action"` - - - `"cancelling"` - - - `"cancelled"` - - - `"failed"` - - - `"completed"` - - - `"incomplete"` - - - `"expired"` - - - `thread_id: string` - - The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run. - - - `tool_choice: AssistantToolChoiceOption` - - Controls which (if any) tool is called by the model. - `none` means the model will not call any tools and instead generates a message. - `auto` is the default value and means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools before responding to the user. - Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. - - - `"none" or "auto" or "required"` - - `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user. - - - `"none"` - - - `"auto"` - - - `"required"` - - - `AssistantToolChoice = object { type, function }` - - Specifies a tool the model should use. Use to force the model to call a specific tool. - - - `type: "function" or "code_interpreter" or "file_search"` - - The type of the tool. If type is `function`, the function name must be set - - - `"function"` - - - `"code_interpreter"` - - - `"file_search"` - - - `function: optional AssistantToolChoiceFunction` - - - `name: string` - - The name of the function to call. - - - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool` - - The list of tools that the [assistant](/docs/api-reference/assistants) used for this run. - - - `CodeInterpreterTool = object { type }` - - - `type: "code_interpreter"` - - The type of tool being defined: `code_interpreter` - - - `"code_interpreter"` - - - `FileSearchTool = object { type, file_search }` - - - `type: "file_search"` - - The type of tool being defined: `file_search` - - - `"file_search"` - - - `file_search: optional object { max_num_results, ranking_options }` - - Overrides for the file search tool. - - - `max_num_results: optional number` - - The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. - - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `ranking_options: optional object { score_threshold, ranker }` - - The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. - - See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - - `score_threshold: number` - - The score threshold for the file search. All values must be a floating point number between 0 and 1. - - - `ranker: optional "auto" or "default_2024_08_21"` - - The ranker to use for the file search. If not specified will use the `auto` ranker. - - - `"auto"` - - - `"default_2024_08_21"` - - - `FunctionTool = object { function, type }` - - - `function: FunctionDefinition` - - - `name: string` - - The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - - - `description: optional string` - - A description of what the function does, used by the model to choose when and how to call the function. - - - `parameters: optional FunctionParameters` - - The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. - - Omitting `parameters` defines a function with an empty parameter list. - - - `strict: optional boolean` - - Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling). - - - `type: "function"` - - The type of tool being defined: `function` - - - `"function"` - - - `truncation_strategy: object { type, last_messages }` - - Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. - - - `type: "auto" or "last_messages"` - - The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`. - - - `"auto"` - - - `"last_messages"` - - - `last_messages: optional number` - - The number of most recent messages from the thread when constructing the context for the run. - - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - - Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). - - - `completion_tokens: number` - - Number of completion tokens used over the course of the run. - - - `prompt_tokens: number` - - Number of prompt tokens used over the course of the run. - - - `total_tokens: number` + - `event: "thread.run.queued"` - Total number of tokens used (prompt + completion). + - `"thread.run.queued"` - - `temperature: optional number` + - `object { data, event }` - The sampling temperature used for this run. If not set, defaults to 1. + Occurs when a [run](/docs/api-reference/runs/object) moves to an `in_progress` status. - - `top_p: optional number` + - `data: Run` - The nucleus sampling value used for this run. If not set, defaults to 1. + Represents an execution run on a [thread](/docs/api-reference/threads). - `event: "thread.run.in_progress"` @@ -14172,2437 +2886,2241 @@ curl https://api.openai.com/v1/assistants/asst_abc123 \ Represents an execution run on a [thread](/docs/api-reference/threads). - - `id: string` - - The identifier, which can be referenced in API endpoints. - - - `assistant_id: string` - - The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run. - - - `cancelled_at: number` - - The Unix timestamp (in seconds) for when the run was cancelled. - - - `completed_at: number` - - The Unix timestamp (in seconds) for when the run was completed. - - - `created_at: number` - - The Unix timestamp (in seconds) for when the run was created. - - - `expires_at: number` - - The Unix timestamp (in seconds) for when the run will expire. - - - `failed_at: number` - - The Unix timestamp (in seconds) for when the run failed. - - - `incomplete_details: object { reason }` - - Details on why the run is incomplete. Will be `null` if the run is not incomplete. - - - `reason: optional "max_completion_tokens" or "max_prompt_tokens"` - - The 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_prompt_tokens"` - - - `instructions: string` - - The instructions that the [assistant](/docs/api-reference/assistants) used for this run. - - - `last_error: object { code, message }` - - The last error associated with this run. Will be `null` if there are no errors. - - - `code: "server_error" or "rate_limit_exceeded" or "invalid_prompt"` - - One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. - - - `"server_error"` - - - `"rate_limit_exceeded"` - - - `"invalid_prompt"` - - - `message: string` - - A human-readable description of the error. - - - `max_completion_tokens: number` - - The maximum number of completion tokens specified to have been used over the course of the run. - - - `max_prompt_tokens: number` - - The maximum number of prompt tokens specified to have been used over the course of the run. - - - `metadata: Metadata` - - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. - - - `model: string` - - The model that the [assistant](/docs/api-reference/assistants) used for this run. - - - `object: "thread.run"` - - The object type, which is always `thread.run`. - - - `"thread.run"` - - - `parallel_tool_calls: boolean` - - Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. - - - `required_action: object { submit_tool_outputs, type }` - - Details on the action required to continue the run. Will be `null` if no action is required. - - - `submit_tool_outputs: object { tool_calls }` - - Details on the tool outputs needed for this run to continue. - - - `tool_calls: array of RequiredActionFunctionToolCall` - - A list of the relevant tool calls. - - - `id: string` + - `event: "thread.run.requires_action"` - The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint. + - `"thread.run.requires_action"` - - `function: object { arguments, name }` + - `object { data, event }` - The function definition. + Occurs when a [run](/docs/api-reference/runs/object) is completed. - - `arguments: string` + - `data: Run` - The arguments that the model expects you to pass to the function. + Represents an execution run on a [thread](/docs/api-reference/threads). - - `name: string` + - `event: "thread.run.completed"` - The name of the function. + - `"thread.run.completed"` - - `type: "function"` + - `object { data, event }` - The type of tool call the output is required for. For now, this is always `function`. + Occurs when a [run](/docs/api-reference/runs/object) ends with status `incomplete`. - - `"function"` + - `data: Run` - - `type: "submit_tool_outputs"` + Represents an execution run on a [thread](/docs/api-reference/threads). - For now, this is always `submit_tool_outputs`. + - `event: "thread.run.incomplete"` - - `"submit_tool_outputs"` + - `"thread.run.incomplete"` - - `response_format: AssistantResponseFormatOption` + - `object { data, event }` - Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`. + Occurs when a [run](/docs/api-reference/runs/object) fails. - 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](/docs/guides/structured-outputs). + - `data: Run` - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + Represents an execution run on a [thread](/docs/api-reference/threads). - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + - `event: "thread.run.failed"` - - `"auto"` + - `"thread.run.failed"` - `auto` is the default value + - `object { data, event }` - - `"auto"` + Occurs when a [run](/docs/api-reference/runs/object) moves to a `cancelling` status. - - `ResponseFormatText = object { type }` + - `data: Run` - Default response format. Used to generate text responses. + Represents an execution run on a [thread](/docs/api-reference/threads). - - `type: "text"` + - `event: "thread.run.cancelling"` - The type of response format being defined. Always `text`. + - `"thread.run.cancelling"` - - `"text"` + - `object { data, event }` - - `ResponseFormatJSONObject = object { type }` + Occurs when a [run](/docs/api-reference/runs/object) is cancelled. - JSON object response format. An older method of generating JSON responses. - Using `json_schema` is recommended for models that support it. Note that the - model will not generate JSON without a system or user message instructing it - to do so. + - `data: Run` - - `type: "json_object"` + Represents an execution run on a [thread](/docs/api-reference/threads). - The type of response format being defined. Always `json_object`. + - `event: "thread.run.cancelled"` - - `"json_object"` + - `"thread.run.cancelled"` - - `ResponseFormatJSONSchema = object { json_schema, type }` + - `object { data, event }` - JSON Schema response format. Used to generate structured JSON responses. - Learn more about [Structured Outputs](/docs/guides/structured-outputs). + Occurs when a [run](/docs/api-reference/runs/object) expires. - - `json_schema: object { name, description, schema, strict }` + - `data: Run` - Structured Outputs configuration options, including a JSON Schema. + Represents an execution run on a [thread](/docs/api-reference/threads). - - `name: string` + - `event: "thread.run.expired"` - The name of the response format. Must be a-z, A-Z, 0-9, or contain - underscores and dashes, with a maximum length of 64. + - `"thread.run.expired"` - - `description: optional string` + - `object { data, event }` - A description of what the response format is for, used by the model to - determine how to respond in the format. + Occurs when a [run step](/docs/api-reference/run-steps/step-object) is created. - - `schema: optional map[unknown]` + - `data: RunStep` - The schema for the response format, described as a JSON Schema object. - Learn how to build JSON schemas [here](https://json-schema.org/). + Represents a step in execution of a run. - - `strict: optional boolean` + - `id: string` - Whether to enable strict schema adherence when generating the output. - If set to true, the model will always follow the exact schema defined - in the `schema` field. Only a subset of JSON Schema is supported when - `strict` is `true`. To learn more, read the [Structured Outputs - guide](/docs/guides/structured-outputs). + The identifier of the run step, which can be referenced in API endpoints. - - `type: "json_schema"` + - `assistant_id: string` - The type of response format being defined. Always `json_schema`. + The ID of the [assistant](/docs/api-reference/assistants) associated with the run step. - - `"json_schema"` + - `cancelled_at: number` - - `started_at: number` + The Unix timestamp (in seconds) for when the run step was cancelled. - The Unix timestamp (in seconds) for when the run was started. + - `completed_at: number` - - `status: "queued" or "in_progress" or "requires_action" or 6 more` + The Unix timestamp (in seconds) for when the run step completed. - The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. + - `created_at: number` - - `"queued"` + The Unix timestamp (in seconds) for when the run step was created. - - `"in_progress"` + - `expired_at: number` - - `"requires_action"` + The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired. - - `"cancelling"` + - `failed_at: number` - - `"cancelled"` + The Unix timestamp (in seconds) for when the run step failed. - - `"failed"` + - `last_error: object { code, message }` - - `"completed"` + The last error associated with this run step. Will be `null` if there are no errors. - - `"incomplete"` + - `code: "server_error" or "rate_limit_exceeded"` - - `"expired"` + One of `server_error` or `rate_limit_exceeded`. - - `thread_id: string` + - `"server_error"` - The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run. + - `"rate_limit_exceeded"` - - `tool_choice: AssistantToolChoiceOption` + - `message: string` - Controls which (if any) tool is called by the model. - `none` means the model will not call any tools and instead generates a message. - `auto` is the default value and means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools before responding to the user. - Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. + A human-readable description of the error. - - `"none" or "auto" or "required"` + - `metadata: Metadata` - `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user. + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. - - `"none"` + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. - - `"auto"` + - `object: "thread.run.step"` - - `"required"` + The object type, which is always `thread.run.step`. - - `AssistantToolChoice = object { type, function }` + - `"thread.run.step"` - Specifies a tool the model should use. Use to force the model to call a specific tool. + - `run_id: string` - - `type: "function" or "code_interpreter" or "file_search"` + The ID of the [run](/docs/api-reference/runs) that this run step is a part of. - The type of the tool. If type is `function`, the function name must be set + - `status: "in_progress" or "cancelled" or "failed" or 2 more` - - `"function"` + The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`. - - `"code_interpreter"` + - `"in_progress"` - - `"file_search"` + - `"cancelled"` - - `function: optional AssistantToolChoiceFunction` + - `"failed"` - - `name: string` + - `"completed"` - The name of the function to call. + - `"expired"` - - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool` + - `step_details: MessageCreationStepDetails or ToolCallsStepDetails` - The list of tools that the [assistant](/docs/api-reference/assistants) used for this run. + The details of the run step. - - `CodeInterpreterTool = object { type }` + - `MessageCreationStepDetails object { message_creation, type }` - - `type: "code_interpreter"` + Details of the message creation by the run step. - The type of tool being defined: `code_interpreter` + - `message_creation: object { message_id }` - - `"code_interpreter"` + - `message_id: string` - - `FileSearchTool = object { type, file_search }` + The ID of the message that was created by this run step. - - `type: "file_search"` + - `type: "message_creation"` - The type of tool being defined: `file_search` + Always `message_creation`. - - `"file_search"` + - `"message_creation"` - - `file_search: optional object { max_num_results, ranking_options }` + - `ToolCallsStepDetails object { tool_calls, type }` - Overrides for the file search tool. + Details of the tool call. - - `max_num_results: optional number` + - `tool_calls: array of CodeInterpreterToolCall or FileSearchToolCall or FunctionToolCall` - The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. + An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + - `CodeInterpreterToolCall object { id, code_interpreter, type }` - - `ranking_options: optional object { score_threshold, ranker }` + Details of the Code Interpreter tool call the run step was involved in. - The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. + - `id: string` - See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + The ID of the tool call. - - `score_threshold: number` + - `code_interpreter: object { input, outputs }` - The score threshold for the file search. All values must be a floating point number between 0 and 1. + The Code Interpreter tool call definition. - - `ranker: optional "auto" or "default_2024_08_21"` + - `input: string` - The ranker to use for the file search. If not specified will use the `auto` ranker. + The input to the Code Interpreter tool call. - - `"auto"` + - `outputs: array of object { logs, type } or object { image, type }` - - `"default_2024_08_21"` + The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. - - `FunctionTool = object { function, type }` + - `CodeInterpreterLogOutput object { logs, type }` - - `function: FunctionDefinition` + Text output from the Code Interpreter tool call as part of a run step. - - `name: string` + - `logs: string` - The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. + The text output from the Code Interpreter tool call. - - `description: optional string` + - `type: "logs"` - A description of what the function does, used by the model to choose when and how to call the function. + Always `logs`. - - `parameters: optional FunctionParameters` + - `"logs"` - The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. + - `CodeInterpreterImageOutput object { image, type }` - Omitting `parameters` defines a function with an empty parameter list. + - `image: object { file_id }` - - `strict: optional boolean` + - `file_id: string` - Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling). + The [file](/docs/api-reference/files) ID of the image. - - `type: "function"` + - `type: "image"` - The type of tool being defined: `function` + Always `image`. - - `"function"` + - `"image"` - - `truncation_strategy: object { type, last_messages }` + - `type: "code_interpreter"` - Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. + The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - - `type: "auto" or "last_messages"` + - `"code_interpreter"` - The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`. + - `FileSearchToolCall object { id, file_search, type }` - - `"auto"` + - `id: string` - - `"last_messages"` + The ID of the tool call object. - - `last_messages: optional number` + - `file_search: object { ranking_options, results }` - The number of most recent messages from the thread when constructing the context for the run. + For now, this is always going to be an empty object. - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` + - `ranking_options: optional object { ranker, score_threshold }` - Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). + The ranking options for the file search. - - `completion_tokens: number` + - `ranker: "auto" or "default_2024_08_21"` - Number of completion tokens used over the course of the run. + The ranker to use for the file search. If not specified will use the `auto` ranker. - - `prompt_tokens: number` + - `"auto"` - Number of prompt tokens used over the course of the run. + - `"default_2024_08_21"` - - `total_tokens: number` + - `score_threshold: number` - Total number of tokens used (prompt + completion). + The score threshold for the file search. All values must be a floating point number between 0 and 1. - - `temperature: optional number` + - `results: optional array of object { file_id, file_name, score, content }` - The sampling temperature used for this run. If not set, defaults to 1. + The results of the file search. - - `top_p: optional number` + - `file_id: string` - The nucleus sampling value used for this run. If not set, defaults to 1. + The ID of the file that result was found in. - - `event: "thread.run.requires_action"` + - `file_name: string` - - `"thread.run.requires_action"` + The name of the file that result was found in. - - `object { data, event }` + - `score: number` - Occurs when a [run](/docs/api-reference/runs/object) is completed. + The score of the result. All values must be a floating point number between 0 and 1. - - `data: Run` + - `content: optional array of object { text, type }` - Represents an execution run on a [thread](/docs/api-reference/threads). + The content of the result that was found. The content is only included if requested via the include query parameter. - - `id: string` + - `text: optional string` - The identifier, which can be referenced in API endpoints. + The text content of the file. - - `assistant_id: string` + - `type: optional "text"` - The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run. + The type of the content. - - `cancelled_at: number` + - `"text"` - The Unix timestamp (in seconds) for when the run was cancelled. + - `type: "file_search"` - - `completed_at: number` + The type of tool call. This is always going to be `file_search` for this type of tool call. - The Unix timestamp (in seconds) for when the run was completed. + - `"file_search"` - - `created_at: number` + - `FunctionToolCall object { id, function, type }` - The Unix timestamp (in seconds) for when the run was created. + - `id: string` - - `expires_at: number` + The ID of the tool call object. - The Unix timestamp (in seconds) for when the run will expire. + - `function: object { arguments, name, output }` - - `failed_at: number` + The definition of the function that was called. - The Unix timestamp (in seconds) for when the run failed. + - `arguments: string` - - `incomplete_details: object { reason }` + The arguments passed to the function. - Details on why the run is incomplete. Will be `null` if the run is not incomplete. + - `name: string` - - `reason: optional "max_completion_tokens" or "max_prompt_tokens"` + The name of the function. - The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run. + - `output: string` - - `"max_completion_tokens"` + The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. - - `"max_prompt_tokens"` + - `type: "function"` - - `instructions: string` + The type of tool call. This is always going to be `function` for this type of tool call. - The instructions that the [assistant](/docs/api-reference/assistants) used for this run. + - `"function"` - - `last_error: object { code, message }` + - `type: "tool_calls"` - The last error associated with this run. Will be `null` if there are no errors. + Always `tool_calls`. - - `code: "server_error" or "rate_limit_exceeded" or "invalid_prompt"` + - `"tool_calls"` - One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. + - `thread_id: string` - - `"server_error"` + The ID of the [thread](/docs/api-reference/threads) that was run. - - `"rate_limit_exceeded"` + - `type: "message_creation" or "tool_calls"` - - `"invalid_prompt"` + The type of run step, which can be either `message_creation` or `tool_calls`. - - `message: string` + - `"message_creation"` - A human-readable description of the error. + - `"tool_calls"` - - `max_completion_tokens: number` + - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - The maximum number of completion tokens specified to have been used over the course of the run. + Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. - - `max_prompt_tokens: number` + - `completion_tokens: number` - The maximum number of prompt tokens specified to have been used over the course of the run. + Number of completion tokens used over the course of the run step. - - `metadata: Metadata` + - `prompt_tokens: number` - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. + Number of prompt tokens used over the course of the run step. - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. + - `total_tokens: number` - - `model: string` + Total number of tokens used (prompt + completion). - The model that the [assistant](/docs/api-reference/assistants) used for this run. + - `event: "thread.run.step.created"` - - `object: "thread.run"` + - `"thread.run.step.created"` - The object type, which is always `thread.run`. + - `object { data, event }` - - `"thread.run"` + Occurs when a [run step](/docs/api-reference/run-steps/step-object) moves to an `in_progress` state. - - `parallel_tool_calls: boolean` + - `data: RunStep` - Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. + Represents a step in execution of a run. - - `required_action: object { submit_tool_outputs, type }` + - `event: "thread.run.step.in_progress"` - Details on the action required to continue the run. Will be `null` if no action is required. + - `"thread.run.step.in_progress"` - - `submit_tool_outputs: object { tool_calls }` + - `object { data, event }` - Details on the tool outputs needed for this run to continue. + Occurs when parts of a [run step](/docs/api-reference/run-steps/step-object) are being streamed. - - `tool_calls: array of RequiredActionFunctionToolCall` + - `data: RunStepDeltaEvent` - A list of the relevant tool calls. + Represents a run step delta i.e. any changed fields on a run step during streaming. - `id: string` - The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint. + The identifier of the run step, which can be referenced in API endpoints. - - `function: object { arguments, name }` + - `delta: object { step_details }` - The function definition. + The delta containing the fields that have changed on the run step. - - `arguments: string` + - `step_details: optional RunStepDeltaMessageDelta or ToolCallDeltaObject` - The arguments that the model expects you to pass to the function. + The details of the run step. - - `name: string` + - `RunStepDeltaMessageDelta object { type, message_creation }` - The name of the function. + Details of the message creation by the run step. - - `type: "function"` + - `type: "message_creation"` - The type of tool call the output is required for. For now, this is always `function`. + Always `message_creation`. - - `"function"` + - `"message_creation"` - - `type: "submit_tool_outputs"` + - `message_creation: optional object { message_id }` - For now, this is always `submit_tool_outputs`. + - `message_id: optional string` - - `"submit_tool_outputs"` + The ID of the message that was created by this run step. - - `response_format: AssistantResponseFormatOption` + - `ToolCallDeltaObject object { type, tool_calls }` - Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`. + Details of the tool call. - 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](/docs/guides/structured-outputs). + - `type: "tool_calls"` - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + Always `tool_calls`. - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + - `"tool_calls"` - - `"auto"` + - `tool_calls: optional array of CodeInterpreterToolCallDelta or FileSearchToolCallDelta or FunctionToolCallDelta` - `auto` is the default value + An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. - - `"auto"` + - `CodeInterpreterToolCallDelta object { index, type, id, code_interpreter }` - - `ResponseFormatText = object { type }` + Details of the Code Interpreter tool call the run step was involved in. - Default response format. Used to generate text responses. + - `index: number` - - `type: "text"` + The index of the tool call in the tool calls array. - The type of response format being defined. Always `text`. + - `type: "code_interpreter"` - - `"text"` + The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - - `ResponseFormatJSONObject = object { type }` + - `"code_interpreter"` - JSON object response format. An older method of generating JSON responses. - Using `json_schema` is recommended for models that support it. Note that the - model will not generate JSON without a system or user message instructing it - to do so. + - `id: optional string` - - `type: "json_object"` + The ID of the tool call. - The type of response format being defined. Always `json_object`. + - `code_interpreter: optional object { input, outputs }` - - `"json_object"` + The Code Interpreter tool call definition. - - `ResponseFormatJSONSchema = object { json_schema, type }` + - `input: optional string` - JSON Schema response format. Used to generate structured JSON responses. - Learn more about [Structured Outputs](/docs/guides/structured-outputs). + The input to the Code Interpreter tool call. - - `json_schema: object { name, description, schema, strict }` + - `outputs: optional array of CodeInterpreterLogs or CodeInterpreterOutputImage` - Structured Outputs configuration options, including a JSON Schema. + The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. - - `name: string` + - `CodeInterpreterLogs object { index, type, logs }` - The name of the response format. Must be a-z, A-Z, 0-9, or contain - underscores and dashes, with a maximum length of 64. + Text output from the Code Interpreter tool call as part of a run step. - - `description: optional string` + - `index: number` - A description of what the response format is for, used by the model to - determine how to respond in the format. + The index of the output in the outputs array. - - `schema: optional map[unknown]` + - `type: "logs"` - The schema for the response format, described as a JSON Schema object. - Learn how to build JSON schemas [here](https://json-schema.org/). + Always `logs`. - - `strict: optional boolean` + - `"logs"` - Whether to enable strict schema adherence when generating the output. - If set to true, the model will always follow the exact schema defined - in the `schema` field. Only a subset of JSON Schema is supported when - `strict` is `true`. To learn more, read the [Structured Outputs - guide](/docs/guides/structured-outputs). + - `logs: optional string` - - `type: "json_schema"` + The text output from the Code Interpreter tool call. - The type of response format being defined. Always `json_schema`. + - `CodeInterpreterOutputImage object { index, type, image }` - - `"json_schema"` + - `index: number` - - `started_at: number` + The index of the output in the outputs array. - The Unix timestamp (in seconds) for when the run was started. + - `type: "image"` - - `status: "queued" or "in_progress" or "requires_action" or 6 more` + Always `image`. - The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. + - `"image"` - - `"queued"` + - `image: optional object { file_id }` - - `"in_progress"` + - `file_id: optional string` - - `"requires_action"` + The [file](/docs/api-reference/files) ID of the image. - - `"cancelling"` + - `FileSearchToolCallDelta object { file_search, index, type, id }` - - `"cancelled"` + - `file_search: unknown` - - `"failed"` + For now, this is always going to be an empty object. - - `"completed"` + - `index: number` - - `"incomplete"` + The index of the tool call in the tool calls array. - - `"expired"` + - `type: "file_search"` - - `thread_id: string` + The type of tool call. This is always going to be `file_search` for this type of tool call. - The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run. + - `"file_search"` - - `tool_choice: AssistantToolChoiceOption` + - `id: optional string` - Controls which (if any) tool is called by the model. - `none` means the model will not call any tools and instead generates a message. - `auto` is the default value and means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools before responding to the user. - Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. + The ID of the tool call object. - - `"none" or "auto" or "required"` + - `FunctionToolCallDelta object { index, type, id, function }` - `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user. + - `index: number` - - `"none"` + The index of the tool call in the tool calls array. - - `"auto"` + - `type: "function"` - - `"required"` + The type of tool call. This is always going to be `function` for this type of tool call. + + - `"function"` + + - `id: optional string` - - `AssistantToolChoice = object { type, function }` + The ID of the tool call object. - Specifies a tool the model should use. Use to force the model to call a specific tool. + - `function: optional object { arguments, name, output }` - - `type: "function" or "code_interpreter" or "file_search"` + The definition of the function that was called. - The type of the tool. If type is `function`, the function name must be set + - `arguments: optional string` - - `"function"` + The arguments passed to the function. - - `"code_interpreter"` + - `name: optional string` - - `"file_search"` + The name of the function. - - `function: optional AssistantToolChoiceFunction` + - `output: optional string` - - `name: string` + The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. - The name of the function to call. + - `object: "thread.run.step.delta"` - - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool` + The object type, which is always `thread.run.step.delta`. - The list of tools that the [assistant](/docs/api-reference/assistants) used for this run. + - `"thread.run.step.delta"` - - `CodeInterpreterTool = object { type }` + - `event: "thread.run.step.delta"` - - `type: "code_interpreter"` + - `"thread.run.step.delta"` - The type of tool being defined: `code_interpreter` + - `object { data, event }` - - `"code_interpreter"` + Occurs when a [run step](/docs/api-reference/run-steps/step-object) is completed. - - `FileSearchTool = object { type, file_search }` + - `data: RunStep` - - `type: "file_search"` + Represents a step in execution of a run. - The type of tool being defined: `file_search` + - `event: "thread.run.step.completed"` - - `"file_search"` + - `"thread.run.step.completed"` - - `file_search: optional object { max_num_results, ranking_options }` + - `object { data, event }` - Overrides for the file search tool. + Occurs when a [run step](/docs/api-reference/run-steps/step-object) fails. - - `max_num_results: optional number` + - `data: RunStep` - The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. + Represents a step in execution of a run. - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + - `event: "thread.run.step.failed"` - - `ranking_options: optional object { score_threshold, ranker }` + - `"thread.run.step.failed"` - The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. + - `object { data, event }` - See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + Occurs when a [run step](/docs/api-reference/run-steps/step-object) is cancelled. - - `score_threshold: number` + - `data: RunStep` - The score threshold for the file search. All values must be a floating point number between 0 and 1. + Represents a step in execution of a run. - - `ranker: optional "auto" or "default_2024_08_21"` + - `event: "thread.run.step.cancelled"` - The ranker to use for the file search. If not specified will use the `auto` ranker. + - `"thread.run.step.cancelled"` - - `"auto"` + - `object { data, event }` - - `"default_2024_08_21"` + Occurs when a [run step](/docs/api-reference/run-steps/step-object) expires. - - `FunctionTool = object { function, type }` + - `data: RunStep` - - `function: FunctionDefinition` + Represents a step in execution of a run. - - `name: string` + - `event: "thread.run.step.expired"` - The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. + - `"thread.run.step.expired"` - - `description: optional string` + - `object { data, event }` - A description of what the function does, used by the model to choose when and how to call the function. + Occurs when a [message](/docs/api-reference/messages/object) is created. - - `parameters: optional FunctionParameters` + - `data: Message` - The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. + Represents a message within a [thread](/docs/api-reference/threads). - Omitting `parameters` defines a function with an empty parameter list. + - `id: string` - - `strict: optional boolean` + The identifier, which can be referenced in API endpoints. - Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling). + - `assistant_id: string` - - `type: "function"` + If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message. - The type of tool being defined: `function` + - `attachments: array of object { file_id, tools }` - - `"function"` + A list of files attached to the message, and the tools they were added to. - - `truncation_strategy: object { type, last_messages }` + - `file_id: optional string` - Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. + The ID of the file to attach to the message. - - `type: "auto" or "last_messages"` + - `tools: optional array of CodeInterpreterTool or object { type }` - The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`. + The tools to add this file to. - - `"auto"` + - `CodeInterpreterTool object { type }` - - `"last_messages"` + - `FileSearchTool object { type }` - - `last_messages: optional number` + - `type: "file_search"` - The number of most recent messages from the thread when constructing the context for the run. + The type of tool being defined: `file_search` - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` + - `"file_search"` - Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). + - `completed_at: number` - - `completion_tokens: number` + The Unix timestamp (in seconds) for when the message was completed. - Number of completion tokens used over the course of the run. + - `content: array of ImageFileContentBlock or ImageURLContentBlock or TextContentBlock or RefusalContentBlock` - - `prompt_tokens: number` + The content of the message in array of text and/or images. - Number of prompt tokens used over the course of the run. + - `ImageFileContentBlock object { image_file, type }` - - `total_tokens: number` + References an image [File](/docs/api-reference/files) in the content of a message. - Total number of tokens used (prompt + completion). + - `image_file: ImageFile` - - `temperature: optional number` + - `file_id: string` - The sampling temperature used for this run. If not set, defaults to 1. + The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. - - `top_p: optional number` + - `detail: optional "auto" or "low" or "high"` - The nucleus sampling value used for this run. If not set, defaults to 1. + Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. - - `event: "thread.run.completed"` + - `"auto"` - - `"thread.run.completed"` + - `"low"` - - `object { data, event }` + - `"high"` - Occurs when a [run](/docs/api-reference/runs/object) ends with status `incomplete`. + - `type: "image_file"` - - `data: Run` + Always `image_file`. - Represents an execution run on a [thread](/docs/api-reference/threads). + - `"image_file"` - - `id: string` + - `ImageURLContentBlock object { image_url, type }` - The identifier, which can be referenced in API endpoints. + References an image URL in the content of a message. - - `assistant_id: string` + - `image_url: ImageURL` - The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run. + - `url: string` - - `cancelled_at: number` + The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. - The Unix timestamp (in seconds) for when the run was cancelled. + - `detail: optional "auto" or "low" or "high"` - - `completed_at: number` + Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` - The Unix timestamp (in seconds) for when the run was completed. + - `"auto"` - - `created_at: number` + - `"low"` - The Unix timestamp (in seconds) for when the run was created. + - `"high"` - - `expires_at: number` + - `type: "image_url"` - The Unix timestamp (in seconds) for when the run will expire. + The type of the content part. - - `failed_at: number` + - `"image_url"` - The Unix timestamp (in seconds) for when the run failed. + - `TextContentBlock object { text, type }` - - `incomplete_details: object { reason }` + The text content that is part of a message. - Details on why the run is incomplete. Will be `null` if the run is not incomplete. + - `text: Text` - - `reason: optional "max_completion_tokens" or "max_prompt_tokens"` + - `annotations: array of FileCitationAnnotation or FilePathAnnotation` - The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run. + - `FileCitationAnnotation object { end_index, file_citation, start_index, 2 more }` - - `"max_completion_tokens"` + 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. - - `"max_prompt_tokens"` + - `end_index: number` - - `instructions: string` + - `file_citation: object { file_id }` - The instructions that the [assistant](/docs/api-reference/assistants) used for this run. + - `file_id: string` - - `last_error: object { code, message }` + The ID of the specific File the citation is from. - The last error associated with this run. Will be `null` if there are no errors. + - `start_index: number` - - `code: "server_error" or "rate_limit_exceeded" or "invalid_prompt"` + - `text: string` - One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. + The text in the message content that needs to be replaced. - - `"server_error"` + - `type: "file_citation"` - - `"rate_limit_exceeded"` + Always `file_citation`. - - `"invalid_prompt"` + - `"file_citation"` - - `message: string` + - `FilePathAnnotation object { end_index, file_path, start_index, 2 more }` - A human-readable description of the error. + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - - `max_completion_tokens: number` + - `end_index: number` - The maximum number of completion tokens specified to have been used over the course of the run. + - `file_path: object { file_id }` - - `max_prompt_tokens: number` + - `file_id: string` - The maximum number of prompt tokens specified to have been used over the course of the run. + The ID of the file that was generated. - - `metadata: Metadata` + - `start_index: number` - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. + - `text: string` - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. + The text in the message content that needs to be replaced. - - `model: string` + - `type: "file_path"` - The model that the [assistant](/docs/api-reference/assistants) used for this run. + Always `file_path`. - - `object: "thread.run"` + - `"file_path"` - The object type, which is always `thread.run`. + - `value: string` - - `"thread.run"` + The data that makes up the text. - - `parallel_tool_calls: boolean` + - `type: "text"` - Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. + Always `text`. - - `required_action: object { submit_tool_outputs, type }` + - `"text"` - Details on the action required to continue the run. Will be `null` if no action is required. + - `RefusalContentBlock object { refusal, type }` - - `submit_tool_outputs: object { tool_calls }` + The refusal content generated by the assistant. - Details on the tool outputs needed for this run to continue. + - `refusal: string` - - `tool_calls: array of RequiredActionFunctionToolCall` + - `type: "refusal"` - A list of the relevant tool calls. + Always `refusal`. - - `id: string` + - `"refusal"` - The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint. + - `created_at: number` - - `function: object { arguments, name }` + The Unix timestamp (in seconds) for when the message was created. - The function definition. + - `incomplete_at: number` - - `arguments: string` + The Unix timestamp (in seconds) for when the message was marked as incomplete. - The arguments that the model expects you to pass to the function. + - `incomplete_details: object { reason }` - - `name: string` + On an incomplete message, details about why the message is incomplete. - The name of the function. + - `reason: "content_filter" or "max_tokens" or "run_cancelled" or 2 more` - - `type: "function"` + The reason the message is incomplete. - The type of tool call the output is required for. For now, this is always `function`. + - `"content_filter"` - - `"function"` + - `"max_tokens"` - - `type: "submit_tool_outputs"` + - `"run_cancelled"` - For now, this is always `submit_tool_outputs`. + - `"run_expired"` - - `"submit_tool_outputs"` + - `"run_failed"` - - `response_format: AssistantResponseFormatOption` + - `metadata: Metadata` - Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`. + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. - 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](/docs/guides/structured-outputs). + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + - `object: "thread.message"` - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + The object type, which is always `thread.message`. - - `"auto"` + - `"thread.message"` - `auto` is the default value + - `role: "user" or "assistant"` - - `"auto"` + The entity that produced the message. One of `user` or `assistant`. - - `ResponseFormatText = object { type }` + - `"user"` - Default response format. Used to generate text responses. + - `"assistant"` - - `type: "text"` + - `run_id: string` - The type of response format being defined. Always `text`. + The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. - - `"text"` + - `status: "in_progress" or "incomplete" or "completed"` - - `ResponseFormatJSONObject = object { type }` + The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. - JSON object response format. An older method of generating JSON responses. - Using `json_schema` is recommended for models that support it. Note that the - model will not generate JSON without a system or user message instructing it - to do so. + - `"in_progress"` - - `type: "json_object"` + - `"incomplete"` - The type of response format being defined. Always `json_object`. + - `"completed"` - - `"json_object"` + - `thread_id: string` - - `ResponseFormatJSONSchema = object { json_schema, type }` + The [thread](/docs/api-reference/threads) ID that this message belongs to. - JSON Schema response format. Used to generate structured JSON responses. - Learn more about [Structured Outputs](/docs/guides/structured-outputs). + - `event: "thread.message.created"` - - `json_schema: object { name, description, schema, strict }` + - `"thread.message.created"` - Structured Outputs configuration options, including a JSON Schema. + - `object { data, event }` - - `name: string` + Occurs when a [message](/docs/api-reference/messages/object) moves to an `in_progress` state. - The name of the response format. Must be a-z, A-Z, 0-9, or contain - underscores and dashes, with a maximum length of 64. + - `data: Message` - - `description: optional string` + Represents a message within a [thread](/docs/api-reference/threads). - A description of what the response format is for, used by the model to - determine how to respond in the format. + - `event: "thread.message.in_progress"` - - `schema: optional map[unknown]` + - `"thread.message.in_progress"` - The schema for the response format, described as a JSON Schema object. - Learn how to build JSON schemas [here](https://json-schema.org/). + - `object { data, event }` - - `strict: optional boolean` + Occurs when parts of a [Message](/docs/api-reference/messages/object) are being streamed. - Whether to enable strict schema adherence when generating the output. - If set to true, the model will always follow the exact schema defined - in the `schema` field. Only a subset of JSON Schema is supported when - `strict` is `true`. To learn more, read the [Structured Outputs - guide](/docs/guides/structured-outputs). + - `data: MessageDeltaEvent` - - `type: "json_schema"` + Represents a message delta i.e. any changed fields on a message during streaming. - The type of response format being defined. Always `json_schema`. + - `id: string` - - `"json_schema"` + The identifier of the message, which can be referenced in API endpoints. - - `started_at: number` + - `delta: MessageDelta` - The Unix timestamp (in seconds) for when the run was started. + The delta containing the fields that have changed on the Message. - - `status: "queued" or "in_progress" or "requires_action" or 6 more` + - `content: optional array of ImageFileDeltaBlock or TextDeltaBlock or RefusalDeltaBlock or ImageURLDeltaBlock` - The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. + The content of the message in array of text and/or images. - - `"queued"` + - `ImageFileDeltaBlock object { index, type, image_file }` - - `"in_progress"` + References an image [File](/docs/api-reference/files) in the content of a message. - - `"requires_action"` + - `index: number` - - `"cancelling"` + The index of the content part in the message. - - `"cancelled"` + - `type: "image_file"` - - `"failed"` + Always `image_file`. - - `"completed"` + - `"image_file"` - - `"incomplete"` + - `image_file: optional ImageFileDelta` - - `"expired"` + - `detail: optional "auto" or "low" or "high"` - - `thread_id: string` + Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. - The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run. + - `"auto"` - - `tool_choice: AssistantToolChoiceOption` + - `"low"` - Controls which (if any) tool is called by the model. - `none` means the model will not call any tools and instead generates a message. - `auto` is the default value and means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools before responding to the user. - Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. + - `"high"` - - `"none" or "auto" or "required"` + - `file_id: optional string` - `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user. + The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. - - `"none"` + - `TextDeltaBlock object { index, type, text }` - - `"auto"` + The text content that is part of a message. - - `"required"` + - `index: number` - - `AssistantToolChoice = object { type, function }` + The index of the content part in the message. - Specifies a tool the model should use. Use to force the model to call a specific tool. + - `type: "text"` - - `type: "function" or "code_interpreter" or "file_search"` + Always `text`. - The type of the tool. If type is `function`, the function name must be set + - `"text"` - - `"function"` + - `text: optional TextDelta` - - `"code_interpreter"` + - `annotations: optional array of FileCitationDeltaAnnotation or FilePathDeltaAnnotation` - - `"file_search"` + - `FileCitationDeltaAnnotation object { index, type, end_index, 3 more }` - - `function: optional AssistantToolChoiceFunction` + 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. - - `name: string` + - `index: number` - The name of the function to call. + The index of the annotation in the text content part. - - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool` + - `type: "file_citation"` - The list of tools that the [assistant](/docs/api-reference/assistants) used for this run. + Always `file_citation`. - - `CodeInterpreterTool = object { type }` + - `"file_citation"` - - `type: "code_interpreter"` + - `end_index: optional number` - The type of tool being defined: `code_interpreter` + - `file_citation: optional object { file_id, quote }` - - `"code_interpreter"` + - `file_id: optional string` - - `FileSearchTool = object { type, file_search }` + The ID of the specific File the citation is from. - - `type: "file_search"` + - `quote: optional string` - The type of tool being defined: `file_search` + The specific quote in the file. - - `"file_search"` + - `start_index: optional number` - - `file_search: optional object { max_num_results, ranking_options }` + - `text: optional string` - Overrides for the file search tool. + The text in the message content that needs to be replaced. - - `max_num_results: optional number` + - `FilePathDeltaAnnotation object { index, type, end_index, 3 more }` - The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + - `index: number` - - `ranking_options: optional object { score_threshold, ranker }` + The index of the annotation in the text content part. - The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. + - `type: "file_path"` - See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + Always `file_path`. - - `score_threshold: number` + - `"file_path"` - The score threshold for the file search. All values must be a floating point number between 0 and 1. + - `end_index: optional number` - - `ranker: optional "auto" or "default_2024_08_21"` + - `file_path: optional object { file_id }` - The ranker to use for the file search. If not specified will use the `auto` ranker. + - `file_id: optional string` - - `"auto"` + The ID of the file that was generated. - - `"default_2024_08_21"` + - `start_index: optional number` - - `FunctionTool = object { function, type }` + - `text: optional string` - - `function: FunctionDefinition` + The text in the message content that needs to be replaced. - - `name: string` + - `value: optional string` - The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. + The data that makes up the text. - - `description: optional string` + - `RefusalDeltaBlock object { index, type, refusal }` - A description of what the function does, used by the model to choose when and how to call the function. + The refusal content that is part of a message. - - `parameters: optional FunctionParameters` + - `index: number` - The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. + The index of the refusal part in the message. - Omitting `parameters` defines a function with an empty parameter list. + - `type: "refusal"` - - `strict: optional boolean` + Always `refusal`. - Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling). + - `"refusal"` - - `type: "function"` + - `refusal: optional string` - The type of tool being defined: `function` + - `ImageURLDeltaBlock object { index, type, image_url }` - - `"function"` + References an image URL in the content of a message. - - `truncation_strategy: object { type, last_messages }` + - `index: number` - Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. + The index of the content part in the message. - - `type: "auto" or "last_messages"` + - `type: "image_url"` - The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`. + Always `image_url`. - - `"auto"` + - `"image_url"` - - `"last_messages"` + - `image_url: optional ImageURLDelta` - - `last_messages: optional number` + - `detail: optional "auto" or "low" or "high"` - The number of most recent messages from the thread when constructing the context for the run. + Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` + - `"auto"` - Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). + - `"low"` - - `completion_tokens: number` + - `"high"` - Number of completion tokens used over the course of the run. + - `url: optional string` - - `prompt_tokens: number` + The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. - Number of prompt tokens used over the course of the run. + - `role: optional "user" or "assistant"` - - `total_tokens: number` + The entity that produced the message. One of `user` or `assistant`. - Total number of tokens used (prompt + completion). + - `"user"` - - `temperature: optional number` + - `"assistant"` - The sampling temperature used for this run. If not set, defaults to 1. + - `object: "thread.message.delta"` - - `top_p: optional number` + The object type, which is always `thread.message.delta`. - The nucleus sampling value used for this run. If not set, defaults to 1. + - `"thread.message.delta"` - - `event: "thread.run.incomplete"` + - `event: "thread.message.delta"` - - `"thread.run.incomplete"` + - `"thread.message.delta"` - `object { data, event }` - Occurs when a [run](/docs/api-reference/runs/object) fails. + Occurs when a [message](/docs/api-reference/messages/object) is completed. - - `data: Run` + - `data: Message` - Represents an execution run on a [thread](/docs/api-reference/threads). + Represents a message within a [thread](/docs/api-reference/threads). - - `id: string` + - `event: "thread.message.completed"` - The identifier, which can be referenced in API endpoints. + - `"thread.message.completed"` - - `assistant_id: string` + - `object { data, event }` - The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run. + Occurs when a [message](/docs/api-reference/messages/object) ends before it is completed. - - `cancelled_at: number` + - `data: Message` - The Unix timestamp (in seconds) for when the run was cancelled. + Represents a message within a [thread](/docs/api-reference/threads). - - `completed_at: number` + - `event: "thread.message.incomplete"` - The Unix timestamp (in seconds) for when the run was completed. + - `"thread.message.incomplete"` - - `created_at: number` + - `ErrorEvent object { data, event }` - The Unix timestamp (in seconds) for when the run was created. + Occurs when an [error](/docs/guides/error-codes#api-errors) occurs. This can happen due to an internal server error or a timeout. - - `expires_at: number` + - `data: ErrorObject` - The Unix timestamp (in seconds) for when the run will expire. + - `code: string` - - `failed_at: number` + - `message: string` - The Unix timestamp (in seconds) for when the run failed. + - `param: string` - - `incomplete_details: object { reason }` + - `type: string` - Details on why the run is incomplete. Will be `null` if the run is not incomplete. + - `event: "error"` - - `reason: optional "max_completion_tokens" or "max_prompt_tokens"` + - `"error"` - The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run. + - `DoneEvent object { data, event }` - - `"max_completion_tokens"` + Occurs when a stream ends. - - `"max_prompt_tokens"` + - `data: "[DONE]"` - - `instructions: string` + - `"[DONE]"` - The instructions that the [assistant](/docs/api-reference/assistants) used for this run. + - `event: "done"` - - `last_error: object { code, message }` + - `"done"` - The last error associated with this run. Will be `null` if there are no errors. +### Code Interpreter Tool - - `code: "server_error" or "rate_limit_exceeded" or "invalid_prompt"` +- `CodeInterpreterTool object { type }` - One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. + - `type: "code_interpreter"` - - `"server_error"` + The type of tool being defined: `code_interpreter` - - `"rate_limit_exceeded"` + - `"code_interpreter"` - - `"invalid_prompt"` +### File Search Tool - - `message: string` +- `FileSearchTool object { type, file_search }` - A human-readable description of the error. + - `type: "file_search"` - - `max_completion_tokens: number` + The type of tool being defined: `file_search` - The maximum number of completion tokens specified to have been used over the course of the run. + - `"file_search"` - - `max_prompt_tokens: number` + - `file_search: optional object { max_num_results, ranking_options }` - The maximum number of prompt tokens specified to have been used over the course of the run. + Overrides for the file search tool. - - `metadata: Metadata` + - `max_num_results: optional number` - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. + The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. + Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - `model: string` + - `ranking_options: optional object { score_threshold, ranker }` - The model that the [assistant](/docs/api-reference/assistants) used for this run. + The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. - - `object: "thread.run"` + See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - The object type, which is always `thread.run`. + - `score_threshold: number` - - `"thread.run"` + The score threshold for the file search. All values must be a floating point number between 0 and 1. - - `parallel_tool_calls: boolean` + - `ranker: optional "auto" or "default_2024_08_21"` - Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. + The ranker to use for the file search. If not specified will use the `auto` ranker. - - `required_action: object { submit_tool_outputs, type }` + - `"auto"` - Details on the action required to continue the run. Will be `null` if no action is required. + - `"default_2024_08_21"` - - `submit_tool_outputs: object { tool_calls }` +### Function Tool - Details on the tool outputs needed for this run to continue. +- `FunctionTool object { function, type }` - - `tool_calls: array of RequiredActionFunctionToolCall` + - `function: FunctionDefinition` - A list of the relevant tool calls. + - `name: string` - - `id: string` + The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint. + - `description: optional string` - - `function: object { arguments, name }` + A description of what the function does, used by the model to choose when and how to call the function. - The function definition. + - `parameters: optional FunctionParameters` - - `arguments: string` + The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. - The arguments that the model expects you to pass to the function. + Omitting `parameters` defines a function with an empty parameter list. - - `name: string` + - `strict: optional boolean` - The name of the function. + Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling). - `type: "function"` - The type of tool call the output is required for. For now, this is always `function`. + The type of tool being defined: `function` - `"function"` - - `type: "submit_tool_outputs"` +### Message Stream Event - For now, this is always `submit_tool_outputs`. +- `MessageStreamEvent = object { data, event } or object { data, event } or object { data, event } or 2 more` - - `"submit_tool_outputs"` + Occurs when a [message](/docs/api-reference/messages/object) is created. - - `response_format: AssistantResponseFormatOption` + - `object { data, event }` - Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`. + Occurs when a [message](/docs/api-reference/messages/object) is created. - 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](/docs/guides/structured-outputs). + - `data: Message` - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + Represents a message within a [thread](/docs/api-reference/threads). - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + - `id: string` - - `"auto"` + The identifier, which can be referenced in API endpoints. - `auto` is the default value + - `assistant_id: string` - - `"auto"` + If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message. - - `ResponseFormatText = object { type }` + - `attachments: array of object { file_id, tools }` - Default response format. Used to generate text responses. + A list of files attached to the message, and the tools they were added to. - - `type: "text"` + - `file_id: optional string` - The type of response format being defined. Always `text`. + The ID of the file to attach to the message. - - `"text"` + - `tools: optional array of CodeInterpreterTool or object { type }` - - `ResponseFormatJSONObject = object { type }` + The tools to add this file to. - JSON object response format. An older method of generating JSON responses. - Using `json_schema` is recommended for models that support it. Note that the - model will not generate JSON without a system or user message instructing it - to do so. + - `CodeInterpreterTool object { type }` - - `type: "json_object"` + - `type: "code_interpreter"` - The type of response format being defined. Always `json_object`. + The type of tool being defined: `code_interpreter` - - `"json_object"` + - `"code_interpreter"` - - `ResponseFormatJSONSchema = object { json_schema, type }` + - `FileSearchTool object { type }` - JSON Schema response format. Used to generate structured JSON responses. - Learn more about [Structured Outputs](/docs/guides/structured-outputs). + - `type: "file_search"` - - `json_schema: object { name, description, schema, strict }` + The type of tool being defined: `file_search` - Structured Outputs configuration options, including a JSON Schema. + - `"file_search"` - - `name: string` + - `completed_at: number` - The name of the response format. Must be a-z, A-Z, 0-9, or contain - underscores and dashes, with a maximum length of 64. + The Unix timestamp (in seconds) for when the message was completed. - - `description: optional string` + - `content: array of ImageFileContentBlock or ImageURLContentBlock or TextContentBlock or RefusalContentBlock` - A description of what the response format is for, used by the model to - determine how to respond in the format. + The content of the message in array of text and/or images. - - `schema: optional map[unknown]` + - `ImageFileContentBlock object { image_file, type }` - The schema for the response format, described as a JSON Schema object. - Learn how to build JSON schemas [here](https://json-schema.org/). + References an image [File](/docs/api-reference/files) in the content of a message. - - `strict: optional boolean` + - `image_file: ImageFile` - Whether to enable strict schema adherence when generating the output. - If set to true, the model will always follow the exact schema defined - in the `schema` field. Only a subset of JSON Schema is supported when - `strict` is `true`. To learn more, read the [Structured Outputs - guide](/docs/guides/structured-outputs). + - `file_id: string` - - `type: "json_schema"` + The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. - The type of response format being defined. Always `json_schema`. + - `detail: optional "auto" or "low" or "high"` - - `"json_schema"` + Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. - - `started_at: number` + - `"auto"` - The Unix timestamp (in seconds) for when the run was started. + - `"low"` - - `status: "queued" or "in_progress" or "requires_action" or 6 more` + - `"high"` - The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. + - `type: "image_file"` - - `"queued"` + Always `image_file`. - - `"in_progress"` + - `"image_file"` - - `"requires_action"` + - `ImageURLContentBlock object { image_url, type }` - - `"cancelling"` + References an image URL in the content of a message. - - `"cancelled"` + - `image_url: ImageURL` - - `"failed"` + - `url: string` - - `"completed"` + The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. - - `"incomplete"` + - `detail: optional "auto" or "low" or "high"` - - `"expired"` + Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` - - `thread_id: string` + - `"auto"` - The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run. + - `"low"` - - `tool_choice: AssistantToolChoiceOption` + - `"high"` - Controls which (if any) tool is called by the model. - `none` means the model will not call any tools and instead generates a message. - `auto` is the default value and means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools before responding to the user. - Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. + - `type: "image_url"` - - `"none" or "auto" or "required"` + The type of the content part. - `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user. + - `"image_url"` - - `"none"` + - `TextContentBlock object { text, type }` - - `"auto"` + The text content that is part of a message. - - `"required"` + - `text: Text` - - `AssistantToolChoice = object { type, function }` + - `annotations: array of FileCitationAnnotation or FilePathAnnotation` - Specifies a tool the model should use. Use to force the model to call a specific tool. + - `FileCitationAnnotation object { end_index, file_citation, start_index, 2 more }` - - `type: "function" or "code_interpreter" or "file_search"` + 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. - The type of the tool. If type is `function`, the function name must be set + - `end_index: number` - - `"function"` + - `file_citation: object { file_id }` - - `"code_interpreter"` + - `file_id: string` - - `"file_search"` + The ID of the specific File the citation is from. - - `function: optional AssistantToolChoiceFunction` + - `start_index: number` - - `name: string` + - `text: string` - The name of the function to call. + The text in the message content that needs to be replaced. - - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool` + - `type: "file_citation"` - The list of tools that the [assistant](/docs/api-reference/assistants) used for this run. + Always `file_citation`. - - `CodeInterpreterTool = object { type }` + - `"file_citation"` - - `type: "code_interpreter"` + - `FilePathAnnotation object { end_index, file_path, start_index, 2 more }` - The type of tool being defined: `code_interpreter` + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - - `"code_interpreter"` + - `end_index: number` - - `FileSearchTool = object { type, file_search }` + - `file_path: object { file_id }` - - `type: "file_search"` + - `file_id: string` - The type of tool being defined: `file_search` + The ID of the file that was generated. - - `"file_search"` + - `start_index: number` - - `file_search: optional object { max_num_results, ranking_options }` + - `text: string` - Overrides for the file search tool. + The text in the message content that needs to be replaced. - - `max_num_results: optional number` + - `type: "file_path"` - The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. + Always `file_path`. - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + - `"file_path"` - - `ranking_options: optional object { score_threshold, ranker }` + - `value: string` - The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. + The data that makes up the text. - See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + - `type: "text"` - - `score_threshold: number` + Always `text`. - The score threshold for the file search. All values must be a floating point number between 0 and 1. + - `"text"` - - `ranker: optional "auto" or "default_2024_08_21"` + - `RefusalContentBlock object { refusal, type }` - The ranker to use for the file search. If not specified will use the `auto` ranker. + The refusal content generated by the assistant. - - `"auto"` + - `refusal: string` - - `"default_2024_08_21"` + - `type: "refusal"` - - `FunctionTool = object { function, type }` + Always `refusal`. - - `function: FunctionDefinition` + - `"refusal"` - - `name: string` + - `created_at: number` - The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. + The Unix timestamp (in seconds) for when the message was created. - - `description: optional string` + - `incomplete_at: number` - A description of what the function does, used by the model to choose when and how to call the function. + The Unix timestamp (in seconds) for when the message was marked as incomplete. - - `parameters: optional FunctionParameters` + - `incomplete_details: object { reason }` - The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. + On an incomplete message, details about why the message is incomplete. - Omitting `parameters` defines a function with an empty parameter list. + - `reason: "content_filter" or "max_tokens" or "run_cancelled" or 2 more` - - `strict: optional boolean` + The reason the message is incomplete. - Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling). + - `"content_filter"` - - `type: "function"` + - `"max_tokens"` - The type of tool being defined: `function` + - `"run_cancelled"` - - `"function"` + - `"run_expired"` - - `truncation_strategy: object { type, last_messages }` + - `"run_failed"` - Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. + - `metadata: Metadata` - - `type: "auto" or "last_messages"` + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. - The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`. + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. - - `"auto"` + - `object: "thread.message"` - - `"last_messages"` + The object type, which is always `thread.message`. - - `last_messages: optional number` + - `"thread.message"` - The number of most recent messages from the thread when constructing the context for the run. + - `role: "user" or "assistant"` - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` + The entity that produced the message. One of `user` or `assistant`. - Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). + - `"user"` - - `completion_tokens: number` + - `"assistant"` - Number of completion tokens used over the course of the run. + - `run_id: string` - - `prompt_tokens: number` + The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. - Number of prompt tokens used over the course of the run. + - `status: "in_progress" or "incomplete" or "completed"` - - `total_tokens: number` + The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. - Total number of tokens used (prompt + completion). + - `"in_progress"` - - `temperature: optional number` + - `"incomplete"` - The sampling temperature used for this run. If not set, defaults to 1. + - `"completed"` - - `top_p: optional number` + - `thread_id: string` - The nucleus sampling value used for this run. If not set, defaults to 1. + The [thread](/docs/api-reference/threads) ID that this message belongs to. - - `event: "thread.run.failed"` + - `event: "thread.message.created"` - - `"thread.run.failed"` + - `"thread.message.created"` - `object { data, event }` - Occurs when a [run](/docs/api-reference/runs/object) moves to a `cancelling` status. - - - `data: Run` + Occurs when a [message](/docs/api-reference/messages/object) moves to an `in_progress` state. - Represents an execution run on a [thread](/docs/api-reference/threads). + - `data: Message` - - `id: string` + Represents a message within a [thread](/docs/api-reference/threads). - The identifier, which can be referenced in API endpoints. + - `event: "thread.message.in_progress"` - - `assistant_id: string` + - `"thread.message.in_progress"` - The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run. + - `object { data, event }` - - `cancelled_at: number` + Occurs when parts of a [Message](/docs/api-reference/messages/object) are being streamed. - The Unix timestamp (in seconds) for when the run was cancelled. + - `data: MessageDeltaEvent` - - `completed_at: number` + Represents a message delta i.e. any changed fields on a message during streaming. - The Unix timestamp (in seconds) for when the run was completed. + - `id: string` - - `created_at: number` + The identifier of the message, which can be referenced in API endpoints. - The Unix timestamp (in seconds) for when the run was created. + - `delta: MessageDelta` - - `expires_at: number` + The delta containing the fields that have changed on the Message. - The Unix timestamp (in seconds) for when the run will expire. + - `content: optional array of ImageFileDeltaBlock or TextDeltaBlock or RefusalDeltaBlock or ImageURLDeltaBlock` - - `failed_at: number` + The content of the message in array of text and/or images. - The Unix timestamp (in seconds) for when the run failed. + - `ImageFileDeltaBlock object { index, type, image_file }` - - `incomplete_details: object { reason }` + References an image [File](/docs/api-reference/files) in the content of a message. - Details on why the run is incomplete. Will be `null` if the run is not incomplete. + - `index: number` - - `reason: optional "max_completion_tokens" or "max_prompt_tokens"` + The index of the content part in the message. - The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run. + - `type: "image_file"` - - `"max_completion_tokens"` + Always `image_file`. - - `"max_prompt_tokens"` + - `"image_file"` - - `instructions: string` + - `image_file: optional ImageFileDelta` - The instructions that the [assistant](/docs/api-reference/assistants) used for this run. + - `detail: optional "auto" or "low" or "high"` - - `last_error: object { code, message }` + Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. - The last error associated with this run. Will be `null` if there are no errors. + - `"auto"` - - `code: "server_error" or "rate_limit_exceeded" or "invalid_prompt"` + - `"low"` - One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. + - `"high"` - - `"server_error"` + - `file_id: optional string` - - `"rate_limit_exceeded"` + The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. - - `"invalid_prompt"` + - `TextDeltaBlock object { index, type, text }` - - `message: string` + The text content that is part of a message. - A human-readable description of the error. + - `index: number` - - `max_completion_tokens: number` + The index of the content part in the message. - The maximum number of completion tokens specified to have been used over the course of the run. + - `type: "text"` - - `max_prompt_tokens: number` + Always `text`. - The maximum number of prompt tokens specified to have been used over the course of the run. + - `"text"` - - `metadata: Metadata` + - `text: optional TextDelta` - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. + - `annotations: optional array of FileCitationDeltaAnnotation or FilePathDeltaAnnotation` - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. + - `FileCitationDeltaAnnotation object { index, type, end_index, 3 more }` - - `model: string` + 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. - The model that the [assistant](/docs/api-reference/assistants) used for this run. + - `index: number` - - `object: "thread.run"` + The index of the annotation in the text content part. - The object type, which is always `thread.run`. + - `type: "file_citation"` - - `"thread.run"` + Always `file_citation`. - - `parallel_tool_calls: boolean` + - `"file_citation"` - Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. + - `end_index: optional number` - - `required_action: object { submit_tool_outputs, type }` + - `file_citation: optional object { file_id, quote }` - Details on the action required to continue the run. Will be `null` if no action is required. + - `file_id: optional string` - - `submit_tool_outputs: object { tool_calls }` + The ID of the specific File the citation is from. - Details on the tool outputs needed for this run to continue. + - `quote: optional string` - - `tool_calls: array of RequiredActionFunctionToolCall` + The specific quote in the file. - A list of the relevant tool calls. + - `start_index: optional number` - - `id: string` + - `text: optional string` - The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint. + The text in the message content that needs to be replaced. - - `function: object { arguments, name }` + - `FilePathDeltaAnnotation object { index, type, end_index, 3 more }` - The function definition. + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - - `arguments: string` + - `index: number` - The arguments that the model expects you to pass to the function. + The index of the annotation in the text content part. - - `name: string` + - `type: "file_path"` - The name of the function. + Always `file_path`. - - `type: "function"` + - `"file_path"` - The type of tool call the output is required for. For now, this is always `function`. + - `end_index: optional number` - - `"function"` + - `file_path: optional object { file_id }` - - `type: "submit_tool_outputs"` + - `file_id: optional string` - For now, this is always `submit_tool_outputs`. + The ID of the file that was generated. - - `"submit_tool_outputs"` + - `start_index: optional number` - - `response_format: AssistantResponseFormatOption` + - `text: optional string` - Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`. + The text in the message content that needs to be replaced. - 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](/docs/guides/structured-outputs). + - `value: optional string` - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + The data that makes up the text. - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + - `RefusalDeltaBlock object { index, type, refusal }` - - `"auto"` + The refusal content that is part of a message. - `auto` is the default value + - `index: number` - - `"auto"` + The index of the refusal part in the message. - - `ResponseFormatText = object { type }` + - `type: "refusal"` - Default response format. Used to generate text responses. + Always `refusal`. - - `type: "text"` + - `"refusal"` - The type of response format being defined. Always `text`. + - `refusal: optional string` - - `"text"` + - `ImageURLDeltaBlock object { index, type, image_url }` - - `ResponseFormatJSONObject = object { type }` + References an image URL in the content of a message. - JSON object response format. An older method of generating JSON responses. - Using `json_schema` is recommended for models that support it. Note that the - model will not generate JSON without a system or user message instructing it - to do so. + - `index: number` - - `type: "json_object"` + The index of the content part in the message. - The type of response format being defined. Always `json_object`. + - `type: "image_url"` - - `"json_object"` + Always `image_url`. - - `ResponseFormatJSONSchema = object { json_schema, type }` + - `"image_url"` - JSON Schema response format. Used to generate structured JSON responses. - Learn more about [Structured Outputs](/docs/guides/structured-outputs). + - `image_url: optional ImageURLDelta` - - `json_schema: object { name, description, schema, strict }` + - `detail: optional "auto" or "low" or "high"` - Structured Outputs configuration options, including a JSON Schema. + Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. - - `name: string` + - `"auto"` - The name of the response format. Must be a-z, A-Z, 0-9, or contain - underscores and dashes, with a maximum length of 64. + - `"low"` - - `description: optional string` + - `"high"` - A description of what the response format is for, used by the model to - determine how to respond in the format. + - `url: optional string` - - `schema: optional map[unknown]` + The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. - The schema for the response format, described as a JSON Schema object. - Learn how to build JSON schemas [here](https://json-schema.org/). + - `role: optional "user" or "assistant"` - - `strict: optional boolean` + The entity that produced the message. One of `user` or `assistant`. - Whether to enable strict schema adherence when generating the output. - If set to true, the model will always follow the exact schema defined - in the `schema` field. Only a subset of JSON Schema is supported when - `strict` is `true`. To learn more, read the [Structured Outputs - guide](/docs/guides/structured-outputs). + - `"user"` - - `type: "json_schema"` + - `"assistant"` - The type of response format being defined. Always `json_schema`. + - `object: "thread.message.delta"` - - `"json_schema"` + The object type, which is always `thread.message.delta`. - - `started_at: number` + - `"thread.message.delta"` - The Unix timestamp (in seconds) for when the run was started. + - `event: "thread.message.delta"` - - `status: "queued" or "in_progress" or "requires_action" or 6 more` + - `"thread.message.delta"` - The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. + - `object { data, event }` - - `"queued"` + Occurs when a [message](/docs/api-reference/messages/object) is completed. - - `"in_progress"` + - `data: Message` - - `"requires_action"` + Represents a message within a [thread](/docs/api-reference/threads). - - `"cancelling"` + - `event: "thread.message.completed"` - - `"cancelled"` + - `"thread.message.completed"` - - `"failed"` + - `object { data, event }` - - `"completed"` + Occurs when a [message](/docs/api-reference/messages/object) ends before it is completed. - - `"incomplete"` + - `data: Message` - - `"expired"` + Represents a message within a [thread](/docs/api-reference/threads). - - `thread_id: string` + - `event: "thread.message.incomplete"` - The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run. + - `"thread.message.incomplete"` - - `tool_choice: AssistantToolChoiceOption` +### Run Step Stream Event - Controls which (if any) tool is called by the model. - `none` means the model will not call any tools and instead generates a message. - `auto` is the default value and means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools before responding to the user. - Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. +- `RunStepStreamEvent = object { data, event } or object { data, event } or object { data, event } or 4 more` - - `"none" or "auto" or "required"` + Occurs when a [run step](/docs/api-reference/run-steps/step-object) is created. - `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user. + - `object { data, event }` - - `"none"` + Occurs when a [run step](/docs/api-reference/run-steps/step-object) is created. - - `"auto"` + - `data: RunStep` - - `"required"` + Represents a step in execution of a run. - - `AssistantToolChoice = object { type, function }` + - `id: string` - Specifies a tool the model should use. Use to force the model to call a specific tool. + The identifier of the run step, which can be referenced in API endpoints. - - `type: "function" or "code_interpreter" or "file_search"` + - `assistant_id: string` - The type of the tool. If type is `function`, the function name must be set + The ID of the [assistant](/docs/api-reference/assistants) associated with the run step. - - `"function"` + - `cancelled_at: number` - - `"code_interpreter"` + The Unix timestamp (in seconds) for when the run step was cancelled. - - `"file_search"` + - `completed_at: number` - - `function: optional AssistantToolChoiceFunction` + The Unix timestamp (in seconds) for when the run step completed. - - `name: string` + - `created_at: number` - The name of the function to call. + The Unix timestamp (in seconds) for when the run step was created. - - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool` + - `expired_at: number` - The list of tools that the [assistant](/docs/api-reference/assistants) used for this run. + The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired. - - `CodeInterpreterTool = object { type }` + - `failed_at: number` - - `type: "code_interpreter"` + The Unix timestamp (in seconds) for when the run step failed. - The type of tool being defined: `code_interpreter` + - `last_error: object { code, message }` - - `"code_interpreter"` + The last error associated with this run step. Will be `null` if there are no errors. - - `FileSearchTool = object { type, file_search }` + - `code: "server_error" or "rate_limit_exceeded"` - - `type: "file_search"` + One of `server_error` or `rate_limit_exceeded`. - The type of tool being defined: `file_search` + - `"server_error"` - - `"file_search"` + - `"rate_limit_exceeded"` - - `file_search: optional object { max_num_results, ranking_options }` + - `message: string` - Overrides for the file search tool. + A human-readable description of the error. - - `max_num_results: optional number` + - `metadata: Metadata` - The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. - - `ranking_options: optional object { score_threshold, ranker }` + - `object: "thread.run.step"` - The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. + The object type, which is always `thread.run.step`. - See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + - `"thread.run.step"` - - `score_threshold: number` + - `run_id: string` - The score threshold for the file search. All values must be a floating point number between 0 and 1. + The ID of the [run](/docs/api-reference/runs) that this run step is a part of. - - `ranker: optional "auto" or "default_2024_08_21"` + - `status: "in_progress" or "cancelled" or "failed" or 2 more` - The ranker to use for the file search. If not specified will use the `auto` ranker. + The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`. - - `"auto"` + - `"in_progress"` - - `"default_2024_08_21"` + - `"cancelled"` - - `FunctionTool = object { function, type }` + - `"failed"` - - `function: FunctionDefinition` + - `"completed"` - - `name: string` + - `"expired"` - The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. + - `step_details: MessageCreationStepDetails or ToolCallsStepDetails` - - `description: optional string` + The details of the run step. - A description of what the function does, used by the model to choose when and how to call the function. + - `MessageCreationStepDetails object { message_creation, type }` - - `parameters: optional FunctionParameters` + Details of the message creation by the run step. - The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. + - `message_creation: object { message_id }` - Omitting `parameters` defines a function with an empty parameter list. + - `message_id: string` - - `strict: optional boolean` + The ID of the message that was created by this run step. - Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling). + - `type: "message_creation"` - - `type: "function"` + Always `message_creation`. - The type of tool being defined: `function` + - `"message_creation"` - - `"function"` + - `ToolCallsStepDetails object { tool_calls, type }` - - `truncation_strategy: object { type, last_messages }` + Details of the tool call. - Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. + - `tool_calls: array of CodeInterpreterToolCall or FileSearchToolCall or FunctionToolCall` - - `type: "auto" or "last_messages"` + An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. - The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`. + - `CodeInterpreterToolCall object { id, code_interpreter, type }` - - `"auto"` + Details of the Code Interpreter tool call the run step was involved in. - - `"last_messages"` + - `id: string` - - `last_messages: optional number` + The ID of the tool call. - The number of most recent messages from the thread when constructing the context for the run. + - `code_interpreter: object { input, outputs }` - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` + The Code Interpreter tool call definition. - Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). + - `input: string` - - `completion_tokens: number` + The input to the Code Interpreter tool call. - Number of completion tokens used over the course of the run. + - `outputs: array of object { logs, type } or object { image, type }` - - `prompt_tokens: number` + The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. - Number of prompt tokens used over the course of the run. + - `CodeInterpreterLogOutput object { logs, type }` - - `total_tokens: number` + Text output from the Code Interpreter tool call as part of a run step. - Total number of tokens used (prompt + completion). + - `logs: string` - - `temperature: optional number` + The text output from the Code Interpreter tool call. - The sampling temperature used for this run. If not set, defaults to 1. + - `type: "logs"` - - `top_p: optional number` + Always `logs`. - The nucleus sampling value used for this run. If not set, defaults to 1. + - `"logs"` - - `event: "thread.run.cancelling"` + - `CodeInterpreterImageOutput object { image, type }` - - `"thread.run.cancelling"` + - `image: object { file_id }` - - `object { data, event }` + - `file_id: string` - Occurs when a [run](/docs/api-reference/runs/object) is cancelled. + The [file](/docs/api-reference/files) ID of the image. - - `data: Run` + - `type: "image"` - Represents an execution run on a [thread](/docs/api-reference/threads). + Always `image`. - - `id: string` + - `"image"` - The identifier, which can be referenced in API endpoints. + - `type: "code_interpreter"` - - `assistant_id: string` + The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run. + - `"code_interpreter"` - - `cancelled_at: number` + - `FileSearchToolCall object { id, file_search, type }` - The Unix timestamp (in seconds) for when the run was cancelled. + - `id: string` - - `completed_at: number` + The ID of the tool call object. - The Unix timestamp (in seconds) for when the run was completed. + - `file_search: object { ranking_options, results }` - - `created_at: number` + For now, this is always going to be an empty object. - The Unix timestamp (in seconds) for when the run was created. + - `ranking_options: optional object { ranker, score_threshold }` - - `expires_at: number` + The ranking options for the file search. - The Unix timestamp (in seconds) for when the run will expire. + - `ranker: "auto" or "default_2024_08_21"` - - `failed_at: number` + The ranker to use for the file search. If not specified will use the `auto` ranker. - The Unix timestamp (in seconds) for when the run failed. + - `"auto"` - - `incomplete_details: object { reason }` + - `"default_2024_08_21"` - Details on why the run is incomplete. Will be `null` if the run is not incomplete. + - `score_threshold: number` - - `reason: optional "max_completion_tokens" or "max_prompt_tokens"` + The score threshold for the file search. All values must be a floating point number between 0 and 1. - The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run. + - `results: optional array of object { file_id, file_name, score, content }` - - `"max_completion_tokens"` + The results of the file search. - - `"max_prompt_tokens"` + - `file_id: string` - - `instructions: string` + The ID of the file that result was found in. - The instructions that the [assistant](/docs/api-reference/assistants) used for this run. + - `file_name: string` - - `last_error: object { code, message }` + The name of the file that result was found in. - The last error associated with this run. Will be `null` if there are no errors. + - `score: number` - - `code: "server_error" or "rate_limit_exceeded" or "invalid_prompt"` + The score of the result. All values must be a floating point number between 0 and 1. - One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. + - `content: optional array of object { text, type }` - - `"server_error"` + The content of the result that was found. The content is only included if requested via the include query parameter. - - `"rate_limit_exceeded"` + - `text: optional string` - - `"invalid_prompt"` + The text content of the file. - - `message: string` + - `type: optional "text"` - A human-readable description of the error. + The type of the content. - - `max_completion_tokens: number` + - `"text"` - The maximum number of completion tokens specified to have been used over the course of the run. + - `type: "file_search"` - - `max_prompt_tokens: number` + The type of tool call. This is always going to be `file_search` for this type of tool call. - The maximum number of prompt tokens specified to have been used over the course of the run. + - `"file_search"` - - `metadata: Metadata` + - `FunctionToolCall object { id, function, type }` - Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. + - `id: string` - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. + The ID of the tool call object. - - `model: string` + - `function: object { arguments, name, output }` - The model that the [assistant](/docs/api-reference/assistants) used for this run. + The definition of the function that was called. - - `object: "thread.run"` + - `arguments: string` - The object type, which is always `thread.run`. + The arguments passed to the function. - - `"thread.run"` + - `name: string` - - `parallel_tool_calls: boolean` + The name of the function. - Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. + - `output: string` - - `required_action: object { submit_tool_outputs, type }` + The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. - Details on the action required to continue the run. Will be `null` if no action is required. + - `type: "function"` - - `submit_tool_outputs: object { tool_calls }` + The type of tool call. This is always going to be `function` for this type of tool call. - Details on the tool outputs needed for this run to continue. + - `"function"` - - `tool_calls: array of RequiredActionFunctionToolCall` + - `type: "tool_calls"` - A list of the relevant tool calls. + Always `tool_calls`. - - `id: string` + - `"tool_calls"` - The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint. + - `thread_id: string` - - `function: object { arguments, name }` + The ID of the [thread](/docs/api-reference/threads) that was run. - The function definition. + - `type: "message_creation" or "tool_calls"` - - `arguments: string` + The type of run step, which can be either `message_creation` or `tool_calls`. - The arguments that the model expects you to pass to the function. + - `"message_creation"` - - `name: string` + - `"tool_calls"` - The name of the function. + - `usage: object { completion_tokens, prompt_tokens, total_tokens }` - - `type: "function"` + Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. - The type of tool call the output is required for. For now, this is always `function`. + - `completion_tokens: number` - - `"function"` + Number of completion tokens used over the course of the run step. - - `type: "submit_tool_outputs"` + - `prompt_tokens: number` - For now, this is always `submit_tool_outputs`. + Number of prompt tokens used over the course of the run step. - - `"submit_tool_outputs"` + - `total_tokens: number` - - `response_format: AssistantResponseFormatOption` + Total number of tokens used (prompt + completion). - Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`. + - `event: "thread.run.step.created"` - 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](/docs/guides/structured-outputs). + - `"thread.run.step.created"` - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + - `object { data, event }` - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + Occurs when a [run step](/docs/api-reference/run-steps/step-object) moves to an `in_progress` state. - - `"auto"` + - `data: RunStep` - `auto` is the default value + Represents a step in execution of a run. - - `"auto"` + - `event: "thread.run.step.in_progress"` - - `ResponseFormatText = object { type }` + - `"thread.run.step.in_progress"` - Default response format. Used to generate text responses. + - `object { data, event }` - - `type: "text"` + Occurs when parts of a [run step](/docs/api-reference/run-steps/step-object) are being streamed. - The type of response format being defined. Always `text`. + - `data: RunStepDeltaEvent` - - `"text"` + Represents a run step delta i.e. any changed fields on a run step during streaming. - - `ResponseFormatJSONObject = object { type }` + - `id: string` - JSON object response format. An older method of generating JSON responses. - Using `json_schema` is recommended for models that support it. Note that the - model will not generate JSON without a system or user message instructing it - to do so. + The identifier of the run step, which can be referenced in API endpoints. - - `type: "json_object"` + - `delta: object { step_details }` - The type of response format being defined. Always `json_object`. + The delta containing the fields that have changed on the run step. - - `"json_object"` + - `step_details: optional RunStepDeltaMessageDelta or ToolCallDeltaObject` - - `ResponseFormatJSONSchema = object { json_schema, type }` + The details of the run step. - JSON Schema response format. Used to generate structured JSON responses. - Learn more about [Structured Outputs](/docs/guides/structured-outputs). + - `RunStepDeltaMessageDelta object { type, message_creation }` - - `json_schema: object { name, description, schema, strict }` + Details of the message creation by the run step. - Structured Outputs configuration options, including a JSON Schema. + - `type: "message_creation"` - - `name: string` + Always `message_creation`. - The name of the response format. Must be a-z, A-Z, 0-9, or contain - underscores and dashes, with a maximum length of 64. + - `"message_creation"` - - `description: optional string` + - `message_creation: optional object { message_id }` - A description of what the response format is for, used by the model to - determine how to respond in the format. + - `message_id: optional string` - - `schema: optional map[unknown]` + The ID of the message that was created by this run step. - The schema for the response format, described as a JSON Schema object. - Learn how to build JSON schemas [here](https://json-schema.org/). + - `ToolCallDeltaObject object { type, tool_calls }` - - `strict: optional boolean` + Details of the tool call. - Whether to enable strict schema adherence when generating the output. - If set to true, the model will always follow the exact schema defined - in the `schema` field. Only a subset of JSON Schema is supported when - `strict` is `true`. To learn more, read the [Structured Outputs - guide](/docs/guides/structured-outputs). + - `type: "tool_calls"` - - `type: "json_schema"` + Always `tool_calls`. - The type of response format being defined. Always `json_schema`. + - `"tool_calls"` - - `"json_schema"` + - `tool_calls: optional array of CodeInterpreterToolCallDelta or FileSearchToolCallDelta or FunctionToolCallDelta` - - `started_at: number` + An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. - The Unix timestamp (in seconds) for when the run was started. + - `CodeInterpreterToolCallDelta object { index, type, id, code_interpreter }` - - `status: "queued" or "in_progress" or "requires_action" or 6 more` + Details of the Code Interpreter tool call the run step was involved in. - The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. + - `index: number` - - `"queued"` + The index of the tool call in the tool calls array. - - `"in_progress"` + - `type: "code_interpreter"` - - `"requires_action"` + The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - - `"cancelling"` + - `"code_interpreter"` - - `"cancelled"` + - `id: optional string` - - `"failed"` + The ID of the tool call. - - `"completed"` + - `code_interpreter: optional object { input, outputs }` - - `"incomplete"` + The Code Interpreter tool call definition. - - `"expired"` + - `input: optional string` - - `thread_id: string` + The input to the Code Interpreter tool call. - The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run. + - `outputs: optional array of CodeInterpreterLogs or CodeInterpreterOutputImage` - - `tool_choice: AssistantToolChoiceOption` + The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. - Controls which (if any) tool is called by the model. - `none` means the model will not call any tools and instead generates a message. - `auto` is the default value and means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools before responding to the user. - Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. + - `CodeInterpreterLogs object { index, type, logs }` - - `"none" or "auto" or "required"` + Text output from the Code Interpreter tool call as part of a run step. - `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user. + - `index: number` - - `"none"` + The index of the output in the outputs array. - - `"auto"` + - `type: "logs"` - - `"required"` + Always `logs`. - - `AssistantToolChoice = object { type, function }` + - `"logs"` - Specifies a tool the model should use. Use to force the model to call a specific tool. + - `logs: optional string` - - `type: "function" or "code_interpreter" or "file_search"` + The text output from the Code Interpreter tool call. - The type of the tool. If type is `function`, the function name must be set + - `CodeInterpreterOutputImage object { index, type, image }` - - `"function"` + - `index: number` - - `"code_interpreter"` + The index of the output in the outputs array. - - `"file_search"` + - `type: "image"` - - `function: optional AssistantToolChoiceFunction` + Always `image`. - - `name: string` + - `"image"` - The name of the function to call. + - `image: optional object { file_id }` - - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool` + - `file_id: optional string` - The list of tools that the [assistant](/docs/api-reference/assistants) used for this run. + The [file](/docs/api-reference/files) ID of the image. - - `CodeInterpreterTool = object { type }` + - `FileSearchToolCallDelta object { file_search, index, type, id }` - - `type: "code_interpreter"` + - `file_search: unknown` - The type of tool being defined: `code_interpreter` + For now, this is always going to be an empty object. - - `"code_interpreter"` + - `index: number` - - `FileSearchTool = object { type, file_search }` + The index of the tool call in the tool calls array. - `type: "file_search"` - The type of tool being defined: `file_search` + The type of tool call. This is always going to be `file_search` for this type of tool call. - `"file_search"` - - `file_search: optional object { max_num_results, ranking_options }` + - `id: optional string` - Overrides for the file search tool. + The ID of the tool call object. - - `max_num_results: optional number` + - `FunctionToolCallDelta object { index, type, id, function }` - The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. + - `index: number` - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + The index of the tool call in the tool calls array. - - `ranking_options: optional object { score_threshold, ranker }` + - `type: "function"` - The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. + The type of tool call. This is always going to be `function` for this type of tool call. - See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + - `"function"` - - `score_threshold: number` + - `id: optional string` - The score threshold for the file search. All values must be a floating point number between 0 and 1. + The ID of the tool call object. - - `ranker: optional "auto" or "default_2024_08_21"` + - `function: optional object { arguments, name, output }` - The ranker to use for the file search. If not specified will use the `auto` ranker. + The definition of the function that was called. - - `"auto"` + - `arguments: optional string` - - `"default_2024_08_21"` + The arguments passed to the function. - - `FunctionTool = object { function, type }` + - `name: optional string` - - `function: FunctionDefinition` + The name of the function. - - `name: string` + - `output: optional string` - The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. + The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. - - `description: optional string` + - `object: "thread.run.step.delta"` - A description of what the function does, used by the model to choose when and how to call the function. + The object type, which is always `thread.run.step.delta`. - - `parameters: optional FunctionParameters` + - `"thread.run.step.delta"` - The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. + - `event: "thread.run.step.delta"` - Omitting `parameters` defines a function with an empty parameter list. + - `"thread.run.step.delta"` - - `strict: optional boolean` + - `object { data, event }` - Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling). + Occurs when a [run step](/docs/api-reference/run-steps/step-object) is completed. - - `type: "function"` + - `data: RunStep` - The type of tool being defined: `function` + Represents a step in execution of a run. - - `"function"` + - `event: "thread.run.step.completed"` - - `truncation_strategy: object { type, last_messages }` + - `"thread.run.step.completed"` - Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. + - `object { data, event }` - - `type: "auto" or "last_messages"` + Occurs when a [run step](/docs/api-reference/run-steps/step-object) fails. - The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`. + - `data: RunStep` - - `"auto"` + Represents a step in execution of a run. - - `"last_messages"` + - `event: "thread.run.step.failed"` - - `last_messages: optional number` + - `"thread.run.step.failed"` - The number of most recent messages from the thread when constructing the context for the run. + - `object { data, event }` - - `usage: object { completion_tokens, prompt_tokens, total_tokens }` + Occurs when a [run step](/docs/api-reference/run-steps/step-object) is cancelled. - Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). + - `data: RunStep` - - `completion_tokens: number` + Represents a step in execution of a run. - Number of completion tokens used over the course of the run. + - `event: "thread.run.step.cancelled"` - - `prompt_tokens: number` + - `"thread.run.step.cancelled"` - Number of prompt tokens used over the course of the run. + - `object { data, event }` - - `total_tokens: number` + Occurs when a [run step](/docs/api-reference/run-steps/step-object) expires. - Total number of tokens used (prompt + completion). + - `data: RunStep` - - `temperature: optional number` + Represents a step in execution of a run. - The sampling temperature used for this run. If not set, defaults to 1. + - `event: "thread.run.step.expired"` - - `top_p: optional number` + - `"thread.run.step.expired"` - The nucleus sampling value used for this run. If not set, defaults to 1. +### Run Stream Event - - `event: "thread.run.cancelled"` +- `RunStreamEvent = object { data, event } or object { data, event } or object { data, event } or 7 more` - - `"thread.run.cancelled"` + Occurs when a new [run](/docs/api-reference/runs/object) is created. - `object { data, event }` - Occurs when a [run](/docs/api-reference/runs/object) expires. + Occurs when a new [run](/docs/api-reference/runs/object) is created. - `data: Run` @@ -16757,7 +5275,7 @@ curl https://api.openai.com/v1/assistants/asst_abc123 \ - `"auto"` - - `ResponseFormatText = object { type }` + - `ResponseFormatText object { type }` Default response format. Used to generate text responses. @@ -16767,7 +5285,7 @@ curl https://api.openai.com/v1/assistants/asst_abc123 \ - `"text"` - - `ResponseFormatJSONObject = object { type }` + - `ResponseFormatJSONObject object { type }` JSON object response format. An older method of generating JSON responses. Using `json_schema` is recommended for models that support it. Note that the @@ -16780,7 +5298,7 @@ curl https://api.openai.com/v1/assistants/asst_abc123 \ - `"json_object"` - - `ResponseFormatJSONSchema = object { json_schema, type }` + - `ResponseFormatJSONSchema object { json_schema, type }` JSON Schema response format. Used to generate structured JSON responses. Learn more about [Structured Outputs](/docs/guides/structured-outputs). @@ -16866,7 +5384,7 @@ curl https://api.openai.com/v1/assistants/asst_abc123 \ - `"required"` - - `AssistantToolChoice = object { type, function }` + - `AssistantToolChoice object { type, function }` Specifies a tool the model should use. Use to force the model to call a specific tool. @@ -16890,7 +5408,7 @@ curl https://api.openai.com/v1/assistants/asst_abc123 \ The list of tools that the [assistant](/docs/api-reference/assistants) used for this run. - - `CodeInterpreterTool = object { type }` + - `CodeInterpreterTool object { type }` - `type: "code_interpreter"` @@ -16898,7 +5416,7 @@ curl https://api.openai.com/v1/assistants/asst_abc123 \ - `"code_interpreter"` - - `FileSearchTool = object { type, file_search }` + - `FileSearchTool object { type, file_search }` - `type: "file_search"` @@ -16934,7 +5452,7 @@ curl https://api.openai.com/v1/assistants/asst_abc123 \ - `"default_2024_08_21"` - - `FunctionTool = object { function, type }` + - `FunctionTool object { function, type }` - `function: FunctionDefinition` @@ -17002,13 +5520,121 @@ curl https://api.openai.com/v1/assistants/asst_abc123 \ The nucleus sampling value used for this run. If not set, defaults to 1. + - `event: "thread.run.created"` + + - `"thread.run.created"` + + - `object { data, event }` + + Occurs when a [run](/docs/api-reference/runs/object) moves to a `queued` status. + + - `data: Run` + + Represents an execution run on a [thread](/docs/api-reference/threads). + + - `event: "thread.run.queued"` + + - `"thread.run.queued"` + + - `object { data, event }` + + Occurs when a [run](/docs/api-reference/runs/object) moves to an `in_progress` status. + + - `data: Run` + + Represents an execution run on a [thread](/docs/api-reference/threads). + + - `event: "thread.run.in_progress"` + + - `"thread.run.in_progress"` + + - `object { data, event }` + + Occurs when a [run](/docs/api-reference/runs/object) moves to a `requires_action` status. + + - `data: Run` + + Represents an execution run on a [thread](/docs/api-reference/threads). + + - `event: "thread.run.requires_action"` + + - `"thread.run.requires_action"` + + - `object { data, event }` + + Occurs when a [run](/docs/api-reference/runs/object) is completed. + + - `data: Run` + + Represents an execution run on a [thread](/docs/api-reference/threads). + + - `event: "thread.run.completed"` + + - `"thread.run.completed"` + + - `object { data, event }` + + Occurs when a [run](/docs/api-reference/runs/object) ends with status `incomplete`. + + - `data: Run` + + Represents an execution run on a [thread](/docs/api-reference/threads). + + - `event: "thread.run.incomplete"` + + - `"thread.run.incomplete"` + + - `object { data, event }` + + Occurs when a [run](/docs/api-reference/runs/object) fails. + + - `data: Run` + + Represents an execution run on a [thread](/docs/api-reference/threads). + + - `event: "thread.run.failed"` + + - `"thread.run.failed"` + + - `object { data, event }` + + Occurs when a [run](/docs/api-reference/runs/object) moves to a `cancelling` status. + + - `data: Run` + + Represents an execution run on a [thread](/docs/api-reference/threads). + + - `event: "thread.run.cancelling"` + + - `"thread.run.cancelling"` + + - `object { data, event }` + + Occurs when a [run](/docs/api-reference/runs/object) is cancelled. + + - `data: Run` + + Represents an execution run on a [thread](/docs/api-reference/threads). + + - `event: "thread.run.cancelled"` + + - `"thread.run.cancelled"` + + - `object { data, event }` + + Occurs when a [run](/docs/api-reference/runs/object) expires. + + - `data: Run` + + Represents an execution run on a [thread](/docs/api-reference/threads). + - `event: "thread.run.expired"` - `"thread.run.expired"` ### Thread Stream Event -- `ThreadStreamEvent = object { data, event, enabled }` +- `ThreadStreamEvent object { data, event, enabled }` Occurs when a new [thread](/docs/api-reference/threads/object) is created.