diff --git a/en/go/resources/beta/subresources/threads/index.md b/en/go/resources/beta/subresources/threads/index.md index fa62020c..be386729 100644 --- a/en/go/resources/beta/subresources/threads/index.md +++ b/en/go/resources/beta/subresources/threads/index.md @@ -6,7 +6,7 @@ **post** `/threads` -Create thread +Create a thread. ### Parameters @@ -26,7 +26,7 @@ Create thread 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). - - `type ImageFileContentBlockParam struct{…}` + - `type ImageFileContentBlock struct{…}` References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. @@ -52,7 +52,7 @@ Create thread - `const ImageFileImageFile ImageFile = "image_file"` - - `type ImageURLContentBlockParam struct{…}` + - `type ImageURLContentBlock struct{…}` References an image URL in the content of a message. @@ -319,7 +319,7 @@ func main() { **post** `/threads/runs` -Create thread and run +Create a thread and run it in one request. ### Parameters @@ -557,7 +557,7 @@ Create thread and run - `[]MessageContentPartParamUnion` - - `type ImageFileContentBlockParam struct{…}` + - `type ImageFileContentBlock struct{…}` References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. @@ -583,7 +583,7 @@ Create thread and run - `const ImageFileImageFile ImageFile = "image_file"` - - `type ImageURLContentBlockParam struct{…}` + - `type ImageURLContentBlock struct{…}` References an image URL in the content of a message. @@ -769,10 +769,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 param.Field[[]any]` + - `Tools param.Field[[]AssistantToolUnion]` Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. + - `type CodeInterpreterTool struct{…}` + + - `type FileSearchTool struct{…}` + + - `Type FileSearch` + + The type of tool being defined: `file_search` + + - `const FileSearchFileSearch FileSearch = "file_search"` + + - `FileSearch FileSearchToolFileSearch` + + Overrides for the file search tool. + + - `MaxNumResults int64` + + 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. + + - `RankingOptions FileSearchToolFileSearchRankingOptions` + + 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. + + - `ScoreThreshold float64` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `Ranker string` + + The ranker to use for the file search. If not specified will use the `auto` ranker. + + - `const FileSearchToolFileSearchRankingOptionsRankerAuto FileSearchToolFileSearchRankingOptionsRanker = "auto"` + + - `const FileSearchToolFileSearchRankingOptionsRankerDefault2024_08_21 FileSearchToolFileSearchRankingOptionsRanker = "default_2024_08_21"` + + - `type FunctionTool struct{…}` + + - `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` + + - `const FunctionFunction Function = "function"` + - `TopP param.Field[float64]` 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. @@ -1015,7 +1081,27 @@ Create thread and run The Unix timestamp (in seconds) for when the run was started. - - `Status any` + - `Status RunStatus` + + The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. + + - `const RunStatusQueued RunStatus = "queued"` + + - `const RunStatusInProgress RunStatus = "in_progress"` + + - `const RunStatusRequiresAction RunStatus = "requires_action"` + + - `const RunStatusCancelling RunStatus = "cancelling"` + + - `const RunStatusCancelled RunStatus = "cancelled"` + + - `const RunStatusFailed RunStatus = "failed"` + + - `const RunStatusCompleted RunStatus = "completed"` + + - `const RunStatusIncomplete RunStatus = "incomplete"` + + - `const RunStatusExpired RunStatus = "expired"` - `ThreadID string` @@ -1059,10 +1145,82 @@ Create thread and run The name of the function to call. - - `Tools []any` + - `Tools []AssistantToolUnion` The list of tools that the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run. + - `type CodeInterpreterTool struct{…}` + + - `Type CodeInterpreter` + + The type of tool being defined: `code_interpreter` + + - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` + + - `type FileSearchTool struct{…}` + + - `Type FileSearch` + + The type of tool being defined: `file_search` + + - `const FileSearchFileSearch FileSearch = "file_search"` + + - `FileSearch FileSearchToolFileSearch` + + Overrides for the file search tool. + + - `MaxNumResults int64` + + 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. + + - `RankingOptions FileSearchToolFileSearchRankingOptions` + + 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. + + - `ScoreThreshold float64` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `Ranker string` + + The ranker to use for the file search. If not specified will use the `auto` ranker. + + - `const FileSearchToolFileSearchRankingOptionsRankerAuto FileSearchToolFileSearchRankingOptionsRanker = "auto"` + + - `const FileSearchToolFileSearchRankingOptionsRankerDefault2024_08_21 FileSearchToolFileSearchRankingOptionsRanker = "default_2024_08_21"` + + - `type FunctionTool struct{…}` + + - `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` + + - `const FunctionFunction Function = "function"` + - `TruncationStrategy RunTruncationStrategy` Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. @@ -1174,11 +1332,13 @@ func main() { }, "response_format": "auto", "started_at": 0, - "status": {}, + "status": "queued", "thread_id": "thread_id", "tool_choice": "none", "tools": [ - {} + { + "type": "code_interpreter" + } ], "truncation_strategy": { "type": "auto", @@ -1200,7 +1360,7 @@ func main() { **get** `/threads/{thread_id}` -Retrieve thread +Retrieves a thread. ### Parameters @@ -1307,7 +1467,7 @@ func main() { **post** `/threads/{thread_id}` -Modify thread +Modifies a thread. ### Parameters @@ -1447,7 +1607,7 @@ func main() { **delete** `/threads/{thread_id}` -Delete thread +Delete a thread. ### Parameters @@ -1716,7 +1876,7 @@ func main() { **get** `/threads/{thread_id}/runs` -List runs +Returns a list of runs belonging to a thread. ### Parameters @@ -1964,7 +2124,27 @@ List runs The Unix timestamp (in seconds) for when the run was started. - - `Status any` + - `Status RunStatus` + + The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. + + - `const RunStatusQueued RunStatus = "queued"` + + - `const RunStatusInProgress RunStatus = "in_progress"` + + - `const RunStatusRequiresAction RunStatus = "requires_action"` + + - `const RunStatusCancelling RunStatus = "cancelling"` + + - `const RunStatusCancelled RunStatus = "cancelled"` + + - `const RunStatusFailed RunStatus = "failed"` + + - `const RunStatusCompleted RunStatus = "completed"` + + - `const RunStatusIncomplete RunStatus = "incomplete"` + + - `const RunStatusExpired RunStatus = "expired"` - `ThreadID string` @@ -2008,10 +2188,82 @@ List runs The name of the function to call. - - `Tools []any` + - `Tools []AssistantToolUnion` The list of tools that the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run. + - `type CodeInterpreterTool struct{…}` + + - `Type CodeInterpreter` + + The type of tool being defined: `code_interpreter` + + - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` + + - `type FileSearchTool struct{…}` + + - `Type FileSearch` + + The type of tool being defined: `file_search` + + - `const FileSearchFileSearch FileSearch = "file_search"` + + - `FileSearch FileSearchToolFileSearch` + + Overrides for the file search tool. + + - `MaxNumResults int64` + + 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. + + - `RankingOptions FileSearchToolFileSearchRankingOptions` + + 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. + + - `ScoreThreshold float64` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `Ranker string` + + The ranker to use for the file search. If not specified will use the `auto` ranker. + + - `const FileSearchToolFileSearchRankingOptionsRankerAuto FileSearchToolFileSearchRankingOptionsRanker = "auto"` + + - `const FileSearchToolFileSearchRankingOptionsRankerDefault2024_08_21 FileSearchToolFileSearchRankingOptionsRanker = "default_2024_08_21"` + + - `type FunctionTool struct{…}` + + - `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` + + - `const FunctionFunction Function = "function"` + - `TruncationStrategy RunTruncationStrategy` Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. @@ -2129,11 +2381,13 @@ func main() { }, "response_format": "auto", "started_at": 0, - "status": {}, + "status": "queued", "thread_id": "thread_id", "tool_choice": "none", "tools": [ - {} + { + "type": "code_interpreter" + } ], "truncation_strategy": { "type": "auto", @@ -2161,7 +2415,7 @@ func main() { **post** `/threads/{thread_id}/runs` -Create run +Create a run. ### Parameters @@ -2197,7 +2451,7 @@ Create run - `[]MessageContentPartParamUnion` - - `type ImageFileContentBlockParam struct{…}` + - `type ImageFileContentBlock struct{…}` References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. @@ -2223,7 +2477,7 @@ Create run - `const ImageFileImageFile ImageFile = "image_file"` - - `type ImageURLContentBlockParam struct{…}` + - `type ImageURLContentBlock struct{…}` References an image URL in the content of a message. @@ -2540,10 +2794,76 @@ Create run `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. - - `Tools param.Field[[]any]` + - `Tools param.Field[[]AssistantToolUnion]` Body param: Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. + - `type CodeInterpreterTool struct{…}` + + - `type FileSearchTool struct{…}` + + - `Type FileSearch` + + The type of tool being defined: `file_search` + + - `const FileSearchFileSearch FileSearch = "file_search"` + + - `FileSearch FileSearchToolFileSearch` + + Overrides for the file search tool. + + - `MaxNumResults int64` + + 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. + + - `RankingOptions FileSearchToolFileSearchRankingOptions` + + 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. + + - `ScoreThreshold float64` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `Ranker string` + + The ranker to use for the file search. If not specified will use the `auto` ranker. + + - `const FileSearchToolFileSearchRankingOptionsRankerAuto FileSearchToolFileSearchRankingOptionsRanker = "auto"` + + - `const FileSearchToolFileSearchRankingOptionsRankerDefault2024_08_21 FileSearchToolFileSearchRankingOptionsRanker = "default_2024_08_21"` + + - `type FunctionTool struct{…}` + + - `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` + + - `const FunctionFunction Function = "function"` + - `TopP param.Field[float64]` Body param: 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. @@ -2786,7 +3106,27 @@ Create run The Unix timestamp (in seconds) for when the run was started. - - `Status any` + - `Status RunStatus` + + The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. + + - `const RunStatusQueued RunStatus = "queued"` + + - `const RunStatusInProgress RunStatus = "in_progress"` + + - `const RunStatusRequiresAction RunStatus = "requires_action"` + + - `const RunStatusCancelling RunStatus = "cancelling"` + + - `const RunStatusCancelled RunStatus = "cancelled"` + + - `const RunStatusFailed RunStatus = "failed"` + + - `const RunStatusCompleted RunStatus = "completed"` + + - `const RunStatusIncomplete RunStatus = "incomplete"` + + - `const RunStatusExpired RunStatus = "expired"` - `ThreadID string` @@ -2830,35 +3170,107 @@ Create run The name of the function to call. - - `Tools []any` + - `Tools []AssistantToolUnion` The list of tools that the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run. - - `TruncationStrategy RunTruncationStrategy` + - `type CodeInterpreterTool struct{…}` - Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. + - `Type CodeInterpreter` - - `Type string` + 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`. + - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` - - `const RunTruncationStrategyTypeAuto RunTruncationStrategyType = "auto"` + - `type FileSearchTool struct{…}` - - `const RunTruncationStrategyTypeLastMessages RunTruncationStrategyType = "last_messages"` + - `Type FileSearch` - - `LastMessages int64` + The type of tool being defined: `file_search` - The number of most recent messages from the thread when constructing the context for the run. + - `const FileSearchFileSearch FileSearch = "file_search"` - - `Usage RunUsage` + - `FileSearch FileSearchToolFileSearch` - Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). + Overrides for the file search tool. - - `CompletionTokens int64` + - `MaxNumResults int64` - Number of completion tokens used over the course of the run. + 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. - - `PromptTokens int64` + 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. + + - `RankingOptions FileSearchToolFileSearchRankingOptions` + + 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. + + - `ScoreThreshold float64` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `Ranker string` + + The ranker to use for the file search. If not specified will use the `auto` ranker. + + - `const FileSearchToolFileSearchRankingOptionsRankerAuto FileSearchToolFileSearchRankingOptionsRanker = "auto"` + + - `const FileSearchToolFileSearchRankingOptionsRankerDefault2024_08_21 FileSearchToolFileSearchRankingOptionsRanker = "default_2024_08_21"` + + - `type FunctionTool struct{…}` + + - `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` + + - `const FunctionFunction Function = "function"` + + - `TruncationStrategy RunTruncationStrategy` + + Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. + + - `Type string` + + 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`. + + - `const RunTruncationStrategyTypeAuto RunTruncationStrategyType = "auto"` + + - `const RunTruncationStrategyTypeLastMessages RunTruncationStrategyType = "last_messages"` + + - `LastMessages int64` + + The number of most recent messages from the thread when constructing the context for the run. + + - `Usage RunUsage` + + Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). + + - `CompletionTokens int64` + + Number of completion tokens used over the course of the run. + + - `PromptTokens int64` Number of prompt tokens used over the course of the run. @@ -2949,11 +3361,13 @@ func main() { }, "response_format": "auto", "started_at": 0, - "status": {}, + "status": "queued", "thread_id": "thread_id", "tool_choice": "none", "tools": [ - {} + { + "type": "code_interpreter" + } ], "truncation_strategy": { "type": "auto", @@ -2975,7 +3389,7 @@ func main() { **get** `/threads/{thread_id}/runs/{run_id}` -Retrieve run +Retrieves a run. ### Parameters @@ -3203,7 +3617,27 @@ Retrieve run The Unix timestamp (in seconds) for when the run was started. - - `Status any` + - `Status RunStatus` + + The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. + + - `const RunStatusQueued RunStatus = "queued"` + + - `const RunStatusInProgress RunStatus = "in_progress"` + + - `const RunStatusRequiresAction RunStatus = "requires_action"` + + - `const RunStatusCancelling RunStatus = "cancelling"` + + - `const RunStatusCancelled RunStatus = "cancelled"` + + - `const RunStatusFailed RunStatus = "failed"` + + - `const RunStatusCompleted RunStatus = "completed"` + + - `const RunStatusIncomplete RunStatus = "incomplete"` + + - `const RunStatusExpired RunStatus = "expired"` - `ThreadID string` @@ -3247,10 +3681,82 @@ Retrieve run The name of the function to call. - - `Tools []any` + - `Tools []AssistantToolUnion` The list of tools that the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run. + - `type CodeInterpreterTool struct{…}` + + - `Type CodeInterpreter` + + The type of tool being defined: `code_interpreter` + + - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` + + - `type FileSearchTool struct{…}` + + - `Type FileSearch` + + The type of tool being defined: `file_search` + + - `const FileSearchFileSearch FileSearch = "file_search"` + + - `FileSearch FileSearchToolFileSearch` + + Overrides for the file search tool. + + - `MaxNumResults int64` + + 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. + + - `RankingOptions FileSearchToolFileSearchRankingOptions` + + 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. + + - `ScoreThreshold float64` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `Ranker string` + + The ranker to use for the file search. If not specified will use the `auto` ranker. + + - `const FileSearchToolFileSearchRankingOptionsRankerAuto FileSearchToolFileSearchRankingOptionsRanker = "auto"` + + - `const FileSearchToolFileSearchRankingOptionsRankerDefault2024_08_21 FileSearchToolFileSearchRankingOptionsRanker = "default_2024_08_21"` + + - `type FunctionTool struct{…}` + + - `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` + + - `const FunctionFunction Function = "function"` + - `TruncationStrategy RunTruncationStrategy` Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. @@ -3364,11 +3870,13 @@ func main() { }, "response_format": "auto", "started_at": 0, - "status": {}, + "status": "queued", "thread_id": "thread_id", "tool_choice": "none", "tools": [ - {} + { + "type": "code_interpreter" + } ], "truncation_strategy": { "type": "auto", @@ -3390,7 +3898,7 @@ func main() { **post** `/threads/{thread_id}/runs/{run_id}` -Modify run +Modifies a run. ### Parameters @@ -3629,7 +4137,27 @@ Modify run The Unix timestamp (in seconds) for when the run was started. - - `Status any` + - `Status RunStatus` + + The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. + + - `const RunStatusQueued RunStatus = "queued"` + + - `const RunStatusInProgress RunStatus = "in_progress"` + + - `const RunStatusRequiresAction RunStatus = "requires_action"` + + - `const RunStatusCancelling RunStatus = "cancelling"` + + - `const RunStatusCancelled RunStatus = "cancelled"` + + - `const RunStatusFailed RunStatus = "failed"` + + - `const RunStatusCompleted RunStatus = "completed"` + + - `const RunStatusIncomplete RunStatus = "incomplete"` + + - `const RunStatusExpired RunStatus = "expired"` - `ThreadID string` @@ -3673,10 +4201,82 @@ Modify run The name of the function to call. - - `Tools []any` + - `Tools []AssistantToolUnion` The list of tools that the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run. + - `type CodeInterpreterTool struct{…}` + + - `Type CodeInterpreter` + + The type of tool being defined: `code_interpreter` + + - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` + + - `type FileSearchTool struct{…}` + + - `Type FileSearch` + + The type of tool being defined: `file_search` + + - `const FileSearchFileSearch FileSearch = "file_search"` + + - `FileSearch FileSearchToolFileSearch` + + Overrides for the file search tool. + + - `MaxNumResults int64` + + 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. + + - `RankingOptions FileSearchToolFileSearchRankingOptions` + + 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. + + - `ScoreThreshold float64` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `Ranker string` + + The ranker to use for the file search. If not specified will use the `auto` ranker. + + - `const FileSearchToolFileSearchRankingOptionsRankerAuto FileSearchToolFileSearchRankingOptionsRanker = "auto"` + + - `const FileSearchToolFileSearchRankingOptionsRankerDefault2024_08_21 FileSearchToolFileSearchRankingOptionsRanker = "default_2024_08_21"` + + - `type FunctionTool struct{…}` + + - `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` + + - `const FunctionFunction Function = "function"` + - `TruncationStrategy RunTruncationStrategy` Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. @@ -3793,11 +4393,13 @@ func main() { }, "response_format": "auto", "started_at": 0, - "status": {}, + "status": "queued", "thread_id": "thread_id", "tool_choice": "none", "tools": [ - {} + { + "type": "code_interpreter" + } ], "truncation_strategy": { "type": "auto", @@ -3819,7 +4421,7 @@ func main() { **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 @@ -4063,7 +4665,27 @@ Submit tool outputs to run The Unix timestamp (in seconds) for when the run was started. - - `Status any` + - `Status RunStatus` + + The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. + + - `const RunStatusQueued RunStatus = "queued"` + + - `const RunStatusInProgress RunStatus = "in_progress"` + + - `const RunStatusRequiresAction RunStatus = "requires_action"` + + - `const RunStatusCancelling RunStatus = "cancelling"` + + - `const RunStatusCancelled RunStatus = "cancelled"` + + - `const RunStatusFailed RunStatus = "failed"` + + - `const RunStatusCompleted RunStatus = "completed"` + + - `const RunStatusIncomplete RunStatus = "incomplete"` + + - `const RunStatusExpired RunStatus = "expired"` - `ThreadID string` @@ -4107,73 +4729,145 @@ Submit tool outputs to run The name of the function to call. - - `Tools []any` + - `Tools []AssistantToolUnion` The list of tools that the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run. - - `TruncationStrategy RunTruncationStrategy` + - `type CodeInterpreterTool struct{…}` - Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. + - `Type CodeInterpreter` - - `Type string` + 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`. + - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` - - `const RunTruncationStrategyTypeAuto RunTruncationStrategyType = "auto"` + - `type FileSearchTool struct{…}` - - `const RunTruncationStrategyTypeLastMessages RunTruncationStrategyType = "last_messages"` + - `Type FileSearch` - - `LastMessages int64` + The type of tool being defined: `file_search` - The number of most recent messages from the thread when constructing the context for the run. + - `const FileSearchFileSearch FileSearch = "file_search"` - - `Usage RunUsage` + - `FileSearch FileSearchToolFileSearch` - Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). + Overrides for the file search tool. - - `CompletionTokens int64` + - `MaxNumResults int64` - Number of completion tokens used over the course of the run. + 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. - - `PromptTokens int64` + 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. - Number of prompt tokens used over the course of the run. + - `RankingOptions FileSearchToolFileSearchRankingOptions` - - `TotalTokens int64` + 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. - Total number of tokens used (prompt + completion). + See the [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. - - `Temperature float64` + - `ScoreThreshold float64` - The sampling temperature used for this run. If not set, defaults to 1. + The score threshold for the file search. All values must be a floating point number between 0 and 1. - - `TopP float64` + - `Ranker string` - The nucleus sampling value used for this run. If not set, defaults to 1. + The ranker to use for the file search. If not specified will use the `auto` ranker. -### Example + - `const FileSearchToolFileSearchRankingOptionsRankerAuto FileSearchToolFileSearchRankingOptionsRanker = "auto"` -```go -package main + - `const FileSearchToolFileSearchRankingOptionsRankerDefault2024_08_21 FileSearchToolFileSearchRankingOptionsRanker = "default_2024_08_21"` -import ( - "context" - "fmt" + - `type FunctionTool struct{…}` - "github.com/openai/openai-go" - "github.com/openai/openai-go/option" -) + - `Function FunctionDefinition` -func main() { - client := openai.NewClient( - option.WithAPIKey("My API Key"), - ) - run, err := client.Beta.Threads.Runs.SubmitToolOutputs( - context.TODO(), - "thread_id", - "run_id", - openai.BetaThreadRunSubmitToolOutputsParams{ - ToolOutputs: []openai.BetaThreadRunSubmitToolOutputsParamsToolOutput{openai.BetaThreadRunSubmitToolOutputsParamsToolOutput{ + - `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` + + - `const FunctionFunction Function = "function"` + + - `TruncationStrategy RunTruncationStrategy` + + Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. + + - `Type string` + + 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`. + + - `const RunTruncationStrategyTypeAuto RunTruncationStrategyType = "auto"` + + - `const RunTruncationStrategyTypeLastMessages RunTruncationStrategyType = "last_messages"` + + - `LastMessages int64` + + The number of most recent messages from the thread when constructing the context for the run. + + - `Usage RunUsage` + + Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). + + - `CompletionTokens int64` + + Number of completion tokens used over the course of the run. + + - `PromptTokens int64` + + Number of prompt tokens used over the course of the run. + + - `TotalTokens int64` + + Total number of tokens used (prompt + completion). + + - `Temperature float64` + + The sampling temperature used for this run. If not set, defaults to 1. + + - `TopP float64` + + The nucleus sampling value used for this run. If not set, defaults to 1. + +### Example + +```go +package main + +import ( + "context" + "fmt" + + "github.com/openai/openai-go" + "github.com/openai/openai-go/option" +) + +func main() { + client := openai.NewClient( + option.WithAPIKey("My API Key"), + ) + run, err := client.Beta.Threads.Runs.SubmitToolOutputs( + context.TODO(), + "thread_id", + "run_id", + openai.BetaThreadRunSubmitToolOutputsParams{ + ToolOutputs: []openai.BetaThreadRunSubmitToolOutputsParamsToolOutput{openai.BetaThreadRunSubmitToolOutputsParamsToolOutput{ }}, }, @@ -4229,11 +4923,13 @@ func main() { }, "response_format": "auto", "started_at": 0, - "status": {}, + "status": "queued", "thread_id": "thread_id", "tool_choice": "none", "tools": [ - {} + { + "type": "code_interpreter" + } ], "truncation_strategy": { "type": "auto", @@ -4255,7 +4951,7 @@ func main() { **post** `/threads/{thread_id}/runs/{run_id}/cancel` -Cancel a run +Cancels a run that is `in_progress`. ### Parameters @@ -4483,7 +5179,27 @@ Cancel a run The Unix timestamp (in seconds) for when the run was started. - - `Status any` + - `Status RunStatus` + + The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. + + - `const RunStatusQueued RunStatus = "queued"` + + - `const RunStatusInProgress RunStatus = "in_progress"` + + - `const RunStatusRequiresAction RunStatus = "requires_action"` + + - `const RunStatusCancelling RunStatus = "cancelling"` + + - `const RunStatusCancelled RunStatus = "cancelled"` + + - `const RunStatusFailed RunStatus = "failed"` + + - `const RunStatusCompleted RunStatus = "completed"` + + - `const RunStatusIncomplete RunStatus = "incomplete"` + + - `const RunStatusExpired RunStatus = "expired"` - `ThreadID string` @@ -4527,10 +5243,82 @@ Cancel a run The name of the function to call. - - `Tools []any` + - `Tools []AssistantToolUnion` The list of tools that the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run. + - `type CodeInterpreterTool struct{…}` + + - `Type CodeInterpreter` + + The type of tool being defined: `code_interpreter` + + - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` + + - `type FileSearchTool struct{…}` + + - `Type FileSearch` + + The type of tool being defined: `file_search` + + - `const FileSearchFileSearch FileSearch = "file_search"` + + - `FileSearch FileSearchToolFileSearch` + + Overrides for the file search tool. + + - `MaxNumResults int64` + + 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. + + - `RankingOptions FileSearchToolFileSearchRankingOptions` + + 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. + + - `ScoreThreshold float64` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `Ranker string` + + The ranker to use for the file search. If not specified will use the `auto` ranker. + + - `const FileSearchToolFileSearchRankingOptionsRankerAuto FileSearchToolFileSearchRankingOptionsRanker = "auto"` + + - `const FileSearchToolFileSearchRankingOptionsRankerDefault2024_08_21 FileSearchToolFileSearchRankingOptionsRanker = "default_2024_08_21"` + + - `type FunctionTool struct{…}` + + - `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` + + - `const FunctionFunction Function = "function"` + - `TruncationStrategy RunTruncationStrategy` Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. @@ -4644,11 +5432,13 @@ func main() { }, "response_format": "auto", "started_at": 0, - "status": {}, + "status": "queued", "thread_id": "thread_id", "tool_choice": "none", "tools": [ - {} + { + "type": "code_interpreter" + } ], "truncation_strategy": { "type": "auto", @@ -4914,7 +5704,27 @@ func main() { The Unix timestamp (in seconds) for when the run was started. - - `Status any` + - `Status RunStatus` + + The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. + + - `const RunStatusQueued RunStatus = "queued"` + + - `const RunStatusInProgress RunStatus = "in_progress"` + + - `const RunStatusRequiresAction RunStatus = "requires_action"` + + - `const RunStatusCancelling RunStatus = "cancelling"` + + - `const RunStatusCancelled RunStatus = "cancelled"` + + - `const RunStatusFailed RunStatus = "failed"` + + - `const RunStatusCompleted RunStatus = "completed"` + + - `const RunStatusIncomplete RunStatus = "incomplete"` + + - `const RunStatusExpired RunStatus = "expired"` - `ThreadID string` @@ -4958,10 +5768,82 @@ func main() { The name of the function to call. - - `Tools []any` + - `Tools []AssistantToolUnion` The list of tools that the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run. + - `type CodeInterpreterTool struct{…}` + + - `Type CodeInterpreter` + + The type of tool being defined: `code_interpreter` + + - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` + + - `type FileSearchTool struct{…}` + + - `Type FileSearch` + + The type of tool being defined: `file_search` + + - `const FileSearchFileSearch FileSearch = "file_search"` + + - `FileSearch FileSearchToolFileSearch` + + Overrides for the file search tool. + + - `MaxNumResults int64` + + 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. + + - `RankingOptions FileSearchToolFileSearchRankingOptions` + + 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. + + - `ScoreThreshold float64` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `Ranker string` + + The ranker to use for the file search. If not specified will use the `auto` ranker. + + - `const FileSearchToolFileSearchRankingOptionsRankerAuto FileSearchToolFileSearchRankingOptionsRanker = "auto"` + + - `const FileSearchToolFileSearchRankingOptionsRankerDefault2024_08_21 FileSearchToolFileSearchRankingOptionsRanker = "default_2024_08_21"` + + - `type FunctionTool struct{…}` + + - `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` + + - `const FunctionFunction Function = "function"` + - `TruncationStrategy RunTruncationStrategy` Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. @@ -5004,7 +5886,27 @@ func main() { ### Run Status -- `type RunStatus interface{…}` +- `type RunStatus string` + + The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. + + - `const RunStatusQueued RunStatus = "queued"` + + - `const RunStatusInProgress RunStatus = "in_progress"` + + - `const RunStatusRequiresAction RunStatus = "requires_action"` + + - `const RunStatusCancelling RunStatus = "cancelling"` + + - `const RunStatusCancelled RunStatus = "cancelled"` + + - `const RunStatusFailed RunStatus = "failed"` + + - `const RunStatusCompleted RunStatus = "completed"` + + - `const RunStatusIncomplete RunStatus = "incomplete"` + + - `const RunStatusExpired RunStatus = "expired"` # Steps @@ -5014,7 +5916,7 @@ func main() { **get** `/threads/{thread_id}/runs/{run_id}/steps` -List run steps +Returns a list of run steps belonging to a run. ### Parameters @@ -5159,48 +6061,192 @@ List run steps Details of the tool call. - - `ToolCalls []any` + - `ToolCalls []ToolCallUnion` 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 ToolCalls` + - `type CodeInterpreterToolCall struct{…}` - Always `tool_calls`. + Details of the Code Interpreter tool call the run step was involved in. - - `const ToolCallsToolCalls ToolCalls = "tool_calls"` + - `ID string` - - `ThreadID string` + The ID of the tool call. - The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) that was run. + - `CodeInterpreter CodeInterpreterToolCallCodeInterpreter` - - `Type RunStepType` + The Code Interpreter tool call definition. - The type of run step, which can be either `message_creation` or `tool_calls`. + - `Input string` - - `const RunStepTypeMessageCreation RunStepType = "message_creation"` + The input to the Code Interpreter tool call. - - `const RunStepTypeToolCalls RunStepType = "tool_calls"` + - `Outputs []CodeInterpreterToolCallCodeInterpreterOutputUnion` - - `Usage RunStepUsage` + 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`. + - `type CodeInterpreterToolCallCodeInterpreterOutputLogs struct{…}` - - `CompletionTokens int64` + 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` - - `PromptTokens int64` + The text output from the Code Interpreter tool call. - Number of prompt tokens used over the course of the run step. + - `Type Logs` - - `TotalTokens int64` + Always `logs`. - Total number of tokens used (prompt + completion). + - `const LogsLogs Logs = "logs"` -### Example + - `type CodeInterpreterToolCallCodeInterpreterOutputImage struct{…}` -```go -package main + - `Image CodeInterpreterToolCallCodeInterpreterOutputImageImage` + + - `FileID string` + + The [file](https://platform.openai.com/docs/api-reference/files) ID of the image. + + - `Type Image` + + Always `image`. + + - `const ImageImage Image = "image"` + + - `Type CodeInterpreter` + + The type of tool call. This is always going to be `code_interpreter` for this type of tool call. + + - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` + + - `type FileSearchToolCall struct{…}` + + - `ID string` + + The ID of the tool call object. + + - `FileSearch FileSearchToolCallFileSearch` + + For now, this is always going to be an empty object. + + - `RankingOptions FileSearchToolCallFileSearchRankingOptions` + + The ranking options for the file search. + + - `Ranker string` + + The ranker to use for the file search. If not specified will use the `auto` ranker. + + - `const FileSearchToolCallFileSearchRankingOptionsRankerAuto FileSearchToolCallFileSearchRankingOptionsRanker = "auto"` + + - `const FileSearchToolCallFileSearchRankingOptionsRankerDefault2024_08_21 FileSearchToolCallFileSearchRankingOptionsRanker = "default_2024_08_21"` + + - `ScoreThreshold float64` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `Results []FileSearchToolCallFileSearchResult` + + The results of the file search. + + - `FileID string` + + The ID of the file that result was found in. + + - `FileName string` + + The name of the file that result was found in. + + - `Score float64` + + The score of the result. All values must be a floating point number between 0 and 1. + + - `Content []FileSearchToolCallFileSearchResultContent` + + 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 string` + + The type of the content. + + - `const FileSearchToolCallFileSearchResultContentTypeText FileSearchToolCallFileSearchResultContentType = "text"` + + - `Type FileSearch` + + The type of tool call. This is always going to be `file_search` for this type of tool call. + + - `const FileSearchFileSearch FileSearch = "file_search"` + + - `type FunctionToolCall struct{…}` + + - `ID string` + + The ID of the tool call object. + + - `Function FunctionToolCallFunction` + + 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. + + - `const FunctionFunction Function = "function"` + + - `Type ToolCalls` + + Always `tool_calls`. + + - `const ToolCallsToolCalls ToolCalls = "tool_calls"` + + - `ThreadID string` + + The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) that was run. + + - `Type RunStepType` + + The type of run step, which can be either `message_creation` or `tool_calls`. + + - `const RunStepTypeMessageCreation RunStepType = "message_creation"` + + - `const RunStepTypeToolCalls RunStepType = "tool_calls"` + + - `Usage RunStepUsage` + + Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. + + - `CompletionTokens int64` + + Number of completion tokens used over the course of the run step. + + - `PromptTokens int64` + + Number of prompt tokens used over the course of the run step. + + - `TotalTokens int64` + + Total number of tokens used (prompt + completion). + +### Example + +```go +package main import ( "context" @@ -5280,7 +6326,7 @@ func main() { **get** `/threads/{thread_id}/runs/{run_id}/steps/{step_id}` -Retrieve run step +Retrieves a run step. ### Parameters @@ -5407,125 +6453,269 @@ Retrieve run step Details of the tool call. - - `ToolCalls []any` + - `ToolCalls []ToolCallUnion` 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 ToolCalls` + - `type CodeInterpreterToolCall struct{…}` - Always `tool_calls`. + Details of the Code Interpreter tool call the run step was involved in. - - `const ToolCallsToolCalls ToolCalls = "tool_calls"` + - `ID string` - - `ThreadID string` + The ID of the tool call. - The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) that was run. + - `CodeInterpreter CodeInterpreterToolCallCodeInterpreter` - - `Type RunStepType` + The Code Interpreter tool call definition. - The type of run step, which can be either `message_creation` or `tool_calls`. + - `Input string` - - `const RunStepTypeMessageCreation RunStepType = "message_creation"` + The input to the Code Interpreter tool call. - - `const RunStepTypeToolCalls RunStepType = "tool_calls"` + - `Outputs []CodeInterpreterToolCallCodeInterpreterOutputUnion` - - `Usage RunStepUsage` + 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`. + - `type CodeInterpreterToolCallCodeInterpreterOutputLogs struct{…}` - - `CompletionTokens int64` + 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` - - `PromptTokens int64` + The text output from the Code Interpreter tool call. - Number of prompt tokens used over the course of the run step. + - `Type Logs` - - `TotalTokens int64` + Always `logs`. - Total number of tokens used (prompt + completion). + - `const LogsLogs Logs = "logs"` -### Example + - `type CodeInterpreterToolCallCodeInterpreterOutputImage struct{…}` -```go -package main + - `Image CodeInterpreterToolCallCodeInterpreterOutputImageImage` -import ( - "context" - "fmt" + - `FileID string` - "github.com/openai/openai-go" - "github.com/openai/openai-go/option" -) + The [file](https://platform.openai.com/docs/api-reference/files) ID of the image. -func main() { - client := openai.NewClient( - option.WithAPIKey("My API Key"), - ) - runStep, err := client.Beta.Threads.Runs.Steps.Get( - context.TODO(), - "thread_id", - "run_id", - "step_id", - openai.BetaThreadRunStepGetParams{ + - `Type Image` - }, - ) - if err != nil { - panic(err.Error()) - } - fmt.Printf("%+v\n", runStep.ID) -} -``` + Always `image`. -#### Response + - `const ImageImage Image = "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 - } -} -``` + - `Type CodeInterpreter` -## Domain Types + The type of tool call. This is always going to be `code_interpreter` for this type of tool call. -### Code Interpreter Logs + - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` -- `type CodeInterpreterLogs struct{…}` + - `type FileSearchToolCall struct{…}` - Text output from the Code Interpreter tool call as part of a run step. + - `ID string` - - `Index int64` + The ID of the tool call object. - The index of the output in the outputs array. + - `FileSearch FileSearchToolCallFileSearch` + + For now, this is always going to be an empty object. + + - `RankingOptions FileSearchToolCallFileSearchRankingOptions` + + The ranking options for the file search. + + - `Ranker string` + + The ranker to use for the file search. If not specified will use the `auto` ranker. + + - `const FileSearchToolCallFileSearchRankingOptionsRankerAuto FileSearchToolCallFileSearchRankingOptionsRanker = "auto"` + + - `const FileSearchToolCallFileSearchRankingOptionsRankerDefault2024_08_21 FileSearchToolCallFileSearchRankingOptionsRanker = "default_2024_08_21"` + + - `ScoreThreshold float64` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `Results []FileSearchToolCallFileSearchResult` + + The results of the file search. + + - `FileID string` + + The ID of the file that result was found in. + + - `FileName string` + + The name of the file that result was found in. + + - `Score float64` + + The score of the result. All values must be a floating point number between 0 and 1. + + - `Content []FileSearchToolCallFileSearchResultContent` + + 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 string` + + The type of the content. + + - `const FileSearchToolCallFileSearchResultContentTypeText FileSearchToolCallFileSearchResultContentType = "text"` + + - `Type FileSearch` + + The type of tool call. This is always going to be `file_search` for this type of tool call. + + - `const FileSearchFileSearch FileSearch = "file_search"` + + - `type FunctionToolCall struct{…}` + + - `ID string` + + The ID of the tool call object. + + - `Function FunctionToolCallFunction` + + 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. + + - `const FunctionFunction Function = "function"` + + - `Type ToolCalls` + + Always `tool_calls`. + + - `const ToolCallsToolCalls ToolCalls = "tool_calls"` + + - `ThreadID string` + + The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) that was run. + + - `Type RunStepType` + + The type of run step, which can be either `message_creation` or `tool_calls`. + + - `const RunStepTypeMessageCreation RunStepType = "message_creation"` + + - `const RunStepTypeToolCalls RunStepType = "tool_calls"` + + - `Usage RunStepUsage` + + Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. + + - `CompletionTokens int64` + + Number of completion tokens used over the course of the run step. + + - `PromptTokens int64` + + Number of prompt tokens used over the course of the run step. + + - `TotalTokens int64` + + Total number of tokens used (prompt + completion). + +### Example + +```go +package main + +import ( + "context" + "fmt" + + "github.com/openai/openai-go" + "github.com/openai/openai-go/option" +) + +func main() { + client := openai.NewClient( + option.WithAPIKey("My API Key"), + ) + runStep, err := client.Beta.Threads.Runs.Steps.Get( + context.TODO(), + "thread_id", + "run_id", + "step_id", + openai.BetaThreadRunStepGetParams{ + + }, + ) + if err != nil { + panic(err.Error()) + } + fmt.Printf("%+v\n", runStep.ID) +} +``` + +#### 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 + +- `type CodeInterpreterLogs struct{…}` + + Text output from the Code Interpreter tool call as part of a run step. + + - `Index int64` + + The index of the output in the outputs array. - `Type Logs` @@ -5579,7 +6769,9 @@ func main() { 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. - - `CodeInterpreterToolCallCodeInterpreterOutputLogs` + - `type CodeInterpreterToolCallCodeInterpreterOutputLogs struct{…}` + + Text output from the Code Interpreter tool call as part of a run step. - `Logs string` @@ -5591,7 +6783,7 @@ func main() { - `const LogsLogs Logs = "logs"` - - `CodeInterpreterToolCallCodeInterpreterOutputImage` + - `type CodeInterpreterToolCallCodeInterpreterOutputImage struct{…}` - `Image CodeInterpreterToolCallCodeInterpreterOutputImageImage` @@ -5954,103 +7146,153 @@ func main() { Details of the tool call. - - `ToolCalls []any` + - `ToolCalls []ToolCallUnion` 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 ToolCalls` + - `type CodeInterpreterToolCall struct{…}` - Always `tool_calls`. + Details of the Code Interpreter tool call the run step was involved in. - - `const ToolCallsToolCalls ToolCalls = "tool_calls"` + - `ID string` - - `ThreadID string` + The ID of the tool call. - The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) that was run. + - `CodeInterpreter CodeInterpreterToolCallCodeInterpreter` - - `Type RunStepType` + The Code Interpreter tool call definition. - The type of run step, which can be either `message_creation` or `tool_calls`. + - `Input string` - - `const RunStepTypeMessageCreation RunStepType = "message_creation"` + The input to the Code Interpreter tool call. - - `const RunStepTypeToolCalls RunStepType = "tool_calls"` + - `Outputs []CodeInterpreterToolCallCodeInterpreterOutputUnion` - - `Usage RunStepUsage` + 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`. + - `type CodeInterpreterToolCallCodeInterpreterOutputLogs struct{…}` - - `CompletionTokens int64` + 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` - - `PromptTokens int64` + The text output from the Code Interpreter tool call. - Number of prompt tokens used over the course of the run step. + - `Type Logs` - - `TotalTokens int64` + Always `logs`. - Total number of tokens used (prompt + completion). + - `const LogsLogs Logs = "logs"` -### Run Step Delta + - `type CodeInterpreterToolCallCodeInterpreterOutputImage struct{…}` -- `type RunStepDelta interface{…}` + - `Image CodeInterpreterToolCallCodeInterpreterOutputImageImage` -### Run Step Delta Event + - `FileID string` -- `type RunStepDeltaEvent struct{…}` + 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. + - `const ImageImage Image = "image"` - - `Delta any` + - `Type CodeInterpreter` - - `Object ThreadRunStepDelta` + 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`. + - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` - - `const ThreadRunStepDeltaThreadRunStepDelta ThreadRunStepDelta = "thread.run.step.delta"` + - `type FileSearchToolCall struct{…}` -### Run Step Delta Message Delta + - `ID string` -- `type RunStepDeltaMessageDelta struct{…}` + The ID of the tool call object. - Details of the message creation by the run step. + - `FileSearch FileSearchToolCallFileSearch` - - `Type MessageCreation` + For now, this is always going to be an empty object. - Always `message_creation`. + - `RankingOptions FileSearchToolCallFileSearchRankingOptions` - - `const MessageCreationMessageCreation MessageCreation = "message_creation"` + The ranking options for the file search. - - `MessageCreation RunStepDeltaMessageDeltaMessageCreation` + - `Ranker string` - - `MessageID 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. + - `const FileSearchToolCallFileSearchRankingOptionsRankerAuto FileSearchToolCallFileSearchRankingOptionsRanker = "auto"` -### Run Step Include + - `const FileSearchToolCallFileSearchRankingOptionsRankerDefault2024_08_21 FileSearchToolCallFileSearchRankingOptionsRanker = "default_2024_08_21"` -- `type RunStepInclude string` + - `ScoreThreshold float64` - - `const RunStepIncludeStepDetailsToolCallsFileSearchResultsContent RunStepInclude = "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 []FileSearchToolCallFileSearchResult` -- `type ToolCall interface{…}` + The results of the file search. -### Tool Call Delta + - `FileID string` -- `type ToolCallDelta interface{…}` + The ID of the file that result was found in. -### Tool Call Delta Object + - `FileName string` -- `type ToolCallDeltaObject struct{…}` + The name of the file that result was found in. - Details of the tool call. + - `Score float64` + + The score of the result. All values must be a floating point number between 0 and 1. + + - `Content []FileSearchToolCallFileSearchResultContent` + + 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 string` + + The type of the content. + + - `const FileSearchToolCallFileSearchResultContentTypeText FileSearchToolCallFileSearchResultContentType = "text"` + + - `Type FileSearch` + + The type of tool call. This is always going to be `file_search` for this type of tool call. + + - `const FileSearchFileSearch FileSearch = "file_search"` + + - `type FunctionToolCall struct{…}` + + - `ID string` + + The ID of the tool call object. + + - `Function FunctionToolCallFunction` + + 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. + + - `const FunctionFunction Function = "function"` - `Type ToolCalls` @@ -6058,19 +7300,63 @@ func main() { - `const ToolCallsToolCalls ToolCalls = "tool_calls"` - - `ToolCalls []any` + - `ThreadID 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 ID of the [thread](https://platform.openai.com/docs/api-reference/threads) that was run. -### Tool Calls Step Details + - `Type RunStepType` -- `type ToolCallsStepDetails struct{…}` + The type of run step, which can be either `message_creation` or `tool_calls`. - Details of the tool call. + - `const RunStepTypeMessageCreation RunStepType = "message_creation"` + + - `const RunStepTypeToolCalls RunStepType = "tool_calls"` - - `ToolCalls []any` + - `Usage RunStepUsage` - 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`. + Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. + + - `CompletionTokens int64` + + Number of completion tokens used over the course of the run step. + + - `PromptTokens int64` + + Number of prompt tokens used over the course of the run step. + + - `TotalTokens int64` + + Total number of tokens used (prompt + completion). + +### Run Step Delta + +- `type RunStepDelta struct{…}` + + The delta containing the fields that have changed on the run step. + + - `StepDetails RunStepDeltaStepDetailsUnion` + + The details of the run step. + + - `type RunStepDeltaMessageDelta struct{…}` + + Details of the message creation by the run step. + + - `Type MessageCreation` + + Always `message_creation`. + + - `const MessageCreationMessageCreation MessageCreation = "message_creation"` + + - `MessageCreation RunStepDeltaMessageDeltaMessageCreation` + + - `MessageID string` + + The ID of the message that was created by this run step. + + - `type ToolCallDeltaObject struct{…}` + + Details of the tool call. - `Type ToolCalls` @@ -6078,289 +7364,2819 @@ func main() { - `const ToolCallsToolCalls ToolCalls = "tool_calls"` -# Messages + - `ToolCalls []ToolCallDeltaUnion` -## List messages + An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. -`client.Beta.Threads.Messages.List(ctx, threadID, query) (*CursorPage[Message], error)` + - `type CodeInterpreterToolCallDelta struct{…}` -**get** `/threads/{thread_id}/messages` + Details of the Code Interpreter tool call the run step was involved in. -List messages + - `Index int64` -### Parameters + The index of the tool call in the tool calls array. -- `threadID string` + - `Type CodeInterpreter` -- `query BetaThreadMessageListParams` + The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - - `After param.Field[string]` + - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` - 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. + - `ID string` - - `Before param.Field[string]` + The ID of the tool call. - 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. + - `CodeInterpreter CodeInterpreterToolCallDeltaCodeInterpreter` - - `Limit param.Field[int64]` + The Code Interpreter tool call definition. - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + - `Input string` - - `Order param.Field[BetaThreadMessageListParamsOrder]` + The input to the Code Interpreter tool call. + + - `Outputs []CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion` + + 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. + + - `type CodeInterpreterLogs struct{…}` + + Text output from the Code Interpreter tool call as part of a run step. + + - `Index int64` + + The index of the output in the outputs array. + + - `Type Logs` + + Always `logs`. + + - `const LogsLogs Logs = "logs"` + + - `Logs string` + + The text output from the Code Interpreter tool call. + + - `type CodeInterpreterOutputImage struct{…}` + + - `Index int64` + + The index of the output in the outputs array. + + - `Type Image` + + Always `image`. + + - `const ImageImage Image = "image"` + + - `Image CodeInterpreterOutputImageImage` + + - `FileID string` + + The [file](https://platform.openai.com/docs/api-reference/files) ID of the image. + + - `type FileSearchToolCallDelta struct{…}` + + - `FileSearch any` + + For now, this is always going to be an empty object. + + - `Index int64` + + The index of the tool call in the tool calls array. + + - `Type FileSearch` + + The type of tool call. This is always going to be `file_search` for this type of tool call. + + - `const FileSearchFileSearch FileSearch = "file_search"` + + - `ID string` + + The ID of the tool call object. + + - `type FunctionToolCallDelta struct{…}` + + - `Index int64` + + 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. + + - `const FunctionFunction Function = "function"` + + - `ID string` + + The ID of the tool call object. + + - `Function FunctionToolCallDeltaFunction` + + 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. + +### Run Step Delta Event + +- `type RunStepDeltaEvent struct{…}` + + 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. + + - `StepDetails RunStepDeltaStepDetailsUnion` + + The details of the run step. + + - `type RunStepDeltaMessageDelta struct{…}` + + Details of the message creation by the run step. + + - `Type MessageCreation` + + Always `message_creation`. + + - `const MessageCreationMessageCreation MessageCreation = "message_creation"` + + - `MessageCreation RunStepDeltaMessageDeltaMessageCreation` + + - `MessageID string` + + The ID of the message that was created by this run step. + + - `type ToolCallDeltaObject struct{…}` + + Details of the tool call. + + - `Type ToolCalls` + + Always `tool_calls`. + + - `const ToolCallsToolCalls ToolCalls = "tool_calls"` + + - `ToolCalls []ToolCallDeltaUnion` + + 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 CodeInterpreterToolCallDelta struct{…}` + + Details of the Code Interpreter tool call the run step was involved in. + + - `Index int64` + + The index of the tool call in the tool calls array. + + - `Type CodeInterpreter` + + The type of tool call. This is always going to be `code_interpreter` for this type of tool call. + + - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` + + - `ID string` + + The ID of the tool call. + + - `CodeInterpreter CodeInterpreterToolCallDeltaCodeInterpreter` + + The Code Interpreter tool call definition. + + - `Input string` + + The input to the Code Interpreter tool call. + + - `Outputs []CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion` + + 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. + + - `type CodeInterpreterLogs struct{…}` + + Text output from the Code Interpreter tool call as part of a run step. + + - `Index int64` + + The index of the output in the outputs array. + + - `Type Logs` + + Always `logs`. + + - `const LogsLogs Logs = "logs"` + + - `Logs string` + + The text output from the Code Interpreter tool call. + + - `type CodeInterpreterOutputImage struct{…}` + + - `Index int64` + + The index of the output in the outputs array. + + - `Type Image` + + Always `image`. + + - `const ImageImage Image = "image"` + + - `Image CodeInterpreterOutputImageImage` + + - `FileID string` + + The [file](https://platform.openai.com/docs/api-reference/files) ID of the image. + + - `type FileSearchToolCallDelta struct{…}` + + - `FileSearch any` + + For now, this is always going to be an empty object. + + - `Index int64` + + The index of the tool call in the tool calls array. + + - `Type FileSearch` + + The type of tool call. This is always going to be `file_search` for this type of tool call. + + - `const FileSearchFileSearch FileSearch = "file_search"` + + - `ID string` + + The ID of the tool call object. + + - `type FunctionToolCallDelta struct{…}` + + - `Index int64` + + 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. + + - `const FunctionFunction Function = "function"` + + - `ID string` + + The ID of the tool call object. + + - `Function FunctionToolCallDeltaFunction` + + 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 ThreadRunStepDelta` + + The object type, which is always `thread.run.step.delta`. + + - `const ThreadRunStepDeltaThreadRunStepDelta ThreadRunStepDelta = "thread.run.step.delta"` + +### Run Step Delta Message Delta + +- `type RunStepDeltaMessageDelta struct{…}` + + Details of the message creation by the run step. + + - `Type MessageCreation` + + Always `message_creation`. + + - `const MessageCreationMessageCreation MessageCreation = "message_creation"` + + - `MessageCreation RunStepDeltaMessageDeltaMessageCreation` + + - `MessageID string` + + The ID of the message that was created by this run step. + +### Run Step Include + +- `type RunStepInclude string` + + - `const RunStepIncludeStepDetailsToolCallsFileSearchResultsContent RunStepInclude = "step_details.tool_calls[*].file_search.results[*].content"` + +### Tool Call + +- `type ToolCallUnion interface{…}` + + Details of the Code Interpreter tool call the run step was involved in. + + - `type CodeInterpreterToolCall struct{…}` + + Details of the Code Interpreter tool call the run step was involved in. + + - `ID string` + + The ID of the tool call. + + - `CodeInterpreter CodeInterpreterToolCallCodeInterpreter` + + The Code Interpreter tool call definition. + + - `Input string` + + The input to the Code Interpreter tool call. + + - `Outputs []CodeInterpreterToolCallCodeInterpreterOutputUnion` + + 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. + + - `type CodeInterpreterToolCallCodeInterpreterOutputLogs struct{…}` + + 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`. + + - `const LogsLogs Logs = "logs"` + + - `type CodeInterpreterToolCallCodeInterpreterOutputImage struct{…}` + + - `Image CodeInterpreterToolCallCodeInterpreterOutputImageImage` + + - `FileID string` + + The [file](https://platform.openai.com/docs/api-reference/files) ID of the image. + + - `Type Image` + + Always `image`. + + - `const ImageImage Image = "image"` + + - `Type CodeInterpreter` + + The type of tool call. This is always going to be `code_interpreter` for this type of tool call. + + - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` + + - `type FileSearchToolCall struct{…}` + + - `ID string` + + The ID of the tool call object. + + - `FileSearch FileSearchToolCallFileSearch` + + For now, this is always going to be an empty object. + + - `RankingOptions FileSearchToolCallFileSearchRankingOptions` + + The ranking options for the file search. + + - `Ranker string` + + The ranker to use for the file search. If not specified will use the `auto` ranker. + + - `const FileSearchToolCallFileSearchRankingOptionsRankerAuto FileSearchToolCallFileSearchRankingOptionsRanker = "auto"` + + - `const FileSearchToolCallFileSearchRankingOptionsRankerDefault2024_08_21 FileSearchToolCallFileSearchRankingOptionsRanker = "default_2024_08_21"` + + - `ScoreThreshold float64` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `Results []FileSearchToolCallFileSearchResult` + + The results of the file search. + + - `FileID string` + + The ID of the file that result was found in. + + - `FileName string` + + The name of the file that result was found in. + + - `Score float64` + + The score of the result. All values must be a floating point number between 0 and 1. + + - `Content []FileSearchToolCallFileSearchResultContent` + + 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 string` + + The type of the content. + + - `const FileSearchToolCallFileSearchResultContentTypeText FileSearchToolCallFileSearchResultContentType = "text"` + + - `Type FileSearch` + + The type of tool call. This is always going to be `file_search` for this type of tool call. + + - `const FileSearchFileSearch FileSearch = "file_search"` + + - `type FunctionToolCall struct{…}` + + - `ID string` + + The ID of the tool call object. + + - `Function FunctionToolCallFunction` + + 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. + + - `const FunctionFunction Function = "function"` + +### Tool Call Delta + +- `type ToolCallDeltaUnion interface{…}` + + Details of the Code Interpreter tool call the run step was involved in. + + - `type CodeInterpreterToolCallDelta struct{…}` + + Details of the Code Interpreter tool call the run step was involved in. + + - `Index int64` + + The index of the tool call in the tool calls array. + + - `Type CodeInterpreter` + + The type of tool call. This is always going to be `code_interpreter` for this type of tool call. + + - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` + + - `ID string` + + The ID of the tool call. + + - `CodeInterpreter CodeInterpreterToolCallDeltaCodeInterpreter` + + The Code Interpreter tool call definition. + + - `Input string` + + The input to the Code Interpreter tool call. + + - `Outputs []CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion` + + 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. + + - `type CodeInterpreterLogs struct{…}` + + Text output from the Code Interpreter tool call as part of a run step. + + - `Index int64` + + The index of the output in the outputs array. + + - `Type Logs` + + Always `logs`. + + - `const LogsLogs Logs = "logs"` + + - `Logs string` + + The text output from the Code Interpreter tool call. + + - `type CodeInterpreterOutputImage struct{…}` + + - `Index int64` + + The index of the output in the outputs array. + + - `Type Image` + + Always `image`. + + - `const ImageImage Image = "image"` + + - `Image CodeInterpreterOutputImageImage` + + - `FileID string` + + The [file](https://platform.openai.com/docs/api-reference/files) ID of the image. + + - `type FileSearchToolCallDelta struct{…}` + + - `FileSearch any` + + For now, this is always going to be an empty object. + + - `Index int64` + + The index of the tool call in the tool calls array. + + - `Type FileSearch` + + The type of tool call. This is always going to be `file_search` for this type of tool call. + + - `const FileSearchFileSearch FileSearch = "file_search"` + + - `ID string` + + The ID of the tool call object. + + - `type FunctionToolCallDelta struct{…}` + + - `Index int64` + + 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. + + - `const FunctionFunction Function = "function"` + + - `ID string` + + The ID of the tool call object. + + - `Function FunctionToolCallDeltaFunction` + + 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 + +- `type ToolCallDeltaObject struct{…}` + + Details of the tool call. + + - `Type ToolCalls` + + Always `tool_calls`. + + - `const ToolCallsToolCalls ToolCalls = "tool_calls"` + + - `ToolCalls []ToolCallDeltaUnion` + + 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 CodeInterpreterToolCallDelta struct{…}` + + Details of the Code Interpreter tool call the run step was involved in. + + - `Index int64` + + The index of the tool call in the tool calls array. + + - `Type CodeInterpreter` + + The type of tool call. This is always going to be `code_interpreter` for this type of tool call. + + - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` + + - `ID string` + + The ID of the tool call. + + - `CodeInterpreter CodeInterpreterToolCallDeltaCodeInterpreter` + + The Code Interpreter tool call definition. + + - `Input string` + + The input to the Code Interpreter tool call. + + - `Outputs []CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion` + + 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. + + - `type CodeInterpreterLogs struct{…}` + + Text output from the Code Interpreter tool call as part of a run step. + + - `Index int64` + + The index of the output in the outputs array. + + - `Type Logs` + + Always `logs`. + + - `const LogsLogs Logs = "logs"` + + - `Logs string` + + The text output from the Code Interpreter tool call. + + - `type CodeInterpreterOutputImage struct{…}` + + - `Index int64` + + The index of the output in the outputs array. + + - `Type Image` + + Always `image`. + + - `const ImageImage Image = "image"` + + - `Image CodeInterpreterOutputImageImage` + + - `FileID string` + + The [file](https://platform.openai.com/docs/api-reference/files) ID of the image. + + - `type FileSearchToolCallDelta struct{…}` + + - `FileSearch any` + + For now, this is always going to be an empty object. + + - `Index int64` + + The index of the tool call in the tool calls array. + + - `Type FileSearch` + + The type of tool call. This is always going to be `file_search` for this type of tool call. + + - `const FileSearchFileSearch FileSearch = "file_search"` + + - `ID string` + + The ID of the tool call object. + + - `type FunctionToolCallDelta struct{…}` + + - `Index int64` + + 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. + + - `const FunctionFunction Function = "function"` + + - `ID string` + + The ID of the tool call object. + + - `Function FunctionToolCallDeltaFunction` + + 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 + +- `type ToolCallsStepDetails struct{…}` + + Details of the tool call. + + - `ToolCalls []ToolCallUnion` + + 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 CodeInterpreterToolCall struct{…}` + + Details of the Code Interpreter tool call the run step was involved in. + + - `ID string` + + The ID of the tool call. + + - `CodeInterpreter CodeInterpreterToolCallCodeInterpreter` + + The Code Interpreter tool call definition. + + - `Input string` + + The input to the Code Interpreter tool call. + + - `Outputs []CodeInterpreterToolCallCodeInterpreterOutputUnion` + + 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. + + - `type CodeInterpreterToolCallCodeInterpreterOutputLogs struct{…}` + + 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`. + + - `const LogsLogs Logs = "logs"` + + - `type CodeInterpreterToolCallCodeInterpreterOutputImage struct{…}` + + - `Image CodeInterpreterToolCallCodeInterpreterOutputImageImage` + + - `FileID string` + + The [file](https://platform.openai.com/docs/api-reference/files) ID of the image. + + - `Type Image` + + Always `image`. + + - `const ImageImage Image = "image"` + + - `Type CodeInterpreter` + + The type of tool call. This is always going to be `code_interpreter` for this type of tool call. + + - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` + + - `type FileSearchToolCall struct{…}` + + - `ID string` + + The ID of the tool call object. + + - `FileSearch FileSearchToolCallFileSearch` + + For now, this is always going to be an empty object. + + - `RankingOptions FileSearchToolCallFileSearchRankingOptions` + + The ranking options for the file search. + + - `Ranker string` + + The ranker to use for the file search. If not specified will use the `auto` ranker. + + - `const FileSearchToolCallFileSearchRankingOptionsRankerAuto FileSearchToolCallFileSearchRankingOptionsRanker = "auto"` + + - `const FileSearchToolCallFileSearchRankingOptionsRankerDefault2024_08_21 FileSearchToolCallFileSearchRankingOptionsRanker = "default_2024_08_21"` + + - `ScoreThreshold float64` + + The score threshold for the file search. All values must be a floating point number between 0 and 1. + + - `Results []FileSearchToolCallFileSearchResult` + + The results of the file search. + + - `FileID string` + + The ID of the file that result was found in. + + - `FileName string` + + The name of the file that result was found in. + + - `Score float64` + + The score of the result. All values must be a floating point number between 0 and 1. + + - `Content []FileSearchToolCallFileSearchResultContent` + + 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 string` + + The type of the content. + + - `const FileSearchToolCallFileSearchResultContentTypeText FileSearchToolCallFileSearchResultContentType = "text"` + + - `Type FileSearch` + + The type of tool call. This is always going to be `file_search` for this type of tool call. + + - `const FileSearchFileSearch FileSearch = "file_search"` + + - `type FunctionToolCall struct{…}` + + - `ID string` + + The ID of the tool call object. + + - `Function FunctionToolCallFunction` + + 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. + + - `const FunctionFunction Function = "function"` + + - `Type ToolCalls` + + Always `tool_calls`. + + - `const ToolCallsToolCalls ToolCalls = "tool_calls"` + +# Messages + +## List messages + +`client.Beta.Threads.Messages.List(ctx, threadID, query) (*CursorPage[Message], error)` + +**get** `/threads/{thread_id}/messages` + +Returns a list of messages for a given thread. + +### Parameters + +- `threadID string` + +- `query BetaThreadMessageListParams` + + - `After param.Field[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 param.Field[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 param.Field[int64]` + + A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + + - `Order param.Field[BetaThreadMessageListParamsOrder]` + + Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. + + - `const BetaThreadMessageListParamsOrderAsc BetaThreadMessageListParamsOrder = "asc"` + + - `const BetaThreadMessageListParamsOrderDesc BetaThreadMessageListParamsOrder = "desc"` + + - `RunID param.Field[string]` + + Filter messages by the run ID that generated them. + +### Returns + +- `type Message struct{…}` + + 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. + + - `AssistantID string` + + If applicable, the ID of the [assistant](https://platform.openai.com/docs/api-reference/assistants) that authored this message. + + - `Attachments []MessageAttachment` + + A list of files attached to the message, and the tools they were added to. + + - `FileID string` + + The ID of the file to attach to the message. + + - `Tools []MessageAttachmentToolUnion` + + The tools to add this file to. + + - `type CodeInterpreterTool struct{…}` + + - `Type CodeInterpreter` + + The type of tool being defined: `code_interpreter` + + - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` + + - `type MessageAttachmentToolAssistantToolsFileSearchTypeOnly struct{…}` + + - `Type FileSearch` + + The type of tool being defined: `file_search` + + - `const FileSearchFileSearch FileSearch = "file_search"` + + - `CompletedAt int64` + + The Unix timestamp (in seconds) for when the message was completed. + + - `Content []MessageContentUnion` + + The content of the message in array of text and/or images. + + - `type ImageFileContentBlock struct{…}` + + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. + + - `ImageFile ImageFile` + + - `FileID 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 ImageFileDetail` + + 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`. + + - `const ImageFileDetailAuto ImageFileDetail = "auto"` + + - `const ImageFileDetailLow ImageFileDetail = "low"` + + - `const ImageFileDetailHigh ImageFileDetail = "high"` + + - `Type ImageFile` + + Always `image_file`. + + - `const ImageFileImageFile ImageFile = "image_file"` + + - `type ImageURLContentBlock struct{…}` + + References an image URL in the content of a message. + + - `ImageURL ImageURL` + + - `URL string` + + The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. + + - `Detail ImageURLDetail` + + Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` + + - `const ImageURLDetailAuto ImageURLDetail = "auto"` + + - `const ImageURLDetailLow ImageURLDetail = "low"` + + - `const ImageURLDetailHigh ImageURLDetail = "high"` + + - `Type ImageURL` + + The type of the content part. + + - `const ImageURLImageURL ImageURL = "image_url"` + + - `type TextContentBlock struct{…}` + + The text content that is part of a message. + + - `Text Text` + + - `Annotations []AnnotationUnion` + + - `type FileCitationAnnotation struct{…}` + + 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. + + - `EndIndex int64` + + - `FileCitation FileCitationAnnotationFileCitation` + + - `FileID string` + + The ID of the specific File the citation is from. + + - `StartIndex int64` + + - `Text string` + + The text in the message content that needs to be replaced. + + - `Type FileCitation` + + Always `file_citation`. + + - `const FileCitationFileCitation FileCitation = "file_citation"` + + - `type FilePathAnnotation struct{…}` + + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + + - `EndIndex int64` + + - `FilePath FilePathAnnotationFilePath` + + - `FileID string` + + The ID of the file that was generated. + + - `StartIndex int64` + + - `Text string` + + The text in the message content that needs to be replaced. + + - `Type FilePath` + + Always `file_path`. + + - `const FilePathFilePath FilePath = "file_path"` + + - `Value string` + + The data that makes up the text. + + - `Type Text` + + Always `text`. + + - `const TextText Text = "text"` + + - `type RefusalContentBlock struct{…}` + + The refusal content generated by the assistant. + + - `Refusal string` + + - `Type Refusal` + + Always `refusal`. + + - `const RefusalRefusal Refusal = "refusal"` + + - `CreatedAt int64` + + The Unix timestamp (in seconds) for when the message was created. + + - `IncompleteAt int64` + + The Unix timestamp (in seconds) for when the message was marked as incomplete. + + - `IncompleteDetails MessageIncompleteDetails` + + On an incomplete message, details about why the message is incomplete. + + - `Reason string` + + The reason the message is incomplete. + + - `const MessageIncompleteDetailsReasonContentFilter MessageIncompleteDetailsReason = "content_filter"` + + - `const MessageIncompleteDetailsReasonMaxTokens MessageIncompleteDetailsReason = "max_tokens"` + + - `const MessageIncompleteDetailsReasonRunCancelled MessageIncompleteDetailsReason = "run_cancelled"` + + - `const MessageIncompleteDetailsReasonRunExpired MessageIncompleteDetailsReason = "run_expired"` + + - `const MessageIncompleteDetailsReasonRunFailed MessageIncompleteDetailsReason = "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 ThreadMessage` + + The object type, which is always `thread.message`. + + - `const ThreadMessageThreadMessage ThreadMessage = "thread.message"` + + - `Role MessageRole` + + The entity that produced the message. One of `user` or `assistant`. + + - `const MessageRoleUser MessageRole = "user"` + + - `const MessageRoleAssistant MessageRole = "assistant"` + + - `RunID 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 MessageStatus` + + The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. + + - `const MessageStatusInProgress MessageStatus = "in_progress"` + + - `const MessageStatusIncomplete MessageStatus = "incomplete"` + + - `const MessageStatusCompleted MessageStatus = "completed"` + + - `ThreadID string` + + The [thread](https://platform.openai.com/docs/api-reference/threads) ID that this message belongs to. + +### Example + +```go +package main + +import ( + "context" + "fmt" + + "github.com/openai/openai-go" + "github.com/openai/openai-go/option" +) + +func main() { + client := openai.NewClient( + option.WithAPIKey("My API Key"), + ) + page, err := client.Beta.Threads.Messages.List( + context.TODO(), + "thread_id", + openai.BetaThreadMessageListParams{ + + }, + ) + if err != nil { + panic(err.Error()) + } + fmt.Printf("%+v\n", 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", + "object": "list" +} +``` + +## Create message + +`client.Beta.Threads.Messages.New(ctx, threadID, body) (*Message, error)` + +**post** `/threads/{thread_id}/messages` + +Create a message. + +### Parameters + +- `threadID string` + +- `body BetaThreadMessageNewParams` + + - `Content param.Field[BetaThreadMessageNewParamsContentUnion]` + + The text contents of the message. + + - `string` + + - `type BetaThreadMessageNewParamsContentArrayOfContentParts []MessageContentPartParamUnionResp` + + 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). + + - `type ImageFileContentBlock struct{…}` + + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. + + - `ImageFile ImageFile` + + - `FileID 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 ImageFileDetail` + + 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`. + + - `const ImageFileDetailAuto ImageFileDetail = "auto"` + + - `const ImageFileDetailLow ImageFileDetail = "low"` + + - `const ImageFileDetailHigh ImageFileDetail = "high"` + + - `Type ImageFile` + + Always `image_file`. + + - `const ImageFileImageFile ImageFile = "image_file"` + + - `type ImageURLContentBlock struct{…}` + + References an image URL in the content of a message. + + - `ImageURL ImageURL` + + - `URL string` + + The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. + + - `Detail ImageURLDetail` + + Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` + + - `const ImageURLDetailAuto ImageURLDetail = "auto"` + + - `const ImageURLDetailLow ImageURLDetail = "low"` + + - `const ImageURLDetailHigh ImageURLDetail = "high"` + + - `Type ImageURL` + + The type of the content part. + + - `const ImageURLImageURL ImageURL = "image_url"` + + - `type TextContentBlockParam struct{…}` + + The text content that is part of a message. + + - `Text string` + + Text content to be sent to the model + + - `Type Text` + + Always `text`. + + - `const TextText Text = "text"` + + - `Role param.Field[BetaThreadMessageNewParamsRole]` + + 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. + + - `const BetaThreadMessageNewParamsRoleUser BetaThreadMessageNewParamsRole = "user"` + + - `const BetaThreadMessageNewParamsRoleAssistant BetaThreadMessageNewParamsRole = "assistant"` + + - `Attachments param.Field[[]BetaThreadMessageNewParamsAttachment]` + + A list of files attached to the message, and the tools they should be added to. + + - `FileID string` + + The ID of the file to attach to the message. + + - `Tools []BetaThreadMessageNewParamsAttachmentToolUnion` + + The tools to add this file to. + + - `type CodeInterpreterTool struct{…}` + + - `Type CodeInterpreter` + + The type of tool being defined: `code_interpreter` + + - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` + + - `type BetaThreadMessageNewParamsAttachmentToolFileSearch struct{…}` + + - `Type FileSearch` + + The type of tool being defined: `file_search` + + - `const FileSearchFileSearch FileSearch = "file_search"` + + - `Metadata param.Field[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 + +- `type Message struct{…}` + + 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. + + - `AssistantID string` + + If applicable, the ID of the [assistant](https://platform.openai.com/docs/api-reference/assistants) that authored this message. + + - `Attachments []MessageAttachment` + + A list of files attached to the message, and the tools they were added to. + + - `FileID string` + + The ID of the file to attach to the message. + + - `Tools []MessageAttachmentToolUnion` + + The tools to add this file to. + + - `type CodeInterpreterTool struct{…}` + + - `Type CodeInterpreter` + + The type of tool being defined: `code_interpreter` + + - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` + + - `type MessageAttachmentToolAssistantToolsFileSearchTypeOnly struct{…}` + + - `Type FileSearch` + + The type of tool being defined: `file_search` + + - `const FileSearchFileSearch FileSearch = "file_search"` + + - `CompletedAt int64` + + The Unix timestamp (in seconds) for when the message was completed. + + - `Content []MessageContentUnion` + + The content of the message in array of text and/or images. + + - `type ImageFileContentBlock struct{…}` + + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. + + - `ImageFile ImageFile` + + - `FileID 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 ImageFileDetail` + + 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`. + + - `const ImageFileDetailAuto ImageFileDetail = "auto"` + + - `const ImageFileDetailLow ImageFileDetail = "low"` + + - `const ImageFileDetailHigh ImageFileDetail = "high"` + + - `Type ImageFile` + + Always `image_file`. + + - `const ImageFileImageFile ImageFile = "image_file"` + + - `type ImageURLContentBlock struct{…}` + + References an image URL in the content of a message. + + - `ImageURL ImageURL` + + - `URL string` + + The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. + + - `Detail ImageURLDetail` + + Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` + + - `const ImageURLDetailAuto ImageURLDetail = "auto"` + + - `const ImageURLDetailLow ImageURLDetail = "low"` + + - `const ImageURLDetailHigh ImageURLDetail = "high"` + + - `Type ImageURL` + + The type of the content part. + + - `const ImageURLImageURL ImageURL = "image_url"` + + - `type TextContentBlock struct{…}` + + The text content that is part of a message. + + - `Text Text` + + - `Annotations []AnnotationUnion` + + - `type FileCitationAnnotation struct{…}` + + 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. + + - `EndIndex int64` + + - `FileCitation FileCitationAnnotationFileCitation` + + - `FileID string` + + The ID of the specific File the citation is from. + + - `StartIndex int64` + + - `Text string` + + The text in the message content that needs to be replaced. + + - `Type FileCitation` + + Always `file_citation`. + + - `const FileCitationFileCitation FileCitation = "file_citation"` + + - `type FilePathAnnotation struct{…}` + + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + + - `EndIndex int64` + + - `FilePath FilePathAnnotationFilePath` + + - `FileID string` + + The ID of the file that was generated. + + - `StartIndex int64` + + - `Text string` + + The text in the message content that needs to be replaced. + + - `Type FilePath` + + Always `file_path`. + + - `const FilePathFilePath FilePath = "file_path"` + + - `Value string` + + The data that makes up the text. + + - `Type Text` + + Always `text`. + + - `const TextText Text = "text"` + + - `type RefusalContentBlock struct{…}` + + The refusal content generated by the assistant. + + - `Refusal string` + + - `Type Refusal` + + Always `refusal`. + + - `const RefusalRefusal Refusal = "refusal"` + + - `CreatedAt int64` + + The Unix timestamp (in seconds) for when the message was created. + + - `IncompleteAt int64` + + The Unix timestamp (in seconds) for when the message was marked as incomplete. + + - `IncompleteDetails MessageIncompleteDetails` + + On an incomplete message, details about why the message is incomplete. + + - `Reason string` + + The reason the message is incomplete. + + - `const MessageIncompleteDetailsReasonContentFilter MessageIncompleteDetailsReason = "content_filter"` + + - `const MessageIncompleteDetailsReasonMaxTokens MessageIncompleteDetailsReason = "max_tokens"` + + - `const MessageIncompleteDetailsReasonRunCancelled MessageIncompleteDetailsReason = "run_cancelled"` + + - `const MessageIncompleteDetailsReasonRunExpired MessageIncompleteDetailsReason = "run_expired"` + + - `const MessageIncompleteDetailsReasonRunFailed MessageIncompleteDetailsReason = "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 ThreadMessage` + + The object type, which is always `thread.message`. + + - `const ThreadMessageThreadMessage ThreadMessage = "thread.message"` + + - `Role MessageRole` + + The entity that produced the message. One of `user` or `assistant`. + + - `const MessageRoleUser MessageRole = "user"` + + - `const MessageRoleAssistant MessageRole = "assistant"` + + - `RunID 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 MessageStatus` + + The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. + + - `const MessageStatusInProgress MessageStatus = "in_progress"` + + - `const MessageStatusIncomplete MessageStatus = "incomplete"` + + - `const MessageStatusCompleted MessageStatus = "completed"` + + - `ThreadID string` + + The [thread](https://platform.openai.com/docs/api-reference/threads) ID that this message belongs to. + +### Example + +```go +package main + +import ( + "context" + "fmt" + + "github.com/openai/openai-go" + "github.com/openai/openai-go/option" +) + +func main() { + client := openai.NewClient( + option.WithAPIKey("My API Key"), + ) + message, err := client.Beta.Threads.Messages.New( + context.TODO(), + "thread_id", + openai.BetaThreadMessageNewParams{ + Content: openai.BetaThreadMessageNewParamsContentUnion{ + OfString: openai.String("string"), + }, + Role: openai.BetaThreadMessageNewParamsRoleUser, + }, + ) + if err != nil { + panic(err.Error()) + } + fmt.Printf("%+v\n", message.ID) +} +``` + +#### 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 + +`client.Beta.Threads.Messages.Update(ctx, threadID, messageID, body) (*Message, error)` + +**post** `/threads/{thread_id}/messages/{message_id}` + +Modifies a message. + +### Parameters + +- `threadID string` + +- `messageID string` + +- `body BetaThreadMessageUpdateParams` + + - `Metadata param.Field[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 + +- `type Message struct{…}` + + 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. + + - `AssistantID string` + + If applicable, the ID of the [assistant](https://platform.openai.com/docs/api-reference/assistants) that authored this message. + + - `Attachments []MessageAttachment` + + A list of files attached to the message, and the tools they were added to. + + - `FileID string` + + The ID of the file to attach to the message. + + - `Tools []MessageAttachmentToolUnion` + + The tools to add this file to. + + - `type CodeInterpreterTool struct{…}` + + - `Type CodeInterpreter` + + The type of tool being defined: `code_interpreter` + + - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` + + - `type MessageAttachmentToolAssistantToolsFileSearchTypeOnly struct{…}` + + - `Type FileSearch` + + The type of tool being defined: `file_search` + + - `const FileSearchFileSearch FileSearch = "file_search"` + + - `CompletedAt int64` + + The Unix timestamp (in seconds) for when the message was completed. + + - `Content []MessageContentUnion` + + The content of the message in array of text and/or images. + + - `type ImageFileContentBlock struct{…}` + + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. + + - `ImageFile ImageFile` + + - `FileID 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 ImageFileDetail` + + 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`. + + - `const ImageFileDetailAuto ImageFileDetail = "auto"` + + - `const ImageFileDetailLow ImageFileDetail = "low"` + + - `const ImageFileDetailHigh ImageFileDetail = "high"` + + - `Type ImageFile` + + Always `image_file`. + + - `const ImageFileImageFile ImageFile = "image_file"` + + - `type ImageURLContentBlock struct{…}` + + References an image URL in the content of a message. + + - `ImageURL ImageURL` + + - `URL string` + + The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. + + - `Detail ImageURLDetail` + + Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` + + - `const ImageURLDetailAuto ImageURLDetail = "auto"` + + - `const ImageURLDetailLow ImageURLDetail = "low"` + + - `const ImageURLDetailHigh ImageURLDetail = "high"` + + - `Type ImageURL` + + The type of the content part. + + - `const ImageURLImageURL ImageURL = "image_url"` + + - `type TextContentBlock struct{…}` + + The text content that is part of a message. + + - `Text Text` + + - `Annotations []AnnotationUnion` + + - `type FileCitationAnnotation struct{…}` + + 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. + + - `EndIndex int64` + + - `FileCitation FileCitationAnnotationFileCitation` + + - `FileID string` + + The ID of the specific File the citation is from. + + - `StartIndex int64` + + - `Text string` + + The text in the message content that needs to be replaced. + + - `Type FileCitation` + + Always `file_citation`. + + - `const FileCitationFileCitation FileCitation = "file_citation"` + + - `type FilePathAnnotation struct{…}` + + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + + - `EndIndex int64` + + - `FilePath FilePathAnnotationFilePath` + + - `FileID string` + + The ID of the file that was generated. + + - `StartIndex int64` + + - `Text string` + + The text in the message content that needs to be replaced. + + - `Type FilePath` + + Always `file_path`. + + - `const FilePathFilePath FilePath = "file_path"` + + - `Value string` + + The data that makes up the text. + + - `Type Text` + + Always `text`. + + - `const TextText Text = "text"` + + - `type RefusalContentBlock struct{…}` + + The refusal content generated by the assistant. + + - `Refusal string` + + - `Type Refusal` + + Always `refusal`. + + - `const RefusalRefusal Refusal = "refusal"` + + - `CreatedAt int64` + + The Unix timestamp (in seconds) for when the message was created. + + - `IncompleteAt int64` + + The Unix timestamp (in seconds) for when the message was marked as incomplete. + + - `IncompleteDetails MessageIncompleteDetails` + + On an incomplete message, details about why the message is incomplete. + + - `Reason string` + + The reason the message is incomplete. + + - `const MessageIncompleteDetailsReasonContentFilter MessageIncompleteDetailsReason = "content_filter"` + + - `const MessageIncompleteDetailsReasonMaxTokens MessageIncompleteDetailsReason = "max_tokens"` + + - `const MessageIncompleteDetailsReasonRunCancelled MessageIncompleteDetailsReason = "run_cancelled"` + + - `const MessageIncompleteDetailsReasonRunExpired MessageIncompleteDetailsReason = "run_expired"` + + - `const MessageIncompleteDetailsReasonRunFailed MessageIncompleteDetailsReason = "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 ThreadMessage` + + The object type, which is always `thread.message`. + + - `const ThreadMessageThreadMessage ThreadMessage = "thread.message"` + + - `Role MessageRole` + + The entity that produced the message. One of `user` or `assistant`. + + - `const MessageRoleUser MessageRole = "user"` + + - `const MessageRoleAssistant MessageRole = "assistant"` + + - `RunID 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 MessageStatus` + + The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. + + - `const MessageStatusInProgress MessageStatus = "in_progress"` + + - `const MessageStatusIncomplete MessageStatus = "incomplete"` + + - `const MessageStatusCompleted MessageStatus = "completed"` + + - `ThreadID string` + + The [thread](https://platform.openai.com/docs/api-reference/threads) ID that this message belongs to. + +### Example + +```go +package main + +import ( + "context" + "fmt" + + "github.com/openai/openai-go" + "github.com/openai/openai-go/option" +) + +func main() { + client := openai.NewClient( + option.WithAPIKey("My API Key"), + ) + message, err := client.Beta.Threads.Messages.Update( + context.TODO(), + "thread_id", + "message_id", + openai.BetaThreadMessageUpdateParams{ + + }, + ) + if err != nil { + panic(err.Error()) + } + fmt.Printf("%+v\n", message.ID) +} +``` + +#### 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 + +`client.Beta.Threads.Messages.Get(ctx, threadID, messageID) (*Message, error)` + +**get** `/threads/{thread_id}/messages/{message_id}` + +Retrieve a message. + +### Parameters + +- `threadID string` + +- `messageID string` + +### Returns + +- `type Message struct{…}` + + 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. + + - `AssistantID string` + + If applicable, the ID of the [assistant](https://platform.openai.com/docs/api-reference/assistants) that authored this message. + + - `Attachments []MessageAttachment` + + A list of files attached to the message, and the tools they were added to. + + - `FileID string` + + The ID of the file to attach to the message. + + - `Tools []MessageAttachmentToolUnion` + + The tools to add this file to. + + - `type CodeInterpreterTool struct{…}` + + - `Type CodeInterpreter` + + The type of tool being defined: `code_interpreter` + + - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` + + - `type MessageAttachmentToolAssistantToolsFileSearchTypeOnly struct{…}` + + - `Type FileSearch` + + The type of tool being defined: `file_search` + + - `const FileSearchFileSearch FileSearch = "file_search"` + + - `CompletedAt int64` + + The Unix timestamp (in seconds) for when the message was completed. + + - `Content []MessageContentUnion` + + The content of the message in array of text and/or images. + + - `type ImageFileContentBlock struct{…}` + + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. + + - `ImageFile ImageFile` + + - `FileID 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 ImageFileDetail` + + 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`. + + - `const ImageFileDetailAuto ImageFileDetail = "auto"` + + - `const ImageFileDetailLow ImageFileDetail = "low"` + + - `const ImageFileDetailHigh ImageFileDetail = "high"` + + - `Type ImageFile` + + Always `image_file`. + + - `const ImageFileImageFile ImageFile = "image_file"` + + - `type ImageURLContentBlock struct{…}` + + References an image URL in the content of a message. + + - `ImageURL ImageURL` + + - `URL string` + + The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. + + - `Detail ImageURLDetail` + + Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` + + - `const ImageURLDetailAuto ImageURLDetail = "auto"` + + - `const ImageURLDetailLow ImageURLDetail = "low"` + + - `const ImageURLDetailHigh ImageURLDetail = "high"` + + - `Type ImageURL` + + The type of the content part. + + - `const ImageURLImageURL ImageURL = "image_url"` + + - `type TextContentBlock struct{…}` + + The text content that is part of a message. + + - `Text Text` + + - `Annotations []AnnotationUnion` + + - `type FileCitationAnnotation struct{…}` + + 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. + + - `EndIndex int64` + + - `FileCitation FileCitationAnnotationFileCitation` + + - `FileID string` + + The ID of the specific File the citation is from. + + - `StartIndex int64` + + - `Text string` + + The text in the message content that needs to be replaced. + + - `Type FileCitation` + + Always `file_citation`. + + - `const FileCitationFileCitation FileCitation = "file_citation"` + + - `type FilePathAnnotation struct{…}` + + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + + - `EndIndex int64` + + - `FilePath FilePathAnnotationFilePath` + + - `FileID string` + + The ID of the file that was generated. + + - `StartIndex int64` + + - `Text string` + + The text in the message content that needs to be replaced. + + - `Type FilePath` + + Always `file_path`. + + - `const FilePathFilePath FilePath = "file_path"` + + - `Value string` + + The data that makes up the text. + + - `Type Text` + + Always `text`. + + - `const TextText Text = "text"` + + - `type RefusalContentBlock struct{…}` + + The refusal content generated by the assistant. + + - `Refusal string` + + - `Type Refusal` + + Always `refusal`. + + - `const RefusalRefusal Refusal = "refusal"` + + - `CreatedAt int64` + + The Unix timestamp (in seconds) for when the message was created. + + - `IncompleteAt int64` + + The Unix timestamp (in seconds) for when the message was marked as incomplete. + + - `IncompleteDetails MessageIncompleteDetails` + + On an incomplete message, details about why the message is incomplete. + + - `Reason string` + + The reason the message is incomplete. + + - `const MessageIncompleteDetailsReasonContentFilter MessageIncompleteDetailsReason = "content_filter"` + + - `const MessageIncompleteDetailsReasonMaxTokens MessageIncompleteDetailsReason = "max_tokens"` + + - `const MessageIncompleteDetailsReasonRunCancelled MessageIncompleteDetailsReason = "run_cancelled"` + + - `const MessageIncompleteDetailsReasonRunExpired MessageIncompleteDetailsReason = "run_expired"` + + - `const MessageIncompleteDetailsReasonRunFailed MessageIncompleteDetailsReason = "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 ThreadMessage` + + The object type, which is always `thread.message`. + + - `const ThreadMessageThreadMessage ThreadMessage = "thread.message"` + + - `Role MessageRole` + + The entity that produced the message. One of `user` or `assistant`. + + - `const MessageRoleUser MessageRole = "user"` + + - `const MessageRoleAssistant MessageRole = "assistant"` + + - `RunID 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 MessageStatus` + + The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. + + - `const MessageStatusInProgress MessageStatus = "in_progress"` + + - `const MessageStatusIncomplete MessageStatus = "incomplete"` + + - `const MessageStatusCompleted MessageStatus = "completed"` + + - `ThreadID string` + + The [thread](https://platform.openai.com/docs/api-reference/threads) ID that this message belongs to. + +### Example + +```go +package main + +import ( + "context" + "fmt" + + "github.com/openai/openai-go" + "github.com/openai/openai-go/option" +) + +func main() { + client := openai.NewClient( + option.WithAPIKey("My API Key"), + ) + message, err := client.Beta.Threads.Messages.Get( + context.TODO(), + "thread_id", + "message_id", + ) + if err != nil { + panic(err.Error()) + } + fmt.Printf("%+v\n", message.ID) +} +``` + +#### 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 + +`client.Beta.Threads.Messages.Delete(ctx, threadID, messageID) (*MessageDeleted, error)` + +**delete** `/threads/{thread_id}/messages/{message_id}` + +Deletes a message. + +### Parameters + +- `threadID string` + +- `messageID string` + +### Returns + +- `type MessageDeleted struct{…}` + + - `ID string` + + - `Deleted bool` + + - `Object ThreadMessageDeleted` + + - `const ThreadMessageDeletedThreadMessageDeleted ThreadMessageDeleted = "thread.message.deleted"` + +### Example + +```go +package main + +import ( + "context" + "fmt" + + "github.com/openai/openai-go" + "github.com/openai/openai-go/option" +) + +func main() { + client := openai.NewClient( + option.WithAPIKey("My API Key"), + ) + messageDeleted, err := client.Beta.Threads.Messages.Delete( + context.TODO(), + "thread_id", + "message_id", + ) + if err != nil { + panic(err.Error()) + } + fmt.Printf("%+v\n", messageDeleted.ID) +} +``` + +#### Response + +```json +{ + "id": "id", + "deleted": true, + "object": "thread.message.deleted" +} +``` + +## Domain Types + +### Annotation + +- `type AnnotationUnion interface{…}` + + 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. + + - `type FileCitationAnnotation struct{…}` + + 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. + + - `EndIndex int64` + + - `FileCitation FileCitationAnnotationFileCitation` + + - `FileID string` + + The ID of the specific File the citation is from. + + - `StartIndex int64` + + - `Text string` + + The text in the message content that needs to be replaced. + + - `Type FileCitation` + + Always `file_citation`. + + - `const FileCitationFileCitation FileCitation = "file_citation"` + + - `type FilePathAnnotation struct{…}` + + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + + - `EndIndex int64` + + - `FilePath FilePathAnnotationFilePath` + + - `FileID string` + + The ID of the file that was generated. + + - `StartIndex int64` + + - `Text string` + + The text in the message content that needs to be replaced. + + - `Type FilePath` + + Always `file_path`. + + - `const FilePathFilePath FilePath = "file_path"` + +### Annotation Delta + +- `type AnnotationDeltaUnion interface{…}` + + 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. + + - `type FileCitationDeltaAnnotation struct{…}` + + 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 int64` + + The index of the annotation in the text content part. + + - `Type FileCitation` + + Always `file_citation`. + + - `const FileCitationFileCitation FileCitation = "file_citation"` + + - `EndIndex int64` + + - `FileCitation FileCitationDeltaAnnotationFileCitation` + + - `FileID string` + + The ID of the specific File the citation is from. + + - `Quote string` + + The specific quote in the file. + + - `StartIndex int64` + + - `Text string` + + The text in the message content that needs to be replaced. + + - `type FilePathDeltaAnnotation struct{…}` + + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + + - `Index int64` + + The index of the annotation in the text content part. + + - `Type FilePath` + + Always `file_path`. + + - `const FilePathFilePath FilePath = "file_path"` + + - `EndIndex int64` + + - `FilePath FilePathDeltaAnnotationFilePath` + + - `FileID string` + + The ID of the file that was generated. + + - `StartIndex int64` + + - `Text string` + + The text in the message content that needs to be replaced. + +### File Citation Annotation + +- `type FileCitationAnnotation struct{…}` + + 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. + + - `EndIndex int64` + + - `FileCitation FileCitationAnnotationFileCitation` + + - `FileID string` + + The ID of the specific File the citation is from. + + - `StartIndex int64` + + - `Text string` + + The text in the message content that needs to be replaced. + + - `Type FileCitation` + + Always `file_citation`. + + - `const FileCitationFileCitation FileCitation = "file_citation"` + +### File Citation Delta Annotation + +- `type FileCitationDeltaAnnotation struct{…}` + + 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 int64` + + The index of the annotation in the text content part. + + - `Type FileCitation` - Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. + Always `file_citation`. - - `const BetaThreadMessageListParamsOrderAsc BetaThreadMessageListParamsOrder = "asc"` + - `const FileCitationFileCitation FileCitation = "file_citation"` - - `const BetaThreadMessageListParamsOrderDesc BetaThreadMessageListParamsOrder = "desc"` + - `EndIndex int64` - - `RunID param.Field[string]` + - `FileCitation FileCitationDeltaAnnotationFileCitation` - Filter messages by the run ID that generated them. + - `FileID string` -### Returns + The ID of the specific File the citation is from. -- `type Message struct{…}` + - `Quote string` - Represents a message within a [thread](https://platform.openai.com/docs/api-reference/threads). + The specific quote in the file. - - `ID string` + - `StartIndex int64` - The identifier, which can be referenced in API endpoints. + - `Text string` - - `AssistantID string` + The text in the message content that needs to be replaced. - If applicable, the ID of the [assistant](https://platform.openai.com/docs/api-reference/assistants) that authored this message. +### File Path Annotation - - `Attachments []MessageAttachment` +- `type FilePathAnnotation struct{…}` - A list of files attached to the message, and the tools they were added to. + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - - `FileID string` + - `EndIndex int64` - The ID of the file to attach to the message. + - `FilePath FilePathAnnotationFilePath` - - `Tools []MessageAttachmentToolUnion` + - `FileID string` - The tools to add this file to. + The ID of the file that was generated. - - `type CodeInterpreterTool struct{…}` + - `StartIndex int64` - - `Type CodeInterpreter` + - `Text string` - The type of tool being defined: `code_interpreter` + The text in the message content that needs to be replaced. - - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` + - `Type FilePath` - - `type MessageAttachmentToolAssistantToolsFileSearchTypeOnly struct{…}` + Always `file_path`. - - `Type FileSearch` + - `const FilePathFilePath FilePath = "file_path"` - The type of tool being defined: `file_search` +### File Path Delta Annotation - - `const FileSearchFileSearch FileSearch = "file_search"` +- `type FilePathDeltaAnnotation struct{…}` - - `CompletedAt int64` + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - The Unix timestamp (in seconds) for when the message was completed. + - `Index int64` - - `Content []any` + The index of the annotation in the text content part. - The content of the message in array of text and/or images. + - `Type FilePath` - - `CreatedAt int64` + Always `file_path`. - The Unix timestamp (in seconds) for when the message was created. + - `const FilePathFilePath FilePath = "file_path"` - - `IncompleteAt int64` + - `EndIndex int64` - The Unix timestamp (in seconds) for when the message was marked as incomplete. + - `FilePath FilePathDeltaAnnotationFilePath` - - `IncompleteDetails MessageIncompleteDetails` + - `FileID string` - On an incomplete message, details about why the message is incomplete. + The ID of the file that was generated. - - `Reason string` + - `StartIndex int64` - The reason the message is incomplete. + - `Text string` - - `const MessageIncompleteDetailsReasonContentFilter MessageIncompleteDetailsReason = "content_filter"` + The text in the message content that needs to be replaced. - - `const MessageIncompleteDetailsReasonMaxTokens MessageIncompleteDetailsReason = "max_tokens"` +### Image File - - `const MessageIncompleteDetailsReasonRunCancelled MessageIncompleteDetailsReason = "run_cancelled"` +- `type ImageFile struct{…}` - - `const MessageIncompleteDetailsReasonRunExpired MessageIncompleteDetailsReason = "run_expired"` + - `FileID string` - - `const MessageIncompleteDetailsReasonRunFailed MessageIncompleteDetailsReason = "run_failed"` + 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. - - `Metadata Metadata` + - `Detail ImageFileDetail` - 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. + 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`. - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. + - `const ImageFileDetailAuto ImageFileDetail = "auto"` - - `Object ThreadMessage` + - `const ImageFileDetailLow ImageFileDetail = "low"` - The object type, which is always `thread.message`. + - `const ImageFileDetailHigh ImageFileDetail = "high"` - - `const ThreadMessageThreadMessage ThreadMessage = "thread.message"` +### Image File Content Block - - `Role MessageRole` +- `type ImageFileContentBlock struct{…}` - The entity that produced the message. One of `user` or `assistant`. + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. - - `const MessageRoleUser MessageRole = "user"` + - `ImageFile ImageFile` - - `const MessageRoleAssistant MessageRole = "assistant"` + - `FileID string` - - `RunID 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. - 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. + - `Detail ImageFileDetail` - - `Status MessageStatus` + 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 status of the message, which can be either `in_progress`, `incomplete`, or `completed`. + - `const ImageFileDetailAuto ImageFileDetail = "auto"` - - `const MessageStatusInProgress MessageStatus = "in_progress"` + - `const ImageFileDetailLow ImageFileDetail = "low"` - - `const MessageStatusIncomplete MessageStatus = "incomplete"` + - `const ImageFileDetailHigh ImageFileDetail = "high"` - - `const MessageStatusCompleted MessageStatus = "completed"` + - `Type ImageFile` - - `ThreadID string` + Always `image_file`. - The [thread](https://platform.openai.com/docs/api-reference/threads) ID that this message belongs to. + - `const ImageFileImageFile ImageFile = "image_file"` -### Example +### Image File Delta -```go -package main +- `type ImageFileDelta struct{…}` -import ( - "context" - "fmt" + - `Detail ImageFileDeltaDetail` - "github.com/openai/openai-go" - "github.com/openai/openai-go/option" -) + 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`. -func main() { - client := openai.NewClient( - option.WithAPIKey("My API Key"), - ) - page, err := client.Beta.Threads.Messages.List( - context.TODO(), - "thread_id", - openai.BetaThreadMessageListParams{ + - `const ImageFileDeltaDetailAuto ImageFileDeltaDetail = "auto"` - }, - ) - if err != nil { - panic(err.Error()) - } - fmt.Printf("%+v\n", page) -} -``` + - `const ImageFileDeltaDetailLow ImageFileDeltaDetail = "low"` -#### Response + - `const ImageFileDeltaDetailHigh ImageFileDeltaDetail = "high"` -```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" - } - ], - "first_id": "msg_abc123", - "has_more": false, - "last_id": "msg_abc123", - "object": "list" -} -``` + - `FileID string` -## Create 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. -`client.Beta.Threads.Messages.New(ctx, threadID, body) (*Message, error)` +### Image File Delta Block -**post** `/threads/{thread_id}/messages` +- `type ImageFileDeltaBlock struct{…}` -Create message + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. -### Parameters + - `Index int64` -- `threadID string` + The index of the content part in the message. -- `body BetaThreadMessageNewParams` + - `Type ImageFile` - - `Content param.Field[BetaThreadMessageNewParamsContentUnion]` + Always `image_file`. - The text contents of the message. + - `const ImageFileImageFile ImageFile = "image_file"` - - `string` + - `ImageFile ImageFileDelta` - - `type BetaThreadMessageNewParamsContentArrayOfContentParts []MessageContentPartParamUnionResp` + - `Detail ImageFileDeltaDetail` - 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). + 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`. - - `type ImageFileContentBlockParam struct{…}` + - `const ImageFileDeltaDetailAuto ImageFileDeltaDetail = "auto"` - References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. + - `const ImageFileDeltaDetailLow ImageFileDeltaDetail = "low"` - - `ImageFile ImageFile` + - `const ImageFileDeltaDetailHigh ImageFileDeltaDetail = "high"` - `FileID 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 ImageFileDetail` +### Image URL - 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`. +- `type ImageURL struct{…}` - - `const ImageFileDetailAuto ImageFileDetail = "auto"` + - `URL string` - - `const ImageFileDetailLow ImageFileDetail = "low"` + The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. - - `const ImageFileDetailHigh ImageFileDetail = "high"` + - `Detail ImageURLDetail` - - `Type ImageFile` + 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 `image_file`. + - `const ImageURLDetailAuto ImageURLDetail = "auto"` - - `const ImageFileImageFile ImageFile = "image_file"` + - `const ImageURLDetailLow ImageURLDetail = "low"` + + - `const ImageURLDetailHigh ImageURLDetail = "high"` + +### Image URL Content Block - - `type ImageURLContentBlockParam struct{…}` +- `type ImageURLContentBlock struct{…}` References an image URL in the content of a message. @@ -6382,73 +10198,61 @@ Create message - `Type ImageURL` - The type of the content part. - - - `const ImageURLImageURL ImageURL = "image_url"` - - - `type TextContentBlockParam struct{…}` - - The text content that is part of a message. - - - `Text string` + The type of the content part. - Text content to be sent to the model + - `const ImageURLImageURL ImageURL = "image_url"` - - `Type Text` +### Image URL Delta - Always `text`. +- `type ImageURLDelta struct{…}` - - `const TextText Text = "text"` + - `Detail ImageURLDeltaDetail` - - `Role param.Field[BetaThreadMessageNewParamsRole]` + 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: + - `const ImageURLDeltaDetailAuto ImageURLDeltaDetail = "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. + - `const ImageURLDeltaDetailLow ImageURLDeltaDetail = "low"` - - `const BetaThreadMessageNewParamsRoleUser BetaThreadMessageNewParamsRole = "user"` + - `const ImageURLDeltaDetailHigh ImageURLDeltaDetail = "high"` - - `const BetaThreadMessageNewParamsRoleAssistant BetaThreadMessageNewParamsRole = "assistant"` + - `URL string` - - `Attachments param.Field[[]BetaThreadMessageNewParamsAttachment]` + 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 - - `FileID string` +- `type ImageURLDeltaBlock struct{…}` - The ID of the file to attach to the message. + References an image URL in the content of a message. - - `Tools []BetaThreadMessageNewParamsAttachmentToolUnion` + - `Index int64` - The tools to add this file to. + The index of the content part in the message. - - `type CodeInterpreterTool struct{…}` + - `Type ImageURL` - - `Type CodeInterpreter` + Always `image_url`. - The type of tool being defined: `code_interpreter` + - `const ImageURLImageURL ImageURL = "image_url"` - - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` + - `ImageURL ImageURLDelta` - - `type BetaThreadMessageNewParamsAttachmentToolFileSearch struct{…}` + - `Detail ImageURLDeltaDetail` - - `Type FileSearch` + 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` + - `const ImageURLDeltaDetailAuto ImageURLDeltaDetail = "auto"` - - `const FileSearchFileSearch FileSearch = "file_search"` + - `const ImageURLDeltaDetailLow ImageURLDeltaDetail = "low"` - - `Metadata param.Field[Metadata]` + - `const ImageURLDeltaDetailHigh ImageURLDeltaDetail = "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 - `type Message struct{…}` @@ -6494,221 +10298,139 @@ Create message The Unix timestamp (in seconds) for when the message was completed. - - `Content []any` + - `Content []MessageContentUnion` The content of the message in array of text and/or images. - - `CreatedAt int64` - - The Unix timestamp (in seconds) for when the message was created. - - - `IncompleteAt int64` - - The Unix timestamp (in seconds) for when the message was marked as incomplete. - - - `IncompleteDetails MessageIncompleteDetails` - - On an incomplete message, details about why the message is incomplete. - - - `Reason string` - - The reason the message is incomplete. - - - `const MessageIncompleteDetailsReasonContentFilter MessageIncompleteDetailsReason = "content_filter"` - - - `const MessageIncompleteDetailsReasonMaxTokens MessageIncompleteDetailsReason = "max_tokens"` - - - `const MessageIncompleteDetailsReasonRunCancelled MessageIncompleteDetailsReason = "run_cancelled"` + - `type ImageFileContentBlock struct{…}` - - `const MessageIncompleteDetailsReasonRunExpired MessageIncompleteDetailsReason = "run_expired"` + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. - - `const MessageIncompleteDetailsReasonRunFailed MessageIncompleteDetailsReason = "run_failed"` + - `ImageFile ImageFile` - - `Metadata Metadata` + - `FileID string` - 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 [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. - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. + - `Detail ImageFileDetail` - - `Object ThreadMessage` + 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 object type, which is always `thread.message`. + - `const ImageFileDetailAuto ImageFileDetail = "auto"` - - `const ThreadMessageThreadMessage ThreadMessage = "thread.message"` + - `const ImageFileDetailLow ImageFileDetail = "low"` - - `Role MessageRole` + - `const ImageFileDetailHigh ImageFileDetail = "high"` - The entity that produced the message. One of `user` or `assistant`. + - `Type ImageFile` - - `const MessageRoleUser MessageRole = "user"` + Always `image_file`. - - `const MessageRoleAssistant MessageRole = "assistant"` + - `const ImageFileImageFile ImageFile = "image_file"` - - `RunID string` + - `type ImageURLContentBlock struct{…}` - 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. + References an image URL in the content of a message. - - `Status MessageStatus` + - `ImageURL ImageURL` - The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. + - `URL string` - - `const MessageStatusInProgress MessageStatus = "in_progress"` + The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. - - `const MessageStatusIncomplete MessageStatus = "incomplete"` + - `Detail ImageURLDetail` - - `const MessageStatusCompleted MessageStatus = "completed"` + Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` - - `ThreadID string` + - `const ImageURLDetailAuto ImageURLDetail = "auto"` - The [thread](https://platform.openai.com/docs/api-reference/threads) ID that this message belongs to. + - `const ImageURLDetailLow ImageURLDetail = "low"` -### Example + - `const ImageURLDetailHigh ImageURLDetail = "high"` -```go -package main + - `Type ImageURL` -import ( - "context" - "fmt" + The type of the content part. - "github.com/openai/openai-go" - "github.com/openai/openai-go/option" -) + - `const ImageURLImageURL ImageURL = "image_url"` -func main() { - client := openai.NewClient( - option.WithAPIKey("My API Key"), - ) - message, err := client.Beta.Threads.Messages.New( - context.TODO(), - "thread_id", - openai.BetaThreadMessageNewParams{ - Content: openai.BetaThreadMessageNewParamsContentUnion{ - OfString: openai.String("string"), - }, - Role: openai.BetaThreadMessageNewParamsRoleUser, - }, - ) - if err != nil { - panic(err.Error()) - } - fmt.Printf("%+v\n", message.ID) -} -``` + - `type TextContentBlock struct{…}` -#### Response + The text content that is part of a message. -```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" -} -``` + - `Text Text` -## Modify message + - `Annotations []AnnotationUnion` -`client.Beta.Threads.Messages.Update(ctx, threadID, messageID, body) (*Message, error)` + - `type FileCitationAnnotation struct{…}` -**post** `/threads/{thread_id}/messages/{message_id}` + 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. -Modify message + - `EndIndex int64` -### Parameters + - `FileCitation FileCitationAnnotationFileCitation` -- `threadID string` + - `FileID string` -- `messageID string` + The ID of the specific File the citation is from. -- `body BetaThreadMessageUpdateParams` + - `StartIndex int64` - - `Metadata param.Field[Metadata]` + - `Text string` - 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 text in the message content that needs to be replaced. - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. + - `Type FileCitation` -### Returns + Always `file_citation`. -- `type Message struct{…}` + - `const FileCitationFileCitation FileCitation = "file_citation"` - Represents a message within a [thread](https://platform.openai.com/docs/api-reference/threads). + - `type FilePathAnnotation struct{…}` - - `ID string` + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - The identifier, which can be referenced in API endpoints. + - `EndIndex int64` - - `AssistantID string` + - `FilePath FilePathAnnotationFilePath` - If applicable, the ID of the [assistant](https://platform.openai.com/docs/api-reference/assistants) that authored this message. + - `FileID string` - - `Attachments []MessageAttachment` + The ID of the file that was generated. - A list of files attached to the message, and the tools they were added to. + - `StartIndex int64` - - `FileID string` + - `Text string` - The ID of the file to attach to the message. + The text in the message content that needs to be replaced. - - `Tools []MessageAttachmentToolUnion` + - `Type FilePath` - The tools to add this file to. + Always `file_path`. - - `type CodeInterpreterTool struct{…}` + - `const FilePathFilePath FilePath = "file_path"` - - `Type CodeInterpreter` + - `Value string` - The type of tool being defined: `code_interpreter` + The data that makes up the text. - - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` + - `Type Text` - - `type MessageAttachmentToolAssistantToolsFileSearchTypeOnly struct{…}` + Always `text`. - - `Type FileSearch` + - `const TextText Text = "text"` - The type of tool being defined: `file_search` + - `type RefusalContentBlock struct{…}` - - `const FileSearchFileSearch FileSearch = "file_search"` + The refusal content generated by the assistant. - - `CompletedAt int64` + - `Refusal string` - The Unix timestamp (in seconds) for when the message was completed. + - `Type Refusal` - - `Content []any` + Always `refusal`. - The content of the message in array of text and/or images. + - `const RefusalRefusal Refusal = "refusal"` - `CreatedAt int64` @@ -6777,374 +10499,197 @@ Modify message The [thread](https://platform.openai.com/docs/api-reference/threads) ID that this message belongs to. -### Example - -```go -package main - -import ( - "context" - "fmt" - - "github.com/openai/openai-go" - "github.com/openai/openai-go/option" -) - -func main() { - client := openai.NewClient( - option.WithAPIKey("My API Key"), - ) - message, err := client.Beta.Threads.Messages.Update( - context.TODO(), - "thread_id", - "message_id", - openai.BetaThreadMessageUpdateParams{ - - }, - ) - if err != nil { - panic(err.Error()) - } - fmt.Printf("%+v\n", message.ID) -} -``` - -#### 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 - -`client.Beta.Threads.Messages.Get(ctx, threadID, messageID) (*Message, error)` - -**get** `/threads/{thread_id}/messages/{message_id}` - -Retrieve message - -### Parameters - -- `threadID string` - -- `messageID string` - -### Returns - -- `type Message struct{…}` - - 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. +- `type MessageContentUnion interface{…}` - - `AssistantID 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. + - `type ImageFileContentBlock struct{…}` - - `Attachments []MessageAttachment` + 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. + - `ImageFile ImageFile` - `FileID string` - The ID of the file to attach to the message. - - - `Tools []MessageAttachmentToolUnion` - - The tools to add this file to. - - - `type CodeInterpreterTool struct{…}` - - - `Type CodeInterpreter` - - The type of tool being defined: `code_interpreter` - - - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` - - - `type MessageAttachmentToolAssistantToolsFileSearchTypeOnly struct{…}` - - - `Type FileSearch` + 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 tool being defined: `file_search` + - `Detail ImageFileDetail` - - `const FileSearchFileSearch FileSearch = "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`. - - `CompletedAt int64` + - `const ImageFileDetailAuto ImageFileDetail = "auto"` - The Unix timestamp (in seconds) for when the message was completed. + - `const ImageFileDetailLow ImageFileDetail = "low"` - - `Content []any` + - `const ImageFileDetailHigh ImageFileDetail = "high"` - The content of the message in array of text and/or images. + - `Type ImageFile` - - `CreatedAt int64` + Always `image_file`. - The Unix timestamp (in seconds) for when the message was created. + - `const ImageFileImageFile ImageFile = "image_file"` - - `IncompleteAt int64` + - `type ImageURLContentBlock struct{…}` - The Unix timestamp (in seconds) for when the message was marked as incomplete. + References an image URL in the content of a message. - - `IncompleteDetails MessageIncompleteDetails` + - `ImageURL ImageURL` - On an incomplete message, details about why the message is incomplete. + - `URL string` - - `Reason string` + The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. - The reason the message is incomplete. + - `Detail ImageURLDetail` - - `const MessageIncompleteDetailsReasonContentFilter MessageIncompleteDetailsReason = "content_filter"` + Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` - - `const MessageIncompleteDetailsReasonMaxTokens MessageIncompleteDetailsReason = "max_tokens"` + - `const ImageURLDetailAuto ImageURLDetail = "auto"` - - `const MessageIncompleteDetailsReasonRunCancelled MessageIncompleteDetailsReason = "run_cancelled"` + - `const ImageURLDetailLow ImageURLDetail = "low"` - - `const MessageIncompleteDetailsReasonRunExpired MessageIncompleteDetailsReason = "run_expired"` + - `const ImageURLDetailHigh ImageURLDetail = "high"` - - `const MessageIncompleteDetailsReasonRunFailed MessageIncompleteDetailsReason = "run_failed"` + - `Type ImageURL` - - `Metadata Metadata` + The type of the content part. - 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. + - `const ImageURLImageURL ImageURL = "image_url"` - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. + - `type TextContentBlock struct{…}` - - `Object ThreadMessage` + The text content that is part of a message. - The object type, which is always `thread.message`. + - `Text Text` - - `const ThreadMessageThreadMessage ThreadMessage = "thread.message"` + - `Annotations []AnnotationUnion` - - `Role MessageRole` + - `type FileCitationAnnotation struct{…}` - The entity that produced the message. One of `user` or `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. - - `const MessageRoleUser MessageRole = "user"` + - `EndIndex int64` - - `const MessageRoleAssistant MessageRole = "assistant"` + - `FileCitation FileCitationAnnotationFileCitation` - - `RunID string` + - `FileID 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. + The ID of the specific File the citation is from. - - `Status MessageStatus` + - `StartIndex int64` - The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. + - `Text string` - - `const MessageStatusInProgress MessageStatus = "in_progress"` + The text in the message content that needs to be replaced. - - `const MessageStatusIncomplete MessageStatus = "incomplete"` + - `Type FileCitation` - - `const MessageStatusCompleted MessageStatus = "completed"` + Always `file_citation`. - - `ThreadID string` + - `const FileCitationFileCitation FileCitation = "file_citation"` - The [thread](https://platform.openai.com/docs/api-reference/threads) ID that this message belongs to. + - `type FilePathAnnotation struct{…}` -### Example + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. -```go -package main + - `EndIndex int64` -import ( - "context" - "fmt" + - `FilePath FilePathAnnotationFilePath` - "github.com/openai/openai-go" - "github.com/openai/openai-go/option" -) + - `FileID string` -func main() { - client := openai.NewClient( - option.WithAPIKey("My API Key"), - ) - message, err := client.Beta.Threads.Messages.Get( - context.TODO(), - "thread_id", - "message_id", - ) - if err != nil { - panic(err.Error()) - } - fmt.Printf("%+v\n", message.ID) -} -``` + The ID of the file that was generated. -#### Response + - `StartIndex int64` -```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" -} -``` + - `Text string` -## Delete message + The text in the message content that needs to be replaced. -`client.Beta.Threads.Messages.Delete(ctx, threadID, messageID) (*MessageDeleted, error)` + - `Type FilePath` -**delete** `/threads/{thread_id}/messages/{message_id}` + Always `file_path`. -Delete message + - `const FilePathFilePath FilePath = "file_path"` -### Parameters + - `Value string` -- `threadID string` + The data that makes up the text. -- `messageID string` + - `Type Text` -### Returns + Always `text`. -- `type MessageDeleted struct{…}` + - `const TextText Text = "text"` - - `ID string` + - `type RefusalContentBlock struct{…}` - - `Deleted bool` + The refusal content generated by the assistant. - - `Object ThreadMessageDeleted` + - `Refusal string` - - `const ThreadMessageDeletedThreadMessageDeleted ThreadMessageDeleted = "thread.message.deleted"` + - `Type Refusal` -### Example + Always `refusal`. -```go -package main + - `const RefusalRefusal Refusal = "refusal"` -import ( - "context" - "fmt" +### Message Content Delta - "github.com/openai/openai-go" - "github.com/openai/openai-go/option" -) +- `type MessageContentDeltaUnion interface{…}` -func main() { - client := openai.NewClient( - option.WithAPIKey("My API Key"), - ) - messageDeleted, err := client.Beta.Threads.Messages.Delete( - context.TODO(), - "thread_id", - "message_id", - ) - if err != nil { - panic(err.Error()) - } - fmt.Printf("%+v\n", messageDeleted.ID) -} -``` + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. -#### Response + - `type ImageFileDeltaBlock struct{…}` -```json -{ - "id": "id", - "deleted": true, - "object": "thread.message.deleted" -} -``` + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. -## Domain Types + - `Index int64` -### Annotation + The index of the content part in the message. -- `type Annotation interface{…}` + - `Type ImageFile` -### Annotation Delta + Always `image_file`. -- `type AnnotationDelta interface{…}` + - `const ImageFileImageFile ImageFile = "image_file"` -### File Citation Annotation + - `ImageFile ImageFileDelta` -- `type FileCitationAnnotation struct{…}` + - `Detail ImageFileDeltaDetail` - 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. + 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`. - - `EndIndex int64` + - `const ImageFileDeltaDetailAuto ImageFileDeltaDetail = "auto"` - - `FileCitation FileCitationAnnotationFileCitation` + - `const ImageFileDeltaDetailLow ImageFileDeltaDetail = "low"` + + - `const ImageFileDeltaDetailHigh ImageFileDeltaDetail = "high"` - `FileID 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. - - `StartIndex int64` + - `type TextDeltaBlock struct{…}` - - `Text string` + The text content that is part of a message. - The text in the message content that needs to be replaced. + - `Index int64` - - `Type FileCitation` + The index of the content part in the message. - Always `file_citation`. + - `Type Text` - - `const FileCitationFileCitation FileCitation = "file_citation"` + Always `text`. -### File Citation Delta Annotation + - `const TextText Text = "text"` -- `type FileCitationDeltaAnnotation struct{…}` + - `Text TextDelta` + + - `Annotations []AnnotationDeltaUnion` + + - `type FileCitationDeltaAnnotation struct{…}` 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. @@ -7176,15 +10721,23 @@ func main() { The text in the message content that needs to be replaced. -### File Path Annotation - -- `type FilePathAnnotation struct{…}` + - `type FilePathDeltaAnnotation struct{…}` A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + - `Index int64` + + The index of the annotation in the text content part. + + - `Type FilePath` + + Always `file_path`. + + - `const FilePathFilePath FilePath = "file_path"` + - `EndIndex int64` - - `FilePath FilePathAnnotationFilePath` + - `FilePath FilePathDeltaAnnotationFilePath` - `FileID string` @@ -7196,63 +10749,63 @@ func main() { The text in the message content that needs to be replaced. - - `Type FilePath` + - `Value string` - Always `file_path`. + The data that makes up the text. - - `const FilePathFilePath FilePath = "file_path"` + - `type RefusalDeltaBlock struct{…}` -### File Path Delta Annotation + The refusal content that is part of a message. -- `type FilePathDeltaAnnotation struct{…}` + - `Index int64` - A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + The index of the refusal part in the message. - - `Index int64` + - `Type Refusal` - The index of the annotation in the text content part. + Always `refusal`. - - `Type FilePath` + - `const RefusalRefusal Refusal = "refusal"` - Always `file_path`. + - `Refusal string` - - `const FilePathFilePath FilePath = "file_path"` + - `type ImageURLDeltaBlock struct{…}` - - `EndIndex int64` + References an image URL in the content of a message. - - `FilePath FilePathDeltaAnnotationFilePath` + - `Index int64` - - `FileID string` + The index of the content part in the message. - The ID of the file that was generated. + - `Type ImageURL` - - `StartIndex int64` + Always `image_url`. - - `Text string` + - `const ImageURLImageURL ImageURL = "image_url"` - The text in the message content that needs to be replaced. + - `ImageURL ImageURLDelta` -### Image File + - `Detail ImageURLDeltaDetail` -- `type ImageFile struct{…}` + Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. - - `FileID string` + - `const ImageURLDeltaDetailAuto ImageURLDeltaDetail = "auto"` - 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. + - `const ImageURLDeltaDetailLow ImageURLDeltaDetail = "low"` - - `Detail ImageFileDetail` + - `const ImageURLDeltaDetailHigh ImageURLDeltaDetail = "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`. + - `URL string` - - `const ImageFileDetailAuto ImageFileDetail = "auto"` + The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. - - `const ImageFileDetailLow ImageFileDetail = "low"` +### Message Content Part Param - - `const ImageFileDetailHigh ImageFileDetail = "high"` +- `type MessageContentPartParamUnionResp interface{…}` -### Image File Content Block + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. -- `type ImageFileContentBlockParam struct{…}` + - `type ImageFileContentBlock struct{…}` References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. @@ -7278,9 +10831,83 @@ func main() { - `const ImageFileImageFile ImageFile = "image_file"` -### Image File Delta + - `type ImageURLContentBlock struct{…}` -- `type ImageFileDelta struct{…}` + References an image URL in the content of a message. + + - `ImageURL ImageURL` + + - `URL string` + + The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. + + - `Detail ImageURLDetail` + + Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` + + - `const ImageURLDetailAuto ImageURLDetail = "auto"` + + - `const ImageURLDetailLow ImageURLDetail = "low"` + + - `const ImageURLDetailHigh ImageURLDetail = "high"` + + - `Type ImageURL` + + The type of the content part. + + - `const ImageURLImageURL ImageURL = "image_url"` + + - `type TextContentBlockParam struct{…}` + + The text content that is part of a message. + + - `Text string` + + Text content to be sent to the model + + - `Type Text` + + Always `text`. + + - `const TextText Text = "text"` + +### Message Deleted + +- `type MessageDeleted struct{…}` + + - `ID string` + + - `Deleted bool` + + - `Object ThreadMessageDeleted` + + - `const ThreadMessageDeletedThreadMessageDeleted ThreadMessageDeleted = "thread.message.deleted"` + +### Message Delta + +- `type MessageDelta struct{…}` + + The delta containing the fields that have changed on the Message. + + - `Content []MessageContentDeltaUnion` + + The content of the message in array of text and/or images. + + - `type ImageFileDeltaBlock struct{…}` + + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. + + - `Index int64` + + The index of the content part in the message. + + - `Type ImageFile` + + Always `image_file`. + + - `const ImageFileImageFile ImageFile = "image_file"` + + - `ImageFile ImageFileDelta` - `Detail ImageFileDeltaDetail` @@ -7296,105 +10923,105 @@ func main() { 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 - -- `type ImageFileDeltaBlock struct{…}` + - `type TextDeltaBlock struct{…}` - 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 int64` The index of the content part in the message. - - `Type ImageFile` + - `Type Text` - Always `image_file`. + Always `text`. + + - `const TextText Text = "text"` - - `const ImageFileImageFile ImageFile = "image_file"` + - `Text TextDelta` - - `ImageFile ImageFileDelta` + - `Annotations []AnnotationDeltaUnion` - - `Detail ImageFileDeltaDetail` + - `type FileCitationDeltaAnnotation struct{…}` - 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. - - `const ImageFileDeltaDetailAuto ImageFileDeltaDetail = "auto"` + - `Index int64` - - `const ImageFileDeltaDetailLow ImageFileDeltaDetail = "low"` + The index of the annotation in the text content part. - - `const ImageFileDeltaDetailHigh ImageFileDeltaDetail = "high"` + - `Type FileCitation` - - `FileID string` + Always `file_citation`. - 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. + - `const FileCitationFileCitation FileCitation = "file_citation"` -### Image URL + - `EndIndex int64` -- `type ImageURL struct{…}` + - `FileCitation FileCitationDeltaAnnotationFileCitation` - - `URL string` + - `FileID string` - The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. + The ID of the specific File the citation is from. - - `Detail ImageURLDetail` + - `Quote string` - 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 specific quote in the file. - - `const ImageURLDetailAuto ImageURLDetail = "auto"` + - `StartIndex int64` - - `const ImageURLDetailLow ImageURLDetail = "low"` + - `Text string` - - `const ImageURLDetailHigh ImageURLDetail = "high"` + The text in the message content that needs to be replaced. -### Image URL Content Block + - `type FilePathDeltaAnnotation struct{…}` -- `type ImageURLContentBlockParam struct{…}` + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - References an image URL in the content of a message. + - `Index int64` - - `ImageURL ImageURL` + The index of the annotation in the text content part. - - `URL string` + - `Type FilePath` - The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. + Always `file_path`. - - `Detail ImageURLDetail` + - `const FilePathFilePath FilePath = "file_path"` - Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` + - `EndIndex int64` - - `const ImageURLDetailAuto ImageURLDetail = "auto"` + - `FilePath FilePathDeltaAnnotationFilePath` - - `const ImageURLDetailLow ImageURLDetail = "low"` + - `FileID string` - - `const ImageURLDetailHigh ImageURLDetail = "high"` + The ID of the file that was generated. - - `Type ImageURL` + - `StartIndex int64` - The type of the content part. + - `Text string` - - `const ImageURLImageURL ImageURL = "image_url"` + The text in the message content that needs to be replaced. -### Image URL Delta + - `Value string` -- `type ImageURLDelta struct{…}` + The data that makes up the text. - - `Detail ImageURLDeltaDetail` + - `type RefusalDeltaBlock struct{…}` - Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. + The refusal content that is part of a message. - - `const ImageURLDeltaDetailAuto ImageURLDeltaDetail = "auto"` + - `Index int64` - - `const ImageURLDeltaDetailLow ImageURLDeltaDetail = "low"` + The index of the refusal part in the message. - - `const ImageURLDeltaDetailHigh ImageURLDeltaDetail = "high"` + - `Type Refusal` - - `URL string` + Always `refusal`. - The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. + - `const RefusalRefusal Refusal = "refusal"` -### Image URL Delta Block + - `Refusal string` -- `type ImageURLDeltaBlock struct{…}` + - `type ImageURLDeltaBlock struct{…}` References an image URL in the content of a message. @@ -7424,250 +11051,189 @@ func main() { The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. -### Message - -- `type Message struct{…}` - - 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. - - - `AssistantID string` - - If applicable, the ID of the [assistant](https://platform.openai.com/docs/api-reference/assistants) that authored this message. - - - `Attachments []MessageAttachment` - - A list of files attached to the message, and the tools they were added to. - - - `FileID string` - - The ID of the file to attach to the message. - - - `Tools []MessageAttachmentToolUnion` - - The tools to add this file to. + - `Role MessageDeltaRole` - - `type CodeInterpreterTool struct{…}` + The entity that produced the message. One of `user` or `assistant`. - - `Type CodeInterpreter` + - `const MessageDeltaRoleUser MessageDeltaRole = "user"` - The type of tool being defined: `code_interpreter` + - `const MessageDeltaRoleAssistant MessageDeltaRole = "assistant"` - - `const CodeInterpreterCodeInterpreter CodeInterpreter = "code_interpreter"` +### Message Delta Event - - `type MessageAttachmentToolAssistantToolsFileSearchTypeOnly struct{…}` +- `type MessageDeltaEvent struct{…}` - - `Type FileSearch` + Represents a message delta i.e. any changed fields on a message during streaming. - The type of tool being defined: `file_search` + - `ID string` - - `const FileSearchFileSearch FileSearch = "file_search"` + The identifier of the message, which can be referenced in API endpoints. - - `CompletedAt int64` + - `Delta MessageDelta` - The Unix timestamp (in seconds) for when the message was completed. + The delta containing the fields that have changed on the Message. - - `Content []any` + - `Content []MessageContentDeltaUnion` The content of the message in array of text and/or images. - - `CreatedAt int64` - - The Unix timestamp (in seconds) for when the message was created. - - - `IncompleteAt int64` - - The Unix timestamp (in seconds) for when the message was marked as incomplete. - - - `IncompleteDetails MessageIncompleteDetails` - - On an incomplete message, details about why the message is incomplete. - - - `Reason string` - - The reason the message is incomplete. - - - `const MessageIncompleteDetailsReasonContentFilter MessageIncompleteDetailsReason = "content_filter"` - - - `const MessageIncompleteDetailsReasonMaxTokens MessageIncompleteDetailsReason = "max_tokens"` + - `type ImageFileDeltaBlock struct{…}` - - `const MessageIncompleteDetailsReasonRunCancelled MessageIncompleteDetailsReason = "run_cancelled"` + References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. - - `const MessageIncompleteDetailsReasonRunExpired MessageIncompleteDetailsReason = "run_expired"` + - `Index int64` - - `const MessageIncompleteDetailsReasonRunFailed MessageIncompleteDetailsReason = "run_failed"` + The index of the content part in the message. - - `Metadata Metadata` + - `Type ImageFile` - 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. + Always `image_file`. - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. + - `const ImageFileImageFile ImageFile = "image_file"` - - `Object ThreadMessage` + - `ImageFile ImageFileDelta` - The object type, which is always `thread.message`. + - `Detail ImageFileDeltaDetail` - - `const ThreadMessageThreadMessage ThreadMessage = "thread.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`. - - `Role MessageRole` + - `const ImageFileDeltaDetailAuto ImageFileDeltaDetail = "auto"` - The entity that produced the message. One of `user` or `assistant`. + - `const ImageFileDeltaDetailLow ImageFileDeltaDetail = "low"` - - `const MessageRoleUser MessageRole = "user"` + - `const ImageFileDeltaDetailHigh ImageFileDeltaDetail = "high"` - - `const MessageRoleAssistant MessageRole = "assistant"` + - `FileID string` - - `RunID 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. - 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. + - `type TextDeltaBlock struct{…}` - - `Status MessageStatus` + The text content that is part of a message. - The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. + - `Index int64` - - `const MessageStatusInProgress MessageStatus = "in_progress"` + The index of the content part in the message. - - `const MessageStatusIncomplete MessageStatus = "incomplete"` + - `Type Text` - - `const MessageStatusCompleted MessageStatus = "completed"` + Always `text`. - - `ThreadID string` + - `const TextText Text = "text"` - The [thread](https://platform.openai.com/docs/api-reference/threads) ID that this message belongs to. + - `Text TextDelta` -### Message Content + - `Annotations []AnnotationDeltaUnion` -- `type MessageContent interface{…}` + - `type FileCitationDeltaAnnotation struct{…}` -### Message Content Delta + 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. -- `type MessageContentDelta interface{…}` + - `Index int64` -### Message Content Part Param + The index of the annotation in the text content part. -- `type MessageContentPartParamUnionResp interface{…}` + - `Type FileCitation` - References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. + Always `file_citation`. - - `type ImageFileContentBlockParam struct{…}` + - `const FileCitationFileCitation FileCitation = "file_citation"` - References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. + - `EndIndex int64` - - `ImageFile ImageFile` + - `FileCitation FileCitationDeltaAnnotationFileCitation` - `FileID 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 ImageFileDetail` - - 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`. - - - `const ImageFileDetailAuto ImageFileDetail = "auto"` - - - `const ImageFileDetailLow ImageFileDetail = "low"` - - - `const ImageFileDetailHigh ImageFileDetail = "high"` - - - `Type ImageFile` + The ID of the specific File the citation is from. - Always `image_file`. + - `Quote string` - - `const ImageFileImageFile ImageFile = "image_file"` + The specific quote in the file. - - `type ImageURLContentBlockParam struct{…}` + - `StartIndex int64` - References an image URL in the content of a message. + - `Text string` - - `ImageURL ImageURL` + The text in the message content that needs to be replaced. - - `URL string` + - `type FilePathDeltaAnnotation struct{…}` - 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 ImageURLDetail` + - `Index int64` - 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. - - `const ImageURLDetailAuto ImageURLDetail = "auto"` + - `Type FilePath` - - `const ImageURLDetailLow ImageURLDetail = "low"` + Always `file_path`. - - `const ImageURLDetailHigh ImageURLDetail = "high"` + - `const FilePathFilePath FilePath = "file_path"` - - `Type ImageURL` + - `EndIndex int64` - The type of the content part. + - `FilePath FilePathDeltaAnnotationFilePath` - - `const ImageURLImageURL ImageURL = "image_url"` + - `FileID string` - - `type TextContentBlockParam struct{…}` + The ID of the file that was generated. - The text content that is part of a message. + - `StartIndex int64` - `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. - - `const TextText Text = "text"` + - `Value string` -### Message Deleted + The data that makes up the text. -- `type MessageDeleted struct{…}` + - `type RefusalDeltaBlock struct{…}` - - `ID string` + The refusal content that is part of a message. - - `Deleted bool` + - `Index int64` - - `Object ThreadMessageDeleted` + The index of the refusal part in the message. - - `const ThreadMessageDeletedThreadMessageDeleted ThreadMessageDeleted = "thread.message.deleted"` + - `Type Refusal` -### Message Delta + Always `refusal`. -- `type MessageDelta struct{…}` + - `const RefusalRefusal Refusal = "refusal"` - The delta containing the fields that have changed on the Message. + - `Refusal string` - - `Content []any` + - `type ImageURLDeltaBlock struct{…}` - The content of the message in array of text and/or images. + References an image URL in the content of a message. - - `Role MessageDeltaRole` + - `Index int64` - The entity that produced the message. One of `user` or `assistant`. + The index of the content part in the message. - - `const MessageDeltaRoleUser MessageDeltaRole = "user"` + - `Type ImageURL` - - `const MessageDeltaRoleAssistant MessageDeltaRole = "assistant"` + Always `image_url`. -### Message Delta Event + - `const ImageURLImageURL ImageURL = "image_url"` -- `type MessageDeltaEvent struct{…}` + - `ImageURL ImageURLDelta` - Represents a message delta i.e. any changed fields on a message during streaming. + - `Detail ImageURLDeltaDetail` - - `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. + - `const ImageURLDeltaDetailAuto ImageURLDeltaDetail = "auto"` - - `Delta MessageDelta` + - `const ImageURLDeltaDetailLow ImageURLDeltaDetail = "low"` - The delta containing the fields that have changed on the Message. + - `const ImageURLDeltaDetailHigh ImageURLDeltaDetail = "high"` - - `Content []any` + - `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 MessageDeltaRole` @@ -7719,7 +11285,55 @@ func main() { - `type Text struct{…}` - - `Annotations []any` + - `Annotations []AnnotationUnion` + + - `type FileCitationAnnotation struct{…}` + + 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. + + - `EndIndex int64` + + - `FileCitation FileCitationAnnotationFileCitation` + + - `FileID string` + + The ID of the specific File the citation is from. + + - `StartIndex int64` + + - `Text string` + + The text in the message content that needs to be replaced. + + - `Type FileCitation` + + Always `file_citation`. + + - `const FileCitationFileCitation FileCitation = "file_citation"` + + - `type FilePathAnnotation struct{…}` + + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + + - `EndIndex int64` + + - `FilePath FilePathAnnotationFilePath` + + - `FileID string` + + The ID of the file that was generated. + + - `StartIndex int64` + + - `Text string` + + The text in the message content that needs to be replaced. + + - `Type FilePath` + + Always `file_path`. + + - `const FilePathFilePath FilePath = "file_path"` - `Value string` @@ -7733,7 +11347,55 @@ func main() { - `Text Text` - - `Annotations []any` + - `Annotations []AnnotationUnion` + + - `type FileCitationAnnotation struct{…}` + + 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. + + - `EndIndex int64` + + - `FileCitation FileCitationAnnotationFileCitation` + + - `FileID string` + + The ID of the specific File the citation is from. + + - `StartIndex int64` + + - `Text string` + + The text in the message content that needs to be replaced. + + - `Type FileCitation` + + Always `file_citation`. + + - `const FileCitationFileCitation FileCitation = "file_citation"` + + - `type FilePathAnnotation struct{…}` + + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + + - `EndIndex int64` + + - `FilePath FilePathAnnotationFilePath` + + - `FileID string` + + The ID of the file that was generated. + + - `StartIndex int64` + + - `Text string` + + The text in the message content that needs to be replaced. + + - `Type FilePath` + + Always `file_path`. + + - `const FilePathFilePath FilePath = "file_path"` - `Value string` @@ -7765,7 +11427,67 @@ func main() { - `type TextDelta struct{…}` - - `Annotations []any` + - `Annotations []AnnotationDeltaUnion` + + - `type FileCitationDeltaAnnotation struct{…}` + + 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 int64` + + The index of the annotation in the text content part. + + - `Type FileCitation` + + Always `file_citation`. + + - `const FileCitationFileCitation FileCitation = "file_citation"` + + - `EndIndex int64` + + - `FileCitation FileCitationDeltaAnnotationFileCitation` + + - `FileID string` + + The ID of the specific File the citation is from. + + - `Quote string` + + The specific quote in the file. + + - `StartIndex int64` + + - `Text string` + + The text in the message content that needs to be replaced. + + - `type FilePathDeltaAnnotation struct{…}` + + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + + - `Index int64` + + The index of the annotation in the text content part. + + - `Type FilePath` + + Always `file_path`. + + - `const FilePathFilePath FilePath = "file_path"` + + - `EndIndex int64` + + - `FilePath FilePathDeltaAnnotationFilePath` + + - `FileID string` + + The ID of the file that was generated. + + - `StartIndex int64` + + - `Text string` + + The text in the message content that needs to be replaced. - `Value string` @@ -7789,7 +11511,67 @@ func main() { - `Text TextDelta` - - `Annotations []any` + - `Annotations []AnnotationDeltaUnion` + + - `type FileCitationDeltaAnnotation struct{…}` + + 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 int64` + + The index of the annotation in the text content part. + + - `Type FileCitation` + + Always `file_citation`. + + - `const FileCitationFileCitation FileCitation = "file_citation"` + + - `EndIndex int64` + + - `FileCitation FileCitationDeltaAnnotationFileCitation` + + - `FileID string` + + The ID of the specific File the citation is from. + + - `Quote string` + + The specific quote in the file. + + - `StartIndex int64` + + - `Text string` + + The text in the message content that needs to be replaced. + + - `type FilePathDeltaAnnotation struct{…}` + + A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + + - `Index int64` + + The index of the annotation in the text content part. + + - `Type FilePath` + + Always `file_path`. + + - `const FilePathFilePath FilePath = "file_path"` + + - `EndIndex int64` + + - `FilePath FilePathDeltaAnnotationFilePath` + + - `FileID string` + + The ID of the file that was generated. + + - `StartIndex int64` + + - `Text string` + + The text in the message content that needs to be replaced. - `Value string`