response.go

   1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
   2
   3package responses
   4
   5import (
   6	"context"
   7	"encoding/json"
   8	"errors"
   9	"fmt"
  10	"net/http"
  11	"net/url"
  12	"reflect"
  13	"strings"
  14
  15	"github.com/openai/openai-go/internal/apijson"
  16	"github.com/openai/openai-go/internal/apiquery"
  17	"github.com/openai/openai-go/internal/requestconfig"
  18	"github.com/openai/openai-go/option"
  19	"github.com/openai/openai-go/packages/param"
  20	"github.com/openai/openai-go/packages/resp"
  21	"github.com/openai/openai-go/packages/ssestream"
  22	"github.com/openai/openai-go/shared"
  23	"github.com/openai/openai-go/shared/constant"
  24	"github.com/tidwall/gjson"
  25)
  26
  27// ResponseService contains methods and other services that help with interacting
  28// with the openai API.
  29//
  30// Note, unlike clients, this service does not read variables from the environment
  31// automatically. You should not instantiate this service directly, and instead use
  32// the [NewResponseService] method instead.
  33type ResponseService struct {
  34	Options    []option.RequestOption
  35	InputItems InputItemService
  36}
  37
  38// NewResponseService generates a new service that applies the given options to
  39// each request. These options are applied after the parent client's options (if
  40// there is one), and before any request-specific options.
  41func NewResponseService(opts ...option.RequestOption) (r ResponseService) {
  42	r = ResponseService{}
  43	r.Options = opts
  44	r.InputItems = NewInputItemService(opts...)
  45	return
  46}
  47
  48// Creates a model response. Provide
  49// [text](https://platform.openai.com/docs/guides/text) or
  50// [image](https://platform.openai.com/docs/guides/images) inputs to generate
  51// [text](https://platform.openai.com/docs/guides/text) or
  52// [JSON](https://platform.openai.com/docs/guides/structured-outputs) outputs. Have
  53// the model call your own
  54// [custom code](https://platform.openai.com/docs/guides/function-calling) or use
  55// built-in [tools](https://platform.openai.com/docs/guides/tools) like
  56// [web search](https://platform.openai.com/docs/guides/tools-web-search) or
  57// [file search](https://platform.openai.com/docs/guides/tools-file-search) to use
  58// your own data as input for the model's response.
  59func (r *ResponseService) New(ctx context.Context, body ResponseNewParams, opts ...option.RequestOption) (res *Response, err error) {
  60	opts = append(r.Options[:], opts...)
  61	path := "responses"
  62	err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
  63	return
  64}
  65
  66// Creates a model response. Provide
  67// [text](https://platform.openai.com/docs/guides/text) or
  68// [image](https://platform.openai.com/docs/guides/images) inputs to generate
  69// [text](https://platform.openai.com/docs/guides/text) or
  70// [JSON](https://platform.openai.com/docs/guides/structured-outputs) outputs. Have
  71// the model call your own
  72// [custom code](https://platform.openai.com/docs/guides/function-calling) or use
  73// built-in [tools](https://platform.openai.com/docs/guides/tools) like
  74// [web search](https://platform.openai.com/docs/guides/tools-web-search) or
  75// [file search](https://platform.openai.com/docs/guides/tools-file-search) to use
  76// your own data as input for the model's response.
  77func (r *ResponseService) NewStreaming(ctx context.Context, body ResponseNewParams, opts ...option.RequestOption) (stream *ssestream.Stream[ResponseStreamEventUnion]) {
  78	var (
  79		raw *http.Response
  80		err error
  81	)
  82	opts = append(r.Options[:], opts...)
  83	opts = append([]option.RequestOption{option.WithJSONSet("stream", true)}, opts...)
  84	path := "responses"
  85	err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &raw, opts...)
  86	return ssestream.NewStream[ResponseStreamEventUnion](ssestream.NewDecoder(raw), err)
  87}
  88
  89// Retrieves a model response with the given ID.
  90func (r *ResponseService) Get(ctx context.Context, responseID string, query ResponseGetParams, opts ...option.RequestOption) (res *Response, err error) {
  91	opts = append(r.Options[:], opts...)
  92	if responseID == "" {
  93		err = errors.New("missing required response_id parameter")
  94		return
  95	}
  96	path := fmt.Sprintf("responses/%s", responseID)
  97	err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
  98	return
  99}
 100
 101// Deletes a model response with the given ID.
 102func (r *ResponseService) Delete(ctx context.Context, responseID string, opts ...option.RequestOption) (err error) {
 103	opts = append(r.Options[:], opts...)
 104	opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...)
 105	if responseID == "" {
 106		err = errors.New("missing required response_id parameter")
 107		return
 108	}
 109	path := fmt.Sprintf("responses/%s", responseID)
 110	err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...)
 111	return
 112}
 113
 114// A tool that controls a virtual computer. Learn more about the
 115// [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
 116type ComputerTool struct {
 117	// The height of the computer display.
 118	DisplayHeight float64 `json:"display_height,required"`
 119	// The width of the computer display.
 120	DisplayWidth float64 `json:"display_width,required"`
 121	// The type of computer environment to control.
 122	//
 123	// Any of "mac", "windows", "ubuntu", "browser".
 124	Environment ComputerToolEnvironment `json:"environment,required"`
 125	// The type of the computer use tool. Always `computer_use_preview`.
 126	Type constant.ComputerUsePreview `json:"type,required"`
 127	// Metadata for the response, check the presence of optional fields with the
 128	// [resp.Field.IsPresent] method.
 129	JSON struct {
 130		DisplayHeight resp.Field
 131		DisplayWidth  resp.Field
 132		Environment   resp.Field
 133		Type          resp.Field
 134		ExtraFields   map[string]resp.Field
 135		raw           string
 136	} `json:"-"`
 137}
 138
 139// Returns the unmodified JSON received from the API
 140func (r ComputerTool) RawJSON() string { return r.JSON.raw }
 141func (r *ComputerTool) UnmarshalJSON(data []byte) error {
 142	return apijson.UnmarshalRoot(data, r)
 143}
 144
 145// ToParam converts this ComputerTool to a ComputerToolParam.
 146//
 147// Warning: the fields of the param type will not be present. ToParam should only
 148// be used at the last possible moment before sending a request. Test for this with
 149// ComputerToolParam.IsOverridden()
 150func (r ComputerTool) ToParam() ComputerToolParam {
 151	return param.OverrideObj[ComputerToolParam](r.RawJSON())
 152}
 153
 154// The type of computer environment to control.
 155type ComputerToolEnvironment string
 156
 157const (
 158	ComputerToolEnvironmentMac     ComputerToolEnvironment = "mac"
 159	ComputerToolEnvironmentWindows ComputerToolEnvironment = "windows"
 160	ComputerToolEnvironmentUbuntu  ComputerToolEnvironment = "ubuntu"
 161	ComputerToolEnvironmentBrowser ComputerToolEnvironment = "browser"
 162)
 163
 164// A tool that controls a virtual computer. Learn more about the
 165// [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
 166//
 167// The properties DisplayHeight, DisplayWidth, Environment, Type are required.
 168type ComputerToolParam struct {
 169	// The height of the computer display.
 170	DisplayHeight float64 `json:"display_height,required"`
 171	// The width of the computer display.
 172	DisplayWidth float64 `json:"display_width,required"`
 173	// The type of computer environment to control.
 174	//
 175	// Any of "mac", "windows", "ubuntu", "browser".
 176	Environment ComputerToolEnvironment `json:"environment,omitzero,required"`
 177	// The type of the computer use tool. Always `computer_use_preview`.
 178	//
 179	// This field can be elided, and will marshal its zero value as
 180	// "computer_use_preview".
 181	Type constant.ComputerUsePreview `json:"type,required"`
 182	paramObj
 183}
 184
 185// IsPresent returns true if the field's value is not omitted and not the JSON
 186// "null". To check if this field is omitted, use [param.IsOmitted].
 187func (f ComputerToolParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
 188func (r ComputerToolParam) MarshalJSON() (data []byte, err error) {
 189	type shadow ComputerToolParam
 190	return param.MarshalObject(r, (*shadow)(&r))
 191}
 192
 193// A message input to the model with a role indicating instruction following
 194// hierarchy. Instructions given with the `developer` or `system` role take
 195// precedence over instructions given with the `user` role. Messages with the
 196// `assistant` role are presumed to have been generated by the model in previous
 197// interactions.
 198//
 199// The properties Content, Role are required.
 200type EasyInputMessageParam struct {
 201	// Text, image, or audio input to the model, used to generate a response. Can also
 202	// contain previous assistant responses.
 203	Content EasyInputMessageContentUnionParam `json:"content,omitzero,required"`
 204	// The role of the message input. One of `user`, `assistant`, `system`, or
 205	// `developer`.
 206	//
 207	// Any of "user", "assistant", "system", "developer".
 208	Role EasyInputMessageRole `json:"role,omitzero,required"`
 209	// The type of the message input. Always `message`.
 210	//
 211	// Any of "message".
 212	Type EasyInputMessageType `json:"type,omitzero"`
 213	paramObj
 214}
 215
 216// IsPresent returns true if the field's value is not omitted and not the JSON
 217// "null". To check if this field is omitted, use [param.IsOmitted].
 218func (f EasyInputMessageParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
 219func (r EasyInputMessageParam) MarshalJSON() (data []byte, err error) {
 220	type shadow EasyInputMessageParam
 221	return param.MarshalObject(r, (*shadow)(&r))
 222}
 223
 224// Only one field can be non-zero.
 225//
 226// Use [param.IsOmitted] to confirm if a field is set.
 227type EasyInputMessageContentUnionParam struct {
 228	OfString               param.Opt[string]                    `json:",omitzero,inline"`
 229	OfInputItemContentList ResponseInputMessageContentListParam `json:",omitzero,inline"`
 230	paramUnion
 231}
 232
 233// IsPresent returns true if the field's value is not omitted and not the JSON
 234// "null". To check if this field is omitted, use [param.IsOmitted].
 235func (u EasyInputMessageContentUnionParam) IsPresent() bool {
 236	return !param.IsOmitted(u) && !u.IsNull()
 237}
 238func (u EasyInputMessageContentUnionParam) MarshalJSON() ([]byte, error) {
 239	return param.MarshalUnion[EasyInputMessageContentUnionParam](u.OfString, u.OfInputItemContentList)
 240}
 241
 242func (u *EasyInputMessageContentUnionParam) asAny() any {
 243	if !param.IsOmitted(u.OfString) {
 244		return &u.OfString.Value
 245	} else if !param.IsOmitted(u.OfInputItemContentList) {
 246		return &u.OfInputItemContentList
 247	}
 248	return nil
 249}
 250
 251// The role of the message input. One of `user`, `assistant`, `system`, or
 252// `developer`.
 253type EasyInputMessageRole string
 254
 255const (
 256	EasyInputMessageRoleUser      EasyInputMessageRole = "user"
 257	EasyInputMessageRoleAssistant EasyInputMessageRole = "assistant"
 258	EasyInputMessageRoleSystem    EasyInputMessageRole = "system"
 259	EasyInputMessageRoleDeveloper EasyInputMessageRole = "developer"
 260)
 261
 262// The type of the message input. Always `message`.
 263type EasyInputMessageType string
 264
 265const (
 266	EasyInputMessageTypeMessage EasyInputMessageType = "message"
 267)
 268
 269// A tool that searches for relevant content from uploaded files. Learn more about
 270// the
 271// [file search tool](https://platform.openai.com/docs/guides/tools-file-search).
 272type FileSearchTool struct {
 273	// The type of the file search tool. Always `file_search`.
 274	Type constant.FileSearch `json:"type,required"`
 275	// The IDs of the vector stores to search.
 276	VectorStoreIDs []string `json:"vector_store_ids,required"`
 277	// A filter to apply based on file attributes.
 278	Filters FileSearchToolFiltersUnion `json:"filters"`
 279	// The maximum number of results to return. This number should be between 1 and 50
 280	// inclusive.
 281	MaxNumResults int64 `json:"max_num_results"`
 282	// Ranking options for search.
 283	RankingOptions FileSearchToolRankingOptions `json:"ranking_options"`
 284	// Metadata for the response, check the presence of optional fields with the
 285	// [resp.Field.IsPresent] method.
 286	JSON struct {
 287		Type           resp.Field
 288		VectorStoreIDs resp.Field
 289		Filters        resp.Field
 290		MaxNumResults  resp.Field
 291		RankingOptions resp.Field
 292		ExtraFields    map[string]resp.Field
 293		raw            string
 294	} `json:"-"`
 295}
 296
 297// Returns the unmodified JSON received from the API
 298func (r FileSearchTool) RawJSON() string { return r.JSON.raw }
 299func (r *FileSearchTool) UnmarshalJSON(data []byte) error {
 300	return apijson.UnmarshalRoot(data, r)
 301}
 302
 303// ToParam converts this FileSearchTool to a FileSearchToolParam.
 304//
 305// Warning: the fields of the param type will not be present. ToParam should only
 306// be used at the last possible moment before sending a request. Test for this with
 307// FileSearchToolParam.IsOverridden()
 308func (r FileSearchTool) ToParam() FileSearchToolParam {
 309	return param.OverrideObj[FileSearchToolParam](r.RawJSON())
 310}
 311
 312// FileSearchToolFiltersUnion contains all possible properties and values from
 313// [shared.ComparisonFilter], [shared.CompoundFilter].
 314//
 315// Use the methods beginning with 'As' to cast the union to one of its variants.
 316type FileSearchToolFiltersUnion struct {
 317	// This field is from variant [shared.ComparisonFilter].
 318	Key  string `json:"key"`
 319	Type string `json:"type"`
 320	// This field is from variant [shared.ComparisonFilter].
 321	Value shared.ComparisonFilterValueUnion `json:"value"`
 322	// This field is from variant [shared.CompoundFilter].
 323	Filters []shared.ComparisonFilter `json:"filters"`
 324	JSON    struct {
 325		Key     resp.Field
 326		Type    resp.Field
 327		Value   resp.Field
 328		Filters resp.Field
 329		raw     string
 330	} `json:"-"`
 331}
 332
 333func (u FileSearchToolFiltersUnion) AsComparisonFilter() (v shared.ComparisonFilter) {
 334	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 335	return
 336}
 337
 338func (u FileSearchToolFiltersUnion) AsCompoundFilter() (v shared.CompoundFilter) {
 339	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 340	return
 341}
 342
 343// Returns the unmodified JSON received from the API
 344func (u FileSearchToolFiltersUnion) RawJSON() string { return u.JSON.raw }
 345
 346func (r *FileSearchToolFiltersUnion) UnmarshalJSON(data []byte) error {
 347	return apijson.UnmarshalRoot(data, r)
 348}
 349
 350// Ranking options for search.
 351type FileSearchToolRankingOptions struct {
 352	// The ranker to use for the file search.
 353	//
 354	// Any of "auto", "default-2024-11-15".
 355	Ranker string `json:"ranker"`
 356	// The score threshold for the file search, a number between 0 and 1. Numbers
 357	// closer to 1 will attempt to return only the most relevant results, but may
 358	// return fewer results.
 359	ScoreThreshold float64 `json:"score_threshold"`
 360	// Metadata for the response, check the presence of optional fields with the
 361	// [resp.Field.IsPresent] method.
 362	JSON struct {
 363		Ranker         resp.Field
 364		ScoreThreshold resp.Field
 365		ExtraFields    map[string]resp.Field
 366		raw            string
 367	} `json:"-"`
 368}
 369
 370// Returns the unmodified JSON received from the API
 371func (r FileSearchToolRankingOptions) RawJSON() string { return r.JSON.raw }
 372func (r *FileSearchToolRankingOptions) UnmarshalJSON(data []byte) error {
 373	return apijson.UnmarshalRoot(data, r)
 374}
 375
 376// A tool that searches for relevant content from uploaded files. Learn more about
 377// the
 378// [file search tool](https://platform.openai.com/docs/guides/tools-file-search).
 379//
 380// The properties Type, VectorStoreIDs are required.
 381type FileSearchToolParam struct {
 382	// The IDs of the vector stores to search.
 383	VectorStoreIDs []string `json:"vector_store_ids,omitzero,required"`
 384	// The maximum number of results to return. This number should be between 1 and 50
 385	// inclusive.
 386	MaxNumResults param.Opt[int64] `json:"max_num_results,omitzero"`
 387	// A filter to apply based on file attributes.
 388	Filters FileSearchToolFiltersUnionParam `json:"filters,omitzero"`
 389	// Ranking options for search.
 390	RankingOptions FileSearchToolRankingOptionsParam `json:"ranking_options,omitzero"`
 391	// The type of the file search tool. Always `file_search`.
 392	//
 393	// This field can be elided, and will marshal its zero value as "file_search".
 394	Type constant.FileSearch `json:"type,required"`
 395	paramObj
 396}
 397
 398// IsPresent returns true if the field's value is not omitted and not the JSON
 399// "null". To check if this field is omitted, use [param.IsOmitted].
 400func (f FileSearchToolParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
 401func (r FileSearchToolParam) MarshalJSON() (data []byte, err error) {
 402	type shadow FileSearchToolParam
 403	return param.MarshalObject(r, (*shadow)(&r))
 404}
 405
 406// Only one field can be non-zero.
 407//
 408// Use [param.IsOmitted] to confirm if a field is set.
 409type FileSearchToolFiltersUnionParam struct {
 410	OfComparisonFilter *shared.ComparisonFilterParam `json:",omitzero,inline"`
 411	OfCompoundFilter   *shared.CompoundFilterParam   `json:",omitzero,inline"`
 412	paramUnion
 413}
 414
 415// IsPresent returns true if the field's value is not omitted and not the JSON
 416// "null". To check if this field is omitted, use [param.IsOmitted].
 417func (u FileSearchToolFiltersUnionParam) IsPresent() bool { return !param.IsOmitted(u) && !u.IsNull() }
 418func (u FileSearchToolFiltersUnionParam) MarshalJSON() ([]byte, error) {
 419	return param.MarshalUnion[FileSearchToolFiltersUnionParam](u.OfComparisonFilter, u.OfCompoundFilter)
 420}
 421
 422func (u *FileSearchToolFiltersUnionParam) asAny() any {
 423	if !param.IsOmitted(u.OfComparisonFilter) {
 424		return u.OfComparisonFilter
 425	} else if !param.IsOmitted(u.OfCompoundFilter) {
 426		return u.OfCompoundFilter
 427	}
 428	return nil
 429}
 430
 431// Returns a pointer to the underlying variant's property, if present.
 432func (u FileSearchToolFiltersUnionParam) GetKey() *string {
 433	if vt := u.OfComparisonFilter; vt != nil {
 434		return &vt.Key
 435	}
 436	return nil
 437}
 438
 439// Returns a pointer to the underlying variant's property, if present.
 440func (u FileSearchToolFiltersUnionParam) GetValue() *shared.ComparisonFilterValueUnionParam {
 441	if vt := u.OfComparisonFilter; vt != nil {
 442		return &vt.Value
 443	}
 444	return nil
 445}
 446
 447// Returns a pointer to the underlying variant's property, if present.
 448func (u FileSearchToolFiltersUnionParam) GetFilters() []shared.ComparisonFilterParam {
 449	if vt := u.OfCompoundFilter; vt != nil {
 450		return vt.Filters
 451	}
 452	return nil
 453}
 454
 455// Returns a pointer to the underlying variant's property, if present.
 456func (u FileSearchToolFiltersUnionParam) GetType() *string {
 457	if vt := u.OfComparisonFilter; vt != nil {
 458		return (*string)(&vt.Type)
 459	} else if vt := u.OfCompoundFilter; vt != nil {
 460		return (*string)(&vt.Type)
 461	}
 462	return nil
 463}
 464
 465// Ranking options for search.
 466type FileSearchToolRankingOptionsParam struct {
 467	// The score threshold for the file search, a number between 0 and 1. Numbers
 468	// closer to 1 will attempt to return only the most relevant results, but may
 469	// return fewer results.
 470	ScoreThreshold param.Opt[float64] `json:"score_threshold,omitzero"`
 471	// The ranker to use for the file search.
 472	//
 473	// Any of "auto", "default-2024-11-15".
 474	Ranker string `json:"ranker,omitzero"`
 475	paramObj
 476}
 477
 478// IsPresent returns true if the field's value is not omitted and not the JSON
 479// "null". To check if this field is omitted, use [param.IsOmitted].
 480func (f FileSearchToolRankingOptionsParam) IsPresent() bool {
 481	return !param.IsOmitted(f) && !f.IsNull()
 482}
 483func (r FileSearchToolRankingOptionsParam) MarshalJSON() (data []byte, err error) {
 484	type shadow FileSearchToolRankingOptionsParam
 485	return param.MarshalObject(r, (*shadow)(&r))
 486}
 487
 488func init() {
 489	apijson.RegisterFieldValidator[FileSearchToolRankingOptionsParam](
 490		"Ranker", false, "auto", "default-2024-11-15",
 491	)
 492}
 493
 494// Defines a function in your own code the model can choose to call. Learn more
 495// about
 496// [function calling](https://platform.openai.com/docs/guides/function-calling).
 497type FunctionTool struct {
 498	// The name of the function to call.
 499	Name string `json:"name,required"`
 500	// A JSON schema object describing the parameters of the function.
 501	Parameters map[string]interface{} `json:"parameters,required"`
 502	// Whether to enforce strict parameter validation. Default `true`.
 503	Strict bool `json:"strict,required"`
 504	// The type of the function tool. Always `function`.
 505	Type constant.Function `json:"type,required"`
 506	// A description of the function. Used by the model to determine whether or not to
 507	// call the function.
 508	Description string `json:"description,nullable"`
 509	// Metadata for the response, check the presence of optional fields with the
 510	// [resp.Field.IsPresent] method.
 511	JSON struct {
 512		Name        resp.Field
 513		Parameters  resp.Field
 514		Strict      resp.Field
 515		Type        resp.Field
 516		Description resp.Field
 517		ExtraFields map[string]resp.Field
 518		raw         string
 519	} `json:"-"`
 520}
 521
 522// Returns the unmodified JSON received from the API
 523func (r FunctionTool) RawJSON() string { return r.JSON.raw }
 524func (r *FunctionTool) UnmarshalJSON(data []byte) error {
 525	return apijson.UnmarshalRoot(data, r)
 526}
 527
 528// ToParam converts this FunctionTool to a FunctionToolParam.
 529//
 530// Warning: the fields of the param type will not be present. ToParam should only
 531// be used at the last possible moment before sending a request. Test for this with
 532// FunctionToolParam.IsOverridden()
 533func (r FunctionTool) ToParam() FunctionToolParam {
 534	return param.OverrideObj[FunctionToolParam](r.RawJSON())
 535}
 536
 537// Defines a function in your own code the model can choose to call. Learn more
 538// about
 539// [function calling](https://platform.openai.com/docs/guides/function-calling).
 540//
 541// The properties Name, Parameters, Strict, Type are required.
 542type FunctionToolParam struct {
 543	// The name of the function to call.
 544	Name string `json:"name,required"`
 545	// A JSON schema object describing the parameters of the function.
 546	Parameters map[string]interface{} `json:"parameters,omitzero,required"`
 547	// Whether to enforce strict parameter validation. Default `true`.
 548	Strict bool `json:"strict,required"`
 549	// A description of the function. Used by the model to determine whether or not to
 550	// call the function.
 551	Description param.Opt[string] `json:"description,omitzero"`
 552	// The type of the function tool. Always `function`.
 553	//
 554	// This field can be elided, and will marshal its zero value as "function".
 555	Type constant.Function `json:"type,required"`
 556	paramObj
 557}
 558
 559// IsPresent returns true if the field's value is not omitted and not the JSON
 560// "null". To check if this field is omitted, use [param.IsOmitted].
 561func (f FunctionToolParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
 562func (r FunctionToolParam) MarshalJSON() (data []byte, err error) {
 563	type shadow FunctionToolParam
 564	return param.MarshalObject(r, (*shadow)(&r))
 565}
 566
 567type Response struct {
 568	// Unique identifier for this Response.
 569	ID string `json:"id,required"`
 570	// Unix timestamp (in seconds) of when this Response was created.
 571	CreatedAt float64 `json:"created_at,required"`
 572	// An error object returned when the model fails to generate a Response.
 573	Error ResponseError `json:"error,required"`
 574	// Details about why the response is incomplete.
 575	IncompleteDetails ResponseIncompleteDetails `json:"incomplete_details,required"`
 576	// Inserts a system (or developer) message as the first item in the model's
 577	// context.
 578	//
 579	// When using along with `previous_response_id`, the instructions from a previous
 580	// response will be not be carried over to the next response. This makes it simple
 581	// to swap out system (or developer) messages in new responses.
 582	Instructions string `json:"instructions,required"`
 583	// Set of 16 key-value pairs that can be attached to an object. This can be useful
 584	// for storing additional information about the object in a structured format, and
 585	// querying for objects via API or the dashboard.
 586	//
 587	// Keys are strings with a maximum length of 64 characters. Values are strings with
 588	// a maximum length of 512 characters.
 589	Metadata shared.Metadata `json:"metadata,required"`
 590	// Model ID used to generate the response, like `gpt-4o` or `o1`. OpenAI offers a
 591	// wide range of models with different capabilities, performance characteristics,
 592	// and price points. Refer to the
 593	// [model guide](https://platform.openai.com/docs/models) to browse and compare
 594	// available models.
 595	Model shared.ResponsesModel `json:"model,required"`
 596	// The object type of this resource - always set to `response`.
 597	Object constant.Response `json:"object,required"`
 598	// An array of content items generated by the model.
 599	//
 600	//   - The length and order of items in the `output` array is dependent on the
 601	//     model's response.
 602	//   - Rather than accessing the first item in the `output` array and assuming it's
 603	//     an `assistant` message with the content generated by the model, you might
 604	//     consider using the `output_text` property where supported in SDKs.
 605	Output []ResponseOutputItemUnion `json:"output,required"`
 606	// Whether to allow the model to run tool calls in parallel.
 607	ParallelToolCalls bool `json:"parallel_tool_calls,required"`
 608	// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
 609	// make the output more random, while lower values like 0.2 will make it more
 610	// focused and deterministic. We generally recommend altering this or `top_p` but
 611	// not both.
 612	Temperature float64 `json:"temperature,required"`
 613	// How the model should select which tool (or tools) to use when generating a
 614	// response. See the `tools` parameter to see how to specify which tools the model
 615	// can call.
 616	ToolChoice ResponseToolChoiceUnion `json:"tool_choice,required"`
 617	// An array of tools the model may call while generating a response. You can
 618	// specify which tool to use by setting the `tool_choice` parameter.
 619	//
 620	// The two categories of tools you can provide the model are:
 621	//
 622	//   - **Built-in tools**: Tools that are provided by OpenAI that extend the model's
 623	//     capabilities, like
 624	//     [web search](https://platform.openai.com/docs/guides/tools-web-search) or
 625	//     [file search](https://platform.openai.com/docs/guides/tools-file-search).
 626	//     Learn more about
 627	//     [built-in tools](https://platform.openai.com/docs/guides/tools).
 628	//   - **Function calls (custom tools)**: Functions that are defined by you, enabling
 629	//     the model to call your own code. Learn more about
 630	//     [function calling](https://platform.openai.com/docs/guides/function-calling).
 631	Tools []ToolUnion `json:"tools,required"`
 632	// An alternative to sampling with temperature, called nucleus sampling, where the
 633	// model considers the results of the tokens with top_p probability mass. So 0.1
 634	// means only the tokens comprising the top 10% probability mass are considered.
 635	//
 636	// We generally recommend altering this or `temperature` but not both.
 637	TopP float64 `json:"top_p,required"`
 638	// An upper bound for the number of tokens that can be generated for a response,
 639	// including visible output tokens and
 640	// [reasoning tokens](https://platform.openai.com/docs/guides/reasoning).
 641	MaxOutputTokens int64 `json:"max_output_tokens,nullable"`
 642	// The unique ID of the previous response to the model. Use this to create
 643	// multi-turn conversations. Learn more about
 644	// [conversation state](https://platform.openai.com/docs/guides/conversation-state).
 645	PreviousResponseID string `json:"previous_response_id,nullable"`
 646	// **o-series models only**
 647	//
 648	// Configuration options for
 649	// [reasoning models](https://platform.openai.com/docs/guides/reasoning).
 650	Reasoning shared.Reasoning `json:"reasoning,nullable"`
 651	// The status of the response generation. One of `completed`, `failed`,
 652	// `in_progress`, or `incomplete`.
 653	//
 654	// Any of "completed", "failed", "in_progress", "incomplete".
 655	Status ResponseStatus `json:"status"`
 656	// Configuration options for a text response from the model. Can be plain text or
 657	// structured JSON data. Learn more:
 658	//
 659	// - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
 660	// - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
 661	Text ResponseTextConfig `json:"text"`
 662	// The truncation strategy to use for the model response.
 663	//
 664	//   - `auto`: If the context of this response and previous ones exceeds the model's
 665	//     context window size, the model will truncate the response to fit the context
 666	//     window by dropping input items in the middle of the conversation.
 667	//   - `disabled` (default): If a model response will exceed the context window size
 668	//     for a model, the request will fail with a 400 error.
 669	//
 670	// Any of "auto", "disabled".
 671	Truncation ResponseTruncation `json:"truncation,nullable"`
 672	// Represents token usage details including input tokens, output tokens, a
 673	// breakdown of output tokens, and the total tokens used.
 674	Usage ResponseUsage `json:"usage"`
 675	// A unique identifier representing your end-user, which can help OpenAI to monitor
 676	// and detect abuse.
 677	// [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
 678	User string `json:"user"`
 679	// Metadata for the response, check the presence of optional fields with the
 680	// [resp.Field.IsPresent] method.
 681	JSON struct {
 682		ID                 resp.Field
 683		CreatedAt          resp.Field
 684		Error              resp.Field
 685		IncompleteDetails  resp.Field
 686		Instructions       resp.Field
 687		Metadata           resp.Field
 688		Model              resp.Field
 689		Object             resp.Field
 690		Output             resp.Field
 691		ParallelToolCalls  resp.Field
 692		Temperature        resp.Field
 693		ToolChoice         resp.Field
 694		Tools              resp.Field
 695		TopP               resp.Field
 696		MaxOutputTokens    resp.Field
 697		PreviousResponseID resp.Field
 698		Reasoning          resp.Field
 699		Status             resp.Field
 700		Text               resp.Field
 701		Truncation         resp.Field
 702		Usage              resp.Field
 703		User               resp.Field
 704		ExtraFields        map[string]resp.Field
 705		raw                string
 706	} `json:"-"`
 707}
 708
 709func (r Response) OutputText() string {
 710	var outputText strings.Builder
 711	for _, item := range r.Output {
 712		for _, content := range item.Content {
 713			if content.Type == "output_text" {
 714				outputText.WriteString(content.Text)
 715			}
 716		}
 717	}
 718	return outputText.String()
 719}
 720
 721// Returns the unmodified JSON received from the API
 722func (r Response) RawJSON() string { return r.JSON.raw }
 723func (r *Response) UnmarshalJSON(data []byte) error {
 724	return apijson.UnmarshalRoot(data, r)
 725}
 726
 727// Details about why the response is incomplete.
 728type ResponseIncompleteDetails struct {
 729	// The reason why the response is incomplete.
 730	//
 731	// Any of "max_output_tokens", "content_filter".
 732	Reason string `json:"reason"`
 733	// Metadata for the response, check the presence of optional fields with the
 734	// [resp.Field.IsPresent] method.
 735	JSON struct {
 736		Reason      resp.Field
 737		ExtraFields map[string]resp.Field
 738		raw         string
 739	} `json:"-"`
 740}
 741
 742// Returns the unmodified JSON received from the API
 743func (r ResponseIncompleteDetails) RawJSON() string { return r.JSON.raw }
 744func (r *ResponseIncompleteDetails) UnmarshalJSON(data []byte) error {
 745	return apijson.UnmarshalRoot(data, r)
 746}
 747
 748// ResponseToolChoiceUnion contains all possible properties and values from
 749// [ToolChoiceOptions], [ToolChoiceTypes], [ToolChoiceFunction].
 750//
 751// Use the methods beginning with 'As' to cast the union to one of its variants.
 752//
 753// If the underlying value is not a json object, one of the following properties
 754// will be valid: OfToolChoiceMode]
 755type ResponseToolChoiceUnion struct {
 756	// This field will be present if the value is a [ToolChoiceOptions] instead of an
 757	// object.
 758	OfToolChoiceMode ToolChoiceOptions `json:",inline"`
 759	Type             string            `json:"type"`
 760	// This field is from variant [ToolChoiceFunction].
 761	Name string `json:"name"`
 762	JSON struct {
 763		OfToolChoiceMode resp.Field
 764		Type             resp.Field
 765		Name             resp.Field
 766		raw              string
 767	} `json:"-"`
 768}
 769
 770func (u ResponseToolChoiceUnion) AsToolChoiceMode() (v ToolChoiceOptions) {
 771	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 772	return
 773}
 774
 775func (u ResponseToolChoiceUnion) AsHostedTool() (v ToolChoiceTypes) {
 776	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 777	return
 778}
 779
 780func (u ResponseToolChoiceUnion) AsFunctionTool() (v ToolChoiceFunction) {
 781	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 782	return
 783}
 784
 785// Returns the unmodified JSON received from the API
 786func (u ResponseToolChoiceUnion) RawJSON() string { return u.JSON.raw }
 787
 788func (r *ResponseToolChoiceUnion) UnmarshalJSON(data []byte) error {
 789	return apijson.UnmarshalRoot(data, r)
 790}
 791
 792// The truncation strategy to use for the model response.
 793//
 794//   - `auto`: If the context of this response and previous ones exceeds the model's
 795//     context window size, the model will truncate the response to fit the context
 796//     window by dropping input items in the middle of the conversation.
 797//   - `disabled` (default): If a model response will exceed the context window size
 798//     for a model, the request will fail with a 400 error.
 799type ResponseTruncation string
 800
 801const (
 802	ResponseTruncationAuto     ResponseTruncation = "auto"
 803	ResponseTruncationDisabled ResponseTruncation = "disabled"
 804)
 805
 806// Emitted when there is a partial audio response.
 807type ResponseAudioDeltaEvent struct {
 808	// A chunk of Base64 encoded response audio bytes.
 809	Delta string `json:"delta,required"`
 810	// The type of the event. Always `response.audio.delta`.
 811	Type constant.ResponseAudioDelta `json:"type,required"`
 812	// Metadata for the response, check the presence of optional fields with the
 813	// [resp.Field.IsPresent] method.
 814	JSON struct {
 815		Delta       resp.Field
 816		Type        resp.Field
 817		ExtraFields map[string]resp.Field
 818		raw         string
 819	} `json:"-"`
 820}
 821
 822// Returns the unmodified JSON received from the API
 823func (r ResponseAudioDeltaEvent) RawJSON() string { return r.JSON.raw }
 824func (r *ResponseAudioDeltaEvent) UnmarshalJSON(data []byte) error {
 825	return apijson.UnmarshalRoot(data, r)
 826}
 827
 828// Emitted when the audio response is complete.
 829type ResponseAudioDoneEvent struct {
 830	// The type of the event. Always `response.audio.done`.
 831	Type constant.ResponseAudioDone `json:"type,required"`
 832	// Metadata for the response, check the presence of optional fields with the
 833	// [resp.Field.IsPresent] method.
 834	JSON struct {
 835		Type        resp.Field
 836		ExtraFields map[string]resp.Field
 837		raw         string
 838	} `json:"-"`
 839}
 840
 841// Returns the unmodified JSON received from the API
 842func (r ResponseAudioDoneEvent) RawJSON() string { return r.JSON.raw }
 843func (r *ResponseAudioDoneEvent) UnmarshalJSON(data []byte) error {
 844	return apijson.UnmarshalRoot(data, r)
 845}
 846
 847// Emitted when there is a partial transcript of audio.
 848type ResponseAudioTranscriptDeltaEvent struct {
 849	// The partial transcript of the audio response.
 850	Delta string `json:"delta,required"`
 851	// The type of the event. Always `response.audio.transcript.delta`.
 852	Type constant.ResponseAudioTranscriptDelta `json:"type,required"`
 853	// Metadata for the response, check the presence of optional fields with the
 854	// [resp.Field.IsPresent] method.
 855	JSON struct {
 856		Delta       resp.Field
 857		Type        resp.Field
 858		ExtraFields map[string]resp.Field
 859		raw         string
 860	} `json:"-"`
 861}
 862
 863// Returns the unmodified JSON received from the API
 864func (r ResponseAudioTranscriptDeltaEvent) RawJSON() string { return r.JSON.raw }
 865func (r *ResponseAudioTranscriptDeltaEvent) UnmarshalJSON(data []byte) error {
 866	return apijson.UnmarshalRoot(data, r)
 867}
 868
 869// Emitted when the full audio transcript is completed.
 870type ResponseAudioTranscriptDoneEvent struct {
 871	// The type of the event. Always `response.audio.transcript.done`.
 872	Type constant.ResponseAudioTranscriptDone `json:"type,required"`
 873	// Metadata for the response, check the presence of optional fields with the
 874	// [resp.Field.IsPresent] method.
 875	JSON struct {
 876		Type        resp.Field
 877		ExtraFields map[string]resp.Field
 878		raw         string
 879	} `json:"-"`
 880}
 881
 882// Returns the unmodified JSON received from the API
 883func (r ResponseAudioTranscriptDoneEvent) RawJSON() string { return r.JSON.raw }
 884func (r *ResponseAudioTranscriptDoneEvent) UnmarshalJSON(data []byte) error {
 885	return apijson.UnmarshalRoot(data, r)
 886}
 887
 888// Emitted when a partial code snippet is added by the code interpreter.
 889type ResponseCodeInterpreterCallCodeDeltaEvent struct {
 890	// The partial code snippet added by the code interpreter.
 891	Delta string `json:"delta,required"`
 892	// The index of the output item that the code interpreter call is in progress.
 893	OutputIndex int64 `json:"output_index,required"`
 894	// The type of the event. Always `response.code_interpreter_call.code.delta`.
 895	Type constant.ResponseCodeInterpreterCallCodeDelta `json:"type,required"`
 896	// Metadata for the response, check the presence of optional fields with the
 897	// [resp.Field.IsPresent] method.
 898	JSON struct {
 899		Delta       resp.Field
 900		OutputIndex resp.Field
 901		Type        resp.Field
 902		ExtraFields map[string]resp.Field
 903		raw         string
 904	} `json:"-"`
 905}
 906
 907// Returns the unmodified JSON received from the API
 908func (r ResponseCodeInterpreterCallCodeDeltaEvent) RawJSON() string { return r.JSON.raw }
 909func (r *ResponseCodeInterpreterCallCodeDeltaEvent) UnmarshalJSON(data []byte) error {
 910	return apijson.UnmarshalRoot(data, r)
 911}
 912
 913// Emitted when code snippet output is finalized by the code interpreter.
 914type ResponseCodeInterpreterCallCodeDoneEvent struct {
 915	// The final code snippet output by the code interpreter.
 916	Code string `json:"code,required"`
 917	// The index of the output item that the code interpreter call is in progress.
 918	OutputIndex int64 `json:"output_index,required"`
 919	// The type of the event. Always `response.code_interpreter_call.code.done`.
 920	Type constant.ResponseCodeInterpreterCallCodeDone `json:"type,required"`
 921	// Metadata for the response, check the presence of optional fields with the
 922	// [resp.Field.IsPresent] method.
 923	JSON struct {
 924		Code        resp.Field
 925		OutputIndex resp.Field
 926		Type        resp.Field
 927		ExtraFields map[string]resp.Field
 928		raw         string
 929	} `json:"-"`
 930}
 931
 932// Returns the unmodified JSON received from the API
 933func (r ResponseCodeInterpreterCallCodeDoneEvent) RawJSON() string { return r.JSON.raw }
 934func (r *ResponseCodeInterpreterCallCodeDoneEvent) UnmarshalJSON(data []byte) error {
 935	return apijson.UnmarshalRoot(data, r)
 936}
 937
 938// Emitted when the code interpreter call is completed.
 939type ResponseCodeInterpreterCallCompletedEvent struct {
 940	// A tool call to run code.
 941	CodeInterpreterCall ResponseCodeInterpreterToolCall `json:"code_interpreter_call,required"`
 942	// The index of the output item that the code interpreter call is in progress.
 943	OutputIndex int64 `json:"output_index,required"`
 944	// The type of the event. Always `response.code_interpreter_call.completed`.
 945	Type constant.ResponseCodeInterpreterCallCompleted `json:"type,required"`
 946	// Metadata for the response, check the presence of optional fields with the
 947	// [resp.Field.IsPresent] method.
 948	JSON struct {
 949		CodeInterpreterCall resp.Field
 950		OutputIndex         resp.Field
 951		Type                resp.Field
 952		ExtraFields         map[string]resp.Field
 953		raw                 string
 954	} `json:"-"`
 955}
 956
 957// Returns the unmodified JSON received from the API
 958func (r ResponseCodeInterpreterCallCompletedEvent) RawJSON() string { return r.JSON.raw }
 959func (r *ResponseCodeInterpreterCallCompletedEvent) UnmarshalJSON(data []byte) error {
 960	return apijson.UnmarshalRoot(data, r)
 961}
 962
 963// Emitted when a code interpreter call is in progress.
 964type ResponseCodeInterpreterCallInProgressEvent struct {
 965	// A tool call to run code.
 966	CodeInterpreterCall ResponseCodeInterpreterToolCall `json:"code_interpreter_call,required"`
 967	// The index of the output item that the code interpreter call is in progress.
 968	OutputIndex int64 `json:"output_index,required"`
 969	// The type of the event. Always `response.code_interpreter_call.in_progress`.
 970	Type constant.ResponseCodeInterpreterCallInProgress `json:"type,required"`
 971	// Metadata for the response, check the presence of optional fields with the
 972	// [resp.Field.IsPresent] method.
 973	JSON struct {
 974		CodeInterpreterCall resp.Field
 975		OutputIndex         resp.Field
 976		Type                resp.Field
 977		ExtraFields         map[string]resp.Field
 978		raw                 string
 979	} `json:"-"`
 980}
 981
 982// Returns the unmodified JSON received from the API
 983func (r ResponseCodeInterpreterCallInProgressEvent) RawJSON() string { return r.JSON.raw }
 984func (r *ResponseCodeInterpreterCallInProgressEvent) UnmarshalJSON(data []byte) error {
 985	return apijson.UnmarshalRoot(data, r)
 986}
 987
 988// Emitted when the code interpreter is actively interpreting the code snippet.
 989type ResponseCodeInterpreterCallInterpretingEvent struct {
 990	// A tool call to run code.
 991	CodeInterpreterCall ResponseCodeInterpreterToolCall `json:"code_interpreter_call,required"`
 992	// The index of the output item that the code interpreter call is in progress.
 993	OutputIndex int64 `json:"output_index,required"`
 994	// The type of the event. Always `response.code_interpreter_call.interpreting`.
 995	Type constant.ResponseCodeInterpreterCallInterpreting `json:"type,required"`
 996	// Metadata for the response, check the presence of optional fields with the
 997	// [resp.Field.IsPresent] method.
 998	JSON struct {
 999		CodeInterpreterCall resp.Field
1000		OutputIndex         resp.Field
1001		Type                resp.Field
1002		ExtraFields         map[string]resp.Field
1003		raw                 string
1004	} `json:"-"`
1005}
1006
1007// Returns the unmodified JSON received from the API
1008func (r ResponseCodeInterpreterCallInterpretingEvent) RawJSON() string { return r.JSON.raw }
1009func (r *ResponseCodeInterpreterCallInterpretingEvent) UnmarshalJSON(data []byte) error {
1010	return apijson.UnmarshalRoot(data, r)
1011}
1012
1013// A tool call to run code.
1014type ResponseCodeInterpreterToolCall struct {
1015	// The unique ID of the code interpreter tool call.
1016	ID string `json:"id,required"`
1017	// The code to run.
1018	Code string `json:"code,required"`
1019	// The results of the code interpreter tool call.
1020	Results []ResponseCodeInterpreterToolCallResultUnion `json:"results,required"`
1021	// The status of the code interpreter tool call.
1022	//
1023	// Any of "in_progress", "interpreting", "completed".
1024	Status ResponseCodeInterpreterToolCallStatus `json:"status,required"`
1025	// The type of the code interpreter tool call. Always `code_interpreter_call`.
1026	Type constant.CodeInterpreterCall `json:"type,required"`
1027	// Metadata for the response, check the presence of optional fields with the
1028	// [resp.Field.IsPresent] method.
1029	JSON struct {
1030		ID          resp.Field
1031		Code        resp.Field
1032		Results     resp.Field
1033		Status      resp.Field
1034		Type        resp.Field
1035		ExtraFields map[string]resp.Field
1036		raw         string
1037	} `json:"-"`
1038}
1039
1040// Returns the unmodified JSON received from the API
1041func (r ResponseCodeInterpreterToolCall) RawJSON() string { return r.JSON.raw }
1042func (r *ResponseCodeInterpreterToolCall) UnmarshalJSON(data []byte) error {
1043	return apijson.UnmarshalRoot(data, r)
1044}
1045
1046// ResponseCodeInterpreterToolCallResultUnion contains all possible properties and
1047// values from [ResponseCodeInterpreterToolCallResultLogs],
1048// [ResponseCodeInterpreterToolCallResultFiles].
1049//
1050// Use the [ResponseCodeInterpreterToolCallResultUnion.AsAny] method to switch on
1051// the variant.
1052//
1053// Use the methods beginning with 'As' to cast the union to one of its variants.
1054type ResponseCodeInterpreterToolCallResultUnion struct {
1055	// This field is from variant [ResponseCodeInterpreterToolCallResultLogs].
1056	Logs string `json:"logs"`
1057	// Any of "logs", "files".
1058	Type string `json:"type"`
1059	// This field is from variant [ResponseCodeInterpreterToolCallResultFiles].
1060	Files []ResponseCodeInterpreterToolCallResultFilesFile `json:"files"`
1061	JSON  struct {
1062		Logs  resp.Field
1063		Type  resp.Field
1064		Files resp.Field
1065		raw   string
1066	} `json:"-"`
1067}
1068
1069// Use the following switch statement to find the correct variant
1070//
1071//	switch variant := ResponseCodeInterpreterToolCallResultUnion.AsAny().(type) {
1072//	case ResponseCodeInterpreterToolCallResultLogs:
1073//	case ResponseCodeInterpreterToolCallResultFiles:
1074//	default:
1075//	  fmt.Errorf("no variant present")
1076//	}
1077func (u ResponseCodeInterpreterToolCallResultUnion) AsAny() any {
1078	switch u.Type {
1079	case "logs":
1080		return u.AsLogs()
1081	case "files":
1082		return u.AsFiles()
1083	}
1084	return nil
1085}
1086
1087func (u ResponseCodeInterpreterToolCallResultUnion) AsLogs() (v ResponseCodeInterpreterToolCallResultLogs) {
1088	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1089	return
1090}
1091
1092func (u ResponseCodeInterpreterToolCallResultUnion) AsFiles() (v ResponseCodeInterpreterToolCallResultFiles) {
1093	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1094	return
1095}
1096
1097// Returns the unmodified JSON received from the API
1098func (u ResponseCodeInterpreterToolCallResultUnion) RawJSON() string { return u.JSON.raw }
1099
1100func (r *ResponseCodeInterpreterToolCallResultUnion) UnmarshalJSON(data []byte) error {
1101	return apijson.UnmarshalRoot(data, r)
1102}
1103
1104// The output of a code interpreter tool call that is text.
1105type ResponseCodeInterpreterToolCallResultLogs struct {
1106	// The logs of the code interpreter tool call.
1107	Logs string `json:"logs,required"`
1108	// The type of the code interpreter text output. Always `logs`.
1109	Type constant.Logs `json:"type,required"`
1110	// Metadata for the response, check the presence of optional fields with the
1111	// [resp.Field.IsPresent] method.
1112	JSON struct {
1113		Logs        resp.Field
1114		Type        resp.Field
1115		ExtraFields map[string]resp.Field
1116		raw         string
1117	} `json:"-"`
1118}
1119
1120// Returns the unmodified JSON received from the API
1121func (r ResponseCodeInterpreterToolCallResultLogs) RawJSON() string { return r.JSON.raw }
1122func (r *ResponseCodeInterpreterToolCallResultLogs) UnmarshalJSON(data []byte) error {
1123	return apijson.UnmarshalRoot(data, r)
1124}
1125
1126// The output of a code interpreter tool call that is a file.
1127type ResponseCodeInterpreterToolCallResultFiles struct {
1128	Files []ResponseCodeInterpreterToolCallResultFilesFile `json:"files,required"`
1129	// The type of the code interpreter file output. Always `files`.
1130	Type constant.Files `json:"type,required"`
1131	// Metadata for the response, check the presence of optional fields with the
1132	// [resp.Field.IsPresent] method.
1133	JSON struct {
1134		Files       resp.Field
1135		Type        resp.Field
1136		ExtraFields map[string]resp.Field
1137		raw         string
1138	} `json:"-"`
1139}
1140
1141// Returns the unmodified JSON received from the API
1142func (r ResponseCodeInterpreterToolCallResultFiles) RawJSON() string { return r.JSON.raw }
1143func (r *ResponseCodeInterpreterToolCallResultFiles) UnmarshalJSON(data []byte) error {
1144	return apijson.UnmarshalRoot(data, r)
1145}
1146
1147type ResponseCodeInterpreterToolCallResultFilesFile struct {
1148	// The ID of the file.
1149	FileID string `json:"file_id,required"`
1150	// The MIME type of the file.
1151	MimeType string `json:"mime_type,required"`
1152	// Metadata for the response, check the presence of optional fields with the
1153	// [resp.Field.IsPresent] method.
1154	JSON struct {
1155		FileID      resp.Field
1156		MimeType    resp.Field
1157		ExtraFields map[string]resp.Field
1158		raw         string
1159	} `json:"-"`
1160}
1161
1162// Returns the unmodified JSON received from the API
1163func (r ResponseCodeInterpreterToolCallResultFilesFile) RawJSON() string { return r.JSON.raw }
1164func (r *ResponseCodeInterpreterToolCallResultFilesFile) UnmarshalJSON(data []byte) error {
1165	return apijson.UnmarshalRoot(data, r)
1166}
1167
1168// The status of the code interpreter tool call.
1169type ResponseCodeInterpreterToolCallStatus string
1170
1171const (
1172	ResponseCodeInterpreterToolCallStatusInProgress   ResponseCodeInterpreterToolCallStatus = "in_progress"
1173	ResponseCodeInterpreterToolCallStatusInterpreting ResponseCodeInterpreterToolCallStatus = "interpreting"
1174	ResponseCodeInterpreterToolCallStatusCompleted    ResponseCodeInterpreterToolCallStatus = "completed"
1175)
1176
1177// Emitted when the model response is complete.
1178type ResponseCompletedEvent struct {
1179	// Properties of the completed response.
1180	Response Response `json:"response,required"`
1181	// The type of the event. Always `response.completed`.
1182	Type constant.ResponseCompleted `json:"type,required"`
1183	// Metadata for the response, check the presence of optional fields with the
1184	// [resp.Field.IsPresent] method.
1185	JSON struct {
1186		Response    resp.Field
1187		Type        resp.Field
1188		ExtraFields map[string]resp.Field
1189		raw         string
1190	} `json:"-"`
1191}
1192
1193// Returns the unmodified JSON received from the API
1194func (r ResponseCompletedEvent) RawJSON() string { return r.JSON.raw }
1195func (r *ResponseCompletedEvent) UnmarshalJSON(data []byte) error {
1196	return apijson.UnmarshalRoot(data, r)
1197}
1198
1199// A tool call to a computer use tool. See the
1200// [computer use guide](https://platform.openai.com/docs/guides/tools-computer-use)
1201// for more information.
1202type ResponseComputerToolCall struct {
1203	// The unique ID of the computer call.
1204	ID string `json:"id,required"`
1205	// A click action.
1206	Action ResponseComputerToolCallActionUnion `json:"action,required"`
1207	// An identifier used when responding to the tool call with output.
1208	CallID string `json:"call_id,required"`
1209	// The pending safety checks for the computer call.
1210	PendingSafetyChecks []ResponseComputerToolCallPendingSafetyCheck `json:"pending_safety_checks,required"`
1211	// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
1212	// Populated when items are returned via API.
1213	//
1214	// Any of "in_progress", "completed", "incomplete".
1215	Status ResponseComputerToolCallStatus `json:"status,required"`
1216	// The type of the computer call. Always `computer_call`.
1217	//
1218	// Any of "computer_call".
1219	Type ResponseComputerToolCallType `json:"type,required"`
1220	// Metadata for the response, check the presence of optional fields with the
1221	// [resp.Field.IsPresent] method.
1222	JSON struct {
1223		ID                  resp.Field
1224		Action              resp.Field
1225		CallID              resp.Field
1226		PendingSafetyChecks resp.Field
1227		Status              resp.Field
1228		Type                resp.Field
1229		ExtraFields         map[string]resp.Field
1230		raw                 string
1231	} `json:"-"`
1232}
1233
1234// Returns the unmodified JSON received from the API
1235func (r ResponseComputerToolCall) RawJSON() string { return r.JSON.raw }
1236func (r *ResponseComputerToolCall) UnmarshalJSON(data []byte) error {
1237	return apijson.UnmarshalRoot(data, r)
1238}
1239
1240// ToParam converts this ResponseComputerToolCall to a
1241// ResponseComputerToolCallParam.
1242//
1243// Warning: the fields of the param type will not be present. ToParam should only
1244// be used at the last possible moment before sending a request. Test for this with
1245// ResponseComputerToolCallParam.IsOverridden()
1246func (r ResponseComputerToolCall) ToParam() ResponseComputerToolCallParam {
1247	return param.OverrideObj[ResponseComputerToolCallParam](r.RawJSON())
1248}
1249
1250// ResponseComputerToolCallActionUnion contains all possible properties and values
1251// from [ResponseComputerToolCallActionClick],
1252// [ResponseComputerToolCallActionDoubleClick],
1253// [ResponseComputerToolCallActionDrag], [ResponseComputerToolCallActionKeypress],
1254// [ResponseComputerToolCallActionMove],
1255// [ResponseComputerToolCallActionScreenshot],
1256// [ResponseComputerToolCallActionScroll], [ResponseComputerToolCallActionType],
1257// [ResponseComputerToolCallActionWait].
1258//
1259// Use the [ResponseComputerToolCallActionUnion.AsAny] method to switch on the
1260// variant.
1261//
1262// Use the methods beginning with 'As' to cast the union to one of its variants.
1263type ResponseComputerToolCallActionUnion struct {
1264	// This field is from variant [ResponseComputerToolCallActionClick].
1265	Button string `json:"button"`
1266	// Any of "click", "double_click", "drag", "keypress", "move", "screenshot",
1267	// "scroll", "type", "wait".
1268	Type string `json:"type"`
1269	X    int64  `json:"x"`
1270	Y    int64  `json:"y"`
1271	// This field is from variant [ResponseComputerToolCallActionDrag].
1272	Path []ResponseComputerToolCallActionDragPath `json:"path"`
1273	// This field is from variant [ResponseComputerToolCallActionKeypress].
1274	Keys []string `json:"keys"`
1275	// This field is from variant [ResponseComputerToolCallActionScroll].
1276	ScrollX int64 `json:"scroll_x"`
1277	// This field is from variant [ResponseComputerToolCallActionScroll].
1278	ScrollY int64 `json:"scroll_y"`
1279	// This field is from variant [ResponseComputerToolCallActionType].
1280	Text string `json:"text"`
1281	JSON struct {
1282		Button  resp.Field
1283		Type    resp.Field
1284		X       resp.Field
1285		Y       resp.Field
1286		Path    resp.Field
1287		Keys    resp.Field
1288		ScrollX resp.Field
1289		ScrollY resp.Field
1290		Text    resp.Field
1291		raw     string
1292	} `json:"-"`
1293}
1294
1295// Use the following switch statement to find the correct variant
1296//
1297//	switch variant := ResponseComputerToolCallActionUnion.AsAny().(type) {
1298//	case ResponseComputerToolCallActionClick:
1299//	case ResponseComputerToolCallActionDoubleClick:
1300//	case ResponseComputerToolCallActionDrag:
1301//	case ResponseComputerToolCallActionKeypress:
1302//	case ResponseComputerToolCallActionMove:
1303//	case ResponseComputerToolCallActionScreenshot:
1304//	case ResponseComputerToolCallActionScroll:
1305//	case ResponseComputerToolCallActionType:
1306//	case ResponseComputerToolCallActionWait:
1307//	default:
1308//	  fmt.Errorf("no variant present")
1309//	}
1310func (u ResponseComputerToolCallActionUnion) AsAny() any {
1311	switch u.Type {
1312	case "click":
1313		return u.AsClick()
1314	case "double_click":
1315		return u.AsDoubleClick()
1316	case "drag":
1317		return u.AsDrag()
1318	case "keypress":
1319		return u.AsKeypress()
1320	case "move":
1321		return u.AsMove()
1322	case "screenshot":
1323		return u.AsScreenshot()
1324	case "scroll":
1325		return u.AsScroll()
1326	case "type":
1327		return u.AsType()
1328	case "wait":
1329		return u.AsWait()
1330	}
1331	return nil
1332}
1333
1334func (u ResponseComputerToolCallActionUnion) AsClick() (v ResponseComputerToolCallActionClick) {
1335	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1336	return
1337}
1338
1339func (u ResponseComputerToolCallActionUnion) AsDoubleClick() (v ResponseComputerToolCallActionDoubleClick) {
1340	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1341	return
1342}
1343
1344func (u ResponseComputerToolCallActionUnion) AsDrag() (v ResponseComputerToolCallActionDrag) {
1345	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1346	return
1347}
1348
1349func (u ResponseComputerToolCallActionUnion) AsKeypress() (v ResponseComputerToolCallActionKeypress) {
1350	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1351	return
1352}
1353
1354func (u ResponseComputerToolCallActionUnion) AsMove() (v ResponseComputerToolCallActionMove) {
1355	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1356	return
1357}
1358
1359func (u ResponseComputerToolCallActionUnion) AsScreenshot() (v ResponseComputerToolCallActionScreenshot) {
1360	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1361	return
1362}
1363
1364func (u ResponseComputerToolCallActionUnion) AsScroll() (v ResponseComputerToolCallActionScroll) {
1365	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1366	return
1367}
1368
1369func (u ResponseComputerToolCallActionUnion) AsType() (v ResponseComputerToolCallActionType) {
1370	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1371	return
1372}
1373
1374func (u ResponseComputerToolCallActionUnion) AsWait() (v ResponseComputerToolCallActionWait) {
1375	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1376	return
1377}
1378
1379// Returns the unmodified JSON received from the API
1380func (u ResponseComputerToolCallActionUnion) RawJSON() string { return u.JSON.raw }
1381
1382func (r *ResponseComputerToolCallActionUnion) UnmarshalJSON(data []byte) error {
1383	return apijson.UnmarshalRoot(data, r)
1384}
1385
1386// A click action.
1387type ResponseComputerToolCallActionClick struct {
1388	// Indicates which mouse button was pressed during the click. One of `left`,
1389	// `right`, `wheel`, `back`, or `forward`.
1390	//
1391	// Any of "left", "right", "wheel", "back", "forward".
1392	Button string `json:"button,required"`
1393	// Specifies the event type. For a click action, this property is always set to
1394	// `click`.
1395	Type constant.Click `json:"type,required"`
1396	// The x-coordinate where the click occurred.
1397	X int64 `json:"x,required"`
1398	// The y-coordinate where the click occurred.
1399	Y int64 `json:"y,required"`
1400	// Metadata for the response, check the presence of optional fields with the
1401	// [resp.Field.IsPresent] method.
1402	JSON struct {
1403		Button      resp.Field
1404		Type        resp.Field
1405		X           resp.Field
1406		Y           resp.Field
1407		ExtraFields map[string]resp.Field
1408		raw         string
1409	} `json:"-"`
1410}
1411
1412// Returns the unmodified JSON received from the API
1413func (r ResponseComputerToolCallActionClick) RawJSON() string { return r.JSON.raw }
1414func (r *ResponseComputerToolCallActionClick) UnmarshalJSON(data []byte) error {
1415	return apijson.UnmarshalRoot(data, r)
1416}
1417
1418// A double click action.
1419type ResponseComputerToolCallActionDoubleClick struct {
1420	// Specifies the event type. For a double click action, this property is always set
1421	// to `double_click`.
1422	Type constant.DoubleClick `json:"type,required"`
1423	// The x-coordinate where the double click occurred.
1424	X int64 `json:"x,required"`
1425	// The y-coordinate where the double click occurred.
1426	Y int64 `json:"y,required"`
1427	// Metadata for the response, check the presence of optional fields with the
1428	// [resp.Field.IsPresent] method.
1429	JSON struct {
1430		Type        resp.Field
1431		X           resp.Field
1432		Y           resp.Field
1433		ExtraFields map[string]resp.Field
1434		raw         string
1435	} `json:"-"`
1436}
1437
1438// Returns the unmodified JSON received from the API
1439func (r ResponseComputerToolCallActionDoubleClick) RawJSON() string { return r.JSON.raw }
1440func (r *ResponseComputerToolCallActionDoubleClick) UnmarshalJSON(data []byte) error {
1441	return apijson.UnmarshalRoot(data, r)
1442}
1443
1444// A drag action.
1445type ResponseComputerToolCallActionDrag struct {
1446	// An array of coordinates representing the path of the drag action. Coordinates
1447	// will appear as an array of objects, eg
1448	//
1449	// ```
1450	// [
1451	//
1452	//	{ x: 100, y: 200 },
1453	//	{ x: 200, y: 300 }
1454	//
1455	// ]
1456	// ```
1457	Path []ResponseComputerToolCallActionDragPath `json:"path,required"`
1458	// Specifies the event type. For a drag action, this property is always set to
1459	// `drag`.
1460	Type constant.Drag `json:"type,required"`
1461	// Metadata for the response, check the presence of optional fields with the
1462	// [resp.Field.IsPresent] method.
1463	JSON struct {
1464		Path        resp.Field
1465		Type        resp.Field
1466		ExtraFields map[string]resp.Field
1467		raw         string
1468	} `json:"-"`
1469}
1470
1471// Returns the unmodified JSON received from the API
1472func (r ResponseComputerToolCallActionDrag) RawJSON() string { return r.JSON.raw }
1473func (r *ResponseComputerToolCallActionDrag) UnmarshalJSON(data []byte) error {
1474	return apijson.UnmarshalRoot(data, r)
1475}
1476
1477// A series of x/y coordinate pairs in the drag path.
1478type ResponseComputerToolCallActionDragPath struct {
1479	// The x-coordinate.
1480	X int64 `json:"x,required"`
1481	// The y-coordinate.
1482	Y int64 `json:"y,required"`
1483	// Metadata for the response, check the presence of optional fields with the
1484	// [resp.Field.IsPresent] method.
1485	JSON struct {
1486		X           resp.Field
1487		Y           resp.Field
1488		ExtraFields map[string]resp.Field
1489		raw         string
1490	} `json:"-"`
1491}
1492
1493// Returns the unmodified JSON received from the API
1494func (r ResponseComputerToolCallActionDragPath) RawJSON() string { return r.JSON.raw }
1495func (r *ResponseComputerToolCallActionDragPath) UnmarshalJSON(data []byte) error {
1496	return apijson.UnmarshalRoot(data, r)
1497}
1498
1499// A collection of keypresses the model would like to perform.
1500type ResponseComputerToolCallActionKeypress struct {
1501	// The combination of keys the model is requesting to be pressed. This is an array
1502	// of strings, each representing a key.
1503	Keys []string `json:"keys,required"`
1504	// Specifies the event type. For a keypress action, this property is always set to
1505	// `keypress`.
1506	Type constant.Keypress `json:"type,required"`
1507	// Metadata for the response, check the presence of optional fields with the
1508	// [resp.Field.IsPresent] method.
1509	JSON struct {
1510		Keys        resp.Field
1511		Type        resp.Field
1512		ExtraFields map[string]resp.Field
1513		raw         string
1514	} `json:"-"`
1515}
1516
1517// Returns the unmodified JSON received from the API
1518func (r ResponseComputerToolCallActionKeypress) RawJSON() string { return r.JSON.raw }
1519func (r *ResponseComputerToolCallActionKeypress) UnmarshalJSON(data []byte) error {
1520	return apijson.UnmarshalRoot(data, r)
1521}
1522
1523// A mouse move action.
1524type ResponseComputerToolCallActionMove struct {
1525	// Specifies the event type. For a move action, this property is always set to
1526	// `move`.
1527	Type constant.Move `json:"type,required"`
1528	// The x-coordinate to move to.
1529	X int64 `json:"x,required"`
1530	// The y-coordinate to move to.
1531	Y int64 `json:"y,required"`
1532	// Metadata for the response, check the presence of optional fields with the
1533	// [resp.Field.IsPresent] method.
1534	JSON struct {
1535		Type        resp.Field
1536		X           resp.Field
1537		Y           resp.Field
1538		ExtraFields map[string]resp.Field
1539		raw         string
1540	} `json:"-"`
1541}
1542
1543// Returns the unmodified JSON received from the API
1544func (r ResponseComputerToolCallActionMove) RawJSON() string { return r.JSON.raw }
1545func (r *ResponseComputerToolCallActionMove) UnmarshalJSON(data []byte) error {
1546	return apijson.UnmarshalRoot(data, r)
1547}
1548
1549// A screenshot action.
1550type ResponseComputerToolCallActionScreenshot struct {
1551	// Specifies the event type. For a screenshot action, this property is always set
1552	// to `screenshot`.
1553	Type constant.Screenshot `json:"type,required"`
1554	// Metadata for the response, check the presence of optional fields with the
1555	// [resp.Field.IsPresent] method.
1556	JSON struct {
1557		Type        resp.Field
1558		ExtraFields map[string]resp.Field
1559		raw         string
1560	} `json:"-"`
1561}
1562
1563// Returns the unmodified JSON received from the API
1564func (r ResponseComputerToolCallActionScreenshot) RawJSON() string { return r.JSON.raw }
1565func (r *ResponseComputerToolCallActionScreenshot) UnmarshalJSON(data []byte) error {
1566	return apijson.UnmarshalRoot(data, r)
1567}
1568
1569// A scroll action.
1570type ResponseComputerToolCallActionScroll struct {
1571	// The horizontal scroll distance.
1572	ScrollX int64 `json:"scroll_x,required"`
1573	// The vertical scroll distance.
1574	ScrollY int64 `json:"scroll_y,required"`
1575	// Specifies the event type. For a scroll action, this property is always set to
1576	// `scroll`.
1577	Type constant.Scroll `json:"type,required"`
1578	// The x-coordinate where the scroll occurred.
1579	X int64 `json:"x,required"`
1580	// The y-coordinate where the scroll occurred.
1581	Y int64 `json:"y,required"`
1582	// Metadata for the response, check the presence of optional fields with the
1583	// [resp.Field.IsPresent] method.
1584	JSON struct {
1585		ScrollX     resp.Field
1586		ScrollY     resp.Field
1587		Type        resp.Field
1588		X           resp.Field
1589		Y           resp.Field
1590		ExtraFields map[string]resp.Field
1591		raw         string
1592	} `json:"-"`
1593}
1594
1595// Returns the unmodified JSON received from the API
1596func (r ResponseComputerToolCallActionScroll) RawJSON() string { return r.JSON.raw }
1597func (r *ResponseComputerToolCallActionScroll) UnmarshalJSON(data []byte) error {
1598	return apijson.UnmarshalRoot(data, r)
1599}
1600
1601// An action to type in text.
1602type ResponseComputerToolCallActionType struct {
1603	// The text to type.
1604	Text string `json:"text,required"`
1605	// Specifies the event type. For a type action, this property is always set to
1606	// `type`.
1607	Type constant.Type `json:"type,required"`
1608	// Metadata for the response, check the presence of optional fields with the
1609	// [resp.Field.IsPresent] method.
1610	JSON struct {
1611		Text        resp.Field
1612		Type        resp.Field
1613		ExtraFields map[string]resp.Field
1614		raw         string
1615	} `json:"-"`
1616}
1617
1618// Returns the unmodified JSON received from the API
1619func (r ResponseComputerToolCallActionType) RawJSON() string { return r.JSON.raw }
1620func (r *ResponseComputerToolCallActionType) UnmarshalJSON(data []byte) error {
1621	return apijson.UnmarshalRoot(data, r)
1622}
1623
1624// A wait action.
1625type ResponseComputerToolCallActionWait struct {
1626	// Specifies the event type. For a wait action, this property is always set to
1627	// `wait`.
1628	Type constant.Wait `json:"type,required"`
1629	// Metadata for the response, check the presence of optional fields with the
1630	// [resp.Field.IsPresent] method.
1631	JSON struct {
1632		Type        resp.Field
1633		ExtraFields map[string]resp.Field
1634		raw         string
1635	} `json:"-"`
1636}
1637
1638// Returns the unmodified JSON received from the API
1639func (r ResponseComputerToolCallActionWait) RawJSON() string { return r.JSON.raw }
1640func (r *ResponseComputerToolCallActionWait) UnmarshalJSON(data []byte) error {
1641	return apijson.UnmarshalRoot(data, r)
1642}
1643
1644// A pending safety check for the computer call.
1645type ResponseComputerToolCallPendingSafetyCheck struct {
1646	// The ID of the pending safety check.
1647	ID string `json:"id,required"`
1648	// The type of the pending safety check.
1649	Code string `json:"code,required"`
1650	// Details about the pending safety check.
1651	Message string `json:"message,required"`
1652	// Metadata for the response, check the presence of optional fields with the
1653	// [resp.Field.IsPresent] method.
1654	JSON struct {
1655		ID          resp.Field
1656		Code        resp.Field
1657		Message     resp.Field
1658		ExtraFields map[string]resp.Field
1659		raw         string
1660	} `json:"-"`
1661}
1662
1663// Returns the unmodified JSON received from the API
1664func (r ResponseComputerToolCallPendingSafetyCheck) RawJSON() string { return r.JSON.raw }
1665func (r *ResponseComputerToolCallPendingSafetyCheck) UnmarshalJSON(data []byte) error {
1666	return apijson.UnmarshalRoot(data, r)
1667}
1668
1669// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
1670// Populated when items are returned via API.
1671type ResponseComputerToolCallStatus string
1672
1673const (
1674	ResponseComputerToolCallStatusInProgress ResponseComputerToolCallStatus = "in_progress"
1675	ResponseComputerToolCallStatusCompleted  ResponseComputerToolCallStatus = "completed"
1676	ResponseComputerToolCallStatusIncomplete ResponseComputerToolCallStatus = "incomplete"
1677)
1678
1679// The type of the computer call. Always `computer_call`.
1680type ResponseComputerToolCallType string
1681
1682const (
1683	ResponseComputerToolCallTypeComputerCall ResponseComputerToolCallType = "computer_call"
1684)
1685
1686// A tool call to a computer use tool. See the
1687// [computer use guide](https://platform.openai.com/docs/guides/tools-computer-use)
1688// for more information.
1689//
1690// The properties ID, Action, CallID, PendingSafetyChecks, Status, Type are
1691// required.
1692type ResponseComputerToolCallParam struct {
1693	// The unique ID of the computer call.
1694	ID string `json:"id,required"`
1695	// A click action.
1696	Action ResponseComputerToolCallActionUnionParam `json:"action,omitzero,required"`
1697	// An identifier used when responding to the tool call with output.
1698	CallID string `json:"call_id,required"`
1699	// The pending safety checks for the computer call.
1700	PendingSafetyChecks []ResponseComputerToolCallPendingSafetyCheckParam `json:"pending_safety_checks,omitzero,required"`
1701	// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
1702	// Populated when items are returned via API.
1703	//
1704	// Any of "in_progress", "completed", "incomplete".
1705	Status ResponseComputerToolCallStatus `json:"status,omitzero,required"`
1706	// The type of the computer call. Always `computer_call`.
1707	//
1708	// Any of "computer_call".
1709	Type ResponseComputerToolCallType `json:"type,omitzero,required"`
1710	paramObj
1711}
1712
1713// IsPresent returns true if the field's value is not omitted and not the JSON
1714// "null". To check if this field is omitted, use [param.IsOmitted].
1715func (f ResponseComputerToolCallParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
1716func (r ResponseComputerToolCallParam) MarshalJSON() (data []byte, err error) {
1717	type shadow ResponseComputerToolCallParam
1718	return param.MarshalObject(r, (*shadow)(&r))
1719}
1720
1721// Only one field can be non-zero.
1722//
1723// Use [param.IsOmitted] to confirm if a field is set.
1724type ResponseComputerToolCallActionUnionParam struct {
1725	OfClick       *ResponseComputerToolCallActionClickParam       `json:",omitzero,inline"`
1726	OfDoubleClick *ResponseComputerToolCallActionDoubleClickParam `json:",omitzero,inline"`
1727	OfDrag        *ResponseComputerToolCallActionDragParam        `json:",omitzero,inline"`
1728	OfKeypress    *ResponseComputerToolCallActionKeypressParam    `json:",omitzero,inline"`
1729	OfMove        *ResponseComputerToolCallActionMoveParam        `json:",omitzero,inline"`
1730	OfScreenshot  *ResponseComputerToolCallActionScreenshotParam  `json:",omitzero,inline"`
1731	OfScroll      *ResponseComputerToolCallActionScrollParam      `json:",omitzero,inline"`
1732	OfType        *ResponseComputerToolCallActionTypeParam        `json:",omitzero,inline"`
1733	OfWait        *ResponseComputerToolCallActionWaitParam        `json:",omitzero,inline"`
1734	paramUnion
1735}
1736
1737// IsPresent returns true if the field's value is not omitted and not the JSON
1738// "null". To check if this field is omitted, use [param.IsOmitted].
1739func (u ResponseComputerToolCallActionUnionParam) IsPresent() bool {
1740	return !param.IsOmitted(u) && !u.IsNull()
1741}
1742func (u ResponseComputerToolCallActionUnionParam) MarshalJSON() ([]byte, error) {
1743	return param.MarshalUnion[ResponseComputerToolCallActionUnionParam](u.OfClick,
1744		u.OfDoubleClick,
1745		u.OfDrag,
1746		u.OfKeypress,
1747		u.OfMove,
1748		u.OfScreenshot,
1749		u.OfScroll,
1750		u.OfType,
1751		u.OfWait)
1752}
1753
1754func (u *ResponseComputerToolCallActionUnionParam) asAny() any {
1755	if !param.IsOmitted(u.OfClick) {
1756		return u.OfClick
1757	} else if !param.IsOmitted(u.OfDoubleClick) {
1758		return u.OfDoubleClick
1759	} else if !param.IsOmitted(u.OfDrag) {
1760		return u.OfDrag
1761	} else if !param.IsOmitted(u.OfKeypress) {
1762		return u.OfKeypress
1763	} else if !param.IsOmitted(u.OfMove) {
1764		return u.OfMove
1765	} else if !param.IsOmitted(u.OfScreenshot) {
1766		return u.OfScreenshot
1767	} else if !param.IsOmitted(u.OfScroll) {
1768		return u.OfScroll
1769	} else if !param.IsOmitted(u.OfType) {
1770		return u.OfType
1771	} else if !param.IsOmitted(u.OfWait) {
1772		return u.OfWait
1773	}
1774	return nil
1775}
1776
1777// Returns a pointer to the underlying variant's property, if present.
1778func (u ResponseComputerToolCallActionUnionParam) GetButton() *string {
1779	if vt := u.OfClick; vt != nil {
1780		return &vt.Button
1781	}
1782	return nil
1783}
1784
1785// Returns a pointer to the underlying variant's property, if present.
1786func (u ResponseComputerToolCallActionUnionParam) GetPath() []ResponseComputerToolCallActionDragPathParam {
1787	if vt := u.OfDrag; vt != nil {
1788		return vt.Path
1789	}
1790	return nil
1791}
1792
1793// Returns a pointer to the underlying variant's property, if present.
1794func (u ResponseComputerToolCallActionUnionParam) GetKeys() []string {
1795	if vt := u.OfKeypress; vt != nil {
1796		return vt.Keys
1797	}
1798	return nil
1799}
1800
1801// Returns a pointer to the underlying variant's property, if present.
1802func (u ResponseComputerToolCallActionUnionParam) GetScrollX() *int64 {
1803	if vt := u.OfScroll; vt != nil {
1804		return &vt.ScrollX
1805	}
1806	return nil
1807}
1808
1809// Returns a pointer to the underlying variant's property, if present.
1810func (u ResponseComputerToolCallActionUnionParam) GetScrollY() *int64 {
1811	if vt := u.OfScroll; vt != nil {
1812		return &vt.ScrollY
1813	}
1814	return nil
1815}
1816
1817// Returns a pointer to the underlying variant's property, if present.
1818func (u ResponseComputerToolCallActionUnionParam) GetText() *string {
1819	if vt := u.OfType; vt != nil {
1820		return &vt.Text
1821	}
1822	return nil
1823}
1824
1825// Returns a pointer to the underlying variant's property, if present.
1826func (u ResponseComputerToolCallActionUnionParam) GetType() *string {
1827	if vt := u.OfClick; vt != nil {
1828		return (*string)(&vt.Type)
1829	} else if vt := u.OfDoubleClick; vt != nil {
1830		return (*string)(&vt.Type)
1831	} else if vt := u.OfDrag; vt != nil {
1832		return (*string)(&vt.Type)
1833	} else if vt := u.OfKeypress; vt != nil {
1834		return (*string)(&vt.Type)
1835	} else if vt := u.OfMove; vt != nil {
1836		return (*string)(&vt.Type)
1837	} else if vt := u.OfScreenshot; vt != nil {
1838		return (*string)(&vt.Type)
1839	} else if vt := u.OfScroll; vt != nil {
1840		return (*string)(&vt.Type)
1841	} else if vt := u.OfType; vt != nil {
1842		return (*string)(&vt.Type)
1843	} else if vt := u.OfWait; vt != nil {
1844		return (*string)(&vt.Type)
1845	}
1846	return nil
1847}
1848
1849// Returns a pointer to the underlying variant's property, if present.
1850func (u ResponseComputerToolCallActionUnionParam) GetX() *int64 {
1851	if vt := u.OfClick; vt != nil {
1852		return (*int64)(&vt.X)
1853	} else if vt := u.OfDoubleClick; vt != nil {
1854		return (*int64)(&vt.X)
1855	} else if vt := u.OfMove; vt != nil {
1856		return (*int64)(&vt.X)
1857	} else if vt := u.OfScroll; vt != nil {
1858		return (*int64)(&vt.X)
1859	}
1860	return nil
1861}
1862
1863// Returns a pointer to the underlying variant's property, if present.
1864func (u ResponseComputerToolCallActionUnionParam) GetY() *int64 {
1865	if vt := u.OfClick; vt != nil {
1866		return (*int64)(&vt.Y)
1867	} else if vt := u.OfDoubleClick; vt != nil {
1868		return (*int64)(&vt.Y)
1869	} else if vt := u.OfMove; vt != nil {
1870		return (*int64)(&vt.Y)
1871	} else if vt := u.OfScroll; vt != nil {
1872		return (*int64)(&vt.Y)
1873	}
1874	return nil
1875}
1876
1877func init() {
1878	apijson.RegisterUnion[ResponseComputerToolCallActionUnionParam](
1879		"type",
1880		apijson.UnionVariant{
1881			TypeFilter:         gjson.JSON,
1882			Type:               reflect.TypeOf(ResponseComputerToolCallActionClickParam{}),
1883			DiscriminatorValue: "click",
1884		},
1885		apijson.UnionVariant{
1886			TypeFilter:         gjson.JSON,
1887			Type:               reflect.TypeOf(ResponseComputerToolCallActionDoubleClickParam{}),
1888			DiscriminatorValue: "double_click",
1889		},
1890		apijson.UnionVariant{
1891			TypeFilter:         gjson.JSON,
1892			Type:               reflect.TypeOf(ResponseComputerToolCallActionDragParam{}),
1893			DiscriminatorValue: "drag",
1894		},
1895		apijson.UnionVariant{
1896			TypeFilter:         gjson.JSON,
1897			Type:               reflect.TypeOf(ResponseComputerToolCallActionKeypressParam{}),
1898			DiscriminatorValue: "keypress",
1899		},
1900		apijson.UnionVariant{
1901			TypeFilter:         gjson.JSON,
1902			Type:               reflect.TypeOf(ResponseComputerToolCallActionMoveParam{}),
1903			DiscriminatorValue: "move",
1904		},
1905		apijson.UnionVariant{
1906			TypeFilter:         gjson.JSON,
1907			Type:               reflect.TypeOf(ResponseComputerToolCallActionScreenshotParam{}),
1908			DiscriminatorValue: "screenshot",
1909		},
1910		apijson.UnionVariant{
1911			TypeFilter:         gjson.JSON,
1912			Type:               reflect.TypeOf(ResponseComputerToolCallActionScrollParam{}),
1913			DiscriminatorValue: "scroll",
1914		},
1915		apijson.UnionVariant{
1916			TypeFilter:         gjson.JSON,
1917			Type:               reflect.TypeOf(ResponseComputerToolCallActionTypeParam{}),
1918			DiscriminatorValue: "type",
1919		},
1920		apijson.UnionVariant{
1921			TypeFilter:         gjson.JSON,
1922			Type:               reflect.TypeOf(ResponseComputerToolCallActionWaitParam{}),
1923			DiscriminatorValue: "wait",
1924		},
1925	)
1926}
1927
1928// A click action.
1929//
1930// The properties Button, Type, X, Y are required.
1931type ResponseComputerToolCallActionClickParam struct {
1932	// Indicates which mouse button was pressed during the click. One of `left`,
1933	// `right`, `wheel`, `back`, or `forward`.
1934	//
1935	// Any of "left", "right", "wheel", "back", "forward".
1936	Button string `json:"button,omitzero,required"`
1937	// The x-coordinate where the click occurred.
1938	X int64 `json:"x,required"`
1939	// The y-coordinate where the click occurred.
1940	Y int64 `json:"y,required"`
1941	// Specifies the event type. For a click action, this property is always set to
1942	// `click`.
1943	//
1944	// This field can be elided, and will marshal its zero value as "click".
1945	Type constant.Click `json:"type,required"`
1946	paramObj
1947}
1948
1949// IsPresent returns true if the field's value is not omitted and not the JSON
1950// "null". To check if this field is omitted, use [param.IsOmitted].
1951func (f ResponseComputerToolCallActionClickParam) IsPresent() bool {
1952	return !param.IsOmitted(f) && !f.IsNull()
1953}
1954func (r ResponseComputerToolCallActionClickParam) MarshalJSON() (data []byte, err error) {
1955	type shadow ResponseComputerToolCallActionClickParam
1956	return param.MarshalObject(r, (*shadow)(&r))
1957}
1958
1959func init() {
1960	apijson.RegisterFieldValidator[ResponseComputerToolCallActionClickParam](
1961		"Button", false, "left", "right", "wheel", "back", "forward",
1962	)
1963}
1964
1965// A double click action.
1966//
1967// The properties Type, X, Y are required.
1968type ResponseComputerToolCallActionDoubleClickParam struct {
1969	// The x-coordinate where the double click occurred.
1970	X int64 `json:"x,required"`
1971	// The y-coordinate where the double click occurred.
1972	Y int64 `json:"y,required"`
1973	// Specifies the event type. For a double click action, this property is always set
1974	// to `double_click`.
1975	//
1976	// This field can be elided, and will marshal its zero value as "double_click".
1977	Type constant.DoubleClick `json:"type,required"`
1978	paramObj
1979}
1980
1981// IsPresent returns true if the field's value is not omitted and not the JSON
1982// "null". To check if this field is omitted, use [param.IsOmitted].
1983func (f ResponseComputerToolCallActionDoubleClickParam) IsPresent() bool {
1984	return !param.IsOmitted(f) && !f.IsNull()
1985}
1986func (r ResponseComputerToolCallActionDoubleClickParam) MarshalJSON() (data []byte, err error) {
1987	type shadow ResponseComputerToolCallActionDoubleClickParam
1988	return param.MarshalObject(r, (*shadow)(&r))
1989}
1990
1991// A drag action.
1992//
1993// The properties Path, Type are required.
1994type ResponseComputerToolCallActionDragParam struct {
1995	// An array of coordinates representing the path of the drag action. Coordinates
1996	// will appear as an array of objects, eg
1997	//
1998	// ```
1999	// [
2000	//
2001	//	{ x: 100, y: 200 },
2002	//	{ x: 200, y: 300 }
2003	//
2004	// ]
2005	// ```
2006	Path []ResponseComputerToolCallActionDragPathParam `json:"path,omitzero,required"`
2007	// Specifies the event type. For a drag action, this property is always set to
2008	// `drag`.
2009	//
2010	// This field can be elided, and will marshal its zero value as "drag".
2011	Type constant.Drag `json:"type,required"`
2012	paramObj
2013}
2014
2015// IsPresent returns true if the field's value is not omitted and not the JSON
2016// "null". To check if this field is omitted, use [param.IsOmitted].
2017func (f ResponseComputerToolCallActionDragParam) IsPresent() bool {
2018	return !param.IsOmitted(f) && !f.IsNull()
2019}
2020func (r ResponseComputerToolCallActionDragParam) MarshalJSON() (data []byte, err error) {
2021	type shadow ResponseComputerToolCallActionDragParam
2022	return param.MarshalObject(r, (*shadow)(&r))
2023}
2024
2025// A series of x/y coordinate pairs in the drag path.
2026//
2027// The properties X, Y are required.
2028type ResponseComputerToolCallActionDragPathParam struct {
2029	// The x-coordinate.
2030	X int64 `json:"x,required"`
2031	// The y-coordinate.
2032	Y int64 `json:"y,required"`
2033	paramObj
2034}
2035
2036// IsPresent returns true if the field's value is not omitted and not the JSON
2037// "null". To check if this field is omitted, use [param.IsOmitted].
2038func (f ResponseComputerToolCallActionDragPathParam) IsPresent() bool {
2039	return !param.IsOmitted(f) && !f.IsNull()
2040}
2041func (r ResponseComputerToolCallActionDragPathParam) MarshalJSON() (data []byte, err error) {
2042	type shadow ResponseComputerToolCallActionDragPathParam
2043	return param.MarshalObject(r, (*shadow)(&r))
2044}
2045
2046// A collection of keypresses the model would like to perform.
2047//
2048// The properties Keys, Type are required.
2049type ResponseComputerToolCallActionKeypressParam struct {
2050	// The combination of keys the model is requesting to be pressed. This is an array
2051	// of strings, each representing a key.
2052	Keys []string `json:"keys,omitzero,required"`
2053	// Specifies the event type. For a keypress action, this property is always set to
2054	// `keypress`.
2055	//
2056	// This field can be elided, and will marshal its zero value as "keypress".
2057	Type constant.Keypress `json:"type,required"`
2058	paramObj
2059}
2060
2061// IsPresent returns true if the field's value is not omitted and not the JSON
2062// "null". To check if this field is omitted, use [param.IsOmitted].
2063func (f ResponseComputerToolCallActionKeypressParam) IsPresent() bool {
2064	return !param.IsOmitted(f) && !f.IsNull()
2065}
2066func (r ResponseComputerToolCallActionKeypressParam) MarshalJSON() (data []byte, err error) {
2067	type shadow ResponseComputerToolCallActionKeypressParam
2068	return param.MarshalObject(r, (*shadow)(&r))
2069}
2070
2071// A mouse move action.
2072//
2073// The properties Type, X, Y are required.
2074type ResponseComputerToolCallActionMoveParam struct {
2075	// The x-coordinate to move to.
2076	X int64 `json:"x,required"`
2077	// The y-coordinate to move to.
2078	Y int64 `json:"y,required"`
2079	// Specifies the event type. For a move action, this property is always set to
2080	// `move`.
2081	//
2082	// This field can be elided, and will marshal its zero value as "move".
2083	Type constant.Move `json:"type,required"`
2084	paramObj
2085}
2086
2087// IsPresent returns true if the field's value is not omitted and not the JSON
2088// "null". To check if this field is omitted, use [param.IsOmitted].
2089func (f ResponseComputerToolCallActionMoveParam) IsPresent() bool {
2090	return !param.IsOmitted(f) && !f.IsNull()
2091}
2092func (r ResponseComputerToolCallActionMoveParam) MarshalJSON() (data []byte, err error) {
2093	type shadow ResponseComputerToolCallActionMoveParam
2094	return param.MarshalObject(r, (*shadow)(&r))
2095}
2096
2097// A screenshot action.
2098//
2099// The property Type is required.
2100type ResponseComputerToolCallActionScreenshotParam struct {
2101	// Specifies the event type. For a screenshot action, this property is always set
2102	// to `screenshot`.
2103	//
2104	// This field can be elided, and will marshal its zero value as "screenshot".
2105	Type constant.Screenshot `json:"type,required"`
2106	paramObj
2107}
2108
2109// IsPresent returns true if the field's value is not omitted and not the JSON
2110// "null". To check if this field is omitted, use [param.IsOmitted].
2111func (f ResponseComputerToolCallActionScreenshotParam) IsPresent() bool {
2112	return !param.IsOmitted(f) && !f.IsNull()
2113}
2114func (r ResponseComputerToolCallActionScreenshotParam) MarshalJSON() (data []byte, err error) {
2115	type shadow ResponseComputerToolCallActionScreenshotParam
2116	return param.MarshalObject(r, (*shadow)(&r))
2117}
2118
2119// A scroll action.
2120//
2121// The properties ScrollX, ScrollY, Type, X, Y are required.
2122type ResponseComputerToolCallActionScrollParam struct {
2123	// The horizontal scroll distance.
2124	ScrollX int64 `json:"scroll_x,required"`
2125	// The vertical scroll distance.
2126	ScrollY int64 `json:"scroll_y,required"`
2127	// The x-coordinate where the scroll occurred.
2128	X int64 `json:"x,required"`
2129	// The y-coordinate where the scroll occurred.
2130	Y int64 `json:"y,required"`
2131	// Specifies the event type. For a scroll action, this property is always set to
2132	// `scroll`.
2133	//
2134	// This field can be elided, and will marshal its zero value as "scroll".
2135	Type constant.Scroll `json:"type,required"`
2136	paramObj
2137}
2138
2139// IsPresent returns true if the field's value is not omitted and not the JSON
2140// "null". To check if this field is omitted, use [param.IsOmitted].
2141func (f ResponseComputerToolCallActionScrollParam) IsPresent() bool {
2142	return !param.IsOmitted(f) && !f.IsNull()
2143}
2144func (r ResponseComputerToolCallActionScrollParam) MarshalJSON() (data []byte, err error) {
2145	type shadow ResponseComputerToolCallActionScrollParam
2146	return param.MarshalObject(r, (*shadow)(&r))
2147}
2148
2149// An action to type in text.
2150//
2151// The properties Text, Type are required.
2152type ResponseComputerToolCallActionTypeParam struct {
2153	// The text to type.
2154	Text string `json:"text,required"`
2155	// Specifies the event type. For a type action, this property is always set to
2156	// `type`.
2157	//
2158	// This field can be elided, and will marshal its zero value as "type".
2159	Type constant.Type `json:"type,required"`
2160	paramObj
2161}
2162
2163// IsPresent returns true if the field's value is not omitted and not the JSON
2164// "null". To check if this field is omitted, use [param.IsOmitted].
2165func (f ResponseComputerToolCallActionTypeParam) IsPresent() bool {
2166	return !param.IsOmitted(f) && !f.IsNull()
2167}
2168func (r ResponseComputerToolCallActionTypeParam) MarshalJSON() (data []byte, err error) {
2169	type shadow ResponseComputerToolCallActionTypeParam
2170	return param.MarshalObject(r, (*shadow)(&r))
2171}
2172
2173// A wait action.
2174//
2175// The property Type is required.
2176type ResponseComputerToolCallActionWaitParam struct {
2177	// Specifies the event type. For a wait action, this property is always set to
2178	// `wait`.
2179	//
2180	// This field can be elided, and will marshal its zero value as "wait".
2181	Type constant.Wait `json:"type,required"`
2182	paramObj
2183}
2184
2185// IsPresent returns true if the field's value is not omitted and not the JSON
2186// "null". To check if this field is omitted, use [param.IsOmitted].
2187func (f ResponseComputerToolCallActionWaitParam) IsPresent() bool {
2188	return !param.IsOmitted(f) && !f.IsNull()
2189}
2190func (r ResponseComputerToolCallActionWaitParam) MarshalJSON() (data []byte, err error) {
2191	type shadow ResponseComputerToolCallActionWaitParam
2192	return param.MarshalObject(r, (*shadow)(&r))
2193}
2194
2195// A pending safety check for the computer call.
2196//
2197// The properties ID, Code, Message are required.
2198type ResponseComputerToolCallPendingSafetyCheckParam struct {
2199	// The ID of the pending safety check.
2200	ID string `json:"id,required"`
2201	// The type of the pending safety check.
2202	Code string `json:"code,required"`
2203	// Details about the pending safety check.
2204	Message string `json:"message,required"`
2205	paramObj
2206}
2207
2208// IsPresent returns true if the field's value is not omitted and not the JSON
2209// "null". To check if this field is omitted, use [param.IsOmitted].
2210func (f ResponseComputerToolCallPendingSafetyCheckParam) IsPresent() bool {
2211	return !param.IsOmitted(f) && !f.IsNull()
2212}
2213func (r ResponseComputerToolCallPendingSafetyCheckParam) MarshalJSON() (data []byte, err error) {
2214	type shadow ResponseComputerToolCallPendingSafetyCheckParam
2215	return param.MarshalObject(r, (*shadow)(&r))
2216}
2217
2218type ResponseComputerToolCallOutputItem struct {
2219	// The unique ID of the computer call tool output.
2220	ID string `json:"id,required"`
2221	// The ID of the computer tool call that produced the output.
2222	CallID string `json:"call_id,required"`
2223	// A computer screenshot image used with the computer use tool.
2224	Output ResponseComputerToolCallOutputScreenshot `json:"output,required"`
2225	// The type of the computer tool call output. Always `computer_call_output`.
2226	Type constant.ComputerCallOutput `json:"type,required"`
2227	// The safety checks reported by the API that have been acknowledged by the
2228	// developer.
2229	AcknowledgedSafetyChecks []ResponseComputerToolCallOutputItemAcknowledgedSafetyCheck `json:"acknowledged_safety_checks"`
2230	// The status of the message input. One of `in_progress`, `completed`, or
2231	// `incomplete`. Populated when input items are returned via API.
2232	//
2233	// Any of "in_progress", "completed", "incomplete".
2234	Status ResponseComputerToolCallOutputItemStatus `json:"status"`
2235	// Metadata for the response, check the presence of optional fields with the
2236	// [resp.Field.IsPresent] method.
2237	JSON struct {
2238		ID                       resp.Field
2239		CallID                   resp.Field
2240		Output                   resp.Field
2241		Type                     resp.Field
2242		AcknowledgedSafetyChecks resp.Field
2243		Status                   resp.Field
2244		ExtraFields              map[string]resp.Field
2245		raw                      string
2246	} `json:"-"`
2247}
2248
2249// Returns the unmodified JSON received from the API
2250func (r ResponseComputerToolCallOutputItem) RawJSON() string { return r.JSON.raw }
2251func (r *ResponseComputerToolCallOutputItem) UnmarshalJSON(data []byte) error {
2252	return apijson.UnmarshalRoot(data, r)
2253}
2254
2255// A pending safety check for the computer call.
2256type ResponseComputerToolCallOutputItemAcknowledgedSafetyCheck struct {
2257	// The ID of the pending safety check.
2258	ID string `json:"id,required"`
2259	// The type of the pending safety check.
2260	Code string `json:"code,required"`
2261	// Details about the pending safety check.
2262	Message string `json:"message,required"`
2263	// Metadata for the response, check the presence of optional fields with the
2264	// [resp.Field.IsPresent] method.
2265	JSON struct {
2266		ID          resp.Field
2267		Code        resp.Field
2268		Message     resp.Field
2269		ExtraFields map[string]resp.Field
2270		raw         string
2271	} `json:"-"`
2272}
2273
2274// Returns the unmodified JSON received from the API
2275func (r ResponseComputerToolCallOutputItemAcknowledgedSafetyCheck) RawJSON() string {
2276	return r.JSON.raw
2277}
2278func (r *ResponseComputerToolCallOutputItemAcknowledgedSafetyCheck) UnmarshalJSON(data []byte) error {
2279	return apijson.UnmarshalRoot(data, r)
2280}
2281
2282// The status of the message input. One of `in_progress`, `completed`, or
2283// `incomplete`. Populated when input items are returned via API.
2284type ResponseComputerToolCallOutputItemStatus string
2285
2286const (
2287	ResponseComputerToolCallOutputItemStatusInProgress ResponseComputerToolCallOutputItemStatus = "in_progress"
2288	ResponseComputerToolCallOutputItemStatusCompleted  ResponseComputerToolCallOutputItemStatus = "completed"
2289	ResponseComputerToolCallOutputItemStatusIncomplete ResponseComputerToolCallOutputItemStatus = "incomplete"
2290)
2291
2292// A computer screenshot image used with the computer use tool.
2293type ResponseComputerToolCallOutputScreenshot struct {
2294	// Specifies the event type. For a computer screenshot, this property is always set
2295	// to `computer_screenshot`.
2296	Type constant.ComputerScreenshot `json:"type,required"`
2297	// The identifier of an uploaded file that contains the screenshot.
2298	FileID string `json:"file_id"`
2299	// The URL of the screenshot image.
2300	ImageURL string `json:"image_url"`
2301	// Metadata for the response, check the presence of optional fields with the
2302	// [resp.Field.IsPresent] method.
2303	JSON struct {
2304		Type        resp.Field
2305		FileID      resp.Field
2306		ImageURL    resp.Field
2307		ExtraFields map[string]resp.Field
2308		raw         string
2309	} `json:"-"`
2310}
2311
2312// Returns the unmodified JSON received from the API
2313func (r ResponseComputerToolCallOutputScreenshot) RawJSON() string { return r.JSON.raw }
2314func (r *ResponseComputerToolCallOutputScreenshot) UnmarshalJSON(data []byte) error {
2315	return apijson.UnmarshalRoot(data, r)
2316}
2317
2318// ToParam converts this ResponseComputerToolCallOutputScreenshot to a
2319// ResponseComputerToolCallOutputScreenshotParam.
2320//
2321// Warning: the fields of the param type will not be present. ToParam should only
2322// be used at the last possible moment before sending a request. Test for this with
2323// ResponseComputerToolCallOutputScreenshotParam.IsOverridden()
2324func (r ResponseComputerToolCallOutputScreenshot) ToParam() ResponseComputerToolCallOutputScreenshotParam {
2325	return param.OverrideObj[ResponseComputerToolCallOutputScreenshotParam](r.RawJSON())
2326}
2327
2328// A computer screenshot image used with the computer use tool.
2329//
2330// The property Type is required.
2331type ResponseComputerToolCallOutputScreenshotParam struct {
2332	// The identifier of an uploaded file that contains the screenshot.
2333	FileID param.Opt[string] `json:"file_id,omitzero"`
2334	// The URL of the screenshot image.
2335	ImageURL param.Opt[string] `json:"image_url,omitzero"`
2336	// Specifies the event type. For a computer screenshot, this property is always set
2337	// to `computer_screenshot`.
2338	//
2339	// This field can be elided, and will marshal its zero value as
2340	// "computer_screenshot".
2341	Type constant.ComputerScreenshot `json:"type,required"`
2342	paramObj
2343}
2344
2345// IsPresent returns true if the field's value is not omitted and not the JSON
2346// "null". To check if this field is omitted, use [param.IsOmitted].
2347func (f ResponseComputerToolCallOutputScreenshotParam) IsPresent() bool {
2348	return !param.IsOmitted(f) && !f.IsNull()
2349}
2350func (r ResponseComputerToolCallOutputScreenshotParam) MarshalJSON() (data []byte, err error) {
2351	type shadow ResponseComputerToolCallOutputScreenshotParam
2352	return param.MarshalObject(r, (*shadow)(&r))
2353}
2354
2355// Emitted when a new content part is added.
2356type ResponseContentPartAddedEvent struct {
2357	// The index of the content part that was added.
2358	ContentIndex int64 `json:"content_index,required"`
2359	// The ID of the output item that the content part was added to.
2360	ItemID string `json:"item_id,required"`
2361	// The index of the output item that the content part was added to.
2362	OutputIndex int64 `json:"output_index,required"`
2363	// The content part that was added.
2364	Part ResponseContentPartAddedEventPartUnion `json:"part,required"`
2365	// The type of the event. Always `response.content_part.added`.
2366	Type constant.ResponseContentPartAdded `json:"type,required"`
2367	// Metadata for the response, check the presence of optional fields with the
2368	// [resp.Field.IsPresent] method.
2369	JSON struct {
2370		ContentIndex resp.Field
2371		ItemID       resp.Field
2372		OutputIndex  resp.Field
2373		Part         resp.Field
2374		Type         resp.Field
2375		ExtraFields  map[string]resp.Field
2376		raw          string
2377	} `json:"-"`
2378}
2379
2380// Returns the unmodified JSON received from the API
2381func (r ResponseContentPartAddedEvent) RawJSON() string { return r.JSON.raw }
2382func (r *ResponseContentPartAddedEvent) UnmarshalJSON(data []byte) error {
2383	return apijson.UnmarshalRoot(data, r)
2384}
2385
2386// ResponseContentPartAddedEventPartUnion contains all possible properties and
2387// values from [ResponseOutputText], [ResponseOutputRefusal].
2388//
2389// Use the [ResponseContentPartAddedEventPartUnion.AsAny] method to switch on the
2390// variant.
2391//
2392// Use the methods beginning with 'As' to cast the union to one of its variants.
2393type ResponseContentPartAddedEventPartUnion struct {
2394	// This field is from variant [ResponseOutputText].
2395	Annotations []ResponseOutputTextAnnotationUnion `json:"annotations"`
2396	// This field is from variant [ResponseOutputText].
2397	Text string `json:"text"`
2398	// Any of "output_text", "refusal".
2399	Type string `json:"type"`
2400	// This field is from variant [ResponseOutputRefusal].
2401	Refusal string `json:"refusal"`
2402	JSON    struct {
2403		Annotations resp.Field
2404		Text        resp.Field
2405		Type        resp.Field
2406		Refusal     resp.Field
2407		raw         string
2408	} `json:"-"`
2409}
2410
2411// Use the following switch statement to find the correct variant
2412//
2413//	switch variant := ResponseContentPartAddedEventPartUnion.AsAny().(type) {
2414//	case ResponseOutputText:
2415//	case ResponseOutputRefusal:
2416//	default:
2417//	  fmt.Errorf("no variant present")
2418//	}
2419func (u ResponseContentPartAddedEventPartUnion) AsAny() any {
2420	switch u.Type {
2421	case "output_text":
2422		return u.AsOutputText()
2423	case "refusal":
2424		return u.AsRefusal()
2425	}
2426	return nil
2427}
2428
2429func (u ResponseContentPartAddedEventPartUnion) AsOutputText() (v ResponseOutputText) {
2430	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
2431	return
2432}
2433
2434func (u ResponseContentPartAddedEventPartUnion) AsRefusal() (v ResponseOutputRefusal) {
2435	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
2436	return
2437}
2438
2439// Returns the unmodified JSON received from the API
2440func (u ResponseContentPartAddedEventPartUnion) RawJSON() string { return u.JSON.raw }
2441
2442func (r *ResponseContentPartAddedEventPartUnion) UnmarshalJSON(data []byte) error {
2443	return apijson.UnmarshalRoot(data, r)
2444}
2445
2446// Emitted when a content part is done.
2447type ResponseContentPartDoneEvent struct {
2448	// The index of the content part that is done.
2449	ContentIndex int64 `json:"content_index,required"`
2450	// The ID of the output item that the content part was added to.
2451	ItemID string `json:"item_id,required"`
2452	// The index of the output item that the content part was added to.
2453	OutputIndex int64 `json:"output_index,required"`
2454	// The content part that is done.
2455	Part ResponseContentPartDoneEventPartUnion `json:"part,required"`
2456	// The type of the event. Always `response.content_part.done`.
2457	Type constant.ResponseContentPartDone `json:"type,required"`
2458	// Metadata for the response, check the presence of optional fields with the
2459	// [resp.Field.IsPresent] method.
2460	JSON struct {
2461		ContentIndex resp.Field
2462		ItemID       resp.Field
2463		OutputIndex  resp.Field
2464		Part         resp.Field
2465		Type         resp.Field
2466		ExtraFields  map[string]resp.Field
2467		raw          string
2468	} `json:"-"`
2469}
2470
2471// Returns the unmodified JSON received from the API
2472func (r ResponseContentPartDoneEvent) RawJSON() string { return r.JSON.raw }
2473func (r *ResponseContentPartDoneEvent) UnmarshalJSON(data []byte) error {
2474	return apijson.UnmarshalRoot(data, r)
2475}
2476
2477// ResponseContentPartDoneEventPartUnion contains all possible properties and
2478// values from [ResponseOutputText], [ResponseOutputRefusal].
2479//
2480// Use the [ResponseContentPartDoneEventPartUnion.AsAny] method to switch on the
2481// variant.
2482//
2483// Use the methods beginning with 'As' to cast the union to one of its variants.
2484type ResponseContentPartDoneEventPartUnion struct {
2485	// This field is from variant [ResponseOutputText].
2486	Annotations []ResponseOutputTextAnnotationUnion `json:"annotations"`
2487	// This field is from variant [ResponseOutputText].
2488	Text string `json:"text"`
2489	// Any of "output_text", "refusal".
2490	Type string `json:"type"`
2491	// This field is from variant [ResponseOutputRefusal].
2492	Refusal string `json:"refusal"`
2493	JSON    struct {
2494		Annotations resp.Field
2495		Text        resp.Field
2496		Type        resp.Field
2497		Refusal     resp.Field
2498		raw         string
2499	} `json:"-"`
2500}
2501
2502// Use the following switch statement to find the correct variant
2503//
2504//	switch variant := ResponseContentPartDoneEventPartUnion.AsAny().(type) {
2505//	case ResponseOutputText:
2506//	case ResponseOutputRefusal:
2507//	default:
2508//	  fmt.Errorf("no variant present")
2509//	}
2510func (u ResponseContentPartDoneEventPartUnion) AsAny() any {
2511	switch u.Type {
2512	case "output_text":
2513		return u.AsOutputText()
2514	case "refusal":
2515		return u.AsRefusal()
2516	}
2517	return nil
2518}
2519
2520func (u ResponseContentPartDoneEventPartUnion) AsOutputText() (v ResponseOutputText) {
2521	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
2522	return
2523}
2524
2525func (u ResponseContentPartDoneEventPartUnion) AsRefusal() (v ResponseOutputRefusal) {
2526	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
2527	return
2528}
2529
2530// Returns the unmodified JSON received from the API
2531func (u ResponseContentPartDoneEventPartUnion) RawJSON() string { return u.JSON.raw }
2532
2533func (r *ResponseContentPartDoneEventPartUnion) UnmarshalJSON(data []byte) error {
2534	return apijson.UnmarshalRoot(data, r)
2535}
2536
2537// An event that is emitted when a response is created.
2538type ResponseCreatedEvent struct {
2539	// The response that was created.
2540	Response Response `json:"response,required"`
2541	// The type of the event. Always `response.created`.
2542	Type constant.ResponseCreated `json:"type,required"`
2543	// Metadata for the response, check the presence of optional fields with the
2544	// [resp.Field.IsPresent] method.
2545	JSON struct {
2546		Response    resp.Field
2547		Type        resp.Field
2548		ExtraFields map[string]resp.Field
2549		raw         string
2550	} `json:"-"`
2551}
2552
2553// Returns the unmodified JSON received from the API
2554func (r ResponseCreatedEvent) RawJSON() string { return r.JSON.raw }
2555func (r *ResponseCreatedEvent) UnmarshalJSON(data []byte) error {
2556	return apijson.UnmarshalRoot(data, r)
2557}
2558
2559// An error object returned when the model fails to generate a Response.
2560type ResponseError struct {
2561	// The error code for the response.
2562	//
2563	// Any of "server_error", "rate_limit_exceeded", "invalid_prompt",
2564	// "vector_store_timeout", "invalid_image", "invalid_image_format",
2565	// "invalid_base64_image", "invalid_image_url", "image_too_large",
2566	// "image_too_small", "image_parse_error", "image_content_policy_violation",
2567	// "invalid_image_mode", "image_file_too_large", "unsupported_image_media_type",
2568	// "empty_image_file", "failed_to_download_image", "image_file_not_found".
2569	Code ResponseErrorCode `json:"code,required"`
2570	// A human-readable description of the error.
2571	Message string `json:"message,required"`
2572	// Metadata for the response, check the presence of optional fields with the
2573	// [resp.Field.IsPresent] method.
2574	JSON struct {
2575		Code        resp.Field
2576		Message     resp.Field
2577		ExtraFields map[string]resp.Field
2578		raw         string
2579	} `json:"-"`
2580}
2581
2582// Returns the unmodified JSON received from the API
2583func (r ResponseError) RawJSON() string { return r.JSON.raw }
2584func (r *ResponseError) UnmarshalJSON(data []byte) error {
2585	return apijson.UnmarshalRoot(data, r)
2586}
2587
2588// The error code for the response.
2589type ResponseErrorCode string
2590
2591const (
2592	ResponseErrorCodeServerError                 ResponseErrorCode = "server_error"
2593	ResponseErrorCodeRateLimitExceeded           ResponseErrorCode = "rate_limit_exceeded"
2594	ResponseErrorCodeInvalidPrompt               ResponseErrorCode = "invalid_prompt"
2595	ResponseErrorCodeVectorStoreTimeout          ResponseErrorCode = "vector_store_timeout"
2596	ResponseErrorCodeInvalidImage                ResponseErrorCode = "invalid_image"
2597	ResponseErrorCodeInvalidImageFormat          ResponseErrorCode = "invalid_image_format"
2598	ResponseErrorCodeInvalidBase64Image          ResponseErrorCode = "invalid_base64_image"
2599	ResponseErrorCodeInvalidImageURL             ResponseErrorCode = "invalid_image_url"
2600	ResponseErrorCodeImageTooLarge               ResponseErrorCode = "image_too_large"
2601	ResponseErrorCodeImageTooSmall               ResponseErrorCode = "image_too_small"
2602	ResponseErrorCodeImageParseError             ResponseErrorCode = "image_parse_error"
2603	ResponseErrorCodeImageContentPolicyViolation ResponseErrorCode = "image_content_policy_violation"
2604	ResponseErrorCodeInvalidImageMode            ResponseErrorCode = "invalid_image_mode"
2605	ResponseErrorCodeImageFileTooLarge           ResponseErrorCode = "image_file_too_large"
2606	ResponseErrorCodeUnsupportedImageMediaType   ResponseErrorCode = "unsupported_image_media_type"
2607	ResponseErrorCodeEmptyImageFile              ResponseErrorCode = "empty_image_file"
2608	ResponseErrorCodeFailedToDownloadImage       ResponseErrorCode = "failed_to_download_image"
2609	ResponseErrorCodeImageFileNotFound           ResponseErrorCode = "image_file_not_found"
2610)
2611
2612// Emitted when an error occurs.
2613type ResponseErrorEvent struct {
2614	// The error code.
2615	Code string `json:"code,required"`
2616	// The error message.
2617	Message string `json:"message,required"`
2618	// The error parameter.
2619	Param string `json:"param,required"`
2620	// The type of the event. Always `error`.
2621	Type constant.Error `json:"type,required"`
2622	// Metadata for the response, check the presence of optional fields with the
2623	// [resp.Field.IsPresent] method.
2624	JSON struct {
2625		Code        resp.Field
2626		Message     resp.Field
2627		Param       resp.Field
2628		Type        resp.Field
2629		ExtraFields map[string]resp.Field
2630		raw         string
2631	} `json:"-"`
2632}
2633
2634// Returns the unmodified JSON received from the API
2635func (r ResponseErrorEvent) RawJSON() string { return r.JSON.raw }
2636func (r *ResponseErrorEvent) UnmarshalJSON(data []byte) error {
2637	return apijson.UnmarshalRoot(data, r)
2638}
2639
2640// An event that is emitted when a response fails.
2641type ResponseFailedEvent struct {
2642	// The response that failed.
2643	Response Response `json:"response,required"`
2644	// The type of the event. Always `response.failed`.
2645	Type constant.ResponseFailed `json:"type,required"`
2646	// Metadata for the response, check the presence of optional fields with the
2647	// [resp.Field.IsPresent] method.
2648	JSON struct {
2649		Response    resp.Field
2650		Type        resp.Field
2651		ExtraFields map[string]resp.Field
2652		raw         string
2653	} `json:"-"`
2654}
2655
2656// Returns the unmodified JSON received from the API
2657func (r ResponseFailedEvent) RawJSON() string { return r.JSON.raw }
2658func (r *ResponseFailedEvent) UnmarshalJSON(data []byte) error {
2659	return apijson.UnmarshalRoot(data, r)
2660}
2661
2662// Emitted when a file search call is completed (results found).
2663type ResponseFileSearchCallCompletedEvent struct {
2664	// The ID of the output item that the file search call is initiated.
2665	ItemID string `json:"item_id,required"`
2666	// The index of the output item that the file search call is initiated.
2667	OutputIndex int64 `json:"output_index,required"`
2668	// The type of the event. Always `response.file_search_call.completed`.
2669	Type constant.ResponseFileSearchCallCompleted `json:"type,required"`
2670	// Metadata for the response, check the presence of optional fields with the
2671	// [resp.Field.IsPresent] method.
2672	JSON struct {
2673		ItemID      resp.Field
2674		OutputIndex resp.Field
2675		Type        resp.Field
2676		ExtraFields map[string]resp.Field
2677		raw         string
2678	} `json:"-"`
2679}
2680
2681// Returns the unmodified JSON received from the API
2682func (r ResponseFileSearchCallCompletedEvent) RawJSON() string { return r.JSON.raw }
2683func (r *ResponseFileSearchCallCompletedEvent) UnmarshalJSON(data []byte) error {
2684	return apijson.UnmarshalRoot(data, r)
2685}
2686
2687// Emitted when a file search call is initiated.
2688type ResponseFileSearchCallInProgressEvent struct {
2689	// The ID of the output item that the file search call is initiated.
2690	ItemID string `json:"item_id,required"`
2691	// The index of the output item that the file search call is initiated.
2692	OutputIndex int64 `json:"output_index,required"`
2693	// The type of the event. Always `response.file_search_call.in_progress`.
2694	Type constant.ResponseFileSearchCallInProgress `json:"type,required"`
2695	// Metadata for the response, check the presence of optional fields with the
2696	// [resp.Field.IsPresent] method.
2697	JSON struct {
2698		ItemID      resp.Field
2699		OutputIndex resp.Field
2700		Type        resp.Field
2701		ExtraFields map[string]resp.Field
2702		raw         string
2703	} `json:"-"`
2704}
2705
2706// Returns the unmodified JSON received from the API
2707func (r ResponseFileSearchCallInProgressEvent) RawJSON() string { return r.JSON.raw }
2708func (r *ResponseFileSearchCallInProgressEvent) UnmarshalJSON(data []byte) error {
2709	return apijson.UnmarshalRoot(data, r)
2710}
2711
2712// Emitted when a file search is currently searching.
2713type ResponseFileSearchCallSearchingEvent struct {
2714	// The ID of the output item that the file search call is initiated.
2715	ItemID string `json:"item_id,required"`
2716	// The index of the output item that the file search call is searching.
2717	OutputIndex int64 `json:"output_index,required"`
2718	// The type of the event. Always `response.file_search_call.searching`.
2719	Type constant.ResponseFileSearchCallSearching `json:"type,required"`
2720	// Metadata for the response, check the presence of optional fields with the
2721	// [resp.Field.IsPresent] method.
2722	JSON struct {
2723		ItemID      resp.Field
2724		OutputIndex resp.Field
2725		Type        resp.Field
2726		ExtraFields map[string]resp.Field
2727		raw         string
2728	} `json:"-"`
2729}
2730
2731// Returns the unmodified JSON received from the API
2732func (r ResponseFileSearchCallSearchingEvent) RawJSON() string { return r.JSON.raw }
2733func (r *ResponseFileSearchCallSearchingEvent) UnmarshalJSON(data []byte) error {
2734	return apijson.UnmarshalRoot(data, r)
2735}
2736
2737// The results of a file search tool call. See the
2738// [file search guide](https://platform.openai.com/docs/guides/tools-file-search)
2739// for more information.
2740type ResponseFileSearchToolCall struct {
2741	// The unique ID of the file search tool call.
2742	ID string `json:"id,required"`
2743	// The queries used to search for files.
2744	Queries []string `json:"queries,required"`
2745	// The status of the file search tool call. One of `in_progress`, `searching`,
2746	// `incomplete` or `failed`,
2747	//
2748	// Any of "in_progress", "searching", "completed", "incomplete", "failed".
2749	Status ResponseFileSearchToolCallStatus `json:"status,required"`
2750	// The type of the file search tool call. Always `file_search_call`.
2751	Type constant.FileSearchCall `json:"type,required"`
2752	// The results of the file search tool call.
2753	Results []ResponseFileSearchToolCallResult `json:"results,nullable"`
2754	// Metadata for the response, check the presence of optional fields with the
2755	// [resp.Field.IsPresent] method.
2756	JSON struct {
2757		ID          resp.Field
2758		Queries     resp.Field
2759		Status      resp.Field
2760		Type        resp.Field
2761		Results     resp.Field
2762		ExtraFields map[string]resp.Field
2763		raw         string
2764	} `json:"-"`
2765}
2766
2767// Returns the unmodified JSON received from the API
2768func (r ResponseFileSearchToolCall) RawJSON() string { return r.JSON.raw }
2769func (r *ResponseFileSearchToolCall) UnmarshalJSON(data []byte) error {
2770	return apijson.UnmarshalRoot(data, r)
2771}
2772
2773// ToParam converts this ResponseFileSearchToolCall to a
2774// ResponseFileSearchToolCallParam.
2775//
2776// Warning: the fields of the param type will not be present. ToParam should only
2777// be used at the last possible moment before sending a request. Test for this with
2778// ResponseFileSearchToolCallParam.IsOverridden()
2779func (r ResponseFileSearchToolCall) ToParam() ResponseFileSearchToolCallParam {
2780	return param.OverrideObj[ResponseFileSearchToolCallParam](r.RawJSON())
2781}
2782
2783// The status of the file search tool call. One of `in_progress`, `searching`,
2784// `incomplete` or `failed`,
2785type ResponseFileSearchToolCallStatus string
2786
2787const (
2788	ResponseFileSearchToolCallStatusInProgress ResponseFileSearchToolCallStatus = "in_progress"
2789	ResponseFileSearchToolCallStatusSearching  ResponseFileSearchToolCallStatus = "searching"
2790	ResponseFileSearchToolCallStatusCompleted  ResponseFileSearchToolCallStatus = "completed"
2791	ResponseFileSearchToolCallStatusIncomplete ResponseFileSearchToolCallStatus = "incomplete"
2792	ResponseFileSearchToolCallStatusFailed     ResponseFileSearchToolCallStatus = "failed"
2793)
2794
2795type ResponseFileSearchToolCallResult struct {
2796	// Set of 16 key-value pairs that can be attached to an object. This can be useful
2797	// for storing additional information about the object in a structured format, and
2798	// querying for objects via API or the dashboard. Keys are strings with a maximum
2799	// length of 64 characters. Values are strings with a maximum length of 512
2800	// characters, booleans, or numbers.
2801	Attributes map[string]ResponseFileSearchToolCallResultAttributeUnion `json:"attributes,nullable"`
2802	// The unique ID of the file.
2803	FileID string `json:"file_id"`
2804	// The name of the file.
2805	Filename string `json:"filename"`
2806	// The relevance score of the file - a value between 0 and 1.
2807	Score float64 `json:"score"`
2808	// The text that was retrieved from the file.
2809	Text string `json:"text"`
2810	// Metadata for the response, check the presence of optional fields with the
2811	// [resp.Field.IsPresent] method.
2812	JSON struct {
2813		Attributes  resp.Field
2814		FileID      resp.Field
2815		Filename    resp.Field
2816		Score       resp.Field
2817		Text        resp.Field
2818		ExtraFields map[string]resp.Field
2819		raw         string
2820	} `json:"-"`
2821}
2822
2823// Returns the unmodified JSON received from the API
2824func (r ResponseFileSearchToolCallResult) RawJSON() string { return r.JSON.raw }
2825func (r *ResponseFileSearchToolCallResult) UnmarshalJSON(data []byte) error {
2826	return apijson.UnmarshalRoot(data, r)
2827}
2828
2829// ResponseFileSearchToolCallResultAttributeUnion contains all possible properties
2830// and values from [string], [float64], [bool].
2831//
2832// Use the methods beginning with 'As' to cast the union to one of its variants.
2833//
2834// If the underlying value is not a json object, one of the following properties
2835// will be valid: OfString OfFloat OfBool]
2836type ResponseFileSearchToolCallResultAttributeUnion struct {
2837	// This field will be present if the value is a [string] instead of an object.
2838	OfString string `json:",inline"`
2839	// This field will be present if the value is a [float64] instead of an object.
2840	OfFloat float64 `json:",inline"`
2841	// This field will be present if the value is a [bool] instead of an object.
2842	OfBool bool `json:",inline"`
2843	JSON   struct {
2844		OfString resp.Field
2845		OfFloat  resp.Field
2846		OfBool   resp.Field
2847		raw      string
2848	} `json:"-"`
2849}
2850
2851func (u ResponseFileSearchToolCallResultAttributeUnion) AsString() (v string) {
2852	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
2853	return
2854}
2855
2856func (u ResponseFileSearchToolCallResultAttributeUnion) AsFloat() (v float64) {
2857	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
2858	return
2859}
2860
2861func (u ResponseFileSearchToolCallResultAttributeUnion) AsBool() (v bool) {
2862	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
2863	return
2864}
2865
2866// Returns the unmodified JSON received from the API
2867func (u ResponseFileSearchToolCallResultAttributeUnion) RawJSON() string { return u.JSON.raw }
2868
2869func (r *ResponseFileSearchToolCallResultAttributeUnion) UnmarshalJSON(data []byte) error {
2870	return apijson.UnmarshalRoot(data, r)
2871}
2872
2873// The results of a file search tool call. See the
2874// [file search guide](https://platform.openai.com/docs/guides/tools-file-search)
2875// for more information.
2876//
2877// The properties ID, Queries, Status, Type are required.
2878type ResponseFileSearchToolCallParam struct {
2879	// The unique ID of the file search tool call.
2880	ID string `json:"id,required"`
2881	// The queries used to search for files.
2882	Queries []string `json:"queries,omitzero,required"`
2883	// The status of the file search tool call. One of `in_progress`, `searching`,
2884	// `incomplete` or `failed`,
2885	//
2886	// Any of "in_progress", "searching", "completed", "incomplete", "failed".
2887	Status ResponseFileSearchToolCallStatus `json:"status,omitzero,required"`
2888	// The results of the file search tool call.
2889	Results []ResponseFileSearchToolCallResultParam `json:"results,omitzero"`
2890	// The type of the file search tool call. Always `file_search_call`.
2891	//
2892	// This field can be elided, and will marshal its zero value as "file_search_call".
2893	Type constant.FileSearchCall `json:"type,required"`
2894	paramObj
2895}
2896
2897// IsPresent returns true if the field's value is not omitted and not the JSON
2898// "null". To check if this field is omitted, use [param.IsOmitted].
2899func (f ResponseFileSearchToolCallParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
2900func (r ResponseFileSearchToolCallParam) MarshalJSON() (data []byte, err error) {
2901	type shadow ResponseFileSearchToolCallParam
2902	return param.MarshalObject(r, (*shadow)(&r))
2903}
2904
2905type ResponseFileSearchToolCallResultParam struct {
2906	// The unique ID of the file.
2907	FileID param.Opt[string] `json:"file_id,omitzero"`
2908	// The name of the file.
2909	Filename param.Opt[string] `json:"filename,omitzero"`
2910	// The relevance score of the file - a value between 0 and 1.
2911	Score param.Opt[float64] `json:"score,omitzero"`
2912	// The text that was retrieved from the file.
2913	Text param.Opt[string] `json:"text,omitzero"`
2914	// Set of 16 key-value pairs that can be attached to an object. This can be useful
2915	// for storing additional information about the object in a structured format, and
2916	// querying for objects via API or the dashboard. Keys are strings with a maximum
2917	// length of 64 characters. Values are strings with a maximum length of 512
2918	// characters, booleans, or numbers.
2919	Attributes map[string]ResponseFileSearchToolCallResultAttributeUnionParam `json:"attributes,omitzero"`
2920	paramObj
2921}
2922
2923// IsPresent returns true if the field's value is not omitted and not the JSON
2924// "null". To check if this field is omitted, use [param.IsOmitted].
2925func (f ResponseFileSearchToolCallResultParam) IsPresent() bool {
2926	return !param.IsOmitted(f) && !f.IsNull()
2927}
2928func (r ResponseFileSearchToolCallResultParam) MarshalJSON() (data []byte, err error) {
2929	type shadow ResponseFileSearchToolCallResultParam
2930	return param.MarshalObject(r, (*shadow)(&r))
2931}
2932
2933// Only one field can be non-zero.
2934//
2935// Use [param.IsOmitted] to confirm if a field is set.
2936type ResponseFileSearchToolCallResultAttributeUnionParam struct {
2937	OfString param.Opt[string]  `json:",omitzero,inline"`
2938	OfFloat  param.Opt[float64] `json:",omitzero,inline"`
2939	OfBool   param.Opt[bool]    `json:",omitzero,inline"`
2940	paramUnion
2941}
2942
2943// IsPresent returns true if the field's value is not omitted and not the JSON
2944// "null". To check if this field is omitted, use [param.IsOmitted].
2945func (u ResponseFileSearchToolCallResultAttributeUnionParam) IsPresent() bool {
2946	return !param.IsOmitted(u) && !u.IsNull()
2947}
2948func (u ResponseFileSearchToolCallResultAttributeUnionParam) MarshalJSON() ([]byte, error) {
2949	return param.MarshalUnion[ResponseFileSearchToolCallResultAttributeUnionParam](u.OfString, u.OfFloat, u.OfBool)
2950}
2951
2952func (u *ResponseFileSearchToolCallResultAttributeUnionParam) asAny() any {
2953	if !param.IsOmitted(u.OfString) {
2954		return &u.OfString.Value
2955	} else if !param.IsOmitted(u.OfFloat) {
2956		return &u.OfFloat.Value
2957	} else if !param.IsOmitted(u.OfBool) {
2958		return &u.OfBool.Value
2959	}
2960	return nil
2961}
2962
2963// ResponseFormatTextConfigUnion contains all possible properties and values from
2964// [shared.ResponseFormatText], [ResponseFormatTextJSONSchemaConfig],
2965// [shared.ResponseFormatJSONObject].
2966//
2967// Use the [ResponseFormatTextConfigUnion.AsAny] method to switch on the variant.
2968//
2969// Use the methods beginning with 'As' to cast the union to one of its variants.
2970type ResponseFormatTextConfigUnion struct {
2971	// Any of "text", "json_schema", "json_object".
2972	Type string `json:"type"`
2973	// This field is from variant [ResponseFormatTextJSONSchemaConfig].
2974	Schema map[string]interface{} `json:"schema"`
2975	// This field is from variant [ResponseFormatTextJSONSchemaConfig].
2976	Description string `json:"description"`
2977	// This field is from variant [ResponseFormatTextJSONSchemaConfig].
2978	Name string `json:"name"`
2979	// This field is from variant [ResponseFormatTextJSONSchemaConfig].
2980	Strict bool `json:"strict"`
2981	JSON   struct {
2982		Type        resp.Field
2983		Schema      resp.Field
2984		Description resp.Field
2985		Name        resp.Field
2986		Strict      resp.Field
2987		raw         string
2988	} `json:"-"`
2989}
2990
2991// Use the following switch statement to find the correct variant
2992//
2993//	switch variant := ResponseFormatTextConfigUnion.AsAny().(type) {
2994//	case shared.ResponseFormatText:
2995//	case ResponseFormatTextJSONSchemaConfig:
2996//	case shared.ResponseFormatJSONObject:
2997//	default:
2998//	  fmt.Errorf("no variant present")
2999//	}
3000func (u ResponseFormatTextConfigUnion) AsAny() any {
3001	switch u.Type {
3002	case "text":
3003		return u.AsText()
3004	case "json_schema":
3005		return u.AsJSONSchema()
3006	case "json_object":
3007		return u.AsJSONObject()
3008	}
3009	return nil
3010}
3011
3012func (u ResponseFormatTextConfigUnion) AsText() (v shared.ResponseFormatText) {
3013	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
3014	return
3015}
3016
3017func (u ResponseFormatTextConfigUnion) AsJSONSchema() (v ResponseFormatTextJSONSchemaConfig) {
3018	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
3019	return
3020}
3021
3022func (u ResponseFormatTextConfigUnion) AsJSONObject() (v shared.ResponseFormatJSONObject) {
3023	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
3024	return
3025}
3026
3027// Returns the unmodified JSON received from the API
3028func (u ResponseFormatTextConfigUnion) RawJSON() string { return u.JSON.raw }
3029
3030func (r *ResponseFormatTextConfigUnion) UnmarshalJSON(data []byte) error {
3031	return apijson.UnmarshalRoot(data, r)
3032}
3033
3034// ToParam converts this ResponseFormatTextConfigUnion to a
3035// ResponseFormatTextConfigUnionParam.
3036//
3037// Warning: the fields of the param type will not be present. ToParam should only
3038// be used at the last possible moment before sending a request. Test for this with
3039// ResponseFormatTextConfigUnionParam.IsOverridden()
3040func (r ResponseFormatTextConfigUnion) ToParam() ResponseFormatTextConfigUnionParam {
3041	return param.OverrideObj[ResponseFormatTextConfigUnionParam](r.RawJSON())
3042}
3043
3044func ResponseFormatTextConfigParamOfJSONSchema(schema map[string]interface{}) ResponseFormatTextConfigUnionParam {
3045	var jsonSchema ResponseFormatTextJSONSchemaConfigParam
3046	jsonSchema.Schema = schema
3047	return ResponseFormatTextConfigUnionParam{OfJSONSchema: &jsonSchema}
3048}
3049
3050// Only one field can be non-zero.
3051//
3052// Use [param.IsOmitted] to confirm if a field is set.
3053type ResponseFormatTextConfigUnionParam struct {
3054	OfText       *shared.ResponseFormatTextParam          `json:",omitzero,inline"`
3055	OfJSONSchema *ResponseFormatTextJSONSchemaConfigParam `json:",omitzero,inline"`
3056	OfJSONObject *shared.ResponseFormatJSONObjectParam    `json:",omitzero,inline"`
3057	paramUnion
3058}
3059
3060// IsPresent returns true if the field's value is not omitted and not the JSON
3061// "null". To check if this field is omitted, use [param.IsOmitted].
3062func (u ResponseFormatTextConfigUnionParam) IsPresent() bool {
3063	return !param.IsOmitted(u) && !u.IsNull()
3064}
3065func (u ResponseFormatTextConfigUnionParam) MarshalJSON() ([]byte, error) {
3066	return param.MarshalUnion[ResponseFormatTextConfigUnionParam](u.OfText, u.OfJSONSchema, u.OfJSONObject)
3067}
3068
3069func (u *ResponseFormatTextConfigUnionParam) asAny() any {
3070	if !param.IsOmitted(u.OfText) {
3071		return u.OfText
3072	} else if !param.IsOmitted(u.OfJSONSchema) {
3073		return u.OfJSONSchema
3074	} else if !param.IsOmitted(u.OfJSONObject) {
3075		return u.OfJSONObject
3076	}
3077	return nil
3078}
3079
3080// Returns a pointer to the underlying variant's property, if present.
3081func (u ResponseFormatTextConfigUnionParam) GetSchema() map[string]interface{} {
3082	if vt := u.OfJSONSchema; vt != nil {
3083		return vt.Schema
3084	}
3085	return nil
3086}
3087
3088// Returns a pointer to the underlying variant's property, if present.
3089func (u ResponseFormatTextConfigUnionParam) GetDescription() *string {
3090	if vt := u.OfJSONSchema; vt != nil && vt.Description.IsPresent() {
3091		return &vt.Description.Value
3092	}
3093	return nil
3094}
3095
3096// Returns a pointer to the underlying variant's property, if present.
3097func (u ResponseFormatTextConfigUnionParam) GetName() *string {
3098	if vt := u.OfJSONSchema; vt != nil && vt.Name.IsPresent() {
3099		return &vt.Name.Value
3100	}
3101	return nil
3102}
3103
3104// Returns a pointer to the underlying variant's property, if present.
3105func (u ResponseFormatTextConfigUnionParam) GetStrict() *bool {
3106	if vt := u.OfJSONSchema; vt != nil && vt.Strict.IsPresent() {
3107		return &vt.Strict.Value
3108	}
3109	return nil
3110}
3111
3112// Returns a pointer to the underlying variant's property, if present.
3113func (u ResponseFormatTextConfigUnionParam) GetType() *string {
3114	if vt := u.OfText; vt != nil {
3115		return (*string)(&vt.Type)
3116	} else if vt := u.OfJSONSchema; vt != nil {
3117		return (*string)(&vt.Type)
3118	} else if vt := u.OfJSONObject; vt != nil {
3119		return (*string)(&vt.Type)
3120	}
3121	return nil
3122}
3123
3124func init() {
3125	apijson.RegisterUnion[ResponseFormatTextConfigUnionParam](
3126		"type",
3127		apijson.UnionVariant{
3128			TypeFilter:         gjson.JSON,
3129			Type:               reflect.TypeOf(shared.ResponseFormatTextParam{}),
3130			DiscriminatorValue: "text",
3131		},
3132		apijson.UnionVariant{
3133			TypeFilter:         gjson.JSON,
3134			Type:               reflect.TypeOf(ResponseFormatTextJSONSchemaConfigParam{}),
3135			DiscriminatorValue: "json_schema",
3136		},
3137		apijson.UnionVariant{
3138			TypeFilter:         gjson.JSON,
3139			Type:               reflect.TypeOf(shared.ResponseFormatJSONObjectParam{}),
3140			DiscriminatorValue: "json_object",
3141		},
3142	)
3143}
3144
3145// JSON Schema response format. Used to generate structured JSON responses. Learn
3146// more about
3147// [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).
3148type ResponseFormatTextJSONSchemaConfig struct {
3149	// The schema for the response format, described as a JSON Schema object. Learn how
3150	// to build JSON schemas [here](https://json-schema.org/).
3151	Schema map[string]interface{} `json:"schema,required"`
3152	// The type of response format being defined. Always `json_schema`.
3153	Type constant.JSONSchema `json:"type,required"`
3154	// A description of what the response format is for, used by the model to determine
3155	// how to respond in the format.
3156	Description string `json:"description"`
3157	// The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores
3158	// and dashes, with a maximum length of 64.
3159	Name string `json:"name"`
3160	// Whether to enable strict schema adherence when generating the output. If set to
3161	// true, the model will always follow the exact schema defined in the `schema`
3162	// field. Only a subset of JSON Schema is supported when `strict` is `true`. To
3163	// learn more, read the
3164	// [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
3165	Strict bool `json:"strict,nullable"`
3166	// Metadata for the response, check the presence of optional fields with the
3167	// [resp.Field.IsPresent] method.
3168	JSON struct {
3169		Schema      resp.Field
3170		Type        resp.Field
3171		Description resp.Field
3172		Name        resp.Field
3173		Strict      resp.Field
3174		ExtraFields map[string]resp.Field
3175		raw         string
3176	} `json:"-"`
3177}
3178
3179// Returns the unmodified JSON received from the API
3180func (r ResponseFormatTextJSONSchemaConfig) RawJSON() string { return r.JSON.raw }
3181func (r *ResponseFormatTextJSONSchemaConfig) UnmarshalJSON(data []byte) error {
3182	return apijson.UnmarshalRoot(data, r)
3183}
3184
3185// ToParam converts this ResponseFormatTextJSONSchemaConfig to a
3186// ResponseFormatTextJSONSchemaConfigParam.
3187//
3188// Warning: the fields of the param type will not be present. ToParam should only
3189// be used at the last possible moment before sending a request. Test for this with
3190// ResponseFormatTextJSONSchemaConfigParam.IsOverridden()
3191func (r ResponseFormatTextJSONSchemaConfig) ToParam() ResponseFormatTextJSONSchemaConfigParam {
3192	return param.OverrideObj[ResponseFormatTextJSONSchemaConfigParam](r.RawJSON())
3193}
3194
3195// JSON Schema response format. Used to generate structured JSON responses. Learn
3196// more about
3197// [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).
3198//
3199// The properties Schema, Type are required.
3200type ResponseFormatTextJSONSchemaConfigParam struct {
3201	// The schema for the response format, described as a JSON Schema object. Learn how
3202	// to build JSON schemas [here](https://json-schema.org/).
3203	Schema map[string]interface{} `json:"schema,omitzero,required"`
3204	// Whether to enable strict schema adherence when generating the output. If set to
3205	// true, the model will always follow the exact schema defined in the `schema`
3206	// field. Only a subset of JSON Schema is supported when `strict` is `true`. To
3207	// learn more, read the
3208	// [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
3209	Strict param.Opt[bool] `json:"strict,omitzero"`
3210	// A description of what the response format is for, used by the model to determine
3211	// how to respond in the format.
3212	Description param.Opt[string] `json:"description,omitzero"`
3213	// The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores
3214	// and dashes, with a maximum length of 64.
3215	Name param.Opt[string] `json:"name,omitzero"`
3216	// The type of response format being defined. Always `json_schema`.
3217	//
3218	// This field can be elided, and will marshal its zero value as "json_schema".
3219	Type constant.JSONSchema `json:"type,required"`
3220	paramObj
3221}
3222
3223// IsPresent returns true if the field's value is not omitted and not the JSON
3224// "null". To check if this field is omitted, use [param.IsOmitted].
3225func (f ResponseFormatTextJSONSchemaConfigParam) IsPresent() bool {
3226	return !param.IsOmitted(f) && !f.IsNull()
3227}
3228func (r ResponseFormatTextJSONSchemaConfigParam) MarshalJSON() (data []byte, err error) {
3229	type shadow ResponseFormatTextJSONSchemaConfigParam
3230	return param.MarshalObject(r, (*shadow)(&r))
3231}
3232
3233// Emitted when there is a partial function-call arguments delta.
3234type ResponseFunctionCallArgumentsDeltaEvent struct {
3235	// The function-call arguments delta that is added.
3236	Delta string `json:"delta,required"`
3237	// The ID of the output item that the function-call arguments delta is added to.
3238	ItemID string `json:"item_id,required"`
3239	// The index of the output item that the function-call arguments delta is added to.
3240	OutputIndex int64 `json:"output_index,required"`
3241	// The type of the event. Always `response.function_call_arguments.delta`.
3242	Type constant.ResponseFunctionCallArgumentsDelta `json:"type,required"`
3243	// Metadata for the response, check the presence of optional fields with the
3244	// [resp.Field.IsPresent] method.
3245	JSON struct {
3246		Delta       resp.Field
3247		ItemID      resp.Field
3248		OutputIndex resp.Field
3249		Type        resp.Field
3250		ExtraFields map[string]resp.Field
3251		raw         string
3252	} `json:"-"`
3253}
3254
3255// Returns the unmodified JSON received from the API
3256func (r ResponseFunctionCallArgumentsDeltaEvent) RawJSON() string { return r.JSON.raw }
3257func (r *ResponseFunctionCallArgumentsDeltaEvent) UnmarshalJSON(data []byte) error {
3258	return apijson.UnmarshalRoot(data, r)
3259}
3260
3261// Emitted when function-call arguments are finalized.
3262type ResponseFunctionCallArgumentsDoneEvent struct {
3263	// The function-call arguments.
3264	Arguments string `json:"arguments,required"`
3265	// The ID of the item.
3266	ItemID string `json:"item_id,required"`
3267	// The index of the output item.
3268	OutputIndex int64                                      `json:"output_index,required"`
3269	Type        constant.ResponseFunctionCallArgumentsDone `json:"type,required"`
3270	// Metadata for the response, check the presence of optional fields with the
3271	// [resp.Field.IsPresent] method.
3272	JSON struct {
3273		Arguments   resp.Field
3274		ItemID      resp.Field
3275		OutputIndex resp.Field
3276		Type        resp.Field
3277		ExtraFields map[string]resp.Field
3278		raw         string
3279	} `json:"-"`
3280}
3281
3282// Returns the unmodified JSON received from the API
3283func (r ResponseFunctionCallArgumentsDoneEvent) RawJSON() string { return r.JSON.raw }
3284func (r *ResponseFunctionCallArgumentsDoneEvent) UnmarshalJSON(data []byte) error {
3285	return apijson.UnmarshalRoot(data, r)
3286}
3287
3288// A tool call to run a function. See the
3289// [function calling guide](https://platform.openai.com/docs/guides/function-calling)
3290// for more information.
3291type ResponseFunctionToolCall struct {
3292	// A JSON string of the arguments to pass to the function.
3293	Arguments string `json:"arguments,required"`
3294	// The unique ID of the function tool call generated by the model.
3295	CallID string `json:"call_id,required"`
3296	// The name of the function to run.
3297	Name string `json:"name,required"`
3298	// The type of the function tool call. Always `function_call`.
3299	Type constant.FunctionCall `json:"type,required"`
3300	// The unique ID of the function tool call.
3301	ID string `json:"id"`
3302	// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
3303	// Populated when items are returned via API.
3304	//
3305	// Any of "in_progress", "completed", "incomplete".
3306	Status ResponseFunctionToolCallStatus `json:"status"`
3307	// Metadata for the response, check the presence of optional fields with the
3308	// [resp.Field.IsPresent] method.
3309	JSON struct {
3310		Arguments   resp.Field
3311		CallID      resp.Field
3312		Name        resp.Field
3313		Type        resp.Field
3314		ID          resp.Field
3315		Status      resp.Field
3316		ExtraFields map[string]resp.Field
3317		raw         string
3318	} `json:"-"`
3319}
3320
3321// Returns the unmodified JSON received from the API
3322func (r ResponseFunctionToolCall) RawJSON() string { return r.JSON.raw }
3323func (r *ResponseFunctionToolCall) UnmarshalJSON(data []byte) error {
3324	return apijson.UnmarshalRoot(data, r)
3325}
3326
3327// ToParam converts this ResponseFunctionToolCall to a
3328// ResponseFunctionToolCallParam.
3329//
3330// Warning: the fields of the param type will not be present. ToParam should only
3331// be used at the last possible moment before sending a request. Test for this with
3332// ResponseFunctionToolCallParam.IsOverridden()
3333func (r ResponseFunctionToolCall) ToParam() ResponseFunctionToolCallParam {
3334	return param.OverrideObj[ResponseFunctionToolCallParam](r.RawJSON())
3335}
3336
3337// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
3338// Populated when items are returned via API.
3339type ResponseFunctionToolCallStatus string
3340
3341const (
3342	ResponseFunctionToolCallStatusInProgress ResponseFunctionToolCallStatus = "in_progress"
3343	ResponseFunctionToolCallStatusCompleted  ResponseFunctionToolCallStatus = "completed"
3344	ResponseFunctionToolCallStatusIncomplete ResponseFunctionToolCallStatus = "incomplete"
3345)
3346
3347// A tool call to run a function. See the
3348// [function calling guide](https://platform.openai.com/docs/guides/function-calling)
3349// for more information.
3350//
3351// The properties Arguments, CallID, Name, Type are required.
3352type ResponseFunctionToolCallParam struct {
3353	// A JSON string of the arguments to pass to the function.
3354	Arguments string `json:"arguments,required"`
3355	// The unique ID of the function tool call generated by the model.
3356	CallID string `json:"call_id,required"`
3357	// The name of the function to run.
3358	Name string `json:"name,required"`
3359	// The unique ID of the function tool call.
3360	ID param.Opt[string] `json:"id,omitzero"`
3361	// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
3362	// Populated when items are returned via API.
3363	//
3364	// Any of "in_progress", "completed", "incomplete".
3365	Status ResponseFunctionToolCallStatus `json:"status,omitzero"`
3366	// The type of the function tool call. Always `function_call`.
3367	//
3368	// This field can be elided, and will marshal its zero value as "function_call".
3369	Type constant.FunctionCall `json:"type,required"`
3370	paramObj
3371}
3372
3373// IsPresent returns true if the field's value is not omitted and not the JSON
3374// "null". To check if this field is omitted, use [param.IsOmitted].
3375func (f ResponseFunctionToolCallParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
3376func (r ResponseFunctionToolCallParam) MarshalJSON() (data []byte, err error) {
3377	type shadow ResponseFunctionToolCallParam
3378	return param.MarshalObject(r, (*shadow)(&r))
3379}
3380
3381// A tool call to run a function. See the
3382// [function calling guide](https://platform.openai.com/docs/guides/function-calling)
3383// for more information.
3384type ResponseFunctionToolCallItem struct {
3385	// The unique ID of the function tool call.
3386	ID string `json:"id,required"`
3387	// Metadata for the response, check the presence of optional fields with the
3388	// [resp.Field.IsPresent] method.
3389	JSON struct {
3390		ID          resp.Field
3391		ExtraFields map[string]resp.Field
3392		raw         string
3393	} `json:"-"`
3394	ResponseFunctionToolCall
3395}
3396
3397// Returns the unmodified JSON received from the API
3398func (r ResponseFunctionToolCallItem) RawJSON() string { return r.JSON.raw }
3399func (r *ResponseFunctionToolCallItem) UnmarshalJSON(data []byte) error {
3400	return apijson.UnmarshalRoot(data, r)
3401}
3402
3403type ResponseFunctionToolCallOutputItem struct {
3404	// The unique ID of the function call tool output.
3405	ID string `json:"id,required"`
3406	// The unique ID of the function tool call generated by the model.
3407	CallID string `json:"call_id,required"`
3408	// A JSON string of the output of the function tool call.
3409	Output string `json:"output,required"`
3410	// The type of the function tool call output. Always `function_call_output`.
3411	Type constant.FunctionCallOutput `json:"type,required"`
3412	// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
3413	// Populated when items are returned via API.
3414	//
3415	// Any of "in_progress", "completed", "incomplete".
3416	Status ResponseFunctionToolCallOutputItemStatus `json:"status"`
3417	// Metadata for the response, check the presence of optional fields with the
3418	// [resp.Field.IsPresent] method.
3419	JSON struct {
3420		ID          resp.Field
3421		CallID      resp.Field
3422		Output      resp.Field
3423		Type        resp.Field
3424		Status      resp.Field
3425		ExtraFields map[string]resp.Field
3426		raw         string
3427	} `json:"-"`
3428}
3429
3430// Returns the unmodified JSON received from the API
3431func (r ResponseFunctionToolCallOutputItem) RawJSON() string { return r.JSON.raw }
3432func (r *ResponseFunctionToolCallOutputItem) UnmarshalJSON(data []byte) error {
3433	return apijson.UnmarshalRoot(data, r)
3434}
3435
3436// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
3437// Populated when items are returned via API.
3438type ResponseFunctionToolCallOutputItemStatus string
3439
3440const (
3441	ResponseFunctionToolCallOutputItemStatusInProgress ResponseFunctionToolCallOutputItemStatus = "in_progress"
3442	ResponseFunctionToolCallOutputItemStatusCompleted  ResponseFunctionToolCallOutputItemStatus = "completed"
3443	ResponseFunctionToolCallOutputItemStatusIncomplete ResponseFunctionToolCallOutputItemStatus = "incomplete"
3444)
3445
3446// The results of a web search tool call. See the
3447// [web search guide](https://platform.openai.com/docs/guides/tools-web-search) for
3448// more information.
3449type ResponseFunctionWebSearch struct {
3450	// The unique ID of the web search tool call.
3451	ID string `json:"id,required"`
3452	// The status of the web search tool call.
3453	//
3454	// Any of "in_progress", "searching", "completed", "failed".
3455	Status ResponseFunctionWebSearchStatus `json:"status,required"`
3456	// The type of the web search tool call. Always `web_search_call`.
3457	Type constant.WebSearchCall `json:"type,required"`
3458	// Metadata for the response, check the presence of optional fields with the
3459	// [resp.Field.IsPresent] method.
3460	JSON struct {
3461		ID          resp.Field
3462		Status      resp.Field
3463		Type        resp.Field
3464		ExtraFields map[string]resp.Field
3465		raw         string
3466	} `json:"-"`
3467}
3468
3469// Returns the unmodified JSON received from the API
3470func (r ResponseFunctionWebSearch) RawJSON() string { return r.JSON.raw }
3471func (r *ResponseFunctionWebSearch) UnmarshalJSON(data []byte) error {
3472	return apijson.UnmarshalRoot(data, r)
3473}
3474
3475// ToParam converts this ResponseFunctionWebSearch to a
3476// ResponseFunctionWebSearchParam.
3477//
3478// Warning: the fields of the param type will not be present. ToParam should only
3479// be used at the last possible moment before sending a request. Test for this with
3480// ResponseFunctionWebSearchParam.IsOverridden()
3481func (r ResponseFunctionWebSearch) ToParam() ResponseFunctionWebSearchParam {
3482	return param.OverrideObj[ResponseFunctionWebSearchParam](r.RawJSON())
3483}
3484
3485// The status of the web search tool call.
3486type ResponseFunctionWebSearchStatus string
3487
3488const (
3489	ResponseFunctionWebSearchStatusInProgress ResponseFunctionWebSearchStatus = "in_progress"
3490	ResponseFunctionWebSearchStatusSearching  ResponseFunctionWebSearchStatus = "searching"
3491	ResponseFunctionWebSearchStatusCompleted  ResponseFunctionWebSearchStatus = "completed"
3492	ResponseFunctionWebSearchStatusFailed     ResponseFunctionWebSearchStatus = "failed"
3493)
3494
3495// The results of a web search tool call. See the
3496// [web search guide](https://platform.openai.com/docs/guides/tools-web-search) for
3497// more information.
3498//
3499// The properties ID, Status, Type are required.
3500type ResponseFunctionWebSearchParam struct {
3501	// The unique ID of the web search tool call.
3502	ID string `json:"id,required"`
3503	// The status of the web search tool call.
3504	//
3505	// Any of "in_progress", "searching", "completed", "failed".
3506	Status ResponseFunctionWebSearchStatus `json:"status,omitzero,required"`
3507	// The type of the web search tool call. Always `web_search_call`.
3508	//
3509	// This field can be elided, and will marshal its zero value as "web_search_call".
3510	Type constant.WebSearchCall `json:"type,required"`
3511	paramObj
3512}
3513
3514// IsPresent returns true if the field's value is not omitted and not the JSON
3515// "null". To check if this field is omitted, use [param.IsOmitted].
3516func (f ResponseFunctionWebSearchParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
3517func (r ResponseFunctionWebSearchParam) MarshalJSON() (data []byte, err error) {
3518	type shadow ResponseFunctionWebSearchParam
3519	return param.MarshalObject(r, (*shadow)(&r))
3520}
3521
3522// Emitted when the response is in progress.
3523type ResponseInProgressEvent struct {
3524	// The response that is in progress.
3525	Response Response `json:"response,required"`
3526	// The type of the event. Always `response.in_progress`.
3527	Type constant.ResponseInProgress `json:"type,required"`
3528	// Metadata for the response, check the presence of optional fields with the
3529	// [resp.Field.IsPresent] method.
3530	JSON struct {
3531		Response    resp.Field
3532		Type        resp.Field
3533		ExtraFields map[string]resp.Field
3534		raw         string
3535	} `json:"-"`
3536}
3537
3538// Returns the unmodified JSON received from the API
3539func (r ResponseInProgressEvent) RawJSON() string { return r.JSON.raw }
3540func (r *ResponseInProgressEvent) UnmarshalJSON(data []byte) error {
3541	return apijson.UnmarshalRoot(data, r)
3542}
3543
3544// Specify additional output data to include in the model response. Currently
3545// supported values are:
3546//
3547//   - `file_search_call.results`: Include the search results of the file search tool
3548//     call.
3549//   - `message.input_image.image_url`: Include image urls from the input message.
3550//   - `computer_call_output.output.image_url`: Include image urls from the computer
3551//     call output.
3552type ResponseIncludable string
3553
3554const (
3555	ResponseIncludableFileSearchCallResults            ResponseIncludable = "file_search_call.results"
3556	ResponseIncludableMessageInputImageImageURL        ResponseIncludable = "message.input_image.image_url"
3557	ResponseIncludableComputerCallOutputOutputImageURL ResponseIncludable = "computer_call_output.output.image_url"
3558)
3559
3560// An event that is emitted when a response finishes as incomplete.
3561type ResponseIncompleteEvent struct {
3562	// The response that was incomplete.
3563	Response Response `json:"response,required"`
3564	// The type of the event. Always `response.incomplete`.
3565	Type constant.ResponseIncomplete `json:"type,required"`
3566	// Metadata for the response, check the presence of optional fields with the
3567	// [resp.Field.IsPresent] method.
3568	JSON struct {
3569		Response    resp.Field
3570		Type        resp.Field
3571		ExtraFields map[string]resp.Field
3572		raw         string
3573	} `json:"-"`
3574}
3575
3576// Returns the unmodified JSON received from the API
3577func (r ResponseIncompleteEvent) RawJSON() string { return r.JSON.raw }
3578func (r *ResponseIncompleteEvent) UnmarshalJSON(data []byte) error {
3579	return apijson.UnmarshalRoot(data, r)
3580}
3581
3582type ResponseInputParam []ResponseInputItemUnionParam
3583
3584// ResponseInputContentUnion contains all possible properties and values from
3585// [ResponseInputText], [ResponseInputImage], [ResponseInputFile].
3586//
3587// Use the [ResponseInputContentUnion.AsAny] method to switch on the variant.
3588//
3589// Use the methods beginning with 'As' to cast the union to one of its variants.
3590type ResponseInputContentUnion struct {
3591	// This field is from variant [ResponseInputText].
3592	Text string `json:"text"`
3593	// Any of "input_text", "input_image", "input_file".
3594	Type string `json:"type"`
3595	// This field is from variant [ResponseInputImage].
3596	Detail ResponseInputImageDetail `json:"detail"`
3597	FileID string                   `json:"file_id"`
3598	// This field is from variant [ResponseInputImage].
3599	ImageURL string `json:"image_url"`
3600	// This field is from variant [ResponseInputFile].
3601	FileData string `json:"file_data"`
3602	// This field is from variant [ResponseInputFile].
3603	Filename string `json:"filename"`
3604	JSON     struct {
3605		Text     resp.Field
3606		Type     resp.Field
3607		Detail   resp.Field
3608		FileID   resp.Field
3609		ImageURL resp.Field
3610		FileData resp.Field
3611		Filename resp.Field
3612		raw      string
3613	} `json:"-"`
3614}
3615
3616// Use the following switch statement to find the correct variant
3617//
3618//	switch variant := ResponseInputContentUnion.AsAny().(type) {
3619//	case ResponseInputText:
3620//	case ResponseInputImage:
3621//	case ResponseInputFile:
3622//	default:
3623//	  fmt.Errorf("no variant present")
3624//	}
3625func (u ResponseInputContentUnion) AsAny() any {
3626	switch u.Type {
3627	case "input_text":
3628		return u.AsInputText()
3629	case "input_image":
3630		return u.AsInputImage()
3631	case "input_file":
3632		return u.AsInputFile()
3633	}
3634	return nil
3635}
3636
3637func (u ResponseInputContentUnion) AsInputText() (v ResponseInputText) {
3638	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
3639	return
3640}
3641
3642func (u ResponseInputContentUnion) AsInputImage() (v ResponseInputImage) {
3643	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
3644	return
3645}
3646
3647func (u ResponseInputContentUnion) AsInputFile() (v ResponseInputFile) {
3648	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
3649	return
3650}
3651
3652// Returns the unmodified JSON received from the API
3653func (u ResponseInputContentUnion) RawJSON() string { return u.JSON.raw }
3654
3655func (r *ResponseInputContentUnion) UnmarshalJSON(data []byte) error {
3656	return apijson.UnmarshalRoot(data, r)
3657}
3658
3659// ToParam converts this ResponseInputContentUnion to a
3660// ResponseInputContentUnionParam.
3661//
3662// Warning: the fields of the param type will not be present. ToParam should only
3663// be used at the last possible moment before sending a request. Test for this with
3664// ResponseInputContentUnionParam.IsOverridden()
3665func (r ResponseInputContentUnion) ToParam() ResponseInputContentUnionParam {
3666	return param.OverrideObj[ResponseInputContentUnionParam](r.RawJSON())
3667}
3668
3669func ResponseInputContentParamOfInputText(text string) ResponseInputContentUnionParam {
3670	var inputText ResponseInputTextParam
3671	inputText.Text = text
3672	return ResponseInputContentUnionParam{OfInputText: &inputText}
3673}
3674
3675func ResponseInputContentParamOfInputImage(detail ResponseInputImageDetail) ResponseInputContentUnionParam {
3676	var inputImage ResponseInputImageParam
3677	inputImage.Detail = detail
3678	return ResponseInputContentUnionParam{OfInputImage: &inputImage}
3679}
3680
3681// Only one field can be non-zero.
3682//
3683// Use [param.IsOmitted] to confirm if a field is set.
3684type ResponseInputContentUnionParam struct {
3685	OfInputText  *ResponseInputTextParam  `json:",omitzero,inline"`
3686	OfInputImage *ResponseInputImageParam `json:",omitzero,inline"`
3687	OfInputFile  *ResponseInputFileParam  `json:",omitzero,inline"`
3688	paramUnion
3689}
3690
3691// IsPresent returns true if the field's value is not omitted and not the JSON
3692// "null". To check if this field is omitted, use [param.IsOmitted].
3693func (u ResponseInputContentUnionParam) IsPresent() bool { return !param.IsOmitted(u) && !u.IsNull() }
3694func (u ResponseInputContentUnionParam) MarshalJSON() ([]byte, error) {
3695	return param.MarshalUnion[ResponseInputContentUnionParam](u.OfInputText, u.OfInputImage, u.OfInputFile)
3696}
3697
3698func (u *ResponseInputContentUnionParam) asAny() any {
3699	if !param.IsOmitted(u.OfInputText) {
3700		return u.OfInputText
3701	} else if !param.IsOmitted(u.OfInputImage) {
3702		return u.OfInputImage
3703	} else if !param.IsOmitted(u.OfInputFile) {
3704		return u.OfInputFile
3705	}
3706	return nil
3707}
3708
3709// Returns a pointer to the underlying variant's property, if present.
3710func (u ResponseInputContentUnionParam) GetText() *string {
3711	if vt := u.OfInputText; vt != nil {
3712		return &vt.Text
3713	}
3714	return nil
3715}
3716
3717// Returns a pointer to the underlying variant's property, if present.
3718func (u ResponseInputContentUnionParam) GetDetail() *string {
3719	if vt := u.OfInputImage; vt != nil {
3720		return (*string)(&vt.Detail)
3721	}
3722	return nil
3723}
3724
3725// Returns a pointer to the underlying variant's property, if present.
3726func (u ResponseInputContentUnionParam) GetImageURL() *string {
3727	if vt := u.OfInputImage; vt != nil && vt.ImageURL.IsPresent() {
3728		return &vt.ImageURL.Value
3729	}
3730	return nil
3731}
3732
3733// Returns a pointer to the underlying variant's property, if present.
3734func (u ResponseInputContentUnionParam) GetFileData() *string {
3735	if vt := u.OfInputFile; vt != nil && vt.FileData.IsPresent() {
3736		return &vt.FileData.Value
3737	}
3738	return nil
3739}
3740
3741// Returns a pointer to the underlying variant's property, if present.
3742func (u ResponseInputContentUnionParam) GetFilename() *string {
3743	if vt := u.OfInputFile; vt != nil && vt.Filename.IsPresent() {
3744		return &vt.Filename.Value
3745	}
3746	return nil
3747}
3748
3749// Returns a pointer to the underlying variant's property, if present.
3750func (u ResponseInputContentUnionParam) GetType() *string {
3751	if vt := u.OfInputText; vt != nil {
3752		return (*string)(&vt.Type)
3753	} else if vt := u.OfInputImage; vt != nil {
3754		return (*string)(&vt.Type)
3755	} else if vt := u.OfInputFile; vt != nil {
3756		return (*string)(&vt.Type)
3757	}
3758	return nil
3759}
3760
3761// Returns a pointer to the underlying variant's property, if present.
3762func (u ResponseInputContentUnionParam) GetFileID() *string {
3763	if vt := u.OfInputImage; vt != nil && vt.FileID.IsPresent() {
3764		return &vt.FileID.Value
3765	} else if vt := u.OfInputFile; vt != nil && vt.FileID.IsPresent() {
3766		return &vt.FileID.Value
3767	}
3768	return nil
3769}
3770
3771func init() {
3772	apijson.RegisterUnion[ResponseInputContentUnionParam](
3773		"type",
3774		apijson.UnionVariant{
3775			TypeFilter:         gjson.JSON,
3776			Type:               reflect.TypeOf(ResponseInputTextParam{}),
3777			DiscriminatorValue: "input_text",
3778		},
3779		apijson.UnionVariant{
3780			TypeFilter:         gjson.JSON,
3781			Type:               reflect.TypeOf(ResponseInputImageParam{}),
3782			DiscriminatorValue: "input_image",
3783		},
3784		apijson.UnionVariant{
3785			TypeFilter:         gjson.JSON,
3786			Type:               reflect.TypeOf(ResponseInputFileParam{}),
3787			DiscriminatorValue: "input_file",
3788		},
3789	)
3790}
3791
3792// A file input to the model.
3793type ResponseInputFile struct {
3794	// The type of the input item. Always `input_file`.
3795	Type constant.InputFile `json:"type,required"`
3796	// The content of the file to be sent to the model.
3797	FileData string `json:"file_data"`
3798	// The ID of the file to be sent to the model.
3799	FileID string `json:"file_id"`
3800	// The name of the file to be sent to the model.
3801	Filename string `json:"filename"`
3802	// Metadata for the response, check the presence of optional fields with the
3803	// [resp.Field.IsPresent] method.
3804	JSON struct {
3805		Type        resp.Field
3806		FileData    resp.Field
3807		FileID      resp.Field
3808		Filename    resp.Field
3809		ExtraFields map[string]resp.Field
3810		raw         string
3811	} `json:"-"`
3812}
3813
3814// Returns the unmodified JSON received from the API
3815func (r ResponseInputFile) RawJSON() string { return r.JSON.raw }
3816func (r *ResponseInputFile) UnmarshalJSON(data []byte) error {
3817	return apijson.UnmarshalRoot(data, r)
3818}
3819
3820// ToParam converts this ResponseInputFile to a ResponseInputFileParam.
3821//
3822// Warning: the fields of the param type will not be present. ToParam should only
3823// be used at the last possible moment before sending a request. Test for this with
3824// ResponseInputFileParam.IsOverridden()
3825func (r ResponseInputFile) ToParam() ResponseInputFileParam {
3826	return param.OverrideObj[ResponseInputFileParam](r.RawJSON())
3827}
3828
3829// A file input to the model.
3830//
3831// The property Type is required.
3832type ResponseInputFileParam struct {
3833	// The content of the file to be sent to the model.
3834	FileData param.Opt[string] `json:"file_data,omitzero"`
3835	// The ID of the file to be sent to the model.
3836	FileID param.Opt[string] `json:"file_id,omitzero"`
3837	// The name of the file to be sent to the model.
3838	Filename param.Opt[string] `json:"filename,omitzero"`
3839	// The type of the input item. Always `input_file`.
3840	//
3841	// This field can be elided, and will marshal its zero value as "input_file".
3842	Type constant.InputFile `json:"type,required"`
3843	paramObj
3844}
3845
3846// IsPresent returns true if the field's value is not omitted and not the JSON
3847// "null". To check if this field is omitted, use [param.IsOmitted].
3848func (f ResponseInputFileParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
3849func (r ResponseInputFileParam) MarshalJSON() (data []byte, err error) {
3850	type shadow ResponseInputFileParam
3851	return param.MarshalObject(r, (*shadow)(&r))
3852}
3853
3854// An image input to the model. Learn about
3855// [image inputs](https://platform.openai.com/docs/guides/vision).
3856type ResponseInputImage struct {
3857	// The detail level of the image to be sent to the model. One of `high`, `low`, or
3858	// `auto`. Defaults to `auto`.
3859	//
3860	// Any of "high", "low", "auto".
3861	Detail ResponseInputImageDetail `json:"detail,required"`
3862	// The type of the input item. Always `input_image`.
3863	Type constant.InputImage `json:"type,required"`
3864	// The ID of the file to be sent to the model.
3865	FileID string `json:"file_id,nullable"`
3866	// The URL of the image to be sent to the model. A fully qualified URL or base64
3867	// encoded image in a data URL.
3868	ImageURL string `json:"image_url,nullable"`
3869	// Metadata for the response, check the presence of optional fields with the
3870	// [resp.Field.IsPresent] method.
3871	JSON struct {
3872		Detail      resp.Field
3873		Type        resp.Field
3874		FileID      resp.Field
3875		ImageURL    resp.Field
3876		ExtraFields map[string]resp.Field
3877		raw         string
3878	} `json:"-"`
3879}
3880
3881// Returns the unmodified JSON received from the API
3882func (r ResponseInputImage) RawJSON() string { return r.JSON.raw }
3883func (r *ResponseInputImage) UnmarshalJSON(data []byte) error {
3884	return apijson.UnmarshalRoot(data, r)
3885}
3886
3887// ToParam converts this ResponseInputImage to a ResponseInputImageParam.
3888//
3889// Warning: the fields of the param type will not be present. ToParam should only
3890// be used at the last possible moment before sending a request. Test for this with
3891// ResponseInputImageParam.IsOverridden()
3892func (r ResponseInputImage) ToParam() ResponseInputImageParam {
3893	return param.OverrideObj[ResponseInputImageParam](r.RawJSON())
3894}
3895
3896// The detail level of the image to be sent to the model. One of `high`, `low`, or
3897// `auto`. Defaults to `auto`.
3898type ResponseInputImageDetail string
3899
3900const (
3901	ResponseInputImageDetailHigh ResponseInputImageDetail = "high"
3902	ResponseInputImageDetailLow  ResponseInputImageDetail = "low"
3903	ResponseInputImageDetailAuto ResponseInputImageDetail = "auto"
3904)
3905
3906// An image input to the model. Learn about
3907// [image inputs](https://platform.openai.com/docs/guides/vision).
3908//
3909// The properties Detail, Type are required.
3910type ResponseInputImageParam struct {
3911	// The detail level of the image to be sent to the model. One of `high`, `low`, or
3912	// `auto`. Defaults to `auto`.
3913	//
3914	// Any of "high", "low", "auto".
3915	Detail ResponseInputImageDetail `json:"detail,omitzero,required"`
3916	// The ID of the file to be sent to the model.
3917	FileID param.Opt[string] `json:"file_id,omitzero"`
3918	// The URL of the image to be sent to the model. A fully qualified URL or base64
3919	// encoded image in a data URL.
3920	ImageURL param.Opt[string] `json:"image_url,omitzero"`
3921	// The type of the input item. Always `input_image`.
3922	//
3923	// This field can be elided, and will marshal its zero value as "input_image".
3924	Type constant.InputImage `json:"type,required"`
3925	paramObj
3926}
3927
3928// IsPresent returns true if the field's value is not omitted and not the JSON
3929// "null". To check if this field is omitted, use [param.IsOmitted].
3930func (f ResponseInputImageParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
3931func (r ResponseInputImageParam) MarshalJSON() (data []byte, err error) {
3932	type shadow ResponseInputImageParam
3933	return param.MarshalObject(r, (*shadow)(&r))
3934}
3935
3936func ResponseInputItemParamOfMessage[T string | ResponseInputMessageContentListParam](content T, role EasyInputMessageRole) ResponseInputItemUnionParam {
3937	var message EasyInputMessageParam
3938	switch v := any(content).(type) {
3939	case string:
3940		message.Content.OfString = param.NewOpt(v)
3941	case ResponseInputMessageContentListParam:
3942		message.Content.OfInputItemContentList = v
3943	}
3944	message.Role = role
3945	return ResponseInputItemUnionParam{OfMessage: &message}
3946}
3947
3948func ResponseInputItemParamOfInputMessage(content ResponseInputMessageContentListParam, role string) ResponseInputItemUnionParam {
3949	var message ResponseInputItemMessageParam
3950	message.Content = content
3951	message.Role = role
3952	return ResponseInputItemUnionParam{OfInputMessage: &message}
3953}
3954
3955func ResponseInputItemParamOfOutputMessage(content []ResponseOutputMessageContentUnionParam, id string, status ResponseOutputMessageStatus) ResponseInputItemUnionParam {
3956	var message ResponseOutputMessageParam
3957	message.Content = content
3958	message.ID = id
3959	message.Status = status
3960	return ResponseInputItemUnionParam{OfOutputMessage: &message}
3961}
3962
3963func ResponseInputItemParamOfFileSearchCall(id string, queries []string, status ResponseFileSearchToolCallStatus) ResponseInputItemUnionParam {
3964	var fileSearchCall ResponseFileSearchToolCallParam
3965	fileSearchCall.ID = id
3966	fileSearchCall.Queries = queries
3967	fileSearchCall.Status = status
3968	return ResponseInputItemUnionParam{OfFileSearchCall: &fileSearchCall}
3969}
3970
3971func ResponseInputItemParamOfComputerCallOutput(callID string, output ResponseComputerToolCallOutputScreenshotParam) ResponseInputItemUnionParam {
3972	var computerCallOutput ResponseInputItemComputerCallOutputParam
3973	computerCallOutput.CallID = callID
3974	computerCallOutput.Output = output
3975	return ResponseInputItemUnionParam{OfComputerCallOutput: &computerCallOutput}
3976}
3977
3978func ResponseInputItemParamOfWebSearchCall(id string, status ResponseFunctionWebSearchStatus) ResponseInputItemUnionParam {
3979	var webSearchCall ResponseFunctionWebSearchParam
3980	webSearchCall.ID = id
3981	webSearchCall.Status = status
3982	return ResponseInputItemUnionParam{OfWebSearchCall: &webSearchCall}
3983}
3984
3985func ResponseInputItemParamOfFunctionCall(arguments string, callID string, name string) ResponseInputItemUnionParam {
3986	var functionCall ResponseFunctionToolCallParam
3987	functionCall.Arguments = arguments
3988	functionCall.CallID = callID
3989	functionCall.Name = name
3990	return ResponseInputItemUnionParam{OfFunctionCall: &functionCall}
3991}
3992
3993func ResponseInputItemParamOfFunctionCallOutput(callID string, output string) ResponseInputItemUnionParam {
3994	var functionCallOutput ResponseInputItemFunctionCallOutputParam
3995	functionCallOutput.CallID = callID
3996	functionCallOutput.Output = output
3997	return ResponseInputItemUnionParam{OfFunctionCallOutput: &functionCallOutput}
3998}
3999
4000func ResponseInputItemParamOfReasoning(id string, summary []ResponseReasoningItemSummaryParam) ResponseInputItemUnionParam {
4001	var reasoning ResponseReasoningItemParam
4002	reasoning.ID = id
4003	reasoning.Summary = summary
4004	return ResponseInputItemUnionParam{OfReasoning: &reasoning}
4005}
4006
4007func ResponseInputItemParamOfItemReference(id string) ResponseInputItemUnionParam {
4008	var itemReference ResponseInputItemItemReferenceParam
4009	itemReference.ID = id
4010	return ResponseInputItemUnionParam{OfItemReference: &itemReference}
4011}
4012
4013// Only one field can be non-zero.
4014//
4015// Use [param.IsOmitted] to confirm if a field is set.
4016type ResponseInputItemUnionParam struct {
4017	OfMessage            *EasyInputMessageParam                    `json:",omitzero,inline"`
4018	OfInputMessage       *ResponseInputItemMessageParam            `json:",omitzero,inline"`
4019	OfOutputMessage      *ResponseOutputMessageParam               `json:",omitzero,inline"`
4020	OfFileSearchCall     *ResponseFileSearchToolCallParam          `json:",omitzero,inline"`
4021	OfComputerCall       *ResponseComputerToolCallParam            `json:",omitzero,inline"`
4022	OfComputerCallOutput *ResponseInputItemComputerCallOutputParam `json:",omitzero,inline"`
4023	OfWebSearchCall      *ResponseFunctionWebSearchParam           `json:",omitzero,inline"`
4024	OfFunctionCall       *ResponseFunctionToolCallParam            `json:",omitzero,inline"`
4025	OfFunctionCallOutput *ResponseInputItemFunctionCallOutputParam `json:",omitzero,inline"`
4026	OfReasoning          *ResponseReasoningItemParam               `json:",omitzero,inline"`
4027	OfItemReference      *ResponseInputItemItemReferenceParam      `json:",omitzero,inline"`
4028	paramUnion
4029}
4030
4031// IsPresent returns true if the field's value is not omitted and not the JSON
4032// "null". To check if this field is omitted, use [param.IsOmitted].
4033func (u ResponseInputItemUnionParam) IsPresent() bool { return !param.IsOmitted(u) && !u.IsNull() }
4034func (u ResponseInputItemUnionParam) MarshalJSON() ([]byte, error) {
4035	return param.MarshalUnion[ResponseInputItemUnionParam](u.OfMessage,
4036		u.OfInputMessage,
4037		u.OfOutputMessage,
4038		u.OfFileSearchCall,
4039		u.OfComputerCall,
4040		u.OfComputerCallOutput,
4041		u.OfWebSearchCall,
4042		u.OfFunctionCall,
4043		u.OfFunctionCallOutput,
4044		u.OfReasoning,
4045		u.OfItemReference)
4046}
4047
4048func (u *ResponseInputItemUnionParam) asAny() any {
4049	if !param.IsOmitted(u.OfMessage) {
4050		return u.OfMessage
4051	} else if !param.IsOmitted(u.OfInputMessage) {
4052		return u.OfInputMessage
4053	} else if !param.IsOmitted(u.OfOutputMessage) {
4054		return u.OfOutputMessage
4055	} else if !param.IsOmitted(u.OfFileSearchCall) {
4056		return u.OfFileSearchCall
4057	} else if !param.IsOmitted(u.OfComputerCall) {
4058		return u.OfComputerCall
4059	} else if !param.IsOmitted(u.OfComputerCallOutput) {
4060		return u.OfComputerCallOutput
4061	} else if !param.IsOmitted(u.OfWebSearchCall) {
4062		return u.OfWebSearchCall
4063	} else if !param.IsOmitted(u.OfFunctionCall) {
4064		return u.OfFunctionCall
4065	} else if !param.IsOmitted(u.OfFunctionCallOutput) {
4066		return u.OfFunctionCallOutput
4067	} else if !param.IsOmitted(u.OfReasoning) {
4068		return u.OfReasoning
4069	} else if !param.IsOmitted(u.OfItemReference) {
4070		return u.OfItemReference
4071	}
4072	return nil
4073}
4074
4075// Returns a pointer to the underlying variant's property, if present.
4076func (u ResponseInputItemUnionParam) GetQueries() []string {
4077	if vt := u.OfFileSearchCall; vt != nil {
4078		return vt.Queries
4079	}
4080	return nil
4081}
4082
4083// Returns a pointer to the underlying variant's property, if present.
4084func (u ResponseInputItemUnionParam) GetResults() []ResponseFileSearchToolCallResultParam {
4085	if vt := u.OfFileSearchCall; vt != nil {
4086		return vt.Results
4087	}
4088	return nil
4089}
4090
4091// Returns a pointer to the underlying variant's property, if present.
4092func (u ResponseInputItemUnionParam) GetAction() *ResponseComputerToolCallActionUnionParam {
4093	if vt := u.OfComputerCall; vt != nil {
4094		return &vt.Action
4095	}
4096	return nil
4097}
4098
4099// Returns a pointer to the underlying variant's property, if present.
4100func (u ResponseInputItemUnionParam) GetPendingSafetyChecks() []ResponseComputerToolCallPendingSafetyCheckParam {
4101	if vt := u.OfComputerCall; vt != nil {
4102		return vt.PendingSafetyChecks
4103	}
4104	return nil
4105}
4106
4107// Returns a pointer to the underlying variant's property, if present.
4108func (u ResponseInputItemUnionParam) GetAcknowledgedSafetyChecks() []ResponseInputItemComputerCallOutputAcknowledgedSafetyCheckParam {
4109	if vt := u.OfComputerCallOutput; vt != nil {
4110		return vt.AcknowledgedSafetyChecks
4111	}
4112	return nil
4113}
4114
4115// Returns a pointer to the underlying variant's property, if present.
4116func (u ResponseInputItemUnionParam) GetArguments() *string {
4117	if vt := u.OfFunctionCall; vt != nil {
4118		return &vt.Arguments
4119	}
4120	return nil
4121}
4122
4123// Returns a pointer to the underlying variant's property, if present.
4124func (u ResponseInputItemUnionParam) GetName() *string {
4125	if vt := u.OfFunctionCall; vt != nil {
4126		return &vt.Name
4127	}
4128	return nil
4129}
4130
4131// Returns a pointer to the underlying variant's property, if present.
4132func (u ResponseInputItemUnionParam) GetSummary() []ResponseReasoningItemSummaryParam {
4133	if vt := u.OfReasoning; vt != nil {
4134		return vt.Summary
4135	}
4136	return nil
4137}
4138
4139// Returns a pointer to the underlying variant's property, if present.
4140func (u ResponseInputItemUnionParam) GetRole() *string {
4141	if vt := u.OfMessage; vt != nil {
4142		return (*string)(&vt.Role)
4143	} else if vt := u.OfInputMessage; vt != nil {
4144		return (*string)(&vt.Role)
4145	} else if vt := u.OfOutputMessage; vt != nil {
4146		return (*string)(&vt.Role)
4147	}
4148	return nil
4149}
4150
4151// Returns a pointer to the underlying variant's property, if present.
4152func (u ResponseInputItemUnionParam) GetType() *string {
4153	if vt := u.OfMessage; vt != nil {
4154		return (*string)(&vt.Type)
4155	} else if vt := u.OfInputMessage; vt != nil {
4156		return (*string)(&vt.Type)
4157	} else if vt := u.OfOutputMessage; vt != nil {
4158		return (*string)(&vt.Type)
4159	} else if vt := u.OfFileSearchCall; vt != nil {
4160		return (*string)(&vt.Type)
4161	} else if vt := u.OfComputerCall; vt != nil {
4162		return (*string)(&vt.Type)
4163	} else if vt := u.OfComputerCallOutput; vt != nil {
4164		return (*string)(&vt.Type)
4165	} else if vt := u.OfWebSearchCall; vt != nil {
4166		return (*string)(&vt.Type)
4167	} else if vt := u.OfFunctionCall; vt != nil {
4168		return (*string)(&vt.Type)
4169	} else if vt := u.OfFunctionCallOutput; vt != nil {
4170		return (*string)(&vt.Type)
4171	} else if vt := u.OfReasoning; vt != nil {
4172		return (*string)(&vt.Type)
4173	} else if vt := u.OfItemReference; vt != nil {
4174		return (*string)(&vt.Type)
4175	}
4176	return nil
4177}
4178
4179// Returns a pointer to the underlying variant's property, if present.
4180func (u ResponseInputItemUnionParam) GetStatus() *string {
4181	if vt := u.OfInputMessage; vt != nil {
4182		return (*string)(&vt.Status)
4183	} else if vt := u.OfOutputMessage; vt != nil {
4184		return (*string)(&vt.Status)
4185	} else if vt := u.OfFileSearchCall; vt != nil {
4186		return (*string)(&vt.Status)
4187	} else if vt := u.OfComputerCall; vt != nil {
4188		return (*string)(&vt.Status)
4189	} else if vt := u.OfComputerCallOutput; vt != nil {
4190		return (*string)(&vt.Status)
4191	} else if vt := u.OfWebSearchCall; vt != nil {
4192		return (*string)(&vt.Status)
4193	} else if vt := u.OfFunctionCall; vt != nil {
4194		return (*string)(&vt.Status)
4195	} else if vt := u.OfFunctionCallOutput; vt != nil {
4196		return (*string)(&vt.Status)
4197	} else if vt := u.OfReasoning; vt != nil {
4198		return (*string)(&vt.Status)
4199	}
4200	return nil
4201}
4202
4203// Returns a pointer to the underlying variant's property, if present.
4204func (u ResponseInputItemUnionParam) GetID() *string {
4205	if vt := u.OfOutputMessage; vt != nil {
4206		return (*string)(&vt.ID)
4207	} else if vt := u.OfFileSearchCall; vt != nil {
4208		return (*string)(&vt.ID)
4209	} else if vt := u.OfComputerCall; vt != nil {
4210		return (*string)(&vt.ID)
4211	} else if vt := u.OfComputerCallOutput; vt != nil && vt.ID.IsPresent() {
4212		return &vt.ID.Value
4213	} else if vt := u.OfWebSearchCall; vt != nil {
4214		return (*string)(&vt.ID)
4215	} else if vt := u.OfFunctionCall; vt != nil && vt.ID.IsPresent() {
4216		return &vt.ID.Value
4217	} else if vt := u.OfFunctionCallOutput; vt != nil && vt.ID.IsPresent() {
4218		return &vt.ID.Value
4219	} else if vt := u.OfReasoning; vt != nil {
4220		return (*string)(&vt.ID)
4221	} else if vt := u.OfItemReference; vt != nil {
4222		return (*string)(&vt.ID)
4223	}
4224	return nil
4225}
4226
4227// Returns a pointer to the underlying variant's property, if present.
4228func (u ResponseInputItemUnionParam) GetCallID() *string {
4229	if vt := u.OfComputerCall; vt != nil {
4230		return (*string)(&vt.CallID)
4231	} else if vt := u.OfComputerCallOutput; vt != nil {
4232		return (*string)(&vt.CallID)
4233	} else if vt := u.OfFunctionCall; vt != nil {
4234		return (*string)(&vt.CallID)
4235	} else if vt := u.OfFunctionCallOutput; vt != nil {
4236		return (*string)(&vt.CallID)
4237	}
4238	return nil
4239}
4240
4241// Returns a subunion which exports methods to access subproperties
4242//
4243// Or use AsAny() to get the underlying value
4244func (u ResponseInputItemUnionParam) GetContent() (res responseInputItemUnionParamContent) {
4245	if vt := u.OfMessage; vt != nil {
4246		res.ofEasyInputMessageContentUnion = &vt.Content
4247	} else if vt := u.OfInputMessage; vt != nil {
4248		res.ofResponseInputMessageContentList = &vt.Content
4249	} else if vt := u.OfOutputMessage; vt != nil {
4250		res.ofResponseOutputMessageContent = &vt.Content
4251	}
4252	return
4253}
4254
4255// Only one field can be non-zero.
4256//
4257// Use [param.IsOmitted] to confirm if a field is set.
4258type responseInputItemUnionParamContent struct {
4259	ofEasyInputMessageContentUnion    *EasyInputMessageContentUnionParam
4260	ofResponseInputMessageContentList *ResponseInputMessageContentListParam
4261	ofResponseOutputMessageContent    *[]ResponseOutputMessageContentUnionParam
4262}
4263
4264// Use the following switch statement to get the type of the union:
4265//
4266//	switch u.AsAny().(type) {
4267//	case *string:
4268//	case *responses.ResponseInputMessageContentListParam:
4269//	case *[]responses.ResponseOutputMessageContentUnionParam:
4270//	default:
4271//	    fmt.Errorf("not present")
4272//	}
4273func (u responseInputItemUnionParamContent) AsAny() any {
4274	if !param.IsOmitted(u.ofEasyInputMessageContentUnion) {
4275		return u.ofEasyInputMessageContentUnion.asAny()
4276	} else if !param.IsOmitted(u.ofResponseInputMessageContentList) {
4277		return u.ofResponseInputMessageContentList
4278	} else if !param.IsOmitted(u.ofResponseOutputMessageContent) {
4279		return u.ofResponseOutputMessageContent
4280	}
4281	return nil
4282}
4283
4284// Returns a subunion which exports methods to access subproperties
4285//
4286// Or use AsAny() to get the underlying value
4287func (u ResponseInputItemUnionParam) GetOutput() (res responseInputItemUnionParamOutput) {
4288	if vt := u.OfComputerCallOutput; vt != nil {
4289		res.ofResponseComputerToolCallOutputScreenshot = &vt.Output
4290	} else if vt := u.OfFunctionCallOutput; vt != nil {
4291		res.ofString = &vt.Output
4292	}
4293	return
4294}
4295
4296// Only one field can be non-zero.
4297//
4298// Use [param.IsOmitted] to confirm if a field is set.
4299type responseInputItemUnionParamOutput struct {
4300	ofResponseComputerToolCallOutputScreenshot *ResponseComputerToolCallOutputScreenshotParam
4301	ofString                                   *string
4302}
4303
4304// Use the following switch statement to get the type of the union:
4305//
4306//	switch u.AsAny().(type) {
4307//	case *responses.ResponseComputerToolCallOutputScreenshotParam:
4308//	case *string:
4309//	default:
4310//	    fmt.Errorf("not present")
4311//	}
4312func (u responseInputItemUnionParamOutput) AsAny() any {
4313	if !param.IsOmitted(u.ofResponseComputerToolCallOutputScreenshot) {
4314		return u.ofResponseComputerToolCallOutputScreenshot
4315	} else if !param.IsOmitted(u.ofString) {
4316		return u.ofString
4317	}
4318	return nil
4319}
4320
4321// Returns a pointer to the underlying variant's property, if present.
4322func (u responseInputItemUnionParamOutput) GetType() *string {
4323	if vt := u.ofResponseComputerToolCallOutputScreenshot; vt != nil {
4324		return (*string)(&vt.Type)
4325	}
4326	return nil
4327}
4328
4329// Returns a pointer to the underlying variant's property, if present.
4330func (u responseInputItemUnionParamOutput) GetFileID() *string {
4331	if vt := u.ofResponseComputerToolCallOutputScreenshot; vt != nil && vt.FileID.IsPresent() {
4332		return &vt.FileID.Value
4333	}
4334	return nil
4335}
4336
4337// Returns a pointer to the underlying variant's property, if present.
4338func (u responseInputItemUnionParamOutput) GetImageURL() *string {
4339	if vt := u.ofResponseComputerToolCallOutputScreenshot; vt != nil && vt.ImageURL.IsPresent() {
4340		return &vt.ImageURL.Value
4341	}
4342	return nil
4343}
4344
4345func init() {
4346	apijson.RegisterUnion[ResponseInputItemUnionParam](
4347		"type",
4348		apijson.UnionVariant{
4349			TypeFilter:         gjson.JSON,
4350			Type:               reflect.TypeOf(EasyInputMessageParam{}),
4351			DiscriminatorValue: "message",
4352		},
4353		apijson.UnionVariant{
4354			TypeFilter:         gjson.JSON,
4355			Type:               reflect.TypeOf(ResponseInputItemMessageParam{}),
4356			DiscriminatorValue: "message",
4357		},
4358		apijson.UnionVariant{
4359			TypeFilter:         gjson.JSON,
4360			Type:               reflect.TypeOf(ResponseOutputMessageParam{}),
4361			DiscriminatorValue: "message",
4362		},
4363		apijson.UnionVariant{
4364			TypeFilter:         gjson.JSON,
4365			Type:               reflect.TypeOf(ResponseFileSearchToolCallParam{}),
4366			DiscriminatorValue: "file_search_call",
4367		},
4368		apijson.UnionVariant{
4369			TypeFilter:         gjson.JSON,
4370			Type:               reflect.TypeOf(ResponseComputerToolCallParam{}),
4371			DiscriminatorValue: "computer_call",
4372		},
4373		apijson.UnionVariant{
4374			TypeFilter:         gjson.JSON,
4375			Type:               reflect.TypeOf(ResponseInputItemComputerCallOutputParam{}),
4376			DiscriminatorValue: "computer_call_output",
4377		},
4378		apijson.UnionVariant{
4379			TypeFilter:         gjson.JSON,
4380			Type:               reflect.TypeOf(ResponseFunctionWebSearchParam{}),
4381			DiscriminatorValue: "web_search_call",
4382		},
4383		apijson.UnionVariant{
4384			TypeFilter:         gjson.JSON,
4385			Type:               reflect.TypeOf(ResponseFunctionToolCallParam{}),
4386			DiscriminatorValue: "function_call",
4387		},
4388		apijson.UnionVariant{
4389			TypeFilter:         gjson.JSON,
4390			Type:               reflect.TypeOf(ResponseInputItemFunctionCallOutputParam{}),
4391			DiscriminatorValue: "function_call_output",
4392		},
4393		apijson.UnionVariant{
4394			TypeFilter:         gjson.JSON,
4395			Type:               reflect.TypeOf(ResponseReasoningItemParam{}),
4396			DiscriminatorValue: "reasoning",
4397		},
4398		apijson.UnionVariant{
4399			TypeFilter:         gjson.JSON,
4400			Type:               reflect.TypeOf(ResponseInputItemItemReferenceParam{}),
4401			DiscriminatorValue: "item_reference",
4402		},
4403	)
4404}
4405
4406// A message input to the model with a role indicating instruction following
4407// hierarchy. Instructions given with the `developer` or `system` role take
4408// precedence over instructions given with the `user` role.
4409//
4410// The properties Content, Role are required.
4411type ResponseInputItemMessageParam struct {
4412	// A list of one or many input items to the model, containing different content
4413	// types.
4414	Content ResponseInputMessageContentListParam `json:"content,omitzero,required"`
4415	// The role of the message input. One of `user`, `system`, or `developer`.
4416	//
4417	// Any of "user", "system", "developer".
4418	Role string `json:"role,omitzero,required"`
4419	// The status of item. One of `in_progress`, `completed`, or `incomplete`.
4420	// Populated when items are returned via API.
4421	//
4422	// Any of "in_progress", "completed", "incomplete".
4423	Status string `json:"status,omitzero"`
4424	// The type of the message input. Always set to `message`.
4425	//
4426	// Any of "message".
4427	Type string `json:"type,omitzero"`
4428	paramObj
4429}
4430
4431// IsPresent returns true if the field's value is not omitted and not the JSON
4432// "null". To check if this field is omitted, use [param.IsOmitted].
4433func (f ResponseInputItemMessageParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
4434func (r ResponseInputItemMessageParam) MarshalJSON() (data []byte, err error) {
4435	type shadow ResponseInputItemMessageParam
4436	return param.MarshalObject(r, (*shadow)(&r))
4437}
4438
4439func init() {
4440	apijson.RegisterFieldValidator[ResponseInputItemMessageParam](
4441		"Role", false, "user", "system", "developer",
4442	)
4443	apijson.RegisterFieldValidator[ResponseInputItemMessageParam](
4444		"Status", false, "in_progress", "completed", "incomplete",
4445	)
4446	apijson.RegisterFieldValidator[ResponseInputItemMessageParam](
4447		"Type", false, "message",
4448	)
4449}
4450
4451// The output of a computer tool call.
4452//
4453// The properties CallID, Output, Type are required.
4454type ResponseInputItemComputerCallOutputParam struct {
4455	// The ID of the computer tool call that produced the output.
4456	CallID string `json:"call_id,required"`
4457	// A computer screenshot image used with the computer use tool.
4458	Output ResponseComputerToolCallOutputScreenshotParam `json:"output,omitzero,required"`
4459	// The ID of the computer tool call output.
4460	ID param.Opt[string] `json:"id,omitzero"`
4461	// The safety checks reported by the API that have been acknowledged by the
4462	// developer.
4463	AcknowledgedSafetyChecks []ResponseInputItemComputerCallOutputAcknowledgedSafetyCheckParam `json:"acknowledged_safety_checks,omitzero"`
4464	// The status of the message input. One of `in_progress`, `completed`, or
4465	// `incomplete`. Populated when input items are returned via API.
4466	//
4467	// Any of "in_progress", "completed", "incomplete".
4468	Status string `json:"status,omitzero"`
4469	// The type of the computer tool call output. Always `computer_call_output`.
4470	//
4471	// This field can be elided, and will marshal its zero value as
4472	// "computer_call_output".
4473	Type constant.ComputerCallOutput `json:"type,required"`
4474	paramObj
4475}
4476
4477// IsPresent returns true if the field's value is not omitted and not the JSON
4478// "null". To check if this field is omitted, use [param.IsOmitted].
4479func (f ResponseInputItemComputerCallOutputParam) IsPresent() bool {
4480	return !param.IsOmitted(f) && !f.IsNull()
4481}
4482func (r ResponseInputItemComputerCallOutputParam) MarshalJSON() (data []byte, err error) {
4483	type shadow ResponseInputItemComputerCallOutputParam
4484	return param.MarshalObject(r, (*shadow)(&r))
4485}
4486
4487func init() {
4488	apijson.RegisterFieldValidator[ResponseInputItemComputerCallOutputParam](
4489		"Status", false, "in_progress", "completed", "incomplete",
4490	)
4491}
4492
4493// A pending safety check for the computer call.
4494//
4495// The properties ID, Code, Message are required.
4496type ResponseInputItemComputerCallOutputAcknowledgedSafetyCheckParam struct {
4497	// The ID of the pending safety check.
4498	ID string `json:"id,required"`
4499	// The type of the pending safety check.
4500	Code string `json:"code,required"`
4501	// Details about the pending safety check.
4502	Message string `json:"message,required"`
4503	paramObj
4504}
4505
4506// IsPresent returns true if the field's value is not omitted and not the JSON
4507// "null". To check if this field is omitted, use [param.IsOmitted].
4508func (f ResponseInputItemComputerCallOutputAcknowledgedSafetyCheckParam) IsPresent() bool {
4509	return !param.IsOmitted(f) && !f.IsNull()
4510}
4511func (r ResponseInputItemComputerCallOutputAcknowledgedSafetyCheckParam) MarshalJSON() (data []byte, err error) {
4512	type shadow ResponseInputItemComputerCallOutputAcknowledgedSafetyCheckParam
4513	return param.MarshalObject(r, (*shadow)(&r))
4514}
4515
4516// The output of a function tool call.
4517//
4518// The properties CallID, Output, Type are required.
4519type ResponseInputItemFunctionCallOutputParam struct {
4520	// The unique ID of the function tool call generated by the model.
4521	CallID string `json:"call_id,required"`
4522	// A JSON string of the output of the function tool call.
4523	Output string `json:"output,required"`
4524	// The unique ID of the function tool call output. Populated when this item is
4525	// returned via API.
4526	ID param.Opt[string] `json:"id,omitzero"`
4527	// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
4528	// Populated when items are returned via API.
4529	//
4530	// Any of "in_progress", "completed", "incomplete".
4531	Status string `json:"status,omitzero"`
4532	// The type of the function tool call output. Always `function_call_output`.
4533	//
4534	// This field can be elided, and will marshal its zero value as
4535	// "function_call_output".
4536	Type constant.FunctionCallOutput `json:"type,required"`
4537	paramObj
4538}
4539
4540// IsPresent returns true if the field's value is not omitted and not the JSON
4541// "null". To check if this field is omitted, use [param.IsOmitted].
4542func (f ResponseInputItemFunctionCallOutputParam) IsPresent() bool {
4543	return !param.IsOmitted(f) && !f.IsNull()
4544}
4545func (r ResponseInputItemFunctionCallOutputParam) MarshalJSON() (data []byte, err error) {
4546	type shadow ResponseInputItemFunctionCallOutputParam
4547	return param.MarshalObject(r, (*shadow)(&r))
4548}
4549
4550func init() {
4551	apijson.RegisterFieldValidator[ResponseInputItemFunctionCallOutputParam](
4552		"Status", false, "in_progress", "completed", "incomplete",
4553	)
4554}
4555
4556// An internal identifier for an item to reference.
4557//
4558// The properties ID, Type are required.
4559type ResponseInputItemItemReferenceParam struct {
4560	// The ID of the item to reference.
4561	ID string `json:"id,required"`
4562	// The type of item to reference. Always `item_reference`.
4563	//
4564	// This field can be elided, and will marshal its zero value as "item_reference".
4565	Type constant.ItemReference `json:"type,required"`
4566	paramObj
4567}
4568
4569// IsPresent returns true if the field's value is not omitted and not the JSON
4570// "null". To check if this field is omitted, use [param.IsOmitted].
4571func (f ResponseInputItemItemReferenceParam) IsPresent() bool {
4572	return !param.IsOmitted(f) && !f.IsNull()
4573}
4574func (r ResponseInputItemItemReferenceParam) MarshalJSON() (data []byte, err error) {
4575	type shadow ResponseInputItemItemReferenceParam
4576	return param.MarshalObject(r, (*shadow)(&r))
4577}
4578
4579type ResponseInputMessageContentList []ResponseInputContentUnion
4580
4581type ResponseInputMessageContentListParam []ResponseInputContentUnionParam
4582
4583type ResponseInputMessageItem struct {
4584	// The unique ID of the message input.
4585	ID string `json:"id,required"`
4586	// A list of one or many input items to the model, containing different content
4587	// types.
4588	Content ResponseInputMessageContentList `json:"content,required"`
4589	// The role of the message input. One of `user`, `system`, or `developer`.
4590	//
4591	// Any of "user", "system", "developer".
4592	Role ResponseInputMessageItemRole `json:"role,required"`
4593	// The status of item. One of `in_progress`, `completed`, or `incomplete`.
4594	// Populated when items are returned via API.
4595	//
4596	// Any of "in_progress", "completed", "incomplete".
4597	Status ResponseInputMessageItemStatus `json:"status"`
4598	// The type of the message input. Always set to `message`.
4599	//
4600	// Any of "message".
4601	Type ResponseInputMessageItemType `json:"type"`
4602	// Metadata for the response, check the presence of optional fields with the
4603	// [resp.Field.IsPresent] method.
4604	JSON struct {
4605		ID          resp.Field
4606		Content     resp.Field
4607		Role        resp.Field
4608		Status      resp.Field
4609		Type        resp.Field
4610		ExtraFields map[string]resp.Field
4611		raw         string
4612	} `json:"-"`
4613}
4614
4615// Returns the unmodified JSON received from the API
4616func (r ResponseInputMessageItem) RawJSON() string { return r.JSON.raw }
4617func (r *ResponseInputMessageItem) UnmarshalJSON(data []byte) error {
4618	return apijson.UnmarshalRoot(data, r)
4619}
4620
4621// The role of the message input. One of `user`, `system`, or `developer`.
4622type ResponseInputMessageItemRole string
4623
4624const (
4625	ResponseInputMessageItemRoleUser      ResponseInputMessageItemRole = "user"
4626	ResponseInputMessageItemRoleSystem    ResponseInputMessageItemRole = "system"
4627	ResponseInputMessageItemRoleDeveloper ResponseInputMessageItemRole = "developer"
4628)
4629
4630// The status of item. One of `in_progress`, `completed`, or `incomplete`.
4631// Populated when items are returned via API.
4632type ResponseInputMessageItemStatus string
4633
4634const (
4635	ResponseInputMessageItemStatusInProgress ResponseInputMessageItemStatus = "in_progress"
4636	ResponseInputMessageItemStatusCompleted  ResponseInputMessageItemStatus = "completed"
4637	ResponseInputMessageItemStatusIncomplete ResponseInputMessageItemStatus = "incomplete"
4638)
4639
4640// The type of the message input. Always set to `message`.
4641type ResponseInputMessageItemType string
4642
4643const (
4644	ResponseInputMessageItemTypeMessage ResponseInputMessageItemType = "message"
4645)
4646
4647// A text input to the model.
4648type ResponseInputText struct {
4649	// The text input to the model.
4650	Text string `json:"text,required"`
4651	// The type of the input item. Always `input_text`.
4652	Type constant.InputText `json:"type,required"`
4653	// Metadata for the response, check the presence of optional fields with the
4654	// [resp.Field.IsPresent] method.
4655	JSON struct {
4656		Text        resp.Field
4657		Type        resp.Field
4658		ExtraFields map[string]resp.Field
4659		raw         string
4660	} `json:"-"`
4661}
4662
4663// Returns the unmodified JSON received from the API
4664func (r ResponseInputText) RawJSON() string { return r.JSON.raw }
4665func (r *ResponseInputText) UnmarshalJSON(data []byte) error {
4666	return apijson.UnmarshalRoot(data, r)
4667}
4668
4669// ToParam converts this ResponseInputText to a ResponseInputTextParam.
4670//
4671// Warning: the fields of the param type will not be present. ToParam should only
4672// be used at the last possible moment before sending a request. Test for this with
4673// ResponseInputTextParam.IsOverridden()
4674func (r ResponseInputText) ToParam() ResponseInputTextParam {
4675	return param.OverrideObj[ResponseInputTextParam](r.RawJSON())
4676}
4677
4678// A text input to the model.
4679//
4680// The properties Text, Type are required.
4681type ResponseInputTextParam struct {
4682	// The text input to the model.
4683	Text string `json:"text,required"`
4684	// The type of the input item. Always `input_text`.
4685	//
4686	// This field can be elided, and will marshal its zero value as "input_text".
4687	Type constant.InputText `json:"type,required"`
4688	paramObj
4689}
4690
4691// IsPresent returns true if the field's value is not omitted and not the JSON
4692// "null". To check if this field is omitted, use [param.IsOmitted].
4693func (f ResponseInputTextParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
4694func (r ResponseInputTextParam) MarshalJSON() (data []byte, err error) {
4695	type shadow ResponseInputTextParam
4696	return param.MarshalObject(r, (*shadow)(&r))
4697}
4698
4699// ResponseItemUnion contains all possible properties and values from
4700// [ResponseInputMessageItem], [ResponseOutputMessage],
4701// [ResponseFileSearchToolCall], [ResponseComputerToolCall],
4702// [ResponseComputerToolCallOutputItem], [ResponseFunctionWebSearch],
4703// [ResponseFunctionToolCallItem], [ResponseFunctionToolCallOutputItem].
4704//
4705// Use the [ResponseItemUnion.AsAny] method to switch on the variant.
4706//
4707// Use the methods beginning with 'As' to cast the union to one of its variants.
4708type ResponseItemUnion struct {
4709	ID string `json:"id"`
4710	// This field is a union of [ResponseInputMessageContentList],
4711	// [[]ResponseOutputMessageContentUnion]
4712	Content ResponseItemUnionContent `json:"content"`
4713	Role    string                   `json:"role"`
4714	Status  string                   `json:"status"`
4715	// Any of "message", "message", "file_search_call", "computer_call",
4716	// "computer_call_output", "web_search_call", "function_call",
4717	// "function_call_output".
4718	Type string `json:"type"`
4719	// This field is from variant [ResponseFileSearchToolCall].
4720	Queries []string `json:"queries"`
4721	// This field is from variant [ResponseFileSearchToolCall].
4722	Results []ResponseFileSearchToolCallResult `json:"results"`
4723	// This field is from variant [ResponseComputerToolCall].
4724	Action ResponseComputerToolCallActionUnion `json:"action"`
4725	CallID string                              `json:"call_id"`
4726	// This field is from variant [ResponseComputerToolCall].
4727	PendingSafetyChecks []ResponseComputerToolCallPendingSafetyCheck `json:"pending_safety_checks"`
4728	// This field is a union of [ResponseComputerToolCallOutputScreenshot], [string]
4729	Output ResponseItemUnionOutput `json:"output"`
4730	// This field is from variant [ResponseComputerToolCallOutputItem].
4731	AcknowledgedSafetyChecks []ResponseComputerToolCallOutputItemAcknowledgedSafetyCheck `json:"acknowledged_safety_checks"`
4732	// This field is from variant [ResponseFunctionToolCallItem].
4733	Arguments string `json:"arguments"`
4734	// This field is from variant [ResponseFunctionToolCallItem].
4735	Name string `json:"name"`
4736	JSON struct {
4737		ID                       resp.Field
4738		Content                  resp.Field
4739		Role                     resp.Field
4740		Status                   resp.Field
4741		Type                     resp.Field
4742		Queries                  resp.Field
4743		Results                  resp.Field
4744		Action                   resp.Field
4745		CallID                   resp.Field
4746		PendingSafetyChecks      resp.Field
4747		Output                   resp.Field
4748		AcknowledgedSafetyChecks resp.Field
4749		Arguments                resp.Field
4750		Name                     resp.Field
4751		raw                      string
4752	} `json:"-"`
4753}
4754
4755// Use the following switch statement to find the correct variant
4756//
4757//	switch variant := ResponseItemUnion.AsAny().(type) {
4758//	case ResponseInputMessageItem:
4759//	case ResponseOutputMessage:
4760//	case ResponseFileSearchToolCall:
4761//	case ResponseComputerToolCall:
4762//	case ResponseComputerToolCallOutputItem:
4763//	case ResponseFunctionWebSearch:
4764//	case ResponseFunctionToolCallItem:
4765//	case ResponseFunctionToolCallOutputItem:
4766//	default:
4767//	  fmt.Errorf("no variant present")
4768//	}
4769func (u ResponseItemUnion) AsAny() any {
4770	switch u.Type {
4771	case "message":
4772		return u.AsOutputMessage()
4773	case "file_search_call":
4774		return u.AsFileSearchCall()
4775	case "computer_call":
4776		return u.AsComputerCall()
4777	case "computer_call_output":
4778		return u.AsComputerCallOutput()
4779	case "web_search_call":
4780		return u.AsWebSearchCall()
4781	case "function_call":
4782		return u.AsFunctionCall()
4783	case "function_call_output":
4784		return u.AsFunctionCallOutput()
4785	}
4786	return nil
4787}
4788
4789func (u ResponseItemUnion) AsMessage() (v ResponseInputMessageItem) {
4790	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
4791	return
4792}
4793
4794func (u ResponseItemUnion) AsOutputMessage() (v ResponseOutputMessage) {
4795	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
4796	return
4797}
4798
4799func (u ResponseItemUnion) AsFileSearchCall() (v ResponseFileSearchToolCall) {
4800	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
4801	return
4802}
4803
4804func (u ResponseItemUnion) AsComputerCall() (v ResponseComputerToolCall) {
4805	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
4806	return
4807}
4808
4809func (u ResponseItemUnion) AsComputerCallOutput() (v ResponseComputerToolCallOutputItem) {
4810	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
4811	return
4812}
4813
4814func (u ResponseItemUnion) AsWebSearchCall() (v ResponseFunctionWebSearch) {
4815	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
4816	return
4817}
4818
4819func (u ResponseItemUnion) AsFunctionCall() (v ResponseFunctionToolCallItem) {
4820	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
4821	return
4822}
4823
4824func (u ResponseItemUnion) AsFunctionCallOutput() (v ResponseFunctionToolCallOutputItem) {
4825	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
4826	return
4827}
4828
4829// Returns the unmodified JSON received from the API
4830func (u ResponseItemUnion) RawJSON() string { return u.JSON.raw }
4831
4832func (r *ResponseItemUnion) UnmarshalJSON(data []byte) error {
4833	return apijson.UnmarshalRoot(data, r)
4834}
4835
4836// ResponseItemUnionContent is an implicit subunion of [ResponseItemUnion].
4837// ResponseItemUnionContent provides convenient access to the sub-properties of the
4838// union.
4839//
4840// For type safety it is recommended to directly use a variant of the
4841// [ResponseItemUnion].
4842//
4843// If the underlying value is not a json object, one of the following properties
4844// will be valid: OfInputItemContentList OfResponseOutputMessageContent]
4845type ResponseItemUnionContent struct {
4846	// This field will be present if the value is a [ResponseInputMessageContentList]
4847	// instead of an object.
4848	OfInputItemContentList ResponseInputMessageContentList `json:",inline"`
4849	// This field will be present if the value is a
4850	// [[]ResponseOutputMessageContentUnion] instead of an object.
4851	OfResponseOutputMessageContent []ResponseOutputMessageContentUnion `json:",inline"`
4852	JSON                           struct {
4853		OfInputItemContentList         resp.Field
4854		OfResponseOutputMessageContent resp.Field
4855		raw                            string
4856	} `json:"-"`
4857}
4858
4859func (r *ResponseItemUnionContent) UnmarshalJSON(data []byte) error {
4860	return apijson.UnmarshalRoot(data, r)
4861}
4862
4863// ResponseItemUnionOutput is an implicit subunion of [ResponseItemUnion].
4864// ResponseItemUnionOutput provides convenient access to the sub-properties of the
4865// union.
4866//
4867// For type safety it is recommended to directly use a variant of the
4868// [ResponseItemUnion].
4869//
4870// If the underlying value is not a json object, one of the following properties
4871// will be valid: OfString]
4872type ResponseItemUnionOutput struct {
4873	// This field will be present if the value is a [string] instead of an object.
4874	OfString string `json:",inline"`
4875	// This field is from variant [ResponseComputerToolCallOutputScreenshot].
4876	Type constant.ComputerScreenshot `json:"type"`
4877	// This field is from variant [ResponseComputerToolCallOutputScreenshot].
4878	FileID string `json:"file_id"`
4879	// This field is from variant [ResponseComputerToolCallOutputScreenshot].
4880	ImageURL string `json:"image_url"`
4881	JSON     struct {
4882		OfString resp.Field
4883		Type     resp.Field
4884		FileID   resp.Field
4885		ImageURL resp.Field
4886		raw      string
4887	} `json:"-"`
4888}
4889
4890func (r *ResponseItemUnionOutput) UnmarshalJSON(data []byte) error {
4891	return apijson.UnmarshalRoot(data, r)
4892}
4893
4894// ResponseOutputItemUnion contains all possible properties and values from
4895// [ResponseOutputMessage], [ResponseFileSearchToolCall],
4896// [ResponseFunctionToolCall], [ResponseFunctionWebSearch],
4897// [ResponseComputerToolCall], [ResponseReasoningItem].
4898//
4899// Use the [ResponseOutputItemUnion.AsAny] method to switch on the variant.
4900//
4901// Use the methods beginning with 'As' to cast the union to one of its variants.
4902type ResponseOutputItemUnion struct {
4903	ID string `json:"id"`
4904	// This field is from variant [ResponseOutputMessage].
4905	Content []ResponseOutputMessageContentUnion `json:"content"`
4906	// This field is from variant [ResponseOutputMessage].
4907	Role   constant.Assistant `json:"role"`
4908	Status string             `json:"status"`
4909	// Any of "message", "file_search_call", "function_call", "web_search_call",
4910	// "computer_call", "reasoning".
4911	Type string `json:"type"`
4912	// This field is from variant [ResponseFileSearchToolCall].
4913	Queries []string `json:"queries"`
4914	// This field is from variant [ResponseFileSearchToolCall].
4915	Results []ResponseFileSearchToolCallResult `json:"results"`
4916	// This field is from variant [ResponseFunctionToolCall].
4917	Arguments string `json:"arguments"`
4918	CallID    string `json:"call_id"`
4919	// This field is from variant [ResponseFunctionToolCall].
4920	Name string `json:"name"`
4921	// This field is from variant [ResponseComputerToolCall].
4922	Action ResponseComputerToolCallActionUnion `json:"action"`
4923	// This field is from variant [ResponseComputerToolCall].
4924	PendingSafetyChecks []ResponseComputerToolCallPendingSafetyCheck `json:"pending_safety_checks"`
4925	// This field is from variant [ResponseReasoningItem].
4926	Summary []ResponseReasoningItemSummary `json:"summary"`
4927	JSON    struct {
4928		ID                  resp.Field
4929		Content             resp.Field
4930		Role                resp.Field
4931		Status              resp.Field
4932		Type                resp.Field
4933		Queries             resp.Field
4934		Results             resp.Field
4935		Arguments           resp.Field
4936		CallID              resp.Field
4937		Name                resp.Field
4938		Action              resp.Field
4939		PendingSafetyChecks resp.Field
4940		Summary             resp.Field
4941		raw                 string
4942	} `json:"-"`
4943}
4944
4945// Use the following switch statement to find the correct variant
4946//
4947//	switch variant := ResponseOutputItemUnion.AsAny().(type) {
4948//	case ResponseOutputMessage:
4949//	case ResponseFileSearchToolCall:
4950//	case ResponseFunctionToolCall:
4951//	case ResponseFunctionWebSearch:
4952//	case ResponseComputerToolCall:
4953//	case ResponseReasoningItem:
4954//	default:
4955//	  fmt.Errorf("no variant present")
4956//	}
4957func (u ResponseOutputItemUnion) AsAny() any {
4958	switch u.Type {
4959	case "message":
4960		return u.AsMessage()
4961	case "file_search_call":
4962		return u.AsFileSearchCall()
4963	case "function_call":
4964		return u.AsFunctionCall()
4965	case "web_search_call":
4966		return u.AsWebSearchCall()
4967	case "computer_call":
4968		return u.AsComputerCall()
4969	case "reasoning":
4970		return u.AsReasoning()
4971	}
4972	return nil
4973}
4974
4975func (u ResponseOutputItemUnion) AsMessage() (v ResponseOutputMessage) {
4976	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
4977	return
4978}
4979
4980func (u ResponseOutputItemUnion) AsFileSearchCall() (v ResponseFileSearchToolCall) {
4981	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
4982	return
4983}
4984
4985func (u ResponseOutputItemUnion) AsFunctionCall() (v ResponseFunctionToolCall) {
4986	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
4987	return
4988}
4989
4990func (u ResponseOutputItemUnion) AsWebSearchCall() (v ResponseFunctionWebSearch) {
4991	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
4992	return
4993}
4994
4995func (u ResponseOutputItemUnion) AsComputerCall() (v ResponseComputerToolCall) {
4996	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
4997	return
4998}
4999
5000func (u ResponseOutputItemUnion) AsReasoning() (v ResponseReasoningItem) {
5001	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
5002	return
5003}
5004
5005// Returns the unmodified JSON received from the API
5006func (u ResponseOutputItemUnion) RawJSON() string { return u.JSON.raw }
5007
5008func (r *ResponseOutputItemUnion) UnmarshalJSON(data []byte) error {
5009	return apijson.UnmarshalRoot(data, r)
5010}
5011
5012// Emitted when a new output item is added.
5013type ResponseOutputItemAddedEvent struct {
5014	// The output item that was added.
5015	Item ResponseOutputItemUnion `json:"item,required"`
5016	// The index of the output item that was added.
5017	OutputIndex int64 `json:"output_index,required"`
5018	// The type of the event. Always `response.output_item.added`.
5019	Type constant.ResponseOutputItemAdded `json:"type,required"`
5020	// Metadata for the response, check the presence of optional fields with the
5021	// [resp.Field.IsPresent] method.
5022	JSON struct {
5023		Item        resp.Field
5024		OutputIndex resp.Field
5025		Type        resp.Field
5026		ExtraFields map[string]resp.Field
5027		raw         string
5028	} `json:"-"`
5029}
5030
5031// Returns the unmodified JSON received from the API
5032func (r ResponseOutputItemAddedEvent) RawJSON() string { return r.JSON.raw }
5033func (r *ResponseOutputItemAddedEvent) UnmarshalJSON(data []byte) error {
5034	return apijson.UnmarshalRoot(data, r)
5035}
5036
5037// Emitted when an output item is marked done.
5038type ResponseOutputItemDoneEvent struct {
5039	// The output item that was marked done.
5040	Item ResponseOutputItemUnion `json:"item,required"`
5041	// The index of the output item that was marked done.
5042	OutputIndex int64 `json:"output_index,required"`
5043	// The type of the event. Always `response.output_item.done`.
5044	Type constant.ResponseOutputItemDone `json:"type,required"`
5045	// Metadata for the response, check the presence of optional fields with the
5046	// [resp.Field.IsPresent] method.
5047	JSON struct {
5048		Item        resp.Field
5049		OutputIndex resp.Field
5050		Type        resp.Field
5051		ExtraFields map[string]resp.Field
5052		raw         string
5053	} `json:"-"`
5054}
5055
5056// Returns the unmodified JSON received from the API
5057func (r ResponseOutputItemDoneEvent) RawJSON() string { return r.JSON.raw }
5058func (r *ResponseOutputItemDoneEvent) UnmarshalJSON(data []byte) error {
5059	return apijson.UnmarshalRoot(data, r)
5060}
5061
5062// An output message from the model.
5063type ResponseOutputMessage struct {
5064	// The unique ID of the output message.
5065	ID string `json:"id,required"`
5066	// The content of the output message.
5067	Content []ResponseOutputMessageContentUnion `json:"content,required"`
5068	// The role of the output message. Always `assistant`.
5069	Role constant.Assistant `json:"role,required"`
5070	// The status of the message input. One of `in_progress`, `completed`, or
5071	// `incomplete`. Populated when input items are returned via API.
5072	//
5073	// Any of "in_progress", "completed", "incomplete".
5074	Status ResponseOutputMessageStatus `json:"status,required"`
5075	// The type of the output message. Always `message`.
5076	Type constant.Message `json:"type,required"`
5077	// Metadata for the response, check the presence of optional fields with the
5078	// [resp.Field.IsPresent] method.
5079	JSON struct {
5080		ID          resp.Field
5081		Content     resp.Field
5082		Role        resp.Field
5083		Status      resp.Field
5084		Type        resp.Field
5085		ExtraFields map[string]resp.Field
5086		raw         string
5087	} `json:"-"`
5088}
5089
5090// Returns the unmodified JSON received from the API
5091func (r ResponseOutputMessage) RawJSON() string { return r.JSON.raw }
5092func (r *ResponseOutputMessage) UnmarshalJSON(data []byte) error {
5093	return apijson.UnmarshalRoot(data, r)
5094}
5095
5096// ToParam converts this ResponseOutputMessage to a ResponseOutputMessageParam.
5097//
5098// Warning: the fields of the param type will not be present. ToParam should only
5099// be used at the last possible moment before sending a request. Test for this with
5100// ResponseOutputMessageParam.IsOverridden()
5101func (r ResponseOutputMessage) ToParam() ResponseOutputMessageParam {
5102	return param.OverrideObj[ResponseOutputMessageParam](r.RawJSON())
5103}
5104
5105// ResponseOutputMessageContentUnion contains all possible properties and values
5106// from [ResponseOutputText], [ResponseOutputRefusal].
5107//
5108// Use the [ResponseOutputMessageContentUnion.AsAny] method to switch on the
5109// variant.
5110//
5111// Use the methods beginning with 'As' to cast the union to one of its variants.
5112type ResponseOutputMessageContentUnion struct {
5113	// This field is from variant [ResponseOutputText].
5114	Annotations []ResponseOutputTextAnnotationUnion `json:"annotations"`
5115	// This field is from variant [ResponseOutputText].
5116	Text string `json:"text"`
5117	// Any of "output_text", "refusal".
5118	Type string `json:"type"`
5119	// This field is from variant [ResponseOutputRefusal].
5120	Refusal string `json:"refusal"`
5121	JSON    struct {
5122		Annotations resp.Field
5123		Text        resp.Field
5124		Type        resp.Field
5125		Refusal     resp.Field
5126		raw         string
5127	} `json:"-"`
5128}
5129
5130// Use the following switch statement to find the correct variant
5131//
5132//	switch variant := ResponseOutputMessageContentUnion.AsAny().(type) {
5133//	case ResponseOutputText:
5134//	case ResponseOutputRefusal:
5135//	default:
5136//	  fmt.Errorf("no variant present")
5137//	}
5138func (u ResponseOutputMessageContentUnion) AsAny() any {
5139	switch u.Type {
5140	case "output_text":
5141		return u.AsOutputText()
5142	case "refusal":
5143		return u.AsRefusal()
5144	}
5145	return nil
5146}
5147
5148func (u ResponseOutputMessageContentUnion) AsOutputText() (v ResponseOutputText) {
5149	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
5150	return
5151}
5152
5153func (u ResponseOutputMessageContentUnion) AsRefusal() (v ResponseOutputRefusal) {
5154	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
5155	return
5156}
5157
5158// Returns the unmodified JSON received from the API
5159func (u ResponseOutputMessageContentUnion) RawJSON() string { return u.JSON.raw }
5160
5161func (r *ResponseOutputMessageContentUnion) UnmarshalJSON(data []byte) error {
5162	return apijson.UnmarshalRoot(data, r)
5163}
5164
5165// The status of the message input. One of `in_progress`, `completed`, or
5166// `incomplete`. Populated when input items are returned via API.
5167type ResponseOutputMessageStatus string
5168
5169const (
5170	ResponseOutputMessageStatusInProgress ResponseOutputMessageStatus = "in_progress"
5171	ResponseOutputMessageStatusCompleted  ResponseOutputMessageStatus = "completed"
5172	ResponseOutputMessageStatusIncomplete ResponseOutputMessageStatus = "incomplete"
5173)
5174
5175// An output message from the model.
5176//
5177// The properties ID, Content, Role, Status, Type are required.
5178type ResponseOutputMessageParam struct {
5179	// The unique ID of the output message.
5180	ID string `json:"id,required"`
5181	// The content of the output message.
5182	Content []ResponseOutputMessageContentUnionParam `json:"content,omitzero,required"`
5183	// The status of the message input. One of `in_progress`, `completed`, or
5184	// `incomplete`. Populated when input items are returned via API.
5185	//
5186	// Any of "in_progress", "completed", "incomplete".
5187	Status ResponseOutputMessageStatus `json:"status,omitzero,required"`
5188	// The role of the output message. Always `assistant`.
5189	//
5190	// This field can be elided, and will marshal its zero value as "assistant".
5191	Role constant.Assistant `json:"role,required"`
5192	// The type of the output message. Always `message`.
5193	//
5194	// This field can be elided, and will marshal its zero value as "message".
5195	Type constant.Message `json:"type,required"`
5196	paramObj
5197}
5198
5199// IsPresent returns true if the field's value is not omitted and not the JSON
5200// "null". To check if this field is omitted, use [param.IsOmitted].
5201func (f ResponseOutputMessageParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
5202func (r ResponseOutputMessageParam) MarshalJSON() (data []byte, err error) {
5203	type shadow ResponseOutputMessageParam
5204	return param.MarshalObject(r, (*shadow)(&r))
5205}
5206
5207// Only one field can be non-zero.
5208//
5209// Use [param.IsOmitted] to confirm if a field is set.
5210type ResponseOutputMessageContentUnionParam struct {
5211	OfOutputText *ResponseOutputTextParam    `json:",omitzero,inline"`
5212	OfRefusal    *ResponseOutputRefusalParam `json:",omitzero,inline"`
5213	paramUnion
5214}
5215
5216// IsPresent returns true if the field's value is not omitted and not the JSON
5217// "null". To check if this field is omitted, use [param.IsOmitted].
5218func (u ResponseOutputMessageContentUnionParam) IsPresent() bool {
5219	return !param.IsOmitted(u) && !u.IsNull()
5220}
5221func (u ResponseOutputMessageContentUnionParam) MarshalJSON() ([]byte, error) {
5222	return param.MarshalUnion[ResponseOutputMessageContentUnionParam](u.OfOutputText, u.OfRefusal)
5223}
5224
5225func (u *ResponseOutputMessageContentUnionParam) asAny() any {
5226	if !param.IsOmitted(u.OfOutputText) {
5227		return u.OfOutputText
5228	} else if !param.IsOmitted(u.OfRefusal) {
5229		return u.OfRefusal
5230	}
5231	return nil
5232}
5233
5234// Returns a pointer to the underlying variant's property, if present.
5235func (u ResponseOutputMessageContentUnionParam) GetAnnotations() []ResponseOutputTextAnnotationUnionParam {
5236	if vt := u.OfOutputText; vt != nil {
5237		return vt.Annotations
5238	}
5239	return nil
5240}
5241
5242// Returns a pointer to the underlying variant's property, if present.
5243func (u ResponseOutputMessageContentUnionParam) GetText() *string {
5244	if vt := u.OfOutputText; vt != nil {
5245		return &vt.Text
5246	}
5247	return nil
5248}
5249
5250// Returns a pointer to the underlying variant's property, if present.
5251func (u ResponseOutputMessageContentUnionParam) GetRefusal() *string {
5252	if vt := u.OfRefusal; vt != nil {
5253		return &vt.Refusal
5254	}
5255	return nil
5256}
5257
5258// Returns a pointer to the underlying variant's property, if present.
5259func (u ResponseOutputMessageContentUnionParam) GetType() *string {
5260	if vt := u.OfOutputText; vt != nil {
5261		return (*string)(&vt.Type)
5262	} else if vt := u.OfRefusal; vt != nil {
5263		return (*string)(&vt.Type)
5264	}
5265	return nil
5266}
5267
5268func init() {
5269	apijson.RegisterUnion[ResponseOutputMessageContentUnionParam](
5270		"type",
5271		apijson.UnionVariant{
5272			TypeFilter:         gjson.JSON,
5273			Type:               reflect.TypeOf(ResponseOutputTextParam{}),
5274			DiscriminatorValue: "output_text",
5275		},
5276		apijson.UnionVariant{
5277			TypeFilter:         gjson.JSON,
5278			Type:               reflect.TypeOf(ResponseOutputRefusalParam{}),
5279			DiscriminatorValue: "refusal",
5280		},
5281	)
5282}
5283
5284// A refusal from the model.
5285type ResponseOutputRefusal struct {
5286	// The refusal explanationfrom the model.
5287	Refusal string `json:"refusal,required"`
5288	// The type of the refusal. Always `refusal`.
5289	Type constant.Refusal `json:"type,required"`
5290	// Metadata for the response, check the presence of optional fields with the
5291	// [resp.Field.IsPresent] method.
5292	JSON struct {
5293		Refusal     resp.Field
5294		Type        resp.Field
5295		ExtraFields map[string]resp.Field
5296		raw         string
5297	} `json:"-"`
5298}
5299
5300// Returns the unmodified JSON received from the API
5301func (r ResponseOutputRefusal) RawJSON() string { return r.JSON.raw }
5302func (r *ResponseOutputRefusal) UnmarshalJSON(data []byte) error {
5303	return apijson.UnmarshalRoot(data, r)
5304}
5305
5306// ToParam converts this ResponseOutputRefusal to a ResponseOutputRefusalParam.
5307//
5308// Warning: the fields of the param type will not be present. ToParam should only
5309// be used at the last possible moment before sending a request. Test for this with
5310// ResponseOutputRefusalParam.IsOverridden()
5311func (r ResponseOutputRefusal) ToParam() ResponseOutputRefusalParam {
5312	return param.OverrideObj[ResponseOutputRefusalParam](r.RawJSON())
5313}
5314
5315// A refusal from the model.
5316//
5317// The properties Refusal, Type are required.
5318type ResponseOutputRefusalParam struct {
5319	// The refusal explanationfrom the model.
5320	Refusal string `json:"refusal,required"`
5321	// The type of the refusal. Always `refusal`.
5322	//
5323	// This field can be elided, and will marshal its zero value as "refusal".
5324	Type constant.Refusal `json:"type,required"`
5325	paramObj
5326}
5327
5328// IsPresent returns true if the field's value is not omitted and not the JSON
5329// "null". To check if this field is omitted, use [param.IsOmitted].
5330func (f ResponseOutputRefusalParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
5331func (r ResponseOutputRefusalParam) MarshalJSON() (data []byte, err error) {
5332	type shadow ResponseOutputRefusalParam
5333	return param.MarshalObject(r, (*shadow)(&r))
5334}
5335
5336// A text output from the model.
5337type ResponseOutputText struct {
5338	// The annotations of the text output.
5339	Annotations []ResponseOutputTextAnnotationUnion `json:"annotations,required"`
5340	// The text output from the model.
5341	Text string `json:"text,required"`
5342	// The type of the output text. Always `output_text`.
5343	Type constant.OutputText `json:"type,required"`
5344	// Metadata for the response, check the presence of optional fields with the
5345	// [resp.Field.IsPresent] method.
5346	JSON struct {
5347		Annotations resp.Field
5348		Text        resp.Field
5349		Type        resp.Field
5350		ExtraFields map[string]resp.Field
5351		raw         string
5352	} `json:"-"`
5353}
5354
5355// Returns the unmodified JSON received from the API
5356func (r ResponseOutputText) RawJSON() string { return r.JSON.raw }
5357func (r *ResponseOutputText) UnmarshalJSON(data []byte) error {
5358	return apijson.UnmarshalRoot(data, r)
5359}
5360
5361// ToParam converts this ResponseOutputText to a ResponseOutputTextParam.
5362//
5363// Warning: the fields of the param type will not be present. ToParam should only
5364// be used at the last possible moment before sending a request. Test for this with
5365// ResponseOutputTextParam.IsOverridden()
5366func (r ResponseOutputText) ToParam() ResponseOutputTextParam {
5367	return param.OverrideObj[ResponseOutputTextParam](r.RawJSON())
5368}
5369
5370// ResponseOutputTextAnnotationUnion contains all possible properties and values
5371// from [ResponseOutputTextAnnotationFileCitation],
5372// [ResponseOutputTextAnnotationURLCitation],
5373// [ResponseOutputTextAnnotationFilePath].
5374//
5375// Use the [ResponseOutputTextAnnotationUnion.AsAny] method to switch on the
5376// variant.
5377//
5378// Use the methods beginning with 'As' to cast the union to one of its variants.
5379type ResponseOutputTextAnnotationUnion struct {
5380	FileID string `json:"file_id"`
5381	Index  int64  `json:"index"`
5382	// Any of "file_citation", "url_citation", "file_path".
5383	Type string `json:"type"`
5384	// This field is from variant [ResponseOutputTextAnnotationURLCitation].
5385	EndIndex int64 `json:"end_index"`
5386	// This field is from variant [ResponseOutputTextAnnotationURLCitation].
5387	StartIndex int64 `json:"start_index"`
5388	// This field is from variant [ResponseOutputTextAnnotationURLCitation].
5389	Title string `json:"title"`
5390	// This field is from variant [ResponseOutputTextAnnotationURLCitation].
5391	URL  string `json:"url"`
5392	JSON struct {
5393		FileID     resp.Field
5394		Index      resp.Field
5395		Type       resp.Field
5396		EndIndex   resp.Field
5397		StartIndex resp.Field
5398		Title      resp.Field
5399		URL        resp.Field
5400		raw        string
5401	} `json:"-"`
5402}
5403
5404// Use the following switch statement to find the correct variant
5405//
5406//	switch variant := ResponseOutputTextAnnotationUnion.AsAny().(type) {
5407//	case ResponseOutputTextAnnotationFileCitation:
5408//	case ResponseOutputTextAnnotationURLCitation:
5409//	case ResponseOutputTextAnnotationFilePath:
5410//	default:
5411//	  fmt.Errorf("no variant present")
5412//	}
5413func (u ResponseOutputTextAnnotationUnion) AsAny() any {
5414	switch u.Type {
5415	case "file_citation":
5416		return u.AsFileCitation()
5417	case "url_citation":
5418		return u.AsURLCitation()
5419	case "file_path":
5420		return u.AsFilePath()
5421	}
5422	return nil
5423}
5424
5425func (u ResponseOutputTextAnnotationUnion) AsFileCitation() (v ResponseOutputTextAnnotationFileCitation) {
5426	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
5427	return
5428}
5429
5430func (u ResponseOutputTextAnnotationUnion) AsURLCitation() (v ResponseOutputTextAnnotationURLCitation) {
5431	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
5432	return
5433}
5434
5435func (u ResponseOutputTextAnnotationUnion) AsFilePath() (v ResponseOutputTextAnnotationFilePath) {
5436	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
5437	return
5438}
5439
5440// Returns the unmodified JSON received from the API
5441func (u ResponseOutputTextAnnotationUnion) RawJSON() string { return u.JSON.raw }
5442
5443func (r *ResponseOutputTextAnnotationUnion) UnmarshalJSON(data []byte) error {
5444	return apijson.UnmarshalRoot(data, r)
5445}
5446
5447// A citation to a file.
5448type ResponseOutputTextAnnotationFileCitation struct {
5449	// The ID of the file.
5450	FileID string `json:"file_id,required"`
5451	// The index of the file in the list of files.
5452	Index int64 `json:"index,required"`
5453	// The type of the file citation. Always `file_citation`.
5454	Type constant.FileCitation `json:"type,required"`
5455	// Metadata for the response, check the presence of optional fields with the
5456	// [resp.Field.IsPresent] method.
5457	JSON struct {
5458		FileID      resp.Field
5459		Index       resp.Field
5460		Type        resp.Field
5461		ExtraFields map[string]resp.Field
5462		raw         string
5463	} `json:"-"`
5464}
5465
5466// Returns the unmodified JSON received from the API
5467func (r ResponseOutputTextAnnotationFileCitation) RawJSON() string { return r.JSON.raw }
5468func (r *ResponseOutputTextAnnotationFileCitation) UnmarshalJSON(data []byte) error {
5469	return apijson.UnmarshalRoot(data, r)
5470}
5471
5472// A citation for a web resource used to generate a model response.
5473type ResponseOutputTextAnnotationURLCitation struct {
5474	// The index of the last character of the URL citation in the message.
5475	EndIndex int64 `json:"end_index,required"`
5476	// The index of the first character of the URL citation in the message.
5477	StartIndex int64 `json:"start_index,required"`
5478	// The title of the web resource.
5479	Title string `json:"title,required"`
5480	// The type of the URL citation. Always `url_citation`.
5481	Type constant.URLCitation `json:"type,required"`
5482	// The URL of the web resource.
5483	URL string `json:"url,required"`
5484	// Metadata for the response, check the presence of optional fields with the
5485	// [resp.Field.IsPresent] method.
5486	JSON struct {
5487		EndIndex    resp.Field
5488		StartIndex  resp.Field
5489		Title       resp.Field
5490		Type        resp.Field
5491		URL         resp.Field
5492		ExtraFields map[string]resp.Field
5493		raw         string
5494	} `json:"-"`
5495}
5496
5497// Returns the unmodified JSON received from the API
5498func (r ResponseOutputTextAnnotationURLCitation) RawJSON() string { return r.JSON.raw }
5499func (r *ResponseOutputTextAnnotationURLCitation) UnmarshalJSON(data []byte) error {
5500	return apijson.UnmarshalRoot(data, r)
5501}
5502
5503// A path to a file.
5504type ResponseOutputTextAnnotationFilePath struct {
5505	// The ID of the file.
5506	FileID string `json:"file_id,required"`
5507	// The index of the file in the list of files.
5508	Index int64 `json:"index,required"`
5509	// The type of the file path. Always `file_path`.
5510	Type constant.FilePath `json:"type,required"`
5511	// Metadata for the response, check the presence of optional fields with the
5512	// [resp.Field.IsPresent] method.
5513	JSON struct {
5514		FileID      resp.Field
5515		Index       resp.Field
5516		Type        resp.Field
5517		ExtraFields map[string]resp.Field
5518		raw         string
5519	} `json:"-"`
5520}
5521
5522// Returns the unmodified JSON received from the API
5523func (r ResponseOutputTextAnnotationFilePath) RawJSON() string { return r.JSON.raw }
5524func (r *ResponseOutputTextAnnotationFilePath) UnmarshalJSON(data []byte) error {
5525	return apijson.UnmarshalRoot(data, r)
5526}
5527
5528// A text output from the model.
5529//
5530// The properties Annotations, Text, Type are required.
5531type ResponseOutputTextParam struct {
5532	// The annotations of the text output.
5533	Annotations []ResponseOutputTextAnnotationUnionParam `json:"annotations,omitzero,required"`
5534	// The text output from the model.
5535	Text string `json:"text,required"`
5536	// The type of the output text. Always `output_text`.
5537	//
5538	// This field can be elided, and will marshal its zero value as "output_text".
5539	Type constant.OutputText `json:"type,required"`
5540	paramObj
5541}
5542
5543// IsPresent returns true if the field's value is not omitted and not the JSON
5544// "null". To check if this field is omitted, use [param.IsOmitted].
5545func (f ResponseOutputTextParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
5546func (r ResponseOutputTextParam) MarshalJSON() (data []byte, err error) {
5547	type shadow ResponseOutputTextParam
5548	return param.MarshalObject(r, (*shadow)(&r))
5549}
5550
5551// Only one field can be non-zero.
5552//
5553// Use [param.IsOmitted] to confirm if a field is set.
5554type ResponseOutputTextAnnotationUnionParam struct {
5555	OfFileCitation *ResponseOutputTextAnnotationFileCitationParam `json:",omitzero,inline"`
5556	OfURLCitation  *ResponseOutputTextAnnotationURLCitationParam  `json:",omitzero,inline"`
5557	OfFilePath     *ResponseOutputTextAnnotationFilePathParam     `json:",omitzero,inline"`
5558	paramUnion
5559}
5560
5561// IsPresent returns true if the field's value is not omitted and not the JSON
5562// "null". To check if this field is omitted, use [param.IsOmitted].
5563func (u ResponseOutputTextAnnotationUnionParam) IsPresent() bool {
5564	return !param.IsOmitted(u) && !u.IsNull()
5565}
5566func (u ResponseOutputTextAnnotationUnionParam) MarshalJSON() ([]byte, error) {
5567	return param.MarshalUnion[ResponseOutputTextAnnotationUnionParam](u.OfFileCitation, u.OfURLCitation, u.OfFilePath)
5568}
5569
5570func (u *ResponseOutputTextAnnotationUnionParam) asAny() any {
5571	if !param.IsOmitted(u.OfFileCitation) {
5572		return u.OfFileCitation
5573	} else if !param.IsOmitted(u.OfURLCitation) {
5574		return u.OfURLCitation
5575	} else if !param.IsOmitted(u.OfFilePath) {
5576		return u.OfFilePath
5577	}
5578	return nil
5579}
5580
5581// Returns a pointer to the underlying variant's property, if present.
5582func (u ResponseOutputTextAnnotationUnionParam) GetEndIndex() *int64 {
5583	if vt := u.OfURLCitation; vt != nil {
5584		return &vt.EndIndex
5585	}
5586	return nil
5587}
5588
5589// Returns a pointer to the underlying variant's property, if present.
5590func (u ResponseOutputTextAnnotationUnionParam) GetStartIndex() *int64 {
5591	if vt := u.OfURLCitation; vt != nil {
5592		return &vt.StartIndex
5593	}
5594	return nil
5595}
5596
5597// Returns a pointer to the underlying variant's property, if present.
5598func (u ResponseOutputTextAnnotationUnionParam) GetTitle() *string {
5599	if vt := u.OfURLCitation; vt != nil {
5600		return &vt.Title
5601	}
5602	return nil
5603}
5604
5605// Returns a pointer to the underlying variant's property, if present.
5606func (u ResponseOutputTextAnnotationUnionParam) GetURL() *string {
5607	if vt := u.OfURLCitation; vt != nil {
5608		return &vt.URL
5609	}
5610	return nil
5611}
5612
5613// Returns a pointer to the underlying variant's property, if present.
5614func (u ResponseOutputTextAnnotationUnionParam) GetFileID() *string {
5615	if vt := u.OfFileCitation; vt != nil {
5616		return (*string)(&vt.FileID)
5617	} else if vt := u.OfFilePath; vt != nil {
5618		return (*string)(&vt.FileID)
5619	}
5620	return nil
5621}
5622
5623// Returns a pointer to the underlying variant's property, if present.
5624func (u ResponseOutputTextAnnotationUnionParam) GetIndex() *int64 {
5625	if vt := u.OfFileCitation; vt != nil {
5626		return (*int64)(&vt.Index)
5627	} else if vt := u.OfFilePath; vt != nil {
5628		return (*int64)(&vt.Index)
5629	}
5630	return nil
5631}
5632
5633// Returns a pointer to the underlying variant's property, if present.
5634func (u ResponseOutputTextAnnotationUnionParam) GetType() *string {
5635	if vt := u.OfFileCitation; vt != nil {
5636		return (*string)(&vt.Type)
5637	} else if vt := u.OfURLCitation; vt != nil {
5638		return (*string)(&vt.Type)
5639	} else if vt := u.OfFilePath; vt != nil {
5640		return (*string)(&vt.Type)
5641	}
5642	return nil
5643}
5644
5645func init() {
5646	apijson.RegisterUnion[ResponseOutputTextAnnotationUnionParam](
5647		"type",
5648		apijson.UnionVariant{
5649			TypeFilter:         gjson.JSON,
5650			Type:               reflect.TypeOf(ResponseOutputTextAnnotationFileCitationParam{}),
5651			DiscriminatorValue: "file_citation",
5652		},
5653		apijson.UnionVariant{
5654			TypeFilter:         gjson.JSON,
5655			Type:               reflect.TypeOf(ResponseOutputTextAnnotationURLCitationParam{}),
5656			DiscriminatorValue: "url_citation",
5657		},
5658		apijson.UnionVariant{
5659			TypeFilter:         gjson.JSON,
5660			Type:               reflect.TypeOf(ResponseOutputTextAnnotationFilePathParam{}),
5661			DiscriminatorValue: "file_path",
5662		},
5663	)
5664}
5665
5666// A citation to a file.
5667//
5668// The properties FileID, Index, Type are required.
5669type ResponseOutputTextAnnotationFileCitationParam struct {
5670	// The ID of the file.
5671	FileID string `json:"file_id,required"`
5672	// The index of the file in the list of files.
5673	Index int64 `json:"index,required"`
5674	// The type of the file citation. Always `file_citation`.
5675	//
5676	// This field can be elided, and will marshal its zero value as "file_citation".
5677	Type constant.FileCitation `json:"type,required"`
5678	paramObj
5679}
5680
5681// IsPresent returns true if the field's value is not omitted and not the JSON
5682// "null". To check if this field is omitted, use [param.IsOmitted].
5683func (f ResponseOutputTextAnnotationFileCitationParam) IsPresent() bool {
5684	return !param.IsOmitted(f) && !f.IsNull()
5685}
5686func (r ResponseOutputTextAnnotationFileCitationParam) MarshalJSON() (data []byte, err error) {
5687	type shadow ResponseOutputTextAnnotationFileCitationParam
5688	return param.MarshalObject(r, (*shadow)(&r))
5689}
5690
5691// A citation for a web resource used to generate a model response.
5692//
5693// The properties EndIndex, StartIndex, Title, Type, URL are required.
5694type ResponseOutputTextAnnotationURLCitationParam struct {
5695	// The index of the last character of the URL citation in the message.
5696	EndIndex int64 `json:"end_index,required"`
5697	// The index of the first character of the URL citation in the message.
5698	StartIndex int64 `json:"start_index,required"`
5699	// The title of the web resource.
5700	Title string `json:"title,required"`
5701	// The URL of the web resource.
5702	URL string `json:"url,required"`
5703	// The type of the URL citation. Always `url_citation`.
5704	//
5705	// This field can be elided, and will marshal its zero value as "url_citation".
5706	Type constant.URLCitation `json:"type,required"`
5707	paramObj
5708}
5709
5710// IsPresent returns true if the field's value is not omitted and not the JSON
5711// "null". To check if this field is omitted, use [param.IsOmitted].
5712func (f ResponseOutputTextAnnotationURLCitationParam) IsPresent() bool {
5713	return !param.IsOmitted(f) && !f.IsNull()
5714}
5715func (r ResponseOutputTextAnnotationURLCitationParam) MarshalJSON() (data []byte, err error) {
5716	type shadow ResponseOutputTextAnnotationURLCitationParam
5717	return param.MarshalObject(r, (*shadow)(&r))
5718}
5719
5720// A path to a file.
5721//
5722// The properties FileID, Index, Type are required.
5723type ResponseOutputTextAnnotationFilePathParam struct {
5724	// The ID of the file.
5725	FileID string `json:"file_id,required"`
5726	// The index of the file in the list of files.
5727	Index int64 `json:"index,required"`
5728	// The type of the file path. Always `file_path`.
5729	//
5730	// This field can be elided, and will marshal its zero value as "file_path".
5731	Type constant.FilePath `json:"type,required"`
5732	paramObj
5733}
5734
5735// IsPresent returns true if the field's value is not omitted and not the JSON
5736// "null". To check if this field is omitted, use [param.IsOmitted].
5737func (f ResponseOutputTextAnnotationFilePathParam) IsPresent() bool {
5738	return !param.IsOmitted(f) && !f.IsNull()
5739}
5740func (r ResponseOutputTextAnnotationFilePathParam) MarshalJSON() (data []byte, err error) {
5741	type shadow ResponseOutputTextAnnotationFilePathParam
5742	return param.MarshalObject(r, (*shadow)(&r))
5743}
5744
5745// A description of the chain of thought used by a reasoning model while generating
5746// a response.
5747type ResponseReasoningItem struct {
5748	// The unique identifier of the reasoning content.
5749	ID string `json:"id,required"`
5750	// Reasoning text contents.
5751	Summary []ResponseReasoningItemSummary `json:"summary,required"`
5752	// The type of the object. Always `reasoning`.
5753	Type constant.Reasoning `json:"type,required"`
5754	// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
5755	// Populated when items are returned via API.
5756	//
5757	// Any of "in_progress", "completed", "incomplete".
5758	Status ResponseReasoningItemStatus `json:"status"`
5759	// Metadata for the response, check the presence of optional fields with the
5760	// [resp.Field.IsPresent] method.
5761	JSON struct {
5762		ID          resp.Field
5763		Summary     resp.Field
5764		Type        resp.Field
5765		Status      resp.Field
5766		ExtraFields map[string]resp.Field
5767		raw         string
5768	} `json:"-"`
5769}
5770
5771// Returns the unmodified JSON received from the API
5772func (r ResponseReasoningItem) RawJSON() string { return r.JSON.raw }
5773func (r *ResponseReasoningItem) UnmarshalJSON(data []byte) error {
5774	return apijson.UnmarshalRoot(data, r)
5775}
5776
5777// ToParam converts this ResponseReasoningItem to a ResponseReasoningItemParam.
5778//
5779// Warning: the fields of the param type will not be present. ToParam should only
5780// be used at the last possible moment before sending a request. Test for this with
5781// ResponseReasoningItemParam.IsOverridden()
5782func (r ResponseReasoningItem) ToParam() ResponseReasoningItemParam {
5783	return param.OverrideObj[ResponseReasoningItemParam](r.RawJSON())
5784}
5785
5786type ResponseReasoningItemSummary struct {
5787	// A short summary of the reasoning used by the model when generating the response.
5788	Text string `json:"text,required"`
5789	// The type of the object. Always `summary_text`.
5790	Type constant.SummaryText `json:"type,required"`
5791	// Metadata for the response, check the presence of optional fields with the
5792	// [resp.Field.IsPresent] method.
5793	JSON struct {
5794		Text        resp.Field
5795		Type        resp.Field
5796		ExtraFields map[string]resp.Field
5797		raw         string
5798	} `json:"-"`
5799}
5800
5801// Returns the unmodified JSON received from the API
5802func (r ResponseReasoningItemSummary) RawJSON() string { return r.JSON.raw }
5803func (r *ResponseReasoningItemSummary) UnmarshalJSON(data []byte) error {
5804	return apijson.UnmarshalRoot(data, r)
5805}
5806
5807// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
5808// Populated when items are returned via API.
5809type ResponseReasoningItemStatus string
5810
5811const (
5812	ResponseReasoningItemStatusInProgress ResponseReasoningItemStatus = "in_progress"
5813	ResponseReasoningItemStatusCompleted  ResponseReasoningItemStatus = "completed"
5814	ResponseReasoningItemStatusIncomplete ResponseReasoningItemStatus = "incomplete"
5815)
5816
5817// A description of the chain of thought used by a reasoning model while generating
5818// a response.
5819//
5820// The properties ID, Summary, Type are required.
5821type ResponseReasoningItemParam struct {
5822	// The unique identifier of the reasoning content.
5823	ID string `json:"id,required"`
5824	// Reasoning text contents.
5825	Summary []ResponseReasoningItemSummaryParam `json:"summary,omitzero,required"`
5826	// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
5827	// Populated when items are returned via API.
5828	//
5829	// Any of "in_progress", "completed", "incomplete".
5830	Status ResponseReasoningItemStatus `json:"status,omitzero"`
5831	// The type of the object. Always `reasoning`.
5832	//
5833	// This field can be elided, and will marshal its zero value as "reasoning".
5834	Type constant.Reasoning `json:"type,required"`
5835	paramObj
5836}
5837
5838// IsPresent returns true if the field's value is not omitted and not the JSON
5839// "null". To check if this field is omitted, use [param.IsOmitted].
5840func (f ResponseReasoningItemParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
5841func (r ResponseReasoningItemParam) MarshalJSON() (data []byte, err error) {
5842	type shadow ResponseReasoningItemParam
5843	return param.MarshalObject(r, (*shadow)(&r))
5844}
5845
5846// The properties Text, Type are required.
5847type ResponseReasoningItemSummaryParam struct {
5848	// A short summary of the reasoning used by the model when generating the response.
5849	Text string `json:"text,required"`
5850	// The type of the object. Always `summary_text`.
5851	//
5852	// This field can be elided, and will marshal its zero value as "summary_text".
5853	Type constant.SummaryText `json:"type,required"`
5854	paramObj
5855}
5856
5857// IsPresent returns true if the field's value is not omitted and not the JSON
5858// "null". To check if this field is omitted, use [param.IsOmitted].
5859func (f ResponseReasoningItemSummaryParam) IsPresent() bool {
5860	return !param.IsOmitted(f) && !f.IsNull()
5861}
5862func (r ResponseReasoningItemSummaryParam) MarshalJSON() (data []byte, err error) {
5863	type shadow ResponseReasoningItemSummaryParam
5864	return param.MarshalObject(r, (*shadow)(&r))
5865}
5866
5867// Emitted when there is a partial refusal text.
5868type ResponseRefusalDeltaEvent struct {
5869	// The index of the content part that the refusal text is added to.
5870	ContentIndex int64 `json:"content_index,required"`
5871	// The refusal text that is added.
5872	Delta string `json:"delta,required"`
5873	// The ID of the output item that the refusal text is added to.
5874	ItemID string `json:"item_id,required"`
5875	// The index of the output item that the refusal text is added to.
5876	OutputIndex int64 `json:"output_index,required"`
5877	// The type of the event. Always `response.refusal.delta`.
5878	Type constant.ResponseRefusalDelta `json:"type,required"`
5879	// Metadata for the response, check the presence of optional fields with the
5880	// [resp.Field.IsPresent] method.
5881	JSON struct {
5882		ContentIndex resp.Field
5883		Delta        resp.Field
5884		ItemID       resp.Field
5885		OutputIndex  resp.Field
5886		Type         resp.Field
5887		ExtraFields  map[string]resp.Field
5888		raw          string
5889	} `json:"-"`
5890}
5891
5892// Returns the unmodified JSON received from the API
5893func (r ResponseRefusalDeltaEvent) RawJSON() string { return r.JSON.raw }
5894func (r *ResponseRefusalDeltaEvent) UnmarshalJSON(data []byte) error {
5895	return apijson.UnmarshalRoot(data, r)
5896}
5897
5898// Emitted when refusal text is finalized.
5899type ResponseRefusalDoneEvent struct {
5900	// The index of the content part that the refusal text is finalized.
5901	ContentIndex int64 `json:"content_index,required"`
5902	// The ID of the output item that the refusal text is finalized.
5903	ItemID string `json:"item_id,required"`
5904	// The index of the output item that the refusal text is finalized.
5905	OutputIndex int64 `json:"output_index,required"`
5906	// The refusal text that is finalized.
5907	Refusal string `json:"refusal,required"`
5908	// The type of the event. Always `response.refusal.done`.
5909	Type constant.ResponseRefusalDone `json:"type,required"`
5910	// Metadata for the response, check the presence of optional fields with the
5911	// [resp.Field.IsPresent] method.
5912	JSON struct {
5913		ContentIndex resp.Field
5914		ItemID       resp.Field
5915		OutputIndex  resp.Field
5916		Refusal      resp.Field
5917		Type         resp.Field
5918		ExtraFields  map[string]resp.Field
5919		raw          string
5920	} `json:"-"`
5921}
5922
5923// Returns the unmodified JSON received from the API
5924func (r ResponseRefusalDoneEvent) RawJSON() string { return r.JSON.raw }
5925func (r *ResponseRefusalDoneEvent) UnmarshalJSON(data []byte) error {
5926	return apijson.UnmarshalRoot(data, r)
5927}
5928
5929// The status of the response generation. One of `completed`, `failed`,
5930// `in_progress`, or `incomplete`.
5931type ResponseStatus string
5932
5933const (
5934	ResponseStatusCompleted  ResponseStatus = "completed"
5935	ResponseStatusFailed     ResponseStatus = "failed"
5936	ResponseStatusInProgress ResponseStatus = "in_progress"
5937	ResponseStatusIncomplete ResponseStatus = "incomplete"
5938)
5939
5940// ResponseStreamEventUnion contains all possible properties and values from
5941// [ResponseAudioDeltaEvent], [ResponseAudioDoneEvent],
5942// [ResponseAudioTranscriptDeltaEvent], [ResponseAudioTranscriptDoneEvent],
5943// [ResponseCodeInterpreterCallCodeDeltaEvent],
5944// [ResponseCodeInterpreterCallCodeDoneEvent],
5945// [ResponseCodeInterpreterCallCompletedEvent],
5946// [ResponseCodeInterpreterCallInProgressEvent],
5947// [ResponseCodeInterpreterCallInterpretingEvent], [ResponseCompletedEvent],
5948// [ResponseContentPartAddedEvent], [ResponseContentPartDoneEvent],
5949// [ResponseCreatedEvent], [ResponseErrorEvent],
5950// [ResponseFileSearchCallCompletedEvent], [ResponseFileSearchCallInProgressEvent],
5951// [ResponseFileSearchCallSearchingEvent],
5952// [ResponseFunctionCallArgumentsDeltaEvent],
5953// [ResponseFunctionCallArgumentsDoneEvent], [ResponseInProgressEvent],
5954// [ResponseFailedEvent], [ResponseIncompleteEvent],
5955// [ResponseOutputItemAddedEvent], [ResponseOutputItemDoneEvent],
5956// [ResponseRefusalDeltaEvent], [ResponseRefusalDoneEvent],
5957// [ResponseTextAnnotationDeltaEvent], [ResponseTextDeltaEvent],
5958// [ResponseTextDoneEvent], [ResponseWebSearchCallCompletedEvent],
5959// [ResponseWebSearchCallInProgressEvent], [ResponseWebSearchCallSearchingEvent].
5960//
5961// Use the [ResponseStreamEventUnion.AsAny] method to switch on the variant.
5962//
5963// Use the methods beginning with 'As' to cast the union to one of its variants.
5964type ResponseStreamEventUnion struct {
5965	Delta string `json:"delta"`
5966	// Any of "response.audio.delta", "response.audio.done",
5967	// "response.audio.transcript.delta", "response.audio.transcript.done",
5968	// "response.code_interpreter_call.code.delta",
5969	// "response.code_interpreter_call.code.done",
5970	// "response.code_interpreter_call.completed",
5971	// "response.code_interpreter_call.in_progress",
5972	// "response.code_interpreter_call.interpreting", "response.completed",
5973	// "response.content_part.added", "response.content_part.done", "response.created",
5974	// "error", "response.file_search_call.completed",
5975	// "response.file_search_call.in_progress", "response.file_search_call.searching",
5976	// "response.function_call_arguments.delta",
5977	// "response.function_call_arguments.done", "response.in_progress",
5978	// "response.failed", "response.incomplete", "response.output_item.added",
5979	// "response.output_item.done", "response.refusal.delta", "response.refusal.done",
5980	// "response.output_text.annotation.added", "response.output_text.delta",
5981	// "response.output_text.done", "response.web_search_call.completed",
5982	// "response.web_search_call.in_progress", "response.web_search_call.searching".
5983	Type        string `json:"type"`
5984	OutputIndex int64  `json:"output_index"`
5985	Code        string `json:"code"`
5986	// This field is from variant [ResponseCodeInterpreterCallCompletedEvent].
5987	CodeInterpreterCall ResponseCodeInterpreterToolCall `json:"code_interpreter_call"`
5988	// This field is from variant [ResponseCompletedEvent].
5989	Response     Response `json:"response"`
5990	ContentIndex int64    `json:"content_index"`
5991	ItemID       string   `json:"item_id"`
5992	// This field is a union of [ResponseContentPartAddedEventPartUnion],
5993	// [ResponseContentPartDoneEventPartUnion]
5994	Part ResponseStreamEventUnionPart `json:"part"`
5995	// This field is from variant [ResponseErrorEvent].
5996	Message string `json:"message"`
5997	// This field is from variant [ResponseErrorEvent].
5998	Param string `json:"param"`
5999	// This field is from variant [ResponseFunctionCallArgumentsDoneEvent].
6000	Arguments string `json:"arguments"`
6001	// This field is from variant [ResponseOutputItemAddedEvent].
6002	Item ResponseOutputItemUnion `json:"item"`
6003	// This field is from variant [ResponseRefusalDoneEvent].
6004	Refusal string `json:"refusal"`
6005	// This field is from variant [ResponseTextAnnotationDeltaEvent].
6006	Annotation ResponseTextAnnotationDeltaEventAnnotationUnion `json:"annotation"`
6007	// This field is from variant [ResponseTextAnnotationDeltaEvent].
6008	AnnotationIndex int64 `json:"annotation_index"`
6009	// This field is from variant [ResponseTextDoneEvent].
6010	Text string `json:"text"`
6011	JSON struct {
6012		Delta               resp.Field
6013		Type                resp.Field
6014		OutputIndex         resp.Field
6015		Code                resp.Field
6016		CodeInterpreterCall resp.Field
6017		Response            resp.Field
6018		ContentIndex        resp.Field
6019		ItemID              resp.Field
6020		Part                resp.Field
6021		Message             resp.Field
6022		Param               resp.Field
6023		Arguments           resp.Field
6024		Item                resp.Field
6025		Refusal             resp.Field
6026		Annotation          resp.Field
6027		AnnotationIndex     resp.Field
6028		Text                resp.Field
6029		raw                 string
6030	} `json:"-"`
6031}
6032
6033// Use the following switch statement to find the correct variant
6034//
6035//	switch variant := ResponseStreamEventUnion.AsAny().(type) {
6036//	case ResponseAudioDeltaEvent:
6037//	case ResponseAudioDoneEvent:
6038//	case ResponseAudioTranscriptDeltaEvent:
6039//	case ResponseAudioTranscriptDoneEvent:
6040//	case ResponseCodeInterpreterCallCodeDeltaEvent:
6041//	case ResponseCodeInterpreterCallCodeDoneEvent:
6042//	case ResponseCodeInterpreterCallCompletedEvent:
6043//	case ResponseCodeInterpreterCallInProgressEvent:
6044//	case ResponseCodeInterpreterCallInterpretingEvent:
6045//	case ResponseCompletedEvent:
6046//	case ResponseContentPartAddedEvent:
6047//	case ResponseContentPartDoneEvent:
6048//	case ResponseCreatedEvent:
6049//	case ResponseErrorEvent:
6050//	case ResponseFileSearchCallCompletedEvent:
6051//	case ResponseFileSearchCallInProgressEvent:
6052//	case ResponseFileSearchCallSearchingEvent:
6053//	case ResponseFunctionCallArgumentsDeltaEvent:
6054//	case ResponseFunctionCallArgumentsDoneEvent:
6055//	case ResponseInProgressEvent:
6056//	case ResponseFailedEvent:
6057//	case ResponseIncompleteEvent:
6058//	case ResponseOutputItemAddedEvent:
6059//	case ResponseOutputItemDoneEvent:
6060//	case ResponseRefusalDeltaEvent:
6061//	case ResponseRefusalDoneEvent:
6062//	case ResponseTextAnnotationDeltaEvent:
6063//	case ResponseTextDeltaEvent:
6064//	case ResponseTextDoneEvent:
6065//	case ResponseWebSearchCallCompletedEvent:
6066//	case ResponseWebSearchCallInProgressEvent:
6067//	case ResponseWebSearchCallSearchingEvent:
6068//	default:
6069//	  fmt.Errorf("no variant present")
6070//	}
6071func (u ResponseStreamEventUnion) AsAny() any {
6072	switch u.Type {
6073	case "response.audio.delta":
6074		return u.AsResponseAudioDelta()
6075	case "response.audio.done":
6076		return u.AsResponseAudioDone()
6077	case "response.audio.transcript.delta":
6078		return u.AsResponseAudioTranscriptDelta()
6079	case "response.audio.transcript.done":
6080		return u.AsResponseAudioTranscriptDone()
6081	case "response.code_interpreter_call.code.delta":
6082		return u.AsResponseCodeInterpreterCallCodeDelta()
6083	case "response.code_interpreter_call.code.done":
6084		return u.AsResponseCodeInterpreterCallCodeDone()
6085	case "response.code_interpreter_call.completed":
6086		return u.AsResponseCodeInterpreterCallCompleted()
6087	case "response.code_interpreter_call.in_progress":
6088		return u.AsResponseCodeInterpreterCallInProgress()
6089	case "response.code_interpreter_call.interpreting":
6090		return u.AsResponseCodeInterpreterCallInterpreting()
6091	case "response.completed":
6092		return u.AsResponseCompleted()
6093	case "response.content_part.added":
6094		return u.AsResponseContentPartAdded()
6095	case "response.content_part.done":
6096		return u.AsResponseContentPartDone()
6097	case "response.created":
6098		return u.AsResponseCreated()
6099	case "error":
6100		return u.AsError()
6101	case "response.file_search_call.completed":
6102		return u.AsResponseFileSearchCallCompleted()
6103	case "response.file_search_call.in_progress":
6104		return u.AsResponseFileSearchCallInProgress()
6105	case "response.file_search_call.searching":
6106		return u.AsResponseFileSearchCallSearching()
6107	case "response.function_call_arguments.delta":
6108		return u.AsResponseFunctionCallArgumentsDelta()
6109	case "response.function_call_arguments.done":
6110		return u.AsResponseFunctionCallArgumentsDone()
6111	case "response.in_progress":
6112		return u.AsResponseInProgress()
6113	case "response.failed":
6114		return u.AsResponseFailed()
6115	case "response.incomplete":
6116		return u.AsResponseIncomplete()
6117	case "response.output_item.added":
6118		return u.AsResponseOutputItemAdded()
6119	case "response.output_item.done":
6120		return u.AsResponseOutputItemDone()
6121	case "response.refusal.delta":
6122		return u.AsResponseRefusalDelta()
6123	case "response.refusal.done":
6124		return u.AsResponseRefusalDone()
6125	case "response.output_text.annotation.added":
6126		return u.AsResponseOutputTextAnnotationAdded()
6127	case "response.output_text.delta":
6128		return u.AsResponseOutputTextDelta()
6129	case "response.output_text.done":
6130		return u.AsResponseOutputTextDone()
6131	case "response.web_search_call.completed":
6132		return u.AsResponseWebSearchCallCompleted()
6133	case "response.web_search_call.in_progress":
6134		return u.AsResponseWebSearchCallInProgress()
6135	case "response.web_search_call.searching":
6136		return u.AsResponseWebSearchCallSearching()
6137	}
6138	return nil
6139}
6140
6141func (u ResponseStreamEventUnion) AsResponseAudioDelta() (v ResponseAudioDeltaEvent) {
6142	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6143	return
6144}
6145
6146func (u ResponseStreamEventUnion) AsResponseAudioDone() (v ResponseAudioDoneEvent) {
6147	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6148	return
6149}
6150
6151func (u ResponseStreamEventUnion) AsResponseAudioTranscriptDelta() (v ResponseAudioTranscriptDeltaEvent) {
6152	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6153	return
6154}
6155
6156func (u ResponseStreamEventUnion) AsResponseAudioTranscriptDone() (v ResponseAudioTranscriptDoneEvent) {
6157	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6158	return
6159}
6160
6161func (u ResponseStreamEventUnion) AsResponseCodeInterpreterCallCodeDelta() (v ResponseCodeInterpreterCallCodeDeltaEvent) {
6162	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6163	return
6164}
6165
6166func (u ResponseStreamEventUnion) AsResponseCodeInterpreterCallCodeDone() (v ResponseCodeInterpreterCallCodeDoneEvent) {
6167	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6168	return
6169}
6170
6171func (u ResponseStreamEventUnion) AsResponseCodeInterpreterCallCompleted() (v ResponseCodeInterpreterCallCompletedEvent) {
6172	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6173	return
6174}
6175
6176func (u ResponseStreamEventUnion) AsResponseCodeInterpreterCallInProgress() (v ResponseCodeInterpreterCallInProgressEvent) {
6177	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6178	return
6179}
6180
6181func (u ResponseStreamEventUnion) AsResponseCodeInterpreterCallInterpreting() (v ResponseCodeInterpreterCallInterpretingEvent) {
6182	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6183	return
6184}
6185
6186func (u ResponseStreamEventUnion) AsResponseCompleted() (v ResponseCompletedEvent) {
6187	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6188	return
6189}
6190
6191func (u ResponseStreamEventUnion) AsResponseContentPartAdded() (v ResponseContentPartAddedEvent) {
6192	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6193	return
6194}
6195
6196func (u ResponseStreamEventUnion) AsResponseContentPartDone() (v ResponseContentPartDoneEvent) {
6197	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6198	return
6199}
6200
6201func (u ResponseStreamEventUnion) AsResponseCreated() (v ResponseCreatedEvent) {
6202	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6203	return
6204}
6205
6206func (u ResponseStreamEventUnion) AsError() (v ResponseErrorEvent) {
6207	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6208	return
6209}
6210
6211func (u ResponseStreamEventUnion) AsResponseFileSearchCallCompleted() (v ResponseFileSearchCallCompletedEvent) {
6212	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6213	return
6214}
6215
6216func (u ResponseStreamEventUnion) AsResponseFileSearchCallInProgress() (v ResponseFileSearchCallInProgressEvent) {
6217	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6218	return
6219}
6220
6221func (u ResponseStreamEventUnion) AsResponseFileSearchCallSearching() (v ResponseFileSearchCallSearchingEvent) {
6222	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6223	return
6224}
6225
6226func (u ResponseStreamEventUnion) AsResponseFunctionCallArgumentsDelta() (v ResponseFunctionCallArgumentsDeltaEvent) {
6227	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6228	return
6229}
6230
6231func (u ResponseStreamEventUnion) AsResponseFunctionCallArgumentsDone() (v ResponseFunctionCallArgumentsDoneEvent) {
6232	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6233	return
6234}
6235
6236func (u ResponseStreamEventUnion) AsResponseInProgress() (v ResponseInProgressEvent) {
6237	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6238	return
6239}
6240
6241func (u ResponseStreamEventUnion) AsResponseFailed() (v ResponseFailedEvent) {
6242	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6243	return
6244}
6245
6246func (u ResponseStreamEventUnion) AsResponseIncomplete() (v ResponseIncompleteEvent) {
6247	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6248	return
6249}
6250
6251func (u ResponseStreamEventUnion) AsResponseOutputItemAdded() (v ResponseOutputItemAddedEvent) {
6252	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6253	return
6254}
6255
6256func (u ResponseStreamEventUnion) AsResponseOutputItemDone() (v ResponseOutputItemDoneEvent) {
6257	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6258	return
6259}
6260
6261func (u ResponseStreamEventUnion) AsResponseRefusalDelta() (v ResponseRefusalDeltaEvent) {
6262	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6263	return
6264}
6265
6266func (u ResponseStreamEventUnion) AsResponseRefusalDone() (v ResponseRefusalDoneEvent) {
6267	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6268	return
6269}
6270
6271func (u ResponseStreamEventUnion) AsResponseOutputTextAnnotationAdded() (v ResponseTextAnnotationDeltaEvent) {
6272	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6273	return
6274}
6275
6276func (u ResponseStreamEventUnion) AsResponseOutputTextDelta() (v ResponseTextDeltaEvent) {
6277	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6278	return
6279}
6280
6281func (u ResponseStreamEventUnion) AsResponseOutputTextDone() (v ResponseTextDoneEvent) {
6282	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6283	return
6284}
6285
6286func (u ResponseStreamEventUnion) AsResponseWebSearchCallCompleted() (v ResponseWebSearchCallCompletedEvent) {
6287	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6288	return
6289}
6290
6291func (u ResponseStreamEventUnion) AsResponseWebSearchCallInProgress() (v ResponseWebSearchCallInProgressEvent) {
6292	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6293	return
6294}
6295
6296func (u ResponseStreamEventUnion) AsResponseWebSearchCallSearching() (v ResponseWebSearchCallSearchingEvent) {
6297	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6298	return
6299}
6300
6301// Returns the unmodified JSON received from the API
6302func (u ResponseStreamEventUnion) RawJSON() string { return u.JSON.raw }
6303
6304func (r *ResponseStreamEventUnion) UnmarshalJSON(data []byte) error {
6305	return apijson.UnmarshalRoot(data, r)
6306}
6307
6308// ResponseStreamEventUnionPart is an implicit subunion of
6309// [ResponseStreamEventUnion]. ResponseStreamEventUnionPart provides convenient
6310// access to the sub-properties of the union.
6311//
6312// For type safety it is recommended to directly use a variant of the
6313// [ResponseStreamEventUnion].
6314type ResponseStreamEventUnionPart struct {
6315	// This field is from variant [ResponseContentPartAddedEventPartUnion],
6316	// [ResponseContentPartDoneEventPartUnion].
6317	Annotations []ResponseOutputTextAnnotationUnion `json:"annotations"`
6318	// This field is from variant [ResponseContentPartAddedEventPartUnion],
6319	// [ResponseContentPartDoneEventPartUnion].
6320	Text string `json:"text"`
6321	Type string `json:"type"`
6322	// This field is from variant [ResponseContentPartAddedEventPartUnion],
6323	// [ResponseContentPartDoneEventPartUnion].
6324	Refusal string `json:"refusal"`
6325	JSON    struct {
6326		Annotations resp.Field
6327		Text        resp.Field
6328		Type        resp.Field
6329		Refusal     resp.Field
6330		raw         string
6331	} `json:"-"`
6332}
6333
6334func (r *ResponseStreamEventUnionPart) UnmarshalJSON(data []byte) error {
6335	return apijson.UnmarshalRoot(data, r)
6336}
6337
6338// Emitted when a text annotation is added.
6339type ResponseTextAnnotationDeltaEvent struct {
6340	// A citation to a file.
6341	Annotation ResponseTextAnnotationDeltaEventAnnotationUnion `json:"annotation,required"`
6342	// The index of the annotation that was added.
6343	AnnotationIndex int64 `json:"annotation_index,required"`
6344	// The index of the content part that the text annotation was added to.
6345	ContentIndex int64 `json:"content_index,required"`
6346	// The ID of the output item that the text annotation was added to.
6347	ItemID string `json:"item_id,required"`
6348	// The index of the output item that the text annotation was added to.
6349	OutputIndex int64 `json:"output_index,required"`
6350	// The type of the event. Always `response.output_text.annotation.added`.
6351	Type constant.ResponseOutputTextAnnotationAdded `json:"type,required"`
6352	// Metadata for the response, check the presence of optional fields with the
6353	// [resp.Field.IsPresent] method.
6354	JSON struct {
6355		Annotation      resp.Field
6356		AnnotationIndex resp.Field
6357		ContentIndex    resp.Field
6358		ItemID          resp.Field
6359		OutputIndex     resp.Field
6360		Type            resp.Field
6361		ExtraFields     map[string]resp.Field
6362		raw             string
6363	} `json:"-"`
6364}
6365
6366// Returns the unmodified JSON received from the API
6367func (r ResponseTextAnnotationDeltaEvent) RawJSON() string { return r.JSON.raw }
6368func (r *ResponseTextAnnotationDeltaEvent) UnmarshalJSON(data []byte) error {
6369	return apijson.UnmarshalRoot(data, r)
6370}
6371
6372// ResponseTextAnnotationDeltaEventAnnotationUnion contains all possible properties
6373// and values from [ResponseTextAnnotationDeltaEventAnnotationFileCitation],
6374// [ResponseTextAnnotationDeltaEventAnnotationURLCitation],
6375// [ResponseTextAnnotationDeltaEventAnnotationFilePath].
6376//
6377// Use the [ResponseTextAnnotationDeltaEventAnnotationUnion.AsAny] method to switch
6378// on the variant.
6379//
6380// Use the methods beginning with 'As' to cast the union to one of its variants.
6381type ResponseTextAnnotationDeltaEventAnnotationUnion struct {
6382	FileID string `json:"file_id"`
6383	Index  int64  `json:"index"`
6384	// Any of "file_citation", "url_citation", "file_path".
6385	Type string `json:"type"`
6386	// This field is from variant
6387	// [ResponseTextAnnotationDeltaEventAnnotationURLCitation].
6388	EndIndex int64 `json:"end_index"`
6389	// This field is from variant
6390	// [ResponseTextAnnotationDeltaEventAnnotationURLCitation].
6391	StartIndex int64 `json:"start_index"`
6392	// This field is from variant
6393	// [ResponseTextAnnotationDeltaEventAnnotationURLCitation].
6394	Title string `json:"title"`
6395	// This field is from variant
6396	// [ResponseTextAnnotationDeltaEventAnnotationURLCitation].
6397	URL  string `json:"url"`
6398	JSON struct {
6399		FileID     resp.Field
6400		Index      resp.Field
6401		Type       resp.Field
6402		EndIndex   resp.Field
6403		StartIndex resp.Field
6404		Title      resp.Field
6405		URL        resp.Field
6406		raw        string
6407	} `json:"-"`
6408}
6409
6410// Use the following switch statement to find the correct variant
6411//
6412//	switch variant := ResponseTextAnnotationDeltaEventAnnotationUnion.AsAny().(type) {
6413//	case ResponseTextAnnotationDeltaEventAnnotationFileCitation:
6414//	case ResponseTextAnnotationDeltaEventAnnotationURLCitation:
6415//	case ResponseTextAnnotationDeltaEventAnnotationFilePath:
6416//	default:
6417//	  fmt.Errorf("no variant present")
6418//	}
6419func (u ResponseTextAnnotationDeltaEventAnnotationUnion) AsAny() any {
6420	switch u.Type {
6421	case "file_citation":
6422		return u.AsFileCitation()
6423	case "url_citation":
6424		return u.AsURLCitation()
6425	case "file_path":
6426		return u.AsFilePath()
6427	}
6428	return nil
6429}
6430
6431func (u ResponseTextAnnotationDeltaEventAnnotationUnion) AsFileCitation() (v ResponseTextAnnotationDeltaEventAnnotationFileCitation) {
6432	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6433	return
6434}
6435
6436func (u ResponseTextAnnotationDeltaEventAnnotationUnion) AsURLCitation() (v ResponseTextAnnotationDeltaEventAnnotationURLCitation) {
6437	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6438	return
6439}
6440
6441func (u ResponseTextAnnotationDeltaEventAnnotationUnion) AsFilePath() (v ResponseTextAnnotationDeltaEventAnnotationFilePath) {
6442	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6443	return
6444}
6445
6446// Returns the unmodified JSON received from the API
6447func (u ResponseTextAnnotationDeltaEventAnnotationUnion) RawJSON() string { return u.JSON.raw }
6448
6449func (r *ResponseTextAnnotationDeltaEventAnnotationUnion) UnmarshalJSON(data []byte) error {
6450	return apijson.UnmarshalRoot(data, r)
6451}
6452
6453// A citation to a file.
6454type ResponseTextAnnotationDeltaEventAnnotationFileCitation struct {
6455	// The ID of the file.
6456	FileID string `json:"file_id,required"`
6457	// The index of the file in the list of files.
6458	Index int64 `json:"index,required"`
6459	// The type of the file citation. Always `file_citation`.
6460	Type constant.FileCitation `json:"type,required"`
6461	// Metadata for the response, check the presence of optional fields with the
6462	// [resp.Field.IsPresent] method.
6463	JSON struct {
6464		FileID      resp.Field
6465		Index       resp.Field
6466		Type        resp.Field
6467		ExtraFields map[string]resp.Field
6468		raw         string
6469	} `json:"-"`
6470}
6471
6472// Returns the unmodified JSON received from the API
6473func (r ResponseTextAnnotationDeltaEventAnnotationFileCitation) RawJSON() string { return r.JSON.raw }
6474func (r *ResponseTextAnnotationDeltaEventAnnotationFileCitation) UnmarshalJSON(data []byte) error {
6475	return apijson.UnmarshalRoot(data, r)
6476}
6477
6478// A citation for a web resource used to generate a model response.
6479type ResponseTextAnnotationDeltaEventAnnotationURLCitation struct {
6480	// The index of the last character of the URL citation in the message.
6481	EndIndex int64 `json:"end_index,required"`
6482	// The index of the first character of the URL citation in the message.
6483	StartIndex int64 `json:"start_index,required"`
6484	// The title of the web resource.
6485	Title string `json:"title,required"`
6486	// The type of the URL citation. Always `url_citation`.
6487	Type constant.URLCitation `json:"type,required"`
6488	// The URL of the web resource.
6489	URL string `json:"url,required"`
6490	// Metadata for the response, check the presence of optional fields with the
6491	// [resp.Field.IsPresent] method.
6492	JSON struct {
6493		EndIndex    resp.Field
6494		StartIndex  resp.Field
6495		Title       resp.Field
6496		Type        resp.Field
6497		URL         resp.Field
6498		ExtraFields map[string]resp.Field
6499		raw         string
6500	} `json:"-"`
6501}
6502
6503// Returns the unmodified JSON received from the API
6504func (r ResponseTextAnnotationDeltaEventAnnotationURLCitation) RawJSON() string { return r.JSON.raw }
6505func (r *ResponseTextAnnotationDeltaEventAnnotationURLCitation) UnmarshalJSON(data []byte) error {
6506	return apijson.UnmarshalRoot(data, r)
6507}
6508
6509// A path to a file.
6510type ResponseTextAnnotationDeltaEventAnnotationFilePath struct {
6511	// The ID of the file.
6512	FileID string `json:"file_id,required"`
6513	// The index of the file in the list of files.
6514	Index int64 `json:"index,required"`
6515	// The type of the file path. Always `file_path`.
6516	Type constant.FilePath `json:"type,required"`
6517	// Metadata for the response, check the presence of optional fields with the
6518	// [resp.Field.IsPresent] method.
6519	JSON struct {
6520		FileID      resp.Field
6521		Index       resp.Field
6522		Type        resp.Field
6523		ExtraFields map[string]resp.Field
6524		raw         string
6525	} `json:"-"`
6526}
6527
6528// Returns the unmodified JSON received from the API
6529func (r ResponseTextAnnotationDeltaEventAnnotationFilePath) RawJSON() string { return r.JSON.raw }
6530func (r *ResponseTextAnnotationDeltaEventAnnotationFilePath) UnmarshalJSON(data []byte) error {
6531	return apijson.UnmarshalRoot(data, r)
6532}
6533
6534// Configuration options for a text response from the model. Can be plain text or
6535// structured JSON data. Learn more:
6536//
6537// - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
6538// - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
6539type ResponseTextConfig struct {
6540	// An object specifying the format that the model must output.
6541	//
6542	// Configuring `{ "type": "json_schema" }` enables Structured Outputs, which
6543	// ensures the model will match your supplied JSON schema. Learn more in the
6544	// [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
6545	//
6546	// The default format is `{ "type": "text" }` with no additional options.
6547	//
6548	// **Not recommended for gpt-4o and newer models:**
6549	//
6550	// Setting to `{ "type": "json_object" }` enables the older JSON mode, which
6551	// ensures the message the model generates is valid JSON. Using `json_schema` is
6552	// preferred for models that support it.
6553	Format ResponseFormatTextConfigUnion `json:"format"`
6554	// Metadata for the response, check the presence of optional fields with the
6555	// [resp.Field.IsPresent] method.
6556	JSON struct {
6557		Format      resp.Field
6558		ExtraFields map[string]resp.Field
6559		raw         string
6560	} `json:"-"`
6561}
6562
6563// Returns the unmodified JSON received from the API
6564func (r ResponseTextConfig) RawJSON() string { return r.JSON.raw }
6565func (r *ResponseTextConfig) UnmarshalJSON(data []byte) error {
6566	return apijson.UnmarshalRoot(data, r)
6567}
6568
6569// ToParam converts this ResponseTextConfig to a ResponseTextConfigParam.
6570//
6571// Warning: the fields of the param type will not be present. ToParam should only
6572// be used at the last possible moment before sending a request. Test for this with
6573// ResponseTextConfigParam.IsOverridden()
6574func (r ResponseTextConfig) ToParam() ResponseTextConfigParam {
6575	return param.OverrideObj[ResponseTextConfigParam](r.RawJSON())
6576}
6577
6578// Configuration options for a text response from the model. Can be plain text or
6579// structured JSON data. Learn more:
6580//
6581// - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
6582// - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
6583type ResponseTextConfigParam struct {
6584	// An object specifying the format that the model must output.
6585	//
6586	// Configuring `{ "type": "json_schema" }` enables Structured Outputs, which
6587	// ensures the model will match your supplied JSON schema. Learn more in the
6588	// [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
6589	//
6590	// The default format is `{ "type": "text" }` with no additional options.
6591	//
6592	// **Not recommended for gpt-4o and newer models:**
6593	//
6594	// Setting to `{ "type": "json_object" }` enables the older JSON mode, which
6595	// ensures the message the model generates is valid JSON. Using `json_schema` is
6596	// preferred for models that support it.
6597	Format ResponseFormatTextConfigUnionParam `json:"format,omitzero"`
6598	paramObj
6599}
6600
6601// IsPresent returns true if the field's value is not omitted and not the JSON
6602// "null". To check if this field is omitted, use [param.IsOmitted].
6603func (f ResponseTextConfigParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
6604func (r ResponseTextConfigParam) MarshalJSON() (data []byte, err error) {
6605	type shadow ResponseTextConfigParam
6606	return param.MarshalObject(r, (*shadow)(&r))
6607}
6608
6609// Emitted when there is an additional text delta.
6610type ResponseTextDeltaEvent struct {
6611	// The index of the content part that the text delta was added to.
6612	ContentIndex int64 `json:"content_index,required"`
6613	// The text delta that was added.
6614	Delta string `json:"delta,required"`
6615	// The ID of the output item that the text delta was added to.
6616	ItemID string `json:"item_id,required"`
6617	// The index of the output item that the text delta was added to.
6618	OutputIndex int64 `json:"output_index,required"`
6619	// The type of the event. Always `response.output_text.delta`.
6620	Type constant.ResponseOutputTextDelta `json:"type,required"`
6621	// Metadata for the response, check the presence of optional fields with the
6622	// [resp.Field.IsPresent] method.
6623	JSON struct {
6624		ContentIndex resp.Field
6625		Delta        resp.Field
6626		ItemID       resp.Field
6627		OutputIndex  resp.Field
6628		Type         resp.Field
6629		ExtraFields  map[string]resp.Field
6630		raw          string
6631	} `json:"-"`
6632}
6633
6634// Returns the unmodified JSON received from the API
6635func (r ResponseTextDeltaEvent) RawJSON() string { return r.JSON.raw }
6636func (r *ResponseTextDeltaEvent) UnmarshalJSON(data []byte) error {
6637	return apijson.UnmarshalRoot(data, r)
6638}
6639
6640// Emitted when text content is finalized.
6641type ResponseTextDoneEvent struct {
6642	// The index of the content part that the text content is finalized.
6643	ContentIndex int64 `json:"content_index,required"`
6644	// The ID of the output item that the text content is finalized.
6645	ItemID string `json:"item_id,required"`
6646	// The index of the output item that the text content is finalized.
6647	OutputIndex int64 `json:"output_index,required"`
6648	// The text content that is finalized.
6649	Text string `json:"text,required"`
6650	// The type of the event. Always `response.output_text.done`.
6651	Type constant.ResponseOutputTextDone `json:"type,required"`
6652	// Metadata for the response, check the presence of optional fields with the
6653	// [resp.Field.IsPresent] method.
6654	JSON struct {
6655		ContentIndex resp.Field
6656		ItemID       resp.Field
6657		OutputIndex  resp.Field
6658		Text         resp.Field
6659		Type         resp.Field
6660		ExtraFields  map[string]resp.Field
6661		raw          string
6662	} `json:"-"`
6663}
6664
6665// Returns the unmodified JSON received from the API
6666func (r ResponseTextDoneEvent) RawJSON() string { return r.JSON.raw }
6667func (r *ResponseTextDoneEvent) UnmarshalJSON(data []byte) error {
6668	return apijson.UnmarshalRoot(data, r)
6669}
6670
6671// Represents token usage details including input tokens, output tokens, a
6672// breakdown of output tokens, and the total tokens used.
6673type ResponseUsage struct {
6674	// The number of input tokens.
6675	InputTokens int64 `json:"input_tokens,required"`
6676	// A detailed breakdown of the input tokens.
6677	InputTokensDetails ResponseUsageInputTokensDetails `json:"input_tokens_details,required"`
6678	// The number of output tokens.
6679	OutputTokens int64 `json:"output_tokens,required"`
6680	// A detailed breakdown of the output tokens.
6681	OutputTokensDetails ResponseUsageOutputTokensDetails `json:"output_tokens_details,required"`
6682	// The total number of tokens used.
6683	TotalTokens int64 `json:"total_tokens,required"`
6684	// Metadata for the response, check the presence of optional fields with the
6685	// [resp.Field.IsPresent] method.
6686	JSON struct {
6687		InputTokens         resp.Field
6688		InputTokensDetails  resp.Field
6689		OutputTokens        resp.Field
6690		OutputTokensDetails resp.Field
6691		TotalTokens         resp.Field
6692		ExtraFields         map[string]resp.Field
6693		raw                 string
6694	} `json:"-"`
6695}
6696
6697// Returns the unmodified JSON received from the API
6698func (r ResponseUsage) RawJSON() string { return r.JSON.raw }
6699func (r *ResponseUsage) UnmarshalJSON(data []byte) error {
6700	return apijson.UnmarshalRoot(data, r)
6701}
6702
6703// A detailed breakdown of the input tokens.
6704type ResponseUsageInputTokensDetails struct {
6705	// The number of tokens that were retrieved from the cache.
6706	// [More on prompt caching](https://platform.openai.com/docs/guides/prompt-caching).
6707	CachedTokens int64 `json:"cached_tokens,required"`
6708	// Metadata for the response, check the presence of optional fields with the
6709	// [resp.Field.IsPresent] method.
6710	JSON struct {
6711		CachedTokens resp.Field
6712		ExtraFields  map[string]resp.Field
6713		raw          string
6714	} `json:"-"`
6715}
6716
6717// Returns the unmodified JSON received from the API
6718func (r ResponseUsageInputTokensDetails) RawJSON() string { return r.JSON.raw }
6719func (r *ResponseUsageInputTokensDetails) UnmarshalJSON(data []byte) error {
6720	return apijson.UnmarshalRoot(data, r)
6721}
6722
6723// A detailed breakdown of the output tokens.
6724type ResponseUsageOutputTokensDetails struct {
6725	// The number of reasoning tokens.
6726	ReasoningTokens int64 `json:"reasoning_tokens,required"`
6727	// Metadata for the response, check the presence of optional fields with the
6728	// [resp.Field.IsPresent] method.
6729	JSON struct {
6730		ReasoningTokens resp.Field
6731		ExtraFields     map[string]resp.Field
6732		raw             string
6733	} `json:"-"`
6734}
6735
6736// Returns the unmodified JSON received from the API
6737func (r ResponseUsageOutputTokensDetails) RawJSON() string { return r.JSON.raw }
6738func (r *ResponseUsageOutputTokensDetails) UnmarshalJSON(data []byte) error {
6739	return apijson.UnmarshalRoot(data, r)
6740}
6741
6742// Emitted when a web search call is completed.
6743type ResponseWebSearchCallCompletedEvent struct {
6744	// Unique ID for the output item associated with the web search call.
6745	ItemID string `json:"item_id,required"`
6746	// The index of the output item that the web search call is associated with.
6747	OutputIndex int64 `json:"output_index,required"`
6748	// The type of the event. Always `response.web_search_call.completed`.
6749	Type constant.ResponseWebSearchCallCompleted `json:"type,required"`
6750	// Metadata for the response, check the presence of optional fields with the
6751	// [resp.Field.IsPresent] method.
6752	JSON struct {
6753		ItemID      resp.Field
6754		OutputIndex resp.Field
6755		Type        resp.Field
6756		ExtraFields map[string]resp.Field
6757		raw         string
6758	} `json:"-"`
6759}
6760
6761// Returns the unmodified JSON received from the API
6762func (r ResponseWebSearchCallCompletedEvent) RawJSON() string { return r.JSON.raw }
6763func (r *ResponseWebSearchCallCompletedEvent) UnmarshalJSON(data []byte) error {
6764	return apijson.UnmarshalRoot(data, r)
6765}
6766
6767// Emitted when a web search call is initiated.
6768type ResponseWebSearchCallInProgressEvent struct {
6769	// Unique ID for the output item associated with the web search call.
6770	ItemID string `json:"item_id,required"`
6771	// The index of the output item that the web search call is associated with.
6772	OutputIndex int64 `json:"output_index,required"`
6773	// The type of the event. Always `response.web_search_call.in_progress`.
6774	Type constant.ResponseWebSearchCallInProgress `json:"type,required"`
6775	// Metadata for the response, check the presence of optional fields with the
6776	// [resp.Field.IsPresent] method.
6777	JSON struct {
6778		ItemID      resp.Field
6779		OutputIndex resp.Field
6780		Type        resp.Field
6781		ExtraFields map[string]resp.Field
6782		raw         string
6783	} `json:"-"`
6784}
6785
6786// Returns the unmodified JSON received from the API
6787func (r ResponseWebSearchCallInProgressEvent) RawJSON() string { return r.JSON.raw }
6788func (r *ResponseWebSearchCallInProgressEvent) UnmarshalJSON(data []byte) error {
6789	return apijson.UnmarshalRoot(data, r)
6790}
6791
6792// Emitted when a web search call is executing.
6793type ResponseWebSearchCallSearchingEvent struct {
6794	// Unique ID for the output item associated with the web search call.
6795	ItemID string `json:"item_id,required"`
6796	// The index of the output item that the web search call is associated with.
6797	OutputIndex int64 `json:"output_index,required"`
6798	// The type of the event. Always `response.web_search_call.searching`.
6799	Type constant.ResponseWebSearchCallSearching `json:"type,required"`
6800	// Metadata for the response, check the presence of optional fields with the
6801	// [resp.Field.IsPresent] method.
6802	JSON struct {
6803		ItemID      resp.Field
6804		OutputIndex resp.Field
6805		Type        resp.Field
6806		ExtraFields map[string]resp.Field
6807		raw         string
6808	} `json:"-"`
6809}
6810
6811// Returns the unmodified JSON received from the API
6812func (r ResponseWebSearchCallSearchingEvent) RawJSON() string { return r.JSON.raw }
6813func (r *ResponseWebSearchCallSearchingEvent) UnmarshalJSON(data []byte) error {
6814	return apijson.UnmarshalRoot(data, r)
6815}
6816
6817// ToolUnion contains all possible properties and values from [FileSearchTool],
6818// [FunctionTool], [ComputerTool], [WebSearchTool].
6819//
6820// Use the [ToolUnion.AsAny] method to switch on the variant.
6821//
6822// Use the methods beginning with 'As' to cast the union to one of its variants.
6823type ToolUnion struct {
6824	// Any of "file_search", "function", "computer_use_preview", nil.
6825	Type string `json:"type"`
6826	// This field is from variant [FileSearchTool].
6827	VectorStoreIDs []string `json:"vector_store_ids"`
6828	// This field is from variant [FileSearchTool].
6829	Filters FileSearchToolFiltersUnion `json:"filters"`
6830	// This field is from variant [FileSearchTool].
6831	MaxNumResults int64 `json:"max_num_results"`
6832	// This field is from variant [FileSearchTool].
6833	RankingOptions FileSearchToolRankingOptions `json:"ranking_options"`
6834	// This field is from variant [FunctionTool].
6835	Name string `json:"name"`
6836	// This field is from variant [FunctionTool].
6837	Parameters map[string]interface{} `json:"parameters"`
6838	// This field is from variant [FunctionTool].
6839	Strict bool `json:"strict"`
6840	// This field is from variant [FunctionTool].
6841	Description string `json:"description"`
6842	// This field is from variant [ComputerTool].
6843	DisplayHeight float64 `json:"display_height"`
6844	// This field is from variant [ComputerTool].
6845	DisplayWidth float64 `json:"display_width"`
6846	// This field is from variant [ComputerTool].
6847	Environment ComputerToolEnvironment `json:"environment"`
6848	// This field is from variant [WebSearchTool].
6849	SearchContextSize WebSearchToolSearchContextSize `json:"search_context_size"`
6850	// This field is from variant [WebSearchTool].
6851	UserLocation WebSearchToolUserLocation `json:"user_location"`
6852	JSON         struct {
6853		Type              resp.Field
6854		VectorStoreIDs    resp.Field
6855		Filters           resp.Field
6856		MaxNumResults     resp.Field
6857		RankingOptions    resp.Field
6858		Name              resp.Field
6859		Parameters        resp.Field
6860		Strict            resp.Field
6861		Description       resp.Field
6862		DisplayHeight     resp.Field
6863		DisplayWidth      resp.Field
6864		Environment       resp.Field
6865		SearchContextSize resp.Field
6866		UserLocation      resp.Field
6867		raw               string
6868	} `json:"-"`
6869}
6870
6871func (u ToolUnion) AsFileSearch() (v FileSearchTool) {
6872	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6873	return
6874}
6875
6876func (u ToolUnion) AsFunction() (v FunctionTool) {
6877	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6878	return
6879}
6880
6881func (u ToolUnion) AsComputerUsePreview() (v ComputerTool) {
6882	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6883	return
6884}
6885
6886func (u ToolUnion) AsWebSearch() (v WebSearchTool) {
6887	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
6888	return
6889}
6890
6891// Returns the unmodified JSON received from the API
6892func (u ToolUnion) RawJSON() string { return u.JSON.raw }
6893
6894func (r *ToolUnion) UnmarshalJSON(data []byte) error {
6895	return apijson.UnmarshalRoot(data, r)
6896}
6897
6898// ToParam converts this ToolUnion to a ToolUnionParam.
6899//
6900// Warning: the fields of the param type will not be present. ToParam should only
6901// be used at the last possible moment before sending a request. Test for this with
6902// ToolUnionParam.IsOverridden()
6903func (r ToolUnion) ToParam() ToolUnionParam {
6904	return param.OverrideObj[ToolUnionParam](r.RawJSON())
6905}
6906
6907func ToolParamOfFileSearch(vectorStoreIDs []string) ToolUnionParam {
6908	var fileSearch FileSearchToolParam
6909	fileSearch.VectorStoreIDs = vectorStoreIDs
6910	return ToolUnionParam{OfFileSearch: &fileSearch}
6911}
6912
6913func ToolParamOfFunction(name string, parameters map[string]interface{}, strict bool) ToolUnionParam {
6914	var function FunctionToolParam
6915	function.Name = name
6916	function.Parameters = parameters
6917	function.Strict = strict
6918	return ToolUnionParam{OfFunction: &function}
6919}
6920
6921func ToolParamOfComputerUsePreview(displayHeight float64, displayWidth float64, environment ComputerToolEnvironment) ToolUnionParam {
6922	var computerUsePreview ComputerToolParam
6923	computerUsePreview.DisplayHeight = displayHeight
6924	computerUsePreview.DisplayWidth = displayWidth
6925	computerUsePreview.Environment = environment
6926	return ToolUnionParam{OfComputerUsePreview: &computerUsePreview}
6927}
6928
6929func ToolParamOfWebSearch(type_ WebSearchToolType) ToolUnionParam {
6930	var variant WebSearchToolParam
6931	variant.Type = type_
6932	return ToolUnionParam{OfWebSearch: &variant}
6933}
6934
6935// Only one field can be non-zero.
6936//
6937// Use [param.IsOmitted] to confirm if a field is set.
6938type ToolUnionParam struct {
6939	OfFileSearch         *FileSearchToolParam `json:",omitzero,inline"`
6940	OfFunction           *FunctionToolParam   `json:",omitzero,inline"`
6941	OfComputerUsePreview *ComputerToolParam   `json:",omitzero,inline"`
6942	OfWebSearch          *WebSearchToolParam  `json:",omitzero,inline"`
6943	paramUnion
6944}
6945
6946// IsPresent returns true if the field's value is not omitted and not the JSON
6947// "null". To check if this field is omitted, use [param.IsOmitted].
6948func (u ToolUnionParam) IsPresent() bool { return !param.IsOmitted(u) && !u.IsNull() }
6949func (u ToolUnionParam) MarshalJSON() ([]byte, error) {
6950	return param.MarshalUnion[ToolUnionParam](u.OfFileSearch, u.OfFunction, u.OfComputerUsePreview, u.OfWebSearch)
6951}
6952
6953func (u *ToolUnionParam) asAny() any {
6954	if !param.IsOmitted(u.OfFileSearch) {
6955		return u.OfFileSearch
6956	} else if !param.IsOmitted(u.OfFunction) {
6957		return u.OfFunction
6958	} else if !param.IsOmitted(u.OfComputerUsePreview) {
6959		return u.OfComputerUsePreview
6960	} else if !param.IsOmitted(u.OfWebSearch) {
6961		return u.OfWebSearch
6962	}
6963	return nil
6964}
6965
6966// Returns a pointer to the underlying variant's property, if present.
6967func (u ToolUnionParam) GetVectorStoreIDs() []string {
6968	if vt := u.OfFileSearch; vt != nil {
6969		return vt.VectorStoreIDs
6970	}
6971	return nil
6972}
6973
6974// Returns a pointer to the underlying variant's property, if present.
6975func (u ToolUnionParam) GetFilters() *FileSearchToolFiltersUnionParam {
6976	if vt := u.OfFileSearch; vt != nil {
6977		return &vt.Filters
6978	}
6979	return nil
6980}
6981
6982// Returns a pointer to the underlying variant's property, if present.
6983func (u ToolUnionParam) GetMaxNumResults() *int64 {
6984	if vt := u.OfFileSearch; vt != nil && vt.MaxNumResults.IsPresent() {
6985		return &vt.MaxNumResults.Value
6986	}
6987	return nil
6988}
6989
6990// Returns a pointer to the underlying variant's property, if present.
6991func (u ToolUnionParam) GetRankingOptions() *FileSearchToolRankingOptionsParam {
6992	if vt := u.OfFileSearch; vt != nil {
6993		return &vt.RankingOptions
6994	}
6995	return nil
6996}
6997
6998// Returns a pointer to the underlying variant's property, if present.
6999func (u ToolUnionParam) GetName() *string {
7000	if vt := u.OfFunction; vt != nil {
7001		return &vt.Name
7002	}
7003	return nil
7004}
7005
7006// Returns a pointer to the underlying variant's property, if present.
7007func (u ToolUnionParam) GetParameters() map[string]interface{} {
7008	if vt := u.OfFunction; vt != nil {
7009		return vt.Parameters
7010	}
7011	return nil
7012}
7013
7014// Returns a pointer to the underlying variant's property, if present.
7015func (u ToolUnionParam) GetStrict() *bool {
7016	if vt := u.OfFunction; vt != nil {
7017		return &vt.Strict
7018	}
7019	return nil
7020}
7021
7022// Returns a pointer to the underlying variant's property, if present.
7023func (u ToolUnionParam) GetDescription() *string {
7024	if vt := u.OfFunction; vt != nil && vt.Description.IsPresent() {
7025		return &vt.Description.Value
7026	}
7027	return nil
7028}
7029
7030// Returns a pointer to the underlying variant's property, if present.
7031func (u ToolUnionParam) GetDisplayHeight() *float64 {
7032	if vt := u.OfComputerUsePreview; vt != nil {
7033		return &vt.DisplayHeight
7034	}
7035	return nil
7036}
7037
7038// Returns a pointer to the underlying variant's property, if present.
7039func (u ToolUnionParam) GetDisplayWidth() *float64 {
7040	if vt := u.OfComputerUsePreview; vt != nil {
7041		return &vt.DisplayWidth
7042	}
7043	return nil
7044}
7045
7046// Returns a pointer to the underlying variant's property, if present.
7047func (u ToolUnionParam) GetEnvironment() *string {
7048	if vt := u.OfComputerUsePreview; vt != nil {
7049		return (*string)(&vt.Environment)
7050	}
7051	return nil
7052}
7053
7054// Returns a pointer to the underlying variant's property, if present.
7055func (u ToolUnionParam) GetSearchContextSize() *string {
7056	if vt := u.OfWebSearch; vt != nil {
7057		return (*string)(&vt.SearchContextSize)
7058	}
7059	return nil
7060}
7061
7062// Returns a pointer to the underlying variant's property, if present.
7063func (u ToolUnionParam) GetUserLocation() *WebSearchToolUserLocationParam {
7064	if vt := u.OfWebSearch; vt != nil {
7065		return &vt.UserLocation
7066	}
7067	return nil
7068}
7069
7070// Returns a pointer to the underlying variant's property, if present.
7071func (u ToolUnionParam) GetType() *string {
7072	if vt := u.OfFileSearch; vt != nil {
7073		return (*string)(&vt.Type)
7074	} else if vt := u.OfFunction; vt != nil {
7075		return (*string)(&vt.Type)
7076	} else if vt := u.OfComputerUsePreview; vt != nil {
7077		return (*string)(&vt.Type)
7078	} else if vt := u.OfWebSearch; vt != nil {
7079		return (*string)(&vt.Type)
7080	}
7081	return nil
7082}
7083
7084func init() {
7085	apijson.RegisterUnion[ToolUnionParam](
7086		"type",
7087		apijson.UnionVariant{
7088			TypeFilter:         gjson.JSON,
7089			Type:               reflect.TypeOf(FileSearchToolParam{}),
7090			DiscriminatorValue: "file_search",
7091		},
7092		apijson.UnionVariant{
7093			TypeFilter:         gjson.JSON,
7094			Type:               reflect.TypeOf(FunctionToolParam{}),
7095			DiscriminatorValue: "function",
7096		},
7097		apijson.UnionVariant{
7098			TypeFilter:         gjson.JSON,
7099			Type:               reflect.TypeOf(ComputerToolParam{}),
7100			DiscriminatorValue: "computer_use_preview",
7101		},
7102		apijson.UnionVariant{
7103			TypeFilter:         gjson.JSON,
7104			Type:               reflect.TypeOf(WebSearchToolParam{}),
7105			DiscriminatorValue: "web_search_preview",
7106		},
7107		apijson.UnionVariant{
7108			TypeFilter:         gjson.JSON,
7109			Type:               reflect.TypeOf(WebSearchToolParam{}),
7110			DiscriminatorValue: "web_search_preview_2025_03_11",
7111		},
7112	)
7113}
7114
7115// Use this option to force the model to call a specific function.
7116type ToolChoiceFunction struct {
7117	// The name of the function to call.
7118	Name string `json:"name,required"`
7119	// For function calling, the type is always `function`.
7120	Type constant.Function `json:"type,required"`
7121	// Metadata for the response, check the presence of optional fields with the
7122	// [resp.Field.IsPresent] method.
7123	JSON struct {
7124		Name        resp.Field
7125		Type        resp.Field
7126		ExtraFields map[string]resp.Field
7127		raw         string
7128	} `json:"-"`
7129}
7130
7131// Returns the unmodified JSON received from the API
7132func (r ToolChoiceFunction) RawJSON() string { return r.JSON.raw }
7133func (r *ToolChoiceFunction) UnmarshalJSON(data []byte) error {
7134	return apijson.UnmarshalRoot(data, r)
7135}
7136
7137// ToParam converts this ToolChoiceFunction to a ToolChoiceFunctionParam.
7138//
7139// Warning: the fields of the param type will not be present. ToParam should only
7140// be used at the last possible moment before sending a request. Test for this with
7141// ToolChoiceFunctionParam.IsOverridden()
7142func (r ToolChoiceFunction) ToParam() ToolChoiceFunctionParam {
7143	return param.OverrideObj[ToolChoiceFunctionParam](r.RawJSON())
7144}
7145
7146// Use this option to force the model to call a specific function.
7147//
7148// The properties Name, Type are required.
7149type ToolChoiceFunctionParam struct {
7150	// The name of the function to call.
7151	Name string `json:"name,required"`
7152	// For function calling, the type is always `function`.
7153	//
7154	// This field can be elided, and will marshal its zero value as "function".
7155	Type constant.Function `json:"type,required"`
7156	paramObj
7157}
7158
7159// IsPresent returns true if the field's value is not omitted and not the JSON
7160// "null". To check if this field is omitted, use [param.IsOmitted].
7161func (f ToolChoiceFunctionParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
7162func (r ToolChoiceFunctionParam) MarshalJSON() (data []byte, err error) {
7163	type shadow ToolChoiceFunctionParam
7164	return param.MarshalObject(r, (*shadow)(&r))
7165}
7166
7167// Controls which (if any) tool is called by the model.
7168//
7169// `none` means the model will not call any tool and instead generates a message.
7170//
7171// `auto` means the model can pick between generating a message or calling one or
7172// more tools.
7173//
7174// `required` means the model must call one or more tools.
7175type ToolChoiceOptions string
7176
7177const (
7178	ToolChoiceOptionsNone     ToolChoiceOptions = "none"
7179	ToolChoiceOptionsAuto     ToolChoiceOptions = "auto"
7180	ToolChoiceOptionsRequired ToolChoiceOptions = "required"
7181)
7182
7183// Indicates that the model should use a built-in tool to generate a response.
7184// [Learn more about built-in tools](https://platform.openai.com/docs/guides/tools).
7185type ToolChoiceTypes struct {
7186	// The type of hosted tool the model should to use. Learn more about
7187	// [built-in tools](https://platform.openai.com/docs/guides/tools).
7188	//
7189	// Allowed values are:
7190	//
7191	// - `file_search`
7192	// - `web_search_preview`
7193	// - `computer_use_preview`
7194	//
7195	// Any of "file_search", "web_search_preview", "computer_use_preview",
7196	// "web_search_preview_2025_03_11".
7197	Type ToolChoiceTypesType `json:"type,required"`
7198	// Metadata for the response, check the presence of optional fields with the
7199	// [resp.Field.IsPresent] method.
7200	JSON struct {
7201		Type        resp.Field
7202		ExtraFields map[string]resp.Field
7203		raw         string
7204	} `json:"-"`
7205}
7206
7207// Returns the unmodified JSON received from the API
7208func (r ToolChoiceTypes) RawJSON() string { return r.JSON.raw }
7209func (r *ToolChoiceTypes) UnmarshalJSON(data []byte) error {
7210	return apijson.UnmarshalRoot(data, r)
7211}
7212
7213// ToParam converts this ToolChoiceTypes to a ToolChoiceTypesParam.
7214//
7215// Warning: the fields of the param type will not be present. ToParam should only
7216// be used at the last possible moment before sending a request. Test for this with
7217// ToolChoiceTypesParam.IsOverridden()
7218func (r ToolChoiceTypes) ToParam() ToolChoiceTypesParam {
7219	return param.OverrideObj[ToolChoiceTypesParam](r.RawJSON())
7220}
7221
7222// The type of hosted tool the model should to use. Learn more about
7223// [built-in tools](https://platform.openai.com/docs/guides/tools).
7224//
7225// Allowed values are:
7226//
7227// - `file_search`
7228// - `web_search_preview`
7229// - `computer_use_preview`
7230type ToolChoiceTypesType string
7231
7232const (
7233	ToolChoiceTypesTypeFileSearch                 ToolChoiceTypesType = "file_search"
7234	ToolChoiceTypesTypeWebSearchPreview           ToolChoiceTypesType = "web_search_preview"
7235	ToolChoiceTypesTypeComputerUsePreview         ToolChoiceTypesType = "computer_use_preview"
7236	ToolChoiceTypesTypeWebSearchPreview2025_03_11 ToolChoiceTypesType = "web_search_preview_2025_03_11"
7237)
7238
7239// Indicates that the model should use a built-in tool to generate a response.
7240// [Learn more about built-in tools](https://platform.openai.com/docs/guides/tools).
7241//
7242// The property Type is required.
7243type ToolChoiceTypesParam struct {
7244	// The type of hosted tool the model should to use. Learn more about
7245	// [built-in tools](https://platform.openai.com/docs/guides/tools).
7246	//
7247	// Allowed values are:
7248	//
7249	// - `file_search`
7250	// - `web_search_preview`
7251	// - `computer_use_preview`
7252	//
7253	// Any of "file_search", "web_search_preview", "computer_use_preview",
7254	// "web_search_preview_2025_03_11".
7255	Type ToolChoiceTypesType `json:"type,omitzero,required"`
7256	paramObj
7257}
7258
7259// IsPresent returns true if the field's value is not omitted and not the JSON
7260// "null". To check if this field is omitted, use [param.IsOmitted].
7261func (f ToolChoiceTypesParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
7262func (r ToolChoiceTypesParam) MarshalJSON() (data []byte, err error) {
7263	type shadow ToolChoiceTypesParam
7264	return param.MarshalObject(r, (*shadow)(&r))
7265}
7266
7267// This tool searches the web for relevant results to use in a response. Learn more
7268// about the
7269// [web search tool](https://platform.openai.com/docs/guides/tools-web-search).
7270type WebSearchTool struct {
7271	// The type of the web search tool. One of:
7272	//
7273	// - `web_search_preview`
7274	// - `web_search_preview_2025_03_11`
7275	//
7276	// Any of "web_search_preview", "web_search_preview_2025_03_11".
7277	Type WebSearchToolType `json:"type,required"`
7278	// High level guidance for the amount of context window space to use for the
7279	// search. One of `low`, `medium`, or `high`. `medium` is the default.
7280	//
7281	// Any of "low", "medium", "high".
7282	SearchContextSize WebSearchToolSearchContextSize `json:"search_context_size"`
7283	UserLocation      WebSearchToolUserLocation      `json:"user_location,nullable"`
7284	// Metadata for the response, check the presence of optional fields with the
7285	// [resp.Field.IsPresent] method.
7286	JSON struct {
7287		Type              resp.Field
7288		SearchContextSize resp.Field
7289		UserLocation      resp.Field
7290		ExtraFields       map[string]resp.Field
7291		raw               string
7292	} `json:"-"`
7293}
7294
7295// Returns the unmodified JSON received from the API
7296func (r WebSearchTool) RawJSON() string { return r.JSON.raw }
7297func (r *WebSearchTool) UnmarshalJSON(data []byte) error {
7298	return apijson.UnmarshalRoot(data, r)
7299}
7300
7301// ToParam converts this WebSearchTool to a WebSearchToolParam.
7302//
7303// Warning: the fields of the param type will not be present. ToParam should only
7304// be used at the last possible moment before sending a request. Test for this with
7305// WebSearchToolParam.IsOverridden()
7306func (r WebSearchTool) ToParam() WebSearchToolParam {
7307	return param.OverrideObj[WebSearchToolParam](r.RawJSON())
7308}
7309
7310// The type of the web search tool. One of:
7311//
7312// - `web_search_preview`
7313// - `web_search_preview_2025_03_11`
7314type WebSearchToolType string
7315
7316const (
7317	WebSearchToolTypeWebSearchPreview           WebSearchToolType = "web_search_preview"
7318	WebSearchToolTypeWebSearchPreview2025_03_11 WebSearchToolType = "web_search_preview_2025_03_11"
7319)
7320
7321// High level guidance for the amount of context window space to use for the
7322// search. One of `low`, `medium`, or `high`. `medium` is the default.
7323type WebSearchToolSearchContextSize string
7324
7325const (
7326	WebSearchToolSearchContextSizeLow    WebSearchToolSearchContextSize = "low"
7327	WebSearchToolSearchContextSizeMedium WebSearchToolSearchContextSize = "medium"
7328	WebSearchToolSearchContextSizeHigh   WebSearchToolSearchContextSize = "high"
7329)
7330
7331type WebSearchToolUserLocation struct {
7332	// The type of location approximation. Always `approximate`.
7333	Type constant.Approximate `json:"type,required"`
7334	// Free text input for the city of the user, e.g. `San Francisco`.
7335	City string `json:"city"`
7336	// The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of
7337	// the user, e.g. `US`.
7338	Country string `json:"country"`
7339	// Free text input for the region of the user, e.g. `California`.
7340	Region string `json:"region"`
7341	// The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the
7342	// user, e.g. `America/Los_Angeles`.
7343	Timezone string `json:"timezone"`
7344	// Metadata for the response, check the presence of optional fields with the
7345	// [resp.Field.IsPresent] method.
7346	JSON struct {
7347		Type        resp.Field
7348		City        resp.Field
7349		Country     resp.Field
7350		Region      resp.Field
7351		Timezone    resp.Field
7352		ExtraFields map[string]resp.Field
7353		raw         string
7354	} `json:"-"`
7355}
7356
7357// Returns the unmodified JSON received from the API
7358func (r WebSearchToolUserLocation) RawJSON() string { return r.JSON.raw }
7359func (r *WebSearchToolUserLocation) UnmarshalJSON(data []byte) error {
7360	return apijson.UnmarshalRoot(data, r)
7361}
7362
7363// This tool searches the web for relevant results to use in a response. Learn more
7364// about the
7365// [web search tool](https://platform.openai.com/docs/guides/tools-web-search).
7366//
7367// The property Type is required.
7368type WebSearchToolParam struct {
7369	// The type of the web search tool. One of:
7370	//
7371	// - `web_search_preview`
7372	// - `web_search_preview_2025_03_11`
7373	//
7374	// Any of "web_search_preview", "web_search_preview_2025_03_11".
7375	Type         WebSearchToolType              `json:"type,omitzero,required"`
7376	UserLocation WebSearchToolUserLocationParam `json:"user_location,omitzero"`
7377	// High level guidance for the amount of context window space to use for the
7378	// search. One of `low`, `medium`, or `high`. `medium` is the default.
7379	//
7380	// Any of "low", "medium", "high".
7381	SearchContextSize WebSearchToolSearchContextSize `json:"search_context_size,omitzero"`
7382	paramObj
7383}
7384
7385// IsPresent returns true if the field's value is not omitted and not the JSON
7386// "null". To check if this field is omitted, use [param.IsOmitted].
7387func (f WebSearchToolParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
7388func (r WebSearchToolParam) MarshalJSON() (data []byte, err error) {
7389	type shadow WebSearchToolParam
7390	return param.MarshalObject(r, (*shadow)(&r))
7391}
7392
7393// The property Type is required.
7394type WebSearchToolUserLocationParam struct {
7395	// Free text input for the city of the user, e.g. `San Francisco`.
7396	City param.Opt[string] `json:"city,omitzero"`
7397	// The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of
7398	// the user, e.g. `US`.
7399	Country param.Opt[string] `json:"country,omitzero"`
7400	// Free text input for the region of the user, e.g. `California`.
7401	Region param.Opt[string] `json:"region,omitzero"`
7402	// The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the
7403	// user, e.g. `America/Los_Angeles`.
7404	Timezone param.Opt[string] `json:"timezone,omitzero"`
7405	// The type of location approximation. Always `approximate`.
7406	//
7407	// This field can be elided, and will marshal its zero value as "approximate".
7408	Type constant.Approximate `json:"type,required"`
7409	paramObj
7410}
7411
7412// IsPresent returns true if the field's value is not omitted and not the JSON
7413// "null". To check if this field is omitted, use [param.IsOmitted].
7414func (f WebSearchToolUserLocationParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
7415func (r WebSearchToolUserLocationParam) MarshalJSON() (data []byte, err error) {
7416	type shadow WebSearchToolUserLocationParam
7417	return param.MarshalObject(r, (*shadow)(&r))
7418}
7419
7420type ResponseNewParams struct {
7421	// Text, image, or file inputs to the model, used to generate a response.
7422	//
7423	// Learn more:
7424	//
7425	// - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
7426	// - [Image inputs](https://platform.openai.com/docs/guides/images)
7427	// - [File inputs](https://platform.openai.com/docs/guides/pdf-files)
7428	// - [Conversation state](https://platform.openai.com/docs/guides/conversation-state)
7429	// - [Function calling](https://platform.openai.com/docs/guides/function-calling)
7430	Input ResponseNewParamsInputUnion `json:"input,omitzero,required"`
7431	// Model ID used to generate the response, like `gpt-4o` or `o1`. OpenAI offers a
7432	// wide range of models with different capabilities, performance characteristics,
7433	// and price points. Refer to the
7434	// [model guide](https://platform.openai.com/docs/models) to browse and compare
7435	// available models.
7436	Model shared.ResponsesModel `json:"model,omitzero,required"`
7437	// Inserts a system (or developer) message as the first item in the model's
7438	// context.
7439	//
7440	// When using along with `previous_response_id`, the instructions from a previous
7441	// response will be not be carried over to the next response. This makes it simple
7442	// to swap out system (or developer) messages in new responses.
7443	Instructions param.Opt[string] `json:"instructions,omitzero"`
7444	// An upper bound for the number of tokens that can be generated for a response,
7445	// including visible output tokens and
7446	// [reasoning tokens](https://platform.openai.com/docs/guides/reasoning).
7447	MaxOutputTokens param.Opt[int64] `json:"max_output_tokens,omitzero"`
7448	// Whether to allow the model to run tool calls in parallel.
7449	ParallelToolCalls param.Opt[bool] `json:"parallel_tool_calls,omitzero"`
7450	// The unique ID of the previous response to the model. Use this to create
7451	// multi-turn conversations. Learn more about
7452	// [conversation state](https://platform.openai.com/docs/guides/conversation-state).
7453	PreviousResponseID param.Opt[string] `json:"previous_response_id,omitzero"`
7454	// Whether to store the generated model response for later retrieval via API.
7455	Store param.Opt[bool] `json:"store,omitzero"`
7456	// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
7457	// make the output more random, while lower values like 0.2 will make it more
7458	// focused and deterministic. We generally recommend altering this or `top_p` but
7459	// not both.
7460	Temperature param.Opt[float64] `json:"temperature,omitzero"`
7461	// An alternative to sampling with temperature, called nucleus sampling, where the
7462	// model considers the results of the tokens with top_p probability mass. So 0.1
7463	// means only the tokens comprising the top 10% probability mass are considered.
7464	//
7465	// We generally recommend altering this or `temperature` but not both.
7466	TopP param.Opt[float64] `json:"top_p,omitzero"`
7467	// A unique identifier representing your end-user, which can help OpenAI to monitor
7468	// and detect abuse.
7469	// [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
7470	User param.Opt[string] `json:"user,omitzero"`
7471	// Specify additional output data to include in the model response. Currently
7472	// supported values are:
7473	//
7474	//   - `file_search_call.results`: Include the search results of the file search tool
7475	//     call.
7476	//   - `message.input_image.image_url`: Include image urls from the input message.
7477	//   - `computer_call_output.output.image_url`: Include image urls from the computer
7478	//     call output.
7479	Include []ResponseIncludable `json:"include,omitzero"`
7480	// Set of 16 key-value pairs that can be attached to an object. This can be useful
7481	// for storing additional information about the object in a structured format, and
7482	// querying for objects via API or the dashboard.
7483	//
7484	// Keys are strings with a maximum length of 64 characters. Values are strings with
7485	// a maximum length of 512 characters.
7486	Metadata shared.MetadataParam `json:"metadata,omitzero"`
7487	// The truncation strategy to use for the model response.
7488	//
7489	//   - `auto`: If the context of this response and previous ones exceeds the model's
7490	//     context window size, the model will truncate the response to fit the context
7491	//     window by dropping input items in the middle of the conversation.
7492	//   - `disabled` (default): If a model response will exceed the context window size
7493	//     for a model, the request will fail with a 400 error.
7494	//
7495	// Any of "auto", "disabled".
7496	Truncation ResponseNewParamsTruncation `json:"truncation,omitzero"`
7497	// **o-series models only**
7498	//
7499	// Configuration options for
7500	// [reasoning models](https://platform.openai.com/docs/guides/reasoning).
7501	Reasoning shared.ReasoningParam `json:"reasoning,omitzero"`
7502	// Configuration options for a text response from the model. Can be plain text or
7503	// structured JSON data. Learn more:
7504	//
7505	// - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
7506	// - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
7507	Text ResponseTextConfigParam `json:"text,omitzero"`
7508	// How the model should select which tool (or tools) to use when generating a
7509	// response. See the `tools` parameter to see how to specify which tools the model
7510	// can call.
7511	ToolChoice ResponseNewParamsToolChoiceUnion `json:"tool_choice,omitzero"`
7512	// An array of tools the model may call while generating a response. You can
7513	// specify which tool to use by setting the `tool_choice` parameter.
7514	//
7515	// The two categories of tools you can provide the model are:
7516	//
7517	//   - **Built-in tools**: Tools that are provided by OpenAI that extend the model's
7518	//     capabilities, like
7519	//     [web search](https://platform.openai.com/docs/guides/tools-web-search) or
7520	//     [file search](https://platform.openai.com/docs/guides/tools-file-search).
7521	//     Learn more about
7522	//     [built-in tools](https://platform.openai.com/docs/guides/tools).
7523	//   - **Function calls (custom tools)**: Functions that are defined by you, enabling
7524	//     the model to call your own code. Learn more about
7525	//     [function calling](https://platform.openai.com/docs/guides/function-calling).
7526	Tools []ToolUnionParam `json:"tools,omitzero"`
7527	paramObj
7528}
7529
7530// IsPresent returns true if the field's value is not omitted and not the JSON
7531// "null". To check if this field is omitted, use [param.IsOmitted].
7532func (f ResponseNewParams) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
7533
7534func (r ResponseNewParams) MarshalJSON() (data []byte, err error) {
7535	type shadow ResponseNewParams
7536	return param.MarshalObject(r, (*shadow)(&r))
7537}
7538
7539// Only one field can be non-zero.
7540//
7541// Use [param.IsOmitted] to confirm if a field is set.
7542type ResponseNewParamsInputUnion struct {
7543	OfString        param.Opt[string]  `json:",omitzero,inline"`
7544	OfInputItemList ResponseInputParam `json:",omitzero,inline"`
7545	paramUnion
7546}
7547
7548// IsPresent returns true if the field's value is not omitted and not the JSON
7549// "null". To check if this field is omitted, use [param.IsOmitted].
7550func (u ResponseNewParamsInputUnion) IsPresent() bool { return !param.IsOmitted(u) && !u.IsNull() }
7551func (u ResponseNewParamsInputUnion) MarshalJSON() ([]byte, error) {
7552	return param.MarshalUnion[ResponseNewParamsInputUnion](u.OfString, u.OfInputItemList)
7553}
7554
7555func (u *ResponseNewParamsInputUnion) asAny() any {
7556	if !param.IsOmitted(u.OfString) {
7557		return &u.OfString.Value
7558	} else if !param.IsOmitted(u.OfInputItemList) {
7559		return &u.OfInputItemList
7560	}
7561	return nil
7562}
7563
7564// Only one field can be non-zero.
7565//
7566// Use [param.IsOmitted] to confirm if a field is set.
7567type ResponseNewParamsToolChoiceUnion struct {
7568	// Check if union is this variant with !param.IsOmitted(union.OfToolChoiceMode)
7569	OfToolChoiceMode param.Opt[ToolChoiceOptions] `json:",omitzero,inline"`
7570	OfHostedTool     *ToolChoiceTypesParam        `json:",omitzero,inline"`
7571	OfFunctionTool   *ToolChoiceFunctionParam     `json:",omitzero,inline"`
7572	paramUnion
7573}
7574
7575// IsPresent returns true if the field's value is not omitted and not the JSON
7576// "null". To check if this field is omitted, use [param.IsOmitted].
7577func (u ResponseNewParamsToolChoiceUnion) IsPresent() bool { return !param.IsOmitted(u) && !u.IsNull() }
7578func (u ResponseNewParamsToolChoiceUnion) MarshalJSON() ([]byte, error) {
7579	return param.MarshalUnion[ResponseNewParamsToolChoiceUnion](u.OfToolChoiceMode, u.OfHostedTool, u.OfFunctionTool)
7580}
7581
7582func (u *ResponseNewParamsToolChoiceUnion) asAny() any {
7583	if !param.IsOmitted(u.OfToolChoiceMode) {
7584		return &u.OfToolChoiceMode
7585	} else if !param.IsOmitted(u.OfHostedTool) {
7586		return u.OfHostedTool
7587	} else if !param.IsOmitted(u.OfFunctionTool) {
7588		return u.OfFunctionTool
7589	}
7590	return nil
7591}
7592
7593// Returns a pointer to the underlying variant's property, if present.
7594func (u ResponseNewParamsToolChoiceUnion) GetName() *string {
7595	if vt := u.OfFunctionTool; vt != nil {
7596		return &vt.Name
7597	}
7598	return nil
7599}
7600
7601// Returns a pointer to the underlying variant's property, if present.
7602func (u ResponseNewParamsToolChoiceUnion) GetType() *string {
7603	if vt := u.OfHostedTool; vt != nil {
7604		return (*string)(&vt.Type)
7605	} else if vt := u.OfFunctionTool; vt != nil {
7606		return (*string)(&vt.Type)
7607	}
7608	return nil
7609}
7610
7611// The truncation strategy to use for the model response.
7612//
7613//   - `auto`: If the context of this response and previous ones exceeds the model's
7614//     context window size, the model will truncate the response to fit the context
7615//     window by dropping input items in the middle of the conversation.
7616//   - `disabled` (default): If a model response will exceed the context window size
7617//     for a model, the request will fail with a 400 error.
7618type ResponseNewParamsTruncation string
7619
7620const (
7621	ResponseNewParamsTruncationAuto     ResponseNewParamsTruncation = "auto"
7622	ResponseNewParamsTruncationDisabled ResponseNewParamsTruncation = "disabled"
7623)
7624
7625type ResponseGetParams struct {
7626	// Additional fields to include in the response. See the `include` parameter for
7627	// Response creation above for more information.
7628	Include []ResponseIncludable `query:"include,omitzero" json:"-"`
7629	paramObj
7630}
7631
7632// IsPresent returns true if the field's value is not omitted and not the JSON
7633// "null". To check if this field is omitted, use [param.IsOmitted].
7634func (f ResponseGetParams) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
7635
7636// URLQuery serializes [ResponseGetParams]'s query parameters as `url.Values`.
7637func (r ResponseGetParams) URLQuery() (v url.Values) {
7638	return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
7639		ArrayFormat:  apiquery.ArrayQueryFormatBrackets,
7640		NestedFormat: apiquery.NestedQueryFormatBrackets,
7641	})
7642}