diff --git a/en/ruby/resources/beta/subresources/threads/index.md b/en/ruby/resources/beta/subresources/threads/index.md index 5bc452b4..a5c6309c 100644 --- a/en/ruby/resources/beta/subresources/threads/index.md +++ b/en/ruby/resources/beta/subresources/threads/index.md @@ -6,7 +6,7 @@ **post** `/threads` -Create thread +Create a thread. ### Parameters @@ -304,7 +304,7 @@ puts(thread) **post** `/threads/runs` -Create thread and run +Create a thread and run it in one request. ### Parameters @@ -857,10 +857,76 @@ Create thread and run The ID of the [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant. -- `tools: Array[untyped]` +- `tools: Array[AssistantTool]` Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. + - `class CodeInterpreterTool` + + - `class FileSearchTool` + + - `type: :file_search` + + The type of tool being defined: `file_search` + + - `:file_search` + + - `file_search: FileSearch{ max_num_results, ranking_options}` + + Overrides for the file search tool. + + - `max_num_results: Integer` + + 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](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + + - `ranking_options: RankingOptions{ 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](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + + - `score_threshold: Float` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `ranker: :auto | :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` + + - `class FunctionTool` + + - `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: String` + + A description of what the function does, used by the model to choose when and how to call the function. + + - `parameters: FunctionParameters` + + The parameters the functions accepts, described as a JSON Schema object. See the [guide](https://platform.openai.com/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: bool` + + 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](https://platform.openai.com/docs/guides/function-calling). + + - `type: :function` + + The type of tool being defined: `function` + + - `:function` + - `top_p: Float` An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. @@ -1103,7 +1169,27 @@ Create thread and run The Unix timestamp (in seconds) for when the run was started. - - `status: untyped` + - `status: RunStatus` + + 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` @@ -1147,10 +1233,82 @@ Create thread and run The name of the function to call. - - `tools: Array[untyped]` + - `tools: Array[AssistantTool]` The list of tools that the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run. + - `class CodeInterpreterTool` + + - `type: :code_interpreter` + + The type of tool being defined: `code_interpreter` + + - `:code_interpreter` + + - `class FileSearchTool` + + - `type: :file_search` + + The type of tool being defined: `file_search` + + - `:file_search` + + - `file_search: FileSearch{ max_num_results, ranking_options}` + + Overrides for the file search tool. + + - `max_num_results: Integer` + + 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](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + + - `ranking_options: RankingOptions{ 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](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + + - `score_threshold: Float` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `ranker: :auto | :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` + + - `class FunctionTool` + + - `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: String` + + A description of what the function does, used by the model to choose when and how to call the function. + + - `parameters: FunctionParameters` + + The parameters the functions accepts, described as a JSON Schema object. See the [guide](https://platform.openai.com/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: bool` + + 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](https://platform.openai.com/docs/guides/function-calling). + + - `type: :function` + + The type of tool being defined: `function` + + - `:function` + - `truncation_strategy: TruncationStrategy{ 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. @@ -1247,11 +1405,13 @@ puts(run) }, "response_format": "auto", "started_at": 0, - "status": {}, + "status": "queued", "thread_id": "thread_id", "tool_choice": "none", "tools": [ - {} + { + "type": "code_interpreter" + } ], "truncation_strategy": { "type": "auto", @@ -1273,7 +1433,7 @@ puts(run) **get** `/threads/{thread_id}` -Retrieve thread +Retrieves a thread. ### Parameters @@ -1367,7 +1527,7 @@ puts(thread) **post** `/threads/{thread_id}` -Modify thread +Modifies a thread. ### Parameters @@ -1486,7 +1646,7 @@ puts(thread) **delete** `/threads/{thread_id}` -Delete thread +Delete a thread. ### Parameters @@ -1742,7 +1902,7 @@ puts(thread_deleted) **get** `/threads/{thread_id}/runs` -List runs +Returns a list of runs belonging to a thread. ### Parameters @@ -1988,7 +2148,27 @@ List runs The Unix timestamp (in seconds) for when the run was started. - - `status: untyped` + - `status: RunStatus` + + 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` @@ -2032,10 +2212,82 @@ List runs The name of the function to call. - - `tools: Array[untyped]` + - `tools: Array[AssistantTool]` The list of tools that the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run. + - `class CodeInterpreterTool` + + - `type: :code_interpreter` + + The type of tool being defined: `code_interpreter` + + - `:code_interpreter` + + - `class FileSearchTool` + + - `type: :file_search` + + The type of tool being defined: `file_search` + + - `:file_search` + + - `file_search: FileSearch{ max_num_results, ranking_options}` + + Overrides for the file search tool. + + - `max_num_results: Integer` + + 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](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + + - `ranking_options: RankingOptions{ 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](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + + - `score_threshold: Float` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `ranker: :auto | :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` + + - `class FunctionTool` + + - `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: String` + + A description of what the function does, used by the model to choose when and how to call the function. + + - `parameters: FunctionParameters` + + The parameters the functions accepts, described as a JSON Schema object. See the [guide](https://platform.openai.com/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: bool` + + 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](https://platform.openai.com/docs/guides/function-calling). + + - `type: :function` + + The type of tool being defined: `function` + + - `:function` + - `truncation_strategy: TruncationStrategy{ 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. @@ -2134,11 +2386,13 @@ puts(page) }, "response_format": "auto", "started_at": 0, - "status": {}, + "status": "queued", "thread_id": "thread_id", "tool_choice": "none", "tools": [ - {} + { + "type": "code_interpreter" + } ], "truncation_strategy": { "type": "auto", @@ -2166,7 +2420,7 @@ puts(page) **post** `/threads/{thread_id}/runs` -Create run +Create a run. ### Parameters @@ -2660,10 +2914,76 @@ Create run The name of the function to call. -- `tools: Array[untyped]` +- `tools: Array[AssistantTool]` Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. + - `class CodeInterpreterTool` + + - `class FileSearchTool` + + - `type: :file_search` + + The type of tool being defined: `file_search` + + - `:file_search` + + - `file_search: FileSearch{ max_num_results, ranking_options}` + + Overrides for the file search tool. + + - `max_num_results: Integer` + + 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](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + + - `ranking_options: RankingOptions{ 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](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + + - `score_threshold: Float` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `ranker: :auto | :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` + + - `class FunctionTool` + + - `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: String` + + A description of what the function does, used by the model to choose when and how to call the function. + + - `parameters: FunctionParameters` + + The parameters the functions accepts, described as a JSON Schema object. See the [guide](https://platform.openai.com/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: bool` + + 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](https://platform.openai.com/docs/guides/function-calling). + + - `type: :function` + + The type of tool being defined: `function` + + - `:function` + - `top_p: Float` An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. @@ -2906,21 +3226,41 @@ Create run The Unix timestamp (in seconds) for when the run was started. - - `status: untyped` + - `status: RunStatus` - - `thread_id: String` + The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. - The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) that was executed on as a part of this run. + - `:queued` - - `tool_choice: AssistantToolChoiceOption` + - `:in_progress` - 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. + - `:requires_action` - - `Auto = :none | :auto | :required` + - `:cancelling` + + - `:cancelled` + + - `:failed` + + - `:completed` + + - `:incomplete` + + - `:expired` + + - `thread_id: String` + + The ID of the [thread](https://platform.openai.com/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. + + - `Auto = :none | :auto | :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. @@ -2950,10 +3290,82 @@ Create run The name of the function to call. - - `tools: Array[untyped]` + - `tools: Array[AssistantTool]` The list of tools that the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run. + - `class CodeInterpreterTool` + + - `type: :code_interpreter` + + The type of tool being defined: `code_interpreter` + + - `:code_interpreter` + + - `class FileSearchTool` + + - `type: :file_search` + + The type of tool being defined: `file_search` + + - `:file_search` + + - `file_search: FileSearch{ max_num_results, ranking_options}` + + Overrides for the file search tool. + + - `max_num_results: Integer` + + 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](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + + - `ranking_options: RankingOptions{ 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](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + + - `score_threshold: Float` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `ranker: :auto | :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` + + - `class FunctionTool` + + - `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: String` + + A description of what the function does, used by the model to choose when and how to call the function. + + - `parameters: FunctionParameters` + + The parameters the functions accepts, described as a JSON Schema object. See the [guide](https://platform.openai.com/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: bool` + + 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](https://platform.openai.com/docs/guides/function-calling). + + - `type: :function` + + The type of tool being defined: `function` + + - `:function` + - `truncation_strategy: TruncationStrategy{ 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. @@ -3050,11 +3462,13 @@ puts(run) }, "response_format": "auto", "started_at": 0, - "status": {}, + "status": "queued", "thread_id": "thread_id", "tool_choice": "none", "tools": [ - {} + { + "type": "code_interpreter" + } ], "truncation_strategy": { "type": "auto", @@ -3076,7 +3490,7 @@ puts(run) **get** `/threads/{thread_id}/runs/{run_id}` -Retrieve run +Retrieves a run. ### Parameters @@ -3304,7 +3718,27 @@ Retrieve run The Unix timestamp (in seconds) for when the run was started. - - `status: untyped` + - `status: RunStatus` + + 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` @@ -3348,10 +3782,82 @@ Retrieve run The name of the function to call. - - `tools: Array[untyped]` + - `tools: Array[AssistantTool]` The list of tools that the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run. + - `class CodeInterpreterTool` + + - `type: :code_interpreter` + + The type of tool being defined: `code_interpreter` + + - `:code_interpreter` + + - `class FileSearchTool` + + - `type: :file_search` + + The type of tool being defined: `file_search` + + - `:file_search` + + - `file_search: FileSearch{ max_num_results, ranking_options}` + + Overrides for the file search tool. + + - `max_num_results: Integer` + + 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](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + + - `ranking_options: RankingOptions{ 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](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + + - `score_threshold: Float` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `ranker: :auto | :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` + + - `class FunctionTool` + + - `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: String` + + A description of what the function does, used by the model to choose when and how to call the function. + + - `parameters: FunctionParameters` + + The parameters the functions accepts, described as a JSON Schema object. See the [guide](https://platform.openai.com/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: bool` + + 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](https://platform.openai.com/docs/guides/function-calling). + + - `type: :function` + + The type of tool being defined: `function` + + - `:function` + - `truncation_strategy: TruncationStrategy{ 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. @@ -3448,11 +3954,13 @@ puts(run) }, "response_format": "auto", "started_at": 0, - "status": {}, + "status": "queued", "thread_id": "thread_id", "tool_choice": "none", "tools": [ - {} + { + "type": "code_interpreter" + } ], "truncation_strategy": { "type": "auto", @@ -3474,7 +3982,7 @@ puts(run) **post** `/threads/{thread_id}/runs/{run_id}` -Modify run +Modifies a run. ### Parameters @@ -3711,7 +4219,27 @@ Modify run The Unix timestamp (in seconds) for when the run was started. - - `status: untyped` + - `status: RunStatus` + + 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` @@ -3755,10 +4283,82 @@ Modify run The name of the function to call. - - `tools: Array[untyped]` + - `tools: Array[AssistantTool]` The list of tools that the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run. + - `class CodeInterpreterTool` + + - `type: :code_interpreter` + + The type of tool being defined: `code_interpreter` + + - `:code_interpreter` + + - `class FileSearchTool` + + - `type: :file_search` + + The type of tool being defined: `file_search` + + - `:file_search` + + - `file_search: FileSearch{ max_num_results, ranking_options}` + + Overrides for the file search tool. + + - `max_num_results: Integer` + + 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](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + + - `ranking_options: RankingOptions{ 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](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + + - `score_threshold: Float` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `ranker: :auto | :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` + + - `class FunctionTool` + + - `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: String` + + A description of what the function does, used by the model to choose when and how to call the function. + + - `parameters: FunctionParameters` + + The parameters the functions accepts, described as a JSON Schema object. See the [guide](https://platform.openai.com/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: bool` + + 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](https://platform.openai.com/docs/guides/function-calling). + + - `type: :function` + + The type of tool being defined: `function` + + - `:function` + - `truncation_strategy: TruncationStrategy{ 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. @@ -3855,11 +4455,13 @@ puts(run) }, "response_format": "auto", "started_at": 0, - "status": {}, + "status": "queued", "thread_id": "thread_id", "tool_choice": "none", "tools": [ - {} + { + "type": "code_interpreter" + } ], "truncation_strategy": { "type": "auto", @@ -3881,7 +4483,7 @@ puts(run) **post** `/threads/{thread_id}/runs/{run_id}/submit_tool_outputs` -Submit tool outputs to run +When a run has the `status: "requires_action"` and `required_action.type` is `submit_tool_outputs`, this endpoint can be used to submit the outputs from the tool calls once they're all completed. All outputs must be submitted in a single request. ### Parameters @@ -4125,7 +4727,27 @@ Submit tool outputs to run The Unix timestamp (in seconds) for when the run was started. - - `status: untyped` + - `status: RunStatus` + + 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` @@ -4169,21 +4791,93 @@ Submit tool outputs to run The name of the function to call. - - `tools: Array[untyped]` + - `tools: Array[AssistantTool]` The list of tools that the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run. - - `truncation_strategy: TruncationStrategy{ type, last_messages}` + - `class CodeInterpreterTool` - Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. + - `type: :code_interpreter` - - `type: :auto | :last_messages` + The type of tool being defined: `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`. + - `:code_interpreter` - - `:auto` + - `class FileSearchTool` - - `:last_messages` + - `type: :file_search` + + The type of tool being defined: `file_search` + + - `:file_search` + + - `file_search: FileSearch{ max_num_results, ranking_options}` + + Overrides for the file search tool. + + - `max_num_results: Integer` + + 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](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + + - `ranking_options: RankingOptions{ 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](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + + - `score_threshold: Float` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `ranker: :auto | :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` + + - `class FunctionTool` + + - `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: String` + + A description of what the function does, used by the model to choose when and how to call the function. + + - `parameters: FunctionParameters` + + The parameters the functions accepts, described as a JSON Schema object. See the [guide](https://platform.openai.com/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: bool` + + 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](https://platform.openai.com/docs/guides/function-calling). + + - `type: :function` + + The type of tool being defined: `function` + + - `:function` + + - `truncation_strategy: TruncationStrategy{ 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 | :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: Integer` @@ -4269,11 +4963,13 @@ puts(run) }, "response_format": "auto", "started_at": 0, - "status": {}, + "status": "queued", "thread_id": "thread_id", "tool_choice": "none", "tools": [ - {} + { + "type": "code_interpreter" + } ], "truncation_strategy": { "type": "auto", @@ -4295,7 +4991,7 @@ puts(run) **post** `/threads/{thread_id}/runs/{run_id}/cancel` -Cancel a run +Cancels a run that is `in_progress`. ### Parameters @@ -4523,7 +5219,27 @@ Cancel a run The Unix timestamp (in seconds) for when the run was started. - - `status: untyped` + - `status: RunStatus` + + 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` @@ -4567,10 +5283,82 @@ Cancel a run The name of the function to call. - - `tools: Array[untyped]` + - `tools: Array[AssistantTool]` The list of tools that the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run. + - `class CodeInterpreterTool` + + - `type: :code_interpreter` + + The type of tool being defined: `code_interpreter` + + - `:code_interpreter` + + - `class FileSearchTool` + + - `type: :file_search` + + The type of tool being defined: `file_search` + + - `:file_search` + + - `file_search: FileSearch{ max_num_results, ranking_options}` + + Overrides for the file search tool. + + - `max_num_results: Integer` + + 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](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + + - `ranking_options: RankingOptions{ 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](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + + - `score_threshold: Float` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `ranker: :auto | :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` + + - `class FunctionTool` + + - `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: String` + + A description of what the function does, used by the model to choose when and how to call the function. + + - `parameters: FunctionParameters` + + The parameters the functions accepts, described as a JSON Schema object. See the [guide](https://platform.openai.com/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: bool` + + 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](https://platform.openai.com/docs/guides/function-calling). + + - `type: :function` + + The type of tool being defined: `function` + + - `:function` + - `truncation_strategy: TruncationStrategy{ 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. @@ -4667,11 +5455,13 @@ puts(run) }, "response_format": "auto", "started_at": 0, - "status": {}, + "status": "queued", "thread_id": "thread_id", "tool_choice": "none", "tools": [ - {} + { + "type": "code_interpreter" + } ], "truncation_strategy": { "type": "auto", @@ -4937,7 +5727,27 @@ puts(run) The Unix timestamp (in seconds) for when the run was started. - - `status: untyped` + - `status: RunStatus` + + 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` @@ -4981,10 +5791,82 @@ puts(run) The name of the function to call. - - `tools: Array[untyped]` + - `tools: Array[AssistantTool]` The list of tools that the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run. + - `class CodeInterpreterTool` + + - `type: :code_interpreter` + + The type of tool being defined: `code_interpreter` + + - `:code_interpreter` + + - `class FileSearchTool` + + - `type: :file_search` + + The type of tool being defined: `file_search` + + - `:file_search` + + - `file_search: FileSearch{ max_num_results, ranking_options}` + + Overrides for the file search tool. + + - `max_num_results: Integer` + + 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](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + + - `ranking_options: RankingOptions{ 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](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. + + - `score_threshold: Float` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `ranker: :auto | :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` + + - `class FunctionTool` + + - `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: String` + + A description of what the function does, used by the model to choose when and how to call the function. + + - `parameters: FunctionParameters` + + The parameters the functions accepts, described as a JSON Schema object. See the [guide](https://platform.openai.com/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: bool` + + 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](https://platform.openai.com/docs/guides/function-calling). + + - `type: :function` + + The type of tool being defined: `function` + + - `:function` + - `truncation_strategy: TruncationStrategy{ 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. @@ -5027,7 +5909,27 @@ puts(run) ### Run Status -- `RunStatus = untyped` +- `RunStatus = :queued | :in_progress | :requires_action | 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` # Steps @@ -5037,7 +5939,7 @@ puts(run) **get** `/threads/{thread_id}/runs/{run_id}/steps` -List run steps +Returns a list of run steps belonging to a run. ### Parameters @@ -5180,45 +6082,189 @@ List run steps Details of the tool call. - - `tool_calls: Array[untyped]` + - `tool_calls: Array[ToolCall]` 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`. - - `type: :tool_calls` + - `class CodeInterpreterToolCall` - Always `tool_calls`. + Details of the Code Interpreter tool call the run step was involved in. - - `:tool_calls` + - `id: String` - - `thread_id: String` + The ID of the tool call. - The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) that was run. + - `code_interpreter: CodeInterpreter{ input, outputs}` - - `type: :message_creation | :tool_calls` + The Code Interpreter tool call definition. - The type of run step, which can be either `message_creation` or `tool_calls`. + - `input: String` - - `:message_creation` + The input to the Code Interpreter tool call. - - `:tool_calls` + - `outputs: Array[Logs{ logs, type} | Image{ image, type}]` - - `usage: Usage{ completion_tokens, prompt_tokens, total_tokens}` + 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. - Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. + - `class Logs` - - `completion_tokens: Integer` + Text output from the Code Interpreter tool call as part of a run step. - Number of completion tokens used over the course of the run step. + - `logs: String` - - `prompt_tokens: Integer` + The text output from the Code Interpreter tool call. - Number of prompt tokens used over the course of the run step. + - `type: :logs` - - `total_tokens: Integer` + Always `logs`. - Total number of tokens used (prompt + completion). + - `:logs` -### Example + - `class Image` + + - `image: Image{ file_id}` + + - `file_id: String` + + The [file](https://platform.openai.com/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` + + - `class FileSearchToolCall` + + - `id: String` + + The ID of the tool call object. + + - `file_search: FileSearch{ ranking_options, results}` + + For now, this is always going to be an empty object. + + - `ranking_options: RankingOptions{ ranker, score_threshold}` + + The ranking options for the file search. + + - `ranker: :auto | :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: Float` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `results: Array[Result{ 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: Float` + + The score of the result. All values must be a floating point number between 0 and 1. + + - `content: Array[Content{ text, type}]` + + The content of the result that was found. The content is only included if requested via the include query parameter. + + - `text: String` + + The text content of the file. + + - `type: :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` + + - `class FunctionToolCall` + + - `id: String` + + The ID of the tool call object. + + - `function: Function{ 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](https://platform.openai.com/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](https://platform.openai.com/docs/api-reference/threads) that was run. + + - `type: :message_creation | :tool_calls` + + The type of run step, which can be either `message_creation` or `tool_calls`. + + - `:message_creation` + + - `:tool_calls` + + - `usage: Usage{ 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: Integer` + + Number of completion tokens used over the course of the run step. + + - `prompt_tokens: Integer` + + Number of prompt tokens used over the course of the run step. + + - `total_tokens: Integer` + + Total number of tokens used (prompt + completion). + +### Example ```ruby require "openai" @@ -5281,7 +6327,7 @@ puts(page) **get** `/threads/{thread_id}/runs/{run_id}/steps/{step_id}` -Retrieve run step +Retrieves a run step. ### Parameters @@ -5406,126 +6452,270 @@ Retrieve run step Details of the tool call. - - `tool_calls: Array[untyped]` + - `tool_calls: Array[ToolCall]` 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`. - - `type: :tool_calls` + - `class CodeInterpreterToolCall` - Always `tool_calls`. + Details of the Code Interpreter tool call the run step was involved in. - - `:tool_calls` + - `id: String` - - `thread_id: String` + The ID of the tool call. - The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) that was run. + - `code_interpreter: CodeInterpreter{ input, outputs}` - - `type: :message_creation | :tool_calls` + The Code Interpreter tool call definition. - The type of run step, which can be either `message_creation` or `tool_calls`. + - `input: String` - - `:message_creation` + The input to the Code Interpreter tool call. - - `:tool_calls` + - `outputs: Array[Logs{ logs, type} | Image{ image, type}]` - - `usage: Usage{ completion_tokens, prompt_tokens, total_tokens}` + 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. - Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. + - `class Logs` - - `completion_tokens: Integer` + Text output from the Code Interpreter tool call as part of a run step. - Number of completion tokens used over the course of the run step. + - `logs: String` - - `prompt_tokens: Integer` + The text output from the Code Interpreter tool call. - Number of prompt tokens used over the course of the run step. + - `type: :logs` - - `total_tokens: Integer` + Always `logs`. - Total number of tokens used (prompt + completion). + - `:logs` -### Example + - `class Image` -```ruby -require "openai" + - `image: Image{ file_id}` -openai = OpenAI::Client.new(api_key: "My API Key") + - `file_id: String` -run_step = openai.beta.threads.runs.steps.retrieve("step_id", thread_id: "thread_id", run_id: "run_id") + The [file](https://platform.openai.com/docs/api-reference/files) ID of the image. -puts(run_step) -``` + - `type: :image` -#### Response + Always `image`. -```json -{ - "id": "id", - "assistant_id": "assistant_id", - "cancelled_at": 0, - "completed_at": 0, - "created_at": 0, - "expired_at": 0, - "failed_at": 0, - "last_error": { - "code": "server_error", - "message": "message" - }, - "metadata": { - "foo": "string" - }, - "object": "thread.run.step", - "run_id": "run_id", - "status": "in_progress", - "step_details": { - "message_creation": { - "message_id": "message_id" - }, - "type": "message_creation" - }, - "thread_id": "thread_id", - "type": "message_creation", - "usage": { - "completion_tokens": 0, - "prompt_tokens": 0, - "total_tokens": 0 - } -} -``` + - `:image` -## Domain Types + - `type: :code_interpreter` -### Code Interpreter Logs + The type of tool call. This is always going to be `code_interpreter` for this type of tool call. -- `class CodeInterpreterLogs` + - `:code_interpreter` - Text output from the Code Interpreter tool call as part of a run step. + - `class FileSearchToolCall` - - `index: Integer` + - `id: String` - The index of the output in the outputs array. + The ID of the tool call object. - - `type: :logs` + - `file_search: FileSearch{ ranking_options, results}` - Always `logs`. + For now, this is always going to be an empty object. - - `:logs` + - `ranking_options: RankingOptions{ ranker, score_threshold}` - - `logs: String` + The ranking options for the file search. - The text output from the Code Interpreter tool call. + - `ranker: :auto | :default_2024_08_21` -### Code Interpreter Output Image + The ranker to use for the file search. If not specified will use the `auto` ranker. -- `class CodeInterpreterOutputImage` + - `:auto` - - `index: Integer` + - `:default_2024_08_21` - The index of the output in the outputs array. + - `score_threshold: Float` - - `type: :image` + The score threshold for the file search. All values must be a floating point number between 0 and 1. - Always `image`. + - `results: Array[Result{ 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: Float` + + The score of the result. All values must be a floating point number between 0 and 1. + + - `content: Array[Content{ text, type}]` + + The content of the result that was found. The content is only included if requested via the include query parameter. + + - `text: String` + + The text content of the file. + + - `type: :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` + + - `class FunctionToolCall` + + - `id: String` + + The ID of the tool call object. + + - `function: Function{ 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](https://platform.openai.com/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](https://platform.openai.com/docs/api-reference/threads) that was run. + + - `type: :message_creation | :tool_calls` + + The type of run step, which can be either `message_creation` or `tool_calls`. + + - `:message_creation` + + - `:tool_calls` + + - `usage: Usage{ 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: Integer` + + Number of completion tokens used over the course of the run step. + + - `prompt_tokens: Integer` + + Number of prompt tokens used over the course of the run step. + + - `total_tokens: Integer` + + Total number of tokens used (prompt + completion). + +### Example + +```ruby +require "openai" + +openai = OpenAI::Client.new(api_key: "My API Key") + +run_step = openai.beta.threads.runs.steps.retrieve("step_id", thread_id: "thread_id", run_id: "run_id") + +puts(run_step) +``` + +#### Response + +```json +{ + "id": "id", + "assistant_id": "assistant_id", + "cancelled_at": 0, + "completed_at": 0, + "created_at": 0, + "expired_at": 0, + "failed_at": 0, + "last_error": { + "code": "server_error", + "message": "message" + }, + "metadata": { + "foo": "string" + }, + "object": "thread.run.step", + "run_id": "run_id", + "status": "in_progress", + "step_details": { + "message_creation": { + "message_id": "message_id" + }, + "type": "message_creation" + }, + "thread_id": "thread_id", + "type": "message_creation", + "usage": { + "completion_tokens": 0, + "prompt_tokens": 0, + "total_tokens": 0 + } +} +``` + +## Domain Types + +### Code Interpreter Logs + +- `class CodeInterpreterLogs` + + Text output from the Code Interpreter tool call as part of a run step. + + - `index: Integer` + + The index of the output in the outputs array. + + - `type: :logs` + + Always `logs`. + + - `:logs` + + - `logs: String` + + The text output from the Code Interpreter tool call. + +### Code Interpreter Output Image + +- `class CodeInterpreterOutputImage` + + - `index: Integer` + + The index of the output in the outputs array. + + - `type: :image` + + Always `image`. - `:image` @@ -5934,123 +7124,153 @@ puts(run_step) Details of the tool call. - - `tool_calls: Array[untyped]` + - `tool_calls: Array[ToolCall]` 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`. - - `type: :tool_calls` + - `class CodeInterpreterToolCall` - Always `tool_calls`. + Details of the Code Interpreter tool call the run step was involved in. - - `:tool_calls` + - `id: String` - - `thread_id: String` + The ID of the tool call. - The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) that was run. + - `code_interpreter: CodeInterpreter{ input, outputs}` - - `type: :message_creation | :tool_calls` + The Code Interpreter tool call definition. - The type of run step, which can be either `message_creation` or `tool_calls`. + - `input: String` - - `:message_creation` + The input to the Code Interpreter tool call. - - `:tool_calls` + - `outputs: Array[Logs{ logs, type} | Image{ image, type}]` - - `usage: Usage{ completion_tokens, prompt_tokens, total_tokens}` + 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. - Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. + - `class Logs` - - `completion_tokens: Integer` + Text output from the Code Interpreter tool call as part of a run step. - Number of completion tokens used over the course of the run step. + - `logs: String` - - `prompt_tokens: Integer` + The text output from the Code Interpreter tool call. - Number of prompt tokens used over the course of the run step. + - `type: :logs` - - `total_tokens: Integer` + Always `logs`. - Total number of tokens used (prompt + completion). + - `:logs` -### Run Step Delta + - `class Image` -- `RunStepDelta = untyped` + - `image: Image{ file_id}` -### Run Step Delta Event + - `file_id: String` -- `class RunStepDeltaEvent` + The [file](https://platform.openai.com/docs/api-reference/files) ID of the image. - Represents a run step delta i.e. any changed fields on a run step during streaming. + - `type: :image` - - `id: String` + Always `image`. - The identifier of the run step, which can be referenced in API endpoints. + - `:image` - - `delta: untyped` + - `type: :code_interpreter` - - `object: :"thread.run.step.delta"` + The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - The object type, which is always `thread.run.step.delta`. + - `:code_interpreter` - - `:"thread.run.step.delta"` + - `class FileSearchToolCall` -### Run Step Delta Message Delta + - `id: String` -- `class RunStepDeltaMessageDelta` + The ID of the tool call object. - Details of the message creation by the run step. + - `file_search: FileSearch{ ranking_options, results}` - - `type: :message_creation` + For now, this is always going to be an empty object. - Always `message_creation`. + - `ranking_options: RankingOptions{ ranker, score_threshold}` - - `:message_creation` + The ranking options for the file search. - - `message_creation: MessageCreation{ message_id}` + - `ranker: :auto | :default_2024_08_21` - - `message_id: String` + The ranker to use for the file search. If not specified will use the `auto` ranker. - The ID of the message that was created by this run step. + - `:auto` -### Run Step Include + - `:default_2024_08_21` -- `RunStepInclude = :"step_details.tool_calls[*].file_search.results[*].content"` + - `score_threshold: Float` - - `:"step_details.tool_calls[*].file_search.results[*].content"` + The score threshold for the file search. All values must be a floating point number between 0 and 1. -### Tool Call + - `results: Array[Result{ file_id, file_name, score, content}]` -- `ToolCall = untyped` + The results of the file search. -### Tool Call Delta + - `file_id: String` -- `ToolCallDelta = untyped` + The ID of the file that result was found in. -### Tool Call Delta Object + - `file_name: String` -- `class ToolCallDeltaObject` + The name of the file that result was found in. - Details of the tool call. + - `score: Float` - - `type: :tool_calls` + The score of the result. All values must be a floating point number between 0 and 1. - Always `tool_calls`. + - `content: Array[Content{ text, type}]` - - `:tool_calls` + The content of the result that was found. The content is only included if requested via the include query parameter. - - `tool_calls: Array[untyped]` + - `text: String` - 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 text content of the file. -### Tool Calls Step Details + - `type: :text` -- `class ToolCallsStepDetails` + The type of the content. - Details of the tool call. + - `:text` - - `tool_calls: Array[untyped]` + - `type: :file_search` - 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 type of tool call. This is always going to be `file_search` for this type of tool call. + + - `:file_search` + + - `class FunctionToolCall` + + - `id: String` + + The ID of the tool call object. + + - `function: Function{ 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](https://platform.openai.com/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` @@ -6058,210 +7278,1296 @@ puts(run_step) - `:tool_calls` -# Messages + - `thread_id: String` -## List messages + The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) that was run. -`beta.threads.messages.list(thread_id, **kwargs) -> CursorPage` + - `type: :message_creation | :tool_calls` -**get** `/threads/{thread_id}/messages` + The type of run step, which can be either `message_creation` or `tool_calls`. -List messages + - `:message_creation` -### Parameters + - `:tool_calls` -- `thread_id: String` + - `usage: Usage{ completion_tokens, prompt_tokens, total_tokens}` -- `after: String` + Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. - A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + - `completion_tokens: Integer` -- `before: String` + Number of completion tokens used over the course of the run step. - A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + - `prompt_tokens: Integer` -- `limit: Integer` + Number of prompt tokens used over the course of the run step. - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + - `total_tokens: Integer` -- `order: :asc | :desc` + Total number of tokens used (prompt + completion). - Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. +### Run Step Delta - - `:asc` +- `class RunStepDelta` - - `:desc` + The delta containing the fields that have changed on the run step. -- `run_id: String` + - `step_details: RunStepDeltaMessageDelta | ToolCallDeltaObject` - Filter messages by the run ID that generated them. + The details of the run step. -### Returns + - `class RunStepDeltaMessageDelta` -- `class Message` + Details of the message creation by the run step. - Represents a message within a [thread](https://platform.openai.com/docs/api-reference/threads). + - `type: :message_creation` - - `id: String` + Always `message_creation`. - The identifier, which can be referenced in API endpoints. + - `:message_creation` - - `assistant_id: String` + - `message_creation: MessageCreation{ message_id}` - If applicable, the ID of the [assistant](https://platform.openai.com/docs/api-reference/assistants) that authored this message. + - `message_id: String` - - `attachments: Array[Attachment{ file_id, tools}]` + The ID of the message that was created by this run step. - A list of files attached to the message, and the tools they were added to. + - `class ToolCallDeltaObject` - - `file_id: String` + Details of the tool call. - The ID of the file to attach to the message. + - `type: :tool_calls` - - `tools: Array[CodeInterpreterTool | AssistantToolsFileSearchTypeOnly{ type}]` + Always `tool_calls`. - The tools to add this file to. + - `:tool_calls` - - `class CodeInterpreterTool` + - `tool_calls: Array[ToolCallDelta]` + + 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`. + + - `class CodeInterpreterToolCallDelta` + + Details of the Code Interpreter tool call the run step was involved in. + + - `index: Integer` + + The index of the tool call in the tool calls array. - `type: :code_interpreter` - The type of tool being defined: `code_interpreter` + The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - `:code_interpreter` - - `class AssistantToolsFileSearchTypeOnly` + - `id: String` - - `type: :file_search` + The ID of the tool call. - The type of tool being defined: `file_search` + - `code_interpreter: CodeInterpreter{ input, outputs}` - - `:file_search` + The Code Interpreter tool call definition. - - `completed_at: Integer` + - `input: String` - The Unix timestamp (in seconds) for when the message was completed. + The input to the Code Interpreter tool call. - - `content: Array[untyped]` + - `outputs: Array[CodeInterpreterLogs | CodeInterpreterOutputImage]` - The content of the message in array of text and/or images. + 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. - - `created_at: Integer` + - `class CodeInterpreterLogs` - The Unix timestamp (in seconds) for when the message was created. + Text output from the Code Interpreter tool call as part of a run step. - - `incomplete_at: Integer` + - `index: Integer` - The Unix timestamp (in seconds) for when the message was marked as incomplete. + The index of the output in the outputs array. - - `incomplete_details: IncompleteDetails{ reason}` + - `type: :logs` - On an incomplete message, details about why the message is incomplete. + Always `logs`. - - `reason: :content_filter | :max_tokens | :run_cancelled | 2 more` + - `:logs` - The reason the message is incomplete. + - `logs: String` - - `:content_filter` + The text output from the Code Interpreter tool call. - - `:max_tokens` + - `class CodeInterpreterOutputImage` - - `:run_cancelled` + - `index: Integer` - - `:run_expired` + The index of the output in the outputs array. - - `:run_failed` + - `type: :image` - - `metadata: Metadata` + Always `image`. - 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. + - `:image` - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. + - `image: Image{ file_id}` - - `object: :"thread.message"` + - `file_id: String` - The object type, which is always `thread.message`. + The [file](https://platform.openai.com/docs/api-reference/files) ID of the image. - - `:"thread.message"` + - `class FileSearchToolCallDelta` - - `role: :user | :assistant` + - `file_search: untyped` - The entity that produced the message. One of `user` or `assistant`. + For now, this is always going to be an empty object. - - `:user` + - `index: Integer` - - `:assistant` + The index of the tool call in the tool calls array. - - `run_id: String` + - `type: :file_search` - The ID of the [run](https://platform.openai.com/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. + The type of tool call. This is always going to be `file_search` for this type of tool call. - - `status: :in_progress | :incomplete | :completed` + - `:file_search` - The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. + - `id: String` - - `:in_progress` + The ID of the tool call object. - - `:incomplete` + - `class FunctionToolCallDelta` - - `:completed` + - `index: Integer` - - `thread_id: String` + The index of the tool call in the tool calls array. - The [thread](https://platform.openai.com/docs/api-reference/threads) ID that this message belongs to. + - `type: :function` -### Example + The type of tool call. This is always going to be `function` for this type of tool call. -```ruby -require "openai" + - `:function` -openai = OpenAI::Client.new(api_key: "My API Key") + - `id: String` -page = openai.beta.threads.messages.list("thread_id") + The ID of the tool call object. -puts(page) -``` + - `function: Function{ arguments, name, output}` -#### Response + The definition of the function that was called. -```json -{ - "data": [ - { - "id": "id", - "assistant_id": "assistant_id", - "attachments": [ - { - "file_id": "file_id", - "tools": [ - { - "type": "code_interpreter" - } - ] - } - ], - "completed_at": 0, - "content": [ - {} - ], - "created_at": 0, - "incomplete_at": 0, - "incomplete_details": { - "reason": "content_filter" - }, - "metadata": { - "foo": "string" - }, - "object": "thread.message", - "role": "user", - "run_id": "run_id", - "status": "in_progress", - "thread_id": "thread_id" - } - ], + - `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](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs) yet. + +### Run Step Delta Event + +- `class 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: RunStepDelta` + + The delta containing the fields that have changed on the run step. + + - `step_details: RunStepDeltaMessageDelta | ToolCallDeltaObject` + + The details of the run step. + + - `class RunStepDeltaMessageDelta` + + Details of the message creation by the run step. + + - `type: :message_creation` + + Always `message_creation`. + + - `:message_creation` + + - `message_creation: MessageCreation{ message_id}` + + - `message_id: String` + + The ID of the message that was created by this run step. + + - `class ToolCallDeltaObject` + + Details of the tool call. + + - `type: :tool_calls` + + Always `tool_calls`. + + - `:tool_calls` + + - `tool_calls: Array[ToolCallDelta]` + + 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`. + + - `class CodeInterpreterToolCallDelta` + + Details of the Code Interpreter tool call the run step was involved in. + + - `index: Integer` + + 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: String` + + The ID of the tool call. + + - `code_interpreter: CodeInterpreter{ input, outputs}` + + The Code Interpreter tool call definition. + + - `input: String` + + The input to the Code Interpreter tool call. + + - `outputs: Array[CodeInterpreterLogs | 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. + + - `class CodeInterpreterLogs` + + Text output from the Code Interpreter tool call as part of a run step. + + - `index: Integer` + + The index of the output in the outputs array. + + - `type: :logs` + + Always `logs`. + + - `:logs` + + - `logs: String` + + The text output from the Code Interpreter tool call. + + - `class CodeInterpreterOutputImage` + + - `index: Integer` + + The index of the output in the outputs array. + + - `type: :image` + + Always `image`. + + - `:image` + + - `image: Image{ file_id}` + + - `file_id: String` + + The [file](https://platform.openai.com/docs/api-reference/files) ID of the image. + + - `class FileSearchToolCallDelta` + + - `file_search: untyped` + + For now, this is always going to be an empty object. + + - `index: Integer` + + 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: String` + + The ID of the tool call object. + + - `class FunctionToolCallDelta` + + - `index: Integer` + + 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: String` + + The ID of the tool call object. + + - `function: Function{ 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](https://platform.openai.com/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"` + +### Run Step Delta Message Delta + +- `class RunStepDeltaMessageDelta` + + Details of the message creation by the run step. + + - `type: :message_creation` + + Always `message_creation`. + + - `:message_creation` + + - `message_creation: MessageCreation{ message_id}` + + - `message_id: String` + + The ID of the message that was created by this run step. + +### Run Step Include + +- `RunStepInclude = :"step_details.tool_calls[*].file_search.results[*].content"` + + - `:"step_details.tool_calls[*].file_search.results[*].content"` + +### Tool Call + +- `ToolCall = CodeInterpreterToolCall | FileSearchToolCall | FunctionToolCall` + + Details of the Code Interpreter tool call the run step was involved in. + + - `class CodeInterpreterToolCall` + + Details of the Code Interpreter tool call the run step was involved in. + + - `id: String` + + The ID of the tool call. + + - `code_interpreter: CodeInterpreter{ input, outputs}` + + The Code Interpreter tool call definition. + + - `input: String` + + The input to the Code Interpreter tool call. + + - `outputs: Array[Logs{ logs, type} | Image{ 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. + + - `class Logs` + + 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` + + - `class Image` + + - `image: Image{ file_id}` + + - `file_id: String` + + The [file](https://platform.openai.com/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` + + - `class FileSearchToolCall` + + - `id: String` + + The ID of the tool call object. + + - `file_search: FileSearch{ ranking_options, results}` + + For now, this is always going to be an empty object. + + - `ranking_options: RankingOptions{ ranker, score_threshold}` + + The ranking options for the file search. + + - `ranker: :auto | :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: Float` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `results: Array[Result{ 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: Float` + + The score of the result. All values must be a floating point number between 0 and 1. + + - `content: Array[Content{ text, type}]` + + The content of the result that was found. The content is only included if requested via the include query parameter. + + - `text: String` + + The text content of the file. + + - `type: :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` + + - `class FunctionToolCall` + + - `id: String` + + The ID of the tool call object. + + - `function: Function{ 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](https://platform.openai.com/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` + +### Tool Call Delta + +- `ToolCallDelta = CodeInterpreterToolCallDelta | FileSearchToolCallDelta | FunctionToolCallDelta` + + Details of the Code Interpreter tool call the run step was involved in. + + - `class CodeInterpreterToolCallDelta` + + Details of the Code Interpreter tool call the run step was involved in. + + - `index: Integer` + + 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: String` + + The ID of the tool call. + + - `code_interpreter: CodeInterpreter{ input, outputs}` + + The Code Interpreter tool call definition. + + - `input: String` + + The input to the Code Interpreter tool call. + + - `outputs: Array[CodeInterpreterLogs | 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. + + - `class CodeInterpreterLogs` + + Text output from the Code Interpreter tool call as part of a run step. + + - `index: Integer` + + The index of the output in the outputs array. + + - `type: :logs` + + Always `logs`. + + - `:logs` + + - `logs: String` + + The text output from the Code Interpreter tool call. + + - `class CodeInterpreterOutputImage` + + - `index: Integer` + + The index of the output in the outputs array. + + - `type: :image` + + Always `image`. + + - `:image` + + - `image: Image{ file_id}` + + - `file_id: String` + + The [file](https://platform.openai.com/docs/api-reference/files) ID of the image. + + - `class FileSearchToolCallDelta` + + - `file_search: untyped` + + For now, this is always going to be an empty object. + + - `index: Integer` + + 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: String` + + The ID of the tool call object. + + - `class FunctionToolCallDelta` + + - `index: Integer` + + 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: String` + + The ID of the tool call object. + + - `function: Function{ 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](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs) yet. + +### Tool Call Delta Object + +- `class ToolCallDeltaObject` + + Details of the tool call. + + - `type: :tool_calls` + + Always `tool_calls`. + + - `:tool_calls` + + - `tool_calls: Array[ToolCallDelta]` + + 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`. + + - `class CodeInterpreterToolCallDelta` + + Details of the Code Interpreter tool call the run step was involved in. + + - `index: Integer` + + 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: String` + + The ID of the tool call. + + - `code_interpreter: CodeInterpreter{ input, outputs}` + + The Code Interpreter tool call definition. + + - `input: String` + + The input to the Code Interpreter tool call. + + - `outputs: Array[CodeInterpreterLogs | 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. + + - `class CodeInterpreterLogs` + + Text output from the Code Interpreter tool call as part of a run step. + + - `index: Integer` + + The index of the output in the outputs array. + + - `type: :logs` + + Always `logs`. + + - `:logs` + + - `logs: String` + + The text output from the Code Interpreter tool call. + + - `class CodeInterpreterOutputImage` + + - `index: Integer` + + The index of the output in the outputs array. + + - `type: :image` + + Always `image`. + + - `:image` + + - `image: Image{ file_id}` + + - `file_id: String` + + The [file](https://platform.openai.com/docs/api-reference/files) ID of the image. + + - `class FileSearchToolCallDelta` + + - `file_search: untyped` + + For now, this is always going to be an empty object. + + - `index: Integer` + + 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: String` + + The ID of the tool call object. + + - `class FunctionToolCallDelta` + + - `index: Integer` + + 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: String` + + The ID of the tool call object. + + - `function: Function{ 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](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs) yet. + +### Tool Calls Step Details + +- `class ToolCallsStepDetails` + + Details of the tool call. + + - `tool_calls: Array[ToolCall]` + + 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`. + + - `class CodeInterpreterToolCall` + + Details of the Code Interpreter tool call the run step was involved in. + + - `id: String` + + The ID of the tool call. + + - `code_interpreter: CodeInterpreter{ input, outputs}` + + The Code Interpreter tool call definition. + + - `input: String` + + The input to the Code Interpreter tool call. + + - `outputs: Array[Logs{ logs, type} | Image{ 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. + + - `class Logs` + + 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` + + - `class Image` + + - `image: Image{ file_id}` + + - `file_id: String` + + The [file](https://platform.openai.com/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` + + - `class FileSearchToolCall` + + - `id: String` + + The ID of the tool call object. + + - `file_search: FileSearch{ ranking_options, results}` + + For now, this is always going to be an empty object. + + - `ranking_options: RankingOptions{ ranker, score_threshold}` + + The ranking options for the file search. + + - `ranker: :auto | :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: Float` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `results: Array[Result{ 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: Float` + + The score of the result. All values must be a floating point number between 0 and 1. + + - `content: Array[Content{ text, type}]` + + The content of the result that was found. The content is only included if requested via the include query parameter. + + - `text: String` + + The text content of the file. + + - `type: :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` + + - `class FunctionToolCall` + + - `id: String` + + The ID of the tool call object. + + - `function: Function{ 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](https://platform.openai.com/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` + +# Messages + +## List messages + +`beta.threads.messages.list(thread_id, **kwargs) -> CursorPage` + +**get** `/threads/{thread_id}/messages` + +Returns a list of messages for a given thread. + +### Parameters + +- `thread_id: String` + +- `after: String` + + A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + +- `before: String` + + A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + +- `limit: Integer` + + A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + +- `order: :asc | :desc` + + Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. + + - `:asc` + + - `:desc` + +- `run_id: String` + + Filter messages by the run ID that generated them. + +### Returns + +- `class Message` + + Represents a message within a [thread](https://platform.openai.com/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](https://platform.openai.com/docs/api-reference/assistants) that authored this message. + + - `attachments: Array[Attachment{ file_id, tools}]` + + A list of files attached to the message, and the tools they were added to. + + - `file_id: String` + + The ID of the file to attach to the message. + + - `tools: Array[CodeInterpreterTool | AssistantToolsFileSearchTypeOnly{ type}]` + + The tools to add this file to. + + - `class CodeInterpreterTool` + + - `type: :code_interpreter` + + The type of tool being defined: `code_interpreter` + + - `:code_interpreter` + + - `class AssistantToolsFileSearchTypeOnly` + + - `type: :file_search` + + The type of tool being defined: `file_search` + + - `:file_search` + + - `completed_at: Integer` + + The Unix timestamp (in seconds) for when the message was completed. + + - `content: Array[MessageContent]` + + The content of the message in array of text and/or images. + + - `class ImageFileContentBlock` + + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. + + - `image_file: ImageFile` + + - `file_id: String` + + The [File](https://platform.openai.com/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: :auto | :low | :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` + + - `class ImageURLContentBlock` + + 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: :auto | :low | :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` + + - `class TextContentBlock` + + The text content that is part of a message. + + - `text: Text` + + - `annotations: Array[Annotation]` + + - `class FileCitationAnnotation` + + A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. + + - `end_index: Integer` + + - `file_citation: FileCitation{ file_id}` + + - `file_id: String` + + The ID of the specific File the citation is from. + + - `start_index: Integer` + + - `text: String` + + The text in the message content that needs to be replaced. + + - `type: :file_citation` + + Always `file_citation`. + + - `:file_citation` + + - `class FilePathAnnotation` + + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + + - `end_index: Integer` + + - `file_path: FilePath{ file_id}` + + - `file_id: String` + + The ID of the file that was generated. + + - `start_index: Integer` + + - `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` + + - `class RefusalContentBlock` + + The refusal content generated by the assistant. + + - `refusal: String` + + - `type: :refusal` + + Always `refusal`. + + - `:refusal` + + - `created_at: Integer` + + The Unix timestamp (in seconds) for when the message was created. + + - `incomplete_at: Integer` + + The Unix timestamp (in seconds) for when the message was marked as incomplete. + + - `incomplete_details: IncompleteDetails{ reason}` + + On an incomplete message, details about why the message is incomplete. + + - `reason: :content_filter | :max_tokens | :run_cancelled | 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 | :assistant` + + The entity that produced the message. One of `user` or `assistant`. + + - `:user` + + - `:assistant` + + - `run_id: String` + + The ID of the [run](https://platform.openai.com/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 | :incomplete | :completed` + + The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. + + - `:in_progress` + + - `:incomplete` + + - `:completed` + + - `thread_id: String` + + The [thread](https://platform.openai.com/docs/api-reference/threads) ID that this message belongs to. + +### Example + +```ruby +require "openai" + +openai = OpenAI::Client.new(api_key: "My API Key") + +page = openai.beta.threads.messages.list("thread_id") + +puts(page) +``` + +#### Response + +```json +{ + "data": [ + { + "id": "id", + "assistant_id": "assistant_id", + "attachments": [ + { + "file_id": "file_id", + "tools": [ + { + "type": "code_interpreter" + } + ] + } + ], + "completed_at": 0, + "content": [ + { + "image_file": { + "file_id": "file_id", + "detail": "auto" + }, + "type": "image_file" + } + ], + "created_at": 0, + "incomplete_at": 0, + "incomplete_details": { + "reason": "content_filter" + }, + "metadata": { + "foo": "string" + }, + "object": "thread.message", + "role": "user", + "run_id": "run_id", + "status": "in_progress", + "thread_id": "thread_id" + } + ], "first_id": "msg_abc123", "has_more": false, "last_id": "msg_abc123", @@ -6269,40 +8575,1452 @@ puts(page) } ``` -## Create message +## Create message + +`beta.threads.messages.create(thread_id, **kwargs) -> Message` + +**post** `/threads/{thread_id}/messages` + +Create a message. + +### Parameters + +- `thread_id: String` + +- `content: String | Array[MessageContentPartParam]` + + The text contents of the message. + + - `String = String` + + The text contents of the message. + + - `ArrayOfContentParts = Array[MessageContentPartParam]` + + An array of content parts with a defined type, each can be of type `text` or images can be passed with `image_url` or `image_file`. Image types are only supported on [Vision-compatible models](https://platform.openai.com/docs/models). + + - `class ImageFileContentBlock` + + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. + + - `image_file: ImageFile` + + - `file_id: String` + + The [File](https://platform.openai.com/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: :auto | :low | :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` + + - `class ImageURLContentBlock` + + 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: :auto | :low | :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` + + - `class TextContentBlockParam` + + The text content that is part of a message. + + - `text: String` + + Text content to be sent to the model + + - `type: :text` + + Always `text`. + + - `:text` + +- `role: :user | :assistant` + + The role of the entity that is creating the message. Allowed values include: + + - `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages. + - `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation. + + - `:user` + + - `:assistant` + +- `attachments: Array[Attachment{ file_id, tools}]` + + A list of files attached to the message, and the tools they should be added to. + + - `file_id: String` + + The ID of the file to attach to the message. + + - `tools: Array[CodeInterpreterTool | FileSearch{ type}]` + + The tools to add this file to. + + - `class CodeInterpreterTool` + + - `type: :code_interpreter` + + The type of tool being defined: `code_interpreter` + + - `:code_interpreter` + + - `class FileSearch` + + - `type: :file_search` + + The type of tool being defined: `file_search` + + - `:file_search` + +- `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. + +### Returns + +- `class Message` + + Represents a message within a [thread](https://platform.openai.com/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](https://platform.openai.com/docs/api-reference/assistants) that authored this message. + + - `attachments: Array[Attachment{ file_id, tools}]` + + A list of files attached to the message, and the tools they were added to. + + - `file_id: String` + + The ID of the file to attach to the message. + + - `tools: Array[CodeInterpreterTool | AssistantToolsFileSearchTypeOnly{ type}]` + + The tools to add this file to. + + - `class CodeInterpreterTool` + + - `type: :code_interpreter` + + The type of tool being defined: `code_interpreter` + + - `:code_interpreter` + + - `class AssistantToolsFileSearchTypeOnly` + + - `type: :file_search` + + The type of tool being defined: `file_search` + + - `:file_search` + + - `completed_at: Integer` + + The Unix timestamp (in seconds) for when the message was completed. + + - `content: Array[MessageContent]` + + The content of the message in array of text and/or images. + + - `class ImageFileContentBlock` + + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. + + - `image_file: ImageFile` + + - `file_id: String` + + The [File](https://platform.openai.com/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: :auto | :low | :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` + + - `class ImageURLContentBlock` + + 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: :auto | :low | :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` + + - `class TextContentBlock` + + The text content that is part of a message. + + - `text: Text` + + - `annotations: Array[Annotation]` + + - `class FileCitationAnnotation` + + A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. + + - `end_index: Integer` + + - `file_citation: FileCitation{ file_id}` + + - `file_id: String` + + The ID of the specific File the citation is from. + + - `start_index: Integer` + + - `text: String` + + The text in the message content that needs to be replaced. + + - `type: :file_citation` + + Always `file_citation`. + + - `:file_citation` + + - `class FilePathAnnotation` + + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + + - `end_index: Integer` + + - `file_path: FilePath{ file_id}` + + - `file_id: String` + + The ID of the file that was generated. + + - `start_index: Integer` + + - `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` + + - `class RefusalContentBlock` + + The refusal content generated by the assistant. + + - `refusal: String` + + - `type: :refusal` + + Always `refusal`. + + - `:refusal` + + - `created_at: Integer` + + The Unix timestamp (in seconds) for when the message was created. + + - `incomplete_at: Integer` + + The Unix timestamp (in seconds) for when the message was marked as incomplete. + + - `incomplete_details: IncompleteDetails{ reason}` + + On an incomplete message, details about why the message is incomplete. + + - `reason: :content_filter | :max_tokens | :run_cancelled | 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 | :assistant` + + The entity that produced the message. One of `user` or `assistant`. + + - `:user` + + - `:assistant` + + - `run_id: String` + + The ID of the [run](https://platform.openai.com/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 | :incomplete | :completed` + + The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. + + - `:in_progress` + + - `:incomplete` + + - `:completed` + + - `thread_id: String` + + The [thread](https://platform.openai.com/docs/api-reference/threads) ID that this message belongs to. + +### Example + +```ruby +require "openai" + +openai = OpenAI::Client.new(api_key: "My API Key") + +message = openai.beta.threads.messages.create("thread_id", content: "string", role: :user) + +puts(message) +``` + +#### Response + +```json +{ + "id": "id", + "assistant_id": "assistant_id", + "attachments": [ + { + "file_id": "file_id", + "tools": [ + { + "type": "code_interpreter" + } + ] + } + ], + "completed_at": 0, + "content": [ + { + "image_file": { + "file_id": "file_id", + "detail": "auto" + }, + "type": "image_file" + } + ], + "created_at": 0, + "incomplete_at": 0, + "incomplete_details": { + "reason": "content_filter" + }, + "metadata": { + "foo": "string" + }, + "object": "thread.message", + "role": "user", + "run_id": "run_id", + "status": "in_progress", + "thread_id": "thread_id" +} +``` + +## Modify message + +`beta.threads.messages.update(message_id, **kwargs) -> Message` + +**post** `/threads/{thread_id}/messages/{message_id}` + +Modifies a message. + +### Parameters + +- `thread_id: String` + +- `message_id: String` + +- `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. + +### Returns + +- `class Message` + + Represents a message within a [thread](https://platform.openai.com/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](https://platform.openai.com/docs/api-reference/assistants) that authored this message. + + - `attachments: Array[Attachment{ file_id, tools}]` + + A list of files attached to the message, and the tools they were added to. + + - `file_id: String` + + The ID of the file to attach to the message. + + - `tools: Array[CodeInterpreterTool | AssistantToolsFileSearchTypeOnly{ type}]` + + The tools to add this file to. + + - `class CodeInterpreterTool` + + - `type: :code_interpreter` + + The type of tool being defined: `code_interpreter` + + - `:code_interpreter` + + - `class AssistantToolsFileSearchTypeOnly` + + - `type: :file_search` + + The type of tool being defined: `file_search` + + - `:file_search` + + - `completed_at: Integer` + + The Unix timestamp (in seconds) for when the message was completed. + + - `content: Array[MessageContent]` + + The content of the message in array of text and/or images. + + - `class ImageFileContentBlock` + + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. + + - `image_file: ImageFile` + + - `file_id: String` + + The [File](https://platform.openai.com/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: :auto | :low | :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` + + - `class ImageURLContentBlock` + + 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: :auto | :low | :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` + + - `class TextContentBlock` + + The text content that is part of a message. + + - `text: Text` + + - `annotations: Array[Annotation]` + + - `class FileCitationAnnotation` + + A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. + + - `end_index: Integer` + + - `file_citation: FileCitation{ file_id}` + + - `file_id: String` + + The ID of the specific File the citation is from. + + - `start_index: Integer` + + - `text: String` + + The text in the message content that needs to be replaced. + + - `type: :file_citation` + + Always `file_citation`. + + - `:file_citation` + + - `class FilePathAnnotation` + + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + + - `end_index: Integer` + + - `file_path: FilePath{ file_id}` + + - `file_id: String` + + The ID of the file that was generated. + + - `start_index: Integer` + + - `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` + + - `class RefusalContentBlock` + + The refusal content generated by the assistant. + + - `refusal: String` + + - `type: :refusal` + + Always `refusal`. + + - `:refusal` + + - `created_at: Integer` + + The Unix timestamp (in seconds) for when the message was created. + + - `incomplete_at: Integer` + + The Unix timestamp (in seconds) for when the message was marked as incomplete. + + - `incomplete_details: IncompleteDetails{ reason}` + + On an incomplete message, details about why the message is incomplete. + + - `reason: :content_filter | :max_tokens | :run_cancelled | 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 | :assistant` + + The entity that produced the message. One of `user` or `assistant`. + + - `:user` + + - `:assistant` + + - `run_id: String` + + The ID of the [run](https://platform.openai.com/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 | :incomplete | :completed` + + The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. + + - `:in_progress` + + - `:incomplete` + + - `:completed` + + - `thread_id: String` + + The [thread](https://platform.openai.com/docs/api-reference/threads) ID that this message belongs to. + +### Example + +```ruby +require "openai" + +openai = OpenAI::Client.new(api_key: "My API Key") + +message = openai.beta.threads.messages.update("message_id", thread_id: "thread_id") + +puts(message) +``` + +#### Response + +```json +{ + "id": "id", + "assistant_id": "assistant_id", + "attachments": [ + { + "file_id": "file_id", + "tools": [ + { + "type": "code_interpreter" + } + ] + } + ], + "completed_at": 0, + "content": [ + { + "image_file": { + "file_id": "file_id", + "detail": "auto" + }, + "type": "image_file" + } + ], + "created_at": 0, + "incomplete_at": 0, + "incomplete_details": { + "reason": "content_filter" + }, + "metadata": { + "foo": "string" + }, + "object": "thread.message", + "role": "user", + "run_id": "run_id", + "status": "in_progress", + "thread_id": "thread_id" +} +``` + +## Retrieve message + +`beta.threads.messages.retrieve(message_id, **kwargs) -> Message` + +**get** `/threads/{thread_id}/messages/{message_id}` + +Retrieve a message. + +### Parameters + +- `thread_id: String` + +- `message_id: String` + +### Returns + +- `class Message` + + Represents a message within a [thread](https://platform.openai.com/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](https://platform.openai.com/docs/api-reference/assistants) that authored this message. + + - `attachments: Array[Attachment{ file_id, tools}]` + + A list of files attached to the message, and the tools they were added to. + + - `file_id: String` + + The ID of the file to attach to the message. + + - `tools: Array[CodeInterpreterTool | AssistantToolsFileSearchTypeOnly{ type}]` + + The tools to add this file to. + + - `class CodeInterpreterTool` + + - `type: :code_interpreter` + + The type of tool being defined: `code_interpreter` + + - `:code_interpreter` + + - `class AssistantToolsFileSearchTypeOnly` + + - `type: :file_search` + + The type of tool being defined: `file_search` + + - `:file_search` + + - `completed_at: Integer` + + The Unix timestamp (in seconds) for when the message was completed. + + - `content: Array[MessageContent]` + + The content of the message in array of text and/or images. + + - `class ImageFileContentBlock` + + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. + + - `image_file: ImageFile` + + - `file_id: String` + + The [File](https://platform.openai.com/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: :auto | :low | :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` + + - `class ImageURLContentBlock` + + 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: :auto | :low | :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` + + - `class TextContentBlock` + + The text content that is part of a message. + + - `text: Text` + + - `annotations: Array[Annotation]` + + - `class FileCitationAnnotation` + + A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. + + - `end_index: Integer` + + - `file_citation: FileCitation{ file_id}` + + - `file_id: String` + + The ID of the specific File the citation is from. + + - `start_index: Integer` + + - `text: String` + + The text in the message content that needs to be replaced. + + - `type: :file_citation` + + Always `file_citation`. + + - `:file_citation` + + - `class FilePathAnnotation` + + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + + - `end_index: Integer` + + - `file_path: FilePath{ file_id}` + + - `file_id: String` + + The ID of the file that was generated. + + - `start_index: Integer` + + - `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` + + - `class RefusalContentBlock` + + The refusal content generated by the assistant. + + - `refusal: String` + + - `type: :refusal` + + Always `refusal`. + + - `:refusal` + + - `created_at: Integer` + + The Unix timestamp (in seconds) for when the message was created. + + - `incomplete_at: Integer` + + The Unix timestamp (in seconds) for when the message was marked as incomplete. + + - `incomplete_details: IncompleteDetails{ reason}` + + On an incomplete message, details about why the message is incomplete. + + - `reason: :content_filter | :max_tokens | :run_cancelled | 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 | :assistant` + + The entity that produced the message. One of `user` or `assistant`. + + - `:user` + + - `:assistant` + + - `run_id: String` + + The ID of the [run](https://platform.openai.com/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 | :incomplete | :completed` + + The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. + + - `:in_progress` + + - `:incomplete` + + - `:completed` + + - `thread_id: String` + + The [thread](https://platform.openai.com/docs/api-reference/threads) ID that this message belongs to. + +### Example + +```ruby +require "openai" + +openai = OpenAI::Client.new(api_key: "My API Key") + +message = openai.beta.threads.messages.retrieve("message_id", thread_id: "thread_id") + +puts(message) +``` + +#### Response + +```json +{ + "id": "id", + "assistant_id": "assistant_id", + "attachments": [ + { + "file_id": "file_id", + "tools": [ + { + "type": "code_interpreter" + } + ] + } + ], + "completed_at": 0, + "content": [ + { + "image_file": { + "file_id": "file_id", + "detail": "auto" + }, + "type": "image_file" + } + ], + "created_at": 0, + "incomplete_at": 0, + "incomplete_details": { + "reason": "content_filter" + }, + "metadata": { + "foo": "string" + }, + "object": "thread.message", + "role": "user", + "run_id": "run_id", + "status": "in_progress", + "thread_id": "thread_id" +} +``` + +## Delete message + +`beta.threads.messages.delete(message_id, **kwargs) -> MessageDeleted` + +**delete** `/threads/{thread_id}/messages/{message_id}` + +Deletes a message. + +### Parameters + +- `thread_id: String` + +- `message_id: String` + +### Returns + +- `class MessageDeleted` + + - `id: String` + + - `deleted: bool` + + - `object: :"thread.message.deleted"` + + - `:"thread.message.deleted"` + +### Example + +```ruby +require "openai" + +openai = OpenAI::Client.new(api_key: "My API Key") + +message_deleted = openai.beta.threads.messages.delete("message_id", thread_id: "thread_id") + +puts(message_deleted) +``` + +#### Response + +```json +{ + "id": "id", + "deleted": true, + "object": "thread.message.deleted" +} +``` + +## Domain Types + +### Annotation + +- `Annotation = FileCitationAnnotation | FilePathAnnotation` + + 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. + + - `class FileCitationAnnotation` + + A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. + + - `end_index: Integer` + + - `file_citation: FileCitation{ file_id}` + + - `file_id: String` + + The ID of the specific File the citation is from. + + - `start_index: Integer` + + - `text: String` + + The text in the message content that needs to be replaced. + + - `type: :file_citation` + + Always `file_citation`. + + - `:file_citation` + + - `class FilePathAnnotation` + + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + + - `end_index: Integer` + + - `file_path: FilePath{ file_id}` + + - `file_id: String` + + The ID of the file that was generated. + + - `start_index: Integer` + + - `text: String` + + The text in the message content that needs to be replaced. + + - `type: :file_path` + + Always `file_path`. + + - `:file_path` + +### Annotation Delta + +- `AnnotationDelta = FileCitationDeltaAnnotation | FilePathDeltaAnnotation` + + 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. + + - `class FileCitationDeltaAnnotation` + + A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. + + - `index: Integer` + + The index of the annotation in the text content part. + + - `type: :file_citation` + + Always `file_citation`. + + - `:file_citation` + + - `end_index: Integer` + + - `file_citation: FileCitation{ file_id, quote}` + + - `file_id: String` + + The ID of the specific File the citation is from. + + - `quote: String` + + The specific quote in the file. + + - `start_index: Integer` + + - `text: String` + + The text in the message content that needs to be replaced. + + - `class FilePathDeltaAnnotation` + + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + + - `index: Integer` + + The index of the annotation in the text content part. + + - `type: :file_path` + + Always `file_path`. + + - `:file_path` + + - `end_index: Integer` + + - `file_path: FilePath{ file_id}` + + - `file_id: String` + + The ID of the file that was generated. + + - `start_index: Integer` + + - `text: String` + + The text in the message content that needs to be replaced. + +### File Citation Annotation + +- `class FileCitationAnnotation` + + A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. + + - `end_index: Integer` + + - `file_citation: FileCitation{ file_id}` + + - `file_id: String` + + The ID of the specific File the citation is from. + + - `start_index: Integer` + + - `text: String` + + The text in the message content that needs to be replaced. + + - `type: :file_citation` + + Always `file_citation`. + + - `:file_citation` + +### File Citation Delta Annotation + +- `class FileCitationDeltaAnnotation` + + A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. + + - `index: Integer` + + The index of the annotation in the text content part. + + - `type: :file_citation` + + Always `file_citation`. + + - `:file_citation` + + - `end_index: Integer` + + - `file_citation: FileCitation{ file_id, quote}` + + - `file_id: String` + + The ID of the specific File the citation is from. + + - `quote: String` + + The specific quote in the file. + + - `start_index: Integer` + + - `text: String` + + The text in the message content that needs to be replaced. + +### File Path Annotation + +- `class FilePathAnnotation` + + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + + - `end_index: Integer` + + - `file_path: FilePath{ file_id}` + + - `file_id: String` + + The ID of the file that was generated. + + - `start_index: Integer` + + - `text: String` + + The text in the message content that needs to be replaced. + + - `type: :file_path` + + Always `file_path`. + + - `:file_path` + +### File Path Delta Annotation + +- `class FilePathDeltaAnnotation` + + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + + - `index: Integer` + + The index of the annotation in the text content part. + + - `type: :file_path` + + Always `file_path`. + + - `:file_path` + + - `end_index: Integer` + + - `file_path: FilePath{ file_id}` + + - `file_id: String` + + The ID of the file that was generated. + + - `start_index: Integer` + + - `text: String` + + The text in the message content that needs to be replaced. + +### Image File + +- `class ImageFile` + + - `file_id: String` + + The [File](https://platform.openai.com/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: :auto | :low | :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` + +### Image File Content Block + +- `class ImageFileContentBlock` + + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. + + - `image_file: ImageFile` + + - `file_id: String` -`beta.threads.messages.create(thread_id, **kwargs) -> Message` + The [File](https://platform.openai.com/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. -**post** `/threads/{thread_id}/messages` + - `detail: :auto | :low | :high` -Create 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`. -### Parameters + - `:auto` -- `thread_id: String` + - `:low` -- `content: String | Array[MessageContentPartParam]` + - `:high` - The text contents of the message. + - `type: :image_file` - - `String = String` + Always `image_file`. - The text contents of the message. + - `:image_file` - - `ArrayOfContentParts = Array[MessageContentPartParam]` +### Image File Delta - An array of content parts with a defined type, each can be of type `text` or images can be passed with `image_url` or `image_file`. Image types are only supported on [Vision-compatible models](https://platform.openai.com/docs/models). +- `class ImageFileDelta` - - `class ImageFileContentBlock` + - `detail: :auto | :low | :high` - References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a 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`. - - `image_file: ImageFile` + - `:auto` + + - `:low` + + - `:high` - `file_id: String` The [File](https://platform.openai.com/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. +### Image File Delta Block + +- `class ImageFileDeltaBlock` + + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. + + - `index: Integer` + + The index of the content part in the message. + + - `type: :image_file` + + Always `image_file`. + + - `:image_file` + + - `image_file: ImageFileDelta` + - `detail: :auto | :low | :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`. @@ -6313,13 +10031,31 @@ Create message - `:high` - - `type: :image_file` + - `file_id: String` - Always `image_file`. + The [File](https://platform.openai.com/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. - - `:image_file` +### Image URL - - `class ImageURLContentBlock` +- `class ImageURL` + + - `url: String` + + The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. + + - `detail: :auto | :low | :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` + +### Image URL Content Block + +- `class ImageURLContentBlock` References an image URL in the content of a message. @@ -6345,69 +10081,57 @@ Create message - `:image_url` - - `class TextContentBlockParam` - - The text content that is part of a message. - - - `text: String` - - Text content to be sent to the model - - - `type: :text` +### Image URL Delta - Always `text`. +- `class ImageURLDelta` - - `:text` + - `detail: :auto | :low | :high` -- `role: :user | :assistant` + Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. - The role of the entity that is creating the message. Allowed values include: + - `:auto` - - `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages. - - `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation. + - `:low` - - `:user` + - `:high` - - `:assistant` + - `url: String` -- `attachments: Array[Attachment{ file_id, tools}]` + The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. - A list of files attached to the message, and the tools they should be added to. +### Image URL Delta Block - - `file_id: String` +- `class ImageURLDeltaBlock` - The ID of the file to attach to the message. + References an image URL in the content of a message. - - `tools: Array[CodeInterpreterTool | FileSearch{ type}]` + - `index: Integer` - The tools to add this file to. + The index of the content part in the message. - - `class CodeInterpreterTool` + - `type: :image_url` - - `type: :code_interpreter` + Always `image_url`. - The type of tool being defined: `code_interpreter` + - `:image_url` - - `:code_interpreter` + - `image_url: ImageURLDelta` - - `class FileSearch` + - `detail: :auto | :low | :high` - - `type: :file_search` + Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. - The type of tool being defined: `file_search` + - `:auto` - - `:file_search` + - `:low` -- `metadata: Metadata` + - `:high` - 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. + - `url: String` - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. + The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. -### Returns +### Message - `class Message` @@ -6453,197 +10177,139 @@ Create message The Unix timestamp (in seconds) for when the message was completed. - - `content: Array[untyped]` + - `content: Array[MessageContent]` The content of the message in array of text and/or images. - - `created_at: Integer` - - The Unix timestamp (in seconds) for when the message was created. - - - `incomplete_at: Integer` - - The Unix timestamp (in seconds) for when the message was marked as incomplete. - - - `incomplete_details: IncompleteDetails{ reason}` - - On an incomplete message, details about why the message is incomplete. - - - `reason: :content_filter | :max_tokens | :run_cancelled | 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`. + - `class ImageFileContentBlock` - - `:"thread.message"` + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. - - `role: :user | :assistant` + - `image_file: ImageFile` - The entity that produced the message. One of `user` or `assistant`. + - `file_id: String` - - `:user` + The [File](https://platform.openai.com/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. - - `:assistant` + - `detail: :auto | :low | :high` - - `run_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 [run](https://platform.openai.com/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. + - `:auto` - - `status: :in_progress | :incomplete | :completed` + - `:low` - The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. + - `:high` - - `:in_progress` + - `type: :image_file` - - `:incomplete` + Always `image_file`. - - `:completed` + - `:image_file` - - `thread_id: String` + - `class ImageURLContentBlock` - The [thread](https://platform.openai.com/docs/api-reference/threads) ID that this message belongs to. + References an image URL in the content of a message. -### Example + - `image_url: ImageURL` -```ruby -require "openai" + - `url: String` -openai = OpenAI::Client.new(api_key: "My API Key") + The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. -message = openai.beta.threads.messages.create("thread_id", content: "string", role: :user) + - `detail: :auto | :low | :high` -puts(message) -``` + Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` -#### Response + - `:auto` -```json -{ - "id": "id", - "assistant_id": "assistant_id", - "attachments": [ - { - "file_id": "file_id", - "tools": [ - { - "type": "code_interpreter" - } - ] - } - ], - "completed_at": 0, - "content": [ - {} - ], - "created_at": 0, - "incomplete_at": 0, - "incomplete_details": { - "reason": "content_filter" - }, - "metadata": { - "foo": "string" - }, - "object": "thread.message", - "role": "user", - "run_id": "run_id", - "status": "in_progress", - "thread_id": "thread_id" -} -``` + - `:low` -## Modify message + - `:high` -`beta.threads.messages.update(message_id, **kwargs) -> Message` + - `type: :image_url` -**post** `/threads/{thread_id}/messages/{message_id}` + The type of the content part. -Modify message + - `:image_url` -### Parameters + - `class TextContentBlock` -- `thread_id: String` + The text content that is part of a message. -- `message_id: String` + - `text: Text` -- `metadata: Metadata` + - `annotations: Array[Annotation]` - 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. + - `class FileCitationAnnotation` - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. + 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. -### Returns + - `end_index: Integer` -- `class Message` + - `file_citation: FileCitation{ file_id}` - Represents a message within a [thread](https://platform.openai.com/docs/api-reference/threads). + - `file_id: String` - - `id: String` + The ID of the specific File the citation is from. - The identifier, which can be referenced in API endpoints. + - `start_index: Integer` - - `assistant_id: String` + - `text: String` - If applicable, the ID of the [assistant](https://platform.openai.com/docs/api-reference/assistants) that authored this message. + The text in the message content that needs to be replaced. - - `attachments: Array[Attachment{ file_id, tools}]` + - `type: :file_citation` - A list of files attached to the message, and the tools they were added to. + Always `file_citation`. + + - `:file_citation` + + - `class FilePathAnnotation` + + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + + - `end_index: Integer` + + - `file_path: FilePath{ file_id}` - `file_id: String` - The ID of the file to attach to the message. + The ID of the file that was generated. - - `tools: Array[CodeInterpreterTool | AssistantToolsFileSearchTypeOnly{ type}]` + - `start_index: Integer` - The tools to add this file to. + - `text: String` - - `class CodeInterpreterTool` + The text in the message content that needs to be replaced. - - `type: :code_interpreter` + - `type: :file_path` - The type of tool being defined: `code_interpreter` + Always `file_path`. - - `:code_interpreter` + - `:file_path` - - `class AssistantToolsFileSearchTypeOnly` + - `value: String` - - `type: :file_search` + The data that makes up the text. - The type of tool being defined: `file_search` + - `type: :text` - - `:file_search` + Always `text`. - - `completed_at: Integer` + - `:text` - The Unix timestamp (in seconds) for when the message was completed. + - `class RefusalContentBlock` + + The refusal content generated by the assistant. - - `content: Array[untyped]` + - `refusal: String` - The content of the message in array of text and/or images. + - `type: :refusal` + + Always `refusal`. + + - `:refusal` - `created_at: Integer` @@ -6712,320 +10378,197 @@ Modify message The [thread](https://platform.openai.com/docs/api-reference/threads) ID that this message belongs to. -### Example - -```ruby -require "openai" - -openai = OpenAI::Client.new(api_key: "My API Key") - -message = openai.beta.threads.messages.update("message_id", thread_id: "thread_id") - -puts(message) -``` - -#### Response - -```json -{ - "id": "id", - "assistant_id": "assistant_id", - "attachments": [ - { - "file_id": "file_id", - "tools": [ - { - "type": "code_interpreter" - } - ] - } - ], - "completed_at": 0, - "content": [ - {} - ], - "created_at": 0, - "incomplete_at": 0, - "incomplete_details": { - "reason": "content_filter" - }, - "metadata": { - "foo": "string" - }, - "object": "thread.message", - "role": "user", - "run_id": "run_id", - "status": "in_progress", - "thread_id": "thread_id" -} -``` - -## Retrieve message - -`beta.threads.messages.retrieve(message_id, **kwargs) -> Message` - -**get** `/threads/{thread_id}/messages/{message_id}` - -Retrieve message - -### Parameters - -- `thread_id: String` - -- `message_id: String` - -### Returns - -- `class Message` - - Represents a message within a [thread](https://platform.openai.com/docs/api-reference/threads). - - - `id: String` +### Message Content - The identifier, which can be referenced in API endpoints. +- `MessageContent = ImageFileContentBlock | ImageURLContentBlock | TextContentBlock | RefusalContentBlock` - - `assistant_id: String` + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. - If applicable, the ID of the [assistant](https://platform.openai.com/docs/api-reference/assistants) that authored this message. + - `class ImageFileContentBlock` - - `attachments: Array[Attachment{ file_id, tools}]` + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. - A list of files attached to the message, and the tools they were added to. + - `image_file: ImageFile` - `file_id: String` - The ID of the file to attach to the message. - - - `tools: Array[CodeInterpreterTool | AssistantToolsFileSearchTypeOnly{ type}]` - - The tools to add this file to. - - - `class CodeInterpreterTool` - - - `type: :code_interpreter` - - The type of tool being defined: `code_interpreter` - - - `:code_interpreter` - - - `class AssistantToolsFileSearchTypeOnly` + The [File](https://platform.openai.com/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. - - `type: :file_search` + - `detail: :auto | :low | :high` - The type of tool being defined: `file_search` + 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`. - - `:file_search` + - `:auto` - - `completed_at: Integer` + - `:low` - The Unix timestamp (in seconds) for when the message was completed. + - `:high` - - `content: Array[untyped]` + - `type: :image_file` - The content of the message in array of text and/or images. + Always `image_file`. - - `created_at: Integer` + - `:image_file` - The Unix timestamp (in seconds) for when the message was created. + - `class ImageURLContentBlock` - - `incomplete_at: Integer` + References an image URL in the content of a message. - The Unix timestamp (in seconds) for when the message was marked as incomplete. + - `image_url: ImageURL` - - `incomplete_details: IncompleteDetails{ reason}` + - `url: String` - On an incomplete message, details about why the message is incomplete. + The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. - - `reason: :content_filter | :max_tokens | :run_cancelled | 2 more` + - `detail: :auto | :low | :high` - The reason the message is incomplete. + Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` - - `:content_filter` + - `:auto` - - `:max_tokens` + - `:low` - - `:run_cancelled` + - `:high` - - `:run_expired` + - `type: :image_url` - - `:run_failed` + The type of the content part. - - `metadata: Metadata` + - `:image_url` - 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. + - `class TextContentBlock` - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. + The text content that is part of a message. - - `object: :"thread.message"` + - `text: Text` - The object type, which is always `thread.message`. + - `annotations: Array[Annotation]` - - `:"thread.message"` + - `class FileCitationAnnotation` - - `role: :user | :assistant` + 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 entity that produced the message. One of `user` or `assistant`. + - `end_index: Integer` - - `:user` + - `file_citation: FileCitation{ file_id}` - - `:assistant` + - `file_id: String` - - `run_id: String` + The ID of the specific File the citation is from. - The ID of the [run](https://platform.openai.com/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. + - `start_index: Integer` - - `status: :in_progress | :incomplete | :completed` + - `text: String` - The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. + The text in the message content that needs to be replaced. - - `:in_progress` + - `type: :file_citation` - - `:incomplete` + Always `file_citation`. - - `:completed` + - `:file_citation` - - `thread_id: String` + - `class FilePathAnnotation` - The [thread](https://platform.openai.com/docs/api-reference/threads) ID that this message belongs to. + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. -### Example + - `end_index: Integer` -```ruby -require "openai" + - `file_path: FilePath{ file_id}` -openai = OpenAI::Client.new(api_key: "My API Key") + - `file_id: String` -message = openai.beta.threads.messages.retrieve("message_id", thread_id: "thread_id") + The ID of the file that was generated. -puts(message) -``` + - `start_index: Integer` -#### Response + - `text: String` -```json -{ - "id": "id", - "assistant_id": "assistant_id", - "attachments": [ - { - "file_id": "file_id", - "tools": [ - { - "type": "code_interpreter" - } - ] - } - ], - "completed_at": 0, - "content": [ - {} - ], - "created_at": 0, - "incomplete_at": 0, - "incomplete_details": { - "reason": "content_filter" - }, - "metadata": { - "foo": "string" - }, - "object": "thread.message", - "role": "user", - "run_id": "run_id", - "status": "in_progress", - "thread_id": "thread_id" -} -``` + The text in the message content that needs to be replaced. -## Delete message + - `type: :file_path` -`beta.threads.messages.delete(message_id, **kwargs) -> MessageDeleted` + Always `file_path`. -**delete** `/threads/{thread_id}/messages/{message_id}` + - `:file_path` -Delete message + - `value: String` -### Parameters + The data that makes up the text. -- `thread_id: String` + - `type: :text` -- `message_id: String` + Always `text`. -### Returns + - `:text` -- `class MessageDeleted` + - `class RefusalContentBlock` - - `id: String` + The refusal content generated by the assistant. - - `deleted: bool` + - `refusal: String` - - `object: :"thread.message.deleted"` + - `type: :refusal` - - `:"thread.message.deleted"` + Always `refusal`. -### Example + - `:refusal` -```ruby -require "openai" +### Message Content Delta -openai = OpenAI::Client.new(api_key: "My API Key") +- `MessageContentDelta = ImageFileDeltaBlock | TextDeltaBlock | RefusalDeltaBlock | ImageURLDeltaBlock` -message_deleted = openai.beta.threads.messages.delete("message_id", thread_id: "thread_id") + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. -puts(message_deleted) -``` + - `class ImageFileDeltaBlock` -#### Response + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. -```json -{ - "id": "id", - "deleted": true, - "object": "thread.message.deleted" -} -``` + - `index: Integer` -## Domain Types + The index of the content part in the message. -### Annotation + - `type: :image_file` -- `Annotation = untyped` + Always `image_file`. -### Annotation Delta + - `:image_file` -- `AnnotationDelta = untyped` + - `image_file: ImageFileDelta` -### File Citation Annotation + - `detail: :auto | :low | :high` -- `class FileCitationAnnotation` + 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`. - 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. + - `:auto` - - `end_index: Integer` + - `:low` - - `file_citation: FileCitation{ file_id}` + - `:high` - `file_id: String` - The ID of the specific File the citation is from. + The [File](https://platform.openai.com/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. - - `start_index: Integer` + - `class TextDeltaBlock` - - `text: String` + The text content that is part of a message. - The text in the message content that needs to be replaced. + - `index: Integer` - - `type: :file_citation` + The index of the content part in the message. - Always `file_citation`. + - `type: :text` - - `:file_citation` + Always `text`. -### File Citation Delta Annotation + - `:text` -- `class FileCitationDeltaAnnotation` + - `text: TextDelta` + + - `annotations: Array[AnnotationDelta]` + + - `class FileCitationDeltaAnnotation` A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. @@ -7057,12 +10600,20 @@ puts(message_deleted) The text in the message content that needs to be replaced. -### File Path Annotation - -- `class FilePathAnnotation` + - `class FilePathDeltaAnnotation` A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + - `index: Integer` + + The index of the annotation in the text content part. + + - `type: :file_path` + + Always `file_path`. + + - `:file_path` + - `end_index: Integer` - `file_path: FilePath{ file_id}` @@ -7077,53 +10628,45 @@ puts(message_deleted) The text in the message content that needs to be replaced. - - `type: :file_path` - - Always `file_path`. - - - `:file_path` + - `value: String` -### File Path Delta Annotation + The data that makes up the text. -- `class FilePathDeltaAnnotation` + - `class RefusalDeltaBlock` - A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + The refusal content that is part of a message. - `index: Integer` - The index of the annotation in the text content part. - - - `type: :file_path` - - Always `file_path`. + The index of the refusal part in the message. - - `:file_path` + - `type: :refusal` - - `end_index: Integer` + Always `refusal`. - - `file_path: FilePath{ file_id}` + - `:refusal` - - `file_id: String` + - `refusal: String` - The ID of the file that was generated. + - `class ImageURLDeltaBlock` - - `start_index: Integer` + References an image URL in the content of a message. - - `text: String` + - `index: Integer` - The text in the message content that needs to be replaced. + The index of the content part in the message. -### Image File + - `type: :image_url` -- `class ImageFile` + Always `image_url`. - - `file_id: String` + - `:image_url` - The [File](https://platform.openai.com/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. + - `image_url: ImageURLDelta` - `detail: :auto | :low | :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`. + Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. - `:auto` @@ -7131,9 +10674,17 @@ puts(message_deleted) - `:high` -### Image File Content Block + - `url: String` -- `class ImageFileContentBlock` + The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. + +### Message Content Part Param + +- `MessageContentPartParam = ImageFileContentBlock | ImageURLContentBlock | TextContentBlockParam` + + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. + + - `class ImageFileContentBlock` References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. @@ -7159,13 +10710,19 @@ puts(message_deleted) - `:image_file` -### Image File Delta + - `class ImageURLContentBlock` -- `class ImageFileDelta` + 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: :auto | :low | :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`. + 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` @@ -7173,53 +10730,67 @@ puts(message_deleted) - `:high` - - `file_id: String` + - `type: :image_url` - The [File](https://platform.openai.com/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 the content part. -### Image File Delta Block + - `:image_url` -- `class ImageFileDeltaBlock` + - `class TextContentBlockParam` - References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. + The text content that is part of a message. - - `index: Integer` + - `text: String` - The index of the content part in the message. + Text content to be sent to the model - - `type: :image_file` + - `type: :text` - Always `image_file`. + Always `text`. - - `:image_file` + - `:text` - - `image_file: ImageFileDelta` +### Message Deleted - - `detail: :auto | :low | :high` +- `class MessageDeleted` - 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`. + - `id: String` - - `:auto` + - `deleted: bool` - - `:low` + - `object: :"thread.message.deleted"` - - `:high` + - `:"thread.message.deleted"` - - `file_id: String` +### Message Delta - The [File](https://platform.openai.com/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. +- `class MessageDelta` -### Image URL + The delta containing the fields that have changed on the Message. -- `class ImageURL` + - `content: Array[MessageContentDelta]` - - `url: String` + The content of the message in array of text and/or images. - The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. + - `class ImageFileDeltaBlock` + + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. + + - `index: Integer` + + The index of the content part in the message. + + - `type: :image_file` + + Always `image_file`. + + - `:image_file` + + - `image_file: ImageFileDelta` - `detail: :auto | :low | :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` + 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` @@ -7227,328 +10798,321 @@ puts(message_deleted) - `:high` -### Image URL Content Block + - `file_id: String` -- `class ImageURLContentBlock` + The [File](https://platform.openai.com/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. - References an image URL in the content of a message. + - `class TextDeltaBlock` - - `image_url: ImageURL` + The text content that is part of a message. - - `url: String` + - `index: Integer` - The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. + The index of the content part in the message. - - `detail: :auto | :low | :high` + - `type: :text` - Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` + Always `text`. - - `:auto` + - `:text` - - `:low` + - `text: TextDelta` - - `:high` + - `annotations: Array[AnnotationDelta]` - - `type: :image_url` + - `class FileCitationDeltaAnnotation` - The type of the content part. + 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. - - `:image_url` + - `index: Integer` -### Image URL Delta + The index of the annotation in the text content part. -- `class ImageURLDelta` + - `type: :file_citation` - - `detail: :auto | :low | :high` + Always `file_citation`. - Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. + - `:file_citation` - - `:auto` + - `end_index: Integer` - - `:low` + - `file_citation: FileCitation{ file_id, quote}` - - `:high` + - `file_id: String` - - `url: String` + The ID of the specific File the citation is from. - The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. + - `quote: String` -### Image URL Delta Block + The specific quote in the file. -- `class ImageURLDeltaBlock` + - `start_index: Integer` - References an image URL in the content of a message. + - `text: String` - - `index: Integer` + The text in the message content that needs to be replaced. - The index of the content part in the message. + - `class FilePathDeltaAnnotation` - - `type: :image_url` + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - Always `image_url`. + - `index: Integer` - - `:image_url` + The index of the annotation in the text content part. - - `image_url: ImageURLDelta` + - `type: :file_path` - - `detail: :auto | :low | :high` + Always `file_path`. - Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. + - `:file_path` - - `:auto` + - `end_index: Integer` - - `:low` + - `file_path: FilePath{ file_id}` - - `:high` + - `file_id: String` - - `url: String` + The ID of the file that was generated. - The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. + - `start_index: Integer` -### Message + - `text: String` -- `class Message` + The text in the message content that needs to be replaced. - Represents a message within a [thread](https://platform.openai.com/docs/api-reference/threads). + - `value: String` - - `id: String` + The data that makes up the text. - The identifier, which can be referenced in API endpoints. + - `class RefusalDeltaBlock` - - `assistant_id: String` + The refusal content that is part of a message. - If applicable, the ID of the [assistant](https://platform.openai.com/docs/api-reference/assistants) that authored this message. + - `index: Integer` - - `attachments: Array[Attachment{ file_id, tools}]` + The index of the refusal part in the message. - A list of files attached to the message, and the tools they were added to. + - `type: :refusal` - - `file_id: String` + Always `refusal`. - The ID of the file to attach to the message. + - `:refusal` - - `tools: Array[CodeInterpreterTool | AssistantToolsFileSearchTypeOnly{ type}]` + - `refusal: String` - The tools to add this file to. + - `class ImageURLDeltaBlock` - - `class CodeInterpreterTool` + References an image URL in the content of a message. - - `type: :code_interpreter` + - `index: Integer` - The type of tool being defined: `code_interpreter` + The index of the content part in the message. - - `:code_interpreter` + - `type: :image_url` - - `class AssistantToolsFileSearchTypeOnly` + Always `image_url`. - - `type: :file_search` + - `:image_url` - The type of tool being defined: `file_search` + - `image_url: ImageURLDelta` - - `:file_search` + - `detail: :auto | :low | :high` - - `completed_at: Integer` + Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. - The Unix timestamp (in seconds) for when the message was completed. + - `:auto` - - `content: Array[untyped]` + - `:low` - The content of the message in array of text and/or images. + - `:high` - - `created_at: Integer` + - `url: String` - The Unix timestamp (in seconds) for when the message was created. + The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. - - `incomplete_at: Integer` + - `role: :user | :assistant` - The Unix timestamp (in seconds) for when the message was marked as incomplete. + The entity that produced the message. One of `user` or `assistant`. - - `incomplete_details: IncompleteDetails{ reason}` + - `:user` - On an incomplete message, details about why the message is incomplete. + - `:assistant` - - `reason: :content_filter | :max_tokens | :run_cancelled | 2 more` +### Message Delta Event - The reason the message is incomplete. +- `class MessageDeltaEvent` - - `:content_filter` + Represents a message delta i.e. any changed fields on a message during streaming. - - `:max_tokens` + - `id: String` - - `:run_cancelled` + The identifier of the message, which can be referenced in API endpoints. - - `:run_expired` + - `delta: MessageDelta` - - `:run_failed` + The delta containing the fields that have changed on the Message. - - `metadata: Metadata` + - `content: Array[MessageContentDelta]` - 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 content of the message in array of text and/or images. - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. + - `class ImageFileDeltaBlock` - - `object: :"thread.message"` + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. - The object type, which is always `thread.message`. + - `index: Integer` - - `:"thread.message"` + The index of the content part in the message. - - `role: :user | :assistant` + - `type: :image_file` - The entity that produced the message. One of `user` or `assistant`. + Always `image_file`. - - `:user` + - `:image_file` - - `:assistant` + - `image_file: ImageFileDelta` - - `run_id: String` + - `detail: :auto | :low | :high` - The ID of the [run](https://platform.openai.com/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. + 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`. - - `status: :in_progress | :incomplete | :completed` + - `:auto` - The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. + - `:low` - - `:in_progress` + - `:high` - - `:incomplete` + - `file_id: String` - - `:completed` + The [File](https://platform.openai.com/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. - - `thread_id: String` + - `class TextDeltaBlock` - The [thread](https://platform.openai.com/docs/api-reference/threads) ID that this message belongs to. + The text content that is part of a message. -### Message Content + - `index: Integer` -- `MessageContent = untyped` + The index of the content part in the message. -### Message Content Delta + - `type: :text` -- `MessageContentDelta = untyped` + Always `text`. -### Message Content Part Param + - `:text` -- `MessageContentPartParam = ImageFileContentBlock | ImageURLContentBlock | TextContentBlockParam` + - `text: TextDelta` - References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. + - `annotations: Array[AnnotationDelta]` - - `class ImageFileContentBlock` + - `class FileCitationDeltaAnnotation` - References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. + 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. - - `image_file: ImageFile` + - `index: Integer` - - `file_id: String` + The index of the annotation in the text content part. - The [File](https://platform.openai.com/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. + - `type: :file_citation` - - `detail: :auto | :low | :high` + Always `file_citation`. - 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`. + - `:file_citation` - - `:auto` + - `end_index: Integer` - - `:low` + - `file_citation: FileCitation{ file_id, quote}` - - `:high` + - `file_id: String` - - `type: :image_file` + The ID of the specific File the citation is from. - Always `image_file`. + - `quote: String` - - `:image_file` + The specific quote in the file. - - `class ImageURLContentBlock` + - `start_index: Integer` - References an image URL in the content of a message. + - `text: String` - - `image_url: ImageURL` + The text in the message content that needs to be replaced. - - `url: String` + - `class FilePathDeltaAnnotation` - The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - - `detail: :auto | :low | :high` + - `index: Integer` - 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 index of the annotation in the text content part. - - `:auto` + - `type: :file_path` - - `:low` + Always `file_path`. - - `:high` + - `:file_path` - - `type: :image_url` + - `end_index: Integer` - The type of the content part. + - `file_path: FilePath{ file_id}` - - `:image_url` + - `file_id: String` - - `class TextContentBlockParam` + The ID of the file that was generated. - The text content that is part of a message. + - `start_index: Integer` - `text: String` - Text content to be sent to the model - - - `type: :text` - - Always `text`. + The text in the message content that needs to be replaced. - - `:text` + - `value: String` -### Message Deleted + The data that makes up the text. -- `class MessageDeleted` + - `class RefusalDeltaBlock` - - `id: String` + The refusal content that is part of a message. - - `deleted: bool` + - `index: Integer` - - `object: :"thread.message.deleted"` + The index of the refusal part in the message. - - `:"thread.message.deleted"` + - `type: :refusal` -### Message Delta + Always `refusal`. -- `class MessageDelta` + - `:refusal` - The delta containing the fields that have changed on the Message. + - `refusal: String` - - `content: Array[untyped]` + - `class ImageURLDeltaBlock` - The content of the message in array of text and/or images. + References an image URL in the content of a message. - - `role: :user | :assistant` + - `index: Integer` - The entity that produced the message. One of `user` or `assistant`. + The index of the content part in the message. - - `:user` + - `type: :image_url` - - `:assistant` + Always `image_url`. -### Message Delta Event + - `:image_url` -- `class MessageDeltaEvent` + - `image_url: ImageURLDelta` - Represents a message delta i.e. any changed fields on a message during streaming. + - `detail: :auto | :low | :high` - - `id: String` + Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. - The identifier of the message, which can be referenced in API endpoints. + - `:auto` - - `delta: MessageDelta` + - `:low` - The delta containing the fields that have changed on the Message. + - `:high` - - `content: Array[untyped]` + - `url: String` - The content of the message in array of text and/or images. + The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. - `role: :user | :assistant` @@ -7600,7 +11164,55 @@ puts(message_deleted) - `class Text` - - `annotations: Array[untyped]` + - `annotations: Array[Annotation]` + + - `class FileCitationAnnotation` + + A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. + + - `end_index: Integer` + + - `file_citation: FileCitation{ file_id}` + + - `file_id: String` + + The ID of the specific File the citation is from. + + - `start_index: Integer` + + - `text: String` + + The text in the message content that needs to be replaced. + + - `type: :file_citation` + + Always `file_citation`. + + - `:file_citation` + + - `class FilePathAnnotation` + + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + + - `end_index: Integer` + + - `file_path: FilePath{ file_id}` + + - `file_id: String` + + The ID of the file that was generated. + + - `start_index: Integer` + + - `text: String` + + The text in the message content that needs to be replaced. + + - `type: :file_path` + + Always `file_path`. + + - `:file_path` - `value: String` @@ -7614,7 +11226,55 @@ puts(message_deleted) - `text: Text` - - `annotations: Array[untyped]` + - `annotations: Array[Annotation]` + + - `class FileCitationAnnotation` + + A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. + + - `end_index: Integer` + + - `file_citation: FileCitation{ file_id}` + + - `file_id: String` + + The ID of the specific File the citation is from. + + - `start_index: Integer` + + - `text: String` + + The text in the message content that needs to be replaced. + + - `type: :file_citation` + + Always `file_citation`. + + - `:file_citation` + + - `class FilePathAnnotation` + + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + + - `end_index: Integer` + + - `file_path: FilePath{ file_id}` + + - `file_id: String` + + The ID of the file that was generated. + + - `start_index: Integer` + + - `text: String` + + The text in the message content that needs to be replaced. + + - `type: :file_path` + + Always `file_path`. + + - `:file_path` - `value: String` @@ -7646,7 +11306,67 @@ puts(message_deleted) - `class TextDelta` - - `annotations: Array[untyped]` + - `annotations: Array[AnnotationDelta]` + + - `class FileCitationDeltaAnnotation` + + A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. + + - `index: Integer` + + The index of the annotation in the text content part. + + - `type: :file_citation` + + Always `file_citation`. + + - `:file_citation` + + - `end_index: Integer` + + - `file_citation: FileCitation{ file_id, quote}` + + - `file_id: String` + + The ID of the specific File the citation is from. + + - `quote: String` + + The specific quote in the file. + + - `start_index: Integer` + + - `text: String` + + The text in the message content that needs to be replaced. + + - `class FilePathDeltaAnnotation` + + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + + - `index: Integer` + + The index of the annotation in the text content part. + + - `type: :file_path` + + Always `file_path`. + + - `:file_path` + + - `end_index: Integer` + + - `file_path: FilePath{ file_id}` + + - `file_id: String` + + The ID of the file that was generated. + + - `start_index: Integer` + + - `text: String` + + The text in the message content that needs to be replaced. - `value: String` @@ -7670,7 +11390,67 @@ puts(message_deleted) - `text: TextDelta` - - `annotations: Array[untyped]` + - `annotations: Array[AnnotationDelta]` + + - `class FileCitationDeltaAnnotation` + + A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. + + - `index: Integer` + + The index of the annotation in the text content part. + + - `type: :file_citation` + + Always `file_citation`. + + - `:file_citation` + + - `end_index: Integer` + + - `file_citation: FileCitation{ file_id, quote}` + + - `file_id: String` + + The ID of the specific File the citation is from. + + - `quote: String` + + The specific quote in the file. + + - `start_index: Integer` + + - `text: String` + + The text in the message content that needs to be replaced. + + - `class FilePathDeltaAnnotation` + + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + + - `index: Integer` + + The index of the annotation in the text content part. + + - `type: :file_path` + + Always `file_path`. + + - `:file_path` + + - `end_index: Integer` + + - `file_path: FilePath{ file_id}` + + - `file_id: String` + + The ID of the file that was generated. + + - `start_index: Integer` + + - `text: String` + + The text in the message content that needs to be replaced. - `value: String`