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	"net/url"
  12
  13	"github.com/openai/openai-go/internal/apijson"
  14	"github.com/openai/openai-go/internal/apiquery"
  15	"github.com/openai/openai-go/internal/requestconfig"
  16	"github.com/openai/openai-go/option"
  17	"github.com/openai/openai-go/packages/pagination"
  18	"github.com/openai/openai-go/packages/param"
  19	"github.com/openai/openai-go/packages/respjson"
  20	"github.com/openai/openai-go/shared"
  21	"github.com/openai/openai-go/shared/constant"
  22)
  23
  24// BetaAssistantService contains methods and other services that help with
  25// interacting with the openai API.
  26//
  27// Note, unlike clients, this service does not read variables from the environment
  28// automatically. You should not instantiate this service directly, and instead use
  29// the [NewBetaAssistantService] method instead.
  30type BetaAssistantService struct {
  31	Options []option.RequestOption
  32}
  33
  34// NewBetaAssistantService generates a new service that applies the given options
  35// to each request. These options are applied after the parent client's options (if
  36// there is one), and before any request-specific options.
  37func NewBetaAssistantService(opts ...option.RequestOption) (r BetaAssistantService) {
  38	r = BetaAssistantService{}
  39	r.Options = opts
  40	return
  41}
  42
  43// Create an assistant with a model and instructions.
  44func (r *BetaAssistantService) New(ctx context.Context, body BetaAssistantNewParams, opts ...option.RequestOption) (res *Assistant, err error) {
  45	opts = append(r.Options[:], opts...)
  46	opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
  47	path := "assistants"
  48	err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
  49	return
  50}
  51
  52// Retrieves an assistant.
  53func (r *BetaAssistantService) Get(ctx context.Context, assistantID string, opts ...option.RequestOption) (res *Assistant, err error) {
  54	opts = append(r.Options[:], opts...)
  55	opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
  56	if assistantID == "" {
  57		err = errors.New("missing required assistant_id parameter")
  58		return
  59	}
  60	path := fmt.Sprintf("assistants/%s", assistantID)
  61	err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
  62	return
  63}
  64
  65// Modifies an assistant.
  66func (r *BetaAssistantService) Update(ctx context.Context, assistantID string, body BetaAssistantUpdateParams, opts ...option.RequestOption) (res *Assistant, err error) {
  67	opts = append(r.Options[:], opts...)
  68	opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
  69	if assistantID == "" {
  70		err = errors.New("missing required assistant_id parameter")
  71		return
  72	}
  73	path := fmt.Sprintf("assistants/%s", assistantID)
  74	err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
  75	return
  76}
  77
  78// Returns a list of assistants.
  79func (r *BetaAssistantService) List(ctx context.Context, query BetaAssistantListParams, opts ...option.RequestOption) (res *pagination.CursorPage[Assistant], err error) {
  80	var raw *http.Response
  81	opts = append(r.Options[:], opts...)
  82	opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2"), option.WithResponseInto(&raw)}, opts...)
  83	path := "assistants"
  84	cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
  85	if err != nil {
  86		return nil, err
  87	}
  88	err = cfg.Execute()
  89	if err != nil {
  90		return nil, err
  91	}
  92	res.SetPageConfig(cfg, raw)
  93	return res, nil
  94}
  95
  96// Returns a list of assistants.
  97func (r *BetaAssistantService) ListAutoPaging(ctx context.Context, query BetaAssistantListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[Assistant] {
  98	return pagination.NewCursorPageAutoPager(r.List(ctx, query, opts...))
  99}
 100
 101// Delete an assistant.
 102func (r *BetaAssistantService) Delete(ctx context.Context, assistantID string, opts ...option.RequestOption) (res *AssistantDeleted, err error) {
 103	opts = append(r.Options[:], opts...)
 104	opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
 105	if assistantID == "" {
 106		err = errors.New("missing required assistant_id parameter")
 107		return
 108	}
 109	path := fmt.Sprintf("assistants/%s", assistantID)
 110	err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
 111	return
 112}
 113
 114// Represents an `assistant` that can call the model and use tools.
 115type Assistant struct {
 116	// The identifier, which can be referenced in API endpoints.
 117	ID string `json:"id,required"`
 118	// The Unix timestamp (in seconds) for when the assistant was created.
 119	CreatedAt int64 `json:"created_at,required"`
 120	// The description of the assistant. The maximum length is 512 characters.
 121	Description string `json:"description,required"`
 122	// The system instructions that the assistant uses. The maximum length is 256,000
 123	// characters.
 124	Instructions string `json:"instructions,required"`
 125	// Set of 16 key-value pairs that can be attached to an object. This can be useful
 126	// for storing additional information about the object in a structured format, and
 127	// querying for objects via API or the dashboard.
 128	//
 129	// Keys are strings with a maximum length of 64 characters. Values are strings with
 130	// a maximum length of 512 characters.
 131	Metadata shared.Metadata `json:"metadata,required"`
 132	// ID of the model to use. You can use the
 133	// [List models](https://platform.openai.com/docs/api-reference/models/list) API to
 134	// see all of your available models, or see our
 135	// [Model overview](https://platform.openai.com/docs/models) for descriptions of
 136	// them.
 137	Model string `json:"model,required"`
 138	// The name of the assistant. The maximum length is 256 characters.
 139	Name string `json:"name,required"`
 140	// The object type, which is always `assistant`.
 141	Object constant.Assistant `json:"object,required"`
 142	// A list of tool enabled on the assistant. There can be a maximum of 128 tools per
 143	// assistant. Tools can be of types `code_interpreter`, `file_search`, or
 144	// `function`.
 145	Tools []AssistantToolUnion `json:"tools,required"`
 146	// Specifies the format that the model must output. Compatible with
 147	// [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
 148	// [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
 149	// and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
 150	//
 151	// Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
 152	// Outputs which ensures the model will match your supplied JSON schema. Learn more
 153	// in the
 154	// [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
 155	//
 156	// Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
 157	// message the model generates is valid JSON.
 158	//
 159	// **Important:** when using JSON mode, you **must** also instruct the model to
 160	// produce JSON yourself via a system or user message. Without this, the model may
 161	// generate an unending stream of whitespace until the generation reaches the token
 162	// limit, resulting in a long-running and seemingly "stuck" request. Also note that
 163	// the message content may be partially cut off if `finish_reason="length"`, which
 164	// indicates the generation exceeded `max_tokens` or the conversation exceeded the
 165	// max context length.
 166	ResponseFormat AssistantResponseFormatOptionUnion `json:"response_format,nullable"`
 167	// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
 168	// make the output more random, while lower values like 0.2 will make it more
 169	// focused and deterministic.
 170	Temperature float64 `json:"temperature,nullable"`
 171	// A set of resources that are used by the assistant's tools. The resources are
 172	// specific to the type of tool. For example, the `code_interpreter` tool requires
 173	// a list of file IDs, while the `file_search` tool requires a list of vector store
 174	// IDs.
 175	ToolResources AssistantToolResources `json:"tool_resources,nullable"`
 176	// An alternative to sampling with temperature, called nucleus sampling, where the
 177	// model considers the results of the tokens with top_p probability mass. So 0.1
 178	// means only the tokens comprising the top 10% probability mass are considered.
 179	//
 180	// We generally recommend altering this or temperature but not both.
 181	TopP float64 `json:"top_p,nullable"`
 182	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
 183	JSON struct {
 184		ID             respjson.Field
 185		CreatedAt      respjson.Field
 186		Description    respjson.Field
 187		Instructions   respjson.Field
 188		Metadata       respjson.Field
 189		Model          respjson.Field
 190		Name           respjson.Field
 191		Object         respjson.Field
 192		Tools          respjson.Field
 193		ResponseFormat respjson.Field
 194		Temperature    respjson.Field
 195		ToolResources  respjson.Field
 196		TopP           respjson.Field
 197		ExtraFields    map[string]respjson.Field
 198		raw            string
 199	} `json:"-"`
 200}
 201
 202// Returns the unmodified JSON received from the API
 203func (r Assistant) RawJSON() string { return r.JSON.raw }
 204func (r *Assistant) UnmarshalJSON(data []byte) error {
 205	return apijson.UnmarshalRoot(data, r)
 206}
 207
 208// A set of resources that are used by the assistant's tools. The resources are
 209// specific to the type of tool. For example, the `code_interpreter` tool requires
 210// a list of file IDs, while the `file_search` tool requires a list of vector store
 211// IDs.
 212type AssistantToolResources struct {
 213	CodeInterpreter AssistantToolResourcesCodeInterpreter `json:"code_interpreter"`
 214	FileSearch      AssistantToolResourcesFileSearch      `json:"file_search"`
 215	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
 216	JSON struct {
 217		CodeInterpreter respjson.Field
 218		FileSearch      respjson.Field
 219		ExtraFields     map[string]respjson.Field
 220		raw             string
 221	} `json:"-"`
 222}
 223
 224// Returns the unmodified JSON received from the API
 225func (r AssistantToolResources) RawJSON() string { return r.JSON.raw }
 226func (r *AssistantToolResources) UnmarshalJSON(data []byte) error {
 227	return apijson.UnmarshalRoot(data, r)
 228}
 229
 230type AssistantToolResourcesCodeInterpreter struct {
 231	// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
 232	// available to the `code_interpreter“ tool. There can be a maximum of 20 files
 233	// associated with the tool.
 234	FileIDs []string `json:"file_ids"`
 235	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
 236	JSON struct {
 237		FileIDs     respjson.Field
 238		ExtraFields map[string]respjson.Field
 239		raw         string
 240	} `json:"-"`
 241}
 242
 243// Returns the unmodified JSON received from the API
 244func (r AssistantToolResourcesCodeInterpreter) RawJSON() string { return r.JSON.raw }
 245func (r *AssistantToolResourcesCodeInterpreter) UnmarshalJSON(data []byte) error {
 246	return apijson.UnmarshalRoot(data, r)
 247}
 248
 249type AssistantToolResourcesFileSearch struct {
 250	// The ID of the
 251	// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
 252	// attached to this assistant. There can be a maximum of 1 vector store attached to
 253	// the assistant.
 254	VectorStoreIDs []string `json:"vector_store_ids"`
 255	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
 256	JSON struct {
 257		VectorStoreIDs respjson.Field
 258		ExtraFields    map[string]respjson.Field
 259		raw            string
 260	} `json:"-"`
 261}
 262
 263// Returns the unmodified JSON received from the API
 264func (r AssistantToolResourcesFileSearch) RawJSON() string { return r.JSON.raw }
 265func (r *AssistantToolResourcesFileSearch) UnmarshalJSON(data []byte) error {
 266	return apijson.UnmarshalRoot(data, r)
 267}
 268
 269type AssistantDeleted struct {
 270	ID      string                    `json:"id,required"`
 271	Deleted bool                      `json:"deleted,required"`
 272	Object  constant.AssistantDeleted `json:"object,required"`
 273	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
 274	JSON struct {
 275		ID          respjson.Field
 276		Deleted     respjson.Field
 277		Object      respjson.Field
 278		ExtraFields map[string]respjson.Field
 279		raw         string
 280	} `json:"-"`
 281}
 282
 283// Returns the unmodified JSON received from the API
 284func (r AssistantDeleted) RawJSON() string { return r.JSON.raw }
 285func (r *AssistantDeleted) UnmarshalJSON(data []byte) error {
 286	return apijson.UnmarshalRoot(data, r)
 287}
 288
 289// AssistantStreamEventUnion contains all possible properties and values from
 290// [AssistantStreamEventThreadCreated], [AssistantStreamEventThreadRunCreated],
 291// [AssistantStreamEventThreadRunQueued],
 292// [AssistantStreamEventThreadRunInProgress],
 293// [AssistantStreamEventThreadRunRequiresAction],
 294// [AssistantStreamEventThreadRunCompleted],
 295// [AssistantStreamEventThreadRunIncomplete],
 296// [AssistantStreamEventThreadRunFailed],
 297// [AssistantStreamEventThreadRunCancelling],
 298// [AssistantStreamEventThreadRunCancelled],
 299// [AssistantStreamEventThreadRunExpired],
 300// [AssistantStreamEventThreadRunStepCreated],
 301// [AssistantStreamEventThreadRunStepInProgress],
 302// [AssistantStreamEventThreadRunStepDelta],
 303// [AssistantStreamEventThreadRunStepCompleted],
 304// [AssistantStreamEventThreadRunStepFailed],
 305// [AssistantStreamEventThreadRunStepCancelled],
 306// [AssistantStreamEventThreadRunStepExpired],
 307// [AssistantStreamEventThreadMessageCreated],
 308// [AssistantStreamEventThreadMessageInProgress],
 309// [AssistantStreamEventThreadMessageDelta],
 310// [AssistantStreamEventThreadMessageCompleted],
 311// [AssistantStreamEventThreadMessageIncomplete], [AssistantStreamEventErrorEvent].
 312//
 313// Use the [AssistantStreamEventUnion.AsAny] method to switch on the variant.
 314//
 315// Use the methods beginning with 'As' to cast the union to one of its variants.
 316type AssistantStreamEventUnion struct {
 317	// This field is a union of [Thread], [Run], [RunStep], [RunStepDeltaEvent],
 318	// [Message], [MessageDeltaEvent], [shared.ErrorObject]
 319	Data AssistantStreamEventUnionData `json:"data"`
 320	// Any of "thread.created", "thread.run.created", "thread.run.queued",
 321	// "thread.run.in_progress", "thread.run.requires_action", "thread.run.completed",
 322	// "thread.run.incomplete", "thread.run.failed", "thread.run.cancelling",
 323	// "thread.run.cancelled", "thread.run.expired", "thread.run.step.created",
 324	// "thread.run.step.in_progress", "thread.run.step.delta",
 325	// "thread.run.step.completed", "thread.run.step.failed",
 326	// "thread.run.step.cancelled", "thread.run.step.expired",
 327	// "thread.message.created", "thread.message.in_progress", "thread.message.delta",
 328	// "thread.message.completed", "thread.message.incomplete", "error".
 329	Event string `json:"event"`
 330	// This field is from variant [AssistantStreamEventThreadCreated].
 331	Enabled bool `json:"enabled"`
 332	JSON    struct {
 333		Data    respjson.Field
 334		Event   respjson.Field
 335		Enabled respjson.Field
 336		raw     string
 337	} `json:"-"`
 338}
 339
 340// anyAssistantStreamEvent is implemented by each variant of
 341// [AssistantStreamEventUnion] to add type safety for the return type of
 342// [AssistantStreamEventUnion.AsAny]
 343type anyAssistantStreamEvent interface {
 344	implAssistantStreamEventUnion()
 345}
 346
 347func (AssistantStreamEventThreadCreated) implAssistantStreamEventUnion()           {}
 348func (AssistantStreamEventThreadRunCreated) implAssistantStreamEventUnion()        {}
 349func (AssistantStreamEventThreadRunQueued) implAssistantStreamEventUnion()         {}
 350func (AssistantStreamEventThreadRunInProgress) implAssistantStreamEventUnion()     {}
 351func (AssistantStreamEventThreadRunRequiresAction) implAssistantStreamEventUnion() {}
 352func (AssistantStreamEventThreadRunCompleted) implAssistantStreamEventUnion()      {}
 353func (AssistantStreamEventThreadRunIncomplete) implAssistantStreamEventUnion()     {}
 354func (AssistantStreamEventThreadRunFailed) implAssistantStreamEventUnion()         {}
 355func (AssistantStreamEventThreadRunCancelling) implAssistantStreamEventUnion()     {}
 356func (AssistantStreamEventThreadRunCancelled) implAssistantStreamEventUnion()      {}
 357func (AssistantStreamEventThreadRunExpired) implAssistantStreamEventUnion()        {}
 358func (AssistantStreamEventThreadRunStepCreated) implAssistantStreamEventUnion()    {}
 359func (AssistantStreamEventThreadRunStepInProgress) implAssistantStreamEventUnion() {}
 360func (AssistantStreamEventThreadRunStepDelta) implAssistantStreamEventUnion()      {}
 361func (AssistantStreamEventThreadRunStepCompleted) implAssistantStreamEventUnion()  {}
 362func (AssistantStreamEventThreadRunStepFailed) implAssistantStreamEventUnion()     {}
 363func (AssistantStreamEventThreadRunStepCancelled) implAssistantStreamEventUnion()  {}
 364func (AssistantStreamEventThreadRunStepExpired) implAssistantStreamEventUnion()    {}
 365func (AssistantStreamEventThreadMessageCreated) implAssistantStreamEventUnion()    {}
 366func (AssistantStreamEventThreadMessageInProgress) implAssistantStreamEventUnion() {}
 367func (AssistantStreamEventThreadMessageDelta) implAssistantStreamEventUnion()      {}
 368func (AssistantStreamEventThreadMessageCompleted) implAssistantStreamEventUnion()  {}
 369func (AssistantStreamEventThreadMessageIncomplete) implAssistantStreamEventUnion() {}
 370func (AssistantStreamEventErrorEvent) implAssistantStreamEventUnion()              {}
 371
 372// Use the following switch statement to find the correct variant
 373//
 374//	switch variant := AssistantStreamEventUnion.AsAny().(type) {
 375//	case openai.AssistantStreamEventThreadCreated:
 376//	case openai.AssistantStreamEventThreadRunCreated:
 377//	case openai.AssistantStreamEventThreadRunQueued:
 378//	case openai.AssistantStreamEventThreadRunInProgress:
 379//	case openai.AssistantStreamEventThreadRunRequiresAction:
 380//	case openai.AssistantStreamEventThreadRunCompleted:
 381//	case openai.AssistantStreamEventThreadRunIncomplete:
 382//	case openai.AssistantStreamEventThreadRunFailed:
 383//	case openai.AssistantStreamEventThreadRunCancelling:
 384//	case openai.AssistantStreamEventThreadRunCancelled:
 385//	case openai.AssistantStreamEventThreadRunExpired:
 386//	case openai.AssistantStreamEventThreadRunStepCreated:
 387//	case openai.AssistantStreamEventThreadRunStepInProgress:
 388//	case openai.AssistantStreamEventThreadRunStepDelta:
 389//	case openai.AssistantStreamEventThreadRunStepCompleted:
 390//	case openai.AssistantStreamEventThreadRunStepFailed:
 391//	case openai.AssistantStreamEventThreadRunStepCancelled:
 392//	case openai.AssistantStreamEventThreadRunStepExpired:
 393//	case openai.AssistantStreamEventThreadMessageCreated:
 394//	case openai.AssistantStreamEventThreadMessageInProgress:
 395//	case openai.AssistantStreamEventThreadMessageDelta:
 396//	case openai.AssistantStreamEventThreadMessageCompleted:
 397//	case openai.AssistantStreamEventThreadMessageIncomplete:
 398//	case openai.AssistantStreamEventErrorEvent:
 399//	default:
 400//	  fmt.Errorf("no variant present")
 401//	}
 402func (u AssistantStreamEventUnion) AsAny() anyAssistantStreamEvent {
 403	switch u.Event {
 404	case "thread.created":
 405		return u.AsThreadCreated()
 406	case "thread.run.created":
 407		return u.AsThreadRunCreated()
 408	case "thread.run.queued":
 409		return u.AsThreadRunQueued()
 410	case "thread.run.in_progress":
 411		return u.AsThreadRunInProgress()
 412	case "thread.run.requires_action":
 413		return u.AsThreadRunRequiresAction()
 414	case "thread.run.completed":
 415		return u.AsThreadRunCompleted()
 416	case "thread.run.incomplete":
 417		return u.AsThreadRunIncomplete()
 418	case "thread.run.failed":
 419		return u.AsThreadRunFailed()
 420	case "thread.run.cancelling":
 421		return u.AsThreadRunCancelling()
 422	case "thread.run.cancelled":
 423		return u.AsThreadRunCancelled()
 424	case "thread.run.expired":
 425		return u.AsThreadRunExpired()
 426	case "thread.run.step.created":
 427		return u.AsThreadRunStepCreated()
 428	case "thread.run.step.in_progress":
 429		return u.AsThreadRunStepInProgress()
 430	case "thread.run.step.delta":
 431		return u.AsThreadRunStepDelta()
 432	case "thread.run.step.completed":
 433		return u.AsThreadRunStepCompleted()
 434	case "thread.run.step.failed":
 435		return u.AsThreadRunStepFailed()
 436	case "thread.run.step.cancelled":
 437		return u.AsThreadRunStepCancelled()
 438	case "thread.run.step.expired":
 439		return u.AsThreadRunStepExpired()
 440	case "thread.message.created":
 441		return u.AsThreadMessageCreated()
 442	case "thread.message.in_progress":
 443		return u.AsThreadMessageInProgress()
 444	case "thread.message.delta":
 445		return u.AsThreadMessageDelta()
 446	case "thread.message.completed":
 447		return u.AsThreadMessageCompleted()
 448	case "thread.message.incomplete":
 449		return u.AsThreadMessageIncomplete()
 450	case "error":
 451		return u.AsErrorEvent()
 452	}
 453	return nil
 454}
 455
 456func (u AssistantStreamEventUnion) AsThreadCreated() (v AssistantStreamEventThreadCreated) {
 457	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 458	return
 459}
 460
 461func (u AssistantStreamEventUnion) AsThreadRunCreated() (v AssistantStreamEventThreadRunCreated) {
 462	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 463	return
 464}
 465
 466func (u AssistantStreamEventUnion) AsThreadRunQueued() (v AssistantStreamEventThreadRunQueued) {
 467	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 468	return
 469}
 470
 471func (u AssistantStreamEventUnion) AsThreadRunInProgress() (v AssistantStreamEventThreadRunInProgress) {
 472	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 473	return
 474}
 475
 476func (u AssistantStreamEventUnion) AsThreadRunRequiresAction() (v AssistantStreamEventThreadRunRequiresAction) {
 477	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 478	return
 479}
 480
 481func (u AssistantStreamEventUnion) AsThreadRunCompleted() (v AssistantStreamEventThreadRunCompleted) {
 482	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 483	return
 484}
 485
 486func (u AssistantStreamEventUnion) AsThreadRunIncomplete() (v AssistantStreamEventThreadRunIncomplete) {
 487	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 488	return
 489}
 490
 491func (u AssistantStreamEventUnion) AsThreadRunFailed() (v AssistantStreamEventThreadRunFailed) {
 492	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 493	return
 494}
 495
 496func (u AssistantStreamEventUnion) AsThreadRunCancelling() (v AssistantStreamEventThreadRunCancelling) {
 497	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 498	return
 499}
 500
 501func (u AssistantStreamEventUnion) AsThreadRunCancelled() (v AssistantStreamEventThreadRunCancelled) {
 502	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 503	return
 504}
 505
 506func (u AssistantStreamEventUnion) AsThreadRunExpired() (v AssistantStreamEventThreadRunExpired) {
 507	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 508	return
 509}
 510
 511func (u AssistantStreamEventUnion) AsThreadRunStepCreated() (v AssistantStreamEventThreadRunStepCreated) {
 512	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 513	return
 514}
 515
 516func (u AssistantStreamEventUnion) AsThreadRunStepInProgress() (v AssistantStreamEventThreadRunStepInProgress) {
 517	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 518	return
 519}
 520
 521func (u AssistantStreamEventUnion) AsThreadRunStepDelta() (v AssistantStreamEventThreadRunStepDelta) {
 522	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 523	return
 524}
 525
 526func (u AssistantStreamEventUnion) AsThreadRunStepCompleted() (v AssistantStreamEventThreadRunStepCompleted) {
 527	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 528	return
 529}
 530
 531func (u AssistantStreamEventUnion) AsThreadRunStepFailed() (v AssistantStreamEventThreadRunStepFailed) {
 532	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 533	return
 534}
 535
 536func (u AssistantStreamEventUnion) AsThreadRunStepCancelled() (v AssistantStreamEventThreadRunStepCancelled) {
 537	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 538	return
 539}
 540
 541func (u AssistantStreamEventUnion) AsThreadRunStepExpired() (v AssistantStreamEventThreadRunStepExpired) {
 542	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 543	return
 544}
 545
 546func (u AssistantStreamEventUnion) AsThreadMessageCreated() (v AssistantStreamEventThreadMessageCreated) {
 547	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 548	return
 549}
 550
 551func (u AssistantStreamEventUnion) AsThreadMessageInProgress() (v AssistantStreamEventThreadMessageInProgress) {
 552	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 553	return
 554}
 555
 556func (u AssistantStreamEventUnion) AsThreadMessageDelta() (v AssistantStreamEventThreadMessageDelta) {
 557	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 558	return
 559}
 560
 561func (u AssistantStreamEventUnion) AsThreadMessageCompleted() (v AssistantStreamEventThreadMessageCompleted) {
 562	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 563	return
 564}
 565
 566func (u AssistantStreamEventUnion) AsThreadMessageIncomplete() (v AssistantStreamEventThreadMessageIncomplete) {
 567	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 568	return
 569}
 570
 571func (u AssistantStreamEventUnion) AsErrorEvent() (v AssistantStreamEventErrorEvent) {
 572	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 573	return
 574}
 575
 576// Returns the unmodified JSON received from the API
 577func (u AssistantStreamEventUnion) RawJSON() string { return u.JSON.raw }
 578
 579func (r *AssistantStreamEventUnion) UnmarshalJSON(data []byte) error {
 580	return apijson.UnmarshalRoot(data, r)
 581}
 582
 583// AssistantStreamEventUnionData is an implicit subunion of
 584// [AssistantStreamEventUnion]. AssistantStreamEventUnionData provides convenient
 585// access to the sub-properties of the union.
 586//
 587// For type safety it is recommended to directly use a variant of the
 588// [AssistantStreamEventUnion].
 589type AssistantStreamEventUnionData struct {
 590	ID        string `json:"id"`
 591	CreatedAt int64  `json:"created_at"`
 592	// This field is from variant [Thread].
 593	Metadata shared.Metadata `json:"metadata"`
 594	Object   string          `json:"object"`
 595	// This field is from variant [Thread].
 596	ToolResources ThreadToolResources `json:"tool_resources"`
 597	AssistantID   string              `json:"assistant_id"`
 598	CancelledAt   int64               `json:"cancelled_at"`
 599	CompletedAt   int64               `json:"completed_at"`
 600	// This field is from variant [Run].
 601	ExpiresAt int64 `json:"expires_at"`
 602	FailedAt  int64 `json:"failed_at"`
 603	// This field is a union of [RunIncompleteDetails], [MessageIncompleteDetails]
 604	IncompleteDetails AssistantStreamEventUnionDataIncompleteDetails `json:"incomplete_details"`
 605	// This field is from variant [Run].
 606	Instructions string `json:"instructions"`
 607	// This field is a union of [RunLastError], [RunStepLastError]
 608	LastError AssistantStreamEventUnionDataLastError `json:"last_error"`
 609	// This field is from variant [Run].
 610	MaxCompletionTokens int64 `json:"max_completion_tokens"`
 611	// This field is from variant [Run].
 612	MaxPromptTokens int64 `json:"max_prompt_tokens"`
 613	// This field is from variant [Run].
 614	Model string `json:"model"`
 615	// This field is from variant [Run].
 616	ParallelToolCalls bool `json:"parallel_tool_calls"`
 617	// This field is from variant [Run].
 618	RequiredAction RunRequiredAction `json:"required_action"`
 619	// This field is from variant [Run].
 620	ResponseFormat AssistantResponseFormatOptionUnion `json:"response_format"`
 621	// This field is from variant [Run].
 622	StartedAt int64  `json:"started_at"`
 623	Status    string `json:"status"`
 624	ThreadID  string `json:"thread_id"`
 625	// This field is from variant [Run].
 626	ToolChoice AssistantToolChoiceOptionUnion `json:"tool_choice"`
 627	// This field is from variant [Run].
 628	Tools []AssistantToolUnion `json:"tools"`
 629	// This field is from variant [Run].
 630	TruncationStrategy RunTruncationStrategy `json:"truncation_strategy"`
 631	// This field is a union of [RunUsage], [RunStepUsage]
 632	Usage AssistantStreamEventUnionDataUsage `json:"usage"`
 633	// This field is from variant [Run].
 634	Temperature float64 `json:"temperature"`
 635	// This field is from variant [Run].
 636	TopP float64 `json:"top_p"`
 637	// This field is from variant [RunStep].
 638	ExpiredAt int64  `json:"expired_at"`
 639	RunID     string `json:"run_id"`
 640	// This field is from variant [RunStep].
 641	StepDetails RunStepStepDetailsUnion `json:"step_details"`
 642	Type        string                  `json:"type"`
 643	// This field is a union of [RunStepDelta], [MessageDelta]
 644	Delta AssistantStreamEventUnionDataDelta `json:"delta"`
 645	// This field is from variant [Message].
 646	Attachments []MessageAttachment `json:"attachments"`
 647	// This field is from variant [Message].
 648	Content []MessageContentUnion `json:"content"`
 649	// This field is from variant [Message].
 650	IncompleteAt int64 `json:"incomplete_at"`
 651	// This field is from variant [Message].
 652	Role MessageRole `json:"role"`
 653	// This field is from variant [shared.ErrorObject].
 654	Code string `json:"code"`
 655	// This field is from variant [shared.ErrorObject].
 656	Message string `json:"message"`
 657	// This field is from variant [shared.ErrorObject].
 658	Param string `json:"param"`
 659	JSON  struct {
 660		ID                  respjson.Field
 661		CreatedAt           respjson.Field
 662		Metadata            respjson.Field
 663		Object              respjson.Field
 664		ToolResources       respjson.Field
 665		AssistantID         respjson.Field
 666		CancelledAt         respjson.Field
 667		CompletedAt         respjson.Field
 668		ExpiresAt           respjson.Field
 669		FailedAt            respjson.Field
 670		IncompleteDetails   respjson.Field
 671		Instructions        respjson.Field
 672		LastError           respjson.Field
 673		MaxCompletionTokens respjson.Field
 674		MaxPromptTokens     respjson.Field
 675		Model               respjson.Field
 676		ParallelToolCalls   respjson.Field
 677		RequiredAction      respjson.Field
 678		ResponseFormat      respjson.Field
 679		StartedAt           respjson.Field
 680		Status              respjson.Field
 681		ThreadID            respjson.Field
 682		ToolChoice          respjson.Field
 683		Tools               respjson.Field
 684		TruncationStrategy  respjson.Field
 685		Usage               respjson.Field
 686		Temperature         respjson.Field
 687		TopP                respjson.Field
 688		ExpiredAt           respjson.Field
 689		RunID               respjson.Field
 690		StepDetails         respjson.Field
 691		Type                respjson.Field
 692		Delta               respjson.Field
 693		Attachments         respjson.Field
 694		Content             respjson.Field
 695		IncompleteAt        respjson.Field
 696		Role                respjson.Field
 697		Code                respjson.Field
 698		Message             respjson.Field
 699		Param               respjson.Field
 700		raw                 string
 701	} `json:"-"`
 702}
 703
 704func (r *AssistantStreamEventUnionData) UnmarshalJSON(data []byte) error {
 705	return apijson.UnmarshalRoot(data, r)
 706}
 707
 708// AssistantStreamEventUnionDataIncompleteDetails is an implicit subunion of
 709// [AssistantStreamEventUnion]. AssistantStreamEventUnionDataIncompleteDetails
 710// provides convenient access to the sub-properties of the union.
 711//
 712// For type safety it is recommended to directly use a variant of the
 713// [AssistantStreamEventUnion].
 714type AssistantStreamEventUnionDataIncompleteDetails struct {
 715	Reason string `json:"reason"`
 716	JSON   struct {
 717		Reason respjson.Field
 718		raw    string
 719	} `json:"-"`
 720}
 721
 722func (r *AssistantStreamEventUnionDataIncompleteDetails) UnmarshalJSON(data []byte) error {
 723	return apijson.UnmarshalRoot(data, r)
 724}
 725
 726// AssistantStreamEventUnionDataLastError is an implicit subunion of
 727// [AssistantStreamEventUnion]. AssistantStreamEventUnionDataLastError provides
 728// convenient access to the sub-properties of the union.
 729//
 730// For type safety it is recommended to directly use a variant of the
 731// [AssistantStreamEventUnion].
 732type AssistantStreamEventUnionDataLastError struct {
 733	Code    string `json:"code"`
 734	Message string `json:"message"`
 735	JSON    struct {
 736		Code    respjson.Field
 737		Message respjson.Field
 738		raw     string
 739	} `json:"-"`
 740}
 741
 742func (r *AssistantStreamEventUnionDataLastError) UnmarshalJSON(data []byte) error {
 743	return apijson.UnmarshalRoot(data, r)
 744}
 745
 746// AssistantStreamEventUnionDataUsage is an implicit subunion of
 747// [AssistantStreamEventUnion]. AssistantStreamEventUnionDataUsage provides
 748// convenient access to the sub-properties of the union.
 749//
 750// For type safety it is recommended to directly use a variant of the
 751// [AssistantStreamEventUnion].
 752type AssistantStreamEventUnionDataUsage struct {
 753	CompletionTokens int64 `json:"completion_tokens"`
 754	PromptTokens     int64 `json:"prompt_tokens"`
 755	TotalTokens      int64 `json:"total_tokens"`
 756	JSON             struct {
 757		CompletionTokens respjson.Field
 758		PromptTokens     respjson.Field
 759		TotalTokens      respjson.Field
 760		raw              string
 761	} `json:"-"`
 762}
 763
 764func (r *AssistantStreamEventUnionDataUsage) UnmarshalJSON(data []byte) error {
 765	return apijson.UnmarshalRoot(data, r)
 766}
 767
 768// AssistantStreamEventUnionDataDelta is an implicit subunion of
 769// [AssistantStreamEventUnion]. AssistantStreamEventUnionDataDelta provides
 770// convenient access to the sub-properties of the union.
 771//
 772// For type safety it is recommended to directly use a variant of the
 773// [AssistantStreamEventUnion].
 774type AssistantStreamEventUnionDataDelta struct {
 775	// This field is from variant [RunStepDelta].
 776	StepDetails RunStepDeltaStepDetailsUnion `json:"step_details"`
 777	// This field is from variant [MessageDelta].
 778	Content []MessageContentDeltaUnion `json:"content"`
 779	// This field is from variant [MessageDelta].
 780	Role MessageDeltaRole `json:"role"`
 781	JSON struct {
 782		StepDetails respjson.Field
 783		Content     respjson.Field
 784		Role        respjson.Field
 785		raw         string
 786	} `json:"-"`
 787}
 788
 789func (r *AssistantStreamEventUnionDataDelta) UnmarshalJSON(data []byte) error {
 790	return apijson.UnmarshalRoot(data, r)
 791}
 792
 793// Occurs when a new
 794// [thread](https://platform.openai.com/docs/api-reference/threads/object) is
 795// created.
 796type AssistantStreamEventThreadCreated struct {
 797	// Represents a thread that contains
 798	// [messages](https://platform.openai.com/docs/api-reference/messages).
 799	Data  Thread                 `json:"data,required"`
 800	Event constant.ThreadCreated `json:"event,required"`
 801	// Whether to enable input audio transcription.
 802	Enabled bool `json:"enabled"`
 803	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
 804	JSON struct {
 805		Data        respjson.Field
 806		Event       respjson.Field
 807		Enabled     respjson.Field
 808		ExtraFields map[string]respjson.Field
 809		raw         string
 810	} `json:"-"`
 811}
 812
 813// Returns the unmodified JSON received from the API
 814func (r AssistantStreamEventThreadCreated) RawJSON() string { return r.JSON.raw }
 815func (r *AssistantStreamEventThreadCreated) UnmarshalJSON(data []byte) error {
 816	return apijson.UnmarshalRoot(data, r)
 817}
 818
 819// Occurs when a new
 820// [run](https://platform.openai.com/docs/api-reference/runs/object) is created.
 821type AssistantStreamEventThreadRunCreated struct {
 822	// Represents an execution run on a
 823	// [thread](https://platform.openai.com/docs/api-reference/threads).
 824	Data  Run                       `json:"data,required"`
 825	Event constant.ThreadRunCreated `json:"event,required"`
 826	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
 827	JSON struct {
 828		Data        respjson.Field
 829		Event       respjson.Field
 830		ExtraFields map[string]respjson.Field
 831		raw         string
 832	} `json:"-"`
 833}
 834
 835// Returns the unmodified JSON received from the API
 836func (r AssistantStreamEventThreadRunCreated) RawJSON() string { return r.JSON.raw }
 837func (r *AssistantStreamEventThreadRunCreated) UnmarshalJSON(data []byte) error {
 838	return apijson.UnmarshalRoot(data, r)
 839}
 840
 841// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
 842// moves to a `queued` status.
 843type AssistantStreamEventThreadRunQueued struct {
 844	// Represents an execution run on a
 845	// [thread](https://platform.openai.com/docs/api-reference/threads).
 846	Data  Run                      `json:"data,required"`
 847	Event constant.ThreadRunQueued `json:"event,required"`
 848	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
 849	JSON struct {
 850		Data        respjson.Field
 851		Event       respjson.Field
 852		ExtraFields map[string]respjson.Field
 853		raw         string
 854	} `json:"-"`
 855}
 856
 857// Returns the unmodified JSON received from the API
 858func (r AssistantStreamEventThreadRunQueued) RawJSON() string { return r.JSON.raw }
 859func (r *AssistantStreamEventThreadRunQueued) UnmarshalJSON(data []byte) error {
 860	return apijson.UnmarshalRoot(data, r)
 861}
 862
 863// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
 864// moves to an `in_progress` status.
 865type AssistantStreamEventThreadRunInProgress struct {
 866	// Represents an execution run on a
 867	// [thread](https://platform.openai.com/docs/api-reference/threads).
 868	Data  Run                          `json:"data,required"`
 869	Event constant.ThreadRunInProgress `json:"event,required"`
 870	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
 871	JSON struct {
 872		Data        respjson.Field
 873		Event       respjson.Field
 874		ExtraFields map[string]respjson.Field
 875		raw         string
 876	} `json:"-"`
 877}
 878
 879// Returns the unmodified JSON received from the API
 880func (r AssistantStreamEventThreadRunInProgress) RawJSON() string { return r.JSON.raw }
 881func (r *AssistantStreamEventThreadRunInProgress) UnmarshalJSON(data []byte) error {
 882	return apijson.UnmarshalRoot(data, r)
 883}
 884
 885// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
 886// moves to a `requires_action` status.
 887type AssistantStreamEventThreadRunRequiresAction struct {
 888	// Represents an execution run on a
 889	// [thread](https://platform.openai.com/docs/api-reference/threads).
 890	Data  Run                              `json:"data,required"`
 891	Event constant.ThreadRunRequiresAction `json:"event,required"`
 892	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
 893	JSON struct {
 894		Data        respjson.Field
 895		Event       respjson.Field
 896		ExtraFields map[string]respjson.Field
 897		raw         string
 898	} `json:"-"`
 899}
 900
 901// Returns the unmodified JSON received from the API
 902func (r AssistantStreamEventThreadRunRequiresAction) RawJSON() string { return r.JSON.raw }
 903func (r *AssistantStreamEventThreadRunRequiresAction) UnmarshalJSON(data []byte) error {
 904	return apijson.UnmarshalRoot(data, r)
 905}
 906
 907// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
 908// is completed.
 909type AssistantStreamEventThreadRunCompleted struct {
 910	// Represents an execution run on a
 911	// [thread](https://platform.openai.com/docs/api-reference/threads).
 912	Data  Run                         `json:"data,required"`
 913	Event constant.ThreadRunCompleted `json:"event,required"`
 914	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
 915	JSON struct {
 916		Data        respjson.Field
 917		Event       respjson.Field
 918		ExtraFields map[string]respjson.Field
 919		raw         string
 920	} `json:"-"`
 921}
 922
 923// Returns the unmodified JSON received from the API
 924func (r AssistantStreamEventThreadRunCompleted) RawJSON() string { return r.JSON.raw }
 925func (r *AssistantStreamEventThreadRunCompleted) UnmarshalJSON(data []byte) error {
 926	return apijson.UnmarshalRoot(data, r)
 927}
 928
 929// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
 930// ends with status `incomplete`.
 931type AssistantStreamEventThreadRunIncomplete struct {
 932	// Represents an execution run on a
 933	// [thread](https://platform.openai.com/docs/api-reference/threads).
 934	Data  Run                          `json:"data,required"`
 935	Event constant.ThreadRunIncomplete `json:"event,required"`
 936	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
 937	JSON struct {
 938		Data        respjson.Field
 939		Event       respjson.Field
 940		ExtraFields map[string]respjson.Field
 941		raw         string
 942	} `json:"-"`
 943}
 944
 945// Returns the unmodified JSON received from the API
 946func (r AssistantStreamEventThreadRunIncomplete) RawJSON() string { return r.JSON.raw }
 947func (r *AssistantStreamEventThreadRunIncomplete) UnmarshalJSON(data []byte) error {
 948	return apijson.UnmarshalRoot(data, r)
 949}
 950
 951// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
 952// fails.
 953type AssistantStreamEventThreadRunFailed struct {
 954	// Represents an execution run on a
 955	// [thread](https://platform.openai.com/docs/api-reference/threads).
 956	Data  Run                      `json:"data,required"`
 957	Event constant.ThreadRunFailed `json:"event,required"`
 958	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
 959	JSON struct {
 960		Data        respjson.Field
 961		Event       respjson.Field
 962		ExtraFields map[string]respjson.Field
 963		raw         string
 964	} `json:"-"`
 965}
 966
 967// Returns the unmodified JSON received from the API
 968func (r AssistantStreamEventThreadRunFailed) RawJSON() string { return r.JSON.raw }
 969func (r *AssistantStreamEventThreadRunFailed) UnmarshalJSON(data []byte) error {
 970	return apijson.UnmarshalRoot(data, r)
 971}
 972
 973// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
 974// moves to a `cancelling` status.
 975type AssistantStreamEventThreadRunCancelling struct {
 976	// Represents an execution run on a
 977	// [thread](https://platform.openai.com/docs/api-reference/threads).
 978	Data  Run                          `json:"data,required"`
 979	Event constant.ThreadRunCancelling `json:"event,required"`
 980	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
 981	JSON struct {
 982		Data        respjson.Field
 983		Event       respjson.Field
 984		ExtraFields map[string]respjson.Field
 985		raw         string
 986	} `json:"-"`
 987}
 988
 989// Returns the unmodified JSON received from the API
 990func (r AssistantStreamEventThreadRunCancelling) RawJSON() string { return r.JSON.raw }
 991func (r *AssistantStreamEventThreadRunCancelling) UnmarshalJSON(data []byte) error {
 992	return apijson.UnmarshalRoot(data, r)
 993}
 994
 995// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
 996// is cancelled.
 997type AssistantStreamEventThreadRunCancelled struct {
 998	// Represents an execution run on a
 999	// [thread](https://platform.openai.com/docs/api-reference/threads).
1000	Data  Run                         `json:"data,required"`
1001	Event constant.ThreadRunCancelled `json:"event,required"`
1002	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1003	JSON struct {
1004		Data        respjson.Field
1005		Event       respjson.Field
1006		ExtraFields map[string]respjson.Field
1007		raw         string
1008	} `json:"-"`
1009}
1010
1011// Returns the unmodified JSON received from the API
1012func (r AssistantStreamEventThreadRunCancelled) RawJSON() string { return r.JSON.raw }
1013func (r *AssistantStreamEventThreadRunCancelled) UnmarshalJSON(data []byte) error {
1014	return apijson.UnmarshalRoot(data, r)
1015}
1016
1017// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
1018// expires.
1019type AssistantStreamEventThreadRunExpired struct {
1020	// Represents an execution run on a
1021	// [thread](https://platform.openai.com/docs/api-reference/threads).
1022	Data  Run                       `json:"data,required"`
1023	Event constant.ThreadRunExpired `json:"event,required"`
1024	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1025	JSON struct {
1026		Data        respjson.Field
1027		Event       respjson.Field
1028		ExtraFields map[string]respjson.Field
1029		raw         string
1030	} `json:"-"`
1031}
1032
1033// Returns the unmodified JSON received from the API
1034func (r AssistantStreamEventThreadRunExpired) RawJSON() string { return r.JSON.raw }
1035func (r *AssistantStreamEventThreadRunExpired) UnmarshalJSON(data []byte) error {
1036	return apijson.UnmarshalRoot(data, r)
1037}
1038
1039// Occurs when a
1040// [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
1041// is created.
1042type AssistantStreamEventThreadRunStepCreated struct {
1043	// Represents a step in execution of a run.
1044	Data  RunStep                       `json:"data,required"`
1045	Event constant.ThreadRunStepCreated `json:"event,required"`
1046	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1047	JSON struct {
1048		Data        respjson.Field
1049		Event       respjson.Field
1050		ExtraFields map[string]respjson.Field
1051		raw         string
1052	} `json:"-"`
1053}
1054
1055// Returns the unmodified JSON received from the API
1056func (r AssistantStreamEventThreadRunStepCreated) RawJSON() string { return r.JSON.raw }
1057func (r *AssistantStreamEventThreadRunStepCreated) UnmarshalJSON(data []byte) error {
1058	return apijson.UnmarshalRoot(data, r)
1059}
1060
1061// Occurs when a
1062// [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
1063// moves to an `in_progress` state.
1064type AssistantStreamEventThreadRunStepInProgress struct {
1065	// Represents a step in execution of a run.
1066	Data  RunStep                          `json:"data,required"`
1067	Event constant.ThreadRunStepInProgress `json:"event,required"`
1068	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1069	JSON struct {
1070		Data        respjson.Field
1071		Event       respjson.Field
1072		ExtraFields map[string]respjson.Field
1073		raw         string
1074	} `json:"-"`
1075}
1076
1077// Returns the unmodified JSON received from the API
1078func (r AssistantStreamEventThreadRunStepInProgress) RawJSON() string { return r.JSON.raw }
1079func (r *AssistantStreamEventThreadRunStepInProgress) UnmarshalJSON(data []byte) error {
1080	return apijson.UnmarshalRoot(data, r)
1081}
1082
1083// Occurs when parts of a
1084// [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
1085// are being streamed.
1086type AssistantStreamEventThreadRunStepDelta struct {
1087	// Represents a run step delta i.e. any changed fields on a run step during
1088	// streaming.
1089	Data  RunStepDeltaEvent           `json:"data,required"`
1090	Event constant.ThreadRunStepDelta `json:"event,required"`
1091	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1092	JSON struct {
1093		Data        respjson.Field
1094		Event       respjson.Field
1095		ExtraFields map[string]respjson.Field
1096		raw         string
1097	} `json:"-"`
1098}
1099
1100// Returns the unmodified JSON received from the API
1101func (r AssistantStreamEventThreadRunStepDelta) RawJSON() string { return r.JSON.raw }
1102func (r *AssistantStreamEventThreadRunStepDelta) UnmarshalJSON(data []byte) error {
1103	return apijson.UnmarshalRoot(data, r)
1104}
1105
1106// Occurs when a
1107// [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
1108// is completed.
1109type AssistantStreamEventThreadRunStepCompleted struct {
1110	// Represents a step in execution of a run.
1111	Data  RunStep                         `json:"data,required"`
1112	Event constant.ThreadRunStepCompleted `json:"event,required"`
1113	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1114	JSON struct {
1115		Data        respjson.Field
1116		Event       respjson.Field
1117		ExtraFields map[string]respjson.Field
1118		raw         string
1119	} `json:"-"`
1120}
1121
1122// Returns the unmodified JSON received from the API
1123func (r AssistantStreamEventThreadRunStepCompleted) RawJSON() string { return r.JSON.raw }
1124func (r *AssistantStreamEventThreadRunStepCompleted) UnmarshalJSON(data []byte) error {
1125	return apijson.UnmarshalRoot(data, r)
1126}
1127
1128// Occurs when a
1129// [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
1130// fails.
1131type AssistantStreamEventThreadRunStepFailed struct {
1132	// Represents a step in execution of a run.
1133	Data  RunStep                      `json:"data,required"`
1134	Event constant.ThreadRunStepFailed `json:"event,required"`
1135	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1136	JSON struct {
1137		Data        respjson.Field
1138		Event       respjson.Field
1139		ExtraFields map[string]respjson.Field
1140		raw         string
1141	} `json:"-"`
1142}
1143
1144// Returns the unmodified JSON received from the API
1145func (r AssistantStreamEventThreadRunStepFailed) RawJSON() string { return r.JSON.raw }
1146func (r *AssistantStreamEventThreadRunStepFailed) UnmarshalJSON(data []byte) error {
1147	return apijson.UnmarshalRoot(data, r)
1148}
1149
1150// Occurs when a
1151// [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
1152// is cancelled.
1153type AssistantStreamEventThreadRunStepCancelled struct {
1154	// Represents a step in execution of a run.
1155	Data  RunStep                         `json:"data,required"`
1156	Event constant.ThreadRunStepCancelled `json:"event,required"`
1157	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1158	JSON struct {
1159		Data        respjson.Field
1160		Event       respjson.Field
1161		ExtraFields map[string]respjson.Field
1162		raw         string
1163	} `json:"-"`
1164}
1165
1166// Returns the unmodified JSON received from the API
1167func (r AssistantStreamEventThreadRunStepCancelled) RawJSON() string { return r.JSON.raw }
1168func (r *AssistantStreamEventThreadRunStepCancelled) UnmarshalJSON(data []byte) error {
1169	return apijson.UnmarshalRoot(data, r)
1170}
1171
1172// Occurs when a
1173// [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
1174// expires.
1175type AssistantStreamEventThreadRunStepExpired struct {
1176	// Represents a step in execution of a run.
1177	Data  RunStep                       `json:"data,required"`
1178	Event constant.ThreadRunStepExpired `json:"event,required"`
1179	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1180	JSON struct {
1181		Data        respjson.Field
1182		Event       respjson.Field
1183		ExtraFields map[string]respjson.Field
1184		raw         string
1185	} `json:"-"`
1186}
1187
1188// Returns the unmodified JSON received from the API
1189func (r AssistantStreamEventThreadRunStepExpired) RawJSON() string { return r.JSON.raw }
1190func (r *AssistantStreamEventThreadRunStepExpired) UnmarshalJSON(data []byte) error {
1191	return apijson.UnmarshalRoot(data, r)
1192}
1193
1194// Occurs when a
1195// [message](https://platform.openai.com/docs/api-reference/messages/object) is
1196// created.
1197type AssistantStreamEventThreadMessageCreated struct {
1198	// Represents a message within a
1199	// [thread](https://platform.openai.com/docs/api-reference/threads).
1200	Data  Message                       `json:"data,required"`
1201	Event constant.ThreadMessageCreated `json:"event,required"`
1202	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1203	JSON struct {
1204		Data        respjson.Field
1205		Event       respjson.Field
1206		ExtraFields map[string]respjson.Field
1207		raw         string
1208	} `json:"-"`
1209}
1210
1211// Returns the unmodified JSON received from the API
1212func (r AssistantStreamEventThreadMessageCreated) RawJSON() string { return r.JSON.raw }
1213func (r *AssistantStreamEventThreadMessageCreated) UnmarshalJSON(data []byte) error {
1214	return apijson.UnmarshalRoot(data, r)
1215}
1216
1217// Occurs when a
1218// [message](https://platform.openai.com/docs/api-reference/messages/object) moves
1219// to an `in_progress` state.
1220type AssistantStreamEventThreadMessageInProgress struct {
1221	// Represents a message within a
1222	// [thread](https://platform.openai.com/docs/api-reference/threads).
1223	Data  Message                          `json:"data,required"`
1224	Event constant.ThreadMessageInProgress `json:"event,required"`
1225	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1226	JSON struct {
1227		Data        respjson.Field
1228		Event       respjson.Field
1229		ExtraFields map[string]respjson.Field
1230		raw         string
1231	} `json:"-"`
1232}
1233
1234// Returns the unmodified JSON received from the API
1235func (r AssistantStreamEventThreadMessageInProgress) RawJSON() string { return r.JSON.raw }
1236func (r *AssistantStreamEventThreadMessageInProgress) UnmarshalJSON(data []byte) error {
1237	return apijson.UnmarshalRoot(data, r)
1238}
1239
1240// Occurs when parts of a
1241// [Message](https://platform.openai.com/docs/api-reference/messages/object) are
1242// being streamed.
1243type AssistantStreamEventThreadMessageDelta struct {
1244	// Represents a message delta i.e. any changed fields on a message during
1245	// streaming.
1246	Data  MessageDeltaEvent           `json:"data,required"`
1247	Event constant.ThreadMessageDelta `json:"event,required"`
1248	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1249	JSON struct {
1250		Data        respjson.Field
1251		Event       respjson.Field
1252		ExtraFields map[string]respjson.Field
1253		raw         string
1254	} `json:"-"`
1255}
1256
1257// Returns the unmodified JSON received from the API
1258func (r AssistantStreamEventThreadMessageDelta) RawJSON() string { return r.JSON.raw }
1259func (r *AssistantStreamEventThreadMessageDelta) UnmarshalJSON(data []byte) error {
1260	return apijson.UnmarshalRoot(data, r)
1261}
1262
1263// Occurs when a
1264// [message](https://platform.openai.com/docs/api-reference/messages/object) is
1265// completed.
1266type AssistantStreamEventThreadMessageCompleted struct {
1267	// Represents a message within a
1268	// [thread](https://platform.openai.com/docs/api-reference/threads).
1269	Data  Message                         `json:"data,required"`
1270	Event constant.ThreadMessageCompleted `json:"event,required"`
1271	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1272	JSON struct {
1273		Data        respjson.Field
1274		Event       respjson.Field
1275		ExtraFields map[string]respjson.Field
1276		raw         string
1277	} `json:"-"`
1278}
1279
1280// Returns the unmodified JSON received from the API
1281func (r AssistantStreamEventThreadMessageCompleted) RawJSON() string { return r.JSON.raw }
1282func (r *AssistantStreamEventThreadMessageCompleted) UnmarshalJSON(data []byte) error {
1283	return apijson.UnmarshalRoot(data, r)
1284}
1285
1286// Occurs when a
1287// [message](https://platform.openai.com/docs/api-reference/messages/object) ends
1288// before it is completed.
1289type AssistantStreamEventThreadMessageIncomplete struct {
1290	// Represents a message within a
1291	// [thread](https://platform.openai.com/docs/api-reference/threads).
1292	Data  Message                          `json:"data,required"`
1293	Event constant.ThreadMessageIncomplete `json:"event,required"`
1294	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1295	JSON struct {
1296		Data        respjson.Field
1297		Event       respjson.Field
1298		ExtraFields map[string]respjson.Field
1299		raw         string
1300	} `json:"-"`
1301}
1302
1303// Returns the unmodified JSON received from the API
1304func (r AssistantStreamEventThreadMessageIncomplete) RawJSON() string { return r.JSON.raw }
1305func (r *AssistantStreamEventThreadMessageIncomplete) UnmarshalJSON(data []byte) error {
1306	return apijson.UnmarshalRoot(data, r)
1307}
1308
1309// Occurs when an
1310// [error](https://platform.openai.com/docs/guides/error-codes#api-errors) occurs.
1311// This can happen due to an internal server error or a timeout.
1312type AssistantStreamEventErrorEvent struct {
1313	Data  shared.ErrorObject `json:"data,required"`
1314	Event constant.Error     `json:"event,required"`
1315	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1316	JSON struct {
1317		Data        respjson.Field
1318		Event       respjson.Field
1319		ExtraFields map[string]respjson.Field
1320		raw         string
1321	} `json:"-"`
1322}
1323
1324// Returns the unmodified JSON received from the API
1325func (r AssistantStreamEventErrorEvent) RawJSON() string { return r.JSON.raw }
1326func (r *AssistantStreamEventErrorEvent) UnmarshalJSON(data []byte) error {
1327	return apijson.UnmarshalRoot(data, r)
1328}
1329
1330// AssistantToolUnion contains all possible properties and values from
1331// [CodeInterpreterTool], [FileSearchTool], [FunctionTool].
1332//
1333// Use the [AssistantToolUnion.AsAny] method to switch on the variant.
1334//
1335// Use the methods beginning with 'As' to cast the union to one of its variants.
1336type AssistantToolUnion struct {
1337	// Any of "code_interpreter", "file_search", "function".
1338	Type string `json:"type"`
1339	// This field is from variant [FileSearchTool].
1340	FileSearch FileSearchToolFileSearch `json:"file_search"`
1341	// This field is from variant [FunctionTool].
1342	Function shared.FunctionDefinition `json:"function"`
1343	JSON     struct {
1344		Type       respjson.Field
1345		FileSearch respjson.Field
1346		Function   respjson.Field
1347		raw        string
1348	} `json:"-"`
1349}
1350
1351// anyAssistantTool is implemented by each variant of [AssistantToolUnion] to add
1352// type safety for the return type of [AssistantToolUnion.AsAny]
1353type anyAssistantTool interface {
1354	implAssistantToolUnion()
1355}
1356
1357func (CodeInterpreterTool) implAssistantToolUnion() {}
1358func (FileSearchTool) implAssistantToolUnion()      {}
1359func (FunctionTool) implAssistantToolUnion()        {}
1360
1361// Use the following switch statement to find the correct variant
1362//
1363//	switch variant := AssistantToolUnion.AsAny().(type) {
1364//	case openai.CodeInterpreterTool:
1365//	case openai.FileSearchTool:
1366//	case openai.FunctionTool:
1367//	default:
1368//	  fmt.Errorf("no variant present")
1369//	}
1370func (u AssistantToolUnion) AsAny() anyAssistantTool {
1371	switch u.Type {
1372	case "code_interpreter":
1373		return u.AsCodeInterpreter()
1374	case "file_search":
1375		return u.AsFileSearch()
1376	case "function":
1377		return u.AsFunction()
1378	}
1379	return nil
1380}
1381
1382func (u AssistantToolUnion) AsCodeInterpreter() (v CodeInterpreterTool) {
1383	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1384	return
1385}
1386
1387func (u AssistantToolUnion) AsFileSearch() (v FileSearchTool) {
1388	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1389	return
1390}
1391
1392func (u AssistantToolUnion) AsFunction() (v FunctionTool) {
1393	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1394	return
1395}
1396
1397// Returns the unmodified JSON received from the API
1398func (u AssistantToolUnion) RawJSON() string { return u.JSON.raw }
1399
1400func (r *AssistantToolUnion) UnmarshalJSON(data []byte) error {
1401	return apijson.UnmarshalRoot(data, r)
1402}
1403
1404// ToParam converts this AssistantToolUnion to a AssistantToolUnionParam.
1405//
1406// Warning: the fields of the param type will not be present. ToParam should only
1407// be used at the last possible moment before sending a request. Test for this with
1408// AssistantToolUnionParam.Overrides()
1409func (r AssistantToolUnion) ToParam() AssistantToolUnionParam {
1410	return param.Override[AssistantToolUnionParam](json.RawMessage(r.RawJSON()))
1411}
1412
1413func AssistantToolParamOfFunction(function shared.FunctionDefinitionParam) AssistantToolUnionParam {
1414	var variant FunctionToolParam
1415	variant.Function = function
1416	return AssistantToolUnionParam{OfFunction: &variant}
1417}
1418
1419// Only one field can be non-zero.
1420//
1421// Use [param.IsOmitted] to confirm if a field is set.
1422type AssistantToolUnionParam struct {
1423	OfCodeInterpreter *CodeInterpreterToolParam `json:",omitzero,inline"`
1424	OfFileSearch      *FileSearchToolParam      `json:",omitzero,inline"`
1425	OfFunction        *FunctionToolParam        `json:",omitzero,inline"`
1426	paramUnion
1427}
1428
1429func (u AssistantToolUnionParam) MarshalJSON() ([]byte, error) {
1430	return param.MarshalUnion(u, u.OfCodeInterpreter, u.OfFileSearch, u.OfFunction)
1431}
1432func (u *AssistantToolUnionParam) UnmarshalJSON(data []byte) error {
1433	return apijson.UnmarshalRoot(data, u)
1434}
1435
1436func (u *AssistantToolUnionParam) asAny() any {
1437	if !param.IsOmitted(u.OfCodeInterpreter) {
1438		return u.OfCodeInterpreter
1439	} else if !param.IsOmitted(u.OfFileSearch) {
1440		return u.OfFileSearch
1441	} else if !param.IsOmitted(u.OfFunction) {
1442		return u.OfFunction
1443	}
1444	return nil
1445}
1446
1447// Returns a pointer to the underlying variant's property, if present.
1448func (u AssistantToolUnionParam) GetFileSearch() *FileSearchToolFileSearchParam {
1449	if vt := u.OfFileSearch; vt != nil {
1450		return &vt.FileSearch
1451	}
1452	return nil
1453}
1454
1455// Returns a pointer to the underlying variant's property, if present.
1456func (u AssistantToolUnionParam) GetFunction() *shared.FunctionDefinitionParam {
1457	if vt := u.OfFunction; vt != nil {
1458		return &vt.Function
1459	}
1460	return nil
1461}
1462
1463// Returns a pointer to the underlying variant's property, if present.
1464func (u AssistantToolUnionParam) GetType() *string {
1465	if vt := u.OfCodeInterpreter; vt != nil {
1466		return (*string)(&vt.Type)
1467	} else if vt := u.OfFileSearch; vt != nil {
1468		return (*string)(&vt.Type)
1469	} else if vt := u.OfFunction; vt != nil {
1470		return (*string)(&vt.Type)
1471	}
1472	return nil
1473}
1474
1475func init() {
1476	apijson.RegisterUnion[AssistantToolUnionParam](
1477		"type",
1478		apijson.Discriminator[CodeInterpreterToolParam]("code_interpreter"),
1479		apijson.Discriminator[FileSearchToolParam]("file_search"),
1480		apijson.Discriminator[FunctionToolParam]("function"),
1481	)
1482}
1483
1484type CodeInterpreterTool struct {
1485	// The type of tool being defined: `code_interpreter`
1486	Type constant.CodeInterpreter `json:"type,required"`
1487	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1488	JSON struct {
1489		Type        respjson.Field
1490		ExtraFields map[string]respjson.Field
1491		raw         string
1492	} `json:"-"`
1493}
1494
1495// Returns the unmodified JSON received from the API
1496func (r CodeInterpreterTool) RawJSON() string { return r.JSON.raw }
1497func (r *CodeInterpreterTool) UnmarshalJSON(data []byte) error {
1498	return apijson.UnmarshalRoot(data, r)
1499}
1500
1501// ToParam converts this CodeInterpreterTool to a CodeInterpreterToolParam.
1502//
1503// Warning: the fields of the param type will not be present. ToParam should only
1504// be used at the last possible moment before sending a request. Test for this with
1505// CodeInterpreterToolParam.Overrides()
1506func (r CodeInterpreterTool) ToParam() CodeInterpreterToolParam {
1507	return param.Override[CodeInterpreterToolParam](json.RawMessage(r.RawJSON()))
1508}
1509
1510func NewCodeInterpreterToolParam() CodeInterpreterToolParam {
1511	return CodeInterpreterToolParam{
1512		Type: "code_interpreter",
1513	}
1514}
1515
1516// This struct has a constant value, construct it with
1517// [NewCodeInterpreterToolParam].
1518type CodeInterpreterToolParam struct {
1519	// The type of tool being defined: `code_interpreter`
1520	Type constant.CodeInterpreter `json:"type,required"`
1521	paramObj
1522}
1523
1524func (r CodeInterpreterToolParam) MarshalJSON() (data []byte, err error) {
1525	type shadow CodeInterpreterToolParam
1526	return param.MarshalObject(r, (*shadow)(&r))
1527}
1528func (r *CodeInterpreterToolParam) UnmarshalJSON(data []byte) error {
1529	return apijson.UnmarshalRoot(data, r)
1530}
1531
1532type FileSearchTool struct {
1533	// The type of tool being defined: `file_search`
1534	Type constant.FileSearch `json:"type,required"`
1535	// Overrides for the file search tool.
1536	FileSearch FileSearchToolFileSearch `json:"file_search"`
1537	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1538	JSON struct {
1539		Type        respjson.Field
1540		FileSearch  respjson.Field
1541		ExtraFields map[string]respjson.Field
1542		raw         string
1543	} `json:"-"`
1544}
1545
1546// Returns the unmodified JSON received from the API
1547func (r FileSearchTool) RawJSON() string { return r.JSON.raw }
1548func (r *FileSearchTool) UnmarshalJSON(data []byte) error {
1549	return apijson.UnmarshalRoot(data, r)
1550}
1551
1552// ToParam converts this FileSearchTool to a FileSearchToolParam.
1553//
1554// Warning: the fields of the param type will not be present. ToParam should only
1555// be used at the last possible moment before sending a request. Test for this with
1556// FileSearchToolParam.Overrides()
1557func (r FileSearchTool) ToParam() FileSearchToolParam {
1558	return param.Override[FileSearchToolParam](json.RawMessage(r.RawJSON()))
1559}
1560
1561// Overrides for the file search tool.
1562type FileSearchToolFileSearch struct {
1563	// The maximum number of results the file search tool should output. The default is
1564	// 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between
1565	// 1 and 50 inclusive.
1566	//
1567	// Note that the file search tool may output fewer than `max_num_results` results.
1568	// See the
1569	// [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
1570	// for more information.
1571	MaxNumResults int64 `json:"max_num_results"`
1572	// The ranking options for the file search. If not specified, the file search tool
1573	// will use the `auto` ranker and a score_threshold of 0.
1574	//
1575	// See the
1576	// [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
1577	// for more information.
1578	RankingOptions FileSearchToolFileSearchRankingOptions `json:"ranking_options"`
1579	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1580	JSON struct {
1581		MaxNumResults  respjson.Field
1582		RankingOptions respjson.Field
1583		ExtraFields    map[string]respjson.Field
1584		raw            string
1585	} `json:"-"`
1586}
1587
1588// Returns the unmodified JSON received from the API
1589func (r FileSearchToolFileSearch) RawJSON() string { return r.JSON.raw }
1590func (r *FileSearchToolFileSearch) UnmarshalJSON(data []byte) error {
1591	return apijson.UnmarshalRoot(data, r)
1592}
1593
1594// The ranking options for the file search. If not specified, the file search tool
1595// will use the `auto` ranker and a score_threshold of 0.
1596//
1597// See the
1598// [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
1599// for more information.
1600type FileSearchToolFileSearchRankingOptions struct {
1601	// The score threshold for the file search. All values must be a floating point
1602	// number between 0 and 1.
1603	ScoreThreshold float64 `json:"score_threshold,required"`
1604	// The ranker to use for the file search. If not specified will use the `auto`
1605	// ranker.
1606	//
1607	// Any of "auto", "default_2024_08_21".
1608	Ranker string `json:"ranker"`
1609	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1610	JSON struct {
1611		ScoreThreshold respjson.Field
1612		Ranker         respjson.Field
1613		ExtraFields    map[string]respjson.Field
1614		raw            string
1615	} `json:"-"`
1616}
1617
1618// Returns the unmodified JSON received from the API
1619func (r FileSearchToolFileSearchRankingOptions) RawJSON() string { return r.JSON.raw }
1620func (r *FileSearchToolFileSearchRankingOptions) UnmarshalJSON(data []byte) error {
1621	return apijson.UnmarshalRoot(data, r)
1622}
1623
1624// The property Type is required.
1625type FileSearchToolParam struct {
1626	// Overrides for the file search tool.
1627	FileSearch FileSearchToolFileSearchParam `json:"file_search,omitzero"`
1628	// The type of tool being defined: `file_search`
1629	//
1630	// This field can be elided, and will marshal its zero value as "file_search".
1631	Type constant.FileSearch `json:"type,required"`
1632	paramObj
1633}
1634
1635func (r FileSearchToolParam) MarshalJSON() (data []byte, err error) {
1636	type shadow FileSearchToolParam
1637	return param.MarshalObject(r, (*shadow)(&r))
1638}
1639func (r *FileSearchToolParam) UnmarshalJSON(data []byte) error {
1640	return apijson.UnmarshalRoot(data, r)
1641}
1642
1643// Overrides for the file search tool.
1644type FileSearchToolFileSearchParam struct {
1645	// The maximum number of results the file search tool should output. The default is
1646	// 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between
1647	// 1 and 50 inclusive.
1648	//
1649	// Note that the file search tool may output fewer than `max_num_results` results.
1650	// See the
1651	// [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
1652	// for more information.
1653	MaxNumResults param.Opt[int64] `json:"max_num_results,omitzero"`
1654	// The ranking options for the file search. If not specified, the file search tool
1655	// will use the `auto` ranker and a score_threshold of 0.
1656	//
1657	// See the
1658	// [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
1659	// for more information.
1660	RankingOptions FileSearchToolFileSearchRankingOptionsParam `json:"ranking_options,omitzero"`
1661	paramObj
1662}
1663
1664func (r FileSearchToolFileSearchParam) MarshalJSON() (data []byte, err error) {
1665	type shadow FileSearchToolFileSearchParam
1666	return param.MarshalObject(r, (*shadow)(&r))
1667}
1668func (r *FileSearchToolFileSearchParam) UnmarshalJSON(data []byte) error {
1669	return apijson.UnmarshalRoot(data, r)
1670}
1671
1672// The ranking options for the file search. If not specified, the file search tool
1673// will use the `auto` ranker and a score_threshold of 0.
1674//
1675// See the
1676// [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
1677// for more information.
1678//
1679// The property ScoreThreshold is required.
1680type FileSearchToolFileSearchRankingOptionsParam struct {
1681	// The score threshold for the file search. All values must be a floating point
1682	// number between 0 and 1.
1683	ScoreThreshold float64 `json:"score_threshold,required"`
1684	// The ranker to use for the file search. If not specified will use the `auto`
1685	// ranker.
1686	//
1687	// Any of "auto", "default_2024_08_21".
1688	Ranker string `json:"ranker,omitzero"`
1689	paramObj
1690}
1691
1692func (r FileSearchToolFileSearchRankingOptionsParam) MarshalJSON() (data []byte, err error) {
1693	type shadow FileSearchToolFileSearchRankingOptionsParam
1694	return param.MarshalObject(r, (*shadow)(&r))
1695}
1696func (r *FileSearchToolFileSearchRankingOptionsParam) UnmarshalJSON(data []byte) error {
1697	return apijson.UnmarshalRoot(data, r)
1698}
1699
1700func init() {
1701	apijson.RegisterFieldValidator[FileSearchToolFileSearchRankingOptionsParam](
1702		"ranker", "auto", "default_2024_08_21",
1703	)
1704}
1705
1706type FunctionTool struct {
1707	Function shared.FunctionDefinition `json:"function,required"`
1708	// The type of tool being defined: `function`
1709	Type constant.Function `json:"type,required"`
1710	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1711	JSON struct {
1712		Function    respjson.Field
1713		Type        respjson.Field
1714		ExtraFields map[string]respjson.Field
1715		raw         string
1716	} `json:"-"`
1717}
1718
1719// Returns the unmodified JSON received from the API
1720func (r FunctionTool) RawJSON() string { return r.JSON.raw }
1721func (r *FunctionTool) UnmarshalJSON(data []byte) error {
1722	return apijson.UnmarshalRoot(data, r)
1723}
1724
1725// ToParam converts this FunctionTool to a FunctionToolParam.
1726//
1727// Warning: the fields of the param type will not be present. ToParam should only
1728// be used at the last possible moment before sending a request. Test for this with
1729// FunctionToolParam.Overrides()
1730func (r FunctionTool) ToParam() FunctionToolParam {
1731	return param.Override[FunctionToolParam](json.RawMessage(r.RawJSON()))
1732}
1733
1734// The properties Function, Type are required.
1735type FunctionToolParam struct {
1736	Function shared.FunctionDefinitionParam `json:"function,omitzero,required"`
1737	// The type of tool being defined: `function`
1738	//
1739	// This field can be elided, and will marshal its zero value as "function".
1740	Type constant.Function `json:"type,required"`
1741	paramObj
1742}
1743
1744func (r FunctionToolParam) MarshalJSON() (data []byte, err error) {
1745	type shadow FunctionToolParam
1746	return param.MarshalObject(r, (*shadow)(&r))
1747}
1748func (r *FunctionToolParam) UnmarshalJSON(data []byte) error {
1749	return apijson.UnmarshalRoot(data, r)
1750}
1751
1752type BetaAssistantNewParams struct {
1753	// ID of the model to use. You can use the
1754	// [List models](https://platform.openai.com/docs/api-reference/models/list) API to
1755	// see all of your available models, or see our
1756	// [Model overview](https://platform.openai.com/docs/models) for descriptions of
1757	// them.
1758	Model shared.ChatModel `json:"model,omitzero,required"`
1759	// The description of the assistant. The maximum length is 512 characters.
1760	Description param.Opt[string] `json:"description,omitzero"`
1761	// The system instructions that the assistant uses. The maximum length is 256,000
1762	// characters.
1763	Instructions param.Opt[string] `json:"instructions,omitzero"`
1764	// The name of the assistant. The maximum length is 256 characters.
1765	Name param.Opt[string] `json:"name,omitzero"`
1766	// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
1767	// make the output more random, while lower values like 0.2 will make it more
1768	// focused and deterministic.
1769	Temperature param.Opt[float64] `json:"temperature,omitzero"`
1770	// An alternative to sampling with temperature, called nucleus sampling, where the
1771	// model considers the results of the tokens with top_p probability mass. So 0.1
1772	// means only the tokens comprising the top 10% probability mass are considered.
1773	//
1774	// We generally recommend altering this or temperature but not both.
1775	TopP param.Opt[float64] `json:"top_p,omitzero"`
1776	// Set of 16 key-value pairs that can be attached to an object. This can be useful
1777	// for storing additional information about the object in a structured format, and
1778	// querying for objects via API or the dashboard.
1779	//
1780	// Keys are strings with a maximum length of 64 characters. Values are strings with
1781	// a maximum length of 512 characters.
1782	Metadata shared.Metadata `json:"metadata,omitzero"`
1783	// **o-series models only**
1784	//
1785	// Constrains effort on reasoning for
1786	// [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
1787	// supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
1788	// result in faster responses and fewer tokens used on reasoning in a response.
1789	//
1790	// Any of "low", "medium", "high".
1791	ReasoningEffort shared.ReasoningEffort `json:"reasoning_effort,omitzero"`
1792	// A set of resources that are used by the assistant's tools. The resources are
1793	// specific to the type of tool. For example, the `code_interpreter` tool requires
1794	// a list of file IDs, while the `file_search` tool requires a list of vector store
1795	// IDs.
1796	ToolResources BetaAssistantNewParamsToolResources `json:"tool_resources,omitzero"`
1797	// Specifies the format that the model must output. Compatible with
1798	// [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
1799	// [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
1800	// and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
1801	//
1802	// Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
1803	// Outputs which ensures the model will match your supplied JSON schema. Learn more
1804	// in the
1805	// [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
1806	//
1807	// Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
1808	// message the model generates is valid JSON.
1809	//
1810	// **Important:** when using JSON mode, you **must** also instruct the model to
1811	// produce JSON yourself via a system or user message. Without this, the model may
1812	// generate an unending stream of whitespace until the generation reaches the token
1813	// limit, resulting in a long-running and seemingly "stuck" request. Also note that
1814	// the message content may be partially cut off if `finish_reason="length"`, which
1815	// indicates the generation exceeded `max_tokens` or the conversation exceeded the
1816	// max context length.
1817	ResponseFormat AssistantResponseFormatOptionUnionParam `json:"response_format,omitzero"`
1818	// A list of tool enabled on the assistant. There can be a maximum of 128 tools per
1819	// assistant. Tools can be of types `code_interpreter`, `file_search`, or
1820	// `function`.
1821	Tools []AssistantToolUnionParam `json:"tools,omitzero"`
1822	paramObj
1823}
1824
1825func (r BetaAssistantNewParams) MarshalJSON() (data []byte, err error) {
1826	type shadow BetaAssistantNewParams
1827	return param.MarshalObject(r, (*shadow)(&r))
1828}
1829func (r *BetaAssistantNewParams) UnmarshalJSON(data []byte) error {
1830	return apijson.UnmarshalRoot(data, r)
1831}
1832
1833// A set of resources that are used by the assistant's tools. The resources are
1834// specific to the type of tool. For example, the `code_interpreter` tool requires
1835// a list of file IDs, while the `file_search` tool requires a list of vector store
1836// IDs.
1837type BetaAssistantNewParamsToolResources struct {
1838	CodeInterpreter BetaAssistantNewParamsToolResourcesCodeInterpreter `json:"code_interpreter,omitzero"`
1839	FileSearch      BetaAssistantNewParamsToolResourcesFileSearch      `json:"file_search,omitzero"`
1840	paramObj
1841}
1842
1843func (r BetaAssistantNewParamsToolResources) MarshalJSON() (data []byte, err error) {
1844	type shadow BetaAssistantNewParamsToolResources
1845	return param.MarshalObject(r, (*shadow)(&r))
1846}
1847func (r *BetaAssistantNewParamsToolResources) UnmarshalJSON(data []byte) error {
1848	return apijson.UnmarshalRoot(data, r)
1849}
1850
1851type BetaAssistantNewParamsToolResourcesCodeInterpreter struct {
1852	// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
1853	// available to the `code_interpreter` tool. There can be a maximum of 20 files
1854	// associated with the tool.
1855	FileIDs []string `json:"file_ids,omitzero"`
1856	paramObj
1857}
1858
1859func (r BetaAssistantNewParamsToolResourcesCodeInterpreter) MarshalJSON() (data []byte, err error) {
1860	type shadow BetaAssistantNewParamsToolResourcesCodeInterpreter
1861	return param.MarshalObject(r, (*shadow)(&r))
1862}
1863func (r *BetaAssistantNewParamsToolResourcesCodeInterpreter) UnmarshalJSON(data []byte) error {
1864	return apijson.UnmarshalRoot(data, r)
1865}
1866
1867type BetaAssistantNewParamsToolResourcesFileSearch struct {
1868	// The
1869	// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
1870	// attached to this assistant. There can be a maximum of 1 vector store attached to
1871	// the assistant.
1872	VectorStoreIDs []string `json:"vector_store_ids,omitzero"`
1873	// A helper to create a
1874	// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
1875	// with file_ids and attach it to this assistant. There can be a maximum of 1
1876	// vector store attached to the assistant.
1877	VectorStores []BetaAssistantNewParamsToolResourcesFileSearchVectorStore `json:"vector_stores,omitzero"`
1878	paramObj
1879}
1880
1881func (r BetaAssistantNewParamsToolResourcesFileSearch) MarshalJSON() (data []byte, err error) {
1882	type shadow BetaAssistantNewParamsToolResourcesFileSearch
1883	return param.MarshalObject(r, (*shadow)(&r))
1884}
1885func (r *BetaAssistantNewParamsToolResourcesFileSearch) UnmarshalJSON(data []byte) error {
1886	return apijson.UnmarshalRoot(data, r)
1887}
1888
1889type BetaAssistantNewParamsToolResourcesFileSearchVectorStore struct {
1890	// Set of 16 key-value pairs that can be attached to an object. This can be useful
1891	// for storing additional information about the object in a structured format, and
1892	// querying for objects via API or the dashboard.
1893	//
1894	// Keys are strings with a maximum length of 64 characters. Values are strings with
1895	// a maximum length of 512 characters.
1896	Metadata shared.Metadata `json:"metadata,omitzero"`
1897	// The chunking strategy used to chunk the file(s). If not set, will use the `auto`
1898	// strategy.
1899	ChunkingStrategy BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion `json:"chunking_strategy,omitzero"`
1900	// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
1901	// add to the vector store. There can be a maximum of 10000 files in a vector
1902	// store.
1903	FileIDs []string `json:"file_ids,omitzero"`
1904	paramObj
1905}
1906
1907func (r BetaAssistantNewParamsToolResourcesFileSearchVectorStore) MarshalJSON() (data []byte, err error) {
1908	type shadow BetaAssistantNewParamsToolResourcesFileSearchVectorStore
1909	return param.MarshalObject(r, (*shadow)(&r))
1910}
1911func (r *BetaAssistantNewParamsToolResourcesFileSearchVectorStore) UnmarshalJSON(data []byte) error {
1912	return apijson.UnmarshalRoot(data, r)
1913}
1914
1915// Only one field can be non-zero.
1916//
1917// Use [param.IsOmitted] to confirm if a field is set.
1918type BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion struct {
1919	OfAuto   *BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto   `json:",omitzero,inline"`
1920	OfStatic *BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic `json:",omitzero,inline"`
1921	paramUnion
1922}
1923
1924func (u BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion) MarshalJSON() ([]byte, error) {
1925	return param.MarshalUnion(u, u.OfAuto, u.OfStatic)
1926}
1927func (u *BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion) UnmarshalJSON(data []byte) error {
1928	return apijson.UnmarshalRoot(data, u)
1929}
1930
1931func (u *BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion) asAny() any {
1932	if !param.IsOmitted(u.OfAuto) {
1933		return u.OfAuto
1934	} else if !param.IsOmitted(u.OfStatic) {
1935		return u.OfStatic
1936	}
1937	return nil
1938}
1939
1940// Returns a pointer to the underlying variant's property, if present.
1941func (u BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion) GetStatic() *BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic {
1942	if vt := u.OfStatic; vt != nil {
1943		return &vt.Static
1944	}
1945	return nil
1946}
1947
1948// Returns a pointer to the underlying variant's property, if present.
1949func (u BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion) GetType() *string {
1950	if vt := u.OfAuto; vt != nil {
1951		return (*string)(&vt.Type)
1952	} else if vt := u.OfStatic; vt != nil {
1953		return (*string)(&vt.Type)
1954	}
1955	return nil
1956}
1957
1958func init() {
1959	apijson.RegisterUnion[BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion](
1960		"type",
1961		apijson.Discriminator[BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto]("auto"),
1962		apijson.Discriminator[BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic]("static"),
1963	)
1964}
1965
1966func NewBetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto() BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto {
1967	return BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto{
1968		Type: "auto",
1969	}
1970}
1971
1972// The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
1973// `800` and `chunk_overlap_tokens` of `400`.
1974//
1975// This struct has a constant value, construct it with
1976// [NewBetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto].
1977type BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto struct {
1978	// Always `auto`.
1979	Type constant.Auto `json:"type,required"`
1980	paramObj
1981}
1982
1983func (r BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto) MarshalJSON() (data []byte, err error) {
1984	type shadow BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto
1985	return param.MarshalObject(r, (*shadow)(&r))
1986}
1987func (r *BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto) UnmarshalJSON(data []byte) error {
1988	return apijson.UnmarshalRoot(data, r)
1989}
1990
1991// The properties Static, Type are required.
1992type BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic struct {
1993	Static BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic `json:"static,omitzero,required"`
1994	// Always `static`.
1995	//
1996	// This field can be elided, and will marshal its zero value as "static".
1997	Type constant.Static `json:"type,required"`
1998	paramObj
1999}
2000
2001func (r BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic) MarshalJSON() (data []byte, err error) {
2002	type shadow BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic
2003	return param.MarshalObject(r, (*shadow)(&r))
2004}
2005func (r *BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic) UnmarshalJSON(data []byte) error {
2006	return apijson.UnmarshalRoot(data, r)
2007}
2008
2009// The properties ChunkOverlapTokens, MaxChunkSizeTokens are required.
2010type BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic struct {
2011	// The number of tokens that overlap between chunks. The default value is `400`.
2012	//
2013	// Note that the overlap must not exceed half of `max_chunk_size_tokens`.
2014	ChunkOverlapTokens int64 `json:"chunk_overlap_tokens,required"`
2015	// The maximum number of tokens in each chunk. The default value is `800`. The
2016	// minimum value is `100` and the maximum value is `4096`.
2017	MaxChunkSizeTokens int64 `json:"max_chunk_size_tokens,required"`
2018	paramObj
2019}
2020
2021func (r BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic) MarshalJSON() (data []byte, err error) {
2022	type shadow BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic
2023	return param.MarshalObject(r, (*shadow)(&r))
2024}
2025func (r *BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic) UnmarshalJSON(data []byte) error {
2026	return apijson.UnmarshalRoot(data, r)
2027}
2028
2029type BetaAssistantUpdateParams struct {
2030	// The description of the assistant. The maximum length is 512 characters.
2031	Description param.Opt[string] `json:"description,omitzero"`
2032	// The system instructions that the assistant uses. The maximum length is 256,000
2033	// characters.
2034	Instructions param.Opt[string] `json:"instructions,omitzero"`
2035	// The name of the assistant. The maximum length is 256 characters.
2036	Name param.Opt[string] `json:"name,omitzero"`
2037	// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
2038	// make the output more random, while lower values like 0.2 will make it more
2039	// focused and deterministic.
2040	Temperature param.Opt[float64] `json:"temperature,omitzero"`
2041	// An alternative to sampling with temperature, called nucleus sampling, where the
2042	// model considers the results of the tokens with top_p probability mass. So 0.1
2043	// means only the tokens comprising the top 10% probability mass are considered.
2044	//
2045	// We generally recommend altering this or temperature but not both.
2046	TopP param.Opt[float64] `json:"top_p,omitzero"`
2047	// Set of 16 key-value pairs that can be attached to an object. This can be useful
2048	// for storing additional information about the object in a structured format, and
2049	// querying for objects via API or the dashboard.
2050	//
2051	// Keys are strings with a maximum length of 64 characters. Values are strings with
2052	// a maximum length of 512 characters.
2053	Metadata shared.Metadata `json:"metadata,omitzero"`
2054	// **o-series models only**
2055	//
2056	// Constrains effort on reasoning for
2057	// [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
2058	// supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
2059	// result in faster responses and fewer tokens used on reasoning in a response.
2060	//
2061	// Any of "low", "medium", "high".
2062	ReasoningEffort shared.ReasoningEffort `json:"reasoning_effort,omitzero"`
2063	// A set of resources that are used by the assistant's tools. The resources are
2064	// specific to the type of tool. For example, the `code_interpreter` tool requires
2065	// a list of file IDs, while the `file_search` tool requires a list of vector store
2066	// IDs.
2067	ToolResources BetaAssistantUpdateParamsToolResources `json:"tool_resources,omitzero"`
2068	// ID of the model to use. You can use the
2069	// [List models](https://platform.openai.com/docs/api-reference/models/list) API to
2070	// see all of your available models, or see our
2071	// [Model overview](https://platform.openai.com/docs/models) for descriptions of
2072	// them.
2073	Model BetaAssistantUpdateParamsModel `json:"model,omitzero"`
2074	// Specifies the format that the model must output. Compatible with
2075	// [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
2076	// [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
2077	// and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
2078	//
2079	// Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
2080	// Outputs which ensures the model will match your supplied JSON schema. Learn more
2081	// in the
2082	// [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
2083	//
2084	// Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
2085	// message the model generates is valid JSON.
2086	//
2087	// **Important:** when using JSON mode, you **must** also instruct the model to
2088	// produce JSON yourself via a system or user message. Without this, the model may
2089	// generate an unending stream of whitespace until the generation reaches the token
2090	// limit, resulting in a long-running and seemingly "stuck" request. Also note that
2091	// the message content may be partially cut off if `finish_reason="length"`, which
2092	// indicates the generation exceeded `max_tokens` or the conversation exceeded the
2093	// max context length.
2094	ResponseFormat AssistantResponseFormatOptionUnionParam `json:"response_format,omitzero"`
2095	// A list of tool enabled on the assistant. There can be a maximum of 128 tools per
2096	// assistant. Tools can be of types `code_interpreter`, `file_search`, or
2097	// `function`.
2098	Tools []AssistantToolUnionParam `json:"tools,omitzero"`
2099	paramObj
2100}
2101
2102func (r BetaAssistantUpdateParams) MarshalJSON() (data []byte, err error) {
2103	type shadow BetaAssistantUpdateParams
2104	return param.MarshalObject(r, (*shadow)(&r))
2105}
2106func (r *BetaAssistantUpdateParams) UnmarshalJSON(data []byte) error {
2107	return apijson.UnmarshalRoot(data, r)
2108}
2109
2110// ID of the model to use. You can use the
2111// [List models](https://platform.openai.com/docs/api-reference/models/list) API to
2112// see all of your available models, or see our
2113// [Model overview](https://platform.openai.com/docs/models) for descriptions of
2114// them.
2115type BetaAssistantUpdateParamsModel string
2116
2117const (
2118	BetaAssistantUpdateParamsModelGPT4_1                  BetaAssistantUpdateParamsModel = "gpt-4.1"
2119	BetaAssistantUpdateParamsModelGPT4_1Mini              BetaAssistantUpdateParamsModel = "gpt-4.1-mini"
2120	BetaAssistantUpdateParamsModelGPT4_1Nano              BetaAssistantUpdateParamsModel = "gpt-4.1-nano"
2121	BetaAssistantUpdateParamsModelGPT4_1_2025_04_14       BetaAssistantUpdateParamsModel = "gpt-4.1-2025-04-14"
2122	BetaAssistantUpdateParamsModelGPT4_1Mini2025_04_14    BetaAssistantUpdateParamsModel = "gpt-4.1-mini-2025-04-14"
2123	BetaAssistantUpdateParamsModelGPT4_1Nano2025_04_14    BetaAssistantUpdateParamsModel = "gpt-4.1-nano-2025-04-14"
2124	BetaAssistantUpdateParamsModelO3Mini                  BetaAssistantUpdateParamsModel = "o3-mini"
2125	BetaAssistantUpdateParamsModelO3Mini2025_01_31        BetaAssistantUpdateParamsModel = "o3-mini-2025-01-31"
2126	BetaAssistantUpdateParamsModelO1                      BetaAssistantUpdateParamsModel = "o1"
2127	BetaAssistantUpdateParamsModelO1_2024_12_17           BetaAssistantUpdateParamsModel = "o1-2024-12-17"
2128	BetaAssistantUpdateParamsModelGPT4o                   BetaAssistantUpdateParamsModel = "gpt-4o"
2129	BetaAssistantUpdateParamsModelGPT4o2024_11_20         BetaAssistantUpdateParamsModel = "gpt-4o-2024-11-20"
2130	BetaAssistantUpdateParamsModelGPT4o2024_08_06         BetaAssistantUpdateParamsModel = "gpt-4o-2024-08-06"
2131	BetaAssistantUpdateParamsModelGPT4o2024_05_13         BetaAssistantUpdateParamsModel = "gpt-4o-2024-05-13"
2132	BetaAssistantUpdateParamsModelGPT4oMini               BetaAssistantUpdateParamsModel = "gpt-4o-mini"
2133	BetaAssistantUpdateParamsModelGPT4oMini2024_07_18     BetaAssistantUpdateParamsModel = "gpt-4o-mini-2024-07-18"
2134	BetaAssistantUpdateParamsModelGPT4_5Preview           BetaAssistantUpdateParamsModel = "gpt-4.5-preview"
2135	BetaAssistantUpdateParamsModelGPT4_5Preview2025_02_27 BetaAssistantUpdateParamsModel = "gpt-4.5-preview-2025-02-27"
2136	BetaAssistantUpdateParamsModelGPT4Turbo               BetaAssistantUpdateParamsModel = "gpt-4-turbo"
2137	BetaAssistantUpdateParamsModelGPT4Turbo2024_04_09     BetaAssistantUpdateParamsModel = "gpt-4-turbo-2024-04-09"
2138	BetaAssistantUpdateParamsModelGPT4_0125Preview        BetaAssistantUpdateParamsModel = "gpt-4-0125-preview"
2139	BetaAssistantUpdateParamsModelGPT4TurboPreview        BetaAssistantUpdateParamsModel = "gpt-4-turbo-preview"
2140	BetaAssistantUpdateParamsModelGPT4_1106Preview        BetaAssistantUpdateParamsModel = "gpt-4-1106-preview"
2141	BetaAssistantUpdateParamsModelGPT4VisionPreview       BetaAssistantUpdateParamsModel = "gpt-4-vision-preview"
2142	BetaAssistantUpdateParamsModelGPT4                    BetaAssistantUpdateParamsModel = "gpt-4"
2143	BetaAssistantUpdateParamsModelGPT4_0314               BetaAssistantUpdateParamsModel = "gpt-4-0314"
2144	BetaAssistantUpdateParamsModelGPT4_0613               BetaAssistantUpdateParamsModel = "gpt-4-0613"
2145	BetaAssistantUpdateParamsModelGPT4_32k                BetaAssistantUpdateParamsModel = "gpt-4-32k"
2146	BetaAssistantUpdateParamsModelGPT4_32k0314            BetaAssistantUpdateParamsModel = "gpt-4-32k-0314"
2147	BetaAssistantUpdateParamsModelGPT4_32k0613            BetaAssistantUpdateParamsModel = "gpt-4-32k-0613"
2148	BetaAssistantUpdateParamsModelGPT3_5Turbo             BetaAssistantUpdateParamsModel = "gpt-3.5-turbo"
2149	BetaAssistantUpdateParamsModelGPT3_5Turbo16k          BetaAssistantUpdateParamsModel = "gpt-3.5-turbo-16k"
2150	BetaAssistantUpdateParamsModelGPT3_5Turbo0613         BetaAssistantUpdateParamsModel = "gpt-3.5-turbo-0613"
2151	BetaAssistantUpdateParamsModelGPT3_5Turbo1106         BetaAssistantUpdateParamsModel = "gpt-3.5-turbo-1106"
2152	BetaAssistantUpdateParamsModelGPT3_5Turbo0125         BetaAssistantUpdateParamsModel = "gpt-3.5-turbo-0125"
2153	BetaAssistantUpdateParamsModelGPT3_5Turbo16k0613      BetaAssistantUpdateParamsModel = "gpt-3.5-turbo-16k-0613"
2154)
2155
2156// A set of resources that are used by the assistant's tools. The resources are
2157// specific to the type of tool. For example, the `code_interpreter` tool requires
2158// a list of file IDs, while the `file_search` tool requires a list of vector store
2159// IDs.
2160type BetaAssistantUpdateParamsToolResources struct {
2161	CodeInterpreter BetaAssistantUpdateParamsToolResourcesCodeInterpreter `json:"code_interpreter,omitzero"`
2162	FileSearch      BetaAssistantUpdateParamsToolResourcesFileSearch      `json:"file_search,omitzero"`
2163	paramObj
2164}
2165
2166func (r BetaAssistantUpdateParamsToolResources) MarshalJSON() (data []byte, err error) {
2167	type shadow BetaAssistantUpdateParamsToolResources
2168	return param.MarshalObject(r, (*shadow)(&r))
2169}
2170func (r *BetaAssistantUpdateParamsToolResources) UnmarshalJSON(data []byte) error {
2171	return apijson.UnmarshalRoot(data, r)
2172}
2173
2174type BetaAssistantUpdateParamsToolResourcesCodeInterpreter struct {
2175	// Overrides the list of
2176	// [file](https://platform.openai.com/docs/api-reference/files) IDs made available
2177	// to the `code_interpreter` tool. There can be a maximum of 20 files associated
2178	// with the tool.
2179	FileIDs []string `json:"file_ids,omitzero"`
2180	paramObj
2181}
2182
2183func (r BetaAssistantUpdateParamsToolResourcesCodeInterpreter) MarshalJSON() (data []byte, err error) {
2184	type shadow BetaAssistantUpdateParamsToolResourcesCodeInterpreter
2185	return param.MarshalObject(r, (*shadow)(&r))
2186}
2187func (r *BetaAssistantUpdateParamsToolResourcesCodeInterpreter) UnmarshalJSON(data []byte) error {
2188	return apijson.UnmarshalRoot(data, r)
2189}
2190
2191type BetaAssistantUpdateParamsToolResourcesFileSearch struct {
2192	// Overrides the
2193	// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
2194	// attached to this assistant. There can be a maximum of 1 vector store attached to
2195	// the assistant.
2196	VectorStoreIDs []string `json:"vector_store_ids,omitzero"`
2197	paramObj
2198}
2199
2200func (r BetaAssistantUpdateParamsToolResourcesFileSearch) MarshalJSON() (data []byte, err error) {
2201	type shadow BetaAssistantUpdateParamsToolResourcesFileSearch
2202	return param.MarshalObject(r, (*shadow)(&r))
2203}
2204func (r *BetaAssistantUpdateParamsToolResourcesFileSearch) UnmarshalJSON(data []byte) error {
2205	return apijson.UnmarshalRoot(data, r)
2206}
2207
2208type BetaAssistantListParams struct {
2209	// A cursor for use in pagination. `after` is an object ID that defines your place
2210	// in the list. For instance, if you make a list request and receive 100 objects,
2211	// ending with obj_foo, your subsequent call can include after=obj_foo in order to
2212	// fetch the next page of the list.
2213	After param.Opt[string] `query:"after,omitzero" json:"-"`
2214	// A cursor for use in pagination. `before` is an object ID that defines your place
2215	// in the list. For instance, if you make a list request and receive 100 objects,
2216	// starting with obj_foo, your subsequent call can include before=obj_foo in order
2217	// to fetch the previous page of the list.
2218	Before param.Opt[string] `query:"before,omitzero" json:"-"`
2219	// A limit on the number of objects to be returned. Limit can range between 1 and
2220	// 100, and the default is 20.
2221	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
2222	// Sort order by the `created_at` timestamp of the objects. `asc` for ascending
2223	// order and `desc` for descending order.
2224	//
2225	// Any of "asc", "desc".
2226	Order BetaAssistantListParamsOrder `query:"order,omitzero" json:"-"`
2227	paramObj
2228}
2229
2230// URLQuery serializes [BetaAssistantListParams]'s query parameters as
2231// `url.Values`.
2232func (r BetaAssistantListParams) URLQuery() (v url.Values, err error) {
2233	return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
2234		ArrayFormat:  apiquery.ArrayQueryFormatBrackets,
2235		NestedFormat: apiquery.NestedQueryFormatBrackets,
2236	})
2237}
2238
2239// Sort order by the `created_at` timestamp of the objects. `asc` for ascending
2240// order and `desc` for descending order.
2241type BetaAssistantListParamsOrder string
2242
2243const (
2244	BetaAssistantListParamsOrderAsc  BetaAssistantListParamsOrder = "asc"
2245	BetaAssistantListParamsOrderDesc BetaAssistantListParamsOrder = "desc"
2246)