betathread.go

   1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
   2
   3package openai
   4
   5import (
   6	"context"
   7	"encoding/json"
   8	"errors"
   9	"fmt"
  10	"net/http"
  11
  12	"github.com/openai/openai-go/internal/apijson"
  13	"github.com/openai/openai-go/internal/requestconfig"
  14	"github.com/openai/openai-go/option"
  15	"github.com/openai/openai-go/packages/param"
  16	"github.com/openai/openai-go/packages/respjson"
  17	"github.com/openai/openai-go/packages/ssestream"
  18	"github.com/openai/openai-go/shared"
  19	"github.com/openai/openai-go/shared/constant"
  20)
  21
  22// BetaThreadService contains methods and other services that help with interacting
  23// with the openai API.
  24//
  25// Note, unlike clients, this service does not read variables from the environment
  26// automatically. You should not instantiate this service directly, and instead use
  27// the [NewBetaThreadService] method instead.
  28//
  29// Deprecated: The Assistants API is deprecated in favor of the Responses API
  30type BetaThreadService struct {
  31	Options []option.RequestOption
  32	// Deprecated: The Assistants API is deprecated in favor of the Responses API
  33	Runs BetaThreadRunService
  34	// Deprecated: The Assistants API is deprecated in favor of the Responses API
  35	Messages BetaThreadMessageService
  36}
  37
  38// NewBetaThreadService generates a new service that applies the given options to
  39// each request. These options are applied after the parent client's options (if
  40// there is one), and before any request-specific options.
  41func NewBetaThreadService(opts ...option.RequestOption) (r BetaThreadService) {
  42	r = BetaThreadService{}
  43	r.Options = opts
  44	r.Runs = NewBetaThreadRunService(opts...)
  45	r.Messages = NewBetaThreadMessageService(opts...)
  46	return
  47}
  48
  49// Create a thread.
  50//
  51// Deprecated: The Assistants API is deprecated in favor of the Responses API
  52func (r *BetaThreadService) New(ctx context.Context, body BetaThreadNewParams, opts ...option.RequestOption) (res *Thread, err error) {
  53	opts = append(r.Options[:], opts...)
  54	opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
  55	path := "threads"
  56	err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
  57	return
  58}
  59
  60// Retrieves a thread.
  61//
  62// Deprecated: The Assistants API is deprecated in favor of the Responses API
  63func (r *BetaThreadService) Get(ctx context.Context, threadID string, opts ...option.RequestOption) (res *Thread, err error) {
  64	opts = append(r.Options[:], opts...)
  65	opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
  66	if threadID == "" {
  67		err = errors.New("missing required thread_id parameter")
  68		return
  69	}
  70	path := fmt.Sprintf("threads/%s", threadID)
  71	err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
  72	return
  73}
  74
  75// Modifies a thread.
  76//
  77// Deprecated: The Assistants API is deprecated in favor of the Responses API
  78func (r *BetaThreadService) Update(ctx context.Context, threadID string, body BetaThreadUpdateParams, opts ...option.RequestOption) (res *Thread, err error) {
  79	opts = append(r.Options[:], opts...)
  80	opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
  81	if threadID == "" {
  82		err = errors.New("missing required thread_id parameter")
  83		return
  84	}
  85	path := fmt.Sprintf("threads/%s", threadID)
  86	err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
  87	return
  88}
  89
  90// Delete a thread.
  91//
  92// Deprecated: The Assistants API is deprecated in favor of the Responses API
  93func (r *BetaThreadService) Delete(ctx context.Context, threadID string, opts ...option.RequestOption) (res *ThreadDeleted, err error) {
  94	opts = append(r.Options[:], opts...)
  95	opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
  96	if threadID == "" {
  97		err = errors.New("missing required thread_id parameter")
  98		return
  99	}
 100	path := fmt.Sprintf("threads/%s", threadID)
 101	err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
 102	return
 103}
 104
 105// Create a thread and run it in one request.
 106//
 107// Deprecated: The Assistants API is deprecated in favor of the Responses API
 108func (r *BetaThreadService) NewAndRun(ctx context.Context, body BetaThreadNewAndRunParams, opts ...option.RequestOption) (res *Run, err error) {
 109	opts = append(r.Options[:], opts...)
 110	opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
 111	path := "threads/runs"
 112	err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
 113	return
 114}
 115
 116// Create a thread and run it in one request.
 117//
 118// Deprecated: The Assistants API is deprecated in favor of the Responses API
 119func (r *BetaThreadService) NewAndRunStreaming(ctx context.Context, body BetaThreadNewAndRunParams, opts ...option.RequestOption) (stream *ssestream.Stream[AssistantStreamEventUnion]) {
 120	var (
 121		raw *http.Response
 122		err error
 123	)
 124	opts = append(r.Options[:], opts...)
 125	opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2"), option.WithJSONSet("stream", true)}, opts...)
 126	path := "threads/runs"
 127	err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &raw, opts...)
 128	return ssestream.NewStream[AssistantStreamEventUnion](ssestream.NewDecoder(raw), err)
 129}
 130
 131// AssistantResponseFormatOptionUnion contains all possible properties and values
 132// from [constant.Auto], [shared.ResponseFormatText],
 133// [shared.ResponseFormatJSONObject], [shared.ResponseFormatJSONSchema].
 134//
 135// Use the methods beginning with 'As' to cast the union to one of its variants.
 136//
 137// If the underlying value is not a json object, one of the following properties
 138// will be valid: OfAuto]
 139type AssistantResponseFormatOptionUnion struct {
 140	// This field will be present if the value is a [constant.Auto] instead of an
 141	// object.
 142	OfAuto constant.Auto `json:",inline"`
 143	Type   string        `json:"type"`
 144	// This field is from variant [shared.ResponseFormatJSONSchema].
 145	JSONSchema shared.ResponseFormatJSONSchemaJSONSchema `json:"json_schema"`
 146	JSON       struct {
 147		OfAuto     respjson.Field
 148		Type       respjson.Field
 149		JSONSchema respjson.Field
 150		raw        string
 151	} `json:"-"`
 152}
 153
 154func (u AssistantResponseFormatOptionUnion) AsAuto() (v constant.Auto) {
 155	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 156	return
 157}
 158
 159func (u AssistantResponseFormatOptionUnion) AsText() (v shared.ResponseFormatText) {
 160	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 161	return
 162}
 163
 164func (u AssistantResponseFormatOptionUnion) AsJSONObject() (v shared.ResponseFormatJSONObject) {
 165	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 166	return
 167}
 168
 169func (u AssistantResponseFormatOptionUnion) AsJSONSchema() (v shared.ResponseFormatJSONSchema) {
 170	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 171	return
 172}
 173
 174// Returns the unmodified JSON received from the API
 175func (u AssistantResponseFormatOptionUnion) RawJSON() string { return u.JSON.raw }
 176
 177func (r *AssistantResponseFormatOptionUnion) UnmarshalJSON(data []byte) error {
 178	return apijson.UnmarshalRoot(data, r)
 179}
 180
 181// ToParam converts this AssistantResponseFormatOptionUnion to a
 182// AssistantResponseFormatOptionUnionParam.
 183//
 184// Warning: the fields of the param type will not be present. ToParam should only
 185// be used at the last possible moment before sending a request. Test for this with
 186// AssistantResponseFormatOptionUnionParam.Overrides()
 187func (r AssistantResponseFormatOptionUnion) ToParam() AssistantResponseFormatOptionUnionParam {
 188	return param.Override[AssistantResponseFormatOptionUnionParam](json.RawMessage(r.RawJSON()))
 189}
 190
 191func AssistantResponseFormatOptionParamOfAuto() AssistantResponseFormatOptionUnionParam {
 192	return AssistantResponseFormatOptionUnionParam{OfAuto: constant.ValueOf[constant.Auto]()}
 193}
 194
 195func AssistantResponseFormatOptionParamOfJSONSchema(jsonSchema shared.ResponseFormatJSONSchemaJSONSchemaParam) AssistantResponseFormatOptionUnionParam {
 196	var variant shared.ResponseFormatJSONSchemaParam
 197	variant.JSONSchema = jsonSchema
 198	return AssistantResponseFormatOptionUnionParam{OfJSONSchema: &variant}
 199}
 200
 201// Only one field can be non-zero.
 202//
 203// Use [param.IsOmitted] to confirm if a field is set.
 204type AssistantResponseFormatOptionUnionParam struct {
 205	// Construct this variant with constant.ValueOf[constant.Auto]()
 206	OfAuto       constant.Auto                         `json:",omitzero,inline"`
 207	OfText       *shared.ResponseFormatTextParam       `json:",omitzero,inline"`
 208	OfJSONObject *shared.ResponseFormatJSONObjectParam `json:",omitzero,inline"`
 209	OfJSONSchema *shared.ResponseFormatJSONSchemaParam `json:",omitzero,inline"`
 210	paramUnion
 211}
 212
 213func (u AssistantResponseFormatOptionUnionParam) MarshalJSON() ([]byte, error) {
 214	return param.MarshalUnion(u, u.OfAuto, u.OfText, u.OfJSONObject, u.OfJSONSchema)
 215}
 216func (u *AssistantResponseFormatOptionUnionParam) UnmarshalJSON(data []byte) error {
 217	return apijson.UnmarshalRoot(data, u)
 218}
 219
 220func (u *AssistantResponseFormatOptionUnionParam) asAny() any {
 221	if !param.IsOmitted(u.OfAuto) {
 222		return &u.OfAuto
 223	} else if !param.IsOmitted(u.OfText) {
 224		return u.OfText
 225	} else if !param.IsOmitted(u.OfJSONObject) {
 226		return u.OfJSONObject
 227	} else if !param.IsOmitted(u.OfJSONSchema) {
 228		return u.OfJSONSchema
 229	}
 230	return nil
 231}
 232
 233// Returns a pointer to the underlying variant's property, if present.
 234func (u AssistantResponseFormatOptionUnionParam) GetJSONSchema() *shared.ResponseFormatJSONSchemaJSONSchemaParam {
 235	if vt := u.OfJSONSchema; vt != nil {
 236		return &vt.JSONSchema
 237	}
 238	return nil
 239}
 240
 241// Returns a pointer to the underlying variant's property, if present.
 242func (u AssistantResponseFormatOptionUnionParam) GetType() *string {
 243	if vt := u.OfText; vt != nil {
 244		return (*string)(&vt.Type)
 245	} else if vt := u.OfJSONObject; vt != nil {
 246		return (*string)(&vt.Type)
 247	} else if vt := u.OfJSONSchema; vt != nil {
 248		return (*string)(&vt.Type)
 249	}
 250	return nil
 251}
 252
 253// Specifies a tool the model should use. Use to force the model to call a specific
 254// tool.
 255type AssistantToolChoice struct {
 256	// The type of the tool. If type is `function`, the function name must be set
 257	//
 258	// Any of "function", "code_interpreter", "file_search".
 259	Type     AssistantToolChoiceType     `json:"type,required"`
 260	Function AssistantToolChoiceFunction `json:"function"`
 261	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
 262	JSON struct {
 263		Type        respjson.Field
 264		Function    respjson.Field
 265		ExtraFields map[string]respjson.Field
 266		raw         string
 267	} `json:"-"`
 268}
 269
 270// Returns the unmodified JSON received from the API
 271func (r AssistantToolChoice) RawJSON() string { return r.JSON.raw }
 272func (r *AssistantToolChoice) UnmarshalJSON(data []byte) error {
 273	return apijson.UnmarshalRoot(data, r)
 274}
 275
 276// ToParam converts this AssistantToolChoice to a AssistantToolChoiceParam.
 277//
 278// Warning: the fields of the param type will not be present. ToParam should only
 279// be used at the last possible moment before sending a request. Test for this with
 280// AssistantToolChoiceParam.Overrides()
 281func (r AssistantToolChoice) ToParam() AssistantToolChoiceParam {
 282	return param.Override[AssistantToolChoiceParam](json.RawMessage(r.RawJSON()))
 283}
 284
 285// The type of the tool. If type is `function`, the function name must be set
 286type AssistantToolChoiceType string
 287
 288const (
 289	AssistantToolChoiceTypeFunction        AssistantToolChoiceType = "function"
 290	AssistantToolChoiceTypeCodeInterpreter AssistantToolChoiceType = "code_interpreter"
 291	AssistantToolChoiceTypeFileSearch      AssistantToolChoiceType = "file_search"
 292)
 293
 294// Specifies a tool the model should use. Use to force the model to call a specific
 295// tool.
 296//
 297// The property Type is required.
 298type AssistantToolChoiceParam struct {
 299	// The type of the tool. If type is `function`, the function name must be set
 300	//
 301	// Any of "function", "code_interpreter", "file_search".
 302	Type     AssistantToolChoiceType          `json:"type,omitzero,required"`
 303	Function AssistantToolChoiceFunctionParam `json:"function,omitzero"`
 304	paramObj
 305}
 306
 307func (r AssistantToolChoiceParam) MarshalJSON() (data []byte, err error) {
 308	type shadow AssistantToolChoiceParam
 309	return param.MarshalObject(r, (*shadow)(&r))
 310}
 311func (r *AssistantToolChoiceParam) UnmarshalJSON(data []byte) error {
 312	return apijson.UnmarshalRoot(data, r)
 313}
 314
 315type AssistantToolChoiceFunction struct {
 316	// The name of the function to call.
 317	Name string `json:"name,required"`
 318	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
 319	JSON struct {
 320		Name        respjson.Field
 321		ExtraFields map[string]respjson.Field
 322		raw         string
 323	} `json:"-"`
 324}
 325
 326// Returns the unmodified JSON received from the API
 327func (r AssistantToolChoiceFunction) RawJSON() string { return r.JSON.raw }
 328func (r *AssistantToolChoiceFunction) UnmarshalJSON(data []byte) error {
 329	return apijson.UnmarshalRoot(data, r)
 330}
 331
 332// ToParam converts this AssistantToolChoiceFunction to a
 333// AssistantToolChoiceFunctionParam.
 334//
 335// Warning: the fields of the param type will not be present. ToParam should only
 336// be used at the last possible moment before sending a request. Test for this with
 337// AssistantToolChoiceFunctionParam.Overrides()
 338func (r AssistantToolChoiceFunction) ToParam() AssistantToolChoiceFunctionParam {
 339	return param.Override[AssistantToolChoiceFunctionParam](json.RawMessage(r.RawJSON()))
 340}
 341
 342// The property Name is required.
 343type AssistantToolChoiceFunctionParam struct {
 344	// The name of the function to call.
 345	Name string `json:"name,required"`
 346	paramObj
 347}
 348
 349func (r AssistantToolChoiceFunctionParam) MarshalJSON() (data []byte, err error) {
 350	type shadow AssistantToolChoiceFunctionParam
 351	return param.MarshalObject(r, (*shadow)(&r))
 352}
 353func (r *AssistantToolChoiceFunctionParam) UnmarshalJSON(data []byte) error {
 354	return apijson.UnmarshalRoot(data, r)
 355}
 356
 357// AssistantToolChoiceOptionUnion contains all possible properties and values from
 358// [string], [AssistantToolChoice].
 359//
 360// Use the methods beginning with 'As' to cast the union to one of its variants.
 361//
 362// If the underlying value is not a json object, one of the following properties
 363// will be valid: OfAuto]
 364type AssistantToolChoiceOptionUnion struct {
 365	// This field will be present if the value is a [string] instead of an object.
 366	OfAuto string `json:",inline"`
 367	// This field is from variant [AssistantToolChoice].
 368	Type AssistantToolChoiceType `json:"type"`
 369	// This field is from variant [AssistantToolChoice].
 370	Function AssistantToolChoiceFunction `json:"function"`
 371	JSON     struct {
 372		OfAuto   respjson.Field
 373		Type     respjson.Field
 374		Function respjson.Field
 375		raw      string
 376	} `json:"-"`
 377}
 378
 379func (u AssistantToolChoiceOptionUnion) AsAuto() (v string) {
 380	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 381	return
 382}
 383
 384func (u AssistantToolChoiceOptionUnion) AsAssistantToolChoice() (v AssistantToolChoice) {
 385	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 386	return
 387}
 388
 389// Returns the unmodified JSON received from the API
 390func (u AssistantToolChoiceOptionUnion) RawJSON() string { return u.JSON.raw }
 391
 392func (r *AssistantToolChoiceOptionUnion) UnmarshalJSON(data []byte) error {
 393	return apijson.UnmarshalRoot(data, r)
 394}
 395
 396// ToParam converts this AssistantToolChoiceOptionUnion to a
 397// AssistantToolChoiceOptionUnionParam.
 398//
 399// Warning: the fields of the param type will not be present. ToParam should only
 400// be used at the last possible moment before sending a request. Test for this with
 401// AssistantToolChoiceOptionUnionParam.Overrides()
 402func (r AssistantToolChoiceOptionUnion) ToParam() AssistantToolChoiceOptionUnionParam {
 403	return param.Override[AssistantToolChoiceOptionUnionParam](json.RawMessage(r.RawJSON()))
 404}
 405
 406// `none` means the model will not call any tools and instead generates a message.
 407// `auto` means the model can pick between generating a message or calling one or
 408// more tools. `required` means the model must call one or more tools before
 409// responding to the user.
 410type AssistantToolChoiceOptionAuto string
 411
 412const (
 413	AssistantToolChoiceOptionAutoNone     AssistantToolChoiceOptionAuto = "none"
 414	AssistantToolChoiceOptionAutoAuto     AssistantToolChoiceOptionAuto = "auto"
 415	AssistantToolChoiceOptionAutoRequired AssistantToolChoiceOptionAuto = "required"
 416)
 417
 418func AssistantToolChoiceOptionParamOfAssistantToolChoice(type_ AssistantToolChoiceType) AssistantToolChoiceOptionUnionParam {
 419	var variant AssistantToolChoiceParam
 420	variant.Type = type_
 421	return AssistantToolChoiceOptionUnionParam{OfAssistantToolChoice: &variant}
 422}
 423
 424// Only one field can be non-zero.
 425//
 426// Use [param.IsOmitted] to confirm if a field is set.
 427type AssistantToolChoiceOptionUnionParam struct {
 428	// Check if union is this variant with !param.IsOmitted(union.OfAuto)
 429	OfAuto                param.Opt[string]         `json:",omitzero,inline"`
 430	OfAssistantToolChoice *AssistantToolChoiceParam `json:",omitzero,inline"`
 431	paramUnion
 432}
 433
 434func (u AssistantToolChoiceOptionUnionParam) MarshalJSON() ([]byte, error) {
 435	return param.MarshalUnion(u, u.OfAuto, u.OfAssistantToolChoice)
 436}
 437func (u *AssistantToolChoiceOptionUnionParam) UnmarshalJSON(data []byte) error {
 438	return apijson.UnmarshalRoot(data, u)
 439}
 440
 441func (u *AssistantToolChoiceOptionUnionParam) asAny() any {
 442	if !param.IsOmitted(u.OfAuto) {
 443		return &u.OfAuto
 444	} else if !param.IsOmitted(u.OfAssistantToolChoice) {
 445		return u.OfAssistantToolChoice
 446	}
 447	return nil
 448}
 449
 450// Represents a thread that contains
 451// [messages](https://platform.openai.com/docs/api-reference/messages).
 452type Thread struct {
 453	// The identifier, which can be referenced in API endpoints.
 454	ID string `json:"id,required"`
 455	// The Unix timestamp (in seconds) for when the thread was created.
 456	CreatedAt int64 `json:"created_at,required"`
 457	// Set of 16 key-value pairs that can be attached to an object. This can be useful
 458	// for storing additional information about the object in a structured format, and
 459	// querying for objects via API or the dashboard.
 460	//
 461	// Keys are strings with a maximum length of 64 characters. Values are strings with
 462	// a maximum length of 512 characters.
 463	Metadata shared.Metadata `json:"metadata,required"`
 464	// The object type, which is always `thread`.
 465	Object constant.Thread `json:"object,required"`
 466	// A set of resources that are made available to the assistant's tools in this
 467	// thread. The resources are specific to the type of tool. For example, the
 468	// `code_interpreter` tool requires a list of file IDs, while the `file_search`
 469	// tool requires a list of vector store IDs.
 470	ToolResources ThreadToolResources `json:"tool_resources,required"`
 471	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
 472	JSON struct {
 473		ID            respjson.Field
 474		CreatedAt     respjson.Field
 475		Metadata      respjson.Field
 476		Object        respjson.Field
 477		ToolResources respjson.Field
 478		ExtraFields   map[string]respjson.Field
 479		raw           string
 480	} `json:"-"`
 481}
 482
 483// Returns the unmodified JSON received from the API
 484func (r Thread) RawJSON() string { return r.JSON.raw }
 485func (r *Thread) UnmarshalJSON(data []byte) error {
 486	return apijson.UnmarshalRoot(data, r)
 487}
 488
 489// A set of resources that are made available to the assistant's tools in this
 490// thread. The resources are specific to the type of tool. For example, the
 491// `code_interpreter` tool requires a list of file IDs, while the `file_search`
 492// tool requires a list of vector store IDs.
 493type ThreadToolResources struct {
 494	CodeInterpreter ThreadToolResourcesCodeInterpreter `json:"code_interpreter"`
 495	FileSearch      ThreadToolResourcesFileSearch      `json:"file_search"`
 496	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
 497	JSON struct {
 498		CodeInterpreter respjson.Field
 499		FileSearch      respjson.Field
 500		ExtraFields     map[string]respjson.Field
 501		raw             string
 502	} `json:"-"`
 503}
 504
 505// Returns the unmodified JSON received from the API
 506func (r ThreadToolResources) RawJSON() string { return r.JSON.raw }
 507func (r *ThreadToolResources) UnmarshalJSON(data []byte) error {
 508	return apijson.UnmarshalRoot(data, r)
 509}
 510
 511type ThreadToolResourcesCodeInterpreter struct {
 512	// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
 513	// available to the `code_interpreter` tool. There can be a maximum of 20 files
 514	// associated with the tool.
 515	FileIDs []string `json:"file_ids"`
 516	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
 517	JSON struct {
 518		FileIDs     respjson.Field
 519		ExtraFields map[string]respjson.Field
 520		raw         string
 521	} `json:"-"`
 522}
 523
 524// Returns the unmodified JSON received from the API
 525func (r ThreadToolResourcesCodeInterpreter) RawJSON() string { return r.JSON.raw }
 526func (r *ThreadToolResourcesCodeInterpreter) UnmarshalJSON(data []byte) error {
 527	return apijson.UnmarshalRoot(data, r)
 528}
 529
 530type ThreadToolResourcesFileSearch struct {
 531	// The
 532	// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
 533	// attached to this thread. There can be a maximum of 1 vector store attached to
 534	// the thread.
 535	VectorStoreIDs []string `json:"vector_store_ids"`
 536	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
 537	JSON struct {
 538		VectorStoreIDs respjson.Field
 539		ExtraFields    map[string]respjson.Field
 540		raw            string
 541	} `json:"-"`
 542}
 543
 544// Returns the unmodified JSON received from the API
 545func (r ThreadToolResourcesFileSearch) RawJSON() string { return r.JSON.raw }
 546func (r *ThreadToolResourcesFileSearch) UnmarshalJSON(data []byte) error {
 547	return apijson.UnmarshalRoot(data, r)
 548}
 549
 550type ThreadDeleted struct {
 551	ID      string                 `json:"id,required"`
 552	Deleted bool                   `json:"deleted,required"`
 553	Object  constant.ThreadDeleted `json:"object,required"`
 554	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
 555	JSON struct {
 556		ID          respjson.Field
 557		Deleted     respjson.Field
 558		Object      respjson.Field
 559		ExtraFields map[string]respjson.Field
 560		raw         string
 561	} `json:"-"`
 562}
 563
 564// Returns the unmodified JSON received from the API
 565func (r ThreadDeleted) RawJSON() string { return r.JSON.raw }
 566func (r *ThreadDeleted) UnmarshalJSON(data []byte) error {
 567	return apijson.UnmarshalRoot(data, r)
 568}
 569
 570type BetaThreadNewParams struct {
 571	// Set of 16 key-value pairs that can be attached to an object. This can be useful
 572	// for storing additional information about the object in a structured format, and
 573	// querying for objects via API or the dashboard.
 574	//
 575	// Keys are strings with a maximum length of 64 characters. Values are strings with
 576	// a maximum length of 512 characters.
 577	Metadata shared.Metadata `json:"metadata,omitzero"`
 578	// A set of resources that are made available to the assistant's tools in this
 579	// thread. The resources are specific to the type of tool. For example, the
 580	// `code_interpreter` tool requires a list of file IDs, while the `file_search`
 581	// tool requires a list of vector store IDs.
 582	ToolResources BetaThreadNewParamsToolResources `json:"tool_resources,omitzero"`
 583	// A list of [messages](https://platform.openai.com/docs/api-reference/messages) to
 584	// start the thread with.
 585	Messages []BetaThreadNewParamsMessage `json:"messages,omitzero"`
 586	paramObj
 587}
 588
 589func (r BetaThreadNewParams) MarshalJSON() (data []byte, err error) {
 590	type shadow BetaThreadNewParams
 591	return param.MarshalObject(r, (*shadow)(&r))
 592}
 593func (r *BetaThreadNewParams) UnmarshalJSON(data []byte) error {
 594	return apijson.UnmarshalRoot(data, r)
 595}
 596
 597// The properties Content, Role are required.
 598type BetaThreadNewParamsMessage struct {
 599	// The text contents of the message.
 600	Content BetaThreadNewParamsMessageContentUnion `json:"content,omitzero,required"`
 601	// The role of the entity that is creating the message. Allowed values include:
 602	//
 603	//   - `user`: Indicates the message is sent by an actual user and should be used in
 604	//     most cases to represent user-generated messages.
 605	//   - `assistant`: Indicates the message is generated by the assistant. Use this
 606	//     value to insert messages from the assistant into the conversation.
 607	//
 608	// Any of "user", "assistant".
 609	Role string `json:"role,omitzero,required"`
 610	// A list of files attached to the message, and the tools they should be added to.
 611	Attachments []BetaThreadNewParamsMessageAttachment `json:"attachments,omitzero"`
 612	// Set of 16 key-value pairs that can be attached to an object. This can be useful
 613	// for storing additional information about the object in a structured format, and
 614	// querying for objects via API or the dashboard.
 615	//
 616	// Keys are strings with a maximum length of 64 characters. Values are strings with
 617	// a maximum length of 512 characters.
 618	Metadata shared.Metadata `json:"metadata,omitzero"`
 619	paramObj
 620}
 621
 622func (r BetaThreadNewParamsMessage) MarshalJSON() (data []byte, err error) {
 623	type shadow BetaThreadNewParamsMessage
 624	return param.MarshalObject(r, (*shadow)(&r))
 625}
 626func (r *BetaThreadNewParamsMessage) UnmarshalJSON(data []byte) error {
 627	return apijson.UnmarshalRoot(data, r)
 628}
 629
 630func init() {
 631	apijson.RegisterFieldValidator[BetaThreadNewParamsMessage](
 632		"role", "user", "assistant",
 633	)
 634}
 635
 636// Only one field can be non-zero.
 637//
 638// Use [param.IsOmitted] to confirm if a field is set.
 639type BetaThreadNewParamsMessageContentUnion struct {
 640	OfString              param.Opt[string]              `json:",omitzero,inline"`
 641	OfArrayOfContentParts []MessageContentPartParamUnion `json:",omitzero,inline"`
 642	paramUnion
 643}
 644
 645func (u BetaThreadNewParamsMessageContentUnion) MarshalJSON() ([]byte, error) {
 646	return param.MarshalUnion(u, u.OfString, u.OfArrayOfContentParts)
 647}
 648func (u *BetaThreadNewParamsMessageContentUnion) UnmarshalJSON(data []byte) error {
 649	return apijson.UnmarshalRoot(data, u)
 650}
 651
 652func (u *BetaThreadNewParamsMessageContentUnion) asAny() any {
 653	if !param.IsOmitted(u.OfString) {
 654		return &u.OfString.Value
 655	} else if !param.IsOmitted(u.OfArrayOfContentParts) {
 656		return &u.OfArrayOfContentParts
 657	}
 658	return nil
 659}
 660
 661type BetaThreadNewParamsMessageAttachment struct {
 662	// The ID of the file to attach to the message.
 663	FileID param.Opt[string] `json:"file_id,omitzero"`
 664	// The tools to add this file to.
 665	Tools []BetaThreadNewParamsMessageAttachmentToolUnion `json:"tools,omitzero"`
 666	paramObj
 667}
 668
 669func (r BetaThreadNewParamsMessageAttachment) MarshalJSON() (data []byte, err error) {
 670	type shadow BetaThreadNewParamsMessageAttachment
 671	return param.MarshalObject(r, (*shadow)(&r))
 672}
 673func (r *BetaThreadNewParamsMessageAttachment) UnmarshalJSON(data []byte) error {
 674	return apijson.UnmarshalRoot(data, r)
 675}
 676
 677// Only one field can be non-zero.
 678//
 679// Use [param.IsOmitted] to confirm if a field is set.
 680type BetaThreadNewParamsMessageAttachmentToolUnion struct {
 681	OfCodeInterpreter *CodeInterpreterToolParam                           `json:",omitzero,inline"`
 682	OfFileSearch      *BetaThreadNewParamsMessageAttachmentToolFileSearch `json:",omitzero,inline"`
 683	paramUnion
 684}
 685
 686func (u BetaThreadNewParamsMessageAttachmentToolUnion) MarshalJSON() ([]byte, error) {
 687	return param.MarshalUnion(u, u.OfCodeInterpreter, u.OfFileSearch)
 688}
 689func (u *BetaThreadNewParamsMessageAttachmentToolUnion) UnmarshalJSON(data []byte) error {
 690	return apijson.UnmarshalRoot(data, u)
 691}
 692
 693func (u *BetaThreadNewParamsMessageAttachmentToolUnion) asAny() any {
 694	if !param.IsOmitted(u.OfCodeInterpreter) {
 695		return u.OfCodeInterpreter
 696	} else if !param.IsOmitted(u.OfFileSearch) {
 697		return u.OfFileSearch
 698	}
 699	return nil
 700}
 701
 702// Returns a pointer to the underlying variant's property, if present.
 703func (u BetaThreadNewParamsMessageAttachmentToolUnion) GetType() *string {
 704	if vt := u.OfCodeInterpreter; vt != nil {
 705		return (*string)(&vt.Type)
 706	} else if vt := u.OfFileSearch; vt != nil {
 707		return (*string)(&vt.Type)
 708	}
 709	return nil
 710}
 711
 712func init() {
 713	apijson.RegisterUnion[BetaThreadNewParamsMessageAttachmentToolUnion](
 714		"type",
 715		apijson.Discriminator[CodeInterpreterToolParam]("code_interpreter"),
 716		apijson.Discriminator[BetaThreadNewParamsMessageAttachmentToolFileSearch]("file_search"),
 717	)
 718}
 719
 720func NewBetaThreadNewParamsMessageAttachmentToolFileSearch() BetaThreadNewParamsMessageAttachmentToolFileSearch {
 721	return BetaThreadNewParamsMessageAttachmentToolFileSearch{
 722		Type: "file_search",
 723	}
 724}
 725
 726// This struct has a constant value, construct it with
 727// [NewBetaThreadNewParamsMessageAttachmentToolFileSearch].
 728type BetaThreadNewParamsMessageAttachmentToolFileSearch struct {
 729	// The type of tool being defined: `file_search`
 730	Type constant.FileSearch `json:"type,required"`
 731	paramObj
 732}
 733
 734func (r BetaThreadNewParamsMessageAttachmentToolFileSearch) MarshalJSON() (data []byte, err error) {
 735	type shadow BetaThreadNewParamsMessageAttachmentToolFileSearch
 736	return param.MarshalObject(r, (*shadow)(&r))
 737}
 738func (r *BetaThreadNewParamsMessageAttachmentToolFileSearch) UnmarshalJSON(data []byte) error {
 739	return apijson.UnmarshalRoot(data, r)
 740}
 741
 742// A set of resources that are made available to the assistant's tools in this
 743// thread. The resources are specific to the type of tool. For example, the
 744// `code_interpreter` tool requires a list of file IDs, while the `file_search`
 745// tool requires a list of vector store IDs.
 746type BetaThreadNewParamsToolResources struct {
 747	CodeInterpreter BetaThreadNewParamsToolResourcesCodeInterpreter `json:"code_interpreter,omitzero"`
 748	FileSearch      BetaThreadNewParamsToolResourcesFileSearch      `json:"file_search,omitzero"`
 749	paramObj
 750}
 751
 752func (r BetaThreadNewParamsToolResources) MarshalJSON() (data []byte, err error) {
 753	type shadow BetaThreadNewParamsToolResources
 754	return param.MarshalObject(r, (*shadow)(&r))
 755}
 756func (r *BetaThreadNewParamsToolResources) UnmarshalJSON(data []byte) error {
 757	return apijson.UnmarshalRoot(data, r)
 758}
 759
 760type BetaThreadNewParamsToolResourcesCodeInterpreter struct {
 761	// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
 762	// available to the `code_interpreter` tool. There can be a maximum of 20 files
 763	// associated with the tool.
 764	FileIDs []string `json:"file_ids,omitzero"`
 765	paramObj
 766}
 767
 768func (r BetaThreadNewParamsToolResourcesCodeInterpreter) MarshalJSON() (data []byte, err error) {
 769	type shadow BetaThreadNewParamsToolResourcesCodeInterpreter
 770	return param.MarshalObject(r, (*shadow)(&r))
 771}
 772func (r *BetaThreadNewParamsToolResourcesCodeInterpreter) UnmarshalJSON(data []byte) error {
 773	return apijson.UnmarshalRoot(data, r)
 774}
 775
 776type BetaThreadNewParamsToolResourcesFileSearch struct {
 777	// The
 778	// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
 779	// attached to this thread. There can be a maximum of 1 vector store attached to
 780	// the thread.
 781	VectorStoreIDs []string `json:"vector_store_ids,omitzero"`
 782	// A helper to create a
 783	// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
 784	// with file_ids and attach it to this thread. There can be a maximum of 1 vector
 785	// store attached to the thread.
 786	VectorStores []BetaThreadNewParamsToolResourcesFileSearchVectorStore `json:"vector_stores,omitzero"`
 787	paramObj
 788}
 789
 790func (r BetaThreadNewParamsToolResourcesFileSearch) MarshalJSON() (data []byte, err error) {
 791	type shadow BetaThreadNewParamsToolResourcesFileSearch
 792	return param.MarshalObject(r, (*shadow)(&r))
 793}
 794func (r *BetaThreadNewParamsToolResourcesFileSearch) UnmarshalJSON(data []byte) error {
 795	return apijson.UnmarshalRoot(data, r)
 796}
 797
 798type BetaThreadNewParamsToolResourcesFileSearchVectorStore struct {
 799	// Set of 16 key-value pairs that can be attached to an object. This can be useful
 800	// for storing additional information about the object in a structured format, and
 801	// querying for objects via API or the dashboard.
 802	//
 803	// Keys are strings with a maximum length of 64 characters. Values are strings with
 804	// a maximum length of 512 characters.
 805	Metadata shared.Metadata `json:"metadata,omitzero"`
 806	// The chunking strategy used to chunk the file(s). If not set, will use the `auto`
 807	// strategy.
 808	ChunkingStrategy BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion `json:"chunking_strategy,omitzero"`
 809	// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
 810	// add to the vector store. There can be a maximum of 10000 files in a vector
 811	// store.
 812	FileIDs []string `json:"file_ids,omitzero"`
 813	paramObj
 814}
 815
 816func (r BetaThreadNewParamsToolResourcesFileSearchVectorStore) MarshalJSON() (data []byte, err error) {
 817	type shadow BetaThreadNewParamsToolResourcesFileSearchVectorStore
 818	return param.MarshalObject(r, (*shadow)(&r))
 819}
 820func (r *BetaThreadNewParamsToolResourcesFileSearchVectorStore) UnmarshalJSON(data []byte) error {
 821	return apijson.UnmarshalRoot(data, r)
 822}
 823
 824// Only one field can be non-zero.
 825//
 826// Use [param.IsOmitted] to confirm if a field is set.
 827type BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion struct {
 828	OfAuto   *BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto   `json:",omitzero,inline"`
 829	OfStatic *BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic `json:",omitzero,inline"`
 830	paramUnion
 831}
 832
 833func (u BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion) MarshalJSON() ([]byte, error) {
 834	return param.MarshalUnion(u, u.OfAuto, u.OfStatic)
 835}
 836func (u *BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion) UnmarshalJSON(data []byte) error {
 837	return apijson.UnmarshalRoot(data, u)
 838}
 839
 840func (u *BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion) asAny() any {
 841	if !param.IsOmitted(u.OfAuto) {
 842		return u.OfAuto
 843	} else if !param.IsOmitted(u.OfStatic) {
 844		return u.OfStatic
 845	}
 846	return nil
 847}
 848
 849// Returns a pointer to the underlying variant's property, if present.
 850func (u BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion) GetStatic() *BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic {
 851	if vt := u.OfStatic; vt != nil {
 852		return &vt.Static
 853	}
 854	return nil
 855}
 856
 857// Returns a pointer to the underlying variant's property, if present.
 858func (u BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion) GetType() *string {
 859	if vt := u.OfAuto; vt != nil {
 860		return (*string)(&vt.Type)
 861	} else if vt := u.OfStatic; vt != nil {
 862		return (*string)(&vt.Type)
 863	}
 864	return nil
 865}
 866
 867func init() {
 868	apijson.RegisterUnion[BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion](
 869		"type",
 870		apijson.Discriminator[BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto]("auto"),
 871		apijson.Discriminator[BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic]("static"),
 872	)
 873}
 874
 875func NewBetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto() BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto {
 876	return BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto{
 877		Type: "auto",
 878	}
 879}
 880
 881// The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
 882// `800` and `chunk_overlap_tokens` of `400`.
 883//
 884// This struct has a constant value, construct it with
 885// [NewBetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto].
 886type BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto struct {
 887	// Always `auto`.
 888	Type constant.Auto `json:"type,required"`
 889	paramObj
 890}
 891
 892func (r BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto) MarshalJSON() (data []byte, err error) {
 893	type shadow BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto
 894	return param.MarshalObject(r, (*shadow)(&r))
 895}
 896func (r *BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto) UnmarshalJSON(data []byte) error {
 897	return apijson.UnmarshalRoot(data, r)
 898}
 899
 900// The properties Static, Type are required.
 901type BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic struct {
 902	Static BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic `json:"static,omitzero,required"`
 903	// Always `static`.
 904	//
 905	// This field can be elided, and will marshal its zero value as "static".
 906	Type constant.Static `json:"type,required"`
 907	paramObj
 908}
 909
 910func (r BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic) MarshalJSON() (data []byte, err error) {
 911	type shadow BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic
 912	return param.MarshalObject(r, (*shadow)(&r))
 913}
 914func (r *BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic) UnmarshalJSON(data []byte) error {
 915	return apijson.UnmarshalRoot(data, r)
 916}
 917
 918// The properties ChunkOverlapTokens, MaxChunkSizeTokens are required.
 919type BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic struct {
 920	// The number of tokens that overlap between chunks. The default value is `400`.
 921	//
 922	// Note that the overlap must not exceed half of `max_chunk_size_tokens`.
 923	ChunkOverlapTokens int64 `json:"chunk_overlap_tokens,required"`
 924	// The maximum number of tokens in each chunk. The default value is `800`. The
 925	// minimum value is `100` and the maximum value is `4096`.
 926	MaxChunkSizeTokens int64 `json:"max_chunk_size_tokens,required"`
 927	paramObj
 928}
 929
 930func (r BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic) MarshalJSON() (data []byte, err error) {
 931	type shadow BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic
 932	return param.MarshalObject(r, (*shadow)(&r))
 933}
 934func (r *BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic) UnmarshalJSON(data []byte) error {
 935	return apijson.UnmarshalRoot(data, r)
 936}
 937
 938type BetaThreadUpdateParams struct {
 939	// Set of 16 key-value pairs that can be attached to an object. This can be useful
 940	// for storing additional information about the object in a structured format, and
 941	// querying for objects via API or the dashboard.
 942	//
 943	// Keys are strings with a maximum length of 64 characters. Values are strings with
 944	// a maximum length of 512 characters.
 945	Metadata shared.Metadata `json:"metadata,omitzero"`
 946	// A set of resources that are made available to the assistant's tools in this
 947	// thread. The resources are specific to the type of tool. For example, the
 948	// `code_interpreter` tool requires a list of file IDs, while the `file_search`
 949	// tool requires a list of vector store IDs.
 950	ToolResources BetaThreadUpdateParamsToolResources `json:"tool_resources,omitzero"`
 951	paramObj
 952}
 953
 954func (r BetaThreadUpdateParams) MarshalJSON() (data []byte, err error) {
 955	type shadow BetaThreadUpdateParams
 956	return param.MarshalObject(r, (*shadow)(&r))
 957}
 958func (r *BetaThreadUpdateParams) UnmarshalJSON(data []byte) error {
 959	return apijson.UnmarshalRoot(data, r)
 960}
 961
 962// A set of resources that are made available to the assistant's tools in this
 963// thread. The resources are specific to the type of tool. For example, the
 964// `code_interpreter` tool requires a list of file IDs, while the `file_search`
 965// tool requires a list of vector store IDs.
 966type BetaThreadUpdateParamsToolResources struct {
 967	CodeInterpreter BetaThreadUpdateParamsToolResourcesCodeInterpreter `json:"code_interpreter,omitzero"`
 968	FileSearch      BetaThreadUpdateParamsToolResourcesFileSearch      `json:"file_search,omitzero"`
 969	paramObj
 970}
 971
 972func (r BetaThreadUpdateParamsToolResources) MarshalJSON() (data []byte, err error) {
 973	type shadow BetaThreadUpdateParamsToolResources
 974	return param.MarshalObject(r, (*shadow)(&r))
 975}
 976func (r *BetaThreadUpdateParamsToolResources) UnmarshalJSON(data []byte) error {
 977	return apijson.UnmarshalRoot(data, r)
 978}
 979
 980type BetaThreadUpdateParamsToolResourcesCodeInterpreter struct {
 981	// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
 982	// available to the `code_interpreter` tool. There can be a maximum of 20 files
 983	// associated with the tool.
 984	FileIDs []string `json:"file_ids,omitzero"`
 985	paramObj
 986}
 987
 988func (r BetaThreadUpdateParamsToolResourcesCodeInterpreter) MarshalJSON() (data []byte, err error) {
 989	type shadow BetaThreadUpdateParamsToolResourcesCodeInterpreter
 990	return param.MarshalObject(r, (*shadow)(&r))
 991}
 992func (r *BetaThreadUpdateParamsToolResourcesCodeInterpreter) UnmarshalJSON(data []byte) error {
 993	return apijson.UnmarshalRoot(data, r)
 994}
 995
 996type BetaThreadUpdateParamsToolResourcesFileSearch struct {
 997	// The
 998	// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
 999	// attached to this thread. There can be a maximum of 1 vector store attached to
1000	// the thread.
1001	VectorStoreIDs []string `json:"vector_store_ids,omitzero"`
1002	paramObj
1003}
1004
1005func (r BetaThreadUpdateParamsToolResourcesFileSearch) MarshalJSON() (data []byte, err error) {
1006	type shadow BetaThreadUpdateParamsToolResourcesFileSearch
1007	return param.MarshalObject(r, (*shadow)(&r))
1008}
1009func (r *BetaThreadUpdateParamsToolResourcesFileSearch) UnmarshalJSON(data []byte) error {
1010	return apijson.UnmarshalRoot(data, r)
1011}
1012
1013type BetaThreadNewAndRunParams struct {
1014	// The ID of the
1015	// [assistant](https://platform.openai.com/docs/api-reference/assistants) to use to
1016	// execute this run.
1017	AssistantID string `json:"assistant_id,required"`
1018	// Override the default system message of the assistant. This is useful for
1019	// modifying the behavior on a per-run basis.
1020	Instructions param.Opt[string] `json:"instructions,omitzero"`
1021	// The maximum number of completion tokens that may be used over the course of the
1022	// run. The run will make a best effort to use only the number of completion tokens
1023	// specified, across multiple turns of the run. If the run exceeds the number of
1024	// completion tokens specified, the run will end with status `incomplete`. See
1025	// `incomplete_details` for more info.
1026	MaxCompletionTokens param.Opt[int64] `json:"max_completion_tokens,omitzero"`
1027	// The maximum number of prompt tokens that may be used over the course of the run.
1028	// The run will make a best effort to use only the number of prompt tokens
1029	// specified, across multiple turns of the run. If the run exceeds the number of
1030	// prompt tokens specified, the run will end with status `incomplete`. See
1031	// `incomplete_details` for more info.
1032	MaxPromptTokens param.Opt[int64] `json:"max_prompt_tokens,omitzero"`
1033	// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
1034	// make the output more random, while lower values like 0.2 will make it more
1035	// focused and deterministic.
1036	Temperature param.Opt[float64] `json:"temperature,omitzero"`
1037	// An alternative to sampling with temperature, called nucleus sampling, where the
1038	// model considers the results of the tokens with top_p probability mass. So 0.1
1039	// means only the tokens comprising the top 10% probability mass are considered.
1040	//
1041	// We generally recommend altering this or temperature but not both.
1042	TopP param.Opt[float64] `json:"top_p,omitzero"`
1043	// Whether to enable
1044	// [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling)
1045	// during tool use.
1046	ParallelToolCalls param.Opt[bool] `json:"parallel_tool_calls,omitzero"`
1047	// Set of 16 key-value pairs that can be attached to an object. This can be useful
1048	// for storing additional information about the object in a structured format, and
1049	// querying for objects via API or the dashboard.
1050	//
1051	// Keys are strings with a maximum length of 64 characters. Values are strings with
1052	// a maximum length of 512 characters.
1053	Metadata shared.Metadata `json:"metadata,omitzero"`
1054	// The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to
1055	// be used to execute this run. If a value is provided here, it will override the
1056	// model associated with the assistant. If not, the model associated with the
1057	// assistant will be used.
1058	Model shared.ChatModel `json:"model,omitzero"`
1059	// A set of resources that are used by the assistant's tools. The resources are
1060	// specific to the type of tool. For example, the `code_interpreter` tool requires
1061	// a list of file IDs, while the `file_search` tool requires a list of vector store
1062	// IDs.
1063	ToolResources BetaThreadNewAndRunParamsToolResources `json:"tool_resources,omitzero"`
1064	// Override the tools the assistant can use for this run. This is useful for
1065	// modifying the behavior on a per-run basis.
1066	Tools []AssistantToolUnionParam `json:"tools,omitzero"`
1067	// Controls for how a thread will be truncated prior to the run. Use this to
1068	// control the intial context window of the run.
1069	TruncationStrategy BetaThreadNewAndRunParamsTruncationStrategy `json:"truncation_strategy,omitzero"`
1070	// Specifies the format that the model must output. Compatible with
1071	// [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
1072	// [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
1073	// and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
1074	//
1075	// Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
1076	// Outputs which ensures the model will match your supplied JSON schema. Learn more
1077	// in the
1078	// [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
1079	//
1080	// Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
1081	// message the model generates is valid JSON.
1082	//
1083	// **Important:** when using JSON mode, you **must** also instruct the model to
1084	// produce JSON yourself via a system or user message. Without this, the model may
1085	// generate an unending stream of whitespace until the generation reaches the token
1086	// limit, resulting in a long-running and seemingly "stuck" request. Also note that
1087	// the message content may be partially cut off if `finish_reason="length"`, which
1088	// indicates the generation exceeded `max_tokens` or the conversation exceeded the
1089	// max context length.
1090	ResponseFormat AssistantResponseFormatOptionUnionParam `json:"response_format,omitzero"`
1091	// Options to create a new thread. If no thread is provided when running a request,
1092	// an empty thread will be created.
1093	Thread BetaThreadNewAndRunParamsThread `json:"thread,omitzero"`
1094	// Controls which (if any) tool is called by the model. `none` means the model will
1095	// not call any tools and instead generates a message. `auto` is the default value
1096	// and means the model can pick between generating a message or calling one or more
1097	// tools. `required` means the model must call one or more tools before responding
1098	// to the user. Specifying a particular tool like `{"type": "file_search"}` or
1099	// `{"type": "function", "function": {"name": "my_function"}}` forces the model to
1100	// call that tool.
1101	ToolChoice AssistantToolChoiceOptionUnionParam `json:"tool_choice,omitzero"`
1102	paramObj
1103}
1104
1105func (r BetaThreadNewAndRunParams) MarshalJSON() (data []byte, err error) {
1106	type shadow BetaThreadNewAndRunParams
1107	return param.MarshalObject(r, (*shadow)(&r))
1108}
1109func (r *BetaThreadNewAndRunParams) UnmarshalJSON(data []byte) error {
1110	return apijson.UnmarshalRoot(data, r)
1111}
1112
1113// Options to create a new thread. If no thread is provided when running a request,
1114// an empty thread will be created.
1115type BetaThreadNewAndRunParamsThread struct {
1116	// Set of 16 key-value pairs that can be attached to an object. This can be useful
1117	// for storing additional information about the object in a structured format, and
1118	// querying for objects via API or the dashboard.
1119	//
1120	// Keys are strings with a maximum length of 64 characters. Values are strings with
1121	// a maximum length of 512 characters.
1122	Metadata shared.Metadata `json:"metadata,omitzero"`
1123	// A set of resources that are made available to the assistant's tools in this
1124	// thread. The resources are specific to the type of tool. For example, the
1125	// `code_interpreter` tool requires a list of file IDs, while the `file_search`
1126	// tool requires a list of vector store IDs.
1127	ToolResources BetaThreadNewAndRunParamsThreadToolResources `json:"tool_resources,omitzero"`
1128	// A list of [messages](https://platform.openai.com/docs/api-reference/messages) to
1129	// start the thread with.
1130	Messages []BetaThreadNewAndRunParamsThreadMessage `json:"messages,omitzero"`
1131	paramObj
1132}
1133
1134func (r BetaThreadNewAndRunParamsThread) MarshalJSON() (data []byte, err error) {
1135	type shadow BetaThreadNewAndRunParamsThread
1136	return param.MarshalObject(r, (*shadow)(&r))
1137}
1138func (r *BetaThreadNewAndRunParamsThread) UnmarshalJSON(data []byte) error {
1139	return apijson.UnmarshalRoot(data, r)
1140}
1141
1142// The properties Content, Role are required.
1143type BetaThreadNewAndRunParamsThreadMessage struct {
1144	// The text contents of the message.
1145	Content BetaThreadNewAndRunParamsThreadMessageContentUnion `json:"content,omitzero,required"`
1146	// The role of the entity that is creating the message. Allowed values include:
1147	//
1148	//   - `user`: Indicates the message is sent by an actual user and should be used in
1149	//     most cases to represent user-generated messages.
1150	//   - `assistant`: Indicates the message is generated by the assistant. Use this
1151	//     value to insert messages from the assistant into the conversation.
1152	//
1153	// Any of "user", "assistant".
1154	Role string `json:"role,omitzero,required"`
1155	// A list of files attached to the message, and the tools they should be added to.
1156	Attachments []BetaThreadNewAndRunParamsThreadMessageAttachment `json:"attachments,omitzero"`
1157	// Set of 16 key-value pairs that can be attached to an object. This can be useful
1158	// for storing additional information about the object in a structured format, and
1159	// querying for objects via API or the dashboard.
1160	//
1161	// Keys are strings with a maximum length of 64 characters. Values are strings with
1162	// a maximum length of 512 characters.
1163	Metadata shared.Metadata `json:"metadata,omitzero"`
1164	paramObj
1165}
1166
1167func (r BetaThreadNewAndRunParamsThreadMessage) MarshalJSON() (data []byte, err error) {
1168	type shadow BetaThreadNewAndRunParamsThreadMessage
1169	return param.MarshalObject(r, (*shadow)(&r))
1170}
1171func (r *BetaThreadNewAndRunParamsThreadMessage) UnmarshalJSON(data []byte) error {
1172	return apijson.UnmarshalRoot(data, r)
1173}
1174
1175func init() {
1176	apijson.RegisterFieldValidator[BetaThreadNewAndRunParamsThreadMessage](
1177		"role", "user", "assistant",
1178	)
1179}
1180
1181// Only one field can be non-zero.
1182//
1183// Use [param.IsOmitted] to confirm if a field is set.
1184type BetaThreadNewAndRunParamsThreadMessageContentUnion struct {
1185	OfString              param.Opt[string]              `json:",omitzero,inline"`
1186	OfArrayOfContentParts []MessageContentPartParamUnion `json:",omitzero,inline"`
1187	paramUnion
1188}
1189
1190func (u BetaThreadNewAndRunParamsThreadMessageContentUnion) MarshalJSON() ([]byte, error) {
1191	return param.MarshalUnion(u, u.OfString, u.OfArrayOfContentParts)
1192}
1193func (u *BetaThreadNewAndRunParamsThreadMessageContentUnion) UnmarshalJSON(data []byte) error {
1194	return apijson.UnmarshalRoot(data, u)
1195}
1196
1197func (u *BetaThreadNewAndRunParamsThreadMessageContentUnion) asAny() any {
1198	if !param.IsOmitted(u.OfString) {
1199		return &u.OfString.Value
1200	} else if !param.IsOmitted(u.OfArrayOfContentParts) {
1201		return &u.OfArrayOfContentParts
1202	}
1203	return nil
1204}
1205
1206type BetaThreadNewAndRunParamsThreadMessageAttachment struct {
1207	// The ID of the file to attach to the message.
1208	FileID param.Opt[string] `json:"file_id,omitzero"`
1209	// The tools to add this file to.
1210	Tools []BetaThreadNewAndRunParamsThreadMessageAttachmentToolUnion `json:"tools,omitzero"`
1211	paramObj
1212}
1213
1214func (r BetaThreadNewAndRunParamsThreadMessageAttachment) MarshalJSON() (data []byte, err error) {
1215	type shadow BetaThreadNewAndRunParamsThreadMessageAttachment
1216	return param.MarshalObject(r, (*shadow)(&r))
1217}
1218func (r *BetaThreadNewAndRunParamsThreadMessageAttachment) UnmarshalJSON(data []byte) error {
1219	return apijson.UnmarshalRoot(data, r)
1220}
1221
1222// Only one field can be non-zero.
1223//
1224// Use [param.IsOmitted] to confirm if a field is set.
1225type BetaThreadNewAndRunParamsThreadMessageAttachmentToolUnion struct {
1226	OfCodeInterpreter *CodeInterpreterToolParam                                       `json:",omitzero,inline"`
1227	OfFileSearch      *BetaThreadNewAndRunParamsThreadMessageAttachmentToolFileSearch `json:",omitzero,inline"`
1228	paramUnion
1229}
1230
1231func (u BetaThreadNewAndRunParamsThreadMessageAttachmentToolUnion) MarshalJSON() ([]byte, error) {
1232	return param.MarshalUnion(u, u.OfCodeInterpreter, u.OfFileSearch)
1233}
1234func (u *BetaThreadNewAndRunParamsThreadMessageAttachmentToolUnion) UnmarshalJSON(data []byte) error {
1235	return apijson.UnmarshalRoot(data, u)
1236}
1237
1238func (u *BetaThreadNewAndRunParamsThreadMessageAttachmentToolUnion) asAny() any {
1239	if !param.IsOmitted(u.OfCodeInterpreter) {
1240		return u.OfCodeInterpreter
1241	} else if !param.IsOmitted(u.OfFileSearch) {
1242		return u.OfFileSearch
1243	}
1244	return nil
1245}
1246
1247// Returns a pointer to the underlying variant's property, if present.
1248func (u BetaThreadNewAndRunParamsThreadMessageAttachmentToolUnion) GetType() *string {
1249	if vt := u.OfCodeInterpreter; vt != nil {
1250		return (*string)(&vt.Type)
1251	} else if vt := u.OfFileSearch; vt != nil {
1252		return (*string)(&vt.Type)
1253	}
1254	return nil
1255}
1256
1257func init() {
1258	apijson.RegisterUnion[BetaThreadNewAndRunParamsThreadMessageAttachmentToolUnion](
1259		"type",
1260		apijson.Discriminator[CodeInterpreterToolParam]("code_interpreter"),
1261		apijson.Discriminator[BetaThreadNewAndRunParamsThreadMessageAttachmentToolFileSearch]("file_search"),
1262	)
1263}
1264
1265func NewBetaThreadNewAndRunParamsThreadMessageAttachmentToolFileSearch() BetaThreadNewAndRunParamsThreadMessageAttachmentToolFileSearch {
1266	return BetaThreadNewAndRunParamsThreadMessageAttachmentToolFileSearch{
1267		Type: "file_search",
1268	}
1269}
1270
1271// This struct has a constant value, construct it with
1272// [NewBetaThreadNewAndRunParamsThreadMessageAttachmentToolFileSearch].
1273type BetaThreadNewAndRunParamsThreadMessageAttachmentToolFileSearch struct {
1274	// The type of tool being defined: `file_search`
1275	Type constant.FileSearch `json:"type,required"`
1276	paramObj
1277}
1278
1279func (r BetaThreadNewAndRunParamsThreadMessageAttachmentToolFileSearch) MarshalJSON() (data []byte, err error) {
1280	type shadow BetaThreadNewAndRunParamsThreadMessageAttachmentToolFileSearch
1281	return param.MarshalObject(r, (*shadow)(&r))
1282}
1283func (r *BetaThreadNewAndRunParamsThreadMessageAttachmentToolFileSearch) UnmarshalJSON(data []byte) error {
1284	return apijson.UnmarshalRoot(data, r)
1285}
1286
1287// A set of resources that are made available to the assistant's tools in this
1288// thread. The resources are specific to the type of tool. For example, the
1289// `code_interpreter` tool requires a list of file IDs, while the `file_search`
1290// tool requires a list of vector store IDs.
1291type BetaThreadNewAndRunParamsThreadToolResources struct {
1292	CodeInterpreter BetaThreadNewAndRunParamsThreadToolResourcesCodeInterpreter `json:"code_interpreter,omitzero"`
1293	FileSearch      BetaThreadNewAndRunParamsThreadToolResourcesFileSearch      `json:"file_search,omitzero"`
1294	paramObj
1295}
1296
1297func (r BetaThreadNewAndRunParamsThreadToolResources) MarshalJSON() (data []byte, err error) {
1298	type shadow BetaThreadNewAndRunParamsThreadToolResources
1299	return param.MarshalObject(r, (*shadow)(&r))
1300}
1301func (r *BetaThreadNewAndRunParamsThreadToolResources) UnmarshalJSON(data []byte) error {
1302	return apijson.UnmarshalRoot(data, r)
1303}
1304
1305type BetaThreadNewAndRunParamsThreadToolResourcesCodeInterpreter struct {
1306	// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
1307	// available to the `code_interpreter` tool. There can be a maximum of 20 files
1308	// associated with the tool.
1309	FileIDs []string `json:"file_ids,omitzero"`
1310	paramObj
1311}
1312
1313func (r BetaThreadNewAndRunParamsThreadToolResourcesCodeInterpreter) MarshalJSON() (data []byte, err error) {
1314	type shadow BetaThreadNewAndRunParamsThreadToolResourcesCodeInterpreter
1315	return param.MarshalObject(r, (*shadow)(&r))
1316}
1317func (r *BetaThreadNewAndRunParamsThreadToolResourcesCodeInterpreter) UnmarshalJSON(data []byte) error {
1318	return apijson.UnmarshalRoot(data, r)
1319}
1320
1321type BetaThreadNewAndRunParamsThreadToolResourcesFileSearch struct {
1322	// The
1323	// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
1324	// attached to this thread. There can be a maximum of 1 vector store attached to
1325	// the thread.
1326	VectorStoreIDs []string `json:"vector_store_ids,omitzero"`
1327	// A helper to create a
1328	// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
1329	// with file_ids and attach it to this thread. There can be a maximum of 1 vector
1330	// store attached to the thread.
1331	VectorStores []BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStore `json:"vector_stores,omitzero"`
1332	paramObj
1333}
1334
1335func (r BetaThreadNewAndRunParamsThreadToolResourcesFileSearch) MarshalJSON() (data []byte, err error) {
1336	type shadow BetaThreadNewAndRunParamsThreadToolResourcesFileSearch
1337	return param.MarshalObject(r, (*shadow)(&r))
1338}
1339func (r *BetaThreadNewAndRunParamsThreadToolResourcesFileSearch) UnmarshalJSON(data []byte) error {
1340	return apijson.UnmarshalRoot(data, r)
1341}
1342
1343type BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStore struct {
1344	// Set of 16 key-value pairs that can be attached to an object. This can be useful
1345	// for storing additional information about the object in a structured format, and
1346	// querying for objects via API or the dashboard.
1347	//
1348	// Keys are strings with a maximum length of 64 characters. Values are strings with
1349	// a maximum length of 512 characters.
1350	Metadata shared.Metadata `json:"metadata,omitzero"`
1351	// The chunking strategy used to chunk the file(s). If not set, will use the `auto`
1352	// strategy.
1353	ChunkingStrategy BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyUnion `json:"chunking_strategy,omitzero"`
1354	// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
1355	// add to the vector store. There can be a maximum of 10000 files in a vector
1356	// store.
1357	FileIDs []string `json:"file_ids,omitzero"`
1358	paramObj
1359}
1360
1361func (r BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStore) MarshalJSON() (data []byte, err error) {
1362	type shadow BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStore
1363	return param.MarshalObject(r, (*shadow)(&r))
1364}
1365func (r *BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStore) UnmarshalJSON(data []byte) error {
1366	return apijson.UnmarshalRoot(data, r)
1367}
1368
1369// Only one field can be non-zero.
1370//
1371// Use [param.IsOmitted] to confirm if a field is set.
1372type BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyUnion struct {
1373	OfAuto   *BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyAuto   `json:",omitzero,inline"`
1374	OfStatic *BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyStatic `json:",omitzero,inline"`
1375	paramUnion
1376}
1377
1378func (u BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyUnion) MarshalJSON() ([]byte, error) {
1379	return param.MarshalUnion(u, u.OfAuto, u.OfStatic)
1380}
1381func (u *BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyUnion) UnmarshalJSON(data []byte) error {
1382	return apijson.UnmarshalRoot(data, u)
1383}
1384
1385func (u *BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyUnion) asAny() any {
1386	if !param.IsOmitted(u.OfAuto) {
1387		return u.OfAuto
1388	} else if !param.IsOmitted(u.OfStatic) {
1389		return u.OfStatic
1390	}
1391	return nil
1392}
1393
1394// Returns a pointer to the underlying variant's property, if present.
1395func (u BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyUnion) GetStatic() *BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic {
1396	if vt := u.OfStatic; vt != nil {
1397		return &vt.Static
1398	}
1399	return nil
1400}
1401
1402// Returns a pointer to the underlying variant's property, if present.
1403func (u BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyUnion) GetType() *string {
1404	if vt := u.OfAuto; vt != nil {
1405		return (*string)(&vt.Type)
1406	} else if vt := u.OfStatic; vt != nil {
1407		return (*string)(&vt.Type)
1408	}
1409	return nil
1410}
1411
1412func init() {
1413	apijson.RegisterUnion[BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyUnion](
1414		"type",
1415		apijson.Discriminator[BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyAuto]("auto"),
1416		apijson.Discriminator[BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyStatic]("static"),
1417	)
1418}
1419
1420func NewBetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyAuto() BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyAuto {
1421	return BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyAuto{
1422		Type: "auto",
1423	}
1424}
1425
1426// The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
1427// `800` and `chunk_overlap_tokens` of `400`.
1428//
1429// This struct has a constant value, construct it with
1430// [NewBetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyAuto].
1431type BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyAuto struct {
1432	// Always `auto`.
1433	Type constant.Auto `json:"type,required"`
1434	paramObj
1435}
1436
1437func (r BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyAuto) MarshalJSON() (data []byte, err error) {
1438	type shadow BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyAuto
1439	return param.MarshalObject(r, (*shadow)(&r))
1440}
1441func (r *BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyAuto) UnmarshalJSON(data []byte) error {
1442	return apijson.UnmarshalRoot(data, r)
1443}
1444
1445// The properties Static, Type are required.
1446type BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyStatic struct {
1447	Static BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic `json:"static,omitzero,required"`
1448	// Always `static`.
1449	//
1450	// This field can be elided, and will marshal its zero value as "static".
1451	Type constant.Static `json:"type,required"`
1452	paramObj
1453}
1454
1455func (r BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyStatic) MarshalJSON() (data []byte, err error) {
1456	type shadow BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyStatic
1457	return param.MarshalObject(r, (*shadow)(&r))
1458}
1459func (r *BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyStatic) UnmarshalJSON(data []byte) error {
1460	return apijson.UnmarshalRoot(data, r)
1461}
1462
1463// The properties ChunkOverlapTokens, MaxChunkSizeTokens are required.
1464type BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic struct {
1465	// The number of tokens that overlap between chunks. The default value is `400`.
1466	//
1467	// Note that the overlap must not exceed half of `max_chunk_size_tokens`.
1468	ChunkOverlapTokens int64 `json:"chunk_overlap_tokens,required"`
1469	// The maximum number of tokens in each chunk. The default value is `800`. The
1470	// minimum value is `100` and the maximum value is `4096`.
1471	MaxChunkSizeTokens int64 `json:"max_chunk_size_tokens,required"`
1472	paramObj
1473}
1474
1475func (r BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic) MarshalJSON() (data []byte, err error) {
1476	type shadow BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic
1477	return param.MarshalObject(r, (*shadow)(&r))
1478}
1479func (r *BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic) UnmarshalJSON(data []byte) error {
1480	return apijson.UnmarshalRoot(data, r)
1481}
1482
1483// A set of resources that are used by the assistant's tools. The resources are
1484// specific to the type of tool. For example, the `code_interpreter` tool requires
1485// a list of file IDs, while the `file_search` tool requires a list of vector store
1486// IDs.
1487type BetaThreadNewAndRunParamsToolResources struct {
1488	CodeInterpreter BetaThreadNewAndRunParamsToolResourcesCodeInterpreter `json:"code_interpreter,omitzero"`
1489	FileSearch      BetaThreadNewAndRunParamsToolResourcesFileSearch      `json:"file_search,omitzero"`
1490	paramObj
1491}
1492
1493func (r BetaThreadNewAndRunParamsToolResources) MarshalJSON() (data []byte, err error) {
1494	type shadow BetaThreadNewAndRunParamsToolResources
1495	return param.MarshalObject(r, (*shadow)(&r))
1496}
1497func (r *BetaThreadNewAndRunParamsToolResources) UnmarshalJSON(data []byte) error {
1498	return apijson.UnmarshalRoot(data, r)
1499}
1500
1501type BetaThreadNewAndRunParamsToolResourcesCodeInterpreter struct {
1502	// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
1503	// available to the `code_interpreter` tool. There can be a maximum of 20 files
1504	// associated with the tool.
1505	FileIDs []string `json:"file_ids,omitzero"`
1506	paramObj
1507}
1508
1509func (r BetaThreadNewAndRunParamsToolResourcesCodeInterpreter) MarshalJSON() (data []byte, err error) {
1510	type shadow BetaThreadNewAndRunParamsToolResourcesCodeInterpreter
1511	return param.MarshalObject(r, (*shadow)(&r))
1512}
1513func (r *BetaThreadNewAndRunParamsToolResourcesCodeInterpreter) UnmarshalJSON(data []byte) error {
1514	return apijson.UnmarshalRoot(data, r)
1515}
1516
1517type BetaThreadNewAndRunParamsToolResourcesFileSearch struct {
1518	// The ID of the
1519	// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
1520	// attached to this assistant. There can be a maximum of 1 vector store attached to
1521	// the assistant.
1522	VectorStoreIDs []string `json:"vector_store_ids,omitzero"`
1523	paramObj
1524}
1525
1526func (r BetaThreadNewAndRunParamsToolResourcesFileSearch) MarshalJSON() (data []byte, err error) {
1527	type shadow BetaThreadNewAndRunParamsToolResourcesFileSearch
1528	return param.MarshalObject(r, (*shadow)(&r))
1529}
1530func (r *BetaThreadNewAndRunParamsToolResourcesFileSearch) UnmarshalJSON(data []byte) error {
1531	return apijson.UnmarshalRoot(data, r)
1532}
1533
1534// Controls for how a thread will be truncated prior to the run. Use this to
1535// control the intial context window of the run.
1536//
1537// The property Type is required.
1538type BetaThreadNewAndRunParamsTruncationStrategy struct {
1539	// The truncation strategy to use for the thread. The default is `auto`. If set to
1540	// `last_messages`, the thread will be truncated to the n most recent messages in
1541	// the thread. When set to `auto`, messages in the middle of the thread will be
1542	// dropped to fit the context length of the model, `max_prompt_tokens`.
1543	//
1544	// Any of "auto", "last_messages".
1545	Type string `json:"type,omitzero,required"`
1546	// The number of most recent messages from the thread when constructing the context
1547	// for the run.
1548	LastMessages param.Opt[int64] `json:"last_messages,omitzero"`
1549	paramObj
1550}
1551
1552func (r BetaThreadNewAndRunParamsTruncationStrategy) MarshalJSON() (data []byte, err error) {
1553	type shadow BetaThreadNewAndRunParamsTruncationStrategy
1554	return param.MarshalObject(r, (*shadow)(&r))
1555}
1556func (r *BetaThreadNewAndRunParamsTruncationStrategy) UnmarshalJSON(data []byte) error {
1557	return apijson.UnmarshalRoot(data, r)
1558}
1559
1560func init() {
1561	apijson.RegisterFieldValidator[BetaThreadNewAndRunParamsTruncationStrategy](
1562		"type", "auto", "last_messages",
1563	)
1564}