Create a thread.
ParametersExpand Collapse
body BetaThreadNewParams
Messages param.Field[[]BetaThreadNewParamsMessage]optionalA list of messages to start the thread with.
A list of messages to start the thread with.
Content BetaThreadNewParamsMessageContentUnionThe text contents of the message.
The text contents of the message.
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.
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.
type ImageFileContentBlock struct{…}References an image File in the content of a message.
References an image File in the content of a message.
ImageFile ImageFile
The File ID of the image in the message content. Set purpose="vision" when uploading the File if you need to later display the file content.
Detail ImageFileDetailoptionalSpecifies the detail level of the image if specified by the user. low uses fewer tokens, you can opt in to high resolution using high.
Specifies the detail level of the image if specified by the user. low uses fewer tokens, you can opt in to high resolution using high.
Always image_file.
type ImageURLContentBlock struct{…}References an image URL in the content of a message.
References an image URL in the content of a message.
ImageURL ImageURL
The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.
Detail ImageURLDetailoptionalSpecifies the detail level of the image. low uses fewer tokens, you can opt in to high resolution using high. Default value is auto
Specifies the detail level of the image. low uses fewer tokens, you can opt in to high resolution using high. Default value is auto
The type of the content part.
type TextContentBlockParam struct{…}The text content that is part of a message.
The text content that is part of a message.
Text content to be sent to the model
Always text.
Role stringThe 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.
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.
Attachments []BetaThreadNewParamsMessageAttachmentoptionalA list of files attached to the message, and the tools they should be added to.
A list of files attached to the message, and the tools they should be added to.
The ID of the file to attach to the message.
Tools []BetaThreadNewParamsMessageAttachmentToolUnionoptionalThe tools to add this file to.
The tools to add this file to.
type CodeInterpreterTool struct{…}
The type of tool being defined: code_interpreter
type BetaThreadNewParamsMessageAttachmentToolFileSearch struct{…}
The type of tool being defined: file_search
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.
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.
A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the code_interpreter tool requires a list of file IDs, while the file_search tool requires a list of vector store IDs.
A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the code_interpreter tool requires a list of file IDs, while the file_search tool requires a list of vector store IDs.
CodeInterpreter BetaThreadNewParamsToolResourcesCodeInterpreteroptional
A list of file IDs made available to the code_interpreter tool. There can be a maximum of 20 files associated with the tool.
FileSearch BetaThreadNewParamsToolResourcesFileSearchoptional
The vector store attached to this thread. There can be a maximum of 1 vector store attached to the thread.
VectorStores []BetaThreadNewParamsToolResourcesFileSearchVectorStoreoptionalA helper to create a vector store with file_ids and attach it to this thread. There can be a maximum of 1 vector store attached to the thread.
A helper to create a vector store with file_ids and attach it to this thread. There can be a maximum of 1 vector store attached to the thread.
ChunkingStrategy BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnionoptionalThe chunking strategy used to chunk the file(s). If not set, will use the auto strategy.
The chunking strategy used to chunk the file(s). If not set, will use the auto strategy.
type BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto struct{…}The default strategy. This strategy currently uses a max_chunk_size_tokens of 800 and chunk_overlap_tokens of 400.
The default strategy. This strategy currently uses a max_chunk_size_tokens of 800 and chunk_overlap_tokens of 400.
Always auto.
type BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic struct{…}
Static BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic
The number of tokens that overlap between chunks. The default value is 400.
Note that the overlap must not exceed half of max_chunk_size_tokens.
The maximum number of tokens in each chunk. The default value is 800. The minimum value is 100 and the maximum value is 4096.
Always static.
A list of file IDs to add to the vector store. There can be a maximum of 10000 files in a vector store.
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.
ReturnsExpand Collapse
type Thread struct{…}Represents a thread that contains messages.
Represents a thread that contains messages.
The identifier, which can be referenced in API endpoints.
The Unix timestamp (in seconds) for when the thread was created.
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.
The object type, which is always thread.
ToolResources ThreadToolResourcesA set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the code_interpreter tool requires a list of file IDs, while the file_search tool requires a list of vector store IDs.
A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the code_interpreter tool requires a list of file IDs, while the file_search tool requires a list of vector store IDs.
CodeInterpreter ThreadToolResourcesCodeInterpreteroptional
A list of file IDs made available to the code_interpreter tool. There can be a maximum of 20 files associated with the tool.
FileSearch ThreadToolResourcesFileSearchoptional
The vector store attached to this thread. There can be a maximum of 1 vector store attached to the thread.
Create thread
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"),
)
thread, err := client.Beta.Threads.New(context.TODO(), openai.BetaThreadNewParams{
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", thread.ID)
}
{
"id": "id",
"created_at": 0,
"metadata": {
"foo": "string"
},
"object": "thread",
"tool_resources": {
"code_interpreter": {
"file_ids": [
"string"
]
},
"file_search": {
"vector_store_ids": [
"string"
]
}
}
}Returns Examples
{
"id": "id",
"created_at": 0,
"metadata": {
"foo": "string"
},
"object": "thread",
"tool_resources": {
"code_interpreter": {
"file_ids": [
"string"
]
},
"file_search": {
"vector_store_ids": [
"string"
]
}
}
}