// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

package openai

import (
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"net/http"
	"net/url"
	"slices"

	"github.com/openai/openai-go/v3/internal/apijson"
	"github.com/openai/openai-go/v3/internal/apiquery"
	"github.com/openai/openai-go/v3/internal/paramutil"
	"github.com/openai/openai-go/v3/internal/requestconfig"
	"github.com/openai/openai-go/v3/option"
	"github.com/openai/openai-go/v3/packages/param"
	"github.com/openai/openai-go/v3/packages/respjson"
	"github.com/openai/openai-go/v3/packages/ssestream"
	"github.com/openai/openai-go/v3/shared/constant"
)

// BetaResponseService contains methods and other services that help with
// interacting with the openai API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewBetaResponseService] method instead.
type BetaResponseService struct {
	Options     []option.RequestOption
	InputItems  BetaResponseInputItemService
	InputTokens BetaResponseInputTokenService
}

// NewBetaResponseService generates a new service that applies the given options to
// each request. These options are applied after the parent client's options (if
// there is one), and before any request-specific options.
func NewBetaResponseService(opts ...option.RequestOption) (r BetaResponseService) {
	r = BetaResponseService{}
	r.Options = opts
	r.InputItems = NewBetaResponseInputItemService(opts...)
	r.InputTokens = NewBetaResponseInputTokenService(opts...)
	return
}

// Creates a model response. Provide
// [text](https://platform.openai.com/docs/guides/text) or
// [image](https://platform.openai.com/docs/guides/images) inputs to generate
// [text](https://platform.openai.com/docs/guides/text) or
// [JSON](https://platform.openai.com/docs/guides/structured-outputs) outputs. Have
// the model call your own
// [custom code](https://platform.openai.com/docs/guides/function-calling) or use
// built-in [tools](https://platform.openai.com/docs/guides/tools) like
// [web search](https://platform.openai.com/docs/guides/tools-web-search) or
// [file search](https://platform.openai.com/docs/guides/tools-file-search) to use
// your own data as input for the model's response.
func (r *BetaResponseService) New(ctx context.Context, params BetaResponseNewParams, opts ...option.RequestOption) (res *BetaResponse, err error) {
	for _, v := range params.Betas {
		opts = append(opts, option.WithHeaderAdd("openai-beta", fmt.Sprintf("%v", v)))
	}
	var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
	opts = slices.Concat(preClientOpts, r.Options, opts)
	path := "responses?beta=true"
	err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
	return res, err
}

// Creates a model response. Provide
// [text](https://platform.openai.com/docs/guides/text) or
// [image](https://platform.openai.com/docs/guides/images) inputs to generate
// [text](https://platform.openai.com/docs/guides/text) or
// [JSON](https://platform.openai.com/docs/guides/structured-outputs) outputs. Have
// the model call your own
// [custom code](https://platform.openai.com/docs/guides/function-calling) or use
// built-in [tools](https://platform.openai.com/docs/guides/tools) like
// [web search](https://platform.openai.com/docs/guides/tools-web-search) or
// [file search](https://platform.openai.com/docs/guides/tools-file-search) to use
// your own data as input for the model's response.
func (r *BetaResponseService) NewStreaming(ctx context.Context, params BetaResponseNewParams, opts ...option.RequestOption) (stream *ssestream.Stream[BetaResponseStreamEventUnion]) {
	var (
		raw *http.Response
		err error
	)
	for _, v := range params.Betas {
		opts = append(opts, option.WithHeaderAdd("openai-beta", fmt.Sprintf("%v", v)))
	}
	var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
	opts = slices.Concat(preClientOpts, r.Options, opts)
	opts = append(opts, option.WithJSONSet("stream", true))
	path := "responses?beta=true"
	err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &raw, opts...)
	return ssestream.NewStream[BetaResponseStreamEventUnion](ssestream.NewDecoder(raw), err)
}

// Retrieves a model response with the given ID.
func (r *BetaResponseService) Get(ctx context.Context, responseID string, params BetaResponseGetParams, opts ...option.RequestOption) (res *BetaResponse, err error) {
	for _, v := range params.Betas {
		opts = append(opts, option.WithHeaderAdd("openai-beta", fmt.Sprintf("%v", v)))
	}
	var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
	opts = slices.Concat(preClientOpts, r.Options, opts)
	if responseID == "" {
		err = errors.New("missing required response_id parameter")
		return nil, err
	}
	path := requestconfig.FormatPath("responses/%s?beta=true", responseID)
	err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &res, opts...)
	return res, err
}

// Retrieves a model response with the given ID.
func (r *BetaResponseService) GetStreaming(ctx context.Context, responseID string, params BetaResponseGetParams, opts ...option.RequestOption) (stream *ssestream.Stream[BetaResponseStreamEventUnion]) {
	var (
		raw *http.Response
		err error
	)
	for _, v := range params.Betas {
		opts = append(opts, option.WithHeaderAdd("openai-beta", fmt.Sprintf("%v", v)))
	}
	var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
	opts = slices.Concat(preClientOpts, r.Options, opts)
	opts = append(opts, option.WithJSONSet("stream", true))
	if responseID == "" {
		err = errors.New("missing required response_id parameter")
		return ssestream.NewStream[BetaResponseStreamEventUnion](nil, err)
	}
	path := requestconfig.FormatPath("responses/%s?beta=true", responseID)
	err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &raw, opts...)
	return ssestream.NewStream[BetaResponseStreamEventUnion](ssestream.NewDecoder(raw), err)
}

// Deletes a model response with the given ID.
func (r *BetaResponseService) Delete(ctx context.Context, responseID string, body BetaResponseDeleteParams, opts ...option.RequestOption) (err error) {
	for _, v := range body.Betas {
		opts = append(opts, option.WithHeaderAdd("openai-beta", fmt.Sprintf("%v", v)))
	}
	var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
	opts = slices.Concat(preClientOpts, r.Options, opts)
	opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...)
	if responseID == "" {
		err = errors.New("missing required response_id parameter")
		return err
	}
	path := requestconfig.FormatPath("responses/%s?beta=true", responseID)
	err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...)
	return err
}

// Cancels a model response with the given ID. Only responses created with the
// `background` parameter set to `true` can be cancelled.
// [Learn more](https://platform.openai.com/docs/guides/background).
func (r *BetaResponseService) Cancel(ctx context.Context, responseID string, body BetaResponseCancelParams, opts ...option.RequestOption) (res *BetaResponse, err error) {
	for _, v := range body.Betas {
		opts = append(opts, option.WithHeaderAdd("openai-beta", fmt.Sprintf("%v", v)))
	}
	var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
	opts = slices.Concat(preClientOpts, r.Options, opts)
	if responseID == "" {
		err = errors.New("missing required response_id parameter")
		return nil, err
	}
	path := requestconfig.FormatPath("responses/%s/cancel?beta=true", responseID)
	err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
	return res, err
}

// Compact a conversation. Returns a compacted response object.
//
// Learn when and how to compact long-running conversations in the
// [conversation state guide](https://platform.openai.com/docs/guides/conversation-state#managing-the-context-window).
// For ZDR-compatible compaction details, see
// [Compaction (advanced)](https://platform.openai.com/docs/guides/conversation-state#compaction-advanced).
func (r *BetaResponseService) Compact(ctx context.Context, params BetaResponseCompactParams, opts ...option.RequestOption) (res *BetaCompactedResponse, err error) {
	for _, v := range params.Betas {
		opts = append(opts, option.WithHeaderAdd("openai-beta", fmt.Sprintf("%v", v)))
	}
	var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
	opts = slices.Concat(preClientOpts, r.Options, opts)
	path := "responses/compact?beta=true"
	err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
	return res, err
}

// Allows the assistant to create, delete, or update files using unified diffs.
type BetaApplyPatchTool struct {
	// The type of the tool. Always `apply_patch`.
	Type constant.ApplyPatch `json:"type" default:"apply_patch"`
	// The tool invocation context(s).
	//
	// Any of "direct", "programmatic".
	AllowedCallers []string `json:"allowed_callers" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type           respjson.Field
		AllowedCallers respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaApplyPatchTool) RawJSON() string { return r.JSON.raw }
func (r *BetaApplyPatchTool) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaApplyPatchTool to a BetaApplyPatchToolParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaApplyPatchToolParam.Overrides()
func (r BetaApplyPatchTool) ToParam() BetaApplyPatchToolParam {
	return param.Override[BetaApplyPatchToolParam](json.RawMessage(r.RawJSON()))
}

// Allows the assistant to create, delete, or update files using unified diffs.
//
// The property Type is required.
type BetaApplyPatchToolParam struct {
	// The tool invocation context(s).
	//
	// Any of "direct", "programmatic".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// The type of the tool. Always `apply_patch`.
	//
	// This field can be elided, and will marshal its zero value as "apply_patch".
	Type constant.ApplyPatch `json:"type" default:"apply_patch"`
	paramObj
}

func (r BetaApplyPatchToolParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaApplyPatchToolParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaApplyPatchToolParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaCompactedResponse struct {
	// The unique identifier for the compacted response.
	ID string `json:"id" api:"required"`
	// Unix timestamp (in seconds) when the compacted conversation was created.
	CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
	// The object type. Always `response.compaction`.
	Object constant.ResponseCompaction `json:"object" default:"response.compaction"`
	// The compacted list of output items. This is a list of all user messages,
	// followed by a single compaction item.
	Output []BetaResponseOutputItemUnion `json:"output" api:"required"`
	// Token accounting for the compaction pass, including cached, reasoning, and total
	// tokens.
	Usage BetaResponseUsage `json:"usage" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CreatedAt   respjson.Field
		Object      respjson.Field
		Output      respjson.Field
		Usage       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaCompactedResponse) RawJSON() string { return r.JSON.raw }
func (r *BetaCompactedResponse) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaComputerActionUnion contains all possible properties and values from
// [BetaComputerActionClick], [BetaComputerActionDoubleClick],
// [BetaComputerActionDrag], [BetaComputerActionKeypress],
// [BetaComputerActionMove], [BetaComputerActionScreenshot],
// [BetaComputerActionScroll], [BetaComputerActionType], [BetaComputerActionWait].
//
// Use the [BetaComputerActionUnion.AsAny] method to switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaComputerActionUnion struct {
	// This field is from variant [BetaComputerActionClick].
	Button string `json:"button"`
	// Any of "click", "double_click", "drag", "keypress", "move", "screenshot",
	// "scroll", "type", "wait".
	Type string   `json:"type"`
	X    int64    `json:"x"`
	Y    int64    `json:"y"`
	Keys []string `json:"keys"`
	// This field is from variant [BetaComputerActionDrag].
	Path []BetaComputerActionDragPath `json:"path"`
	// This field is from variant [BetaComputerActionScroll].
	ScrollX int64 `json:"scroll_x"`
	// This field is from variant [BetaComputerActionScroll].
	ScrollY int64 `json:"scroll_y"`
	// This field is from variant [BetaComputerActionType].
	Text string `json:"text"`
	JSON struct {
		Button  respjson.Field
		Type    respjson.Field
		X       respjson.Field
		Y       respjson.Field
		Keys    respjson.Field
		Path    respjson.Field
		ScrollX respjson.Field
		ScrollY respjson.Field
		Text    respjson.Field
		raw     string
	} `json:"-"`
}

// anyBetaComputerAction is implemented by each variant of
// [BetaComputerActionUnion] to add type safety for the return type of
// [BetaComputerActionUnion.AsAny]
type anyBetaComputerAction interface {
	implBetaComputerActionUnion()
}

func (BetaComputerActionClick) implBetaComputerActionUnion()       {}
func (BetaComputerActionDoubleClick) implBetaComputerActionUnion() {}
func (BetaComputerActionDrag) implBetaComputerActionUnion()        {}
func (BetaComputerActionKeypress) implBetaComputerActionUnion()    {}
func (BetaComputerActionMove) implBetaComputerActionUnion()        {}
func (BetaComputerActionScreenshot) implBetaComputerActionUnion()  {}
func (BetaComputerActionScroll) implBetaComputerActionUnion()      {}
func (BetaComputerActionType) implBetaComputerActionUnion()        {}
func (BetaComputerActionWait) implBetaComputerActionUnion()        {}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaComputerActionUnion.AsAny().(type) {
//	case openai.BetaComputerActionClick:
//	case openai.BetaComputerActionDoubleClick:
//	case openai.BetaComputerActionDrag:
//	case openai.BetaComputerActionKeypress:
//	case openai.BetaComputerActionMove:
//	case openai.BetaComputerActionScreenshot:
//	case openai.BetaComputerActionScroll:
//	case openai.BetaComputerActionType:
//	case openai.BetaComputerActionWait:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaComputerActionUnion) AsAny() anyBetaComputerAction {
	switch u.Type {
	case "click":
		return u.AsClick()
	case "double_click":
		return u.AsDoubleClick()
	case "drag":
		return u.AsDrag()
	case "keypress":
		return u.AsKeypress()
	case "move":
		return u.AsMove()
	case "screenshot":
		return u.AsScreenshot()
	case "scroll":
		return u.AsScroll()
	case "type":
		return u.AsType()
	case "wait":
		return u.AsWait()
	}
	return nil
}

func (u BetaComputerActionUnion) AsClick() (v BetaComputerActionClick) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaComputerActionUnion) AsDoubleClick() (v BetaComputerActionDoubleClick) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaComputerActionUnion) AsDrag() (v BetaComputerActionDrag) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaComputerActionUnion) AsKeypress() (v BetaComputerActionKeypress) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaComputerActionUnion) AsMove() (v BetaComputerActionMove) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaComputerActionUnion) AsScreenshot() (v BetaComputerActionScreenshot) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaComputerActionUnion) AsScroll() (v BetaComputerActionScroll) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaComputerActionUnion) AsType() (v BetaComputerActionType) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaComputerActionUnion) AsWait() (v BetaComputerActionWait) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaComputerActionUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaComputerActionUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaComputerActionUnion to a BetaComputerActionUnionParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaComputerActionUnionParam.Overrides()
func (r BetaComputerActionUnion) ToParam() BetaComputerActionUnionParam {
	return param.Override[BetaComputerActionUnionParam](json.RawMessage(r.RawJSON()))
}

// A click action.
type BetaComputerActionClick struct {
	// Indicates which mouse button was pressed during the click. One of `left`,
	// `right`, `wheel`, `back`, or `forward`.
	//
	// Any of "left", "right", "wheel", "back", "forward".
	Button string `json:"button" api:"required"`
	// Specifies the event type. For a click action, this property is always `click`.
	Type constant.Click `json:"type" default:"click"`
	// The x-coordinate where the click occurred.
	X int64 `json:"x" api:"required"`
	// The y-coordinate where the click occurred.
	Y int64 `json:"y" api:"required"`
	// The keys being held while clicking.
	Keys []string `json:"keys" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Button      respjson.Field
		Type        respjson.Field
		X           respjson.Field
		Y           respjson.Field
		Keys        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaComputerActionClick) RawJSON() string { return r.JSON.raw }
func (r *BetaComputerActionClick) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A double click action.
type BetaComputerActionDoubleClick struct {
	// The keys being held while double-clicking.
	Keys []string `json:"keys" api:"required"`
	// Specifies the event type. For a double click action, this property is always set
	// to `double_click`.
	Type constant.DoubleClick `json:"type" default:"double_click"`
	// The x-coordinate where the double click occurred.
	X int64 `json:"x" api:"required"`
	// The y-coordinate where the double click occurred.
	Y int64 `json:"y" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Keys        respjson.Field
		Type        respjson.Field
		X           respjson.Field
		Y           respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaComputerActionDoubleClick) RawJSON() string { return r.JSON.raw }
func (r *BetaComputerActionDoubleClick) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A drag action.
type BetaComputerActionDrag struct {
	// An array of coordinates representing the path of the drag action. Coordinates
	// will appear as an array of objects, eg
	//
	// ```
	// [
	//
	//	{ x: 100, y: 200 },
	//	{ x: 200, y: 300 }
	//
	// ]
	// ```
	Path []BetaComputerActionDragPath `json:"path" api:"required"`
	// Specifies the event type. For a drag action, this property is always set to
	// `drag`.
	Type constant.Drag `json:"type" default:"drag"`
	// The keys being held while dragging the mouse.
	Keys []string `json:"keys" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Path        respjson.Field
		Type        respjson.Field
		Keys        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaComputerActionDrag) RawJSON() string { return r.JSON.raw }
func (r *BetaComputerActionDrag) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// An x/y coordinate pair, e.g. `{ x: 100, y: 200 }`.
type BetaComputerActionDragPath struct {
	// The x-coordinate.
	X int64 `json:"x" api:"required"`
	// The y-coordinate.
	Y int64 `json:"y" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		X           respjson.Field
		Y           respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaComputerActionDragPath) RawJSON() string { return r.JSON.raw }
func (r *BetaComputerActionDragPath) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A collection of keypresses the model would like to perform.
type BetaComputerActionKeypress struct {
	// The combination of keys the model is requesting to be pressed. This is an array
	// of strings, each representing a key.
	Keys []string `json:"keys" api:"required"`
	// Specifies the event type. For a keypress action, this property is always set to
	// `keypress`.
	Type constant.Keypress `json:"type" default:"keypress"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Keys        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaComputerActionKeypress) RawJSON() string { return r.JSON.raw }
func (r *BetaComputerActionKeypress) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A mouse move action.
type BetaComputerActionMove struct {
	// Specifies the event type. For a move action, this property is always set to
	// `move`.
	Type constant.Move `json:"type" default:"move"`
	// The x-coordinate to move to.
	X int64 `json:"x" api:"required"`
	// The y-coordinate to move to.
	Y int64 `json:"y" api:"required"`
	// The keys being held while moving the mouse.
	Keys []string `json:"keys" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		X           respjson.Field
		Y           respjson.Field
		Keys        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaComputerActionMove) RawJSON() string { return r.JSON.raw }
func (r *BetaComputerActionMove) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A screenshot action.
type BetaComputerActionScreenshot struct {
	// Specifies the event type. For a screenshot action, this property is always set
	// to `screenshot`.
	Type constant.Screenshot `json:"type" default:"screenshot"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaComputerActionScreenshot) RawJSON() string { return r.JSON.raw }
func (r *BetaComputerActionScreenshot) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A scroll action.
type BetaComputerActionScroll struct {
	// The horizontal scroll distance.
	ScrollX int64 `json:"scroll_x" api:"required"`
	// The vertical scroll distance.
	ScrollY int64 `json:"scroll_y" api:"required"`
	// Specifies the event type. For a scroll action, this property is always set to
	// `scroll`.
	Type constant.Scroll `json:"type" default:"scroll"`
	// The x-coordinate where the scroll occurred.
	X int64 `json:"x" api:"required"`
	// The y-coordinate where the scroll occurred.
	Y int64 `json:"y" api:"required"`
	// The keys being held while scrolling.
	Keys []string `json:"keys" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ScrollX     respjson.Field
		ScrollY     respjson.Field
		Type        respjson.Field
		X           respjson.Field
		Y           respjson.Field
		Keys        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaComputerActionScroll) RawJSON() string { return r.JSON.raw }
func (r *BetaComputerActionScroll) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// An action to type in text.
type BetaComputerActionType struct {
	// The text to type.
	Text string `json:"text" api:"required"`
	// Specifies the event type. For a type action, this property is always set to
	// `type`.
	Type constant.Type `json:"type" default:"type"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaComputerActionType) RawJSON() string { return r.JSON.raw }
func (r *BetaComputerActionType) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A wait action.
type BetaComputerActionWait struct {
	// Specifies the event type. For a wait action, this property is always set to
	// `wait`.
	Type constant.Wait `json:"type" default:"wait"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaComputerActionWait) RawJSON() string { return r.JSON.raw }
func (r *BetaComputerActionWait) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func BetaComputerActionParamOfClick(button string, x int64, y int64) BetaComputerActionUnionParam {
	var click BetaComputerActionClickParam
	click.Button = button
	click.X = x
	click.Y = y
	return BetaComputerActionUnionParam{OfClick: &click}
}

func BetaComputerActionParamOfDoubleClick(keys []string, x int64, y int64) BetaComputerActionUnionParam {
	var doubleClick BetaComputerActionDoubleClickParam
	doubleClick.Keys = keys
	doubleClick.X = x
	doubleClick.Y = y
	return BetaComputerActionUnionParam{OfDoubleClick: &doubleClick}
}

func BetaComputerActionParamOfDrag(path []BetaComputerActionDragPathParam) BetaComputerActionUnionParam {
	var drag BetaComputerActionDragParam
	drag.Path = path
	return BetaComputerActionUnionParam{OfDrag: &drag}
}

func BetaComputerActionParamOfKeypress(keys []string) BetaComputerActionUnionParam {
	var keypress BetaComputerActionKeypressParam
	keypress.Keys = keys
	return BetaComputerActionUnionParam{OfKeypress: &keypress}
}

func BetaComputerActionParamOfMove(x int64, y int64) BetaComputerActionUnionParam {
	var move BetaComputerActionMoveParam
	move.X = x
	move.Y = y
	return BetaComputerActionUnionParam{OfMove: &move}
}

func BetaComputerActionParamOfType(text string) BetaComputerActionUnionParam {
	var type_ BetaComputerActionTypeParam
	type_.Text = text
	return BetaComputerActionUnionParam{OfType: &type_}
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaComputerActionUnionParam struct {
	OfClick       *BetaComputerActionClickParam       `json:",omitzero,inline"`
	OfDoubleClick *BetaComputerActionDoubleClickParam `json:",omitzero,inline"`
	OfDrag        *BetaComputerActionDragParam        `json:",omitzero,inline"`
	OfKeypress    *BetaComputerActionKeypressParam    `json:",omitzero,inline"`
	OfMove        *BetaComputerActionMoveParam        `json:",omitzero,inline"`
	OfScreenshot  *BetaComputerActionScreenshotParam  `json:",omitzero,inline"`
	OfScroll      *BetaComputerActionScrollParam      `json:",omitzero,inline"`
	OfType        *BetaComputerActionTypeParam        `json:",omitzero,inline"`
	OfWait        *BetaComputerActionWaitParam        `json:",omitzero,inline"`
	paramUnion
}

func (u BetaComputerActionUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfClick,
		u.OfDoubleClick,
		u.OfDrag,
		u.OfKeypress,
		u.OfMove,
		u.OfScreenshot,
		u.OfScroll,
		u.OfType,
		u.OfWait)
}
func (u *BetaComputerActionUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaComputerActionUnionParam) asAny() any {
	if !param.IsOmitted(u.OfClick) {
		return u.OfClick
	} else if !param.IsOmitted(u.OfDoubleClick) {
		return u.OfDoubleClick
	} else if !param.IsOmitted(u.OfDrag) {
		return u.OfDrag
	} else if !param.IsOmitted(u.OfKeypress) {
		return u.OfKeypress
	} else if !param.IsOmitted(u.OfMove) {
		return u.OfMove
	} else if !param.IsOmitted(u.OfScreenshot) {
		return u.OfScreenshot
	} else if !param.IsOmitted(u.OfScroll) {
		return u.OfScroll
	} else if !param.IsOmitted(u.OfType) {
		return u.OfType
	} else if !param.IsOmitted(u.OfWait) {
		return u.OfWait
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaComputerActionUnionParam) GetButton() *string {
	if vt := u.OfClick; vt != nil {
		return &vt.Button
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaComputerActionUnionParam) GetPath() []BetaComputerActionDragPathParam {
	if vt := u.OfDrag; vt != nil {
		return vt.Path
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaComputerActionUnionParam) GetScrollX() *int64 {
	if vt := u.OfScroll; vt != nil {
		return &vt.ScrollX
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaComputerActionUnionParam) GetScrollY() *int64 {
	if vt := u.OfScroll; vt != nil {
		return &vt.ScrollY
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaComputerActionUnionParam) GetText() *string {
	if vt := u.OfType; vt != nil {
		return &vt.Text
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaComputerActionUnionParam) GetType() *string {
	if vt := u.OfClick; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfDoubleClick; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfDrag; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfKeypress; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfMove; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfScreenshot; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfScroll; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfType; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfWait; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaComputerActionUnionParam) GetX() *int64 {
	if vt := u.OfClick; vt != nil {
		return (*int64)(&vt.X)
	} else if vt := u.OfDoubleClick; vt != nil {
		return (*int64)(&vt.X)
	} else if vt := u.OfMove; vt != nil {
		return (*int64)(&vt.X)
	} else if vt := u.OfScroll; vt != nil {
		return (*int64)(&vt.X)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaComputerActionUnionParam) GetY() *int64 {
	if vt := u.OfClick; vt != nil {
		return (*int64)(&vt.Y)
	} else if vt := u.OfDoubleClick; vt != nil {
		return (*int64)(&vt.Y)
	} else if vt := u.OfMove; vt != nil {
		return (*int64)(&vt.Y)
	} else if vt := u.OfScroll; vt != nil {
		return (*int64)(&vt.Y)
	}
	return nil
}

// Returns a pointer to the underlying variant's Keys property, if present.
func (u BetaComputerActionUnionParam) GetKeys() []string {
	if vt := u.OfClick; vt != nil {
		return vt.Keys
	} else if vt := u.OfDoubleClick; vt != nil {
		return vt.Keys
	} else if vt := u.OfDrag; vt != nil {
		return vt.Keys
	} else if vt := u.OfKeypress; vt != nil {
		return vt.Keys
	} else if vt := u.OfMove; vt != nil {
		return vt.Keys
	} else if vt := u.OfScroll; vt != nil {
		return vt.Keys
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaComputerActionUnionParam](
		"type",
		apijson.Discriminator[BetaComputerActionClickParam]("click"),
		apijson.Discriminator[BetaComputerActionDoubleClickParam]("double_click"),
		apijson.Discriminator[BetaComputerActionDragParam]("drag"),
		apijson.Discriminator[BetaComputerActionKeypressParam]("keypress"),
		apijson.Discriminator[BetaComputerActionMoveParam]("move"),
		apijson.Discriminator[BetaComputerActionScreenshotParam]("screenshot"),
		apijson.Discriminator[BetaComputerActionScrollParam]("scroll"),
		apijson.Discriminator[BetaComputerActionTypeParam]("type"),
		apijson.Discriminator[BetaComputerActionWaitParam]("wait"),
	)
}

// A click action.
//
// The properties Button, Type, X, Y are required.
type BetaComputerActionClickParam struct {
	// Indicates which mouse button was pressed during the click. One of `left`,
	// `right`, `wheel`, `back`, or `forward`.
	//
	// Any of "left", "right", "wheel", "back", "forward".
	Button string `json:"button,omitzero" api:"required"`
	// The x-coordinate where the click occurred.
	X int64 `json:"x" api:"required"`
	// The y-coordinate where the click occurred.
	Y int64 `json:"y" api:"required"`
	// The keys being held while clicking.
	Keys []string `json:"keys,omitzero"`
	// Specifies the event type. For a click action, this property is always `click`.
	//
	// This field can be elided, and will marshal its zero value as "click".
	Type constant.Click `json:"type" default:"click"`
	paramObj
}

func (r BetaComputerActionClickParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaComputerActionClickParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaComputerActionClickParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaComputerActionClickParam](
		"button", "left", "right", "wheel", "back", "forward",
	)
}

// A double click action.
//
// The properties Keys, Type, X, Y are required.
type BetaComputerActionDoubleClickParam struct {
	// The keys being held while double-clicking.
	Keys []string `json:"keys,omitzero" api:"required"`
	// The x-coordinate where the double click occurred.
	X int64 `json:"x" api:"required"`
	// The y-coordinate where the double click occurred.
	Y int64 `json:"y" api:"required"`
	// Specifies the event type. For a double click action, this property is always set
	// to `double_click`.
	//
	// This field can be elided, and will marshal its zero value as "double_click".
	Type constant.DoubleClick `json:"type" default:"double_click"`
	paramObj
}

func (r BetaComputerActionDoubleClickParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaComputerActionDoubleClickParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaComputerActionDoubleClickParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A drag action.
//
// The properties Path, Type are required.
type BetaComputerActionDragParam struct {
	// An array of coordinates representing the path of the drag action. Coordinates
	// will appear as an array of objects, eg
	//
	// ```
	// [
	//
	//	{ x: 100, y: 200 },
	//	{ x: 200, y: 300 }
	//
	// ]
	// ```
	Path []BetaComputerActionDragPathParam `json:"path,omitzero" api:"required"`
	// The keys being held while dragging the mouse.
	Keys []string `json:"keys,omitzero"`
	// Specifies the event type. For a drag action, this property is always set to
	// `drag`.
	//
	// This field can be elided, and will marshal its zero value as "drag".
	Type constant.Drag `json:"type" default:"drag"`
	paramObj
}

func (r BetaComputerActionDragParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaComputerActionDragParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaComputerActionDragParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// An x/y coordinate pair, e.g. `{ x: 100, y: 200 }`.
//
// The properties X, Y are required.
type BetaComputerActionDragPathParam struct {
	// The x-coordinate.
	X int64 `json:"x" api:"required"`
	// The y-coordinate.
	Y int64 `json:"y" api:"required"`
	paramObj
}

func (r BetaComputerActionDragPathParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaComputerActionDragPathParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaComputerActionDragPathParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A collection of keypresses the model would like to perform.
//
// The properties Keys, Type are required.
type BetaComputerActionKeypressParam struct {
	// The combination of keys the model is requesting to be pressed. This is an array
	// of strings, each representing a key.
	Keys []string `json:"keys,omitzero" api:"required"`
	// Specifies the event type. For a keypress action, this property is always set to
	// `keypress`.
	//
	// This field can be elided, and will marshal its zero value as "keypress".
	Type constant.Keypress `json:"type" default:"keypress"`
	paramObj
}

func (r BetaComputerActionKeypressParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaComputerActionKeypressParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaComputerActionKeypressParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A mouse move action.
//
// The properties Type, X, Y are required.
type BetaComputerActionMoveParam struct {
	// The x-coordinate to move to.
	X int64 `json:"x" api:"required"`
	// The y-coordinate to move to.
	Y int64 `json:"y" api:"required"`
	// The keys being held while moving the mouse.
	Keys []string `json:"keys,omitzero"`
	// Specifies the event type. For a move action, this property is always set to
	// `move`.
	//
	// This field can be elided, and will marshal its zero value as "move".
	Type constant.Move `json:"type" default:"move"`
	paramObj
}

func (r BetaComputerActionMoveParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaComputerActionMoveParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaComputerActionMoveParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func NewBetaComputerActionScreenshotParam() BetaComputerActionScreenshotParam {
	return BetaComputerActionScreenshotParam{
		Type: "screenshot",
	}
}

// A screenshot action.
//
// This struct has a constant value, construct it with
// [NewBetaComputerActionScreenshotParam].
type BetaComputerActionScreenshotParam struct {
	// Specifies the event type. For a screenshot action, this property is always set
	// to `screenshot`.
	Type constant.Screenshot `json:"type" default:"screenshot"`
	paramObj
}

func (r BetaComputerActionScreenshotParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaComputerActionScreenshotParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaComputerActionScreenshotParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A scroll action.
//
// The properties ScrollX, ScrollY, Type, X, Y are required.
type BetaComputerActionScrollParam struct {
	// The horizontal scroll distance.
	ScrollX int64 `json:"scroll_x" api:"required"`
	// The vertical scroll distance.
	ScrollY int64 `json:"scroll_y" api:"required"`
	// The x-coordinate where the scroll occurred.
	X int64 `json:"x" api:"required"`
	// The y-coordinate where the scroll occurred.
	Y int64 `json:"y" api:"required"`
	// The keys being held while scrolling.
	Keys []string `json:"keys,omitzero"`
	// Specifies the event type. For a scroll action, this property is always set to
	// `scroll`.
	//
	// This field can be elided, and will marshal its zero value as "scroll".
	Type constant.Scroll `json:"type" default:"scroll"`
	paramObj
}

func (r BetaComputerActionScrollParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaComputerActionScrollParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaComputerActionScrollParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// An action to type in text.
//
// The properties Text, Type are required.
type BetaComputerActionTypeParam struct {
	// The text to type.
	Text string `json:"text" api:"required"`
	// Specifies the event type. For a type action, this property is always set to
	// `type`.
	//
	// This field can be elided, and will marshal its zero value as "type".
	Type constant.Type `json:"type" default:"type"`
	paramObj
}

func (r BetaComputerActionTypeParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaComputerActionTypeParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaComputerActionTypeParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func NewBetaComputerActionWaitParam() BetaComputerActionWaitParam {
	return BetaComputerActionWaitParam{
		Type: "wait",
	}
}

// A wait action.
//
// This struct has a constant value, construct it with
// [NewBetaComputerActionWaitParam].
type BetaComputerActionWaitParam struct {
	// Specifies the event type. For a wait action, this property is always set to
	// `wait`.
	Type constant.Wait `json:"type" default:"wait"`
	paramObj
}

func (r BetaComputerActionWaitParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaComputerActionWaitParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaComputerActionWaitParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaComputerActionList []BetaComputerActionUnion

type BetaComputerActionListParam []BetaComputerActionUnionParam

// A tool that controls a virtual computer. Learn more about the
// [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
type BetaComputerTool struct {
	// The type of the computer tool. Always `computer`.
	Type constant.Computer `json:"type" default:"computer"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaComputerTool) RawJSON() string { return r.JSON.raw }
func (r *BetaComputerTool) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaComputerTool to a BetaComputerToolParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaComputerToolParam.Overrides()
func (r BetaComputerTool) ToParam() BetaComputerToolParam {
	return param.Override[BetaComputerToolParam](json.RawMessage(r.RawJSON()))
}

func NewBetaComputerToolParam() BetaComputerToolParam {
	return BetaComputerToolParam{
		Type: "computer",
	}
}

// A tool that controls a virtual computer. Learn more about the
// [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
//
// This struct has a constant value, construct it with [NewBetaComputerToolParam].
type BetaComputerToolParam struct {
	// The type of the computer tool. Always `computer`.
	Type constant.Computer `json:"type" default:"computer"`
	paramObj
}

func (r BetaComputerToolParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaComputerToolParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaComputerToolParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool that controls a virtual computer. Learn more about the
// [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
type BetaComputerUsePreviewTool struct {
	// The height of the computer display.
	DisplayHeight int64 `json:"display_height" api:"required"`
	// The width of the computer display.
	DisplayWidth int64 `json:"display_width" api:"required"`
	// The type of computer environment to control.
	//
	// Any of "windows", "mac", "linux", "ubuntu", "browser".
	Environment BetaComputerUsePreviewToolEnvironment `json:"environment" api:"required"`
	// The type of the computer use tool. Always `computer_use_preview`.
	Type constant.ComputerUsePreview `json:"type" default:"computer_use_preview"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		DisplayHeight respjson.Field
		DisplayWidth  respjson.Field
		Environment   respjson.Field
		Type          respjson.Field
		ExtraFields   map[string]respjson.Field
		raw           string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaComputerUsePreviewTool) RawJSON() string { return r.JSON.raw }
func (r *BetaComputerUsePreviewTool) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaComputerUsePreviewTool to a
// BetaComputerUsePreviewToolParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaComputerUsePreviewToolParam.Overrides()
func (r BetaComputerUsePreviewTool) ToParam() BetaComputerUsePreviewToolParam {
	return param.Override[BetaComputerUsePreviewToolParam](json.RawMessage(r.RawJSON()))
}

// The type of computer environment to control.
type BetaComputerUsePreviewToolEnvironment string

const (
	BetaComputerUsePreviewToolEnvironmentWindows BetaComputerUsePreviewToolEnvironment = "windows"
	BetaComputerUsePreviewToolEnvironmentMac     BetaComputerUsePreviewToolEnvironment = "mac"
	BetaComputerUsePreviewToolEnvironmentLinux   BetaComputerUsePreviewToolEnvironment = "linux"
	BetaComputerUsePreviewToolEnvironmentUbuntu  BetaComputerUsePreviewToolEnvironment = "ubuntu"
	BetaComputerUsePreviewToolEnvironmentBrowser BetaComputerUsePreviewToolEnvironment = "browser"
)

// A tool that controls a virtual computer. Learn more about the
// [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
//
// The properties DisplayHeight, DisplayWidth, Environment, Type are required.
type BetaComputerUsePreviewToolParam struct {
	// The height of the computer display.
	DisplayHeight int64 `json:"display_height" api:"required"`
	// The width of the computer display.
	DisplayWidth int64 `json:"display_width" api:"required"`
	// The type of computer environment to control.
	//
	// Any of "windows", "mac", "linux", "ubuntu", "browser".
	Environment BetaComputerUsePreviewToolEnvironment `json:"environment,omitzero" api:"required"`
	// The type of the computer use tool. Always `computer_use_preview`.
	//
	// This field can be elided, and will marshal its zero value as
	// "computer_use_preview".
	Type constant.ComputerUsePreview `json:"type" default:"computer_use_preview"`
	paramObj
}

func (r BetaComputerUsePreviewToolParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaComputerUsePreviewToolParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaComputerUsePreviewToolParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaContainerAuto struct {
	// Automatically creates a container for this request
	Type constant.ContainerAuto `json:"type" default:"container_auto"`
	// An optional list of uploaded files to make available to your code.
	FileIDs []string `json:"file_ids"`
	// The memory limit for the container.
	//
	// Any of "1g", "4g", "16g", "64g".
	MemoryLimit BetaContainerAutoMemoryLimit `json:"memory_limit" api:"nullable"`
	// Network access policy for the container.
	NetworkPolicy BetaContainerAutoNetworkPolicyUnion `json:"network_policy"`
	// An optional list of skills referenced by id or inline data.
	Skills []BetaContainerAutoSkillUnion `json:"skills"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type          respjson.Field
		FileIDs       respjson.Field
		MemoryLimit   respjson.Field
		NetworkPolicy respjson.Field
		Skills        respjson.Field
		ExtraFields   map[string]respjson.Field
		raw           string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaContainerAuto) RawJSON() string { return r.JSON.raw }
func (r *BetaContainerAuto) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaContainerAuto to a BetaContainerAutoParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaContainerAutoParam.Overrides()
func (r BetaContainerAuto) ToParam() BetaContainerAutoParam {
	return param.Override[BetaContainerAutoParam](json.RawMessage(r.RawJSON()))
}

// The memory limit for the container.
type BetaContainerAutoMemoryLimit string

const (
	BetaContainerAutoMemoryLimit1g  BetaContainerAutoMemoryLimit = "1g"
	BetaContainerAutoMemoryLimit4g  BetaContainerAutoMemoryLimit = "4g"
	BetaContainerAutoMemoryLimit16g BetaContainerAutoMemoryLimit = "16g"
	BetaContainerAutoMemoryLimit64g BetaContainerAutoMemoryLimit = "64g"
)

// BetaContainerAutoNetworkPolicyUnion contains all possible properties and values
// from [BetaContainerNetworkPolicyDisabled],
// [BetaContainerNetworkPolicyAllowlist].
//
// Use the [BetaContainerAutoNetworkPolicyUnion.AsAny] method to switch on the
// variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaContainerAutoNetworkPolicyUnion struct {
	// Any of "disabled", "allowlist".
	Type string `json:"type"`
	// This field is from variant [BetaContainerNetworkPolicyAllowlist].
	AllowedDomains []string `json:"allowed_domains"`
	// This field is from variant [BetaContainerNetworkPolicyAllowlist].
	DomainSecrets []BetaContainerNetworkPolicyDomainSecret `json:"domain_secrets"`
	JSON          struct {
		Type           respjson.Field
		AllowedDomains respjson.Field
		DomainSecrets  respjson.Field
		raw            string
	} `json:"-"`
}

// anyBetaContainerAutoNetworkPolicy is implemented by each variant of
// [BetaContainerAutoNetworkPolicyUnion] to add type safety for the return type of
// [BetaContainerAutoNetworkPolicyUnion.AsAny]
type anyBetaContainerAutoNetworkPolicy interface {
	implBetaContainerAutoNetworkPolicyUnion()
}

func (BetaContainerNetworkPolicyDisabled) implBetaContainerAutoNetworkPolicyUnion()  {}
func (BetaContainerNetworkPolicyAllowlist) implBetaContainerAutoNetworkPolicyUnion() {}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaContainerAutoNetworkPolicyUnion.AsAny().(type) {
//	case openai.BetaContainerNetworkPolicyDisabled:
//	case openai.BetaContainerNetworkPolicyAllowlist:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaContainerAutoNetworkPolicyUnion) AsAny() anyBetaContainerAutoNetworkPolicy {
	switch u.Type {
	case "disabled":
		return u.AsDisabled()
	case "allowlist":
		return u.AsAllowlist()
	}
	return nil
}

func (u BetaContainerAutoNetworkPolicyUnion) AsDisabled() (v BetaContainerNetworkPolicyDisabled) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaContainerAutoNetworkPolicyUnion) AsAllowlist() (v BetaContainerNetworkPolicyAllowlist) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaContainerAutoNetworkPolicyUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaContainerAutoNetworkPolicyUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaContainerAutoSkillUnion contains all possible properties and values from
// [BetaSkillReference], [BetaInlineSkill].
//
// Use the [BetaContainerAutoSkillUnion.AsAny] method to switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaContainerAutoSkillUnion struct {
	// This field is from variant [BetaSkillReference].
	SkillID string `json:"skill_id"`
	// Any of "skill_reference", "inline".
	Type string `json:"type"`
	// This field is from variant [BetaSkillReference].
	Version string `json:"version"`
	// This field is from variant [BetaInlineSkill].
	Description string `json:"description"`
	// This field is from variant [BetaInlineSkill].
	Name string `json:"name"`
	// This field is from variant [BetaInlineSkill].
	Source BetaInlineSkillSource `json:"source"`
	JSON   struct {
		SkillID     respjson.Field
		Type        respjson.Field
		Version     respjson.Field
		Description respjson.Field
		Name        respjson.Field
		Source      respjson.Field
		raw         string
	} `json:"-"`
}

// anyBetaContainerAutoSkill is implemented by each variant of
// [BetaContainerAutoSkillUnion] to add type safety for the return type of
// [BetaContainerAutoSkillUnion.AsAny]
type anyBetaContainerAutoSkill interface {
	implBetaContainerAutoSkillUnion()
}

func (BetaSkillReference) implBetaContainerAutoSkillUnion() {}
func (BetaInlineSkill) implBetaContainerAutoSkillUnion()    {}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaContainerAutoSkillUnion.AsAny().(type) {
//	case openai.BetaSkillReference:
//	case openai.BetaInlineSkill:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaContainerAutoSkillUnion) AsAny() anyBetaContainerAutoSkill {
	switch u.Type {
	case "skill_reference":
		return u.AsSkillReference()
	case "inline":
		return u.AsInline()
	}
	return nil
}

func (u BetaContainerAutoSkillUnion) AsSkillReference() (v BetaSkillReference) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaContainerAutoSkillUnion) AsInline() (v BetaInlineSkill) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaContainerAutoSkillUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaContainerAutoSkillUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The property Type is required.
type BetaContainerAutoParam struct {
	// The memory limit for the container.
	//
	// Any of "1g", "4g", "16g", "64g".
	MemoryLimit BetaContainerAutoMemoryLimit `json:"memory_limit,omitzero"`
	// An optional list of uploaded files to make available to your code.
	FileIDs []string `json:"file_ids,omitzero"`
	// Network access policy for the container.
	NetworkPolicy BetaContainerAutoNetworkPolicyUnionParam `json:"network_policy,omitzero"`
	// An optional list of skills referenced by id or inline data.
	Skills []BetaContainerAutoSkillUnionParam `json:"skills,omitzero"`
	// Automatically creates a container for this request
	//
	// This field can be elided, and will marshal its zero value as "container_auto".
	Type constant.ContainerAuto `json:"type" default:"container_auto"`
	paramObj
}

func (r BetaContainerAutoParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaContainerAutoParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaContainerAutoParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaContainerAutoNetworkPolicyUnionParam struct {
	OfDisabled  *BetaContainerNetworkPolicyDisabledParam  `json:",omitzero,inline"`
	OfAllowlist *BetaContainerNetworkPolicyAllowlistParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaContainerAutoNetworkPolicyUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfDisabled, u.OfAllowlist)
}
func (u *BetaContainerAutoNetworkPolicyUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaContainerAutoNetworkPolicyUnionParam) asAny() any {
	if !param.IsOmitted(u.OfDisabled) {
		return u.OfDisabled
	} else if !param.IsOmitted(u.OfAllowlist) {
		return u.OfAllowlist
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaContainerAutoNetworkPolicyUnionParam) GetAllowedDomains() []string {
	if vt := u.OfAllowlist; vt != nil {
		return vt.AllowedDomains
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaContainerAutoNetworkPolicyUnionParam) GetDomainSecrets() []BetaContainerNetworkPolicyDomainSecretParam {
	if vt := u.OfAllowlist; vt != nil {
		return vt.DomainSecrets
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaContainerAutoNetworkPolicyUnionParam) GetType() *string {
	if vt := u.OfDisabled; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfAllowlist; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaContainerAutoNetworkPolicyUnionParam](
		"type",
		apijson.Discriminator[BetaContainerNetworkPolicyDisabledParam]("disabled"),
		apijson.Discriminator[BetaContainerNetworkPolicyAllowlistParam]("allowlist"),
	)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaContainerAutoSkillUnionParam struct {
	OfSkillReference *BetaSkillReferenceParam `json:",omitzero,inline"`
	OfInline         *BetaInlineSkillParam    `json:",omitzero,inline"`
	paramUnion
}

func (u BetaContainerAutoSkillUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfSkillReference, u.OfInline)
}
func (u *BetaContainerAutoSkillUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaContainerAutoSkillUnionParam) asAny() any {
	if !param.IsOmitted(u.OfSkillReference) {
		return u.OfSkillReference
	} else if !param.IsOmitted(u.OfInline) {
		return u.OfInline
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaContainerAutoSkillUnionParam) GetSkillID() *string {
	if vt := u.OfSkillReference; vt != nil {
		return &vt.SkillID
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaContainerAutoSkillUnionParam) GetVersion() *string {
	if vt := u.OfSkillReference; vt != nil && vt.Version.Valid() {
		return &vt.Version.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaContainerAutoSkillUnionParam) GetDescription() *string {
	if vt := u.OfInline; vt != nil {
		return &vt.Description
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaContainerAutoSkillUnionParam) GetName() *string {
	if vt := u.OfInline; vt != nil {
		return &vt.Name
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaContainerAutoSkillUnionParam) GetSource() *BetaInlineSkillSourceParam {
	if vt := u.OfInline; vt != nil {
		return &vt.Source
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaContainerAutoSkillUnionParam) GetType() *string {
	if vt := u.OfSkillReference; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfInline; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaContainerAutoSkillUnionParam](
		"type",
		apijson.Discriminator[BetaSkillReferenceParam]("skill_reference"),
		apijson.Discriminator[BetaInlineSkillParam]("inline"),
	)
}

type BetaContainerNetworkPolicyAllowlist struct {
	// A list of allowed domains when type is `allowlist`.
	AllowedDomains []string `json:"allowed_domains" api:"required"`
	// Allow outbound network access only to specified domains. Always `allowlist`.
	Type constant.Allowlist `json:"type" default:"allowlist"`
	// Optional domain-scoped secrets for allowlisted domains.
	DomainSecrets []BetaContainerNetworkPolicyDomainSecret `json:"domain_secrets"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AllowedDomains respjson.Field
		Type           respjson.Field
		DomainSecrets  respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaContainerNetworkPolicyAllowlist) RawJSON() string { return r.JSON.raw }
func (r *BetaContainerNetworkPolicyAllowlist) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaContainerNetworkPolicyAllowlist to a
// BetaContainerNetworkPolicyAllowlistParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaContainerNetworkPolicyAllowlistParam.Overrides()
func (r BetaContainerNetworkPolicyAllowlist) ToParam() BetaContainerNetworkPolicyAllowlistParam {
	return param.Override[BetaContainerNetworkPolicyAllowlistParam](json.RawMessage(r.RawJSON()))
}

// The properties AllowedDomains, Type are required.
type BetaContainerNetworkPolicyAllowlistParam struct {
	// A list of allowed domains when type is `allowlist`.
	AllowedDomains []string `json:"allowed_domains,omitzero" api:"required"`
	// Optional domain-scoped secrets for allowlisted domains.
	DomainSecrets []BetaContainerNetworkPolicyDomainSecretParam `json:"domain_secrets,omitzero"`
	// Allow outbound network access only to specified domains. Always `allowlist`.
	//
	// This field can be elided, and will marshal its zero value as "allowlist".
	Type constant.Allowlist `json:"type" default:"allowlist"`
	paramObj
}

func (r BetaContainerNetworkPolicyAllowlistParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaContainerNetworkPolicyAllowlistParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaContainerNetworkPolicyAllowlistParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaContainerNetworkPolicyDisabled struct {
	// Disable outbound network access. Always `disabled`.
	Type constant.Disabled `json:"type" default:"disabled"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaContainerNetworkPolicyDisabled) RawJSON() string { return r.JSON.raw }
func (r *BetaContainerNetworkPolicyDisabled) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaContainerNetworkPolicyDisabled to a
// BetaContainerNetworkPolicyDisabledParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaContainerNetworkPolicyDisabledParam.Overrides()
func (r BetaContainerNetworkPolicyDisabled) ToParam() BetaContainerNetworkPolicyDisabledParam {
	return param.Override[BetaContainerNetworkPolicyDisabledParam](json.RawMessage(r.RawJSON()))
}

func NewBetaContainerNetworkPolicyDisabledParam() BetaContainerNetworkPolicyDisabledParam {
	return BetaContainerNetworkPolicyDisabledParam{
		Type: "disabled",
	}
}

// This struct has a constant value, construct it with
// [NewBetaContainerNetworkPolicyDisabledParam].
type BetaContainerNetworkPolicyDisabledParam struct {
	// Disable outbound network access. Always `disabled`.
	Type constant.Disabled `json:"type" default:"disabled"`
	paramObj
}

func (r BetaContainerNetworkPolicyDisabledParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaContainerNetworkPolicyDisabledParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaContainerNetworkPolicyDisabledParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaContainerNetworkPolicyDomainSecret struct {
	// The domain associated with the secret.
	Domain string `json:"domain" api:"required"`
	// The name of the secret to inject for the domain.
	Name string `json:"name" api:"required"`
	// The secret value to inject for the domain.
	Value string `json:"value" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Domain      respjson.Field
		Name        respjson.Field
		Value       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaContainerNetworkPolicyDomainSecret) RawJSON() string { return r.JSON.raw }
func (r *BetaContainerNetworkPolicyDomainSecret) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaContainerNetworkPolicyDomainSecret to a
// BetaContainerNetworkPolicyDomainSecretParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaContainerNetworkPolicyDomainSecretParam.Overrides()
func (r BetaContainerNetworkPolicyDomainSecret) ToParam() BetaContainerNetworkPolicyDomainSecretParam {
	return param.Override[BetaContainerNetworkPolicyDomainSecretParam](json.RawMessage(r.RawJSON()))
}

// The properties Domain, Name, Value are required.
type BetaContainerNetworkPolicyDomainSecretParam struct {
	// The domain associated with the secret.
	Domain string `json:"domain" api:"required"`
	// The name of the secret to inject for the domain.
	Name string `json:"name" api:"required"`
	// The secret value to inject for the domain.
	Value string `json:"value" api:"required"`
	paramObj
}

func (r BetaContainerNetworkPolicyDomainSecretParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaContainerNetworkPolicyDomainSecretParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaContainerNetworkPolicyDomainSecretParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaContainerReference struct {
	// The ID of the referenced container.
	ContainerID string `json:"container_id" api:"required"`
	// References a container created with the /v1/containers endpoint
	Type constant.ContainerReference `json:"type" default:"container_reference"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ContainerID respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaContainerReference) RawJSON() string { return r.JSON.raw }
func (r *BetaContainerReference) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaContainerReference to a BetaContainerReferenceParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaContainerReferenceParam.Overrides()
func (r BetaContainerReference) ToParam() BetaContainerReferenceParam {
	return param.Override[BetaContainerReferenceParam](json.RawMessage(r.RawJSON()))
}

// The properties ContainerID, Type are required.
type BetaContainerReferenceParam struct {
	// The ID of the referenced container.
	ContainerID string `json:"container_id" api:"required"`
	// References a container created with the /v1/containers endpoint
	//
	// This field can be elided, and will marshal its zero value as
	// "container_reference".
	Type constant.ContainerReference `json:"type" default:"container_reference"`
	paramObj
}

func (r BetaContainerReferenceParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaContainerReferenceParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaContainerReferenceParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A custom tool that processes input using a specified format. Learn more about
// [custom tools](https://platform.openai.com/docs/guides/function-calling#custom-tools)
type BetaCustomTool struct {
	// The name of the custom tool, used to identify it in tool calls.
	Name string `json:"name" api:"required"`
	// The type of the custom tool. Always `custom`.
	Type constant.Custom `json:"type" default:"custom"`
	// The tool invocation context(s).
	//
	// Any of "direct", "programmatic".
	AllowedCallers []string `json:"allowed_callers" api:"nullable"`
	// Whether this tool should be deferred and discovered via tool search.
	DeferLoading bool `json:"defer_loading"`
	// Optional description of the custom tool, used to provide more context.
	Description string `json:"description"`
	// The input format for the custom tool. Default is unconstrained text.
	Format BetaCustomToolFormatUnion `json:"format"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Name           respjson.Field
		Type           respjson.Field
		AllowedCallers respjson.Field
		DeferLoading   respjson.Field
		Description    respjson.Field
		Format         respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaCustomTool) RawJSON() string { return r.JSON.raw }
func (r *BetaCustomTool) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaCustomTool to a BetaCustomToolParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaCustomToolParam.Overrides()
func (r BetaCustomTool) ToParam() BetaCustomToolParam {
	return param.Override[BetaCustomToolParam](json.RawMessage(r.RawJSON()))
}

// BetaCustomToolFormatUnion contains all possible properties and values from
// [BetaCustomToolFormatText], [BetaCustomToolFormatGrammar].
//
// Use the [BetaCustomToolFormatUnion.AsAny] method to switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaCustomToolFormatUnion struct {
	// Any of "text", "grammar".
	Type string `json:"type"`
	// This field is from variant [BetaCustomToolFormatGrammar].
	Definition string `json:"definition"`
	// This field is from variant [BetaCustomToolFormatGrammar].
	Syntax string `json:"syntax"`
	JSON   struct {
		Type       respjson.Field
		Definition respjson.Field
		Syntax     respjson.Field
		raw        string
	} `json:"-"`
}

// anyBetaCustomToolFormat is implemented by each variant of
// [BetaCustomToolFormatUnion] to add type safety for the return type of
// [BetaCustomToolFormatUnion.AsAny]
type anyBetaCustomToolFormat interface {
	implBetaCustomToolFormatUnion()
}

func (BetaCustomToolFormatText) implBetaCustomToolFormatUnion()    {}
func (BetaCustomToolFormatGrammar) implBetaCustomToolFormatUnion() {}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaCustomToolFormatUnion.AsAny().(type) {
//	case openai.BetaCustomToolFormatText:
//	case openai.BetaCustomToolFormatGrammar:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaCustomToolFormatUnion) AsAny() anyBetaCustomToolFormat {
	switch u.Type {
	case "text":
		return u.AsText()
	case "grammar":
		return u.AsGrammar()
	}
	return nil
}

func (u BetaCustomToolFormatUnion) AsText() (v BetaCustomToolFormatText) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaCustomToolFormatUnion) AsGrammar() (v BetaCustomToolFormatGrammar) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaCustomToolFormatUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaCustomToolFormatUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Unconstrained free-form text.
type BetaCustomToolFormatText struct {
	// Unconstrained text format. Always `text`.
	Type constant.Text `json:"type" default:"text"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaCustomToolFormatText) RawJSON() string { return r.JSON.raw }
func (r *BetaCustomToolFormatText) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A grammar defined by the user.
type BetaCustomToolFormatGrammar struct {
	// The grammar definition.
	Definition string `json:"definition" api:"required"`
	// The syntax of the grammar definition. One of `lark` or `regex`.
	//
	// Any of "lark", "regex".
	Syntax string `json:"syntax" api:"required"`
	// Grammar format. Always `grammar`.
	Type constant.Grammar `json:"type" default:"grammar"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Definition  respjson.Field
		Syntax      respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaCustomToolFormatGrammar) RawJSON() string { return r.JSON.raw }
func (r *BetaCustomToolFormatGrammar) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A custom tool that processes input using a specified format. Learn more about
// [custom tools](https://platform.openai.com/docs/guides/function-calling#custom-tools)
//
// The properties Name, Type are required.
type BetaCustomToolParam struct {
	// The name of the custom tool, used to identify it in tool calls.
	Name string `json:"name" api:"required"`
	// Whether this tool should be deferred and discovered via tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// Optional description of the custom tool, used to provide more context.
	Description param.Opt[string] `json:"description,omitzero"`
	// The tool invocation context(s).
	//
	// Any of "direct", "programmatic".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// The input format for the custom tool. Default is unconstrained text.
	Format BetaCustomToolFormatUnionParam `json:"format,omitzero"`
	// The type of the custom tool. Always `custom`.
	//
	// This field can be elided, and will marshal its zero value as "custom".
	Type constant.Custom `json:"type" default:"custom"`
	paramObj
}

func (r BetaCustomToolParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaCustomToolParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaCustomToolParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaCustomToolFormatUnionParam struct {
	OfText    *BetaCustomToolFormatTextParam    `json:",omitzero,inline"`
	OfGrammar *BetaCustomToolFormatGrammarParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaCustomToolFormatUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfText, u.OfGrammar)
}
func (u *BetaCustomToolFormatUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaCustomToolFormatUnionParam) asAny() any {
	if !param.IsOmitted(u.OfText) {
		return u.OfText
	} else if !param.IsOmitted(u.OfGrammar) {
		return u.OfGrammar
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaCustomToolFormatUnionParam) GetDefinition() *string {
	if vt := u.OfGrammar; vt != nil {
		return &vt.Definition
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaCustomToolFormatUnionParam) GetSyntax() *string {
	if vt := u.OfGrammar; vt != nil {
		return &vt.Syntax
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaCustomToolFormatUnionParam) GetType() *string {
	if vt := u.OfText; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfGrammar; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaCustomToolFormatUnionParam](
		"type",
		apijson.Discriminator[BetaCustomToolFormatTextParam]("text"),
		apijson.Discriminator[BetaCustomToolFormatGrammarParam]("grammar"),
	)
}

func NewBetaCustomToolFormatTextParam() BetaCustomToolFormatTextParam {
	return BetaCustomToolFormatTextParam{
		Type: "text",
	}
}

// Unconstrained free-form text.
//
// This struct has a constant value, construct it with
// [NewBetaCustomToolFormatTextParam].
type BetaCustomToolFormatTextParam struct {
	// Unconstrained text format. Always `text`.
	Type constant.Text `json:"type" default:"text"`
	paramObj
}

func (r BetaCustomToolFormatTextParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaCustomToolFormatTextParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaCustomToolFormatTextParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A grammar defined by the user.
//
// The properties Definition, Syntax, Type are required.
type BetaCustomToolFormatGrammarParam struct {
	// The grammar definition.
	Definition string `json:"definition" api:"required"`
	// The syntax of the grammar definition. One of `lark` or `regex`.
	//
	// Any of "lark", "regex".
	Syntax string `json:"syntax,omitzero" api:"required"`
	// Grammar format. Always `grammar`.
	//
	// This field can be elided, and will marshal its zero value as "grammar".
	Type constant.Grammar `json:"type" default:"grammar"`
	paramObj
}

func (r BetaCustomToolFormatGrammarParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaCustomToolFormatGrammarParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaCustomToolFormatGrammarParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaCustomToolFormatGrammarParam](
		"syntax", "lark", "regex",
	)
}

// A message input to the model with a role indicating instruction following
// hierarchy. Instructions given with the `developer` or `system` role take
// precedence over instructions given with the `user` role. Messages with the
// `assistant` role are presumed to have been generated by the model in previous
// interactions.
type BetaEasyInputMessage struct {
	// Text, image, or audio input to the model, used to generate a response. Can also
	// contain previous assistant responses.
	Content BetaEasyInputMessageContentUnion `json:"content" api:"required"`
	// The role of the message input. One of `user`, `assistant`, `system`, or
	// `developer`.
	//
	// Any of "user", "assistant", "system", "developer".
	Role BetaEasyInputMessageRole `json:"role" api:"required"`
	// Labels an `assistant` message as intermediate commentary (`commentary`) or the
	// final answer (`final_answer`). For models like `gpt-5.3-codex` and beyond, when
	// sending follow-up requests, preserve and resend phase on all assistant messages
	// — dropping it can degrade performance. Not used for user messages.
	//
	// Any of "commentary", "final_answer".
	Phase BetaEasyInputMessagePhase `json:"phase" api:"nullable"`
	// The type of the message input. Always `message`.
	//
	// Any of "message".
	Type BetaEasyInputMessageType `json:"type"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		Role        respjson.Field
		Phase       respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaEasyInputMessage) RawJSON() string { return r.JSON.raw }
func (r *BetaEasyInputMessage) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaEasyInputMessage to a BetaEasyInputMessageParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaEasyInputMessageParam.Overrides()
func (r BetaEasyInputMessage) ToParam() BetaEasyInputMessageParam {
	return param.Override[BetaEasyInputMessageParam](json.RawMessage(r.RawJSON()))
}

// BetaEasyInputMessageContentUnion contains all possible properties and values
// from [string], [BetaResponseInputMessageContentList].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfString OfInputItemContentList]
type BetaEasyInputMessageContentUnion struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a
	// [BetaResponseInputMessageContentList] instead of an object.
	OfInputItemContentList BetaResponseInputMessageContentList `json:",inline"`
	JSON                   struct {
		OfString               respjson.Field
		OfInputItemContentList respjson.Field
		raw                    string
	} `json:"-"`
}

func (u BetaEasyInputMessageContentUnion) AsString() (v string) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaEasyInputMessageContentUnion) AsInputItemContentList() (v BetaResponseInputMessageContentList) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaEasyInputMessageContentUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaEasyInputMessageContentUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The role of the message input. One of `user`, `assistant`, `system`, or
// `developer`.
type BetaEasyInputMessageRole string

const (
	BetaEasyInputMessageRoleUser      BetaEasyInputMessageRole = "user"
	BetaEasyInputMessageRoleAssistant BetaEasyInputMessageRole = "assistant"
	BetaEasyInputMessageRoleSystem    BetaEasyInputMessageRole = "system"
	BetaEasyInputMessageRoleDeveloper BetaEasyInputMessageRole = "developer"
)

// Labels an `assistant` message as intermediate commentary (`commentary`) or the
// final answer (`final_answer`). For models like `gpt-5.3-codex` and beyond, when
// sending follow-up requests, preserve and resend phase on all assistant messages
// — dropping it can degrade performance. Not used for user messages.
type BetaEasyInputMessagePhase string

const (
	BetaEasyInputMessagePhaseCommentary  BetaEasyInputMessagePhase = "commentary"
	BetaEasyInputMessagePhaseFinalAnswer BetaEasyInputMessagePhase = "final_answer"
)

// The type of the message input. Always `message`.
type BetaEasyInputMessageType string

const (
	BetaEasyInputMessageTypeMessage BetaEasyInputMessageType = "message"
)

// A message input to the model with a role indicating instruction following
// hierarchy. Instructions given with the `developer` or `system` role take
// precedence over instructions given with the `user` role. Messages with the
// `assistant` role are presumed to have been generated by the model in previous
// interactions.
//
// The properties Content, Role are required.
type BetaEasyInputMessageParam struct {
	// Text, image, or audio input to the model, used to generate a response. Can also
	// contain previous assistant responses.
	Content BetaEasyInputMessageContentUnionParam `json:"content,omitzero" api:"required"`
	// The role of the message input. One of `user`, `assistant`, `system`, or
	// `developer`.
	//
	// Any of "user", "assistant", "system", "developer".
	Role BetaEasyInputMessageRole `json:"role,omitzero" api:"required"`
	// Labels an `assistant` message as intermediate commentary (`commentary`) or the
	// final answer (`final_answer`). For models like `gpt-5.3-codex` and beyond, when
	// sending follow-up requests, preserve and resend phase on all assistant messages
	// — dropping it can degrade performance. Not used for user messages.
	//
	// Any of "commentary", "final_answer".
	Phase BetaEasyInputMessagePhase `json:"phase,omitzero"`
	// The type of the message input. Always `message`.
	//
	// Any of "message".
	Type BetaEasyInputMessageType `json:"type,omitzero"`
	paramObj
}

func (r BetaEasyInputMessageParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaEasyInputMessageParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaEasyInputMessageParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaEasyInputMessageContentUnionParam struct {
	OfString               param.Opt[string]                        `json:",omitzero,inline"`
	OfInputItemContentList BetaResponseInputMessageContentListParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaEasyInputMessageContentUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfString, u.OfInputItemContentList)
}
func (u *BetaEasyInputMessageContentUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaEasyInputMessageContentUnionParam) asAny() any {
	if !param.IsOmitted(u.OfString) {
		return &u.OfString.Value
	} else if !param.IsOmitted(u.OfInputItemContentList) {
		return &u.OfInputItemContentList
	}
	return nil
}

// A tool that searches for relevant content from uploaded files. Learn more about
// the
// [file search tool](https://platform.openai.com/docs/guides/tools-file-search).
type BetaFileSearchTool struct {
	// The type of the file search tool. Always `file_search`.
	Type constant.FileSearch `json:"type" default:"file_search"`
	// The IDs of the vector stores to search.
	VectorStoreIDs []string `json:"vector_store_ids" api:"required"`
	// A filter to apply.
	Filters BetaFileSearchToolFiltersUnion `json:"filters" api:"nullable"`
	// The maximum number of results to return. This number should be between 1 and 50
	// inclusive.
	MaxNumResults int64 `json:"max_num_results"`
	// Ranking options for search.
	RankingOptions BetaFileSearchToolRankingOptions `json:"ranking_options"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type           respjson.Field
		VectorStoreIDs respjson.Field
		Filters        respjson.Field
		MaxNumResults  respjson.Field
		RankingOptions respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaFileSearchTool) RawJSON() string { return r.JSON.raw }
func (r *BetaFileSearchTool) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaFileSearchTool to a BetaFileSearchToolParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaFileSearchToolParam.Overrides()
func (r BetaFileSearchTool) ToParam() BetaFileSearchToolParam {
	return param.Override[BetaFileSearchToolParam](json.RawMessage(r.RawJSON()))
}

// BetaFileSearchToolFiltersUnion contains all possible properties and values from
// [BetaFileSearchToolFiltersComparisonFilter],
// [BetaFileSearchToolFiltersCompoundFilter].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaFileSearchToolFiltersUnion struct {
	// This field is from variant [BetaFileSearchToolFiltersComparisonFilter].
	Key  string `json:"key"`
	Type string `json:"type"`
	// This field is from variant [BetaFileSearchToolFiltersComparisonFilter].
	Value BetaFileSearchToolFiltersComparisonFilterValueUnion `json:"value"`
	// This field is from variant [BetaFileSearchToolFiltersCompoundFilter].
	Filters []BetaFileSearchToolFiltersCompoundFilterFilter `json:"filters"`
	JSON    struct {
		Key     respjson.Field
		Type    respjson.Field
		Value   respjson.Field
		Filters respjson.Field
		raw     string
	} `json:"-"`
}

func (u BetaFileSearchToolFiltersUnion) AsComparisonFilter() (v BetaFileSearchToolFiltersComparisonFilter) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaFileSearchToolFiltersUnion) AsCompoundFilter() (v BetaFileSearchToolFiltersCompoundFilter) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaFileSearchToolFiltersUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaFileSearchToolFiltersUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A filter used to compare a specified attribute key to a given value using a
// defined comparison operation.
type BetaFileSearchToolFiltersComparisonFilter struct {
	// The key to compare against the value.
	Key string `json:"key" api:"required"`
	// Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `in`,
	// `nin`.
	//
	// - `eq`: equals
	// - `ne`: not equal
	// - `gt`: greater than
	// - `gte`: greater than or equal
	// - `lt`: less than
	// - `lte`: less than or equal
	// - `in`: in
	// - `nin`: not in
	//
	// Any of "eq", "ne", "gt", "gte", "lt", "lte", "in", "nin".
	Type string `json:"type" api:"required"`
	// The value to compare against the attribute key; supports string, number, or
	// boolean types.
	Value BetaFileSearchToolFiltersComparisonFilterValueUnion `json:"value" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Key         respjson.Field
		Type        respjson.Field
		Value       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaFileSearchToolFiltersComparisonFilter) RawJSON() string { return r.JSON.raw }
func (r *BetaFileSearchToolFiltersComparisonFilter) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaFileSearchToolFiltersComparisonFilterValueUnion contains all possible
// properties and values from [string], [float64], [bool],
// [[]BetaFileSearchToolFiltersComparisonFilterValueArrayItemUnion].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfString OfFloat OfBool
// OfBetaFileSearchToolFiltersComparisonFilterValueArray]
type BetaFileSearchToolFiltersComparisonFilterValueUnion struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a [float64] instead of an object.
	OfFloat float64 `json:",inline"`
	// This field will be present if the value is a [bool] instead of an object.
	OfBool bool `json:",inline"`
	// This field will be present if the value is a
	// [[]BetaFileSearchToolFiltersComparisonFilterValueArrayItemUnion] instead of an
	// object.
	OfBetaFileSearchToolFiltersComparisonFilterValueArray []BetaFileSearchToolFiltersComparisonFilterValueArrayItemUnion `json:",inline"`
	JSON                                                  struct {
		OfString                                              respjson.Field
		OfFloat                                               respjson.Field
		OfBool                                                respjson.Field
		OfBetaFileSearchToolFiltersComparisonFilterValueArray respjson.Field
		raw                                                   string
	} `json:"-"`
}

func (u BetaFileSearchToolFiltersComparisonFilterValueUnion) AsString() (v string) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaFileSearchToolFiltersComparisonFilterValueUnion) AsFloat() (v float64) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaFileSearchToolFiltersComparisonFilterValueUnion) AsBool() (v bool) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaFileSearchToolFiltersComparisonFilterValueUnion) AsBetaFileSearchToolFiltersComparisonFilterValueArray() (v []BetaFileSearchToolFiltersComparisonFilterValueArrayItemUnion) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaFileSearchToolFiltersComparisonFilterValueUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaFileSearchToolFiltersComparisonFilterValueUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaFileSearchToolFiltersComparisonFilterValueArrayItemUnion contains all
// possible properties and values from [string], [float64].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfString OfFloat]
type BetaFileSearchToolFiltersComparisonFilterValueArrayItemUnion struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a [float64] instead of an object.
	OfFloat float64 `json:",inline"`
	JSON    struct {
		OfString respjson.Field
		OfFloat  respjson.Field
		raw      string
	} `json:"-"`
}

func (u BetaFileSearchToolFiltersComparisonFilterValueArrayItemUnion) AsString() (v string) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaFileSearchToolFiltersComparisonFilterValueArrayItemUnion) AsFloat() (v float64) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaFileSearchToolFiltersComparisonFilterValueArrayItemUnion) RawJSON() string {
	return u.JSON.raw
}

func (r *BetaFileSearchToolFiltersComparisonFilterValueArrayItemUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Combine multiple filters using `and` or `or`.
type BetaFileSearchToolFiltersCompoundFilter struct {
	// Array of filters to combine. Items can be `ComparisonFilter` or
	// `CompoundFilter`.
	Filters []BetaFileSearchToolFiltersCompoundFilterFilter `json:"filters" api:"required"`
	// Type of operation: `and` or `or`.
	//
	// Any of "and", "or".
	Type string `json:"type" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Filters     respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaFileSearchToolFiltersCompoundFilter) RawJSON() string { return r.JSON.raw }
func (r *BetaFileSearchToolFiltersCompoundFilter) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A filter used to compare a specified attribute key to a given value using a
// defined comparison operation.
type BetaFileSearchToolFiltersCompoundFilterFilter struct {
	// The key to compare against the value.
	Key string `json:"key" api:"required"`
	// Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `in`,
	// `nin`.
	//
	// - `eq`: equals
	// - `ne`: not equal
	// - `gt`: greater than
	// - `gte`: greater than or equal
	// - `lt`: less than
	// - `lte`: less than or equal
	// - `in`: in
	// - `nin`: not in
	//
	// Any of "eq", "ne", "gt", "gte", "lt", "lte", "in", "nin".
	Type string `json:"type" api:"required"`
	// The value to compare against the attribute key; supports string, number, or
	// boolean types.
	Value BetaFileSearchToolFiltersCompoundFilterFilterValueUnion `json:"value" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Key         respjson.Field
		Type        respjson.Field
		Value       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaFileSearchToolFiltersCompoundFilterFilter) RawJSON() string { return r.JSON.raw }
func (r *BetaFileSearchToolFiltersCompoundFilterFilter) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaFileSearchToolFiltersCompoundFilterFilterValueUnion contains all possible
// properties and values from [string], [float64], [bool],
// [[]BetaFileSearchToolFiltersCompoundFilterFilterValueArrayItemUnion].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfString OfFloat OfBool
// OfBetaFileSearchToolFiltersCompoundFilterFilterValueArray]
type BetaFileSearchToolFiltersCompoundFilterFilterValueUnion struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a [float64] instead of an object.
	OfFloat float64 `json:",inline"`
	// This field will be present if the value is a [bool] instead of an object.
	OfBool bool `json:",inline"`
	// This field will be present if the value is a
	// [[]BetaFileSearchToolFiltersCompoundFilterFilterValueArrayItemUnion] instead of
	// an object.
	OfBetaFileSearchToolFiltersCompoundFilterFilterValueArray []BetaFileSearchToolFiltersCompoundFilterFilterValueArrayItemUnion `json:",inline"`
	JSON                                                      struct {
		OfString                                                  respjson.Field
		OfFloat                                                   respjson.Field
		OfBool                                                    respjson.Field
		OfBetaFileSearchToolFiltersCompoundFilterFilterValueArray respjson.Field
		raw                                                       string
	} `json:"-"`
}

func (u BetaFileSearchToolFiltersCompoundFilterFilterValueUnion) AsString() (v string) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaFileSearchToolFiltersCompoundFilterFilterValueUnion) AsFloat() (v float64) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaFileSearchToolFiltersCompoundFilterFilterValueUnion) AsBool() (v bool) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaFileSearchToolFiltersCompoundFilterFilterValueUnion) AsBetaFileSearchToolFiltersCompoundFilterFilterValueArray() (v []BetaFileSearchToolFiltersCompoundFilterFilterValueArrayItemUnion) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaFileSearchToolFiltersCompoundFilterFilterValueUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaFileSearchToolFiltersCompoundFilterFilterValueUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaFileSearchToolFiltersCompoundFilterFilterValueArrayItemUnion contains all
// possible properties and values from [string], [float64].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfString OfFloat]
type BetaFileSearchToolFiltersCompoundFilterFilterValueArrayItemUnion struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a [float64] instead of an object.
	OfFloat float64 `json:",inline"`
	JSON    struct {
		OfString respjson.Field
		OfFloat  respjson.Field
		raw      string
	} `json:"-"`
}

func (u BetaFileSearchToolFiltersCompoundFilterFilterValueArrayItemUnion) AsString() (v string) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaFileSearchToolFiltersCompoundFilterFilterValueArrayItemUnion) AsFloat() (v float64) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaFileSearchToolFiltersCompoundFilterFilterValueArrayItemUnion) RawJSON() string {
	return u.JSON.raw
}

func (r *BetaFileSearchToolFiltersCompoundFilterFilterValueArrayItemUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Ranking options for search.
type BetaFileSearchToolRankingOptions struct {
	// Weights that control how reciprocal rank fusion balances semantic embedding
	// matches versus sparse keyword matches when hybrid search is enabled.
	HybridSearch BetaFileSearchToolRankingOptionsHybridSearch `json:"hybrid_search"`
	// The ranker to use for the file search.
	//
	// Any of "auto", "default-2024-11-15".
	Ranker string `json:"ranker"`
	// The score threshold for the file search, a number between 0 and 1. Numbers
	// closer to 1 will attempt to return only the most relevant results, but may
	// return fewer results.
	ScoreThreshold float64 `json:"score_threshold"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		HybridSearch   respjson.Field
		Ranker         respjson.Field
		ScoreThreshold respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaFileSearchToolRankingOptions) RawJSON() string { return r.JSON.raw }
func (r *BetaFileSearchToolRankingOptions) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Weights that control how reciprocal rank fusion balances semantic embedding
// matches versus sparse keyword matches when hybrid search is enabled.
type BetaFileSearchToolRankingOptionsHybridSearch struct {
	// The weight of the embedding in the reciprocal ranking fusion.
	EmbeddingWeight float64 `json:"embedding_weight" api:"required"`
	// The weight of the text in the reciprocal ranking fusion.
	TextWeight float64 `json:"text_weight" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		EmbeddingWeight respjson.Field
		TextWeight      respjson.Field
		ExtraFields     map[string]respjson.Field
		raw             string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaFileSearchToolRankingOptionsHybridSearch) RawJSON() string { return r.JSON.raw }
func (r *BetaFileSearchToolRankingOptionsHybridSearch) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool that searches for relevant content from uploaded files. Learn more about
// the
// [file search tool](https://platform.openai.com/docs/guides/tools-file-search).
//
// The properties Type, VectorStoreIDs are required.
type BetaFileSearchToolParam struct {
	// The IDs of the vector stores to search.
	VectorStoreIDs []string `json:"vector_store_ids,omitzero" api:"required"`
	// The maximum number of results to return. This number should be between 1 and 50
	// inclusive.
	MaxNumResults param.Opt[int64] `json:"max_num_results,omitzero"`
	// A filter to apply.
	Filters BetaFileSearchToolFiltersUnionParam `json:"filters,omitzero"`
	// Ranking options for search.
	RankingOptions BetaFileSearchToolRankingOptionsParam `json:"ranking_options,omitzero"`
	// The type of the file search tool. Always `file_search`.
	//
	// This field can be elided, and will marshal its zero value as "file_search".
	Type constant.FileSearch `json:"type" default:"file_search"`
	paramObj
}

func (r BetaFileSearchToolParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaFileSearchToolParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaFileSearchToolParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaFileSearchToolFiltersUnionParam struct {
	OfComparisonFilter *BetaFileSearchToolFiltersComparisonFilterParam `json:",omitzero,inline"`
	OfCompoundFilter   *BetaFileSearchToolFiltersCompoundFilterParam   `json:",omitzero,inline"`
	paramUnion
}

func (u BetaFileSearchToolFiltersUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfComparisonFilter, u.OfCompoundFilter)
}
func (u *BetaFileSearchToolFiltersUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaFileSearchToolFiltersUnionParam) asAny() any {
	if !param.IsOmitted(u.OfComparisonFilter) {
		return u.OfComparisonFilter
	} else if !param.IsOmitted(u.OfCompoundFilter) {
		return u.OfCompoundFilter
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaFileSearchToolFiltersUnionParam) GetKey() *string {
	if vt := u.OfComparisonFilter; vt != nil {
		return &vt.Key
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaFileSearchToolFiltersUnionParam) GetValue() *BetaFileSearchToolFiltersComparisonFilterValueUnionParam {
	if vt := u.OfComparisonFilter; vt != nil {
		return &vt.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaFileSearchToolFiltersUnionParam) GetFilters() []BetaFileSearchToolFiltersCompoundFilterFilterParam {
	if vt := u.OfCompoundFilter; vt != nil {
		return vt.Filters
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaFileSearchToolFiltersUnionParam) GetType() *string {
	if vt := u.OfComparisonFilter; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfCompoundFilter; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

// A filter used to compare a specified attribute key to a given value using a
// defined comparison operation.
//
// The properties Key, Type, Value are required.
type BetaFileSearchToolFiltersComparisonFilterParam struct {
	// The key to compare against the value.
	Key string `json:"key" api:"required"`
	// Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `in`,
	// `nin`.
	//
	// - `eq`: equals
	// - `ne`: not equal
	// - `gt`: greater than
	// - `gte`: greater than or equal
	// - `lt`: less than
	// - `lte`: less than or equal
	// - `in`: in
	// - `nin`: not in
	//
	// Any of "eq", "ne", "gt", "gte", "lt", "lte", "in", "nin".
	Type string `json:"type,omitzero" api:"required"`
	// The value to compare against the attribute key; supports string, number, or
	// boolean types.
	Value BetaFileSearchToolFiltersComparisonFilterValueUnionParam `json:"value,omitzero" api:"required"`
	paramObj
}

func (r BetaFileSearchToolFiltersComparisonFilterParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaFileSearchToolFiltersComparisonFilterParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaFileSearchToolFiltersComparisonFilterParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaFileSearchToolFiltersComparisonFilterParam](
		"type", "eq", "ne", "gt", "gte", "lt", "lte", "in", "nin",
	)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaFileSearchToolFiltersComparisonFilterValueUnionParam struct {
	OfString                                              param.Opt[string]                                                   `json:",omitzero,inline"`
	OfFloat                                               param.Opt[float64]                                                  `json:",omitzero,inline"`
	OfBool                                                param.Opt[bool]                                                     `json:",omitzero,inline"`
	OfBetaFileSearchToolFiltersComparisonFilterValueArray []BetaFileSearchToolFiltersComparisonFilterValueArrayItemUnionParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaFileSearchToolFiltersComparisonFilterValueUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfString, u.OfFloat, u.OfBool, u.OfBetaFileSearchToolFiltersComparisonFilterValueArray)
}
func (u *BetaFileSearchToolFiltersComparisonFilterValueUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaFileSearchToolFiltersComparisonFilterValueUnionParam) asAny() any {
	if !param.IsOmitted(u.OfString) {
		return &u.OfString.Value
	} else if !param.IsOmitted(u.OfFloat) {
		return &u.OfFloat.Value
	} else if !param.IsOmitted(u.OfBool) {
		return &u.OfBool.Value
	} else if !param.IsOmitted(u.OfBetaFileSearchToolFiltersComparisonFilterValueArray) {
		return &u.OfBetaFileSearchToolFiltersComparisonFilterValueArray
	}
	return nil
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaFileSearchToolFiltersComparisonFilterValueArrayItemUnionParam struct {
	OfString param.Opt[string]  `json:",omitzero,inline"`
	OfFloat  param.Opt[float64] `json:",omitzero,inline"`
	paramUnion
}

func (u BetaFileSearchToolFiltersComparisonFilterValueArrayItemUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfString, u.OfFloat)
}
func (u *BetaFileSearchToolFiltersComparisonFilterValueArrayItemUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaFileSearchToolFiltersComparisonFilterValueArrayItemUnionParam) asAny() any {
	if !param.IsOmitted(u.OfString) {
		return &u.OfString.Value
	} else if !param.IsOmitted(u.OfFloat) {
		return &u.OfFloat.Value
	}
	return nil
}

// Combine multiple filters using `and` or `or`.
//
// The properties Filters, Type are required.
type BetaFileSearchToolFiltersCompoundFilterParam struct {
	// Array of filters to combine. Items can be `ComparisonFilter` or
	// `CompoundFilter`.
	Filters []BetaFileSearchToolFiltersCompoundFilterFilterParam `json:"filters,omitzero" api:"required"`
	// Type of operation: `and` or `or`.
	//
	// Any of "and", "or".
	Type string `json:"type,omitzero" api:"required"`
	paramObj
}

func (r BetaFileSearchToolFiltersCompoundFilterParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaFileSearchToolFiltersCompoundFilterParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaFileSearchToolFiltersCompoundFilterParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaFileSearchToolFiltersCompoundFilterParam](
		"type", "and", "or",
	)
}

// A filter used to compare a specified attribute key to a given value using a
// defined comparison operation.
//
// The properties Key, Type, Value are required.
type BetaFileSearchToolFiltersCompoundFilterFilterParam struct {
	// The key to compare against the value.
	Key string `json:"key" api:"required"`
	// Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `in`,
	// `nin`.
	//
	// - `eq`: equals
	// - `ne`: not equal
	// - `gt`: greater than
	// - `gte`: greater than or equal
	// - `lt`: less than
	// - `lte`: less than or equal
	// - `in`: in
	// - `nin`: not in
	//
	// Any of "eq", "ne", "gt", "gte", "lt", "lte", "in", "nin".
	Type string `json:"type,omitzero" api:"required"`
	// The value to compare against the attribute key; supports string, number, or
	// boolean types.
	Value BetaFileSearchToolFiltersCompoundFilterFilterValueUnionParam `json:"value,omitzero" api:"required"`
	paramObj
}

func (r BetaFileSearchToolFiltersCompoundFilterFilterParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaFileSearchToolFiltersCompoundFilterFilterParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaFileSearchToolFiltersCompoundFilterFilterParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaFileSearchToolFiltersCompoundFilterFilterParam](
		"type", "eq", "ne", "gt", "gte", "lt", "lte", "in", "nin",
	)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaFileSearchToolFiltersCompoundFilterFilterValueUnionParam struct {
	OfString                                                  param.Opt[string]                                                       `json:",omitzero,inline"`
	OfFloat                                                   param.Opt[float64]                                                      `json:",omitzero,inline"`
	OfBool                                                    param.Opt[bool]                                                         `json:",omitzero,inline"`
	OfBetaFileSearchToolFiltersCompoundFilterFilterValueArray []BetaFileSearchToolFiltersCompoundFilterFilterValueArrayItemUnionParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaFileSearchToolFiltersCompoundFilterFilterValueUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfString, u.OfFloat, u.OfBool, u.OfBetaFileSearchToolFiltersCompoundFilterFilterValueArray)
}
func (u *BetaFileSearchToolFiltersCompoundFilterFilterValueUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaFileSearchToolFiltersCompoundFilterFilterValueUnionParam) asAny() any {
	if !param.IsOmitted(u.OfString) {
		return &u.OfString.Value
	} else if !param.IsOmitted(u.OfFloat) {
		return &u.OfFloat.Value
	} else if !param.IsOmitted(u.OfBool) {
		return &u.OfBool.Value
	} else if !param.IsOmitted(u.OfBetaFileSearchToolFiltersCompoundFilterFilterValueArray) {
		return &u.OfBetaFileSearchToolFiltersCompoundFilterFilterValueArray
	}
	return nil
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaFileSearchToolFiltersCompoundFilterFilterValueArrayItemUnionParam struct {
	OfString param.Opt[string]  `json:",omitzero,inline"`
	OfFloat  param.Opt[float64] `json:",omitzero,inline"`
	paramUnion
}

func (u BetaFileSearchToolFiltersCompoundFilterFilterValueArrayItemUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfString, u.OfFloat)
}
func (u *BetaFileSearchToolFiltersCompoundFilterFilterValueArrayItemUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaFileSearchToolFiltersCompoundFilterFilterValueArrayItemUnionParam) asAny() any {
	if !param.IsOmitted(u.OfString) {
		return &u.OfString.Value
	} else if !param.IsOmitted(u.OfFloat) {
		return &u.OfFloat.Value
	}
	return nil
}

// Ranking options for search.
type BetaFileSearchToolRankingOptionsParam struct {
	// The score threshold for the file search, a number between 0 and 1. Numbers
	// closer to 1 will attempt to return only the most relevant results, but may
	// return fewer results.
	ScoreThreshold param.Opt[float64] `json:"score_threshold,omitzero"`
	// Weights that control how reciprocal rank fusion balances semantic embedding
	// matches versus sparse keyword matches when hybrid search is enabled.
	HybridSearch BetaFileSearchToolRankingOptionsHybridSearchParam `json:"hybrid_search,omitzero"`
	// The ranker to use for the file search.
	//
	// Any of "auto", "default-2024-11-15".
	Ranker string `json:"ranker,omitzero"`
	paramObj
}

func (r BetaFileSearchToolRankingOptionsParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaFileSearchToolRankingOptionsParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaFileSearchToolRankingOptionsParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaFileSearchToolRankingOptionsParam](
		"ranker", "auto", "default-2024-11-15",
	)
}

// Weights that control how reciprocal rank fusion balances semantic embedding
// matches versus sparse keyword matches when hybrid search is enabled.
//
// The properties EmbeddingWeight, TextWeight are required.
type BetaFileSearchToolRankingOptionsHybridSearchParam struct {
	// The weight of the embedding in the reciprocal ranking fusion.
	EmbeddingWeight float64 `json:"embedding_weight" api:"required"`
	// The weight of the text in the reciprocal ranking fusion.
	TextWeight float64 `json:"text_weight" api:"required"`
	paramObj
}

func (r BetaFileSearchToolRankingOptionsHybridSearchParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaFileSearchToolRankingOptionsHybridSearchParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaFileSearchToolRankingOptionsHybridSearchParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool that allows the model to execute shell commands.
type BetaFunctionShellTool struct {
	// The type of the shell tool. Always `shell`.
	Type constant.Shell `json:"type" default:"shell"`
	// The tool invocation context(s).
	//
	// Any of "direct", "programmatic".
	AllowedCallers []string                              `json:"allowed_callers" api:"nullable"`
	Environment    BetaFunctionShellToolEnvironmentUnion `json:"environment" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type           respjson.Field
		AllowedCallers respjson.Field
		Environment    respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaFunctionShellTool) RawJSON() string { return r.JSON.raw }
func (r *BetaFunctionShellTool) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaFunctionShellTool to a BetaFunctionShellToolParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaFunctionShellToolParam.Overrides()
func (r BetaFunctionShellTool) ToParam() BetaFunctionShellToolParam {
	return param.Override[BetaFunctionShellToolParam](json.RawMessage(r.RawJSON()))
}

// BetaFunctionShellToolEnvironmentUnion contains all possible properties and
// values from [BetaContainerAuto], [BetaLocalEnvironment],
// [BetaContainerReference].
//
// Use the [BetaFunctionShellToolEnvironmentUnion.AsAny] method to switch on the
// variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaFunctionShellToolEnvironmentUnion struct {
	// Any of "container_auto", "local", "container_reference".
	Type string `json:"type"`
	// This field is from variant [BetaContainerAuto].
	FileIDs []string `json:"file_ids"`
	// This field is from variant [BetaContainerAuto].
	MemoryLimit BetaContainerAutoMemoryLimit `json:"memory_limit"`
	// This field is from variant [BetaContainerAuto].
	NetworkPolicy BetaContainerAutoNetworkPolicyUnion `json:"network_policy"`
	// This field is a union of [[]BetaContainerAutoSkillUnion], [[]BetaLocalSkill]
	Skills BetaFunctionShellToolEnvironmentUnionSkills `json:"skills"`
	// This field is from variant [BetaContainerReference].
	ContainerID string `json:"container_id"`
	JSON        struct {
		Type          respjson.Field
		FileIDs       respjson.Field
		MemoryLimit   respjson.Field
		NetworkPolicy respjson.Field
		Skills        respjson.Field
		ContainerID   respjson.Field
		raw           string
	} `json:"-"`
}

// anyBetaFunctionShellToolEnvironment is implemented by each variant of
// [BetaFunctionShellToolEnvironmentUnion] to add type safety for the return type
// of [BetaFunctionShellToolEnvironmentUnion.AsAny]
type anyBetaFunctionShellToolEnvironment interface {
	implBetaFunctionShellToolEnvironmentUnion()
}

func (BetaContainerAuto) implBetaFunctionShellToolEnvironmentUnion()      {}
func (BetaLocalEnvironment) implBetaFunctionShellToolEnvironmentUnion()   {}
func (BetaContainerReference) implBetaFunctionShellToolEnvironmentUnion() {}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaFunctionShellToolEnvironmentUnion.AsAny().(type) {
//	case openai.BetaContainerAuto:
//	case openai.BetaLocalEnvironment:
//	case openai.BetaContainerReference:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaFunctionShellToolEnvironmentUnion) AsAny() anyBetaFunctionShellToolEnvironment {
	switch u.Type {
	case "container_auto":
		return u.AsContainerAuto()
	case "local":
		return u.AsLocal()
	case "container_reference":
		return u.AsContainerReference()
	}
	return nil
}

func (u BetaFunctionShellToolEnvironmentUnion) AsContainerAuto() (v BetaContainerAuto) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaFunctionShellToolEnvironmentUnion) AsLocal() (v BetaLocalEnvironment) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaFunctionShellToolEnvironmentUnion) AsContainerReference() (v BetaContainerReference) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaFunctionShellToolEnvironmentUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaFunctionShellToolEnvironmentUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaFunctionShellToolEnvironmentUnionSkills is an implicit subunion of
// [BetaFunctionShellToolEnvironmentUnion].
// BetaFunctionShellToolEnvironmentUnionSkills provides convenient access to the
// sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaFunctionShellToolEnvironmentUnion].
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfBetaContainerAutoSkills OfBetaLocalSkillArray]
type BetaFunctionShellToolEnvironmentUnionSkills struct {
	// This field will be present if the value is a [[]BetaContainerAutoSkillUnion]
	// instead of an object.
	OfBetaContainerAutoSkills []BetaContainerAutoSkillUnion `json:",inline"`
	// This field will be present if the value is a [[]BetaLocalSkill] instead of an
	// object.
	OfBetaLocalSkillArray []BetaLocalSkill `json:",inline"`
	JSON                  struct {
		OfBetaContainerAutoSkills respjson.Field
		OfBetaLocalSkillArray     respjson.Field
		raw                       string
	} `json:"-"`
}

func (r *BetaFunctionShellToolEnvironmentUnionSkills) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool that allows the model to execute shell commands.
//
// The property Type is required.
type BetaFunctionShellToolParam struct {
	// The tool invocation context(s).
	//
	// Any of "direct", "programmatic".
	AllowedCallers []string                                   `json:"allowed_callers,omitzero"`
	Environment    BetaFunctionShellToolEnvironmentUnionParam `json:"environment,omitzero"`
	// The type of the shell tool. Always `shell`.
	//
	// This field can be elided, and will marshal its zero value as "shell".
	Type constant.Shell `json:"type" default:"shell"`
	paramObj
}

func (r BetaFunctionShellToolParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaFunctionShellToolParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaFunctionShellToolParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaFunctionShellToolEnvironmentUnionParam struct {
	OfContainerAuto      *BetaContainerAutoParam      `json:",omitzero,inline"`
	OfLocal              *BetaLocalEnvironmentParam   `json:",omitzero,inline"`
	OfContainerReference *BetaContainerReferenceParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaFunctionShellToolEnvironmentUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfContainerAuto, u.OfLocal, u.OfContainerReference)
}
func (u *BetaFunctionShellToolEnvironmentUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaFunctionShellToolEnvironmentUnionParam) asAny() any {
	if !param.IsOmitted(u.OfContainerAuto) {
		return u.OfContainerAuto
	} else if !param.IsOmitted(u.OfLocal) {
		return u.OfLocal
	} else if !param.IsOmitted(u.OfContainerReference) {
		return u.OfContainerReference
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaFunctionShellToolEnvironmentUnionParam) GetFileIDs() []string {
	if vt := u.OfContainerAuto; vt != nil {
		return vt.FileIDs
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaFunctionShellToolEnvironmentUnionParam) GetMemoryLimit() *string {
	if vt := u.OfContainerAuto; vt != nil {
		return (*string)(&vt.MemoryLimit)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaFunctionShellToolEnvironmentUnionParam) GetNetworkPolicy() *BetaContainerAutoNetworkPolicyUnionParam {
	if vt := u.OfContainerAuto; vt != nil {
		return &vt.NetworkPolicy
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaFunctionShellToolEnvironmentUnionParam) GetContainerID() *string {
	if vt := u.OfContainerReference; vt != nil {
		return &vt.ContainerID
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaFunctionShellToolEnvironmentUnionParam) GetType() *string {
	if vt := u.OfContainerAuto; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfLocal; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfContainerReference; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

// Returns a subunion which exports methods to access subproperties
//
// Or use AsAny() to get the underlying value
func (u BetaFunctionShellToolEnvironmentUnionParam) GetSkills() (res betaFunctionShellToolEnvironmentUnionParamSkills) {
	if vt := u.OfContainerAuto; vt != nil {
		res.any = &vt.Skills
	} else if vt := u.OfLocal; vt != nil {
		res.any = &vt.Skills
	}
	return
}

// Can have the runtime types [_[]BetaContainerAutoSkillUnionParam],
// [_[]BetaLocalSkillParam]
type betaFunctionShellToolEnvironmentUnionParamSkills struct{ any }

// Use the following switch statement to get the type of the union:
//
//	switch u.AsAny().(type) {
//	case *[]openai.BetaContainerAutoSkillUnionParam:
//	case *[]openai.BetaLocalSkillParam:
//	default:
//	    fmt.Errorf("not present")
//	}
func (u betaFunctionShellToolEnvironmentUnionParamSkills) AsAny() any { return u.any }

func init() {
	apijson.RegisterUnion[BetaFunctionShellToolEnvironmentUnionParam](
		"type",
		apijson.Discriminator[BetaContainerAutoParam]("container_auto"),
		apijson.Discriminator[BetaLocalEnvironmentParam]("local"),
		apijson.Discriminator[BetaContainerReferenceParam]("container_reference"),
	)
}

// Defines a function in your own code the model can choose to call. Learn more
// about
// [function calling](https://platform.openai.com/docs/guides/function-calling).
type BetaFunctionTool struct {
	// The name of the function to call.
	Name string `json:"name" api:"required"`
	// A JSON schema object describing the parameters of the function.
	Parameters map[string]any `json:"parameters" api:"required"`
	// Whether strict parameter validation is enforced for this function tool.
	Strict bool `json:"strict" api:"required"`
	// The type of the function tool. Always `function`.
	Type constant.Function `json:"type" default:"function"`
	// The tool invocation context(s).
	//
	// Any of "direct", "programmatic".
	AllowedCallers []string `json:"allowed_callers" api:"nullable"`
	// Whether this function is deferred and loaded via tool search.
	DeferLoading bool `json:"defer_loading"`
	// A description of the function. Used by the model to determine whether or not to
	// call the function.
	Description string `json:"description" api:"nullable"`
	// A JSON schema object describing the JSON value encoded in string outputs for
	// this function.
	OutputSchema map[string]any `json:"output_schema" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Name           respjson.Field
		Parameters     respjson.Field
		Strict         respjson.Field
		Type           respjson.Field
		AllowedCallers respjson.Field
		DeferLoading   respjson.Field
		Description    respjson.Field
		OutputSchema   respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaFunctionTool) RawJSON() string { return r.JSON.raw }
func (r *BetaFunctionTool) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaFunctionTool to a BetaFunctionToolParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaFunctionToolParam.Overrides()
func (r BetaFunctionTool) ToParam() BetaFunctionToolParam {
	return param.Override[BetaFunctionToolParam](json.RawMessage(r.RawJSON()))
}

// Defines a function in your own code the model can choose to call. Learn more
// about
// [function calling](https://platform.openai.com/docs/guides/function-calling).
//
// The properties Name, Parameters, Strict, Type are required.
type BetaFunctionToolParam struct {
	// Whether strict parameter validation is enforced for this function tool.
	Strict param.Opt[bool] `json:"strict,omitzero" api:"required"`
	// A JSON schema object describing the parameters of the function.
	Parameters map[string]any `json:"parameters,omitzero" api:"required"`
	// The name of the function to call.
	Name string `json:"name" api:"required"`
	// A description of the function. Used by the model to determine whether or not to
	// call the function.
	Description param.Opt[string] `json:"description,omitzero"`
	// Whether this function is deferred and loaded via tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// The tool invocation context(s).
	//
	// Any of "direct", "programmatic".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// A JSON schema object describing the JSON value encoded in string outputs for
	// this function.
	OutputSchema map[string]any `json:"output_schema,omitzero"`
	// The type of the function tool. Always `function`.
	//
	// This field can be elided, and will marshal its zero value as "function".
	Type constant.Function `json:"type" default:"function"`
	paramObj
}

func (r BetaFunctionToolParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaFunctionToolParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaFunctionToolParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaInlineSkill struct {
	// The description of the skill.
	Description string `json:"description" api:"required"`
	// The name of the skill.
	Name string `json:"name" api:"required"`
	// Inline skill payload
	Source BetaInlineSkillSource `json:"source" api:"required"`
	// Defines an inline skill for this request.
	Type constant.Inline `json:"type" default:"inline"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Description respjson.Field
		Name        respjson.Field
		Source      respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaInlineSkill) RawJSON() string { return r.JSON.raw }
func (r *BetaInlineSkill) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaInlineSkill to a BetaInlineSkillParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaInlineSkillParam.Overrides()
func (r BetaInlineSkill) ToParam() BetaInlineSkillParam {
	return param.Override[BetaInlineSkillParam](json.RawMessage(r.RawJSON()))
}

// The properties Description, Name, Source, Type are required.
type BetaInlineSkillParam struct {
	// The description of the skill.
	Description string `json:"description" api:"required"`
	// The name of the skill.
	Name string `json:"name" api:"required"`
	// Inline skill payload
	Source BetaInlineSkillSourceParam `json:"source,omitzero" api:"required"`
	// Defines an inline skill for this request.
	//
	// This field can be elided, and will marshal its zero value as "inline".
	Type constant.Inline `json:"type" default:"inline"`
	paramObj
}

func (r BetaInlineSkillParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaInlineSkillParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaInlineSkillParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Inline skill payload
type BetaInlineSkillSource struct {
	// Base64-encoded skill zip bundle.
	Data string `json:"data" api:"required"`
	// The media type of the inline skill payload. Must be `application/zip`.
	MediaType constant.ApplicationZip `json:"media_type" default:"application/zip"`
	// The type of the inline skill source. Must be `base64`.
	Type constant.Base64 `json:"type" default:"base64"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		MediaType   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaInlineSkillSource) RawJSON() string { return r.JSON.raw }
func (r *BetaInlineSkillSource) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaInlineSkillSource to a BetaInlineSkillSourceParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaInlineSkillSourceParam.Overrides()
func (r BetaInlineSkillSource) ToParam() BetaInlineSkillSourceParam {
	return param.Override[BetaInlineSkillSourceParam](json.RawMessage(r.RawJSON()))
}

// Inline skill payload
//
// The properties Data, MediaType, Type are required.
type BetaInlineSkillSourceParam struct {
	// Base64-encoded skill zip bundle.
	Data string `json:"data" api:"required"`
	// The media type of the inline skill payload. Must be `application/zip`.
	//
	// This field can be elided, and will marshal its zero value as "application/zip".
	MediaType constant.ApplicationZip `json:"media_type" default:"application/zip"`
	// The type of the inline skill source. Must be `base64`.
	//
	// This field can be elided, and will marshal its zero value as "base64".
	Type constant.Base64 `json:"type" default:"base64"`
	paramObj
}

func (r BetaInlineSkillSourceParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaInlineSkillSourceParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaInlineSkillSourceParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaLocalEnvironment struct {
	// Use a local computer environment.
	Type constant.Local `json:"type" default:"local"`
	// An optional list of skills.
	Skills []BetaLocalSkill `json:"skills"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		Skills      respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaLocalEnvironment) RawJSON() string { return r.JSON.raw }
func (r *BetaLocalEnvironment) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaLocalEnvironment to a BetaLocalEnvironmentParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaLocalEnvironmentParam.Overrides()
func (r BetaLocalEnvironment) ToParam() BetaLocalEnvironmentParam {
	return param.Override[BetaLocalEnvironmentParam](json.RawMessage(r.RawJSON()))
}

// The property Type is required.
type BetaLocalEnvironmentParam struct {
	// An optional list of skills.
	Skills []BetaLocalSkillParam `json:"skills,omitzero"`
	// Use a local computer environment.
	//
	// This field can be elided, and will marshal its zero value as "local".
	Type constant.Local `json:"type" default:"local"`
	paramObj
}

func (r BetaLocalEnvironmentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaLocalEnvironmentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaLocalEnvironmentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaLocalSkill struct {
	// The description of the skill.
	Description string `json:"description" api:"required"`
	// The name of the skill.
	Name string `json:"name" api:"required"`
	// The path to the directory containing the skill.
	Path string `json:"path" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Description respjson.Field
		Name        respjson.Field
		Path        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaLocalSkill) RawJSON() string { return r.JSON.raw }
func (r *BetaLocalSkill) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaLocalSkill to a BetaLocalSkillParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaLocalSkillParam.Overrides()
func (r BetaLocalSkill) ToParam() BetaLocalSkillParam {
	return param.Override[BetaLocalSkillParam](json.RawMessage(r.RawJSON()))
}

// The properties Description, Name, Path are required.
type BetaLocalSkillParam struct {
	// The description of the skill.
	Description string `json:"description" api:"required"`
	// The name of the skill.
	Name string `json:"name" api:"required"`
	// The path to the directory containing the skill.
	Path string `json:"path" api:"required"`
	paramObj
}

func (r BetaLocalSkillParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaLocalSkillParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaLocalSkillParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Groups function/custom tools under a shared namespace.
type BetaNamespaceTool struct {
	// A description of the namespace shown to the model.
	Description string `json:"description" api:"required"`
	// The namespace name used in tool calls (for example, `crm`).
	Name string `json:"name" api:"required"`
	// The function/custom tools available inside this namespace.
	Tools []BetaNamespaceToolToolUnion `json:"tools" api:"required"`
	// The type of the tool. Always `namespace`.
	Type constant.Namespace `json:"type" default:"namespace"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Description respjson.Field
		Name        respjson.Field
		Tools       respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaNamespaceTool) RawJSON() string { return r.JSON.raw }
func (r *BetaNamespaceTool) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaNamespaceTool to a BetaNamespaceToolParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaNamespaceToolParam.Overrides()
func (r BetaNamespaceTool) ToParam() BetaNamespaceToolParam {
	return param.Override[BetaNamespaceToolParam](json.RawMessage(r.RawJSON()))
}

// BetaNamespaceToolToolUnion contains all possible properties and values from
// [BetaNamespaceToolToolFunction], [BetaCustomTool].
//
// Use the [BetaNamespaceToolToolUnion.AsAny] method to switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaNamespaceToolToolUnion struct {
	Name string `json:"name"`
	// Any of "function", "custom".
	Type           string   `json:"type"`
	AllowedCallers []string `json:"allowed_callers"`
	DeferLoading   bool     `json:"defer_loading"`
	Description    string   `json:"description"`
	// This field is from variant [BetaNamespaceToolToolFunction].
	OutputSchema map[string]any `json:"output_schema"`
	// This field is from variant [BetaNamespaceToolToolFunction].
	Parameters any `json:"parameters"`
	// This field is from variant [BetaNamespaceToolToolFunction].
	Strict bool `json:"strict"`
	// This field is from variant [BetaCustomTool].
	Format BetaCustomToolFormatUnion `json:"format"`
	JSON   struct {
		Name           respjson.Field
		Type           respjson.Field
		AllowedCallers respjson.Field
		DeferLoading   respjson.Field
		Description    respjson.Field
		OutputSchema   respjson.Field
		Parameters     respjson.Field
		Strict         respjson.Field
		Format         respjson.Field
		raw            string
	} `json:"-"`
}

// anyBetaNamespaceToolTool is implemented by each variant of
// [BetaNamespaceToolToolUnion] to add type safety for the return type of
// [BetaNamespaceToolToolUnion.AsAny]
type anyBetaNamespaceToolTool interface {
	implBetaNamespaceToolToolUnion()
}

func (BetaNamespaceToolToolFunction) implBetaNamespaceToolToolUnion() {}
func (BetaCustomTool) implBetaNamespaceToolToolUnion()                {}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaNamespaceToolToolUnion.AsAny().(type) {
//	case openai.BetaNamespaceToolToolFunction:
//	case openai.BetaCustomTool:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaNamespaceToolToolUnion) AsAny() anyBetaNamespaceToolTool {
	switch u.Type {
	case "function":
		return u.AsFunction()
	case "custom":
		return u.AsCustom()
	}
	return nil
}

func (u BetaNamespaceToolToolUnion) AsFunction() (v BetaNamespaceToolToolFunction) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaNamespaceToolToolUnion) AsCustom() (v BetaCustomTool) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaNamespaceToolToolUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaNamespaceToolToolUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaNamespaceToolToolFunction struct {
	Name string            `json:"name" api:"required"`
	Type constant.Function `json:"type" default:"function"`
	// The tool invocation context(s).
	//
	// Any of "direct", "programmatic".
	AllowedCallers []string `json:"allowed_callers" api:"nullable"`
	// Whether this function should be deferred and discovered via tool search.
	DeferLoading bool   `json:"defer_loading"`
	Description  string `json:"description" api:"nullable"`
	// A JSON Schema describing the JSON value encoded in string outputs for this
	// function tool. This does not describe content-array outputs.
	OutputSchema map[string]any `json:"output_schema" api:"nullable"`
	Parameters   any            `json:"parameters" api:"nullable"`
	// Whether to enforce strict parameter validation. If omitted, Responses attempts
	// to use strict validation when the schema is compatible, and falls back to
	// non-strict validation otherwise.
	Strict bool `json:"strict" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Name           respjson.Field
		Type           respjson.Field
		AllowedCallers respjson.Field
		DeferLoading   respjson.Field
		Description    respjson.Field
		OutputSchema   respjson.Field
		Parameters     respjson.Field
		Strict         respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaNamespaceToolToolFunction) RawJSON() string { return r.JSON.raw }
func (r *BetaNamespaceToolToolFunction) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Groups function/custom tools under a shared namespace.
//
// The properties Description, Name, Tools, Type are required.
type BetaNamespaceToolParam struct {
	// A description of the namespace shown to the model.
	Description string `json:"description" api:"required"`
	// The namespace name used in tool calls (for example, `crm`).
	Name string `json:"name" api:"required"`
	// The function/custom tools available inside this namespace.
	Tools []BetaNamespaceToolToolUnionParam `json:"tools,omitzero" api:"required"`
	// The type of the tool. Always `namespace`.
	//
	// This field can be elided, and will marshal its zero value as "namespace".
	Type constant.Namespace `json:"type" default:"namespace"`
	paramObj
}

func (r BetaNamespaceToolParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaNamespaceToolParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaNamespaceToolParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaNamespaceToolToolUnionParam struct {
	OfFunction *BetaNamespaceToolToolFunctionParam `json:",omitzero,inline"`
	OfCustom   *BetaCustomToolParam                `json:",omitzero,inline"`
	paramUnion
}

func (u BetaNamespaceToolToolUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfFunction, u.OfCustom)
}
func (u *BetaNamespaceToolToolUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaNamespaceToolToolUnionParam) asAny() any {
	if !param.IsOmitted(u.OfFunction) {
		return u.OfFunction
	} else if !param.IsOmitted(u.OfCustom) {
		return u.OfCustom
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaNamespaceToolToolUnionParam) GetOutputSchema() map[string]any {
	if vt := u.OfFunction; vt != nil {
		return vt.OutputSchema
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaNamespaceToolToolUnionParam) GetParameters() *any {
	if vt := u.OfFunction; vt != nil {
		return &vt.Parameters
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaNamespaceToolToolUnionParam) GetStrict() *bool {
	if vt := u.OfFunction; vt != nil && vt.Strict.Valid() {
		return &vt.Strict.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaNamespaceToolToolUnionParam) GetFormat() *BetaCustomToolFormatUnionParam {
	if vt := u.OfCustom; vt != nil {
		return &vt.Format
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaNamespaceToolToolUnionParam) GetName() *string {
	if vt := u.OfFunction; vt != nil {
		return (*string)(&vt.Name)
	} else if vt := u.OfCustom; vt != nil {
		return (*string)(&vt.Name)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaNamespaceToolToolUnionParam) GetType() *string {
	if vt := u.OfFunction; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfCustom; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaNamespaceToolToolUnionParam) GetDeferLoading() *bool {
	if vt := u.OfFunction; vt != nil && vt.DeferLoading.Valid() {
		return &vt.DeferLoading.Value
	} else if vt := u.OfCustom; vt != nil && vt.DeferLoading.Valid() {
		return &vt.DeferLoading.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaNamespaceToolToolUnionParam) GetDescription() *string {
	if vt := u.OfFunction; vt != nil && vt.Description.Valid() {
		return &vt.Description.Value
	} else if vt := u.OfCustom; vt != nil && vt.Description.Valid() {
		return &vt.Description.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's AllowedCallers property, if
// present.
func (u BetaNamespaceToolToolUnionParam) GetAllowedCallers() []string {
	if vt := u.OfFunction; vt != nil {
		return vt.AllowedCallers
	} else if vt := u.OfCustom; vt != nil {
		return vt.AllowedCallers
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaNamespaceToolToolUnionParam](
		"type",
		apijson.Discriminator[BetaNamespaceToolToolFunctionParam]("function"),
		apijson.Discriminator[BetaCustomToolParam]("custom"),
	)
}

// The properties Name, Type are required.
type BetaNamespaceToolToolFunctionParam struct {
	Name        string            `json:"name" api:"required"`
	Description param.Opt[string] `json:"description,omitzero"`
	// Whether to enforce strict parameter validation. If omitted, Responses attempts
	// to use strict validation when the schema is compatible, and falls back to
	// non-strict validation otherwise.
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Whether this function should be deferred and discovered via tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// The tool invocation context(s).
	//
	// Any of "direct", "programmatic".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// A JSON Schema describing the JSON value encoded in string outputs for this
	// function tool. This does not describe content-array outputs.
	OutputSchema map[string]any `json:"output_schema,omitzero"`
	Parameters   any            `json:"parameters,omitzero"`
	// This field can be elided, and will marshal its zero value as "function".
	Type constant.Function `json:"type" default:"function"`
	paramObj
}

func (r BetaNamespaceToolToolFunctionParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaNamespaceToolToolFunctionParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaNamespaceToolToolFunctionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponse struct {
	// Unique identifier for this Response.
	ID string `json:"id" api:"required"`
	// Unix timestamp (in seconds) of when this Response was created.
	CreatedAt float64 `json:"created_at" api:"required" format:"unixtime"`
	// An error object returned when the model fails to generate a Response.
	Error BetaResponseError `json:"error" api:"required"`
	// Details about why the response is incomplete.
	IncompleteDetails BetaResponseIncompleteDetails `json:"incomplete_details" api:"required"`
	// A system (or developer) message inserted into the model's context.
	//
	// When using along with `previous_response_id`, the instructions from a previous
	// response will not be carried over to the next response. This makes it simple to
	// swap out system (or developer) messages in new responses.
	Instructions BetaResponseInstructionsUnion `json:"instructions" api:"required"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata map[string]string `json:"metadata" api:"required"`
	// Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a
	// wide range of models with different capabilities, performance characteristics,
	// and price points. Refer to the
	// [model guide](https://platform.openai.com/docs/models) to browse and compare
	// available models.
	Model BetaResponseModel `json:"model" api:"required"`
	// The object type of this resource - always set to `response`.
	Object constant.Response `json:"object" default:"response"`
	// An array of content items generated by the model.
	//
	//   - The length and order of items in the `output` array is dependent on the
	//     model's response.
	//   - Rather than accessing the first item in the `output` array and assuming it's
	//     an `assistant` message with the content generated by the model, you might
	//     consider using the `output_text` property where supported in SDKs.
	Output []BetaResponseOutputItemUnion `json:"output" api:"required"`
	// Whether to allow the model to run tool calls in parallel.
	ParallelToolCalls bool `json:"parallel_tool_calls" api:"required"`
	// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
	// make the output more random, while lower values like 0.2 will make it more
	// focused and deterministic. We generally recommend altering this or `top_p` but
	// not both.
	Temperature float64 `json:"temperature" api:"required"`
	// How the model should select which tool (or tools) to use when generating a
	// response. See the `tools` parameter to see how to specify which tools the model
	// can call.
	ToolChoice BetaResponseToolChoiceUnion `json:"tool_choice" api:"required"`
	// An array of tools the model may call while generating a response. You can
	// specify which tool to use by setting the `tool_choice` parameter.
	//
	// We support the following categories of tools:
	//
	//   - **Built-in tools**: Tools that are provided by OpenAI that extend the model's
	//     capabilities, like
	//     [web search](https://platform.openai.com/docs/guides/tools-web-search) or
	//     [file search](https://platform.openai.com/docs/guides/tools-file-search).
	//     Learn more about
	//     [built-in tools](https://platform.openai.com/docs/guides/tools).
	//   - **MCP Tools**: Integrations with third-party systems via custom MCP servers or
	//     predefined connectors such as Google Drive and SharePoint. Learn more about
	//     [MCP Tools](https://platform.openai.com/docs/guides/tools-connectors-mcp).
	//   - **Function calls (custom tools)**: Functions that are defined by you, enabling
	//     the model to call your own code with strongly typed arguments and outputs.
	//     Learn more about
	//     [function calling](https://platform.openai.com/docs/guides/function-calling).
	//     You can also use custom tools to call your own code.
	Tools []BetaToolUnion `json:"tools" api:"required"`
	// An alternative to sampling with temperature, called nucleus sampling, where the
	// model considers the results of the tokens with top_p probability mass. So 0.1
	// means only the tokens comprising the top 10% probability mass are considered.
	//
	// We generally recommend altering this or `temperature` but not both.
	TopP float64 `json:"top_p" api:"required"`
	// Whether to run the model response in the background.
	// [Learn more](https://platform.openai.com/docs/guides/background).
	Background bool `json:"background" api:"nullable"`
	// Unix timestamp (in seconds) of when this Response was completed. Only present
	// when the status is `completed`.
	CompletedAt float64 `json:"completed_at" api:"nullable" format:"unixtime"`
	// The conversation that this response belonged to. Input items and output items
	// from this response were automatically added to this conversation.
	Conversation BetaResponseConversation `json:"conversation" api:"nullable"`
	// An upper bound for the number of tokens that can be generated for a response,
	// including visible output tokens and
	// [reasoning tokens](https://platform.openai.com/docs/guides/reasoning).
	MaxOutputTokens int64 `json:"max_output_tokens" api:"nullable"`
	// The maximum number of total calls to built-in tools that can be processed in a
	// response. This maximum number applies across all built-in tool calls, not per
	// individual tool. Any further attempts to call a tool by the model will be
	// ignored.
	MaxToolCalls int64 `json:"max_tool_calls" api:"nullable"`
	// Moderation results for the response input and output, if moderated completions
	// were requested.
	Moderation BetaResponseModeration `json:"moderation" api:"nullable"`
	// The unique ID of the previous response to the model. Use this to create
	// multi-turn conversations. Learn more about
	// [conversation state](https://platform.openai.com/docs/guides/conversation-state).
	// Cannot be used in conjunction with `conversation`.
	PreviousResponseID string `json:"previous_response_id" api:"nullable"`
	// Reference to a prompt template and its variables.
	// [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
	Prompt BetaResponsePrompt `json:"prompt" api:"nullable"`
	// Used by OpenAI to cache responses for similar requests to optimize your cache
	// hit rates. Replaces the `user` field.
	// [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
	PromptCacheKey string `json:"prompt_cache_key" api:"nullable"`
	// The prompt-caching options that were applied to the response. Supported for
	// `gpt-5.6` and later models.
	PromptCacheOptions BetaResponsePromptCacheOptions `json:"prompt_cache_options"`
	// Deprecated. Use `prompt_cache_options.ttl` instead.
	//
	// The retention policy for the prompt cache. Set to `24h` to enable extended
	// prompt caching, which keeps cached prefixes active for longer, up to a maximum
	// of 24 hours.
	// [Learn more](https://platform.openai.com/docs/guides/prompt-caching#prompt-cache-retention).
	// This field expresses a maximum retention policy, while
	// `prompt_cache_options.ttl` expresses a minimum cache lifetime. The two fields
	// are independent and do not interact. For `gpt-5.5`, `gpt-5.5-pro`, and future
	// models, only `24h` is supported.
	//
	// For older models that support both `in_memory` and `24h`, the default depends on
	// your organization's data retention policy:
	//
	//   - Organizations without ZDR enabled default to `24h`.
	//   - Organizations with ZDR enabled default to `in_memory` when
	//     `prompt_cache_retention` is not specified.
	//
	// Any of "in_memory", "24h".
	//
	// Deprecated: deprecated
	PromptCacheRetention BetaResponsePromptCacheRetention `json:"prompt_cache_retention" api:"nullable"`
	// **gpt-5 and o-series models only**
	//
	// Configuration options for
	// [reasoning models](https://platform.openai.com/docs/guides/reasoning).
	Reasoning BetaResponseReasoning `json:"reasoning" api:"nullable"`
	// A stable identifier used to help detect users of your application that may be
	// violating OpenAI's usage policies. The IDs should be a string that uniquely
	// identifies each user, with a maximum length of 64 characters. We recommend
	// hashing their username or email address, in order to avoid sending us any
	// identifying information.
	// [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
	SafetyIdentifier string `json:"safety_identifier" api:"nullable"`
	// Specifies the processing type used for serving the request.
	//
	//   - If set to 'auto', then the request will be processed with the service tier
	//     configured in the Project settings. Unless otherwise configured, the Project
	//     will use 'default'.
	//   - If set to 'default', then the request will be processed with the standard
	//     pricing and performance for the selected model.
	//   - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
	//     '[priority](https://openai.com/api-priority-processing/)', then the request
	//     will be processed with the corresponding service tier.
	//   - When not set, the default behavior is 'auto'.
	//
	// When the `service_tier` parameter is set, the response body will include the
	// `service_tier` value based on the processing mode actually used to serve the
	// request. This response value may be different from the value set in the
	// parameter.
	//
	// Any of "auto", "default", "flex", "scale", "priority".
	ServiceTier BetaResponseServiceTier `json:"service_tier" api:"nullable"`
	// The status of the response generation. One of `completed`, `failed`,
	// `in_progress`, `cancelled`, `queued`, or `incomplete`.
	//
	// Any of "completed", "failed", "in_progress", "cancelled", "queued",
	// "incomplete".
	Status BetaResponseStatus `json:"status"`
	// Configuration options for a text response from the model. Can be plain text or
	// structured JSON data. Learn more:
	//
	// - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
	// - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
	Text BetaResponseTextConfig `json:"text"`
	// An integer between 0 and 20 specifying the maximum number of most likely tokens
	// to return at each token position, each with an associated log probability. In
	// some cases, the number of returned tokens may be fewer than requested.
	TopLogprobs int64 `json:"top_logprobs" api:"nullable"`
	// The truncation strategy to use for the model response.
	//
	//   - `auto`: If the input to this Response exceeds the model's context window size,
	//     the model will truncate the response to fit the context window by dropping
	//     items from the beginning of the conversation.
	//   - `disabled` (default): If the input size will exceed the context window size
	//     for a model, the request will fail with a 400 error.
	//
	// Any of "auto", "disabled".
	Truncation BetaResponseTruncation `json:"truncation" api:"nullable"`
	// Represents token usage details including input tokens, output tokens, a
	// breakdown of output tokens, and the total tokens used.
	Usage BetaResponseUsage `json:"usage"`
	// This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
	// `prompt_cache_key` instead to maintain caching optimizations. A stable
	// identifier for your end-users. Used to boost cache hit rates by better bucketing
	// similar requests and to help OpenAI detect and prevent abuse.
	// [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
	//
	// Deprecated: deprecated
	User string `json:"user"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                   respjson.Field
		CreatedAt            respjson.Field
		Error                respjson.Field
		IncompleteDetails    respjson.Field
		Instructions         respjson.Field
		Metadata             respjson.Field
		Model                respjson.Field
		Object               respjson.Field
		Output               respjson.Field
		ParallelToolCalls    respjson.Field
		Temperature          respjson.Field
		ToolChoice           respjson.Field
		Tools                respjson.Field
		TopP                 respjson.Field
		Background           respjson.Field
		CompletedAt          respjson.Field
		Conversation         respjson.Field
		MaxOutputTokens      respjson.Field
		MaxToolCalls         respjson.Field
		Moderation           respjson.Field
		PreviousResponseID   respjson.Field
		Prompt               respjson.Field
		PromptCacheKey       respjson.Field
		PromptCacheOptions   respjson.Field
		PromptCacheRetention respjson.Field
		Reasoning            respjson.Field
		SafetyIdentifier     respjson.Field
		ServiceTier          respjson.Field
		Status               respjson.Field
		Text                 respjson.Field
		TopLogprobs          respjson.Field
		Truncation           respjson.Field
		Usage                respjson.Field
		User                 respjson.Field
		ExtraFields          map[string]respjson.Field
		raw                  string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponse) RawJSON() string { return r.JSON.raw }
func (r *BetaResponse) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Details about why the response is incomplete.
type BetaResponseIncompleteDetails struct {
	// The reason why the response is incomplete.
	//
	// Any of "max_output_tokens", "content_filter".
	Reason string `json:"reason"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Reason      respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseIncompleteDetails) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseIncompleteDetails) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseInstructionsUnion contains all possible properties and values from
// [string], [[]BetaResponseInputItemUnion].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfString OfInputItemList]
type BetaResponseInstructionsUnion struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a [[]BetaResponseInputItemUnion]
	// instead of an object.
	OfInputItemList []BetaResponseInputItemUnion `json:",inline"`
	JSON            struct {
		OfString        respjson.Field
		OfInputItemList respjson.Field
		raw             string
	} `json:"-"`
}

func (u BetaResponseInstructionsUnion) AsString() (v string) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInstructionsUnion) AsInputItemList() (v []BetaResponseInputItemUnion) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseInstructionsUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseInstructionsUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a
// wide range of models with different capabilities, performance characteristics,
// and price points. Refer to the
// [model guide](https://platform.openai.com/docs/models) to browse and compare
// available models.
type BetaResponseModel string

const (
	BetaResponseModelGPT5_6Sol                        BetaResponseModel = "gpt-5.6-sol"
	BetaResponseModelGPT5_6Terra                      BetaResponseModel = "gpt-5.6-terra"
	BetaResponseModelGPT5_6Luna                       BetaResponseModel = "gpt-5.6-luna"
	BetaResponseModelGPT5_4                           BetaResponseModel = "gpt-5.4"
	BetaResponseModelGPT5_4Mini                       BetaResponseModel = "gpt-5.4-mini"
	BetaResponseModelGPT5_4Nano                       BetaResponseModel = "gpt-5.4-nano"
	BetaResponseModelGPT5_4Mini2026_03_17             BetaResponseModel = "gpt-5.4-mini-2026-03-17"
	BetaResponseModelGPT5_4Nano2026_03_17             BetaResponseModel = "gpt-5.4-nano-2026-03-17"
	BetaResponseModelGPT5_3ChatLatest                 BetaResponseModel = "gpt-5.3-chat-latest"
	BetaResponseModelGPT5_2                           BetaResponseModel = "gpt-5.2"
	BetaResponseModelGPT5_2_2025_12_11                BetaResponseModel = "gpt-5.2-2025-12-11"
	BetaResponseModelGPT5_2ChatLatest                 BetaResponseModel = "gpt-5.2-chat-latest"
	BetaResponseModelGPT5_2Pro                        BetaResponseModel = "gpt-5.2-pro"
	BetaResponseModelGPT5_2Pro2025_12_11              BetaResponseModel = "gpt-5.2-pro-2025-12-11"
	BetaResponseModelGPT5_1                           BetaResponseModel = "gpt-5.1"
	BetaResponseModelGPT5_1_2025_11_13                BetaResponseModel = "gpt-5.1-2025-11-13"
	BetaResponseModelGPT5_1Codex                      BetaResponseModel = "gpt-5.1-codex"
	BetaResponseModelGPT5_1Mini                       BetaResponseModel = "gpt-5.1-mini"
	BetaResponseModelGPT5_1ChatLatest                 BetaResponseModel = "gpt-5.1-chat-latest"
	BetaResponseModelGPT5                             BetaResponseModel = "gpt-5"
	BetaResponseModelGPT5Mini                         BetaResponseModel = "gpt-5-mini"
	BetaResponseModelGPT5Nano                         BetaResponseModel = "gpt-5-nano"
	BetaResponseModelGPT5_2025_08_07                  BetaResponseModel = "gpt-5-2025-08-07"
	BetaResponseModelGPT5Mini2025_08_07               BetaResponseModel = "gpt-5-mini-2025-08-07"
	BetaResponseModelGPT5Nano2025_08_07               BetaResponseModel = "gpt-5-nano-2025-08-07"
	BetaResponseModelGPT5ChatLatest                   BetaResponseModel = "gpt-5-chat-latest"
	BetaResponseModelGPT4_1                           BetaResponseModel = "gpt-4.1"
	BetaResponseModelGPT4_1Mini                       BetaResponseModel = "gpt-4.1-mini"
	BetaResponseModelGPT4_1Nano                       BetaResponseModel = "gpt-4.1-nano"
	BetaResponseModelGPT4_1_2025_04_14                BetaResponseModel = "gpt-4.1-2025-04-14"
	BetaResponseModelGPT4_1Mini2025_04_14             BetaResponseModel = "gpt-4.1-mini-2025-04-14"
	BetaResponseModelGPT4_1Nano2025_04_14             BetaResponseModel = "gpt-4.1-nano-2025-04-14"
	BetaResponseModelO4Mini                           BetaResponseModel = "o4-mini"
	BetaResponseModelO4Mini2025_04_16                 BetaResponseModel = "o4-mini-2025-04-16"
	BetaResponseModelO3                               BetaResponseModel = "o3"
	BetaResponseModelO3_2025_04_16                    BetaResponseModel = "o3-2025-04-16"
	BetaResponseModelO3Mini                           BetaResponseModel = "o3-mini"
	BetaResponseModelO3Mini2025_01_31                 BetaResponseModel = "o3-mini-2025-01-31"
	BetaResponseModelO1                               BetaResponseModel = "o1"
	BetaResponseModelO1_2024_12_17                    BetaResponseModel = "o1-2024-12-17"
	BetaResponseModelO1Preview                        BetaResponseModel = "o1-preview"
	BetaResponseModelO1Preview2024_09_12              BetaResponseModel = "o1-preview-2024-09-12"
	BetaResponseModelO1Mini                           BetaResponseModel = "o1-mini"
	BetaResponseModelO1Mini2024_09_12                 BetaResponseModel = "o1-mini-2024-09-12"
	BetaResponseModelGPT4o                            BetaResponseModel = "gpt-4o"
	BetaResponseModelGPT4o2024_11_20                  BetaResponseModel = "gpt-4o-2024-11-20"
	BetaResponseModelGPT4o2024_08_06                  BetaResponseModel = "gpt-4o-2024-08-06"
	BetaResponseModelGPT4o2024_05_13                  BetaResponseModel = "gpt-4o-2024-05-13"
	BetaResponseModelGPT4oAudioPreview                BetaResponseModel = "gpt-4o-audio-preview"
	BetaResponseModelGPT4oAudioPreview2024_10_01      BetaResponseModel = "gpt-4o-audio-preview-2024-10-01"
	BetaResponseModelGPT4oAudioPreview2024_12_17      BetaResponseModel = "gpt-4o-audio-preview-2024-12-17"
	BetaResponseModelGPT4oAudioPreview2025_06_03      BetaResponseModel = "gpt-4o-audio-preview-2025-06-03"
	BetaResponseModelGPT4oMiniAudioPreview            BetaResponseModel = "gpt-4o-mini-audio-preview"
	BetaResponseModelGPT4oMiniAudioPreview2024_12_17  BetaResponseModel = "gpt-4o-mini-audio-preview-2024-12-17"
	BetaResponseModelGPT4oSearchPreview               BetaResponseModel = "gpt-4o-search-preview"
	BetaResponseModelGPT4oMiniSearchPreview           BetaResponseModel = "gpt-4o-mini-search-preview"
	BetaResponseModelGPT4oSearchPreview2025_03_11     BetaResponseModel = "gpt-4o-search-preview-2025-03-11"
	BetaResponseModelGPT4oMiniSearchPreview2025_03_11 BetaResponseModel = "gpt-4o-mini-search-preview-2025-03-11"
	BetaResponseModelChatgpt4oLatest                  BetaResponseModel = "chatgpt-4o-latest"
	BetaResponseModelCodexMiniLatest                  BetaResponseModel = "codex-mini-latest"
	BetaResponseModelGPT4oMini                        BetaResponseModel = "gpt-4o-mini"
	BetaResponseModelGPT4oMini2024_07_18              BetaResponseModel = "gpt-4o-mini-2024-07-18"
	BetaResponseModelGPT4Turbo                        BetaResponseModel = "gpt-4-turbo"
	BetaResponseModelGPT4Turbo2024_04_09              BetaResponseModel = "gpt-4-turbo-2024-04-09"
	BetaResponseModelGPT4_0125Preview                 BetaResponseModel = "gpt-4-0125-preview"
	BetaResponseModelGPT4TurboPreview                 BetaResponseModel = "gpt-4-turbo-preview"
	BetaResponseModelGPT4_1106Preview                 BetaResponseModel = "gpt-4-1106-preview"
	BetaResponseModelGPT4VisionPreview                BetaResponseModel = "gpt-4-vision-preview"
	BetaResponseModelGPT4                             BetaResponseModel = "gpt-4"
	BetaResponseModelGPT4_0314                        BetaResponseModel = "gpt-4-0314"
	BetaResponseModelGPT4_0613                        BetaResponseModel = "gpt-4-0613"
	BetaResponseModelGPT4_32k                         BetaResponseModel = "gpt-4-32k"
	BetaResponseModelGPT4_32k0314                     BetaResponseModel = "gpt-4-32k-0314"
	BetaResponseModelGPT4_32k0613                     BetaResponseModel = "gpt-4-32k-0613"
	BetaResponseModelGPT3_5Turbo                      BetaResponseModel = "gpt-3.5-turbo"
	BetaResponseModelGPT3_5Turbo16k                   BetaResponseModel = "gpt-3.5-turbo-16k"
	BetaResponseModelGPT3_5Turbo0301                  BetaResponseModel = "gpt-3.5-turbo-0301"
	BetaResponseModelGPT3_5Turbo0613                  BetaResponseModel = "gpt-3.5-turbo-0613"
	BetaResponseModelGPT3_5Turbo1106                  BetaResponseModel = "gpt-3.5-turbo-1106"
	BetaResponseModelGPT3_5Turbo0125                  BetaResponseModel = "gpt-3.5-turbo-0125"
	BetaResponseModelGPT3_5Turbo16k0613               BetaResponseModel = "gpt-3.5-turbo-16k-0613"
	BetaResponseModelO1Pro                            BetaResponseModel = "o1-pro"
	BetaResponseModelO1Pro2025_03_19                  BetaResponseModel = "o1-pro-2025-03-19"
	BetaResponseModelO3Pro                            BetaResponseModel = "o3-pro"
	BetaResponseModelO3Pro2025_06_10                  BetaResponseModel = "o3-pro-2025-06-10"
	BetaResponseModelO3DeepResearch                   BetaResponseModel = "o3-deep-research"
	BetaResponseModelO3DeepResearch2025_06_26         BetaResponseModel = "o3-deep-research-2025-06-26"
	BetaResponseModelO4MiniDeepResearch               BetaResponseModel = "o4-mini-deep-research"
	BetaResponseModelO4MiniDeepResearch2025_06_26     BetaResponseModel = "o4-mini-deep-research-2025-06-26"
	BetaResponseModelComputerUsePreview               BetaResponseModel = "computer-use-preview"
	BetaResponseModelComputerUsePreview2025_03_11     BetaResponseModel = "computer-use-preview-2025-03-11"
	BetaResponseModelGPT5Codex                        BetaResponseModel = "gpt-5-codex"
	BetaResponseModelGPT5Pro                          BetaResponseModel = "gpt-5-pro"
	BetaResponseModelGPT5Pro2025_10_06                BetaResponseModel = "gpt-5-pro-2025-10-06"
	BetaResponseModelGPT5_1CodexMax                   BetaResponseModel = "gpt-5.1-codex-max"
)

// BetaResponseToolChoiceUnion contains all possible properties and values from
// [BetaToolChoiceOptions], [BetaToolChoiceAllowed], [BetaToolChoiceTypes],
// [BetaToolChoiceFunction], [BetaToolChoiceMcp], [BetaToolChoiceCustom],
// [BetaResponseToolChoiceBetaSpecificProgrammaticToolCallingParam],
// [BetaToolChoiceApplyPatch], [BetaToolChoiceShell].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfToolChoiceMode]
type BetaResponseToolChoiceUnion struct {
	// This field will be present if the value is a [BetaToolChoiceOptions] instead of
	// an object.
	OfToolChoiceMode BetaToolChoiceOptions `json:",inline"`
	// This field is from variant [BetaToolChoiceAllowed].
	Mode BetaToolChoiceAllowedMode `json:"mode"`
	// This field is from variant [BetaToolChoiceAllowed].
	Tools []map[string]any `json:"tools"`
	Type  string           `json:"type"`
	Name  string           `json:"name"`
	// This field is from variant [BetaToolChoiceMcp].
	ServerLabel string `json:"server_label"`
	JSON        struct {
		OfToolChoiceMode respjson.Field
		Mode             respjson.Field
		Tools            respjson.Field
		Type             respjson.Field
		Name             respjson.Field
		ServerLabel      respjson.Field
		raw              string
	} `json:"-"`
}

func (u BetaResponseToolChoiceUnion) AsToolChoiceMode() (v BetaToolChoiceOptions) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseToolChoiceUnion) AsAllowedTools() (v BetaToolChoiceAllowed) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseToolChoiceUnion) AsHostedTool() (v BetaToolChoiceTypes) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseToolChoiceUnion) AsFunctionTool() (v BetaToolChoiceFunction) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseToolChoiceUnion) AsMcpTool() (v BetaToolChoiceMcp) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseToolChoiceUnion) AsCustomTool() (v BetaToolChoiceCustom) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseToolChoiceUnion) AsBetaResponseToolChoiceBetaSpecificProgrammaticToolCallingParam() (v BetaResponseToolChoiceBetaSpecificProgrammaticToolCallingParam) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseToolChoiceUnion) AsSpecificApplyPatchToolChoice() (v BetaToolChoiceApplyPatch) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseToolChoiceUnion) AsSpecificShellToolChoice() (v BetaToolChoiceShell) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseToolChoiceUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseToolChoiceUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseToolChoiceBetaSpecificProgrammaticToolCallingParam struct {
	// The tool to call. Always `programmatic_tool_calling`.
	Type constant.ProgrammaticToolCalling `json:"type" default:"programmatic_tool_calling"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseToolChoiceBetaSpecificProgrammaticToolCallingParam) RawJSON() string {
	return r.JSON.raw
}
func (r *BetaResponseToolChoiceBetaSpecificProgrammaticToolCallingParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The conversation that this response belonged to. Input items and output items
// from this response were automatically added to this conversation.
type BetaResponseConversation struct {
	// The unique ID of the conversation that this response was associated with.
	ID string `json:"id" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseConversation) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseConversation) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Moderation results for the response input and output, if moderated completions
// were requested.
type BetaResponseModeration struct {
	// Moderation for the response input.
	Input BetaResponseModerationInputUnion `json:"input" api:"required"`
	// Moderation for the response output.
	Output BetaResponseModerationOutputUnion `json:"output" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Input       respjson.Field
		Output      respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseModeration) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseModeration) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseModerationInputUnion contains all possible properties and values
// from [BetaResponseModerationInputModerationResult],
// [BetaResponseModerationInputError].
//
// Use the [BetaResponseModerationInputUnion.AsAny] method to switch on the
// variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseModerationInputUnion struct {
	// This field is from variant [BetaResponseModerationInputModerationResult].
	Categories map[string]bool `json:"categories"`
	// This field is from variant [BetaResponseModerationInputModerationResult].
	CategoryAppliedInputTypes map[string][]string `json:"category_applied_input_types"`
	// This field is from variant [BetaResponseModerationInputModerationResult].
	CategoryScores map[string]float64 `json:"category_scores"`
	// This field is from variant [BetaResponseModerationInputModerationResult].
	Flagged bool `json:"flagged"`
	// This field is from variant [BetaResponseModerationInputModerationResult].
	Model string `json:"model"`
	// Any of "moderation_result", "error".
	Type string `json:"type"`
	// This field is from variant [BetaResponseModerationInputError].
	Code string `json:"code"`
	// This field is from variant [BetaResponseModerationInputError].
	Message string `json:"message"`
	JSON    struct {
		Categories                respjson.Field
		CategoryAppliedInputTypes respjson.Field
		CategoryScores            respjson.Field
		Flagged                   respjson.Field
		Model                     respjson.Field
		Type                      respjson.Field
		Code                      respjson.Field
		Message                   respjson.Field
		raw                       string
	} `json:"-"`
}

// anyBetaResponseModerationInput is implemented by each variant of
// [BetaResponseModerationInputUnion] to add type safety for the return type of
// [BetaResponseModerationInputUnion.AsAny]
type anyBetaResponseModerationInput interface {
	implBetaResponseModerationInputUnion()
}

func (BetaResponseModerationInputModerationResult) implBetaResponseModerationInputUnion() {}
func (BetaResponseModerationInputError) implBetaResponseModerationInputUnion()            {}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseModerationInputUnion.AsAny().(type) {
//	case openai.BetaResponseModerationInputModerationResult:
//	case openai.BetaResponseModerationInputError:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseModerationInputUnion) AsAny() anyBetaResponseModerationInput {
	switch u.Type {
	case "moderation_result":
		return u.AsModerationResult()
	case "error":
		return u.AsError()
	}
	return nil
}

func (u BetaResponseModerationInputUnion) AsModerationResult() (v BetaResponseModerationInputModerationResult) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseModerationInputUnion) AsError() (v BetaResponseModerationInputError) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseModerationInputUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseModerationInputUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A moderation result produced for the response input or output.
type BetaResponseModerationInputModerationResult struct {
	// A dictionary of moderation categories to booleans, True if the input is flagged
	// under this category.
	Categories map[string]bool `json:"categories" api:"required"`
	// Which modalities of input are reflected by the score for each category.
	CategoryAppliedInputTypes map[string][]string `json:"category_applied_input_types" api:"required"`
	// A dictionary of moderation categories to scores.
	CategoryScores map[string]float64 `json:"category_scores" api:"required"`
	// A boolean indicating whether the content was flagged by any category.
	Flagged bool `json:"flagged" api:"required"`
	// The moderation model that produced this result.
	Model string `json:"model" api:"required"`
	// The object type, which was always `moderation_result` for successful moderation
	// results.
	Type constant.ModerationResult `json:"type" default:"moderation_result"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Categories                respjson.Field
		CategoryAppliedInputTypes respjson.Field
		CategoryScores            respjson.Field
		Flagged                   respjson.Field
		Model                     respjson.Field
		Type                      respjson.Field
		ExtraFields               map[string]respjson.Field
		raw                       string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseModerationInputModerationResult) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseModerationInputModerationResult) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// An error produced while attempting moderation for the response input or output.
type BetaResponseModerationInputError struct {
	// The error code.
	Code string `json:"code" api:"required"`
	// The error message.
	Message string `json:"message" api:"required"`
	// The object type, which was always `error` for moderation failures.
	Type constant.Error `json:"type" default:"error"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Code        respjson.Field
		Message     respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseModerationInputError) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseModerationInputError) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseModerationOutputUnion contains all possible properties and values
// from [BetaResponseModerationOutputModerationResult],
// [BetaResponseModerationOutputError].
//
// Use the [BetaResponseModerationOutputUnion.AsAny] method to switch on the
// variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseModerationOutputUnion struct {
	// This field is from variant [BetaResponseModerationOutputModerationResult].
	Categories map[string]bool `json:"categories"`
	// This field is from variant [BetaResponseModerationOutputModerationResult].
	CategoryAppliedInputTypes map[string][]string `json:"category_applied_input_types"`
	// This field is from variant [BetaResponseModerationOutputModerationResult].
	CategoryScores map[string]float64 `json:"category_scores"`
	// This field is from variant [BetaResponseModerationOutputModerationResult].
	Flagged bool `json:"flagged"`
	// This field is from variant [BetaResponseModerationOutputModerationResult].
	Model string `json:"model"`
	// Any of "moderation_result", "error".
	Type string `json:"type"`
	// This field is from variant [BetaResponseModerationOutputError].
	Code string `json:"code"`
	// This field is from variant [BetaResponseModerationOutputError].
	Message string `json:"message"`
	JSON    struct {
		Categories                respjson.Field
		CategoryAppliedInputTypes respjson.Field
		CategoryScores            respjson.Field
		Flagged                   respjson.Field
		Model                     respjson.Field
		Type                      respjson.Field
		Code                      respjson.Field
		Message                   respjson.Field
		raw                       string
	} `json:"-"`
}

// anyBetaResponseModerationOutput is implemented by each variant of
// [BetaResponseModerationOutputUnion] to add type safety for the return type of
// [BetaResponseModerationOutputUnion.AsAny]
type anyBetaResponseModerationOutput interface {
	implBetaResponseModerationOutputUnion()
}

func (BetaResponseModerationOutputModerationResult) implBetaResponseModerationOutputUnion() {}
func (BetaResponseModerationOutputError) implBetaResponseModerationOutputUnion()            {}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseModerationOutputUnion.AsAny().(type) {
//	case openai.BetaResponseModerationOutputModerationResult:
//	case openai.BetaResponseModerationOutputError:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseModerationOutputUnion) AsAny() anyBetaResponseModerationOutput {
	switch u.Type {
	case "moderation_result":
		return u.AsModerationResult()
	case "error":
		return u.AsError()
	}
	return nil
}

func (u BetaResponseModerationOutputUnion) AsModerationResult() (v BetaResponseModerationOutputModerationResult) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseModerationOutputUnion) AsError() (v BetaResponseModerationOutputError) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseModerationOutputUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseModerationOutputUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A moderation result produced for the response input or output.
type BetaResponseModerationOutputModerationResult struct {
	// A dictionary of moderation categories to booleans, True if the input is flagged
	// under this category.
	Categories map[string]bool `json:"categories" api:"required"`
	// Which modalities of input are reflected by the score for each category.
	CategoryAppliedInputTypes map[string][]string `json:"category_applied_input_types" api:"required"`
	// A dictionary of moderation categories to scores.
	CategoryScores map[string]float64 `json:"category_scores" api:"required"`
	// A boolean indicating whether the content was flagged by any category.
	Flagged bool `json:"flagged" api:"required"`
	// The moderation model that produced this result.
	Model string `json:"model" api:"required"`
	// The object type, which was always `moderation_result` for successful moderation
	// results.
	Type constant.ModerationResult `json:"type" default:"moderation_result"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Categories                respjson.Field
		CategoryAppliedInputTypes respjson.Field
		CategoryScores            respjson.Field
		Flagged                   respjson.Field
		Model                     respjson.Field
		Type                      respjson.Field
		ExtraFields               map[string]respjson.Field
		raw                       string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseModerationOutputModerationResult) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseModerationOutputModerationResult) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// An error produced while attempting moderation for the response input or output.
type BetaResponseModerationOutputError struct {
	// The error code.
	Code string `json:"code" api:"required"`
	// The error message.
	Message string `json:"message" api:"required"`
	// The object type, which was always `error` for moderation failures.
	Type constant.Error `json:"type" default:"error"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Code        respjson.Field
		Message     respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseModerationOutputError) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseModerationOutputError) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The prompt-caching options that were applied to the response. Supported for
// `gpt-5.6` and later models.
type BetaResponsePromptCacheOptions struct {
	// Whether implicit prompt-cache breakpoints were enabled.
	//
	// Any of "implicit", "explicit".
	Mode string `json:"mode" api:"required"`
	// The minimum lifetime applied to each cache breakpoint.
	//
	// Any of "30m".
	Ttl string `json:"ttl" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Mode        respjson.Field
		Ttl         respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponsePromptCacheOptions) RawJSON() string { return r.JSON.raw }
func (r *BetaResponsePromptCacheOptions) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Deprecated. Use `prompt_cache_options.ttl` instead.
//
// The retention policy for the prompt cache. Set to `24h` to enable extended
// prompt caching, which keeps cached prefixes active for longer, up to a maximum
// of 24 hours.
// [Learn more](https://platform.openai.com/docs/guides/prompt-caching#prompt-cache-retention).
// This field expresses a maximum retention policy, while
// `prompt_cache_options.ttl` expresses a minimum cache lifetime. The two fields
// are independent and do not interact. For `gpt-5.5`, `gpt-5.5-pro`, and future
// models, only `24h` is supported.
//
// For older models that support both `in_memory` and `24h`, the default depends on
// your organization's data retention policy:
//
//   - Organizations without ZDR enabled default to `24h`.
//   - Organizations with ZDR enabled default to `in_memory` when
//     `prompt_cache_retention` is not specified.
type BetaResponsePromptCacheRetention string

const (
	BetaResponsePromptCacheRetentionInMemory BetaResponsePromptCacheRetention = "in_memory"
	BetaResponsePromptCacheRetention24h      BetaResponsePromptCacheRetention = "24h"
)

// **gpt-5 and o-series models only**
//
// Configuration options for
// [reasoning models](https://platform.openai.com/docs/guides/reasoning).
type BetaResponseReasoning struct {
	// Controls which reasoning items are rendered back to the model on later turns. If
	// omitted or set to `auto`, the model determines the context mode. The `gpt-5.6`
	// model family defaults to `all_turns`; earlier models default to `current_turn`.
	//
	// When returned on a response, this is the effective reasoning context mode used
	// for the response.
	//
	// Any of "auto", "current_turn", "all_turns".
	Context string `json:"context" api:"nullable"`
	// Constrains effort on reasoning for reasoning models. Currently supported values
	// are `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. Reducing
	// reasoning effort can result in faster responses and fewer tokens used on
	// reasoning in a response. Not all reasoning models support every value. See the
	// [reasoning guide](https://platform.openai.com/docs/guides/reasoning) for
	// model-specific support.
	//
	// Any of "none", "minimal", "low", "medium", "high", "xhigh", "max".
	Effort string `json:"effort" api:"nullable"`
	// **Deprecated:** use `summary` instead.
	//
	// A summary of the reasoning performed by the model. This can be useful for
	// debugging and understanding the model's reasoning process. One of `auto`,
	// `concise`, or `detailed`.
	//
	// Any of "auto", "concise", "detailed".
	//
	// Deprecated: deprecated
	GenerateSummary string `json:"generate_summary" api:"nullable"`
	// Controls the reasoning execution mode for the request.
	//
	// When returned on a response, this is the effective execution mode.
	Mode string `json:"mode"`
	// A summary of the reasoning performed by the model. This can be useful for
	// debugging and understanding the model's reasoning process. One of `auto`,
	// `concise`, or `detailed`.
	//
	// `concise` is supported for `computer-use-preview` models and all reasoning
	// models after `gpt-5`.
	//
	// Any of "auto", "concise", "detailed".
	Summary string `json:"summary" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Context         respjson.Field
		Effort          respjson.Field
		GenerateSummary respjson.Field
		Mode            respjson.Field
		Summary         respjson.Field
		ExtraFields     map[string]respjson.Field
		raw             string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseReasoning) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseReasoning) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Specifies the processing type used for serving the request.
//
//   - If set to 'auto', then the request will be processed with the service tier
//     configured in the Project settings. Unless otherwise configured, the Project
//     will use 'default'.
//   - If set to 'default', then the request will be processed with the standard
//     pricing and performance for the selected model.
//   - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
//     '[priority](https://openai.com/api-priority-processing/)', then the request
//     will be processed with the corresponding service tier.
//   - When not set, the default behavior is 'auto'.
//
// When the `service_tier` parameter is set, the response body will include the
// `service_tier` value based on the processing mode actually used to serve the
// request. This response value may be different from the value set in the
// parameter.
type BetaResponseServiceTier string

const (
	BetaResponseServiceTierAuto     BetaResponseServiceTier = "auto"
	BetaResponseServiceTierDefault  BetaResponseServiceTier = "default"
	BetaResponseServiceTierFlex     BetaResponseServiceTier = "flex"
	BetaResponseServiceTierScale    BetaResponseServiceTier = "scale"
	BetaResponseServiceTierPriority BetaResponseServiceTier = "priority"
)

// The truncation strategy to use for the model response.
//
//   - `auto`: If the input to this Response exceeds the model's context window size,
//     the model will truncate the response to fit the context window by dropping
//     items from the beginning of the conversation.
//   - `disabled` (default): If the input size will exceed the context window size
//     for a model, the request will fail with a 400 error.
type BetaResponseTruncation string

const (
	BetaResponseTruncationAuto     BetaResponseTruncation = "auto"
	BetaResponseTruncationDisabled BetaResponseTruncation = "disabled"
)

// A tool call that applies file diffs by creating, deleting, or updating files.
type BetaResponseApplyPatchToolCall struct {
	// The unique ID of the apply patch tool call. Populated when this item is returned
	// via API.
	ID string `json:"id" api:"required"`
	// The unique ID of the apply patch tool call generated by the model.
	CallID string `json:"call_id" api:"required"`
	// One of the create_file, delete_file, or update_file operations applied via
	// apply_patch.
	Operation BetaResponseApplyPatchToolCallOperationUnion `json:"operation" api:"required"`
	// The status of the apply patch tool call. One of `in_progress` or `completed`.
	//
	// Any of "in_progress", "completed".
	Status BetaResponseApplyPatchToolCallStatus `json:"status" api:"required"`
	// The type of the item. Always `apply_patch_call`.
	Type constant.ApplyPatchCall `json:"type" default:"apply_patch_call"`
	// The agent that produced this item.
	Agent BetaResponseApplyPatchToolCallAgent `json:"agent"`
	// The execution context that produced this tool call.
	Caller BetaResponseApplyPatchToolCallCallerUnion `json:"caller" api:"nullable"`
	// The ID of the entity that created this tool call.
	CreatedBy string `json:"created_by"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CallID      respjson.Field
		Operation   respjson.Field
		Status      respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		Caller      respjson.Field
		CreatedBy   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseApplyPatchToolCall) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseApplyPatchToolCall) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseApplyPatchToolCallOperationUnion contains all possible properties
// and values from [BetaResponseApplyPatchToolCallOperationCreateFile],
// [BetaResponseApplyPatchToolCallOperationDeleteFile],
// [BetaResponseApplyPatchToolCallOperationUpdateFile].
//
// Use the [BetaResponseApplyPatchToolCallOperationUnion.AsAny] method to switch on
// the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseApplyPatchToolCallOperationUnion struct {
	Diff string `json:"diff"`
	Path string `json:"path"`
	// Any of "create_file", "delete_file", "update_file".
	Type string `json:"type"`
	JSON struct {
		Diff respjson.Field
		Path respjson.Field
		Type respjson.Field
		raw  string
	} `json:"-"`
}

// anyBetaResponseApplyPatchToolCallOperation is implemented by each variant of
// [BetaResponseApplyPatchToolCallOperationUnion] to add type safety for the return
// type of [BetaResponseApplyPatchToolCallOperationUnion.AsAny]
type anyBetaResponseApplyPatchToolCallOperation interface {
	implBetaResponseApplyPatchToolCallOperationUnion()
}

func (BetaResponseApplyPatchToolCallOperationCreateFile) implBetaResponseApplyPatchToolCallOperationUnion() {
}
func (BetaResponseApplyPatchToolCallOperationDeleteFile) implBetaResponseApplyPatchToolCallOperationUnion() {
}
func (BetaResponseApplyPatchToolCallOperationUpdateFile) implBetaResponseApplyPatchToolCallOperationUnion() {
}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseApplyPatchToolCallOperationUnion.AsAny().(type) {
//	case openai.BetaResponseApplyPatchToolCallOperationCreateFile:
//	case openai.BetaResponseApplyPatchToolCallOperationDeleteFile:
//	case openai.BetaResponseApplyPatchToolCallOperationUpdateFile:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseApplyPatchToolCallOperationUnion) AsAny() anyBetaResponseApplyPatchToolCallOperation {
	switch u.Type {
	case "create_file":
		return u.AsCreateFile()
	case "delete_file":
		return u.AsDeleteFile()
	case "update_file":
		return u.AsUpdateFile()
	}
	return nil
}

func (u BetaResponseApplyPatchToolCallOperationUnion) AsCreateFile() (v BetaResponseApplyPatchToolCallOperationCreateFile) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseApplyPatchToolCallOperationUnion) AsDeleteFile() (v BetaResponseApplyPatchToolCallOperationDeleteFile) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseApplyPatchToolCallOperationUnion) AsUpdateFile() (v BetaResponseApplyPatchToolCallOperationUpdateFile) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseApplyPatchToolCallOperationUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseApplyPatchToolCallOperationUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Instruction describing how to create a file via the apply_patch tool.
type BetaResponseApplyPatchToolCallOperationCreateFile struct {
	// Diff to apply.
	Diff string `json:"diff" api:"required"`
	// Path of the file to create.
	Path string `json:"path" api:"required"`
	// Create a new file with the provided diff.
	Type constant.CreateFile `json:"type" default:"create_file"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Diff        respjson.Field
		Path        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseApplyPatchToolCallOperationCreateFile) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseApplyPatchToolCallOperationCreateFile) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Instruction describing how to delete a file via the apply_patch tool.
type BetaResponseApplyPatchToolCallOperationDeleteFile struct {
	// Path of the file to delete.
	Path string `json:"path" api:"required"`
	// Delete the specified file.
	Type constant.DeleteFile `json:"type" default:"delete_file"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Path        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseApplyPatchToolCallOperationDeleteFile) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseApplyPatchToolCallOperationDeleteFile) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Instruction describing how to update a file via the apply_patch tool.
type BetaResponseApplyPatchToolCallOperationUpdateFile struct {
	// Diff to apply.
	Diff string `json:"diff" api:"required"`
	// Path of the file to update.
	Path string `json:"path" api:"required"`
	// Update an existing file with the provided diff.
	Type constant.UpdateFile `json:"type" default:"update_file"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Diff        respjson.Field
		Path        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseApplyPatchToolCallOperationUpdateFile) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseApplyPatchToolCallOperationUpdateFile) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The status of the apply patch tool call. One of `in_progress` or `completed`.
type BetaResponseApplyPatchToolCallStatus string

const (
	BetaResponseApplyPatchToolCallStatusInProgress BetaResponseApplyPatchToolCallStatus = "in_progress"
	BetaResponseApplyPatchToolCallStatusCompleted  BetaResponseApplyPatchToolCallStatus = "completed"
)

// The agent that produced this item.
type BetaResponseApplyPatchToolCallAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseApplyPatchToolCallAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseApplyPatchToolCallAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseApplyPatchToolCallCallerUnion contains all possible properties and
// values from [BetaResponseApplyPatchToolCallCallerDirect],
// [BetaResponseApplyPatchToolCallCallerProgram].
//
// Use the [BetaResponseApplyPatchToolCallCallerUnion.AsAny] method to switch on
// the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseApplyPatchToolCallCallerUnion struct {
	// Any of "direct", "program".
	Type string `json:"type"`
	// This field is from variant [BetaResponseApplyPatchToolCallCallerProgram].
	CallerID string `json:"caller_id"`
	JSON     struct {
		Type     respjson.Field
		CallerID respjson.Field
		raw      string
	} `json:"-"`
}

// anyBetaResponseApplyPatchToolCallCaller is implemented by each variant of
// [BetaResponseApplyPatchToolCallCallerUnion] to add type safety for the return
// type of [BetaResponseApplyPatchToolCallCallerUnion.AsAny]
type anyBetaResponseApplyPatchToolCallCaller interface {
	implBetaResponseApplyPatchToolCallCallerUnion()
}

func (BetaResponseApplyPatchToolCallCallerDirect) implBetaResponseApplyPatchToolCallCallerUnion()  {}
func (BetaResponseApplyPatchToolCallCallerProgram) implBetaResponseApplyPatchToolCallCallerUnion() {}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseApplyPatchToolCallCallerUnion.AsAny().(type) {
//	case openai.BetaResponseApplyPatchToolCallCallerDirect:
//	case openai.BetaResponseApplyPatchToolCallCallerProgram:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseApplyPatchToolCallCallerUnion) AsAny() anyBetaResponseApplyPatchToolCallCaller {
	switch u.Type {
	case "direct":
		return u.AsDirect()
	case "program":
		return u.AsProgram()
	}
	return nil
}

func (u BetaResponseApplyPatchToolCallCallerUnion) AsDirect() (v BetaResponseApplyPatchToolCallCallerDirect) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseApplyPatchToolCallCallerUnion) AsProgram() (v BetaResponseApplyPatchToolCallCallerProgram) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseApplyPatchToolCallCallerUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseApplyPatchToolCallCallerUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseApplyPatchToolCallCallerDirect struct {
	Type constant.Direct `json:"type" default:"direct"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseApplyPatchToolCallCallerDirect) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseApplyPatchToolCallCallerDirect) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseApplyPatchToolCallCallerProgram struct {
	// The call ID of the program item that produced this tool call.
	CallerID string           `json:"caller_id" api:"required"`
	Type     constant.Program `json:"type" default:"program"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CallerID    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseApplyPatchToolCallCallerProgram) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseApplyPatchToolCallCallerProgram) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The output emitted by an apply patch tool call.
type BetaResponseApplyPatchToolCallOutput struct {
	// The unique ID of the apply patch tool call output. Populated when this item is
	// returned via API.
	ID string `json:"id" api:"required"`
	// The unique ID of the apply patch tool call generated by the model.
	CallID string `json:"call_id" api:"required"`
	// The status of the apply patch tool call output. One of `completed` or `failed`.
	//
	// Any of "completed", "failed".
	Status BetaResponseApplyPatchToolCallOutputStatus `json:"status" api:"required"`
	// The type of the item. Always `apply_patch_call_output`.
	Type constant.ApplyPatchCallOutput `json:"type" default:"apply_patch_call_output"`
	// The agent that produced this item.
	Agent BetaResponseApplyPatchToolCallOutputAgent `json:"agent"`
	// The execution context that produced this tool call.
	Caller BetaResponseApplyPatchToolCallOutputCallerUnion `json:"caller" api:"nullable"`
	// The ID of the entity that created this tool call output.
	CreatedBy string `json:"created_by"`
	// Optional textual output returned by the apply patch tool.
	Output string `json:"output" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CallID      respjson.Field
		Status      respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		Caller      respjson.Field
		CreatedBy   respjson.Field
		Output      respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseApplyPatchToolCallOutput) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseApplyPatchToolCallOutput) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The status of the apply patch tool call output. One of `completed` or `failed`.
type BetaResponseApplyPatchToolCallOutputStatus string

const (
	BetaResponseApplyPatchToolCallOutputStatusCompleted BetaResponseApplyPatchToolCallOutputStatus = "completed"
	BetaResponseApplyPatchToolCallOutputStatusFailed    BetaResponseApplyPatchToolCallOutputStatus = "failed"
)

// The agent that produced this item.
type BetaResponseApplyPatchToolCallOutputAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseApplyPatchToolCallOutputAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseApplyPatchToolCallOutputAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseApplyPatchToolCallOutputCallerUnion contains all possible properties
// and values from [BetaResponseApplyPatchToolCallOutputCallerDirect],
// [BetaResponseApplyPatchToolCallOutputCallerProgram].
//
// Use the [BetaResponseApplyPatchToolCallOutputCallerUnion.AsAny] method to switch
// on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseApplyPatchToolCallOutputCallerUnion struct {
	// Any of "direct", "program".
	Type string `json:"type"`
	// This field is from variant [BetaResponseApplyPatchToolCallOutputCallerProgram].
	CallerID string `json:"caller_id"`
	JSON     struct {
		Type     respjson.Field
		CallerID respjson.Field
		raw      string
	} `json:"-"`
}

// anyBetaResponseApplyPatchToolCallOutputCaller is implemented by each variant of
// [BetaResponseApplyPatchToolCallOutputCallerUnion] to add type safety for the
// return type of [BetaResponseApplyPatchToolCallOutputCallerUnion.AsAny]
type anyBetaResponseApplyPatchToolCallOutputCaller interface {
	implBetaResponseApplyPatchToolCallOutputCallerUnion()
}

func (BetaResponseApplyPatchToolCallOutputCallerDirect) implBetaResponseApplyPatchToolCallOutputCallerUnion() {
}
func (BetaResponseApplyPatchToolCallOutputCallerProgram) implBetaResponseApplyPatchToolCallOutputCallerUnion() {
}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseApplyPatchToolCallOutputCallerUnion.AsAny().(type) {
//	case openai.BetaResponseApplyPatchToolCallOutputCallerDirect:
//	case openai.BetaResponseApplyPatchToolCallOutputCallerProgram:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseApplyPatchToolCallOutputCallerUnion) AsAny() anyBetaResponseApplyPatchToolCallOutputCaller {
	switch u.Type {
	case "direct":
		return u.AsDirect()
	case "program":
		return u.AsProgram()
	}
	return nil
}

func (u BetaResponseApplyPatchToolCallOutputCallerUnion) AsDirect() (v BetaResponseApplyPatchToolCallOutputCallerDirect) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseApplyPatchToolCallOutputCallerUnion) AsProgram() (v BetaResponseApplyPatchToolCallOutputCallerProgram) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseApplyPatchToolCallOutputCallerUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseApplyPatchToolCallOutputCallerUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseApplyPatchToolCallOutputCallerDirect struct {
	Type constant.Direct `json:"type" default:"direct"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseApplyPatchToolCallOutputCallerDirect) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseApplyPatchToolCallOutputCallerDirect) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseApplyPatchToolCallOutputCallerProgram struct {
	// The call ID of the program item that produced this tool call.
	CallerID string           `json:"caller_id" api:"required"`
	Type     constant.Program `json:"type" default:"program"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CallerID    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseApplyPatchToolCallOutputCallerProgram) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseApplyPatchToolCallOutputCallerProgram) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when there is a partial audio response.
type BetaResponseAudioDeltaEvent struct {
	// A chunk of Base64 encoded response audio bytes.
	Delta string `json:"delta" api:"required"`
	// A sequence number for this chunk of the stream response.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.audio.delta`.
	Type constant.ResponseAudioDelta `json:"type" default:"response.audio.delta"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseAudioDeltaEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Delta          respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseAudioDeltaEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseAudioDeltaEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseAudioDeltaEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseAudioDeltaEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseAudioDeltaEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when the audio response is complete.
type BetaResponseAudioDoneEvent struct {
	// The sequence number of the delta.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.audio.done`.
	Type constant.ResponseAudioDone `json:"type" default:"response.audio.done"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseAudioDoneEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseAudioDoneEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseAudioDoneEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseAudioDoneEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseAudioDoneEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseAudioDoneEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when there is a partial transcript of audio.
type BetaResponseAudioTranscriptDeltaEvent struct {
	// The partial transcript of the audio response.
	Delta string `json:"delta" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.audio.transcript.delta`.
	Type constant.ResponseAudioTranscriptDelta `json:"type" default:"response.audio.transcript.delta"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseAudioTranscriptDeltaEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Delta          respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseAudioTranscriptDeltaEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseAudioTranscriptDeltaEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseAudioTranscriptDeltaEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseAudioTranscriptDeltaEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseAudioTranscriptDeltaEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when the full audio transcript is completed.
type BetaResponseAudioTranscriptDoneEvent struct {
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.audio.transcript.done`.
	Type constant.ResponseAudioTranscriptDone `json:"type" default:"response.audio.transcript.done"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseAudioTranscriptDoneEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseAudioTranscriptDoneEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseAudioTranscriptDoneEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseAudioTranscriptDoneEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseAudioTranscriptDoneEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseAudioTranscriptDoneEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when a partial code snippet is streamed by the code interpreter.
type BetaResponseCodeInterpreterCallCodeDeltaEvent struct {
	// The partial code snippet being streamed by the code interpreter.
	Delta string `json:"delta" api:"required"`
	// The unique identifier of the code interpreter tool call item.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item in the response for which the code is being
	// streamed.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event, used to order streaming events.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.code_interpreter_call_code.delta`.
	Type constant.ResponseCodeInterpreterCallCodeDelta `json:"type" default:"response.code_interpreter_call_code.delta"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseCodeInterpreterCallCodeDeltaEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Delta          respjson.Field
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCodeInterpreterCallCodeDeltaEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCodeInterpreterCallCodeDeltaEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseCodeInterpreterCallCodeDeltaEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCodeInterpreterCallCodeDeltaEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCodeInterpreterCallCodeDeltaEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when the code snippet is finalized by the code interpreter.
type BetaResponseCodeInterpreterCallCodeDoneEvent struct {
	// The final code snippet output by the code interpreter.
	Code string `json:"code" api:"required"`
	// The unique identifier of the code interpreter tool call item.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item in the response for which the code is finalized.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event, used to order streaming events.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.code_interpreter_call_code.done`.
	Type constant.ResponseCodeInterpreterCallCodeDone `json:"type" default:"response.code_interpreter_call_code.done"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseCodeInterpreterCallCodeDoneEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Code           respjson.Field
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCodeInterpreterCallCodeDoneEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCodeInterpreterCallCodeDoneEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseCodeInterpreterCallCodeDoneEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCodeInterpreterCallCodeDoneEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCodeInterpreterCallCodeDoneEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when the code interpreter call is completed.
type BetaResponseCodeInterpreterCallCompletedEvent struct {
	// The unique identifier of the code interpreter tool call item.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item in the response for which the code interpreter call
	// is completed.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event, used to order streaming events.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.code_interpreter_call.completed`.
	Type constant.ResponseCodeInterpreterCallCompleted `json:"type" default:"response.code_interpreter_call.completed"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseCodeInterpreterCallCompletedEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCodeInterpreterCallCompletedEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCodeInterpreterCallCompletedEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseCodeInterpreterCallCompletedEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCodeInterpreterCallCompletedEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCodeInterpreterCallCompletedEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when a code interpreter call is in progress.
type BetaResponseCodeInterpreterCallInProgressEvent struct {
	// The unique identifier of the code interpreter tool call item.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item in the response for which the code interpreter call
	// is in progress.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event, used to order streaming events.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.code_interpreter_call.in_progress`.
	Type constant.ResponseCodeInterpreterCallInProgress `json:"type" default:"response.code_interpreter_call.in_progress"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseCodeInterpreterCallInProgressEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCodeInterpreterCallInProgressEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCodeInterpreterCallInProgressEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseCodeInterpreterCallInProgressEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCodeInterpreterCallInProgressEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCodeInterpreterCallInProgressEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when the code interpreter is actively interpreting the code snippet.
type BetaResponseCodeInterpreterCallInterpretingEvent struct {
	// The unique identifier of the code interpreter tool call item.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item in the response for which the code interpreter is
	// interpreting code.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event, used to order streaming events.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.code_interpreter_call.interpreting`.
	Type constant.ResponseCodeInterpreterCallInterpreting `json:"type" default:"response.code_interpreter_call.interpreting"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseCodeInterpreterCallInterpretingEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCodeInterpreterCallInterpretingEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCodeInterpreterCallInterpretingEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseCodeInterpreterCallInterpretingEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCodeInterpreterCallInterpretingEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCodeInterpreterCallInterpretingEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool call to run code.
type BetaResponseCodeInterpreterToolCall struct {
	// The unique ID of the code interpreter tool call.
	ID string `json:"id" api:"required"`
	// The code to run, or null if not available.
	Code string `json:"code" api:"required"`
	// The ID of the container used to run the code.
	ContainerID string `json:"container_id" api:"required"`
	// The outputs generated by the code interpreter, such as logs or images. Can be
	// null if no outputs are available.
	Outputs []BetaResponseCodeInterpreterToolCallOutputUnion `json:"outputs" api:"required"`
	// The status of the code interpreter tool call. Valid values are `in_progress`,
	// `completed`, `incomplete`, `interpreting`, and `failed`.
	//
	// Any of "in_progress", "completed", "incomplete", "interpreting", "failed".
	Status BetaResponseCodeInterpreterToolCallStatus `json:"status" api:"required"`
	// The type of the code interpreter tool call. Always `code_interpreter_call`.
	Type constant.CodeInterpreterCall `json:"type" default:"code_interpreter_call"`
	// The agent that produced this item.
	Agent BetaResponseCodeInterpreterToolCallAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Code        respjson.Field
		ContainerID respjson.Field
		Outputs     respjson.Field
		Status      respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCodeInterpreterToolCall) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCodeInterpreterToolCall) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseCodeInterpreterToolCall to a
// BetaResponseCodeInterpreterToolCallParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseCodeInterpreterToolCallParam.Overrides()
func (r BetaResponseCodeInterpreterToolCall) ToParam() BetaResponseCodeInterpreterToolCallParam {
	return param.Override[BetaResponseCodeInterpreterToolCallParam](json.RawMessage(r.RawJSON()))
}

// BetaResponseCodeInterpreterToolCallOutputUnion contains all possible properties
// and values from [BetaResponseCodeInterpreterToolCallOutputLogs],
// [BetaResponseCodeInterpreterToolCallOutputImage].
//
// Use the [BetaResponseCodeInterpreterToolCallOutputUnion.AsAny] method to switch
// on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseCodeInterpreterToolCallOutputUnion struct {
	// This field is from variant [BetaResponseCodeInterpreterToolCallOutputLogs].
	Logs string `json:"logs"`
	// Any of "logs", "image".
	Type string `json:"type"`
	// This field is from variant [BetaResponseCodeInterpreterToolCallOutputImage].
	URL  string `json:"url"`
	JSON struct {
		Logs respjson.Field
		Type respjson.Field
		URL  respjson.Field
		raw  string
	} `json:"-"`
}

// anyBetaResponseCodeInterpreterToolCallOutput is implemented by each variant of
// [BetaResponseCodeInterpreterToolCallOutputUnion] to add type safety for the
// return type of [BetaResponseCodeInterpreterToolCallOutputUnion.AsAny]
type anyBetaResponseCodeInterpreterToolCallOutput interface {
	implBetaResponseCodeInterpreterToolCallOutputUnion()
}

func (BetaResponseCodeInterpreterToolCallOutputLogs) implBetaResponseCodeInterpreterToolCallOutputUnion() {
}
func (BetaResponseCodeInterpreterToolCallOutputImage) implBetaResponseCodeInterpreterToolCallOutputUnion() {
}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseCodeInterpreterToolCallOutputUnion.AsAny().(type) {
//	case openai.BetaResponseCodeInterpreterToolCallOutputLogs:
//	case openai.BetaResponseCodeInterpreterToolCallOutputImage:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseCodeInterpreterToolCallOutputUnion) AsAny() anyBetaResponseCodeInterpreterToolCallOutput {
	switch u.Type {
	case "logs":
		return u.AsLogs()
	case "image":
		return u.AsImage()
	}
	return nil
}

func (u BetaResponseCodeInterpreterToolCallOutputUnion) AsLogs() (v BetaResponseCodeInterpreterToolCallOutputLogs) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseCodeInterpreterToolCallOutputUnion) AsImage() (v BetaResponseCodeInterpreterToolCallOutputImage) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseCodeInterpreterToolCallOutputUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseCodeInterpreterToolCallOutputUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The logs output from the code interpreter.
type BetaResponseCodeInterpreterToolCallOutputLogs struct {
	// The logs output from the code interpreter.
	Logs string `json:"logs" api:"required"`
	// The type of the output. Always `logs`.
	Type constant.Logs `json:"type" default:"logs"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Logs        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCodeInterpreterToolCallOutputLogs) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCodeInterpreterToolCallOutputLogs) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The image output from the code interpreter.
type BetaResponseCodeInterpreterToolCallOutputImage struct {
	// The type of the output. Always `image`.
	Type constant.Image `json:"type" default:"image"`
	// The URL of the image output from the code interpreter.
	URL string `json:"url" api:"required" format:"uri"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		URL         respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCodeInterpreterToolCallOutputImage) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCodeInterpreterToolCallOutputImage) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The status of the code interpreter tool call. Valid values are `in_progress`,
// `completed`, `incomplete`, `interpreting`, and `failed`.
type BetaResponseCodeInterpreterToolCallStatus string

const (
	BetaResponseCodeInterpreterToolCallStatusInProgress   BetaResponseCodeInterpreterToolCallStatus = "in_progress"
	BetaResponseCodeInterpreterToolCallStatusCompleted    BetaResponseCodeInterpreterToolCallStatus = "completed"
	BetaResponseCodeInterpreterToolCallStatusIncomplete   BetaResponseCodeInterpreterToolCallStatus = "incomplete"
	BetaResponseCodeInterpreterToolCallStatusInterpreting BetaResponseCodeInterpreterToolCallStatus = "interpreting"
	BetaResponseCodeInterpreterToolCallStatusFailed       BetaResponseCodeInterpreterToolCallStatus = "failed"
)

// The agent that produced this item.
type BetaResponseCodeInterpreterToolCallAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCodeInterpreterToolCallAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCodeInterpreterToolCallAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool call to run code.
//
// The properties ID, Code, ContainerID, Outputs, Status, Type are required.
type BetaResponseCodeInterpreterToolCallParam struct {
	// The code to run, or null if not available.
	Code param.Opt[string] `json:"code,omitzero" api:"required"`
	// The outputs generated by the code interpreter, such as logs or images. Can be
	// null if no outputs are available.
	Outputs []BetaResponseCodeInterpreterToolCallOutputUnionParam `json:"outputs,omitzero" api:"required"`
	// The unique ID of the code interpreter tool call.
	ID string `json:"id" api:"required"`
	// The ID of the container used to run the code.
	ContainerID string `json:"container_id" api:"required"`
	// The status of the code interpreter tool call. Valid values are `in_progress`,
	// `completed`, `incomplete`, `interpreting`, and `failed`.
	//
	// Any of "in_progress", "completed", "incomplete", "interpreting", "failed".
	Status BetaResponseCodeInterpreterToolCallStatus `json:"status,omitzero" api:"required"`
	// The agent that produced this item.
	Agent BetaResponseCodeInterpreterToolCallAgentParam `json:"agent,omitzero"`
	// The type of the code interpreter tool call. Always `code_interpreter_call`.
	//
	// This field can be elided, and will marshal its zero value as
	// "code_interpreter_call".
	Type constant.CodeInterpreterCall `json:"type" default:"code_interpreter_call"`
	paramObj
}

func (r BetaResponseCodeInterpreterToolCallParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseCodeInterpreterToolCallParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseCodeInterpreterToolCallParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseCodeInterpreterToolCallOutputUnionParam struct {
	OfLogs  *BetaResponseCodeInterpreterToolCallOutputLogsParam  `json:",omitzero,inline"`
	OfImage *BetaResponseCodeInterpreterToolCallOutputImageParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseCodeInterpreterToolCallOutputUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfLogs, u.OfImage)
}
func (u *BetaResponseCodeInterpreterToolCallOutputUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseCodeInterpreterToolCallOutputUnionParam) asAny() any {
	if !param.IsOmitted(u.OfLogs) {
		return u.OfLogs
	} else if !param.IsOmitted(u.OfImage) {
		return u.OfImage
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseCodeInterpreterToolCallOutputUnionParam) GetLogs() *string {
	if vt := u.OfLogs; vt != nil {
		return &vt.Logs
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseCodeInterpreterToolCallOutputUnionParam) GetURL() *string {
	if vt := u.OfImage; vt != nil {
		return &vt.URL
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseCodeInterpreterToolCallOutputUnionParam) GetType() *string {
	if vt := u.OfLogs; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfImage; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaResponseCodeInterpreterToolCallOutputUnionParam](
		"type",
		apijson.Discriminator[BetaResponseCodeInterpreterToolCallOutputLogsParam]("logs"),
		apijson.Discriminator[BetaResponseCodeInterpreterToolCallOutputImageParam]("image"),
	)
}

// The logs output from the code interpreter.
//
// The properties Logs, Type are required.
type BetaResponseCodeInterpreterToolCallOutputLogsParam struct {
	// The logs output from the code interpreter.
	Logs string `json:"logs" api:"required"`
	// The type of the output. Always `logs`.
	//
	// This field can be elided, and will marshal its zero value as "logs".
	Type constant.Logs `json:"type" default:"logs"`
	paramObj
}

func (r BetaResponseCodeInterpreterToolCallOutputLogsParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseCodeInterpreterToolCallOutputLogsParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseCodeInterpreterToolCallOutputLogsParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The image output from the code interpreter.
//
// The properties Type, URL are required.
type BetaResponseCodeInterpreterToolCallOutputImageParam struct {
	// The URL of the image output from the code interpreter.
	URL string `json:"url" api:"required" format:"uri"`
	// The type of the output. Always `image`.
	//
	// This field can be elided, and will marshal its zero value as "image".
	Type constant.Image `json:"type" default:"image"`
	paramObj
}

func (r BetaResponseCodeInterpreterToolCallOutputImageParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseCodeInterpreterToolCallOutputImageParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseCodeInterpreterToolCallOutputImageParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseCodeInterpreterToolCallAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseCodeInterpreterToolCallAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseCodeInterpreterToolCallAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseCodeInterpreterToolCallAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A compaction item generated by the
// [`v1/responses/compact` API](https://platform.openai.com/docs/api-reference/responses/compact).
type BetaResponseCompactionItem struct {
	// The unique ID of the compaction item.
	ID string `json:"id" api:"required"`
	// The encrypted content that was produced by compaction.
	EncryptedContent string `json:"encrypted_content" api:"required"`
	// The type of the item. Always `compaction`.
	Type constant.Compaction `json:"type" default:"compaction"`
	// The agent that produced this item.
	Agent BetaResponseCompactionItemAgent `json:"agent"`
	// The identifier of the actor that created the item.
	CreatedBy string `json:"created_by"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID               respjson.Field
		EncryptedContent respjson.Field
		Type             respjson.Field
		Agent            respjson.Field
		CreatedBy        respjson.Field
		ExtraFields      map[string]respjson.Field
		raw              string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCompactionItem) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCompactionItem) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseCompactionItemAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCompactionItemAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCompactionItemAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A compaction item generated by the
// [`v1/responses/compact` API](https://platform.openai.com/docs/api-reference/responses/compact).
type BetaResponseCompactionItemParamResp struct {
	// The encrypted content of the compaction summary.
	EncryptedContent string `json:"encrypted_content" api:"required"`
	// The type of the item. Always `compaction`.
	Type constant.Compaction `json:"type" default:"compaction"`
	// The ID of the compaction item.
	ID string `json:"id" api:"nullable"`
	// The agent that produced this item.
	Agent BetaResponseCompactionItemParamAgentResp `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		EncryptedContent respjson.Field
		Type             respjson.Field
		ID               respjson.Field
		Agent            respjson.Field
		ExtraFields      map[string]respjson.Field
		raw              string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCompactionItemParamResp) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCompactionItemParamResp) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseCompactionItemParamResp to a
// BetaResponseCompactionItemParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseCompactionItemParam.Overrides()
func (r BetaResponseCompactionItemParamResp) ToParam() BetaResponseCompactionItemParam {
	return param.Override[BetaResponseCompactionItemParam](json.RawMessage(r.RawJSON()))
}

// The agent that produced this item.
type BetaResponseCompactionItemParamAgentResp struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCompactionItemParamAgentResp) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCompactionItemParamAgentResp) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A compaction item generated by the
// [`v1/responses/compact` API](https://platform.openai.com/docs/api-reference/responses/compact).
//
// The properties EncryptedContent, Type are required.
type BetaResponseCompactionItemParam struct {
	// The encrypted content of the compaction summary.
	EncryptedContent string `json:"encrypted_content" api:"required"`
	// The ID of the compaction item.
	ID param.Opt[string] `json:"id,omitzero"`
	// The agent that produced this item.
	Agent BetaResponseCompactionItemParamAgent `json:"agent,omitzero"`
	// The type of the item. Always `compaction`.
	//
	// This field can be elided, and will marshal its zero value as "compaction".
	Type constant.Compaction `json:"type" default:"compaction"`
	paramObj
}

func (r BetaResponseCompactionItemParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseCompactionItemParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseCompactionItemParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseCompactionItemParamAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseCompactionItemParamAgent) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseCompactionItemParamAgent
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseCompactionItemParamAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when the model response is complete.
type BetaResponseCompletedEvent struct {
	// Properties of the completed response.
	Response BetaResponse `json:"response" api:"required"`
	// The sequence number for this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.completed`.
	Type constant.ResponseCompleted `json:"type" default:"response.completed"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseCompletedEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Response       respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCompletedEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCompletedEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseCompletedEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCompletedEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCompletedEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool call to a computer use tool. See the
// [computer use guide](https://platform.openai.com/docs/guides/tools-computer-use)
// for more information.
type BetaResponseComputerToolCall struct {
	// The unique ID of the computer call.
	ID string `json:"id" api:"required"`
	// An identifier used when responding to the tool call with output.
	CallID string `json:"call_id" api:"required"`
	// The pending safety checks for the computer call.
	PendingSafetyChecks []BetaResponseComputerToolCallPendingSafetyCheck `json:"pending_safety_checks" api:"required"`
	// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
	// Populated when items are returned via API.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status BetaResponseComputerToolCallStatus `json:"status" api:"required"`
	// The type of the computer call. Always `computer_call`.
	//
	// Any of "computer_call".
	Type BetaResponseComputerToolCallType `json:"type" api:"required"`
	// A click action.
	Action BetaComputerActionUnion `json:"action"`
	// Flattened batched actions for `computer_use`. Each action includes an `type`
	// discriminator and action-specific fields.
	Actions BetaComputerActionList `json:"actions"`
	// The agent that produced this item.
	Agent BetaResponseComputerToolCallAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                  respjson.Field
		CallID              respjson.Field
		PendingSafetyChecks respjson.Field
		Status              respjson.Field
		Type                respjson.Field
		Action              respjson.Field
		Actions             respjson.Field
		Agent               respjson.Field
		ExtraFields         map[string]respjson.Field
		raw                 string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseComputerToolCall) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseComputerToolCall) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseComputerToolCall to a
// BetaResponseComputerToolCallParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseComputerToolCallParam.Overrides()
func (r BetaResponseComputerToolCall) ToParam() BetaResponseComputerToolCallParam {
	return param.Override[BetaResponseComputerToolCallParam](json.RawMessage(r.RawJSON()))
}

// A pending safety check for the computer call.
type BetaResponseComputerToolCallPendingSafetyCheck struct {
	// The ID of the pending safety check.
	ID string `json:"id" api:"required"`
	// The type of the pending safety check.
	Code string `json:"code" api:"nullable"`
	// Details about the pending safety check.
	Message string `json:"message" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Code        respjson.Field
		Message     respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseComputerToolCallPendingSafetyCheck) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseComputerToolCallPendingSafetyCheck) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
// Populated when items are returned via API.
type BetaResponseComputerToolCallStatus string

const (
	BetaResponseComputerToolCallStatusInProgress BetaResponseComputerToolCallStatus = "in_progress"
	BetaResponseComputerToolCallStatusCompleted  BetaResponseComputerToolCallStatus = "completed"
	BetaResponseComputerToolCallStatusIncomplete BetaResponseComputerToolCallStatus = "incomplete"
)

// The type of the computer call. Always `computer_call`.
type BetaResponseComputerToolCallType string

const (
	BetaResponseComputerToolCallTypeComputerCall BetaResponseComputerToolCallType = "computer_call"
)

// The agent that produced this item.
type BetaResponseComputerToolCallAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseComputerToolCallAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseComputerToolCallAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool call to a computer use tool. See the
// [computer use guide](https://platform.openai.com/docs/guides/tools-computer-use)
// for more information.
//
// The properties ID, CallID, PendingSafetyChecks, Status, Type are required.
type BetaResponseComputerToolCallParam struct {
	// The unique ID of the computer call.
	ID string `json:"id" api:"required"`
	// An identifier used when responding to the tool call with output.
	CallID string `json:"call_id" api:"required"`
	// The pending safety checks for the computer call.
	PendingSafetyChecks []BetaResponseComputerToolCallPendingSafetyCheckParam `json:"pending_safety_checks,omitzero" api:"required"`
	// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
	// Populated when items are returned via API.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status BetaResponseComputerToolCallStatus `json:"status,omitzero" api:"required"`
	// The type of the computer call. Always `computer_call`.
	//
	// Any of "computer_call".
	Type BetaResponseComputerToolCallType `json:"type,omitzero" api:"required"`
	// The agent that produced this item.
	Agent BetaResponseComputerToolCallAgentParam `json:"agent,omitzero"`
	// A click action.
	Action BetaComputerActionUnionParam `json:"action,omitzero"`
	// Flattened batched actions for `computer_use`. Each action includes an `type`
	// discriminator and action-specific fields.
	Actions BetaComputerActionListParam `json:"actions,omitzero"`
	paramObj
}

func (r BetaResponseComputerToolCallParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseComputerToolCallParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseComputerToolCallParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A pending safety check for the computer call.
//
// The property ID is required.
type BetaResponseComputerToolCallPendingSafetyCheckParam struct {
	// The ID of the pending safety check.
	ID string `json:"id" api:"required"`
	// The type of the pending safety check.
	Code param.Opt[string] `json:"code,omitzero"`
	// Details about the pending safety check.
	Message param.Opt[string] `json:"message,omitzero"`
	paramObj
}

func (r BetaResponseComputerToolCallPendingSafetyCheckParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseComputerToolCallPendingSafetyCheckParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseComputerToolCallPendingSafetyCheckParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseComputerToolCallAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseComputerToolCallAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseComputerToolCallAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseComputerToolCallAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseComputerToolCallOutputItem struct {
	// The unique ID of the computer call tool output.
	ID string `json:"id" api:"required"`
	// The ID of the computer tool call that produced the output.
	CallID string `json:"call_id" api:"required"`
	// A computer screenshot image used with the computer use tool.
	Output BetaResponseComputerToolCallOutputScreenshot `json:"output" api:"required"`
	// The status of the message input. One of `in_progress`, `completed`, or
	// `incomplete`. Populated when input items are returned via API.
	//
	// Any of "completed", "incomplete", "failed", "in_progress".
	Status BetaResponseComputerToolCallOutputItemStatus `json:"status" api:"required"`
	// The type of the computer tool call output. Always `computer_call_output`.
	Type constant.ComputerCallOutput `json:"type" default:"computer_call_output"`
	// The safety checks reported by the API that have been acknowledged by the
	// developer.
	AcknowledgedSafetyChecks []BetaResponseComputerToolCallOutputItemAcknowledgedSafetyCheck `json:"acknowledged_safety_checks"`
	// The agent that produced this item.
	Agent BetaResponseComputerToolCallOutputItemAgent `json:"agent" api:"nullable"`
	// The identifier of the actor that created the item.
	CreatedBy string `json:"created_by"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                       respjson.Field
		CallID                   respjson.Field
		Output                   respjson.Field
		Status                   respjson.Field
		Type                     respjson.Field
		AcknowledgedSafetyChecks respjson.Field
		Agent                    respjson.Field
		CreatedBy                respjson.Field
		ExtraFields              map[string]respjson.Field
		raw                      string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseComputerToolCallOutputItem) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseComputerToolCallOutputItem) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The status of the message input. One of `in_progress`, `completed`, or
// `incomplete`. Populated when input items are returned via API.
type BetaResponseComputerToolCallOutputItemStatus string

const (
	BetaResponseComputerToolCallOutputItemStatusCompleted  BetaResponseComputerToolCallOutputItemStatus = "completed"
	BetaResponseComputerToolCallOutputItemStatusIncomplete BetaResponseComputerToolCallOutputItemStatus = "incomplete"
	BetaResponseComputerToolCallOutputItemStatusFailed     BetaResponseComputerToolCallOutputItemStatus = "failed"
	BetaResponseComputerToolCallOutputItemStatusInProgress BetaResponseComputerToolCallOutputItemStatus = "in_progress"
)

// A pending safety check for the computer call.
type BetaResponseComputerToolCallOutputItemAcknowledgedSafetyCheck struct {
	// The ID of the pending safety check.
	ID string `json:"id" api:"required"`
	// The type of the pending safety check.
	Code string `json:"code" api:"nullable"`
	// Details about the pending safety check.
	Message string `json:"message" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Code        respjson.Field
		Message     respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseComputerToolCallOutputItemAcknowledgedSafetyCheck) RawJSON() string {
	return r.JSON.raw
}
func (r *BetaResponseComputerToolCallOutputItemAcknowledgedSafetyCheck) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseComputerToolCallOutputItemAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseComputerToolCallOutputItemAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseComputerToolCallOutputItemAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A computer screenshot image used with the computer use tool.
type BetaResponseComputerToolCallOutputScreenshot struct {
	// Specifies the event type. For a computer screenshot, this property is always set
	// to `computer_screenshot`.
	Type constant.ComputerScreenshot `json:"type" default:"computer_screenshot"`
	// The identifier of an uploaded file that contains the screenshot.
	FileID string `json:"file_id"`
	// The URL of the screenshot image.
	ImageURL string `json:"image_url" format:"uri"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		FileID      respjson.Field
		ImageURL    respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseComputerToolCallOutputScreenshot) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseComputerToolCallOutputScreenshot) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseComputerToolCallOutputScreenshot to a
// BetaResponseComputerToolCallOutputScreenshotParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseComputerToolCallOutputScreenshotParam.Overrides()
func (r BetaResponseComputerToolCallOutputScreenshot) ToParam() BetaResponseComputerToolCallOutputScreenshotParam {
	return param.Override[BetaResponseComputerToolCallOutputScreenshotParam](json.RawMessage(r.RawJSON()))
}

// A computer screenshot image used with the computer use tool.
//
// The property Type is required.
type BetaResponseComputerToolCallOutputScreenshotParam struct {
	// The identifier of an uploaded file that contains the screenshot.
	FileID param.Opt[string] `json:"file_id,omitzero"`
	// The URL of the screenshot image.
	ImageURL param.Opt[string] `json:"image_url,omitzero" format:"uri"`
	// Specifies the event type. For a computer screenshot, this property is always set
	// to `computer_screenshot`.
	//
	// This field can be elided, and will marshal its zero value as
	// "computer_screenshot".
	Type constant.ComputerScreenshot `json:"type" default:"computer_screenshot"`
	paramObj
}

func (r BetaResponseComputerToolCallOutputScreenshotParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseComputerToolCallOutputScreenshotParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseComputerToolCallOutputScreenshotParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Represents a container created with /v1/containers.
type BetaResponseContainerReference struct {
	ContainerID string `json:"container_id" api:"required"`
	// The environment type. Always `container_reference`.
	Type constant.ContainerReference `json:"type" default:"container_reference"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ContainerID respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseContainerReference) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseContainerReference) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when a new content part is added.
type BetaResponseContentPartAddedEvent struct {
	// The index of the content part that was added.
	ContentIndex int64 `json:"content_index" api:"required"`
	// The ID of the output item that the content part was added to.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item that the content part was added to.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The content part that was added.
	Part BetaResponseContentPartAddedEventPartUnion `json:"part" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.content_part.added`.
	Type constant.ResponseContentPartAdded `json:"type" default:"response.content_part.added"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseContentPartAddedEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ContentIndex   respjson.Field
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		Part           respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseContentPartAddedEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseContentPartAddedEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseContentPartAddedEventPartUnion contains all possible properties and
// values from [BetaResponseOutputText], [BetaResponseOutputRefusal],
// [BetaResponseContentPartAddedEventPartReasoningText].
//
// Use the [BetaResponseContentPartAddedEventPartUnion.AsAny] method to switch on
// the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseContentPartAddedEventPartUnion struct {
	// This field is from variant [BetaResponseOutputText].
	Annotations []BetaResponseOutputTextAnnotationUnion `json:"annotations"`
	Text        string                                  `json:"text"`
	// Any of "output_text", "refusal", "reasoning_text".
	Type string `json:"type"`
	// This field is from variant [BetaResponseOutputText].
	Logprobs []BetaResponseOutputTextLogprob `json:"logprobs"`
	// This field is from variant [BetaResponseOutputRefusal].
	Refusal string `json:"refusal"`
	JSON    struct {
		Annotations respjson.Field
		Text        respjson.Field
		Type        respjson.Field
		Logprobs    respjson.Field
		Refusal     respjson.Field
		raw         string
	} `json:"-"`
}

// anyBetaResponseContentPartAddedEventPart is implemented by each variant of
// [BetaResponseContentPartAddedEventPartUnion] to add type safety for the return
// type of [BetaResponseContentPartAddedEventPartUnion.AsAny]
type anyBetaResponseContentPartAddedEventPart interface {
	implBetaResponseContentPartAddedEventPartUnion()
}

func (BetaResponseOutputText) implBetaResponseContentPartAddedEventPartUnion()    {}
func (BetaResponseOutputRefusal) implBetaResponseContentPartAddedEventPartUnion() {}
func (BetaResponseContentPartAddedEventPartReasoningText) implBetaResponseContentPartAddedEventPartUnion() {
}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseContentPartAddedEventPartUnion.AsAny().(type) {
//	case openai.BetaResponseOutputText:
//	case openai.BetaResponseOutputRefusal:
//	case openai.BetaResponseContentPartAddedEventPartReasoningText:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseContentPartAddedEventPartUnion) AsAny() anyBetaResponseContentPartAddedEventPart {
	switch u.Type {
	case "output_text":
		return u.AsOutputText()
	case "refusal":
		return u.AsRefusal()
	case "reasoning_text":
		return u.AsReasoningText()
	}
	return nil
}

func (u BetaResponseContentPartAddedEventPartUnion) AsOutputText() (v BetaResponseOutputText) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseContentPartAddedEventPartUnion) AsRefusal() (v BetaResponseOutputRefusal) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseContentPartAddedEventPartUnion) AsReasoningText() (v BetaResponseContentPartAddedEventPartReasoningText) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseContentPartAddedEventPartUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseContentPartAddedEventPartUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Reasoning text from the model.
type BetaResponseContentPartAddedEventPartReasoningText struct {
	// The reasoning text from the model.
	Text string `json:"text" api:"required"`
	// The type of the reasoning text. Always `reasoning_text`.
	Type constant.ReasoningText `json:"type" default:"reasoning_text"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseContentPartAddedEventPartReasoningText) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseContentPartAddedEventPartReasoningText) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseContentPartAddedEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseContentPartAddedEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseContentPartAddedEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when a content part is done.
type BetaResponseContentPartDoneEvent struct {
	// The index of the content part that is done.
	ContentIndex int64 `json:"content_index" api:"required"`
	// The ID of the output item that the content part was added to.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item that the content part was added to.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The content part that is done.
	Part BetaResponseContentPartDoneEventPartUnion `json:"part" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.content_part.done`.
	Type constant.ResponseContentPartDone `json:"type" default:"response.content_part.done"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseContentPartDoneEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ContentIndex   respjson.Field
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		Part           respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseContentPartDoneEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseContentPartDoneEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseContentPartDoneEventPartUnion contains all possible properties and
// values from [BetaResponseOutputText], [BetaResponseOutputRefusal],
// [BetaResponseContentPartDoneEventPartReasoningText].
//
// Use the [BetaResponseContentPartDoneEventPartUnion.AsAny] method to switch on
// the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseContentPartDoneEventPartUnion struct {
	// This field is from variant [BetaResponseOutputText].
	Annotations []BetaResponseOutputTextAnnotationUnion `json:"annotations"`
	Text        string                                  `json:"text"`
	// Any of "output_text", "refusal", "reasoning_text".
	Type string `json:"type"`
	// This field is from variant [BetaResponseOutputText].
	Logprobs []BetaResponseOutputTextLogprob `json:"logprobs"`
	// This field is from variant [BetaResponseOutputRefusal].
	Refusal string `json:"refusal"`
	JSON    struct {
		Annotations respjson.Field
		Text        respjson.Field
		Type        respjson.Field
		Logprobs    respjson.Field
		Refusal     respjson.Field
		raw         string
	} `json:"-"`
}

// anyBetaResponseContentPartDoneEventPart is implemented by each variant of
// [BetaResponseContentPartDoneEventPartUnion] to add type safety for the return
// type of [BetaResponseContentPartDoneEventPartUnion.AsAny]
type anyBetaResponseContentPartDoneEventPart interface {
	implBetaResponseContentPartDoneEventPartUnion()
}

func (BetaResponseOutputText) implBetaResponseContentPartDoneEventPartUnion()    {}
func (BetaResponseOutputRefusal) implBetaResponseContentPartDoneEventPartUnion() {}
func (BetaResponseContentPartDoneEventPartReasoningText) implBetaResponseContentPartDoneEventPartUnion() {
}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseContentPartDoneEventPartUnion.AsAny().(type) {
//	case openai.BetaResponseOutputText:
//	case openai.BetaResponseOutputRefusal:
//	case openai.BetaResponseContentPartDoneEventPartReasoningText:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseContentPartDoneEventPartUnion) AsAny() anyBetaResponseContentPartDoneEventPart {
	switch u.Type {
	case "output_text":
		return u.AsOutputText()
	case "refusal":
		return u.AsRefusal()
	case "reasoning_text":
		return u.AsReasoningText()
	}
	return nil
}

func (u BetaResponseContentPartDoneEventPartUnion) AsOutputText() (v BetaResponseOutputText) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseContentPartDoneEventPartUnion) AsRefusal() (v BetaResponseOutputRefusal) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseContentPartDoneEventPartUnion) AsReasoningText() (v BetaResponseContentPartDoneEventPartReasoningText) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseContentPartDoneEventPartUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseContentPartDoneEventPartUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Reasoning text from the model.
type BetaResponseContentPartDoneEventPartReasoningText struct {
	// The reasoning text from the model.
	Text string `json:"text" api:"required"`
	// The type of the reasoning text. Always `reasoning_text`.
	Type constant.ReasoningText `json:"type" default:"reasoning_text"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseContentPartDoneEventPartReasoningText) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseContentPartDoneEventPartReasoningText) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseContentPartDoneEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseContentPartDoneEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseContentPartDoneEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The conversation that this response belongs to.
//
// The property ID is required.
type BetaResponseConversationParam struct {
	// The unique ID of the conversation.
	ID string `json:"id" api:"required"`
	paramObj
}

func (r BetaResponseConversationParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseConversationParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseConversationParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// An event that is emitted when a response is created.
type BetaResponseCreatedEvent struct {
	// The response that was created.
	Response BetaResponse `json:"response" api:"required"`
	// The sequence number for this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.created`.
	Type constant.ResponseCreated `json:"type" default:"response.created"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseCreatedEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Response       respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCreatedEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCreatedEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseCreatedEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCreatedEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCreatedEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A call to a custom tool created by the model.
type BetaResponseCustomToolCall struct {
	// An identifier used to map this custom tool call to a tool call output.
	CallID string `json:"call_id" api:"required"`
	// The input for the custom tool call generated by the model.
	Input string `json:"input" api:"required"`
	// The name of the custom tool being called.
	Name string `json:"name" api:"required"`
	// The type of the custom tool call. Always `custom_tool_call`.
	Type constant.CustomToolCall `json:"type" default:"custom_tool_call"`
	// The unique ID of the custom tool call in the OpenAI platform.
	ID string `json:"id"`
	// The agent that produced this item.
	Agent BetaResponseCustomToolCallAgent `json:"agent" api:"nullable"`
	// The execution context that produced this tool call.
	Caller BetaResponseCustomToolCallCallerUnion `json:"caller" api:"nullable"`
	// The namespace of the custom tool being called.
	Namespace string `json:"namespace"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CallID      respjson.Field
		Input       respjson.Field
		Name        respjson.Field
		Type        respjson.Field
		ID          respjson.Field
		Agent       respjson.Field
		Caller      respjson.Field
		Namespace   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCustomToolCall) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCustomToolCall) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseCustomToolCall to a
// BetaResponseCustomToolCallParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseCustomToolCallParam.Overrides()
func (r BetaResponseCustomToolCall) ToParam() BetaResponseCustomToolCallParam {
	return param.Override[BetaResponseCustomToolCallParam](json.RawMessage(r.RawJSON()))
}

// The agent that produced this item.
type BetaResponseCustomToolCallAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCustomToolCallAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCustomToolCallAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseCustomToolCallCallerUnion contains all possible properties and
// values from [BetaResponseCustomToolCallCallerDirect],
// [BetaResponseCustomToolCallCallerProgram].
//
// Use the [BetaResponseCustomToolCallCallerUnion.AsAny] method to switch on the
// variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseCustomToolCallCallerUnion struct {
	// Any of "direct", "program".
	Type string `json:"type"`
	// This field is from variant [BetaResponseCustomToolCallCallerProgram].
	CallerID string `json:"caller_id"`
	JSON     struct {
		Type     respjson.Field
		CallerID respjson.Field
		raw      string
	} `json:"-"`
}

// anyBetaResponseCustomToolCallCaller is implemented by each variant of
// [BetaResponseCustomToolCallCallerUnion] to add type safety for the return type
// of [BetaResponseCustomToolCallCallerUnion.AsAny]
type anyBetaResponseCustomToolCallCaller interface {
	implBetaResponseCustomToolCallCallerUnion()
}

func (BetaResponseCustomToolCallCallerDirect) implBetaResponseCustomToolCallCallerUnion()  {}
func (BetaResponseCustomToolCallCallerProgram) implBetaResponseCustomToolCallCallerUnion() {}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseCustomToolCallCallerUnion.AsAny().(type) {
//	case openai.BetaResponseCustomToolCallCallerDirect:
//	case openai.BetaResponseCustomToolCallCallerProgram:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseCustomToolCallCallerUnion) AsAny() anyBetaResponseCustomToolCallCaller {
	switch u.Type {
	case "direct":
		return u.AsDirect()
	case "program":
		return u.AsProgram()
	}
	return nil
}

func (u BetaResponseCustomToolCallCallerUnion) AsDirect() (v BetaResponseCustomToolCallCallerDirect) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseCustomToolCallCallerUnion) AsProgram() (v BetaResponseCustomToolCallCallerProgram) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseCustomToolCallCallerUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseCustomToolCallCallerUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseCustomToolCallCallerDirect struct {
	Type constant.Direct `json:"type" default:"direct"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCustomToolCallCallerDirect) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCustomToolCallCallerDirect) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseCustomToolCallCallerProgram struct {
	// The call ID of the program item that produced this tool call.
	CallerID string           `json:"caller_id" api:"required"`
	Type     constant.Program `json:"type" default:"program"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CallerID    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCustomToolCallCallerProgram) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCustomToolCallCallerProgram) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A call to a custom tool created by the model.
//
// The properties CallID, Input, Name, Type are required.
type BetaResponseCustomToolCallParam struct {
	// An identifier used to map this custom tool call to a tool call output.
	CallID string `json:"call_id" api:"required"`
	// The input for the custom tool call generated by the model.
	Input string `json:"input" api:"required"`
	// The name of the custom tool being called.
	Name string `json:"name" api:"required"`
	// The unique ID of the custom tool call in the OpenAI platform.
	ID param.Opt[string] `json:"id,omitzero"`
	// The namespace of the custom tool being called.
	Namespace param.Opt[string] `json:"namespace,omitzero"`
	// The agent that produced this item.
	Agent BetaResponseCustomToolCallAgentParam `json:"agent,omitzero"`
	// The execution context that produced this tool call.
	Caller BetaResponseCustomToolCallCallerUnionParam `json:"caller,omitzero"`
	// The type of the custom tool call. Always `custom_tool_call`.
	//
	// This field can be elided, and will marshal its zero value as "custom_tool_call".
	Type constant.CustomToolCall `json:"type" default:"custom_tool_call"`
	paramObj
}

func (r BetaResponseCustomToolCallParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseCustomToolCallParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseCustomToolCallParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseCustomToolCallAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseCustomToolCallAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseCustomToolCallAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseCustomToolCallAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseCustomToolCallCallerUnionParam struct {
	OfDirect  *BetaResponseCustomToolCallCallerDirectParam  `json:",omitzero,inline"`
	OfProgram *BetaResponseCustomToolCallCallerProgramParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseCustomToolCallCallerUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfDirect, u.OfProgram)
}
func (u *BetaResponseCustomToolCallCallerUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseCustomToolCallCallerUnionParam) asAny() any {
	if !param.IsOmitted(u.OfDirect) {
		return u.OfDirect
	} else if !param.IsOmitted(u.OfProgram) {
		return u.OfProgram
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseCustomToolCallCallerUnionParam) GetCallerID() *string {
	if vt := u.OfProgram; vt != nil {
		return &vt.CallerID
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseCustomToolCallCallerUnionParam) GetType() *string {
	if vt := u.OfDirect; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfProgram; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaResponseCustomToolCallCallerUnionParam](
		"type",
		apijson.Discriminator[BetaResponseCustomToolCallCallerDirectParam]("direct"),
		apijson.Discriminator[BetaResponseCustomToolCallCallerProgramParam]("program"),
	)
}

func NewBetaResponseCustomToolCallCallerDirectParam() BetaResponseCustomToolCallCallerDirectParam {
	return BetaResponseCustomToolCallCallerDirectParam{
		Type: "direct",
	}
}

// This struct has a constant value, construct it with
// [NewBetaResponseCustomToolCallCallerDirectParam].
type BetaResponseCustomToolCallCallerDirectParam struct {
	Type constant.Direct `json:"type" default:"direct"`
	paramObj
}

func (r BetaResponseCustomToolCallCallerDirectParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseCustomToolCallCallerDirectParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseCustomToolCallCallerDirectParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The properties CallerID, Type are required.
type BetaResponseCustomToolCallCallerProgramParam struct {
	// The call ID of the program item that produced this tool call.
	CallerID string `json:"caller_id" api:"required"`
	// This field can be elided, and will marshal its zero value as "program".
	Type constant.Program `json:"type" default:"program"`
	paramObj
}

func (r BetaResponseCustomToolCallCallerProgramParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseCustomToolCallCallerProgramParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseCustomToolCallCallerProgramParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Event representing a delta (partial update) to the input of a custom tool call.
type BetaResponseCustomToolCallInputDeltaEvent struct {
	// The incremental input data (delta) for the custom tool call.
	Delta string `json:"delta" api:"required"`
	// Unique identifier for the API item associated with this event.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output this delta applies to.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The event type identifier.
	Type constant.ResponseCustomToolCallInputDelta `json:"type" default:"response.custom_tool_call_input.delta"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseCustomToolCallInputDeltaEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Delta          respjson.Field
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCustomToolCallInputDeltaEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCustomToolCallInputDeltaEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseCustomToolCallInputDeltaEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCustomToolCallInputDeltaEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCustomToolCallInputDeltaEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Event indicating that input for a custom tool call is complete.
type BetaResponseCustomToolCallInputDoneEvent struct {
	// The complete input data for the custom tool call.
	Input string `json:"input" api:"required"`
	// Unique identifier for the API item associated with this event.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output this event applies to.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The event type identifier.
	Type constant.ResponseCustomToolCallInputDone `json:"type" default:"response.custom_tool_call_input.done"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseCustomToolCallInputDoneEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Input          respjson.Field
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCustomToolCallInputDoneEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCustomToolCallInputDoneEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseCustomToolCallInputDoneEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCustomToolCallInputDoneEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCustomToolCallInputDoneEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A call to a custom tool created by the model.
type BetaResponseCustomToolCallItem struct {
	// The unique ID of the custom tool call item.
	ID string `json:"id" api:"required"`
	// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
	// Populated when items are returned via API.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status string `json:"status" api:"required"`
	// The identifier of the actor that created the item.
	CreatedBy string `json:"created_by"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Status      respjson.Field
		CreatedBy   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
	BetaResponseCustomToolCall
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCustomToolCallItem) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCustomToolCallItem) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The output of a custom tool call from your code, being sent back to the model.
type BetaResponseCustomToolCallOutput struct {
	// The call ID, used to map this custom tool call output to a custom tool call.
	CallID string `json:"call_id" api:"required"`
	// The output from the custom tool call generated by your code. Can be a string or
	// an list of output content.
	Output BetaResponseCustomToolCallOutputOutputUnion `json:"output" api:"required"`
	// The type of the custom tool call output. Always `custom_tool_call_output`.
	Type constant.CustomToolCallOutput `json:"type" default:"custom_tool_call_output"`
	// The unique ID of the custom tool call output in the OpenAI platform.
	ID string `json:"id"`
	// The agent that produced this item.
	Agent BetaResponseCustomToolCallOutputAgent `json:"agent" api:"nullable"`
	// The execution context that produced this tool call.
	Caller BetaResponseCustomToolCallOutputCallerUnion `json:"caller" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CallID      respjson.Field
		Output      respjson.Field
		Type        respjson.Field
		ID          respjson.Field
		Agent       respjson.Field
		Caller      respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCustomToolCallOutput) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCustomToolCallOutput) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseCustomToolCallOutput to a
// BetaResponseCustomToolCallOutputParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseCustomToolCallOutputParam.Overrides()
func (r BetaResponseCustomToolCallOutput) ToParam() BetaResponseCustomToolCallOutputParam {
	return param.Override[BetaResponseCustomToolCallOutputParam](json.RawMessage(r.RawJSON()))
}

// BetaResponseCustomToolCallOutputOutputUnion contains all possible properties and
// values from [string],
// [[]BetaResponseCustomToolCallOutputOutputOutputContentListItemUnion].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfString OfOutputContentList]
type BetaResponseCustomToolCallOutputOutputUnion struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a
	// [[]BetaResponseCustomToolCallOutputOutputOutputContentListItemUnion] instead of
	// an object.
	OfOutputContentList []BetaResponseCustomToolCallOutputOutputOutputContentListItemUnion `json:",inline"`
	JSON                struct {
		OfString            respjson.Field
		OfOutputContentList respjson.Field
		raw                 string
	} `json:"-"`
}

func (u BetaResponseCustomToolCallOutputOutputUnion) AsString() (v string) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseCustomToolCallOutputOutputUnion) AsOutputContentList() (v []BetaResponseCustomToolCallOutputOutputOutputContentListItemUnion) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseCustomToolCallOutputOutputUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseCustomToolCallOutputOutputUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseCustomToolCallOutputOutputOutputContentListItemUnion contains all
// possible properties and values from [BetaResponseInputText],
// [BetaResponseInputImage], [BetaResponseInputFile].
//
// Use the [BetaResponseCustomToolCallOutputOutputOutputContentListItemUnion.AsAny]
// method to switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseCustomToolCallOutputOutputOutputContentListItemUnion struct {
	// This field is from variant [BetaResponseInputText].
	Text string `json:"text"`
	// Any of "input_text", "input_image", "input_file".
	Type string `json:"type"`
	// This field is a union of [BetaResponseInputTextPromptCacheBreakpoint],
	// [BetaResponseInputImagePromptCacheBreakpoint],
	// [BetaResponseInputFilePromptCacheBreakpoint]
	PromptCacheBreakpoint BetaResponseCustomToolCallOutputOutputOutputContentListItemUnionPromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
	Detail                string                                                                                `json:"detail"`
	FileID                string                                                                                `json:"file_id"`
	// This field is from variant [BetaResponseInputImage].
	ImageURL string `json:"image_url"`
	// This field is from variant [BetaResponseInputFile].
	FileData string `json:"file_data"`
	// This field is from variant [BetaResponseInputFile].
	FileURL string `json:"file_url"`
	// This field is from variant [BetaResponseInputFile].
	Filename string `json:"filename"`
	JSON     struct {
		Text                  respjson.Field
		Type                  respjson.Field
		PromptCacheBreakpoint respjson.Field
		Detail                respjson.Field
		FileID                respjson.Field
		ImageURL              respjson.Field
		FileData              respjson.Field
		FileURL               respjson.Field
		Filename              respjson.Field
		raw                   string
	} `json:"-"`
}

// anyBetaResponseCustomToolCallOutputOutputOutputContentListItem is implemented by
// each variant of
// [BetaResponseCustomToolCallOutputOutputOutputContentListItemUnion] to add type
// safety for the return type of
// [BetaResponseCustomToolCallOutputOutputOutputContentListItemUnion.AsAny]
type anyBetaResponseCustomToolCallOutputOutputOutputContentListItem interface {
	implBetaResponseCustomToolCallOutputOutputOutputContentListItemUnion()
}

func (BetaResponseInputText) implBetaResponseCustomToolCallOutputOutputOutputContentListItemUnion() {}
func (BetaResponseInputImage) implBetaResponseCustomToolCallOutputOutputOutputContentListItemUnion() {
}
func (BetaResponseInputFile) implBetaResponseCustomToolCallOutputOutputOutputContentListItemUnion() {}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseCustomToolCallOutputOutputOutputContentListItemUnion.AsAny().(type) {
//	case openai.BetaResponseInputText:
//	case openai.BetaResponseInputImage:
//	case openai.BetaResponseInputFile:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseCustomToolCallOutputOutputOutputContentListItemUnion) AsAny() anyBetaResponseCustomToolCallOutputOutputOutputContentListItem {
	switch u.Type {
	case "input_text":
		return u.AsInputText()
	case "input_image":
		return u.AsInputImage()
	case "input_file":
		return u.AsInputFile()
	}
	return nil
}

func (u BetaResponseCustomToolCallOutputOutputOutputContentListItemUnion) AsInputText() (v BetaResponseInputText) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseCustomToolCallOutputOutputOutputContentListItemUnion) AsInputImage() (v BetaResponseInputImage) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseCustomToolCallOutputOutputOutputContentListItemUnion) AsInputFile() (v BetaResponseInputFile) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseCustomToolCallOutputOutputOutputContentListItemUnion) RawJSON() string {
	return u.JSON.raw
}

func (r *BetaResponseCustomToolCallOutputOutputOutputContentListItemUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseCustomToolCallOutputOutputOutputContentListItemUnionPromptCacheBreakpoint
// is an implicit subunion of
// [BetaResponseCustomToolCallOutputOutputOutputContentListItemUnion].
// BetaResponseCustomToolCallOutputOutputOutputContentListItemUnionPromptCacheBreakpoint
// provides convenient access to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseCustomToolCallOutputOutputOutputContentListItemUnion].
type BetaResponseCustomToolCallOutputOutputOutputContentListItemUnionPromptCacheBreakpoint struct {
	// This field is from variant [BetaResponseInputTextPromptCacheBreakpoint].
	Mode constant.Explicit `json:"mode"`
	JSON struct {
		Mode respjson.Field
		raw  string
	} `json:"-"`
}

func (r *BetaResponseCustomToolCallOutputOutputOutputContentListItemUnionPromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseCustomToolCallOutputAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCustomToolCallOutputAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCustomToolCallOutputAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseCustomToolCallOutputCallerUnion contains all possible properties and
// values from [BetaResponseCustomToolCallOutputCallerDirect],
// [BetaResponseCustomToolCallOutputCallerProgram].
//
// Use the [BetaResponseCustomToolCallOutputCallerUnion.AsAny] method to switch on
// the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseCustomToolCallOutputCallerUnion struct {
	// Any of "direct", "program".
	Type string `json:"type"`
	// This field is from variant [BetaResponseCustomToolCallOutputCallerProgram].
	CallerID string `json:"caller_id"`
	JSON     struct {
		Type     respjson.Field
		CallerID respjson.Field
		raw      string
	} `json:"-"`
}

// anyBetaResponseCustomToolCallOutputCaller is implemented by each variant of
// [BetaResponseCustomToolCallOutputCallerUnion] to add type safety for the return
// type of [BetaResponseCustomToolCallOutputCallerUnion.AsAny]
type anyBetaResponseCustomToolCallOutputCaller interface {
	implBetaResponseCustomToolCallOutputCallerUnion()
}

func (BetaResponseCustomToolCallOutputCallerDirect) implBetaResponseCustomToolCallOutputCallerUnion() {
}
func (BetaResponseCustomToolCallOutputCallerProgram) implBetaResponseCustomToolCallOutputCallerUnion() {
}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseCustomToolCallOutputCallerUnion.AsAny().(type) {
//	case openai.BetaResponseCustomToolCallOutputCallerDirect:
//	case openai.BetaResponseCustomToolCallOutputCallerProgram:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseCustomToolCallOutputCallerUnion) AsAny() anyBetaResponseCustomToolCallOutputCaller {
	switch u.Type {
	case "direct":
		return u.AsDirect()
	case "program":
		return u.AsProgram()
	}
	return nil
}

func (u BetaResponseCustomToolCallOutputCallerUnion) AsDirect() (v BetaResponseCustomToolCallOutputCallerDirect) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseCustomToolCallOutputCallerUnion) AsProgram() (v BetaResponseCustomToolCallOutputCallerProgram) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseCustomToolCallOutputCallerUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseCustomToolCallOutputCallerUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseCustomToolCallOutputCallerDirect struct {
	// The caller type. Always `direct`.
	Type constant.Direct `json:"type" default:"direct"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCustomToolCallOutputCallerDirect) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCustomToolCallOutputCallerDirect) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseCustomToolCallOutputCallerProgram struct {
	// The call ID of the program item that produced this tool call.
	CallerID string `json:"caller_id" api:"required"`
	// The caller type. Always `program`.
	Type constant.Program `json:"type" default:"program"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CallerID    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCustomToolCallOutputCallerProgram) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCustomToolCallOutputCallerProgram) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The output of a custom tool call from your code, being sent back to the model.
//
// The properties CallID, Output, Type are required.
type BetaResponseCustomToolCallOutputParam struct {
	// The call ID, used to map this custom tool call output to a custom tool call.
	CallID string `json:"call_id" api:"required"`
	// The output from the custom tool call generated by your code. Can be a string or
	// an list of output content.
	Output BetaResponseCustomToolCallOutputOutputUnionParam `json:"output,omitzero" api:"required"`
	// The unique ID of the custom tool call output in the OpenAI platform.
	ID param.Opt[string] `json:"id,omitzero"`
	// The agent that produced this item.
	Agent BetaResponseCustomToolCallOutputAgentParam `json:"agent,omitzero"`
	// The execution context that produced this tool call.
	Caller BetaResponseCustomToolCallOutputCallerUnionParam `json:"caller,omitzero"`
	// The type of the custom tool call output. Always `custom_tool_call_output`.
	//
	// This field can be elided, and will marshal its zero value as
	// "custom_tool_call_output".
	Type constant.CustomToolCallOutput `json:"type" default:"custom_tool_call_output"`
	paramObj
}

func (r BetaResponseCustomToolCallOutputParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseCustomToolCallOutputParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseCustomToolCallOutputParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseCustomToolCallOutputOutputUnionParam struct {
	OfString            param.Opt[string]                                                       `json:",omitzero,inline"`
	OfOutputContentList []BetaResponseCustomToolCallOutputOutputOutputContentListItemUnionParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseCustomToolCallOutputOutputUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfString, u.OfOutputContentList)
}
func (u *BetaResponseCustomToolCallOutputOutputUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseCustomToolCallOutputOutputUnionParam) asAny() any {
	if !param.IsOmitted(u.OfString) {
		return &u.OfString.Value
	} else if !param.IsOmitted(u.OfOutputContentList) {
		return &u.OfOutputContentList
	}
	return nil
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseCustomToolCallOutputOutputOutputContentListItemUnionParam struct {
	OfInputText  *BetaResponseInputTextParam  `json:",omitzero,inline"`
	OfInputImage *BetaResponseInputImageParam `json:",omitzero,inline"`
	OfInputFile  *BetaResponseInputFileParam  `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseCustomToolCallOutputOutputOutputContentListItemUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfInputText, u.OfInputImage, u.OfInputFile)
}
func (u *BetaResponseCustomToolCallOutputOutputOutputContentListItemUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseCustomToolCallOutputOutputOutputContentListItemUnionParam) asAny() any {
	if !param.IsOmitted(u.OfInputText) {
		return u.OfInputText
	} else if !param.IsOmitted(u.OfInputImage) {
		return u.OfInputImage
	} else if !param.IsOmitted(u.OfInputFile) {
		return u.OfInputFile
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseCustomToolCallOutputOutputOutputContentListItemUnionParam) GetText() *string {
	if vt := u.OfInputText; vt != nil {
		return &vt.Text
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseCustomToolCallOutputOutputOutputContentListItemUnionParam) GetImageURL() *string {
	if vt := u.OfInputImage; vt != nil && vt.ImageURL.Valid() {
		return &vt.ImageURL.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseCustomToolCallOutputOutputOutputContentListItemUnionParam) GetFileData() *string {
	if vt := u.OfInputFile; vt != nil && vt.FileData.Valid() {
		return &vt.FileData.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseCustomToolCallOutputOutputOutputContentListItemUnionParam) GetFileURL() *string {
	if vt := u.OfInputFile; vt != nil && vt.FileURL.Valid() {
		return &vt.FileURL.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseCustomToolCallOutputOutputOutputContentListItemUnionParam) GetFilename() *string {
	if vt := u.OfInputFile; vt != nil && vt.Filename.Valid() {
		return &vt.Filename.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseCustomToolCallOutputOutputOutputContentListItemUnionParam) GetType() *string {
	if vt := u.OfInputText; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfInputImage; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfInputFile; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseCustomToolCallOutputOutputOutputContentListItemUnionParam) GetDetail() *string {
	if vt := u.OfInputImage; vt != nil {
		return (*string)(&vt.Detail)
	} else if vt := u.OfInputFile; vt != nil {
		return (*string)(&vt.Detail)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseCustomToolCallOutputOutputOutputContentListItemUnionParam) GetFileID() *string {
	if vt := u.OfInputImage; vt != nil && vt.FileID.Valid() {
		return &vt.FileID.Value
	} else if vt := u.OfInputFile; vt != nil && vt.FileID.Valid() {
		return &vt.FileID.Value
	}
	return nil
}

// Returns a subunion which exports methods to access subproperties
//
// Or use AsAny() to get the underlying value
func (u BetaResponseCustomToolCallOutputOutputOutputContentListItemUnionParam) GetPromptCacheBreakpoint() (res betaResponseCustomToolCallOutputOutputOutputContentListItemUnionParamPromptCacheBreakpoint) {
	if vt := u.OfInputText; vt != nil {
		res.any = &vt.PromptCacheBreakpoint
	} else if vt := u.OfInputImage; vt != nil {
		res.any = &vt.PromptCacheBreakpoint
	} else if vt := u.OfInputFile; vt != nil {
		res.any = &vt.PromptCacheBreakpoint
	}
	return
}

// Can have the runtime types [*BetaResponseInputTextPromptCacheBreakpointParam],
// [*BetaResponseInputImagePromptCacheBreakpointParam],
// [*BetaResponseInputFilePromptCacheBreakpointParam]
type betaResponseCustomToolCallOutputOutputOutputContentListItemUnionParamPromptCacheBreakpoint struct{ any }

// Use the following switch statement to get the type of the union:
//
//	switch u.AsAny().(type) {
//	case *openai.BetaResponseInputTextPromptCacheBreakpointParam:
//	case *openai.BetaResponseInputImagePromptCacheBreakpointParam:
//	case *openai.BetaResponseInputFilePromptCacheBreakpointParam:
//	default:
//	    fmt.Errorf("not present")
//	}
func (u betaResponseCustomToolCallOutputOutputOutputContentListItemUnionParamPromptCacheBreakpoint) AsAny() any {
	return u.any
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseCustomToolCallOutputOutputOutputContentListItemUnionParamPromptCacheBreakpoint) GetMode() *string {
	switch vt := u.any.(type) {
	case *BetaResponseInputTextPromptCacheBreakpointParam:
		return (*string)(&vt.Mode)
	case *BetaResponseInputImagePromptCacheBreakpointParam:
		return (*string)(&vt.Mode)
	case *BetaResponseInputFilePromptCacheBreakpointParam:
		return (*string)(&vt.Mode)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaResponseCustomToolCallOutputOutputOutputContentListItemUnionParam](
		"type",
		apijson.Discriminator[BetaResponseInputTextParam]("input_text"),
		apijson.Discriminator[BetaResponseInputImageParam]("input_image"),
		apijson.Discriminator[BetaResponseInputFileParam]("input_file"),
	)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseCustomToolCallOutputAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseCustomToolCallOutputAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseCustomToolCallOutputAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseCustomToolCallOutputAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseCustomToolCallOutputCallerUnionParam struct {
	OfDirect  *BetaResponseCustomToolCallOutputCallerDirectParam  `json:",omitzero,inline"`
	OfProgram *BetaResponseCustomToolCallOutputCallerProgramParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseCustomToolCallOutputCallerUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfDirect, u.OfProgram)
}
func (u *BetaResponseCustomToolCallOutputCallerUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseCustomToolCallOutputCallerUnionParam) asAny() any {
	if !param.IsOmitted(u.OfDirect) {
		return u.OfDirect
	} else if !param.IsOmitted(u.OfProgram) {
		return u.OfProgram
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseCustomToolCallOutputCallerUnionParam) GetCallerID() *string {
	if vt := u.OfProgram; vt != nil {
		return &vt.CallerID
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseCustomToolCallOutputCallerUnionParam) GetType() *string {
	if vt := u.OfDirect; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfProgram; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaResponseCustomToolCallOutputCallerUnionParam](
		"type",
		apijson.Discriminator[BetaResponseCustomToolCallOutputCallerDirectParam]("direct"),
		apijson.Discriminator[BetaResponseCustomToolCallOutputCallerProgramParam]("program"),
	)
}

func NewBetaResponseCustomToolCallOutputCallerDirectParam() BetaResponseCustomToolCallOutputCallerDirectParam {
	return BetaResponseCustomToolCallOutputCallerDirectParam{
		Type: "direct",
	}
}

// This struct has a constant value, construct it with
// [NewBetaResponseCustomToolCallOutputCallerDirectParam].
type BetaResponseCustomToolCallOutputCallerDirectParam struct {
	// The caller type. Always `direct`.
	Type constant.Direct `json:"type" default:"direct"`
	paramObj
}

func (r BetaResponseCustomToolCallOutputCallerDirectParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseCustomToolCallOutputCallerDirectParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseCustomToolCallOutputCallerDirectParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The properties CallerID, Type are required.
type BetaResponseCustomToolCallOutputCallerProgramParam struct {
	// The call ID of the program item that produced this tool call.
	CallerID string `json:"caller_id" api:"required"`
	// The caller type. Always `program`.
	//
	// This field can be elided, and will marshal its zero value as "program".
	Type constant.Program `json:"type" default:"program"`
	paramObj
}

func (r BetaResponseCustomToolCallOutputCallerProgramParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseCustomToolCallOutputCallerProgramParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseCustomToolCallOutputCallerProgramParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The output of a custom tool call from your code, being sent back to the model.
type BetaResponseCustomToolCallOutputItem struct {
	// The unique ID of the custom tool call output item.
	ID string `json:"id" api:"required"`
	// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
	// Populated when items are returned via API.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status string `json:"status" api:"required"`
	// The identifier of the actor that created the item.
	CreatedBy string `json:"created_by"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Status      respjson.Field
		CreatedBy   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
	BetaResponseCustomToolCallOutput
}

// Returns the unmodified JSON received from the API
func (r BetaResponseCustomToolCallOutputItem) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseCustomToolCallOutputItem) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// An error object returned when the model fails to generate a Response.
type BetaResponseError struct {
	// The error code for the response.
	//
	// Any of "server_error", "rate_limit_exceeded", "invalid_prompt",
	// "data_residency_mismatch", "bio_policy", "vector_store_timeout",
	// "invalid_image", "invalid_image_format", "invalid_base64_image",
	// "invalid_image_url", "image_too_large", "image_too_small", "image_parse_error",
	// "image_content_policy_violation", "invalid_image_mode", "image_file_too_large",
	// "unsupported_image_media_type", "empty_image_file", "failed_to_download_image",
	// "image_file_not_found".
	Code BetaResponseErrorCode `json:"code" api:"required"`
	// A human-readable description of the error.
	Message string `json:"message" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Code        respjson.Field
		Message     respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseError) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseError) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The error code for the response.
type BetaResponseErrorCode string

const (
	BetaResponseErrorCodeServerError                 BetaResponseErrorCode = "server_error"
	BetaResponseErrorCodeRateLimitExceeded           BetaResponseErrorCode = "rate_limit_exceeded"
	BetaResponseErrorCodeInvalidPrompt               BetaResponseErrorCode = "invalid_prompt"
	BetaResponseErrorCodeDataResidencyMismatch       BetaResponseErrorCode = "data_residency_mismatch"
	BetaResponseErrorCodeBioPolicy                   BetaResponseErrorCode = "bio_policy"
	BetaResponseErrorCodeVectorStoreTimeout          BetaResponseErrorCode = "vector_store_timeout"
	BetaResponseErrorCodeInvalidImage                BetaResponseErrorCode = "invalid_image"
	BetaResponseErrorCodeInvalidImageFormat          BetaResponseErrorCode = "invalid_image_format"
	BetaResponseErrorCodeInvalidBase64Image          BetaResponseErrorCode = "invalid_base64_image"
	BetaResponseErrorCodeInvalidImageURL             BetaResponseErrorCode = "invalid_image_url"
	BetaResponseErrorCodeImageTooLarge               BetaResponseErrorCode = "image_too_large"
	BetaResponseErrorCodeImageTooSmall               BetaResponseErrorCode = "image_too_small"
	BetaResponseErrorCodeImageParseError             BetaResponseErrorCode = "image_parse_error"
	BetaResponseErrorCodeImageContentPolicyViolation BetaResponseErrorCode = "image_content_policy_violation"
	BetaResponseErrorCodeInvalidImageMode            BetaResponseErrorCode = "invalid_image_mode"
	BetaResponseErrorCodeImageFileTooLarge           BetaResponseErrorCode = "image_file_too_large"
	BetaResponseErrorCodeUnsupportedImageMediaType   BetaResponseErrorCode = "unsupported_image_media_type"
	BetaResponseErrorCodeEmptyImageFile              BetaResponseErrorCode = "empty_image_file"
	BetaResponseErrorCodeFailedToDownloadImage       BetaResponseErrorCode = "failed_to_download_image"
	BetaResponseErrorCodeImageFileNotFound           BetaResponseErrorCode = "image_file_not_found"
)

// Emitted when an error occurs.
type BetaResponseErrorEvent struct {
	// The error code.
	Code string `json:"code" api:"required"`
	// The error message.
	Message string `json:"message" api:"required"`
	// The error parameter.
	Param string `json:"param" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `error`.
	Type constant.Error `json:"type" default:"error"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseErrorEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Code           respjson.Field
		Message        respjson.Field
		Param          respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseErrorEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseErrorEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseErrorEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseErrorEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseErrorEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// An event that is emitted when a response fails.
type BetaResponseFailedEvent struct {
	// The response that failed.
	Response BetaResponse `json:"response" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.failed`.
	Type constant.ResponseFailed `json:"type" default:"response.failed"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseFailedEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Response       respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFailedEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFailedEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseFailedEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFailedEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFailedEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when a file search call is completed (results found).
type BetaResponseFileSearchCallCompletedEvent struct {
	// The ID of the output item that the file search call is initiated.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item that the file search call is initiated.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.file_search_call.completed`.
	Type constant.ResponseFileSearchCallCompleted `json:"type" default:"response.file_search_call.completed"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseFileSearchCallCompletedEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFileSearchCallCompletedEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFileSearchCallCompletedEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseFileSearchCallCompletedEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFileSearchCallCompletedEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFileSearchCallCompletedEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when a file search call is initiated.
type BetaResponseFileSearchCallInProgressEvent struct {
	// The ID of the output item that the file search call is initiated.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item that the file search call is initiated.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.file_search_call.in_progress`.
	Type constant.ResponseFileSearchCallInProgress `json:"type" default:"response.file_search_call.in_progress"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseFileSearchCallInProgressEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFileSearchCallInProgressEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFileSearchCallInProgressEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseFileSearchCallInProgressEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFileSearchCallInProgressEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFileSearchCallInProgressEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when a file search is currently searching.
type BetaResponseFileSearchCallSearchingEvent struct {
	// The ID of the output item that the file search call is initiated.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item that the file search call is searching.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.file_search_call.searching`.
	Type constant.ResponseFileSearchCallSearching `json:"type" default:"response.file_search_call.searching"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseFileSearchCallSearchingEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFileSearchCallSearchingEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFileSearchCallSearchingEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseFileSearchCallSearchingEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFileSearchCallSearchingEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFileSearchCallSearchingEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The results of a file search tool call. See the
// [file search guide](https://platform.openai.com/docs/guides/tools-file-search)
// for more information.
type BetaResponseFileSearchToolCall struct {
	// The unique ID of the file search tool call.
	ID string `json:"id" api:"required"`
	// The queries used to search for files.
	Queries []string `json:"queries" api:"required"`
	// The status of the file search tool call. One of `in_progress`, `searching`,
	// `incomplete` or `failed`,
	//
	// Any of "in_progress", "searching", "completed", "incomplete", "failed".
	Status BetaResponseFileSearchToolCallStatus `json:"status" api:"required"`
	// The type of the file search tool call. Always `file_search_call`.
	Type constant.FileSearchCall `json:"type" default:"file_search_call"`
	// The agent that produced this item.
	Agent BetaResponseFileSearchToolCallAgent `json:"agent" api:"nullable"`
	// The results of the file search tool call.
	Results []BetaResponseFileSearchToolCallResult `json:"results" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Queries     respjson.Field
		Status      respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		Results     respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFileSearchToolCall) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFileSearchToolCall) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseFileSearchToolCall to a
// BetaResponseFileSearchToolCallParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseFileSearchToolCallParam.Overrides()
func (r BetaResponseFileSearchToolCall) ToParam() BetaResponseFileSearchToolCallParam {
	return param.Override[BetaResponseFileSearchToolCallParam](json.RawMessage(r.RawJSON()))
}

// The status of the file search tool call. One of `in_progress`, `searching`,
// `incomplete` or `failed`,
type BetaResponseFileSearchToolCallStatus string

const (
	BetaResponseFileSearchToolCallStatusInProgress BetaResponseFileSearchToolCallStatus = "in_progress"
	BetaResponseFileSearchToolCallStatusSearching  BetaResponseFileSearchToolCallStatus = "searching"
	BetaResponseFileSearchToolCallStatusCompleted  BetaResponseFileSearchToolCallStatus = "completed"
	BetaResponseFileSearchToolCallStatusIncomplete BetaResponseFileSearchToolCallStatus = "incomplete"
	BetaResponseFileSearchToolCallStatusFailed     BetaResponseFileSearchToolCallStatus = "failed"
)

// The agent that produced this item.
type BetaResponseFileSearchToolCallAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFileSearchToolCallAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFileSearchToolCallAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseFileSearchToolCallResult struct {
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard. Keys are strings with a maximum
	// length of 64 characters. Values are strings with a maximum length of 512
	// characters, booleans, or numbers.
	Attributes map[string]BetaResponseFileSearchToolCallResultAttributeUnion `json:"attributes" api:"nullable"`
	// The unique ID of the file.
	FileID string `json:"file_id"`
	// The name of the file.
	Filename string `json:"filename"`
	// The relevance score of the file - a value between 0 and 1.
	Score float64 `json:"score"`
	// The text that was retrieved from the file.
	Text string `json:"text"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Attributes  respjson.Field
		FileID      respjson.Field
		Filename    respjson.Field
		Score       respjson.Field
		Text        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFileSearchToolCallResult) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFileSearchToolCallResult) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseFileSearchToolCallResultAttributeUnion contains all possible
// properties and values from [string], [float64], [bool].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfString OfFloat OfBool]
type BetaResponseFileSearchToolCallResultAttributeUnion struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a [float64] instead of an object.
	OfFloat float64 `json:",inline"`
	// This field will be present if the value is a [bool] instead of an object.
	OfBool bool `json:",inline"`
	JSON   struct {
		OfString respjson.Field
		OfFloat  respjson.Field
		OfBool   respjson.Field
		raw      string
	} `json:"-"`
}

func (u BetaResponseFileSearchToolCallResultAttributeUnion) AsString() (v string) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseFileSearchToolCallResultAttributeUnion) AsFloat() (v float64) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseFileSearchToolCallResultAttributeUnion) AsBool() (v bool) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseFileSearchToolCallResultAttributeUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseFileSearchToolCallResultAttributeUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The results of a file search tool call. See the
// [file search guide](https://platform.openai.com/docs/guides/tools-file-search)
// for more information.
//
// The properties ID, Queries, Status, Type are required.
type BetaResponseFileSearchToolCallParam struct {
	// The unique ID of the file search tool call.
	ID string `json:"id" api:"required"`
	// The queries used to search for files.
	Queries []string `json:"queries,omitzero" api:"required"`
	// The status of the file search tool call. One of `in_progress`, `searching`,
	// `incomplete` or `failed`,
	//
	// Any of "in_progress", "searching", "completed", "incomplete", "failed".
	Status BetaResponseFileSearchToolCallStatus `json:"status,omitzero" api:"required"`
	// The agent that produced this item.
	Agent BetaResponseFileSearchToolCallAgentParam `json:"agent,omitzero"`
	// The results of the file search tool call.
	Results []BetaResponseFileSearchToolCallResultParam `json:"results,omitzero"`
	// The type of the file search tool call. Always `file_search_call`.
	//
	// This field can be elided, and will marshal its zero value as "file_search_call".
	Type constant.FileSearchCall `json:"type" default:"file_search_call"`
	paramObj
}

func (r BetaResponseFileSearchToolCallParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseFileSearchToolCallParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseFileSearchToolCallParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseFileSearchToolCallAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseFileSearchToolCallAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseFileSearchToolCallAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseFileSearchToolCallAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseFileSearchToolCallResultParam struct {
	// The unique ID of the file.
	FileID param.Opt[string] `json:"file_id,omitzero"`
	// The name of the file.
	Filename param.Opt[string] `json:"filename,omitzero"`
	// The relevance score of the file - a value between 0 and 1.
	Score param.Opt[float64] `json:"score,omitzero"`
	// The text that was retrieved from the file.
	Text param.Opt[string] `json:"text,omitzero"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard. Keys are strings with a maximum
	// length of 64 characters. Values are strings with a maximum length of 512
	// characters, booleans, or numbers.
	Attributes map[string]BetaResponseFileSearchToolCallResultAttributeUnionParam `json:"attributes,omitzero"`
	paramObj
}

func (r BetaResponseFileSearchToolCallResultParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseFileSearchToolCallResultParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseFileSearchToolCallResultParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseFileSearchToolCallResultAttributeUnionParam struct {
	OfString param.Opt[string]  `json:",omitzero,inline"`
	OfFloat  param.Opt[float64] `json:",omitzero,inline"`
	OfBool   param.Opt[bool]    `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseFileSearchToolCallResultAttributeUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfString, u.OfFloat, u.OfBool)
}
func (u *BetaResponseFileSearchToolCallResultAttributeUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseFileSearchToolCallResultAttributeUnionParam) asAny() any {
	if !param.IsOmitted(u.OfString) {
		return &u.OfString.Value
	} else if !param.IsOmitted(u.OfFloat) {
		return &u.OfFloat.Value
	} else if !param.IsOmitted(u.OfBool) {
		return &u.OfBool.Value
	}
	return nil
}

// BetaResponseFormatTextConfigUnion contains all possible properties and values
// from [BetaResponseFormatTextConfigText],
// [BetaResponseFormatTextJSONSchemaConfig],
// [BetaResponseFormatTextConfigJSONObject].
//
// Use the [BetaResponseFormatTextConfigUnion.AsAny] method to switch on the
// variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseFormatTextConfigUnion struct {
	// Any of "text", "json_schema", "json_object".
	Type string `json:"type"`
	// This field is from variant [BetaResponseFormatTextJSONSchemaConfig].
	Name string `json:"name"`
	// This field is from variant [BetaResponseFormatTextJSONSchemaConfig].
	Schema map[string]any `json:"schema"`
	// This field is from variant [BetaResponseFormatTextJSONSchemaConfig].
	Description string `json:"description"`
	// This field is from variant [BetaResponseFormatTextJSONSchemaConfig].
	Strict bool `json:"strict"`
	JSON   struct {
		Type        respjson.Field
		Name        respjson.Field
		Schema      respjson.Field
		Description respjson.Field
		Strict      respjson.Field
		raw         string
	} `json:"-"`
}

// anyBetaResponseFormatTextConfig is implemented by each variant of
// [BetaResponseFormatTextConfigUnion] to add type safety for the return type of
// [BetaResponseFormatTextConfigUnion.AsAny]
type anyBetaResponseFormatTextConfig interface {
	implBetaResponseFormatTextConfigUnion()
}

func (BetaResponseFormatTextConfigText) implBetaResponseFormatTextConfigUnion()       {}
func (BetaResponseFormatTextJSONSchemaConfig) implBetaResponseFormatTextConfigUnion() {}
func (BetaResponseFormatTextConfigJSONObject) implBetaResponseFormatTextConfigUnion() {}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseFormatTextConfigUnion.AsAny().(type) {
//	case openai.BetaResponseFormatTextConfigText:
//	case openai.BetaResponseFormatTextJSONSchemaConfig:
//	case openai.BetaResponseFormatTextConfigJSONObject:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseFormatTextConfigUnion) AsAny() anyBetaResponseFormatTextConfig {
	switch u.Type {
	case "text":
		return u.AsText()
	case "json_schema":
		return u.AsJSONSchema()
	case "json_object":
		return u.AsJSONObject()
	}
	return nil
}

func (u BetaResponseFormatTextConfigUnion) AsText() (v BetaResponseFormatTextConfigText) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseFormatTextConfigUnion) AsJSONSchema() (v BetaResponseFormatTextJSONSchemaConfig) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseFormatTextConfigUnion) AsJSONObject() (v BetaResponseFormatTextConfigJSONObject) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseFormatTextConfigUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseFormatTextConfigUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseFormatTextConfigUnion to a
// BetaResponseFormatTextConfigUnionParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseFormatTextConfigUnionParam.Overrides()
func (r BetaResponseFormatTextConfigUnion) ToParam() BetaResponseFormatTextConfigUnionParam {
	return param.Override[BetaResponseFormatTextConfigUnionParam](json.RawMessage(r.RawJSON()))
}

// Default response format. Used to generate text responses.
type BetaResponseFormatTextConfigText struct {
	// The type of response format being defined. Always `text`.
	Type constant.Text `json:"type" default:"text"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFormatTextConfigText) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFormatTextConfigText) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// JSON object response format. An older method of generating JSON responses. Using
// `json_schema` is recommended for models that support it. Note that the model
// will not generate JSON without a system or user message instructing it to do so.
type BetaResponseFormatTextConfigJSONObject struct {
	// The type of response format being defined. Always `json_object`.
	Type constant.JSONObject `json:"type" default:"json_object"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFormatTextConfigJSONObject) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFormatTextConfigJSONObject) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func BetaResponseFormatTextConfigParamOfJSONSchema(name string, schema map[string]any) BetaResponseFormatTextConfigUnionParam {
	var jsonSchema BetaResponseFormatTextJSONSchemaConfigParam
	jsonSchema.Name = name
	jsonSchema.Schema = schema
	return BetaResponseFormatTextConfigUnionParam{OfJSONSchema: &jsonSchema}
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseFormatTextConfigUnionParam struct {
	OfText       *BetaResponseFormatTextConfigTextParam       `json:",omitzero,inline"`
	OfJSONSchema *BetaResponseFormatTextJSONSchemaConfigParam `json:",omitzero,inline"`
	OfJSONObject *BetaResponseFormatTextConfigJSONObjectParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseFormatTextConfigUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfText, u.OfJSONSchema, u.OfJSONObject)
}
func (u *BetaResponseFormatTextConfigUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseFormatTextConfigUnionParam) asAny() any {
	if !param.IsOmitted(u.OfText) {
		return u.OfText
	} else if !param.IsOmitted(u.OfJSONSchema) {
		return u.OfJSONSchema
	} else if !param.IsOmitted(u.OfJSONObject) {
		return u.OfJSONObject
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseFormatTextConfigUnionParam) GetName() *string {
	if vt := u.OfJSONSchema; vt != nil {
		return &vt.Name
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseFormatTextConfigUnionParam) GetSchema() map[string]any {
	if vt := u.OfJSONSchema; vt != nil {
		return vt.Schema
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseFormatTextConfigUnionParam) GetDescription() *string {
	if vt := u.OfJSONSchema; vt != nil && vt.Description.Valid() {
		return &vt.Description.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseFormatTextConfigUnionParam) GetStrict() *bool {
	if vt := u.OfJSONSchema; vt != nil && vt.Strict.Valid() {
		return &vt.Strict.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseFormatTextConfigUnionParam) GetType() *string {
	if vt := u.OfText; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfJSONSchema; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfJSONObject; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaResponseFormatTextConfigUnionParam](
		"type",
		apijson.Discriminator[BetaResponseFormatTextConfigTextParam]("text"),
		apijson.Discriminator[BetaResponseFormatTextJSONSchemaConfigParam]("json_schema"),
		apijson.Discriminator[BetaResponseFormatTextConfigJSONObjectParam]("json_object"),
	)
}

func NewBetaResponseFormatTextConfigTextParam() BetaResponseFormatTextConfigTextParam {
	return BetaResponseFormatTextConfigTextParam{
		Type: "text",
	}
}

// Default response format. Used to generate text responses.
//
// This struct has a constant value, construct it with
// [NewBetaResponseFormatTextConfigTextParam].
type BetaResponseFormatTextConfigTextParam struct {
	// The type of response format being defined. Always `text`.
	Type constant.Text `json:"type" default:"text"`
	paramObj
}

func (r BetaResponseFormatTextConfigTextParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseFormatTextConfigTextParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseFormatTextConfigTextParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func NewBetaResponseFormatTextConfigJSONObjectParam() BetaResponseFormatTextConfigJSONObjectParam {
	return BetaResponseFormatTextConfigJSONObjectParam{
		Type: "json_object",
	}
}

// JSON object response format. An older method of generating JSON responses. Using
// `json_schema` is recommended for models that support it. Note that the model
// will not generate JSON without a system or user message instructing it to do so.
//
// This struct has a constant value, construct it with
// [NewBetaResponseFormatTextConfigJSONObjectParam].
type BetaResponseFormatTextConfigJSONObjectParam struct {
	// The type of response format being defined. Always `json_object`.
	Type constant.JSONObject `json:"type" default:"json_object"`
	paramObj
}

func (r BetaResponseFormatTextConfigJSONObjectParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseFormatTextConfigJSONObjectParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseFormatTextConfigJSONObjectParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// JSON Schema response format. Used to generate structured JSON responses. Learn
// more about
// [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).
type BetaResponseFormatTextJSONSchemaConfig struct {
	// The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores
	// and dashes, with a maximum length of 64.
	Name string `json:"name" api:"required"`
	// The schema for the response format, described as a JSON Schema object. Learn how
	// to build JSON schemas [here](https://json-schema.org/).
	Schema map[string]any `json:"schema" api:"required"`
	// The type of response format being defined. Always `json_schema`.
	Type constant.JSONSchema `json:"type" default:"json_schema"`
	// A description of what the response format is for, used by the model to determine
	// how to respond in the format.
	Description string `json:"description"`
	// Whether to enable strict schema adherence when generating the output. If set to
	// true, the model will always follow the exact schema defined in the `schema`
	// field. Only a subset of JSON Schema is supported when `strict` is `true`. To
	// learn more, read the
	// [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
	Strict bool `json:"strict" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Name        respjson.Field
		Schema      respjson.Field
		Type        respjson.Field
		Description respjson.Field
		Strict      respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFormatTextJSONSchemaConfig) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFormatTextJSONSchemaConfig) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseFormatTextJSONSchemaConfig to a
// BetaResponseFormatTextJSONSchemaConfigParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseFormatTextJSONSchemaConfigParam.Overrides()
func (r BetaResponseFormatTextJSONSchemaConfig) ToParam() BetaResponseFormatTextJSONSchemaConfigParam {
	return param.Override[BetaResponseFormatTextJSONSchemaConfigParam](json.RawMessage(r.RawJSON()))
}

// JSON Schema response format. Used to generate structured JSON responses. Learn
// more about
// [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).
//
// The properties Name, Schema, Type are required.
type BetaResponseFormatTextJSONSchemaConfigParam struct {
	// The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores
	// and dashes, with a maximum length of 64.
	Name string `json:"name" api:"required"`
	// The schema for the response format, described as a JSON Schema object. Learn how
	// to build JSON schemas [here](https://json-schema.org/).
	Schema map[string]any `json:"schema,omitzero" api:"required"`
	// Whether to enable strict schema adherence when generating the output. If set to
	// true, the model will always follow the exact schema defined in the `schema`
	// field. Only a subset of JSON Schema is supported when `strict` is `true`. To
	// learn more, read the
	// [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// A description of what the response format is for, used by the model to determine
	// how to respond in the format.
	Description param.Opt[string] `json:"description,omitzero"`
	// The type of response format being defined. Always `json_schema`.
	//
	// This field can be elided, and will marshal its zero value as "json_schema".
	Type constant.JSONSchema `json:"type" default:"json_schema"`
	paramObj
}

func (r BetaResponseFormatTextJSONSchemaConfigParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseFormatTextJSONSchemaConfigParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseFormatTextJSONSchemaConfigParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when there is a partial function-call arguments delta.
type BetaResponseFunctionCallArgumentsDeltaEvent struct {
	// The function-call arguments delta that is added.
	Delta string `json:"delta" api:"required"`
	// The ID of the output item that the function-call arguments delta is added to.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item that the function-call arguments delta is added to.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.function_call_arguments.delta`.
	Type constant.ResponseFunctionCallArgumentsDelta `json:"type" default:"response.function_call_arguments.delta"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseFunctionCallArgumentsDeltaEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Delta          respjson.Field
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionCallArgumentsDeltaEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionCallArgumentsDeltaEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseFunctionCallArgumentsDeltaEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionCallArgumentsDeltaEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionCallArgumentsDeltaEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when function-call arguments are finalized.
type BetaResponseFunctionCallArgumentsDoneEvent struct {
	// The function-call arguments.
	Arguments string `json:"arguments" api:"required"`
	// The ID of the item.
	ItemID string `json:"item_id" api:"required"`
	// The name of the function that was called.
	Name string `json:"name" api:"required"`
	// The index of the output item.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64                                      `json:"sequence_number" api:"required"`
	Type           constant.ResponseFunctionCallArgumentsDone `json:"type" default:"response.function_call_arguments.done"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseFunctionCallArgumentsDoneEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Arguments      respjson.Field
		ItemID         respjson.Field
		Name           respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionCallArgumentsDoneEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionCallArgumentsDoneEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseFunctionCallArgumentsDoneEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionCallArgumentsDoneEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionCallArgumentsDoneEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseFunctionCallOutputItemUnion contains all possible properties and
// values from [BetaResponseInputTextContent], [BetaResponseInputImageContent],
// [BetaResponseInputFileContent].
//
// Use the [BetaResponseFunctionCallOutputItemUnion.AsAny] method to switch on the
// variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseFunctionCallOutputItemUnion struct {
	// This field is from variant [BetaResponseInputTextContent].
	Text string `json:"text"`
	// Any of "input_text", "input_image", "input_file".
	Type string `json:"type"`
	// This field is a union of [BetaResponseInputTextContentPromptCacheBreakpoint],
	// [BetaResponseInputImageContentPromptCacheBreakpoint],
	// [BetaResponseInputFileContentPromptCacheBreakpoint]
	PromptCacheBreakpoint BetaResponseFunctionCallOutputItemUnionPromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
	Detail                string                                                       `json:"detail"`
	FileID                string                                                       `json:"file_id"`
	// This field is from variant [BetaResponseInputImageContent].
	ImageURL string `json:"image_url"`
	// This field is from variant [BetaResponseInputFileContent].
	FileData string `json:"file_data"`
	// This field is from variant [BetaResponseInputFileContent].
	FileURL string `json:"file_url"`
	// This field is from variant [BetaResponseInputFileContent].
	Filename string `json:"filename"`
	JSON     struct {
		Text                  respjson.Field
		Type                  respjson.Field
		PromptCacheBreakpoint respjson.Field
		Detail                respjson.Field
		FileID                respjson.Field
		ImageURL              respjson.Field
		FileData              respjson.Field
		FileURL               respjson.Field
		Filename              respjson.Field
		raw                   string
	} `json:"-"`
}

// anyBetaResponseFunctionCallOutputItem is implemented by each variant of
// [BetaResponseFunctionCallOutputItemUnion] to add type safety for the return type
// of [BetaResponseFunctionCallOutputItemUnion.AsAny]
type anyBetaResponseFunctionCallOutputItem interface {
	implBetaResponseFunctionCallOutputItemUnion()
}

func (BetaResponseInputTextContent) implBetaResponseFunctionCallOutputItemUnion()  {}
func (BetaResponseInputImageContent) implBetaResponseFunctionCallOutputItemUnion() {}
func (BetaResponseInputFileContent) implBetaResponseFunctionCallOutputItemUnion()  {}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseFunctionCallOutputItemUnion.AsAny().(type) {
//	case openai.BetaResponseInputTextContent:
//	case openai.BetaResponseInputImageContent:
//	case openai.BetaResponseInputFileContent:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseFunctionCallOutputItemUnion) AsAny() anyBetaResponseFunctionCallOutputItem {
	switch u.Type {
	case "input_text":
		return u.AsInputText()
	case "input_image":
		return u.AsInputImage()
	case "input_file":
		return u.AsInputFile()
	}
	return nil
}

func (u BetaResponseFunctionCallOutputItemUnion) AsInputText() (v BetaResponseInputTextContent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseFunctionCallOutputItemUnion) AsInputImage() (v BetaResponseInputImageContent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseFunctionCallOutputItemUnion) AsInputFile() (v BetaResponseInputFileContent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseFunctionCallOutputItemUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseFunctionCallOutputItemUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseFunctionCallOutputItemUnionPromptCacheBreakpoint is an implicit
// subunion of [BetaResponseFunctionCallOutputItemUnion].
// BetaResponseFunctionCallOutputItemUnionPromptCacheBreakpoint provides convenient
// access to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseFunctionCallOutputItemUnion].
type BetaResponseFunctionCallOutputItemUnionPromptCacheBreakpoint struct {
	// This field is from variant [BetaResponseInputTextContentPromptCacheBreakpoint].
	Mode constant.Explicit `json:"mode"`
	JSON struct {
		Mode respjson.Field
		raw  string
	} `json:"-"`
}

func (r *BetaResponseFunctionCallOutputItemUnionPromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseFunctionCallOutputItemUnion to a
// BetaResponseFunctionCallOutputItemUnionParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseFunctionCallOutputItemUnionParam.Overrides()
func (r BetaResponseFunctionCallOutputItemUnion) ToParam() BetaResponseFunctionCallOutputItemUnionParam {
	return param.Override[BetaResponseFunctionCallOutputItemUnionParam](json.RawMessage(r.RawJSON()))
}

func BetaResponseFunctionCallOutputItemParamOfInputText(text string) BetaResponseFunctionCallOutputItemUnionParam {
	var inputText BetaResponseInputTextContentParam
	inputText.Text = text
	return BetaResponseFunctionCallOutputItemUnionParam{OfInputText: &inputText}
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseFunctionCallOutputItemUnionParam struct {
	OfInputText  *BetaResponseInputTextContentParam  `json:",omitzero,inline"`
	OfInputImage *BetaResponseInputImageContentParam `json:",omitzero,inline"`
	OfInputFile  *BetaResponseInputFileContentParam  `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseFunctionCallOutputItemUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfInputText, u.OfInputImage, u.OfInputFile)
}
func (u *BetaResponseFunctionCallOutputItemUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseFunctionCallOutputItemUnionParam) asAny() any {
	if !param.IsOmitted(u.OfInputText) {
		return u.OfInputText
	} else if !param.IsOmitted(u.OfInputImage) {
		return u.OfInputImage
	} else if !param.IsOmitted(u.OfInputFile) {
		return u.OfInputFile
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseFunctionCallOutputItemUnionParam) GetText() *string {
	if vt := u.OfInputText; vt != nil {
		return &vt.Text
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseFunctionCallOutputItemUnionParam) GetImageURL() *string {
	if vt := u.OfInputImage; vt != nil && vt.ImageURL.Valid() {
		return &vt.ImageURL.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseFunctionCallOutputItemUnionParam) GetFileData() *string {
	if vt := u.OfInputFile; vt != nil && vt.FileData.Valid() {
		return &vt.FileData.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseFunctionCallOutputItemUnionParam) GetFileURL() *string {
	if vt := u.OfInputFile; vt != nil && vt.FileURL.Valid() {
		return &vt.FileURL.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseFunctionCallOutputItemUnionParam) GetFilename() *string {
	if vt := u.OfInputFile; vt != nil && vt.Filename.Valid() {
		return &vt.Filename.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseFunctionCallOutputItemUnionParam) GetType() *string {
	if vt := u.OfInputText; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfInputImage; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfInputFile; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseFunctionCallOutputItemUnionParam) GetDetail() *string {
	if vt := u.OfInputImage; vt != nil {
		return (*string)(&vt.Detail)
	} else if vt := u.OfInputFile; vt != nil {
		return (*string)(&vt.Detail)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseFunctionCallOutputItemUnionParam) GetFileID() *string {
	if vt := u.OfInputImage; vt != nil && vt.FileID.Valid() {
		return &vt.FileID.Value
	} else if vt := u.OfInputFile; vt != nil && vt.FileID.Valid() {
		return &vt.FileID.Value
	}
	return nil
}

// Returns a subunion which exports methods to access subproperties
//
// Or use AsAny() to get the underlying value
func (u BetaResponseFunctionCallOutputItemUnionParam) GetPromptCacheBreakpoint() (res betaResponseFunctionCallOutputItemUnionParamPromptCacheBreakpoint) {
	if vt := u.OfInputText; vt != nil {
		res.any = &vt.PromptCacheBreakpoint
	} else if vt := u.OfInputImage; vt != nil {
		res.any = &vt.PromptCacheBreakpoint
	} else if vt := u.OfInputFile; vt != nil {
		res.any = &vt.PromptCacheBreakpoint
	}
	return
}

// Can have the runtime types
// [*BetaResponseInputTextContentPromptCacheBreakpointParam],
// [*BetaResponseInputImageContentPromptCacheBreakpointParam],
// [*BetaResponseInputFileContentPromptCacheBreakpointParam]
type betaResponseFunctionCallOutputItemUnionParamPromptCacheBreakpoint struct{ any }

// Use the following switch statement to get the type of the union:
//
//	switch u.AsAny().(type) {
//	case *openai.BetaResponseInputTextContentPromptCacheBreakpointParam:
//	case *openai.BetaResponseInputImageContentPromptCacheBreakpointParam:
//	case *openai.BetaResponseInputFileContentPromptCacheBreakpointParam:
//	default:
//	    fmt.Errorf("not present")
//	}
func (u betaResponseFunctionCallOutputItemUnionParamPromptCacheBreakpoint) AsAny() any { return u.any }

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseFunctionCallOutputItemUnionParamPromptCacheBreakpoint) GetMode() *string {
	switch vt := u.any.(type) {
	case *BetaResponseInputTextContentPromptCacheBreakpointParam:
		return (*string)(&vt.Mode)
	case *BetaResponseInputImageContentPromptCacheBreakpointParam:
		return (*string)(&vt.Mode)
	case *BetaResponseInputFileContentPromptCacheBreakpointParam:
		return (*string)(&vt.Mode)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaResponseFunctionCallOutputItemUnionParam](
		"type",
		apijson.Discriminator[BetaResponseInputTextContentParam]("input_text"),
		apijson.Discriminator[BetaResponseInputImageContentParam]("input_image"),
		apijson.Discriminator[BetaResponseInputFileContentParam]("input_file"),
	)
}

type BetaResponseFunctionCallOutputItemList []BetaResponseFunctionCallOutputItemUnion

type BetaResponseFunctionCallOutputItemListParam []BetaResponseFunctionCallOutputItemUnionParam

// Captured stdout and stderr for a portion of a shell tool call output.
type BetaResponseFunctionShellCallOutputContent struct {
	// The exit or timeout outcome associated with this shell call.
	Outcome BetaResponseFunctionShellCallOutputContentOutcomeUnion `json:"outcome" api:"required"`
	// Captured stderr output for the shell call.
	Stderr string `json:"stderr" api:"required"`
	// Captured stdout output for the shell call.
	Stdout string `json:"stdout" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Outcome     respjson.Field
		Stderr      respjson.Field
		Stdout      respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionShellCallOutputContent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionShellCallOutputContent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseFunctionShellCallOutputContent to a
// BetaResponseFunctionShellCallOutputContentParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseFunctionShellCallOutputContentParam.Overrides()
func (r BetaResponseFunctionShellCallOutputContent) ToParam() BetaResponseFunctionShellCallOutputContentParam {
	return param.Override[BetaResponseFunctionShellCallOutputContentParam](json.RawMessage(r.RawJSON()))
}

// BetaResponseFunctionShellCallOutputContentOutcomeUnion contains all possible
// properties and values from
// [BetaResponseFunctionShellCallOutputContentOutcomeTimeout],
// [BetaResponseFunctionShellCallOutputContentOutcomeExit].
//
// Use the [BetaResponseFunctionShellCallOutputContentOutcomeUnion.AsAny] method to
// switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseFunctionShellCallOutputContentOutcomeUnion struct {
	// Any of "timeout", "exit".
	Type string `json:"type"`
	// This field is from variant
	// [BetaResponseFunctionShellCallOutputContentOutcomeExit].
	ExitCode int64 `json:"exit_code"`
	JSON     struct {
		Type     respjson.Field
		ExitCode respjson.Field
		raw      string
	} `json:"-"`
}

// anyBetaResponseFunctionShellCallOutputContentOutcome is implemented by each
// variant of [BetaResponseFunctionShellCallOutputContentOutcomeUnion] to add type
// safety for the return type of
// [BetaResponseFunctionShellCallOutputContentOutcomeUnion.AsAny]
type anyBetaResponseFunctionShellCallOutputContentOutcome interface {
	implBetaResponseFunctionShellCallOutputContentOutcomeUnion()
}

func (BetaResponseFunctionShellCallOutputContentOutcomeTimeout) implBetaResponseFunctionShellCallOutputContentOutcomeUnion() {
}
func (BetaResponseFunctionShellCallOutputContentOutcomeExit) implBetaResponseFunctionShellCallOutputContentOutcomeUnion() {
}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseFunctionShellCallOutputContentOutcomeUnion.AsAny().(type) {
//	case openai.BetaResponseFunctionShellCallOutputContentOutcomeTimeout:
//	case openai.BetaResponseFunctionShellCallOutputContentOutcomeExit:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseFunctionShellCallOutputContentOutcomeUnion) AsAny() anyBetaResponseFunctionShellCallOutputContentOutcome {
	switch u.Type {
	case "timeout":
		return u.AsTimeout()
	case "exit":
		return u.AsExit()
	}
	return nil
}

func (u BetaResponseFunctionShellCallOutputContentOutcomeUnion) AsTimeout() (v BetaResponseFunctionShellCallOutputContentOutcomeTimeout) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseFunctionShellCallOutputContentOutcomeUnion) AsExit() (v BetaResponseFunctionShellCallOutputContentOutcomeExit) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseFunctionShellCallOutputContentOutcomeUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseFunctionShellCallOutputContentOutcomeUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Indicates that the shell call exceeded its configured time limit.
type BetaResponseFunctionShellCallOutputContentOutcomeTimeout struct {
	// The outcome type. Always `timeout`.
	Type constant.Timeout `json:"type" default:"timeout"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionShellCallOutputContentOutcomeTimeout) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionShellCallOutputContentOutcomeTimeout) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Indicates that the shell commands finished and returned an exit code.
type BetaResponseFunctionShellCallOutputContentOutcomeExit struct {
	// The exit code returned by the shell process.
	ExitCode int64 `json:"exit_code" api:"required"`
	// The outcome type. Always `exit`.
	Type constant.Exit `json:"type" default:"exit"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ExitCode    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionShellCallOutputContentOutcomeExit) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionShellCallOutputContentOutcomeExit) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Captured stdout and stderr for a portion of a shell tool call output.
//
// The properties Outcome, Stderr, Stdout are required.
type BetaResponseFunctionShellCallOutputContentParam struct {
	// The exit or timeout outcome associated with this shell call.
	Outcome BetaResponseFunctionShellCallOutputContentOutcomeUnionParam `json:"outcome,omitzero" api:"required"`
	// Captured stderr output for the shell call.
	Stderr string `json:"stderr" api:"required"`
	// Captured stdout output for the shell call.
	Stdout string `json:"stdout" api:"required"`
	paramObj
}

func (r BetaResponseFunctionShellCallOutputContentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseFunctionShellCallOutputContentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseFunctionShellCallOutputContentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseFunctionShellCallOutputContentOutcomeUnionParam struct {
	OfTimeout *BetaResponseFunctionShellCallOutputContentOutcomeTimeoutParam `json:",omitzero,inline"`
	OfExit    *BetaResponseFunctionShellCallOutputContentOutcomeExitParam    `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseFunctionShellCallOutputContentOutcomeUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfTimeout, u.OfExit)
}
func (u *BetaResponseFunctionShellCallOutputContentOutcomeUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseFunctionShellCallOutputContentOutcomeUnionParam) asAny() any {
	if !param.IsOmitted(u.OfTimeout) {
		return u.OfTimeout
	} else if !param.IsOmitted(u.OfExit) {
		return u.OfExit
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseFunctionShellCallOutputContentOutcomeUnionParam) GetExitCode() *int64 {
	if vt := u.OfExit; vt != nil {
		return &vt.ExitCode
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseFunctionShellCallOutputContentOutcomeUnionParam) GetType() *string {
	if vt := u.OfTimeout; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfExit; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaResponseFunctionShellCallOutputContentOutcomeUnionParam](
		"type",
		apijson.Discriminator[BetaResponseFunctionShellCallOutputContentOutcomeTimeoutParam]("timeout"),
		apijson.Discriminator[BetaResponseFunctionShellCallOutputContentOutcomeExitParam]("exit"),
	)
}

func NewBetaResponseFunctionShellCallOutputContentOutcomeTimeoutParam() BetaResponseFunctionShellCallOutputContentOutcomeTimeoutParam {
	return BetaResponseFunctionShellCallOutputContentOutcomeTimeoutParam{
		Type: "timeout",
	}
}

// Indicates that the shell call exceeded its configured time limit.
//
// This struct has a constant value, construct it with
// [NewBetaResponseFunctionShellCallOutputContentOutcomeTimeoutParam].
type BetaResponseFunctionShellCallOutputContentOutcomeTimeoutParam struct {
	// The outcome type. Always `timeout`.
	Type constant.Timeout `json:"type" default:"timeout"`
	paramObj
}

func (r BetaResponseFunctionShellCallOutputContentOutcomeTimeoutParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseFunctionShellCallOutputContentOutcomeTimeoutParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseFunctionShellCallOutputContentOutcomeTimeoutParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Indicates that the shell commands finished and returned an exit code.
//
// The properties ExitCode, Type are required.
type BetaResponseFunctionShellCallOutputContentOutcomeExitParam struct {
	// The exit code returned by the shell process.
	ExitCode int64 `json:"exit_code" api:"required"`
	// The outcome type. Always `exit`.
	//
	// This field can be elided, and will marshal its zero value as "exit".
	Type constant.Exit `json:"type" default:"exit"`
	paramObj
}

func (r BetaResponseFunctionShellCallOutputContentOutcomeExitParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseFunctionShellCallOutputContentOutcomeExitParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseFunctionShellCallOutputContentOutcomeExitParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool call that executes one or more shell commands in a managed environment.
type BetaResponseFunctionShellToolCall struct {
	// The unique ID of the shell tool call. Populated when this item is returned via
	// API.
	ID string `json:"id" api:"required"`
	// The shell commands and limits that describe how to run the tool call.
	Action BetaResponseFunctionShellToolCallAction `json:"action" api:"required"`
	// The unique ID of the shell tool call generated by the model.
	CallID string `json:"call_id" api:"required"`
	// Represents the use of a local environment to perform shell actions.
	Environment BetaResponseFunctionShellToolCallEnvironmentUnion `json:"environment" api:"required"`
	// The status of the shell call. One of `in_progress`, `completed`, or
	// `incomplete`.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status BetaResponseFunctionShellToolCallStatus `json:"status" api:"required"`
	// The type of the item. Always `shell_call`.
	Type constant.ShellCall `json:"type" default:"shell_call"`
	// The agent that produced this item.
	Agent BetaResponseFunctionShellToolCallAgent `json:"agent"`
	// The execution context that produced this tool call.
	Caller BetaResponseFunctionShellToolCallCallerUnion `json:"caller" api:"nullable"`
	// The ID of the entity that created this tool call.
	CreatedBy string `json:"created_by"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Action      respjson.Field
		CallID      respjson.Field
		Environment respjson.Field
		Status      respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		Caller      respjson.Field
		CreatedBy   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionShellToolCall) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionShellToolCall) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The shell commands and limits that describe how to run the tool call.
type BetaResponseFunctionShellToolCallAction struct {
	Commands []string `json:"commands" api:"required"`
	// Optional maximum number of characters to return from each command.
	MaxOutputLength int64 `json:"max_output_length" api:"required"`
	// Optional timeout in milliseconds for the commands.
	TimeoutMs int64 `json:"timeout_ms" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Commands        respjson.Field
		MaxOutputLength respjson.Field
		TimeoutMs       respjson.Field
		ExtraFields     map[string]respjson.Field
		raw             string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionShellToolCallAction) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionShellToolCallAction) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseFunctionShellToolCallEnvironmentUnion contains all possible
// properties and values from [BetaResponseLocalEnvironment],
// [BetaResponseContainerReference].
//
// Use the [BetaResponseFunctionShellToolCallEnvironmentUnion.AsAny] method to
// switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseFunctionShellToolCallEnvironmentUnion struct {
	// Any of "local", "container_reference".
	Type string `json:"type"`
	// This field is from variant [BetaResponseContainerReference].
	ContainerID string `json:"container_id"`
	JSON        struct {
		Type        respjson.Field
		ContainerID respjson.Field
		raw         string
	} `json:"-"`
}

// anyBetaResponseFunctionShellToolCallEnvironment is implemented by each variant
// of [BetaResponseFunctionShellToolCallEnvironmentUnion] to add type safety for
// the return type of [BetaResponseFunctionShellToolCallEnvironmentUnion.AsAny]
type anyBetaResponseFunctionShellToolCallEnvironment interface {
	implBetaResponseFunctionShellToolCallEnvironmentUnion()
}

func (BetaResponseLocalEnvironment) implBetaResponseFunctionShellToolCallEnvironmentUnion()   {}
func (BetaResponseContainerReference) implBetaResponseFunctionShellToolCallEnvironmentUnion() {}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseFunctionShellToolCallEnvironmentUnion.AsAny().(type) {
//	case openai.BetaResponseLocalEnvironment:
//	case openai.BetaResponseContainerReference:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseFunctionShellToolCallEnvironmentUnion) AsAny() anyBetaResponseFunctionShellToolCallEnvironment {
	switch u.Type {
	case "local":
		return u.AsLocal()
	case "container_reference":
		return u.AsContainerReference()
	}
	return nil
}

func (u BetaResponseFunctionShellToolCallEnvironmentUnion) AsLocal() (v BetaResponseLocalEnvironment) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseFunctionShellToolCallEnvironmentUnion) AsContainerReference() (v BetaResponseContainerReference) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseFunctionShellToolCallEnvironmentUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseFunctionShellToolCallEnvironmentUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The status of the shell call. One of `in_progress`, `completed`, or
// `incomplete`.
type BetaResponseFunctionShellToolCallStatus string

const (
	BetaResponseFunctionShellToolCallStatusInProgress BetaResponseFunctionShellToolCallStatus = "in_progress"
	BetaResponseFunctionShellToolCallStatusCompleted  BetaResponseFunctionShellToolCallStatus = "completed"
	BetaResponseFunctionShellToolCallStatusIncomplete BetaResponseFunctionShellToolCallStatus = "incomplete"
)

// The agent that produced this item.
type BetaResponseFunctionShellToolCallAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionShellToolCallAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionShellToolCallAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseFunctionShellToolCallCallerUnion contains all possible properties
// and values from [BetaResponseFunctionShellToolCallCallerDirect],
// [BetaResponseFunctionShellToolCallCallerProgram].
//
// Use the [BetaResponseFunctionShellToolCallCallerUnion.AsAny] method to switch on
// the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseFunctionShellToolCallCallerUnion struct {
	// Any of "direct", "program".
	Type string `json:"type"`
	// This field is from variant [BetaResponseFunctionShellToolCallCallerProgram].
	CallerID string `json:"caller_id"`
	JSON     struct {
		Type     respjson.Field
		CallerID respjson.Field
		raw      string
	} `json:"-"`
}

// anyBetaResponseFunctionShellToolCallCaller is implemented by each variant of
// [BetaResponseFunctionShellToolCallCallerUnion] to add type safety for the return
// type of [BetaResponseFunctionShellToolCallCallerUnion.AsAny]
type anyBetaResponseFunctionShellToolCallCaller interface {
	implBetaResponseFunctionShellToolCallCallerUnion()
}

func (BetaResponseFunctionShellToolCallCallerDirect) implBetaResponseFunctionShellToolCallCallerUnion() {
}
func (BetaResponseFunctionShellToolCallCallerProgram) implBetaResponseFunctionShellToolCallCallerUnion() {
}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseFunctionShellToolCallCallerUnion.AsAny().(type) {
//	case openai.BetaResponseFunctionShellToolCallCallerDirect:
//	case openai.BetaResponseFunctionShellToolCallCallerProgram:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseFunctionShellToolCallCallerUnion) AsAny() anyBetaResponseFunctionShellToolCallCaller {
	switch u.Type {
	case "direct":
		return u.AsDirect()
	case "program":
		return u.AsProgram()
	}
	return nil
}

func (u BetaResponseFunctionShellToolCallCallerUnion) AsDirect() (v BetaResponseFunctionShellToolCallCallerDirect) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseFunctionShellToolCallCallerUnion) AsProgram() (v BetaResponseFunctionShellToolCallCallerProgram) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseFunctionShellToolCallCallerUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseFunctionShellToolCallCallerUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseFunctionShellToolCallCallerDirect struct {
	Type constant.Direct `json:"type" default:"direct"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionShellToolCallCallerDirect) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionShellToolCallCallerDirect) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseFunctionShellToolCallCallerProgram struct {
	// The call ID of the program item that produced this tool call.
	CallerID string           `json:"caller_id" api:"required"`
	Type     constant.Program `json:"type" default:"program"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CallerID    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionShellToolCallCallerProgram) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionShellToolCallCallerProgram) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The output of a shell tool call that was emitted.
type BetaResponseFunctionShellToolCallOutput struct {
	// The unique ID of the shell call output. Populated when this item is returned via
	// API.
	ID string `json:"id" api:"required"`
	// The unique ID of the shell tool call generated by the model.
	CallID string `json:"call_id" api:"required"`
	// The maximum length of the shell command output. This is generated by the model
	// and should be passed back with the raw output.
	MaxOutputLength int64 `json:"max_output_length" api:"required"`
	// An array of shell call output contents
	Output []BetaResponseFunctionShellToolCallOutputOutput `json:"output" api:"required"`
	// The status of the shell call output. One of `in_progress`, `completed`, or
	// `incomplete`.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status BetaResponseFunctionShellToolCallOutputStatus `json:"status" api:"required"`
	// The type of the shell call output. Always `shell_call_output`.
	Type constant.ShellCallOutput `json:"type" default:"shell_call_output"`
	// The agent that produced this item.
	Agent BetaResponseFunctionShellToolCallOutputAgent `json:"agent"`
	// The execution context that produced this tool call.
	Caller BetaResponseFunctionShellToolCallOutputCallerUnion `json:"caller" api:"nullable"`
	// The identifier of the actor that created the item.
	CreatedBy string `json:"created_by"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID              respjson.Field
		CallID          respjson.Field
		MaxOutputLength respjson.Field
		Output          respjson.Field
		Status          respjson.Field
		Type            respjson.Field
		Agent           respjson.Field
		Caller          respjson.Field
		CreatedBy       respjson.Field
		ExtraFields     map[string]respjson.Field
		raw             string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionShellToolCallOutput) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionShellToolCallOutput) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The content of a shell tool call output that was emitted.
type BetaResponseFunctionShellToolCallOutputOutput struct {
	// Represents either an exit outcome (with an exit code) or a timeout outcome for a
	// shell call output chunk.
	Outcome BetaResponseFunctionShellToolCallOutputOutputOutcomeUnion `json:"outcome" api:"required"`
	// The standard error output that was captured.
	Stderr string `json:"stderr" api:"required"`
	// The standard output that was captured.
	Stdout string `json:"stdout" api:"required"`
	// The identifier of the actor that created the item.
	CreatedBy string `json:"created_by"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Outcome     respjson.Field
		Stderr      respjson.Field
		Stdout      respjson.Field
		CreatedBy   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionShellToolCallOutputOutput) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionShellToolCallOutputOutput) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseFunctionShellToolCallOutputOutputOutcomeUnion contains all possible
// properties and values from
// [BetaResponseFunctionShellToolCallOutputOutputOutcomeTimeout],
// [BetaResponseFunctionShellToolCallOutputOutputOutcomeExit].
//
// Use the [BetaResponseFunctionShellToolCallOutputOutputOutcomeUnion.AsAny] method
// to switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseFunctionShellToolCallOutputOutputOutcomeUnion struct {
	// Any of "timeout", "exit".
	Type string `json:"type"`
	// This field is from variant
	// [BetaResponseFunctionShellToolCallOutputOutputOutcomeExit].
	ExitCode int64 `json:"exit_code"`
	JSON     struct {
		Type     respjson.Field
		ExitCode respjson.Field
		raw      string
	} `json:"-"`
}

// anyBetaResponseFunctionShellToolCallOutputOutputOutcome is implemented by each
// variant of [BetaResponseFunctionShellToolCallOutputOutputOutcomeUnion] to add
// type safety for the return type of
// [BetaResponseFunctionShellToolCallOutputOutputOutcomeUnion.AsAny]
type anyBetaResponseFunctionShellToolCallOutputOutputOutcome interface {
	implBetaResponseFunctionShellToolCallOutputOutputOutcomeUnion()
}

func (BetaResponseFunctionShellToolCallOutputOutputOutcomeTimeout) implBetaResponseFunctionShellToolCallOutputOutputOutcomeUnion() {
}
func (BetaResponseFunctionShellToolCallOutputOutputOutcomeExit) implBetaResponseFunctionShellToolCallOutputOutputOutcomeUnion() {
}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseFunctionShellToolCallOutputOutputOutcomeUnion.AsAny().(type) {
//	case openai.BetaResponseFunctionShellToolCallOutputOutputOutcomeTimeout:
//	case openai.BetaResponseFunctionShellToolCallOutputOutputOutcomeExit:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseFunctionShellToolCallOutputOutputOutcomeUnion) AsAny() anyBetaResponseFunctionShellToolCallOutputOutputOutcome {
	switch u.Type {
	case "timeout":
		return u.AsTimeout()
	case "exit":
		return u.AsExit()
	}
	return nil
}

func (u BetaResponseFunctionShellToolCallOutputOutputOutcomeUnion) AsTimeout() (v BetaResponseFunctionShellToolCallOutputOutputOutcomeTimeout) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseFunctionShellToolCallOutputOutputOutcomeUnion) AsExit() (v BetaResponseFunctionShellToolCallOutputOutputOutcomeExit) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseFunctionShellToolCallOutputOutputOutcomeUnion) RawJSON() string {
	return u.JSON.raw
}

func (r *BetaResponseFunctionShellToolCallOutputOutputOutcomeUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Indicates that the shell call exceeded its configured time limit.
type BetaResponseFunctionShellToolCallOutputOutputOutcomeTimeout struct {
	// The outcome type. Always `timeout`.
	Type constant.Timeout `json:"type" default:"timeout"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionShellToolCallOutputOutputOutcomeTimeout) RawJSON() string {
	return r.JSON.raw
}
func (r *BetaResponseFunctionShellToolCallOutputOutputOutcomeTimeout) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Indicates that the shell commands finished and returned an exit code.
type BetaResponseFunctionShellToolCallOutputOutputOutcomeExit struct {
	// Exit code from the shell process.
	ExitCode int64 `json:"exit_code" api:"required"`
	// The outcome type. Always `exit`.
	Type constant.Exit `json:"type" default:"exit"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ExitCode    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionShellToolCallOutputOutputOutcomeExit) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionShellToolCallOutputOutputOutcomeExit) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The status of the shell call output. One of `in_progress`, `completed`, or
// `incomplete`.
type BetaResponseFunctionShellToolCallOutputStatus string

const (
	BetaResponseFunctionShellToolCallOutputStatusInProgress BetaResponseFunctionShellToolCallOutputStatus = "in_progress"
	BetaResponseFunctionShellToolCallOutputStatusCompleted  BetaResponseFunctionShellToolCallOutputStatus = "completed"
	BetaResponseFunctionShellToolCallOutputStatusIncomplete BetaResponseFunctionShellToolCallOutputStatus = "incomplete"
)

// The agent that produced this item.
type BetaResponseFunctionShellToolCallOutputAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionShellToolCallOutputAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionShellToolCallOutputAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseFunctionShellToolCallOutputCallerUnion contains all possible
// properties and values from
// [BetaResponseFunctionShellToolCallOutputCallerDirect],
// [BetaResponseFunctionShellToolCallOutputCallerProgram].
//
// Use the [BetaResponseFunctionShellToolCallOutputCallerUnion.AsAny] method to
// switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseFunctionShellToolCallOutputCallerUnion struct {
	// Any of "direct", "program".
	Type string `json:"type"`
	// This field is from variant
	// [BetaResponseFunctionShellToolCallOutputCallerProgram].
	CallerID string `json:"caller_id"`
	JSON     struct {
		Type     respjson.Field
		CallerID respjson.Field
		raw      string
	} `json:"-"`
}

// anyBetaResponseFunctionShellToolCallOutputCaller is implemented by each variant
// of [BetaResponseFunctionShellToolCallOutputCallerUnion] to add type safety for
// the return type of [BetaResponseFunctionShellToolCallOutputCallerUnion.AsAny]
type anyBetaResponseFunctionShellToolCallOutputCaller interface {
	implBetaResponseFunctionShellToolCallOutputCallerUnion()
}

func (BetaResponseFunctionShellToolCallOutputCallerDirect) implBetaResponseFunctionShellToolCallOutputCallerUnion() {
}
func (BetaResponseFunctionShellToolCallOutputCallerProgram) implBetaResponseFunctionShellToolCallOutputCallerUnion() {
}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseFunctionShellToolCallOutputCallerUnion.AsAny().(type) {
//	case openai.BetaResponseFunctionShellToolCallOutputCallerDirect:
//	case openai.BetaResponseFunctionShellToolCallOutputCallerProgram:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseFunctionShellToolCallOutputCallerUnion) AsAny() anyBetaResponseFunctionShellToolCallOutputCaller {
	switch u.Type {
	case "direct":
		return u.AsDirect()
	case "program":
		return u.AsProgram()
	}
	return nil
}

func (u BetaResponseFunctionShellToolCallOutputCallerUnion) AsDirect() (v BetaResponseFunctionShellToolCallOutputCallerDirect) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseFunctionShellToolCallOutputCallerUnion) AsProgram() (v BetaResponseFunctionShellToolCallOutputCallerProgram) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseFunctionShellToolCallOutputCallerUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseFunctionShellToolCallOutputCallerUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseFunctionShellToolCallOutputCallerDirect struct {
	Type constant.Direct `json:"type" default:"direct"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionShellToolCallOutputCallerDirect) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionShellToolCallOutputCallerDirect) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseFunctionShellToolCallOutputCallerProgram struct {
	// The call ID of the program item that produced this tool call.
	CallerID string           `json:"caller_id" api:"required"`
	Type     constant.Program `json:"type" default:"program"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CallerID    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionShellToolCallOutputCallerProgram) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionShellToolCallOutputCallerProgram) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool call to run a function. See the
// [function calling guide](https://platform.openai.com/docs/guides/function-calling)
// for more information.
type BetaResponseFunctionToolCall struct {
	// A JSON string of the arguments to pass to the function.
	Arguments string `json:"arguments" api:"required"`
	// The unique ID of the function tool call generated by the model.
	CallID string `json:"call_id" api:"required"`
	// The name of the function to run.
	Name string `json:"name" api:"required"`
	// The type of the function tool call. Always `function_call`.
	Type constant.FunctionCall `json:"type" default:"function_call"`
	// The unique ID of the function tool call.
	ID string `json:"id"`
	// The agent that produced this item.
	Agent BetaResponseFunctionToolCallAgent `json:"agent" api:"nullable"`
	// The execution context that produced this tool call.
	Caller BetaResponseFunctionToolCallCallerUnion `json:"caller" api:"nullable"`
	// The namespace of the function to run.
	Namespace string `json:"namespace"`
	// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
	// Populated when items are returned via API.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status BetaResponseFunctionToolCallStatus `json:"status"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Arguments   respjson.Field
		CallID      respjson.Field
		Name        respjson.Field
		Type        respjson.Field
		ID          respjson.Field
		Agent       respjson.Field
		Caller      respjson.Field
		Namespace   respjson.Field
		Status      respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionToolCall) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionToolCall) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseFunctionToolCall to a
// BetaResponseFunctionToolCallParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseFunctionToolCallParam.Overrides()
func (r BetaResponseFunctionToolCall) ToParam() BetaResponseFunctionToolCallParam {
	return param.Override[BetaResponseFunctionToolCallParam](json.RawMessage(r.RawJSON()))
}

// The agent that produced this item.
type BetaResponseFunctionToolCallAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionToolCallAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionToolCallAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseFunctionToolCallCallerUnion contains all possible properties and
// values from [BetaResponseFunctionToolCallCallerDirect],
// [BetaResponseFunctionToolCallCallerProgram].
//
// Use the [BetaResponseFunctionToolCallCallerUnion.AsAny] method to switch on the
// variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseFunctionToolCallCallerUnion struct {
	// Any of "direct", "program".
	Type string `json:"type"`
	// This field is from variant [BetaResponseFunctionToolCallCallerProgram].
	CallerID string `json:"caller_id"`
	JSON     struct {
		Type     respjson.Field
		CallerID respjson.Field
		raw      string
	} `json:"-"`
}

// anyBetaResponseFunctionToolCallCaller is implemented by each variant of
// [BetaResponseFunctionToolCallCallerUnion] to add type safety for the return type
// of [BetaResponseFunctionToolCallCallerUnion.AsAny]
type anyBetaResponseFunctionToolCallCaller interface {
	implBetaResponseFunctionToolCallCallerUnion()
}

func (BetaResponseFunctionToolCallCallerDirect) implBetaResponseFunctionToolCallCallerUnion()  {}
func (BetaResponseFunctionToolCallCallerProgram) implBetaResponseFunctionToolCallCallerUnion() {}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseFunctionToolCallCallerUnion.AsAny().(type) {
//	case openai.BetaResponseFunctionToolCallCallerDirect:
//	case openai.BetaResponseFunctionToolCallCallerProgram:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseFunctionToolCallCallerUnion) AsAny() anyBetaResponseFunctionToolCallCaller {
	switch u.Type {
	case "direct":
		return u.AsDirect()
	case "program":
		return u.AsProgram()
	}
	return nil
}

func (u BetaResponseFunctionToolCallCallerUnion) AsDirect() (v BetaResponseFunctionToolCallCallerDirect) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseFunctionToolCallCallerUnion) AsProgram() (v BetaResponseFunctionToolCallCallerProgram) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseFunctionToolCallCallerUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseFunctionToolCallCallerUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseFunctionToolCallCallerDirect struct {
	Type constant.Direct `json:"type" default:"direct"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionToolCallCallerDirect) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionToolCallCallerDirect) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseFunctionToolCallCallerProgram struct {
	// The call ID of the program item that produced this tool call.
	CallerID string           `json:"caller_id" api:"required"`
	Type     constant.Program `json:"type" default:"program"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CallerID    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionToolCallCallerProgram) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionToolCallCallerProgram) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
// Populated when items are returned via API.
type BetaResponseFunctionToolCallStatus string

const (
	BetaResponseFunctionToolCallStatusInProgress BetaResponseFunctionToolCallStatus = "in_progress"
	BetaResponseFunctionToolCallStatusCompleted  BetaResponseFunctionToolCallStatus = "completed"
	BetaResponseFunctionToolCallStatusIncomplete BetaResponseFunctionToolCallStatus = "incomplete"
)

// A tool call to run a function. See the
// [function calling guide](https://platform.openai.com/docs/guides/function-calling)
// for more information.
//
// The properties Arguments, CallID, Name, Type are required.
type BetaResponseFunctionToolCallParam struct {
	// A JSON string of the arguments to pass to the function.
	Arguments string `json:"arguments" api:"required"`
	// The unique ID of the function tool call generated by the model.
	CallID string `json:"call_id" api:"required"`
	// The name of the function to run.
	Name string `json:"name" api:"required"`
	// The unique ID of the function tool call.
	ID param.Opt[string] `json:"id,omitzero"`
	// The namespace of the function to run.
	Namespace param.Opt[string] `json:"namespace,omitzero"`
	// The agent that produced this item.
	Agent BetaResponseFunctionToolCallAgentParam `json:"agent,omitzero"`
	// The execution context that produced this tool call.
	Caller BetaResponseFunctionToolCallCallerUnionParam `json:"caller,omitzero"`
	// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
	// Populated when items are returned via API.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status BetaResponseFunctionToolCallStatus `json:"status,omitzero"`
	// The type of the function tool call. Always `function_call`.
	//
	// This field can be elided, and will marshal its zero value as "function_call".
	Type constant.FunctionCall `json:"type" default:"function_call"`
	paramObj
}

func (r BetaResponseFunctionToolCallParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseFunctionToolCallParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseFunctionToolCallParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseFunctionToolCallAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseFunctionToolCallAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseFunctionToolCallAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseFunctionToolCallAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseFunctionToolCallCallerUnionParam struct {
	OfDirect  *BetaResponseFunctionToolCallCallerDirectParam  `json:",omitzero,inline"`
	OfProgram *BetaResponseFunctionToolCallCallerProgramParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseFunctionToolCallCallerUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfDirect, u.OfProgram)
}
func (u *BetaResponseFunctionToolCallCallerUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseFunctionToolCallCallerUnionParam) asAny() any {
	if !param.IsOmitted(u.OfDirect) {
		return u.OfDirect
	} else if !param.IsOmitted(u.OfProgram) {
		return u.OfProgram
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseFunctionToolCallCallerUnionParam) GetCallerID() *string {
	if vt := u.OfProgram; vt != nil {
		return &vt.CallerID
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseFunctionToolCallCallerUnionParam) GetType() *string {
	if vt := u.OfDirect; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfProgram; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaResponseFunctionToolCallCallerUnionParam](
		"type",
		apijson.Discriminator[BetaResponseFunctionToolCallCallerDirectParam]("direct"),
		apijson.Discriminator[BetaResponseFunctionToolCallCallerProgramParam]("program"),
	)
}

func NewBetaResponseFunctionToolCallCallerDirectParam() BetaResponseFunctionToolCallCallerDirectParam {
	return BetaResponseFunctionToolCallCallerDirectParam{
		Type: "direct",
	}
}

// This struct has a constant value, construct it with
// [NewBetaResponseFunctionToolCallCallerDirectParam].
type BetaResponseFunctionToolCallCallerDirectParam struct {
	Type constant.Direct `json:"type" default:"direct"`
	paramObj
}

func (r BetaResponseFunctionToolCallCallerDirectParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseFunctionToolCallCallerDirectParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseFunctionToolCallCallerDirectParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The properties CallerID, Type are required.
type BetaResponseFunctionToolCallCallerProgramParam struct {
	// The call ID of the program item that produced this tool call.
	CallerID string `json:"caller_id" api:"required"`
	// This field can be elided, and will marshal its zero value as "program".
	Type constant.Program `json:"type" default:"program"`
	paramObj
}

func (r BetaResponseFunctionToolCallCallerProgramParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseFunctionToolCallCallerProgramParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseFunctionToolCallCallerProgramParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool call to run a function. See the
// [function calling guide](https://platform.openai.com/docs/guides/function-calling)
// for more information.
type BetaResponseFunctionToolCallItem struct {
	// The unique ID of the function tool call.
	ID string `json:"id" api:"required"`
	// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
	// Populated when items are returned via API.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status string `json:"status" api:"required"`
	// The identifier of the actor that created the item.
	CreatedBy string `json:"created_by"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Status      respjson.Field
		CreatedBy   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
	BetaResponseFunctionToolCall
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionToolCallItem) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionToolCallItem) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseFunctionToolCallOutputItem struct {
	// The unique ID of the function call tool output.
	ID string `json:"id" api:"required"`
	// The unique ID of the function tool call generated by the model.
	CallID string `json:"call_id" api:"required"`
	// The output from the function call generated by your code. Can be a string or an
	// list of output content.
	Output BetaResponseFunctionToolCallOutputItemOutputUnion `json:"output" api:"required"`
	// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
	// Populated when items are returned via API.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status BetaResponseFunctionToolCallOutputItemStatus `json:"status" api:"required"`
	// The type of the function tool call output. Always `function_call_output`.
	Type constant.FunctionCallOutput `json:"type" default:"function_call_output"`
	// The agent that produced this item.
	Agent BetaResponseFunctionToolCallOutputItemAgent `json:"agent" api:"nullable"`
	// The execution context that produced this tool call.
	Caller BetaResponseFunctionToolCallOutputItemCallerUnion `json:"caller" api:"nullable"`
	// The identifier of the actor that created the item.
	CreatedBy string `json:"created_by"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CallID      respjson.Field
		Output      respjson.Field
		Status      respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		Caller      respjson.Field
		CreatedBy   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionToolCallOutputItem) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionToolCallOutputItem) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseFunctionToolCallOutputItemOutputUnion contains all possible
// properties and values from [string],
// [[]BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfString OfOutputContentList]
type BetaResponseFunctionToolCallOutputItemOutputUnion struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a
	// [[]BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion]
	// instead of an object.
	OfOutputContentList []BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion `json:",inline"`
	JSON                struct {
		OfString            respjson.Field
		OfOutputContentList respjson.Field
		raw                 string
	} `json:"-"`
}

func (u BetaResponseFunctionToolCallOutputItemOutputUnion) AsString() (v string) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseFunctionToolCallOutputItemOutputUnion) AsOutputContentList() (v []BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseFunctionToolCallOutputItemOutputUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseFunctionToolCallOutputItemOutputUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion contains
// all possible properties and values from [BetaResponseInputText],
// [BetaResponseInputImage], [BetaResponseInputFile].
//
// Use the
// [BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion.AsAny]
// method to switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion struct {
	// This field is from variant [BetaResponseInputText].
	Text string `json:"text"`
	// Any of "input_text", "input_image", "input_file".
	Type string `json:"type"`
	// This field is a union of [BetaResponseInputTextPromptCacheBreakpoint],
	// [BetaResponseInputImagePromptCacheBreakpoint],
	// [BetaResponseInputFilePromptCacheBreakpoint]
	PromptCacheBreakpoint BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnionPromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
	Detail                string                                                                                      `json:"detail"`
	FileID                string                                                                                      `json:"file_id"`
	// This field is from variant [BetaResponseInputImage].
	ImageURL string `json:"image_url"`
	// This field is from variant [BetaResponseInputFile].
	FileData string `json:"file_data"`
	// This field is from variant [BetaResponseInputFile].
	FileURL string `json:"file_url"`
	// This field is from variant [BetaResponseInputFile].
	Filename string `json:"filename"`
	JSON     struct {
		Text                  respjson.Field
		Type                  respjson.Field
		PromptCacheBreakpoint respjson.Field
		Detail                respjson.Field
		FileID                respjson.Field
		ImageURL              respjson.Field
		FileData              respjson.Field
		FileURL               respjson.Field
		Filename              respjson.Field
		raw                   string
	} `json:"-"`
}

// anyBetaResponseFunctionToolCallOutputItemOutputOutputContentListItem is
// implemented by each variant of
// [BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion] to add
// type safety for the return type of
// [BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion.AsAny]
type anyBetaResponseFunctionToolCallOutputItemOutputOutputContentListItem interface {
	implBetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion()
}

func (BetaResponseInputText) implBetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion() {
}
func (BetaResponseInputImage) implBetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion() {
}
func (BetaResponseInputFile) implBetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion() {
}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion.AsAny().(type) {
//	case openai.BetaResponseInputText:
//	case openai.BetaResponseInputImage:
//	case openai.BetaResponseInputFile:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion) AsAny() anyBetaResponseFunctionToolCallOutputItemOutputOutputContentListItem {
	switch u.Type {
	case "input_text":
		return u.AsInputText()
	case "input_image":
		return u.AsInputImage()
	case "input_file":
		return u.AsInputFile()
	}
	return nil
}

func (u BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion) AsInputText() (v BetaResponseInputText) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion) AsInputImage() (v BetaResponseInputImage) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion) AsInputFile() (v BetaResponseInputFile) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion) RawJSON() string {
	return u.JSON.raw
}

func (r *BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnionPromptCacheBreakpoint
// is an implicit subunion of
// [BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion].
// BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnionPromptCacheBreakpoint
// provides convenient access to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion].
type BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnionPromptCacheBreakpoint struct {
	// This field is from variant [BetaResponseInputTextPromptCacheBreakpoint].
	Mode constant.Explicit `json:"mode"`
	JSON struct {
		Mode respjson.Field
		raw  string
	} `json:"-"`
}

func (r *BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnionPromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
// Populated when items are returned via API.
type BetaResponseFunctionToolCallOutputItemStatus string

const (
	BetaResponseFunctionToolCallOutputItemStatusInProgress BetaResponseFunctionToolCallOutputItemStatus = "in_progress"
	BetaResponseFunctionToolCallOutputItemStatusCompleted  BetaResponseFunctionToolCallOutputItemStatus = "completed"
	BetaResponseFunctionToolCallOutputItemStatusIncomplete BetaResponseFunctionToolCallOutputItemStatus = "incomplete"
)

// The agent that produced this item.
type BetaResponseFunctionToolCallOutputItemAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionToolCallOutputItemAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionToolCallOutputItemAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseFunctionToolCallOutputItemCallerUnion contains all possible
// properties and values from [BetaResponseFunctionToolCallOutputItemCallerDirect],
// [BetaResponseFunctionToolCallOutputItemCallerProgram].
//
// Use the [BetaResponseFunctionToolCallOutputItemCallerUnion.AsAny] method to
// switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseFunctionToolCallOutputItemCallerUnion struct {
	// Any of "direct", "program".
	Type string `json:"type"`
	// This field is from variant
	// [BetaResponseFunctionToolCallOutputItemCallerProgram].
	CallerID string `json:"caller_id"`
	JSON     struct {
		Type     respjson.Field
		CallerID respjson.Field
		raw      string
	} `json:"-"`
}

// anyBetaResponseFunctionToolCallOutputItemCaller is implemented by each variant
// of [BetaResponseFunctionToolCallOutputItemCallerUnion] to add type safety for
// the return type of [BetaResponseFunctionToolCallOutputItemCallerUnion.AsAny]
type anyBetaResponseFunctionToolCallOutputItemCaller interface {
	implBetaResponseFunctionToolCallOutputItemCallerUnion()
}

func (BetaResponseFunctionToolCallOutputItemCallerDirect) implBetaResponseFunctionToolCallOutputItemCallerUnion() {
}
func (BetaResponseFunctionToolCallOutputItemCallerProgram) implBetaResponseFunctionToolCallOutputItemCallerUnion() {
}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseFunctionToolCallOutputItemCallerUnion.AsAny().(type) {
//	case openai.BetaResponseFunctionToolCallOutputItemCallerDirect:
//	case openai.BetaResponseFunctionToolCallOutputItemCallerProgram:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseFunctionToolCallOutputItemCallerUnion) AsAny() anyBetaResponseFunctionToolCallOutputItemCaller {
	switch u.Type {
	case "direct":
		return u.AsDirect()
	case "program":
		return u.AsProgram()
	}
	return nil
}

func (u BetaResponseFunctionToolCallOutputItemCallerUnion) AsDirect() (v BetaResponseFunctionToolCallOutputItemCallerDirect) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseFunctionToolCallOutputItemCallerUnion) AsProgram() (v BetaResponseFunctionToolCallOutputItemCallerProgram) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseFunctionToolCallOutputItemCallerUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseFunctionToolCallOutputItemCallerUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseFunctionToolCallOutputItemCallerDirect struct {
	// The caller type. Always `direct`.
	Type constant.Direct `json:"type" default:"direct"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionToolCallOutputItemCallerDirect) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionToolCallOutputItemCallerDirect) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseFunctionToolCallOutputItemCallerProgram struct {
	// The call ID of the program item that produced this tool call.
	CallerID string `json:"caller_id" api:"required"`
	// The caller type. Always `program`.
	Type constant.Program `json:"type" default:"program"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CallerID    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionToolCallOutputItemCallerProgram) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionToolCallOutputItemCallerProgram) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The results of a web search tool call. See the
// [web search guide](https://platform.openai.com/docs/guides/tools-web-search) for
// more information.
type BetaResponseFunctionWebSearch struct {
	// The unique ID of the web search tool call.
	ID string `json:"id" api:"required"`
	// An object describing the specific action taken in this web search call. Includes
	// details on how the model used the web (search, open_page, find_in_page).
	Action BetaResponseFunctionWebSearchActionUnion `json:"action" api:"required"`
	// The status of the web search tool call.
	//
	// Any of "in_progress", "searching", "completed", "failed".
	Status BetaResponseFunctionWebSearchStatus `json:"status" api:"required"`
	// The type of the web search tool call. Always `web_search_call`.
	Type constant.WebSearchCall `json:"type" default:"web_search_call"`
	// The agent that produced this item.
	Agent BetaResponseFunctionWebSearchAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Action      respjson.Field
		Status      respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionWebSearch) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionWebSearch) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseFunctionWebSearch to a
// BetaResponseFunctionWebSearchParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseFunctionWebSearchParam.Overrides()
func (r BetaResponseFunctionWebSearch) ToParam() BetaResponseFunctionWebSearchParam {
	return param.Override[BetaResponseFunctionWebSearchParam](json.RawMessage(r.RawJSON()))
}

// BetaResponseFunctionWebSearchActionUnion contains all possible properties and
// values from [BetaResponseFunctionWebSearchActionSearch],
// [BetaResponseFunctionWebSearchActionOpenPage],
// [BetaResponseFunctionWebSearchActionFindInPage].
//
// Use the [BetaResponseFunctionWebSearchActionUnion.AsAny] method to switch on the
// variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseFunctionWebSearchActionUnion struct {
	// Any of "search", "open_page", "find_in_page".
	Type string `json:"type"`
	// This field is from variant [BetaResponseFunctionWebSearchActionSearch].
	Queries []string `json:"queries"`
	// This field is from variant [BetaResponseFunctionWebSearchActionSearch].
	Query string `json:"query"`
	// This field is from variant [BetaResponseFunctionWebSearchActionSearch].
	Sources []BetaResponseFunctionWebSearchActionSearchSource `json:"sources"`
	URL     string                                            `json:"url"`
	// This field is from variant [BetaResponseFunctionWebSearchActionFindInPage].
	Pattern string `json:"pattern"`
	JSON    struct {
		Type    respjson.Field
		Queries respjson.Field
		Query   respjson.Field
		Sources respjson.Field
		URL     respjson.Field
		Pattern respjson.Field
		raw     string
	} `json:"-"`
}

// anyBetaResponseFunctionWebSearchAction is implemented by each variant of
// [BetaResponseFunctionWebSearchActionUnion] to add type safety for the return
// type of [BetaResponseFunctionWebSearchActionUnion.AsAny]
type anyBetaResponseFunctionWebSearchAction interface {
	implBetaResponseFunctionWebSearchActionUnion()
}

func (BetaResponseFunctionWebSearchActionSearch) implBetaResponseFunctionWebSearchActionUnion()     {}
func (BetaResponseFunctionWebSearchActionOpenPage) implBetaResponseFunctionWebSearchActionUnion()   {}
func (BetaResponseFunctionWebSearchActionFindInPage) implBetaResponseFunctionWebSearchActionUnion() {}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseFunctionWebSearchActionUnion.AsAny().(type) {
//	case openai.BetaResponseFunctionWebSearchActionSearch:
//	case openai.BetaResponseFunctionWebSearchActionOpenPage:
//	case openai.BetaResponseFunctionWebSearchActionFindInPage:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseFunctionWebSearchActionUnion) AsAny() anyBetaResponseFunctionWebSearchAction {
	switch u.Type {
	case "search":
		return u.AsSearch()
	case "open_page":
		return u.AsOpenPage()
	case "find_in_page":
		return u.AsFindInPage()
	}
	return nil
}

func (u BetaResponseFunctionWebSearchActionUnion) AsSearch() (v BetaResponseFunctionWebSearchActionSearch) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseFunctionWebSearchActionUnion) AsOpenPage() (v BetaResponseFunctionWebSearchActionOpenPage) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseFunctionWebSearchActionUnion) AsFindInPage() (v BetaResponseFunctionWebSearchActionFindInPage) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseFunctionWebSearchActionUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseFunctionWebSearchActionUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Action type "search" - Performs a web search query.
type BetaResponseFunctionWebSearchActionSearch struct {
	// The action type.
	Type constant.Search `json:"type" default:"search"`
	// The search queries.
	Queries []string `json:"queries"`
	// The search query.
	//
	// Deprecated: deprecated
	Query string `json:"query"`
	// The sources used in the search.
	Sources []BetaResponseFunctionWebSearchActionSearchSource `json:"sources"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		Queries     respjson.Field
		Query       respjson.Field
		Sources     respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionWebSearchActionSearch) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionWebSearchActionSearch) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A source used in the search.
type BetaResponseFunctionWebSearchActionSearchSource struct {
	// The type of source. Always `url`.
	Type constant.URL `json:"type" default:"url"`
	// The URL of the source.
	URL string `json:"url" api:"required" format:"uri"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		URL         respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionWebSearchActionSearchSource) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionWebSearchActionSearchSource) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Action type "open_page" - Opens a specific URL from search results.
type BetaResponseFunctionWebSearchActionOpenPage struct {
	// The action type.
	Type constant.OpenPage `json:"type" default:"open_page"`
	// The URL opened by the model.
	URL string `json:"url" api:"nullable" format:"uri"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		URL         respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionWebSearchActionOpenPage) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionWebSearchActionOpenPage) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Action type "find_in_page": Searches for a pattern within a loaded page.
type BetaResponseFunctionWebSearchActionFindInPage struct {
	// The pattern or text to search for within the page.
	Pattern string `json:"pattern" api:"required"`
	// The action type.
	Type constant.FindInPage `json:"type" default:"find_in_page"`
	// The URL of the page searched for the pattern.
	URL string `json:"url" api:"required" format:"uri"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Pattern     respjson.Field
		Type        respjson.Field
		URL         respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionWebSearchActionFindInPage) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionWebSearchActionFindInPage) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The status of the web search tool call.
type BetaResponseFunctionWebSearchStatus string

const (
	BetaResponseFunctionWebSearchStatusInProgress BetaResponseFunctionWebSearchStatus = "in_progress"
	BetaResponseFunctionWebSearchStatusSearching  BetaResponseFunctionWebSearchStatus = "searching"
	BetaResponseFunctionWebSearchStatusCompleted  BetaResponseFunctionWebSearchStatus = "completed"
	BetaResponseFunctionWebSearchStatusFailed     BetaResponseFunctionWebSearchStatus = "failed"
)

// The agent that produced this item.
type BetaResponseFunctionWebSearchAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseFunctionWebSearchAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseFunctionWebSearchAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The results of a web search tool call. See the
// [web search guide](https://platform.openai.com/docs/guides/tools-web-search) for
// more information.
//
// The properties ID, Action, Status, Type are required.
type BetaResponseFunctionWebSearchParam struct {
	// The unique ID of the web search tool call.
	ID string `json:"id" api:"required"`
	// An object describing the specific action taken in this web search call. Includes
	// details on how the model used the web (search, open_page, find_in_page).
	Action BetaResponseFunctionWebSearchActionUnionParam `json:"action,omitzero" api:"required"`
	// The status of the web search tool call.
	//
	// Any of "in_progress", "searching", "completed", "failed".
	Status BetaResponseFunctionWebSearchStatus `json:"status,omitzero" api:"required"`
	// The agent that produced this item.
	Agent BetaResponseFunctionWebSearchAgentParam `json:"agent,omitzero"`
	// The type of the web search tool call. Always `web_search_call`.
	//
	// This field can be elided, and will marshal its zero value as "web_search_call".
	Type constant.WebSearchCall `json:"type" default:"web_search_call"`
	paramObj
}

func (r BetaResponseFunctionWebSearchParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseFunctionWebSearchParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseFunctionWebSearchParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseFunctionWebSearchActionUnionParam struct {
	OfSearch     *BetaResponseFunctionWebSearchActionSearchParam     `json:",omitzero,inline"`
	OfOpenPage   *BetaResponseFunctionWebSearchActionOpenPageParam   `json:",omitzero,inline"`
	OfFindInPage *BetaResponseFunctionWebSearchActionFindInPageParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseFunctionWebSearchActionUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfSearch, u.OfOpenPage, u.OfFindInPage)
}
func (u *BetaResponseFunctionWebSearchActionUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseFunctionWebSearchActionUnionParam) asAny() any {
	if !param.IsOmitted(u.OfSearch) {
		return u.OfSearch
	} else if !param.IsOmitted(u.OfOpenPage) {
		return u.OfOpenPage
	} else if !param.IsOmitted(u.OfFindInPage) {
		return u.OfFindInPage
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseFunctionWebSearchActionUnionParam) GetQueries() []string {
	if vt := u.OfSearch; vt != nil {
		return vt.Queries
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseFunctionWebSearchActionUnionParam) GetQuery() *string {
	if vt := u.OfSearch; vt != nil && vt.Query.Valid() {
		return &vt.Query.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseFunctionWebSearchActionUnionParam) GetSources() []BetaResponseFunctionWebSearchActionSearchSourceParam {
	if vt := u.OfSearch; vt != nil {
		return vt.Sources
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseFunctionWebSearchActionUnionParam) GetPattern() *string {
	if vt := u.OfFindInPage; vt != nil {
		return &vt.Pattern
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseFunctionWebSearchActionUnionParam) GetType() *string {
	if vt := u.OfSearch; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfOpenPage; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfFindInPage; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseFunctionWebSearchActionUnionParam) GetURL() *string {
	if vt := u.OfOpenPage; vt != nil && vt.URL.Valid() {
		return &vt.URL.Value
	} else if vt := u.OfFindInPage; vt != nil {
		return (*string)(&vt.URL)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaResponseFunctionWebSearchActionUnionParam](
		"type",
		apijson.Discriminator[BetaResponseFunctionWebSearchActionSearchParam]("search"),
		apijson.Discriminator[BetaResponseFunctionWebSearchActionOpenPageParam]("open_page"),
		apijson.Discriminator[BetaResponseFunctionWebSearchActionFindInPageParam]("find_in_page"),
	)
}

// Action type "search" - Performs a web search query.
//
// The property Type is required.
type BetaResponseFunctionWebSearchActionSearchParam struct {
	// The search query.
	//
	// Deprecated: deprecated
	Query param.Opt[string] `json:"query,omitzero"`
	// The search queries.
	Queries []string `json:"queries,omitzero"`
	// The sources used in the search.
	Sources []BetaResponseFunctionWebSearchActionSearchSourceParam `json:"sources,omitzero"`
	// The action type.
	//
	// This field can be elided, and will marshal its zero value as "search".
	Type constant.Search `json:"type" default:"search"`
	paramObj
}

func (r BetaResponseFunctionWebSearchActionSearchParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseFunctionWebSearchActionSearchParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseFunctionWebSearchActionSearchParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A source used in the search.
//
// The properties Type, URL are required.
type BetaResponseFunctionWebSearchActionSearchSourceParam struct {
	// The URL of the source.
	URL string `json:"url" api:"required" format:"uri"`
	// The type of source. Always `url`.
	//
	// This field can be elided, and will marshal its zero value as "url".
	Type constant.URL `json:"type" default:"url"`
	paramObj
}

func (r BetaResponseFunctionWebSearchActionSearchSourceParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseFunctionWebSearchActionSearchSourceParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseFunctionWebSearchActionSearchSourceParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Action type "open_page" - Opens a specific URL from search results.
//
// The property Type is required.
type BetaResponseFunctionWebSearchActionOpenPageParam struct {
	// The URL opened by the model.
	URL param.Opt[string] `json:"url,omitzero" format:"uri"`
	// The action type.
	//
	// This field can be elided, and will marshal its zero value as "open_page".
	Type constant.OpenPage `json:"type" default:"open_page"`
	paramObj
}

func (r BetaResponseFunctionWebSearchActionOpenPageParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseFunctionWebSearchActionOpenPageParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseFunctionWebSearchActionOpenPageParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Action type "find_in_page": Searches for a pattern within a loaded page.
//
// The properties Pattern, Type, URL are required.
type BetaResponseFunctionWebSearchActionFindInPageParam struct {
	// The pattern or text to search for within the page.
	Pattern string `json:"pattern" api:"required"`
	// The URL of the page searched for the pattern.
	URL string `json:"url" api:"required" format:"uri"`
	// The action type.
	//
	// This field can be elided, and will marshal its zero value as "find_in_page".
	Type constant.FindInPage `json:"type" default:"find_in_page"`
	paramObj
}

func (r BetaResponseFunctionWebSearchActionFindInPageParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseFunctionWebSearchActionFindInPageParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseFunctionWebSearchActionFindInPageParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseFunctionWebSearchAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseFunctionWebSearchAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseFunctionWebSearchAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseFunctionWebSearchAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when an image generation tool call has completed and the final image is
// available.
type BetaResponseImageGenCallCompletedEvent struct {
	// The unique identifier of the image generation item being processed.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item in the response's output array.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always 'response.image_generation_call.completed'.
	Type constant.ResponseImageGenerationCallCompleted `json:"type" default:"response.image_generation_call.completed"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseImageGenCallCompletedEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseImageGenCallCompletedEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseImageGenCallCompletedEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseImageGenCallCompletedEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseImageGenCallCompletedEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseImageGenCallCompletedEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when an image generation tool call is actively generating an image
// (intermediate state).
type BetaResponseImageGenCallGeneratingEvent struct {
	// The unique identifier of the image generation item being processed.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item in the response's output array.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of the image generation item being processed.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always 'response.image_generation_call.generating'.
	Type constant.ResponseImageGenerationCallGenerating `json:"type" default:"response.image_generation_call.generating"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseImageGenCallGeneratingEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseImageGenCallGeneratingEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseImageGenCallGeneratingEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseImageGenCallGeneratingEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseImageGenCallGeneratingEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseImageGenCallGeneratingEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when an image generation tool call is in progress.
type BetaResponseImageGenCallInProgressEvent struct {
	// The unique identifier of the image generation item being processed.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item in the response's output array.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of the image generation item being processed.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always 'response.image_generation_call.in_progress'.
	Type constant.ResponseImageGenerationCallInProgress `json:"type" default:"response.image_generation_call.in_progress"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseImageGenCallInProgressEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseImageGenCallInProgressEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseImageGenCallInProgressEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseImageGenCallInProgressEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseImageGenCallInProgressEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseImageGenCallInProgressEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when a partial image is available during image generation streaming.
type BetaResponseImageGenCallPartialImageEvent struct {
	// The unique identifier of the image generation item being processed.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item in the response's output array.
	OutputIndex int64 `json:"output_index" api:"required"`
	// Base64-encoded partial image data, suitable for rendering as an image.
	PartialImageB64 string `json:"partial_image_b64" api:"required"`
	// 0-based index for the partial image (backend is 1-based, but this is 0-based for
	// the user).
	PartialImageIndex int64 `json:"partial_image_index" api:"required"`
	// The sequence number of the image generation item being processed.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always 'response.image_generation_call.partial_image'.
	Type constant.ResponseImageGenerationCallPartialImage `json:"type" default:"response.image_generation_call.partial_image"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseImageGenCallPartialImageEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ItemID            respjson.Field
		OutputIndex       respjson.Field
		PartialImageB64   respjson.Field
		PartialImageIndex respjson.Field
		SequenceNumber    respjson.Field
		Type              respjson.Field
		Agent             respjson.Field
		ExtraFields       map[string]respjson.Field
		raw               string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseImageGenCallPartialImageEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseImageGenCallPartialImageEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseImageGenCallPartialImageEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseImageGenCallPartialImageEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseImageGenCallPartialImageEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when the response is in progress.
type BetaResponseInProgressEvent struct {
	// The response that is in progress.
	Response BetaResponse `json:"response" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.in_progress`.
	Type constant.ResponseInProgress `json:"type" default:"response.in_progress"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseInProgressEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Response       respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInProgressEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInProgressEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseInProgressEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInProgressEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInProgressEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Specify additional output data to include in the model response. Currently
// supported values are:
//
//   - `web_search_call.results`: Include the search results of the web search tool
//     call.
//   - `web_search_call.action.sources`: Include the sources of the web search tool
//     call.
//   - `code_interpreter_call.outputs`: Includes the outputs of python code execution
//     in code interpreter tool call items.
//   - `computer_call_output.output.image_url`: Include image urls from the computer
//     call output.
//   - `file_search_call.results`: Include the search results of the file search tool
//     call.
//   - `message.input_image.image_url`: Include image urls from the input message.
//   - `message.output_text.logprobs`: Include logprobs with assistant messages.
//   - `reasoning.encrypted_content`: Includes an encrypted version of reasoning
//     tokens in reasoning item outputs. This enables reasoning items to be used in
//     multi-turn conversations when using the Responses API statelessly (like when
//     the `store` parameter is set to `false`, or when an organization is enrolled
//     in the zero data retention program).
type BetaResponseIncludable string

const (
	BetaResponseIncludableFileSearchCallResults            BetaResponseIncludable = "file_search_call.results"
	BetaResponseIncludableWebSearchCallResults             BetaResponseIncludable = "web_search_call.results"
	BetaResponseIncludableWebSearchCallActionSources       BetaResponseIncludable = "web_search_call.action.sources"
	BetaResponseIncludableMessageInputImageImageURL        BetaResponseIncludable = "message.input_image.image_url"
	BetaResponseIncludableComputerCallOutputOutputImageURL BetaResponseIncludable = "computer_call_output.output.image_url"
	BetaResponseIncludableCodeInterpreterCallOutputs       BetaResponseIncludable = "code_interpreter_call.outputs"
	BetaResponseIncludableReasoningEncryptedContent        BetaResponseIncludable = "reasoning.encrypted_content"
	BetaResponseIncludableMessageOutputTextLogprobs        BetaResponseIncludable = "message.output_text.logprobs"
)

// An event that is emitted when a response finishes as incomplete.
type BetaResponseIncompleteEvent struct {
	// The response that was incomplete.
	Response BetaResponse `json:"response" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.incomplete`.
	Type constant.ResponseIncomplete `json:"type" default:"response.incomplete"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseIncompleteEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Response       respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseIncompleteEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseIncompleteEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseIncompleteEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseIncompleteEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseIncompleteEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseInputParam []BetaResponseInputItemUnionParam

// BetaResponseInputContentUnion contains all possible properties and values from
// [BetaResponseInputText], [BetaResponseInputImage], [BetaResponseInputFile].
//
// Use the [BetaResponseInputContentUnion.AsAny] method to switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseInputContentUnion struct {
	// This field is from variant [BetaResponseInputText].
	Text string `json:"text"`
	// Any of "input_text", "input_image", "input_file".
	Type string `json:"type"`
	// This field is a union of [BetaResponseInputTextPromptCacheBreakpoint],
	// [BetaResponseInputImagePromptCacheBreakpoint],
	// [BetaResponseInputFilePromptCacheBreakpoint]
	PromptCacheBreakpoint BetaResponseInputContentUnionPromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
	Detail                string                                             `json:"detail"`
	FileID                string                                             `json:"file_id"`
	// This field is from variant [BetaResponseInputImage].
	ImageURL string `json:"image_url"`
	// This field is from variant [BetaResponseInputFile].
	FileData string `json:"file_data"`
	// This field is from variant [BetaResponseInputFile].
	FileURL string `json:"file_url"`
	// This field is from variant [BetaResponseInputFile].
	Filename string `json:"filename"`
	JSON     struct {
		Text                  respjson.Field
		Type                  respjson.Field
		PromptCacheBreakpoint respjson.Field
		Detail                respjson.Field
		FileID                respjson.Field
		ImageURL              respjson.Field
		FileData              respjson.Field
		FileURL               respjson.Field
		Filename              respjson.Field
		raw                   string
	} `json:"-"`
}

// anyBetaResponseInputContent is implemented by each variant of
// [BetaResponseInputContentUnion] to add type safety for the return type of
// [BetaResponseInputContentUnion.AsAny]
type anyBetaResponseInputContent interface {
	implBetaResponseInputContentUnion()
}

func (BetaResponseInputText) implBetaResponseInputContentUnion()  {}
func (BetaResponseInputImage) implBetaResponseInputContentUnion() {}
func (BetaResponseInputFile) implBetaResponseInputContentUnion()  {}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseInputContentUnion.AsAny().(type) {
//	case openai.BetaResponseInputText:
//	case openai.BetaResponseInputImage:
//	case openai.BetaResponseInputFile:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseInputContentUnion) AsAny() anyBetaResponseInputContent {
	switch u.Type {
	case "input_text":
		return u.AsInputText()
	case "input_image":
		return u.AsInputImage()
	case "input_file":
		return u.AsInputFile()
	}
	return nil
}

func (u BetaResponseInputContentUnion) AsInputText() (v BetaResponseInputText) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputContentUnion) AsInputImage() (v BetaResponseInputImage) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputContentUnion) AsInputFile() (v BetaResponseInputFile) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseInputContentUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseInputContentUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseInputContentUnionPromptCacheBreakpoint is an implicit subunion of
// [BetaResponseInputContentUnion].
// BetaResponseInputContentUnionPromptCacheBreakpoint provides convenient access to
// the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseInputContentUnion].
type BetaResponseInputContentUnionPromptCacheBreakpoint struct {
	// This field is from variant [BetaResponseInputTextPromptCacheBreakpoint].
	Mode constant.Explicit `json:"mode"`
	JSON struct {
		Mode respjson.Field
		raw  string
	} `json:"-"`
}

func (r *BetaResponseInputContentUnionPromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseInputContentUnion to a
// BetaResponseInputContentUnionParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseInputContentUnionParam.Overrides()
func (r BetaResponseInputContentUnion) ToParam() BetaResponseInputContentUnionParam {
	return param.Override[BetaResponseInputContentUnionParam](json.RawMessage(r.RawJSON()))
}

func BetaResponseInputContentParamOfInputText(text string) BetaResponseInputContentUnionParam {
	var inputText BetaResponseInputTextParam
	inputText.Text = text
	return BetaResponseInputContentUnionParam{OfInputText: &inputText}
}

func BetaResponseInputContentParamOfInputImage(detail BetaResponseInputImageDetail) BetaResponseInputContentUnionParam {
	var inputImage BetaResponseInputImageParam
	inputImage.Detail = detail
	return BetaResponseInputContentUnionParam{OfInputImage: &inputImage}
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseInputContentUnionParam struct {
	OfInputText  *BetaResponseInputTextParam  `json:",omitzero,inline"`
	OfInputImage *BetaResponseInputImageParam `json:",omitzero,inline"`
	OfInputFile  *BetaResponseInputFileParam  `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseInputContentUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfInputText, u.OfInputImage, u.OfInputFile)
}
func (u *BetaResponseInputContentUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseInputContentUnionParam) asAny() any {
	if !param.IsOmitted(u.OfInputText) {
		return u.OfInputText
	} else if !param.IsOmitted(u.OfInputImage) {
		return u.OfInputImage
	} else if !param.IsOmitted(u.OfInputFile) {
		return u.OfInputFile
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputContentUnionParam) GetText() *string {
	if vt := u.OfInputText; vt != nil {
		return &vt.Text
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputContentUnionParam) GetImageURL() *string {
	if vt := u.OfInputImage; vt != nil && vt.ImageURL.Valid() {
		return &vt.ImageURL.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputContentUnionParam) GetFileData() *string {
	if vt := u.OfInputFile; vt != nil && vt.FileData.Valid() {
		return &vt.FileData.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputContentUnionParam) GetFileURL() *string {
	if vt := u.OfInputFile; vt != nil && vt.FileURL.Valid() {
		return &vt.FileURL.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputContentUnionParam) GetFilename() *string {
	if vt := u.OfInputFile; vt != nil && vt.Filename.Valid() {
		return &vt.Filename.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputContentUnionParam) GetType() *string {
	if vt := u.OfInputText; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfInputImage; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfInputFile; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputContentUnionParam) GetDetail() *string {
	if vt := u.OfInputImage; vt != nil {
		return (*string)(&vt.Detail)
	} else if vt := u.OfInputFile; vt != nil {
		return (*string)(&vt.Detail)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputContentUnionParam) GetFileID() *string {
	if vt := u.OfInputImage; vt != nil && vt.FileID.Valid() {
		return &vt.FileID.Value
	} else if vt := u.OfInputFile; vt != nil && vt.FileID.Valid() {
		return &vt.FileID.Value
	}
	return nil
}

// Returns a subunion which exports methods to access subproperties
//
// Or use AsAny() to get the underlying value
func (u BetaResponseInputContentUnionParam) GetPromptCacheBreakpoint() (res betaResponseInputContentUnionParamPromptCacheBreakpoint) {
	if vt := u.OfInputText; vt != nil {
		res.any = &vt.PromptCacheBreakpoint
	} else if vt := u.OfInputImage; vt != nil {
		res.any = &vt.PromptCacheBreakpoint
	} else if vt := u.OfInputFile; vt != nil {
		res.any = &vt.PromptCacheBreakpoint
	}
	return
}

// Can have the runtime types [*BetaResponseInputTextPromptCacheBreakpointParam],
// [*BetaResponseInputImagePromptCacheBreakpointParam],
// [*BetaResponseInputFilePromptCacheBreakpointParam]
type betaResponseInputContentUnionParamPromptCacheBreakpoint struct{ any }

// Use the following switch statement to get the type of the union:
//
//	switch u.AsAny().(type) {
//	case *openai.BetaResponseInputTextPromptCacheBreakpointParam:
//	case *openai.BetaResponseInputImagePromptCacheBreakpointParam:
//	case *openai.BetaResponseInputFilePromptCacheBreakpointParam:
//	default:
//	    fmt.Errorf("not present")
//	}
func (u betaResponseInputContentUnionParamPromptCacheBreakpoint) AsAny() any { return u.any }

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseInputContentUnionParamPromptCacheBreakpoint) GetMode() *string {
	switch vt := u.any.(type) {
	case *BetaResponseInputTextPromptCacheBreakpointParam:
		return (*string)(&vt.Mode)
	case *BetaResponseInputImagePromptCacheBreakpointParam:
		return (*string)(&vt.Mode)
	case *BetaResponseInputFilePromptCacheBreakpointParam:
		return (*string)(&vt.Mode)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaResponseInputContentUnionParam](
		"type",
		apijson.Discriminator[BetaResponseInputTextParam]("input_text"),
		apijson.Discriminator[BetaResponseInputImageParam]("input_image"),
		apijson.Discriminator[BetaResponseInputFileParam]("input_file"),
	)
}

// A file input to the model.
type BetaResponseInputFile struct {
	// The type of the input item. Always `input_file`.
	Type constant.InputFile `json:"type" default:"input_file"`
	// The detail level of the file to be sent to the model. Use `auto` to let the
	// system select the detail level; for GPT-5.6 and later models, `auto` uses
	// high-quality rendering, which may increase input token usage. Use `low` for
	// lower-cost rendering, or `high` to render the file at higher quality. Defaults
	// to `auto`.
	//
	// Any of "auto", "low", "high".
	Detail BetaResponseInputFileDetail `json:"detail"`
	// The content of the file to be sent to the model.
	FileData string `json:"file_data"`
	// The ID of the file to be sent to the model.
	FileID string `json:"file_id" api:"nullable"`
	// The URL of the file to be sent to the model.
	FileURL string `json:"file_url" format:"uri"`
	// The name of the file to be sent to the model.
	Filename string `json:"filename"`
	// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
	// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
	// token block.
	PromptCacheBreakpoint BetaResponseInputFilePromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type                  respjson.Field
		Detail                respjson.Field
		FileData              respjson.Field
		FileID                respjson.Field
		FileURL               respjson.Field
		Filename              respjson.Field
		PromptCacheBreakpoint respjson.Field
		ExtraFields           map[string]respjson.Field
		raw                   string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputFile) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputFile) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseInputFile to a BetaResponseInputFileParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseInputFileParam.Overrides()
func (r BetaResponseInputFile) ToParam() BetaResponseInputFileParam {
	return param.Override[BetaResponseInputFileParam](json.RawMessage(r.RawJSON()))
}

// The detail level of the file to be sent to the model. Use `auto` to let the
// system select the detail level; for GPT-5.6 and later models, `auto` uses
// high-quality rendering, which may increase input token usage. Use `low` for
// lower-cost rendering, or `high` to render the file at higher quality. Defaults
// to `auto`.
type BetaResponseInputFileDetail string

const (
	BetaResponseInputFileDetailAuto BetaResponseInputFileDetail = "auto"
	BetaResponseInputFileDetailLow  BetaResponseInputFileDetail = "low"
	BetaResponseInputFileDetailHigh BetaResponseInputFileDetail = "high"
)

// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
// token block.
type BetaResponseInputFilePromptCacheBreakpoint struct {
	// The breakpoint mode. Always `explicit`.
	Mode constant.Explicit `json:"mode" default:"explicit"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Mode        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputFilePromptCacheBreakpoint) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputFilePromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A file input to the model.
//
// The property Type is required.
type BetaResponseInputFileParam struct {
	// The ID of the file to be sent to the model.
	FileID param.Opt[string] `json:"file_id,omitzero"`
	// The content of the file to be sent to the model.
	FileData param.Opt[string] `json:"file_data,omitzero"`
	// The URL of the file to be sent to the model.
	FileURL param.Opt[string] `json:"file_url,omitzero" format:"uri"`
	// The name of the file to be sent to the model.
	Filename param.Opt[string] `json:"filename,omitzero"`
	// The detail level of the file to be sent to the model. Use `auto` to let the
	// system select the detail level; for GPT-5.6 and later models, `auto` uses
	// high-quality rendering, which may increase input token usage. Use `low` for
	// lower-cost rendering, or `high` to render the file at higher quality. Defaults
	// to `auto`.
	//
	// Any of "auto", "low", "high".
	Detail BetaResponseInputFileDetail `json:"detail,omitzero"`
	// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
	// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
	// token block.
	PromptCacheBreakpoint BetaResponseInputFilePromptCacheBreakpointParam `json:"prompt_cache_breakpoint,omitzero"`
	// The type of the input item. Always `input_file`.
	//
	// This field can be elided, and will marshal its zero value as "input_file".
	Type constant.InputFile `json:"type" default:"input_file"`
	paramObj
}

func (r BetaResponseInputFileParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputFileParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputFileParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func NewBetaResponseInputFilePromptCacheBreakpointParam() BetaResponseInputFilePromptCacheBreakpointParam {
	return BetaResponseInputFilePromptCacheBreakpointParam{
		Mode: "explicit",
	}
}

// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
// token block.
//
// This struct has a constant value, construct it with
// [NewBetaResponseInputFilePromptCacheBreakpointParam].
type BetaResponseInputFilePromptCacheBreakpointParam struct {
	// The breakpoint mode. Always `explicit`.
	Mode constant.Explicit `json:"mode" default:"explicit"`
	paramObj
}

func (r BetaResponseInputFilePromptCacheBreakpointParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputFilePromptCacheBreakpointParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputFilePromptCacheBreakpointParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A file input to the model.
type BetaResponseInputFileContent struct {
	// The type of the input item. Always `input_file`.
	Type constant.InputFile `json:"type" default:"input_file"`
	// The detail level of the file to be sent to the model. Use `auto` to let the
	// system select the detail level; for GPT-5.6 and later models, `auto` uses
	// high-quality rendering, which may increase input token usage. Use `low` for
	// lower-cost rendering, or `high` to render the file at higher quality. Defaults
	// to `auto`.
	//
	// Any of "auto", "low", "high".
	Detail BetaResponseInputFileContentDetail `json:"detail"`
	// The base64-encoded data of the file to be sent to the model.
	FileData string `json:"file_data" api:"nullable"`
	// The ID of the file to be sent to the model.
	FileID string `json:"file_id" api:"nullable"`
	// The URL of the file to be sent to the model.
	FileURL string `json:"file_url" api:"nullable" format:"uri"`
	// The name of the file to be sent to the model.
	Filename string `json:"filename" api:"nullable"`
	// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
	// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
	// token block.
	PromptCacheBreakpoint BetaResponseInputFileContentPromptCacheBreakpoint `json:"prompt_cache_breakpoint" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type                  respjson.Field
		Detail                respjson.Field
		FileData              respjson.Field
		FileID                respjson.Field
		FileURL               respjson.Field
		Filename              respjson.Field
		PromptCacheBreakpoint respjson.Field
		ExtraFields           map[string]respjson.Field
		raw                   string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputFileContent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputFileContent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseInputFileContent to a
// BetaResponseInputFileContentParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseInputFileContentParam.Overrides()
func (r BetaResponseInputFileContent) ToParam() BetaResponseInputFileContentParam {
	return param.Override[BetaResponseInputFileContentParam](json.RawMessage(r.RawJSON()))
}

// The detail level of the file to be sent to the model. Use `auto` to let the
// system select the detail level; for GPT-5.6 and later models, `auto` uses
// high-quality rendering, which may increase input token usage. Use `low` for
// lower-cost rendering, or `high` to render the file at higher quality. Defaults
// to `auto`.
type BetaResponseInputFileContentDetail string

const (
	BetaResponseInputFileContentDetailAuto BetaResponseInputFileContentDetail = "auto"
	BetaResponseInputFileContentDetailLow  BetaResponseInputFileContentDetail = "low"
	BetaResponseInputFileContentDetailHigh BetaResponseInputFileContentDetail = "high"
)

// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
// token block.
type BetaResponseInputFileContentPromptCacheBreakpoint struct {
	// The breakpoint mode. Always `explicit`.
	Mode constant.Explicit `json:"mode" default:"explicit"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Mode        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputFileContentPromptCacheBreakpoint) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputFileContentPromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A file input to the model.
//
// The property Type is required.
type BetaResponseInputFileContentParam struct {
	// The base64-encoded data of the file to be sent to the model.
	FileData param.Opt[string] `json:"file_data,omitzero"`
	// The ID of the file to be sent to the model.
	FileID param.Opt[string] `json:"file_id,omitzero"`
	// The URL of the file to be sent to the model.
	FileURL param.Opt[string] `json:"file_url,omitzero" format:"uri"`
	// The name of the file to be sent to the model.
	Filename param.Opt[string] `json:"filename,omitzero"`
	// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
	// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
	// token block.
	PromptCacheBreakpoint BetaResponseInputFileContentPromptCacheBreakpointParam `json:"prompt_cache_breakpoint,omitzero"`
	// The detail level of the file to be sent to the model. Use `auto` to let the
	// system select the detail level; for GPT-5.6 and later models, `auto` uses
	// high-quality rendering, which may increase input token usage. Use `low` for
	// lower-cost rendering, or `high` to render the file at higher quality. Defaults
	// to `auto`.
	//
	// Any of "auto", "low", "high".
	Detail BetaResponseInputFileContentDetail `json:"detail,omitzero"`
	// The type of the input item. Always `input_file`.
	//
	// This field can be elided, and will marshal its zero value as "input_file".
	Type constant.InputFile `json:"type" default:"input_file"`
	paramObj
}

func (r BetaResponseInputFileContentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputFileContentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputFileContentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func NewBetaResponseInputFileContentPromptCacheBreakpointParam() BetaResponseInputFileContentPromptCacheBreakpointParam {
	return BetaResponseInputFileContentPromptCacheBreakpointParam{
		Mode: "explicit",
	}
}

// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
// token block.
//
// This struct has a constant value, construct it with
// [NewBetaResponseInputFileContentPromptCacheBreakpointParam].
type BetaResponseInputFileContentPromptCacheBreakpointParam struct {
	// The breakpoint mode. Always `explicit`.
	Mode constant.Explicit `json:"mode" default:"explicit"`
	paramObj
}

func (r BetaResponseInputFileContentPromptCacheBreakpointParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputFileContentPromptCacheBreakpointParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputFileContentPromptCacheBreakpointParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// An image input to the model. Learn about
// [image inputs](https://platform.openai.com/docs/guides/vision).
type BetaResponseInputImage struct {
	// The detail level of the image to be sent to the model. One of `high`, `low`,
	// `auto`, or `original`. Defaults to `auto`.
	//
	// Any of "low", "high", "auto", "original".
	Detail BetaResponseInputImageDetail `json:"detail" api:"required"`
	// The type of the input item. Always `input_image`.
	Type constant.InputImage `json:"type" default:"input_image"`
	// The ID of the file to be sent to the model.
	FileID string `json:"file_id" api:"nullable"`
	// The URL of the image to be sent to the model. A fully qualified URL or base64
	// encoded image in a data URL.
	ImageURL string `json:"image_url" api:"nullable" format:"uri"`
	// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
	// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
	// token block.
	PromptCacheBreakpoint BetaResponseInputImagePromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Detail                respjson.Field
		Type                  respjson.Field
		FileID                respjson.Field
		ImageURL              respjson.Field
		PromptCacheBreakpoint respjson.Field
		ExtraFields           map[string]respjson.Field
		raw                   string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputImage) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputImage) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseInputImage to a BetaResponseInputImageParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseInputImageParam.Overrides()
func (r BetaResponseInputImage) ToParam() BetaResponseInputImageParam {
	return param.Override[BetaResponseInputImageParam](json.RawMessage(r.RawJSON()))
}

// The detail level of the image to be sent to the model. One of `high`, `low`,
// `auto`, or `original`. Defaults to `auto`.
type BetaResponseInputImageDetail string

const (
	BetaResponseInputImageDetailLow      BetaResponseInputImageDetail = "low"
	BetaResponseInputImageDetailHigh     BetaResponseInputImageDetail = "high"
	BetaResponseInputImageDetailAuto     BetaResponseInputImageDetail = "auto"
	BetaResponseInputImageDetailOriginal BetaResponseInputImageDetail = "original"
)

// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
// token block.
type BetaResponseInputImagePromptCacheBreakpoint struct {
	// The breakpoint mode. Always `explicit`.
	Mode constant.Explicit `json:"mode" default:"explicit"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Mode        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputImagePromptCacheBreakpoint) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputImagePromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// An image input to the model. Learn about
// [image inputs](https://platform.openai.com/docs/guides/vision).
//
// The properties Detail, Type are required.
type BetaResponseInputImageParam struct {
	// The detail level of the image to be sent to the model. One of `high`, `low`,
	// `auto`, or `original`. Defaults to `auto`.
	//
	// Any of "low", "high", "auto", "original".
	Detail BetaResponseInputImageDetail `json:"detail,omitzero" api:"required"`
	// The ID of the file to be sent to the model.
	FileID param.Opt[string] `json:"file_id,omitzero"`
	// The URL of the image to be sent to the model. A fully qualified URL or base64
	// encoded image in a data URL.
	ImageURL param.Opt[string] `json:"image_url,omitzero" format:"uri"`
	// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
	// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
	// token block.
	PromptCacheBreakpoint BetaResponseInputImagePromptCacheBreakpointParam `json:"prompt_cache_breakpoint,omitzero"`
	// The type of the input item. Always `input_image`.
	//
	// This field can be elided, and will marshal its zero value as "input_image".
	Type constant.InputImage `json:"type" default:"input_image"`
	paramObj
}

func (r BetaResponseInputImageParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputImageParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputImageParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func NewBetaResponseInputImagePromptCacheBreakpointParam() BetaResponseInputImagePromptCacheBreakpointParam {
	return BetaResponseInputImagePromptCacheBreakpointParam{
		Mode: "explicit",
	}
}

// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
// token block.
//
// This struct has a constant value, construct it with
// [NewBetaResponseInputImagePromptCacheBreakpointParam].
type BetaResponseInputImagePromptCacheBreakpointParam struct {
	// The breakpoint mode. Always `explicit`.
	Mode constant.Explicit `json:"mode" default:"explicit"`
	paramObj
}

func (r BetaResponseInputImagePromptCacheBreakpointParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputImagePromptCacheBreakpointParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputImagePromptCacheBreakpointParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// An image input to the model. Learn about
// [image inputs](https://platform.openai.com/docs/guides/vision)
type BetaResponseInputImageContent struct {
	// The type of the input item. Always `input_image`.
	Type constant.InputImage `json:"type" default:"input_image"`
	// The detail level of the image to be sent to the model. One of `high`, `low`,
	// `auto`, or `original`. Defaults to `auto`.
	//
	// Any of "low", "high", "auto", "original".
	Detail BetaResponseInputImageContentDetail `json:"detail" api:"nullable"`
	// The ID of the file to be sent to the model.
	FileID string `json:"file_id" api:"nullable"`
	// The URL of the image to be sent to the model. A fully qualified URL or base64
	// encoded image in a data URL.
	ImageURL string `json:"image_url" api:"nullable" format:"uri"`
	// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
	// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
	// token block.
	PromptCacheBreakpoint BetaResponseInputImageContentPromptCacheBreakpoint `json:"prompt_cache_breakpoint" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type                  respjson.Field
		Detail                respjson.Field
		FileID                respjson.Field
		ImageURL              respjson.Field
		PromptCacheBreakpoint respjson.Field
		ExtraFields           map[string]respjson.Field
		raw                   string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputImageContent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputImageContent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseInputImageContent to a
// BetaResponseInputImageContentParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseInputImageContentParam.Overrides()
func (r BetaResponseInputImageContent) ToParam() BetaResponseInputImageContentParam {
	return param.Override[BetaResponseInputImageContentParam](json.RawMessage(r.RawJSON()))
}

// The detail level of the image to be sent to the model. One of `high`, `low`,
// `auto`, or `original`. Defaults to `auto`.
type BetaResponseInputImageContentDetail string

const (
	BetaResponseInputImageContentDetailLow      BetaResponseInputImageContentDetail = "low"
	BetaResponseInputImageContentDetailHigh     BetaResponseInputImageContentDetail = "high"
	BetaResponseInputImageContentDetailAuto     BetaResponseInputImageContentDetail = "auto"
	BetaResponseInputImageContentDetailOriginal BetaResponseInputImageContentDetail = "original"
)

// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
// token block.
type BetaResponseInputImageContentPromptCacheBreakpoint struct {
	// The breakpoint mode. Always `explicit`.
	Mode constant.Explicit `json:"mode" default:"explicit"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Mode        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputImageContentPromptCacheBreakpoint) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputImageContentPromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// An image input to the model. Learn about
// [image inputs](https://platform.openai.com/docs/guides/vision)
//
// The property Type is required.
type BetaResponseInputImageContentParam struct {
	// The ID of the file to be sent to the model.
	FileID param.Opt[string] `json:"file_id,omitzero"`
	// The URL of the image to be sent to the model. A fully qualified URL or base64
	// encoded image in a data URL.
	ImageURL param.Opt[string] `json:"image_url,omitzero" format:"uri"`
	// The detail level of the image to be sent to the model. One of `high`, `low`,
	// `auto`, or `original`. Defaults to `auto`.
	//
	// Any of "low", "high", "auto", "original".
	Detail BetaResponseInputImageContentDetail `json:"detail,omitzero"`
	// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
	// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
	// token block.
	PromptCacheBreakpoint BetaResponseInputImageContentPromptCacheBreakpointParam `json:"prompt_cache_breakpoint,omitzero"`
	// The type of the input item. Always `input_image`.
	//
	// This field can be elided, and will marshal its zero value as "input_image".
	Type constant.InputImage `json:"type" default:"input_image"`
	paramObj
}

func (r BetaResponseInputImageContentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputImageContentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputImageContentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func NewBetaResponseInputImageContentPromptCacheBreakpointParam() BetaResponseInputImageContentPromptCacheBreakpointParam {
	return BetaResponseInputImageContentPromptCacheBreakpointParam{
		Mode: "explicit",
	}
}

// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
// token block.
//
// This struct has a constant value, construct it with
// [NewBetaResponseInputImageContentPromptCacheBreakpointParam].
type BetaResponseInputImageContentPromptCacheBreakpointParam struct {
	// The breakpoint mode. Always `explicit`.
	Mode constant.Explicit `json:"mode" default:"explicit"`
	paramObj
}

func (r BetaResponseInputImageContentPromptCacheBreakpointParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputImageContentPromptCacheBreakpointParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputImageContentPromptCacheBreakpointParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseInputItemUnion contains all possible properties and values from
// [BetaEasyInputMessage], [BetaResponseInputItemMessage],
// [BetaResponseOutputMessage], [BetaResponseFileSearchToolCall],
// [BetaResponseComputerToolCall], [BetaResponseInputItemComputerCallOutput],
// [BetaResponseFunctionWebSearch], [BetaResponseFunctionToolCall],
// [BetaResponseInputItemFunctionCallOutput], [BetaResponseInputItemAgentMessage],
// [BetaResponseInputItemMultiAgentCall],
// [BetaResponseInputItemMultiAgentCallOutput],
// [BetaResponseInputItemToolSearchCall],
// [BetaResponseToolSearchOutputItemParamResp],
// [BetaResponseInputItemAdditionalTools], [BetaResponseReasoningItem],
// [BetaResponseCompactionItemParamResp],
// [BetaResponseInputItemImageGenerationCall],
// [BetaResponseCodeInterpreterToolCall], [BetaResponseInputItemLocalShellCall],
// [BetaResponseInputItemLocalShellCallOutput], [BetaResponseInputItemShellCall],
// [BetaResponseInputItemShellCallOutput], [BetaResponseInputItemApplyPatchCall],
// [BetaResponseInputItemApplyPatchCallOutput],
// [BetaResponseInputItemMcpListTools], [BetaResponseInputItemMcpApprovalRequest],
// [BetaResponseInputItemMcpApprovalResponse], [BetaResponseInputItemMcpCall],
// [BetaResponseCustomToolCallOutput], [BetaResponseCustomToolCall],
// [BetaResponseInputItemCompactionTrigger], [BetaResponseInputItemItemReference],
// [BetaResponseInputItemProgram], [BetaResponseInputItemProgramOutput].
//
// Use the [BetaResponseInputItemUnion.AsAny] method to switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseInputItemUnion struct {
	// This field is a union of [BetaEasyInputMessageContentUnion],
	// [BetaResponseInputMessageContentList],
	// [[]BetaResponseOutputMessageContentUnion],
	// [[]BetaResponseInputItemAgentMessageContentUnion],
	// [[]BetaResponseReasoningItemContent]
	Content BetaResponseInputItemUnionContent `json:"content"`
	Role    string                            `json:"role"`
	Phase   string                            `json:"phase"`
	// Any of "message", "message", "message", "file_search_call", "computer_call",
	// "computer_call_output", "web_search_call", "function_call",
	// "function_call_output", "agent_message", "multi_agent_call",
	// "multi_agent_call_output", "tool_search_call", "tool_search_output",
	// "additional_tools", "reasoning", "compaction", "image_generation_call",
	// "code_interpreter_call", "local_shell_call", "local_shell_call_output",
	// "shell_call", "shell_call_output", "apply_patch_call",
	// "apply_patch_call_output", "mcp_list_tools", "mcp_approval_request",
	// "mcp_approval_response", "mcp_call", "custom_tool_call_output",
	// "custom_tool_call", "compaction_trigger", "item_reference", "program",
	// "program_output".
	Type string `json:"type"`
	// This field is a union of [BetaResponseInputItemMessageAgent],
	// [BetaResponseOutputMessageAgent], [BetaResponseFileSearchToolCallAgent],
	// [BetaResponseComputerToolCallAgent],
	// [BetaResponseInputItemComputerCallOutputAgent],
	// [BetaResponseFunctionWebSearchAgent], [BetaResponseFunctionToolCallAgent],
	// [BetaResponseInputItemFunctionCallOutputAgent],
	// [BetaResponseInputItemAgentMessageAgent],
	// [BetaResponseInputItemMultiAgentCallAgent],
	// [BetaResponseInputItemMultiAgentCallOutputAgent],
	// [BetaResponseInputItemToolSearchCallAgent],
	// [BetaResponseToolSearchOutputItemParamAgentResp],
	// [BetaResponseInputItemAdditionalToolsAgent], [BetaResponseReasoningItemAgent],
	// [BetaResponseCompactionItemParamAgentResp],
	// [BetaResponseInputItemImageGenerationCallAgent],
	// [BetaResponseCodeInterpreterToolCallAgent],
	// [BetaResponseInputItemLocalShellCallAgent],
	// [BetaResponseInputItemLocalShellCallOutputAgent],
	// [BetaResponseInputItemShellCallAgent],
	// [BetaResponseInputItemShellCallOutputAgent],
	// [BetaResponseInputItemApplyPatchCallAgent],
	// [BetaResponseInputItemApplyPatchCallOutputAgent],
	// [BetaResponseInputItemMcpListToolsAgent],
	// [BetaResponseInputItemMcpApprovalRequestAgent],
	// [BetaResponseInputItemMcpApprovalResponseAgent],
	// [BetaResponseInputItemMcpCallAgent], [BetaResponseCustomToolCallOutputAgent],
	// [BetaResponseCustomToolCallAgent],
	// [BetaResponseInputItemCompactionTriggerAgent],
	// [BetaResponseInputItemItemReferenceAgent], [BetaResponseInputItemProgramAgent],
	// [BetaResponseInputItemProgramOutputAgent]
	Agent  BetaResponseInputItemUnionAgent `json:"agent"`
	Status string                          `json:"status"`
	ID     string                          `json:"id"`
	// This field is from variant [BetaResponseFileSearchToolCall].
	Queries []string `json:"queries"`
	// This field is from variant [BetaResponseFileSearchToolCall].
	Results []BetaResponseFileSearchToolCallResult `json:"results"`
	CallID  string                                 `json:"call_id"`
	// This field is from variant [BetaResponseComputerToolCall].
	PendingSafetyChecks []BetaResponseComputerToolCallPendingSafetyCheck `json:"pending_safety_checks"`
	// This field is a union of [BetaComputerActionUnion],
	// [BetaResponseFunctionWebSearchActionUnion], [string], [string],
	// [BetaResponseInputItemLocalShellCallAction],
	// [BetaResponseInputItemShellCallAction]
	Action BetaResponseInputItemUnionAction `json:"action"`
	// This field is from variant [BetaResponseComputerToolCall].
	Actions BetaComputerActionList `json:"actions"`
	// This field is a union of [BetaResponseComputerToolCallOutputScreenshot],
	// [BetaResponseInputItemFunctionCallOutputOutputUnion],
	// [[]BetaResponseInputItemMultiAgentCallOutputOutput], [string],
	// [[]BetaResponseFunctionShellCallOutputContent], [string], [string],
	// [BetaResponseCustomToolCallOutputOutputUnion]
	Output BetaResponseInputItemUnionOutput `json:"output"`
	// This field is from variant [BetaResponseInputItemComputerCallOutput].
	AcknowledgedSafetyChecks []BetaResponseInputItemComputerCallOutputAcknowledgedSafetyCheck `json:"acknowledged_safety_checks"`
	// This field is a union of [string], [string], [any], [string], [string]
	Arguments BetaResponseInputItemUnionArguments `json:"arguments"`
	Name      string                              `json:"name"`
	// This field is a union of [BetaResponseFunctionToolCallCallerUnion],
	// [BetaResponseInputItemFunctionCallOutputCallerUnion],
	// [BetaResponseInputItemShellCallCallerUnion],
	// [BetaResponseInputItemShellCallOutputCallerUnion],
	// [BetaResponseInputItemApplyPatchCallCallerUnion],
	// [BetaResponseInputItemApplyPatchCallOutputCallerUnion],
	// [BetaResponseCustomToolCallOutputCallerUnion],
	// [BetaResponseCustomToolCallCallerUnion]
	Caller    BetaResponseInputItemUnionCaller `json:"caller"`
	Namespace string                           `json:"namespace"`
	// This field is from variant [BetaResponseInputItemAgentMessage].
	Author string `json:"author"`
	// This field is from variant [BetaResponseInputItemAgentMessage].
	Recipient string `json:"recipient"`
	Execution string `json:"execution"`
	// This field is a union of [[]BetaToolUnion], [[]BetaToolUnion],
	// [[]BetaResponseInputItemMcpListToolsTool]
	Tools BetaResponseInputItemUnionTools `json:"tools"`
	// This field is from variant [BetaResponseReasoningItem].
	Summary          []BetaResponseReasoningItemSummary `json:"summary"`
	EncryptedContent string                             `json:"encrypted_content"`
	Result           string                             `json:"result"`
	Code             string                             `json:"code"`
	// This field is from variant [BetaResponseCodeInterpreterToolCall].
	ContainerID string `json:"container_id"`
	// This field is from variant [BetaResponseCodeInterpreterToolCall].
	Outputs []BetaResponseCodeInterpreterToolCallOutputUnion `json:"outputs"`
	// This field is from variant [BetaResponseInputItemShellCall].
	Environment BetaResponseInputItemShellCallEnvironmentUnion `json:"environment"`
	// This field is from variant [BetaResponseInputItemShellCallOutput].
	MaxOutputLength int64 `json:"max_output_length"`
	// This field is from variant [BetaResponseInputItemApplyPatchCall].
	Operation         BetaResponseInputItemApplyPatchCallOperationUnion `json:"operation"`
	ServerLabel       string                                            `json:"server_label"`
	Error             string                                            `json:"error"`
	ApprovalRequestID string                                            `json:"approval_request_id"`
	// This field is from variant [BetaResponseInputItemMcpApprovalResponse].
	Approve bool `json:"approve"`
	// This field is from variant [BetaResponseInputItemMcpApprovalResponse].
	Reason string `json:"reason"`
	// This field is from variant [BetaResponseCustomToolCall].
	Input string `json:"input"`
	// This field is from variant [BetaResponseInputItemProgram].
	Fingerprint string `json:"fingerprint"`
	JSON        struct {
		Content                  respjson.Field
		Role                     respjson.Field
		Phase                    respjson.Field
		Type                     respjson.Field
		Agent                    respjson.Field
		Status                   respjson.Field
		ID                       respjson.Field
		Queries                  respjson.Field
		Results                  respjson.Field
		CallID                   respjson.Field
		PendingSafetyChecks      respjson.Field
		Action                   respjson.Field
		Actions                  respjson.Field
		Output                   respjson.Field
		AcknowledgedSafetyChecks respjson.Field
		Arguments                respjson.Field
		Name                     respjson.Field
		Caller                   respjson.Field
		Namespace                respjson.Field
		Author                   respjson.Field
		Recipient                respjson.Field
		Execution                respjson.Field
		Tools                    respjson.Field
		Summary                  respjson.Field
		EncryptedContent         respjson.Field
		Result                   respjson.Field
		Code                     respjson.Field
		ContainerID              respjson.Field
		Outputs                  respjson.Field
		Environment              respjson.Field
		MaxOutputLength          respjson.Field
		Operation                respjson.Field
		ServerLabel              respjson.Field
		Error                    respjson.Field
		ApprovalRequestID        respjson.Field
		Approve                  respjson.Field
		Reason                   respjson.Field
		Input                    respjson.Field
		Fingerprint              respjson.Field
		raw                      string
	} `json:"-"`
}

// anyBetaResponseInputItem is implemented by each variant of
// [BetaResponseInputItemUnion] to add type safety for the return type of
// [BetaResponseInputItemUnion.AsAny]
type anyBetaResponseInputItem interface {
	implBetaResponseInputItemUnion()
}

func (BetaEasyInputMessage) implBetaResponseInputItemUnion()                      {}
func (BetaResponseInputItemMessage) implBetaResponseInputItemUnion()              {}
func (BetaResponseOutputMessage) implBetaResponseInputItemUnion()                 {}
func (BetaResponseFileSearchToolCall) implBetaResponseInputItemUnion()            {}
func (BetaResponseComputerToolCall) implBetaResponseInputItemUnion()              {}
func (BetaResponseInputItemComputerCallOutput) implBetaResponseInputItemUnion()   {}
func (BetaResponseFunctionWebSearch) implBetaResponseInputItemUnion()             {}
func (BetaResponseFunctionToolCall) implBetaResponseInputItemUnion()              {}
func (BetaResponseInputItemFunctionCallOutput) implBetaResponseInputItemUnion()   {}
func (BetaResponseInputItemAgentMessage) implBetaResponseInputItemUnion()         {}
func (BetaResponseInputItemMultiAgentCall) implBetaResponseInputItemUnion()       {}
func (BetaResponseInputItemMultiAgentCallOutput) implBetaResponseInputItemUnion() {}
func (BetaResponseInputItemToolSearchCall) implBetaResponseInputItemUnion()       {}
func (BetaResponseToolSearchOutputItemParamResp) implBetaResponseInputItemUnion() {}
func (BetaResponseInputItemAdditionalTools) implBetaResponseInputItemUnion()      {}
func (BetaResponseReasoningItem) implBetaResponseInputItemUnion()                 {}
func (BetaResponseCompactionItemParamResp) implBetaResponseInputItemUnion()       {}
func (BetaResponseInputItemImageGenerationCall) implBetaResponseInputItemUnion()  {}
func (BetaResponseCodeInterpreterToolCall) implBetaResponseInputItemUnion()       {}
func (BetaResponseInputItemLocalShellCall) implBetaResponseInputItemUnion()       {}
func (BetaResponseInputItemLocalShellCallOutput) implBetaResponseInputItemUnion() {}
func (BetaResponseInputItemShellCall) implBetaResponseInputItemUnion()            {}
func (BetaResponseInputItemShellCallOutput) implBetaResponseInputItemUnion()      {}
func (BetaResponseInputItemApplyPatchCall) implBetaResponseInputItemUnion()       {}
func (BetaResponseInputItemApplyPatchCallOutput) implBetaResponseInputItemUnion() {}
func (BetaResponseInputItemMcpListTools) implBetaResponseInputItemUnion()         {}
func (BetaResponseInputItemMcpApprovalRequest) implBetaResponseInputItemUnion()   {}
func (BetaResponseInputItemMcpApprovalResponse) implBetaResponseInputItemUnion()  {}
func (BetaResponseInputItemMcpCall) implBetaResponseInputItemUnion()              {}
func (BetaResponseCustomToolCallOutput) implBetaResponseInputItemUnion()          {}
func (BetaResponseCustomToolCall) implBetaResponseInputItemUnion()                {}
func (BetaResponseInputItemCompactionTrigger) implBetaResponseInputItemUnion()    {}
func (BetaResponseInputItemItemReference) implBetaResponseInputItemUnion()        {}
func (BetaResponseInputItemProgram) implBetaResponseInputItemUnion()              {}
func (BetaResponseInputItemProgramOutput) implBetaResponseInputItemUnion()        {}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseInputItemUnion.AsAny().(type) {
//	case openai.BetaEasyInputMessage:
//	case openai.BetaResponseInputItemMessage:
//	case openai.BetaResponseOutputMessage:
//	case openai.BetaResponseFileSearchToolCall:
//	case openai.BetaResponseComputerToolCall:
//	case openai.BetaResponseInputItemComputerCallOutput:
//	case openai.BetaResponseFunctionWebSearch:
//	case openai.BetaResponseFunctionToolCall:
//	case openai.BetaResponseInputItemFunctionCallOutput:
//	case openai.BetaResponseInputItemAgentMessage:
//	case openai.BetaResponseInputItemMultiAgentCall:
//	case openai.BetaResponseInputItemMultiAgentCallOutput:
//	case openai.BetaResponseInputItemToolSearchCall:
//	case openai.BetaResponseToolSearchOutputItemParamResp:
//	case openai.BetaResponseInputItemAdditionalTools:
//	case openai.BetaResponseReasoningItem:
//	case openai.BetaResponseCompactionItemParamResp:
//	case openai.BetaResponseInputItemImageGenerationCall:
//	case openai.BetaResponseCodeInterpreterToolCall:
//	case openai.BetaResponseInputItemLocalShellCall:
//	case openai.BetaResponseInputItemLocalShellCallOutput:
//	case openai.BetaResponseInputItemShellCall:
//	case openai.BetaResponseInputItemShellCallOutput:
//	case openai.BetaResponseInputItemApplyPatchCall:
//	case openai.BetaResponseInputItemApplyPatchCallOutput:
//	case openai.BetaResponseInputItemMcpListTools:
//	case openai.BetaResponseInputItemMcpApprovalRequest:
//	case openai.BetaResponseInputItemMcpApprovalResponse:
//	case openai.BetaResponseInputItemMcpCall:
//	case openai.BetaResponseCustomToolCallOutput:
//	case openai.BetaResponseCustomToolCall:
//	case openai.BetaResponseInputItemCompactionTrigger:
//	case openai.BetaResponseInputItemItemReference:
//	case openai.BetaResponseInputItemProgram:
//	case openai.BetaResponseInputItemProgramOutput:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseInputItemUnion) AsAny() anyBetaResponseInputItem {
	switch u.Type {
	case "message":
		return u.AsOutputMessage()
	case "file_search_call":
		return u.AsFileSearchCall()
	case "computer_call":
		return u.AsComputerCall()
	case "computer_call_output":
		return u.AsComputerCallOutput()
	case "web_search_call":
		return u.AsWebSearchCall()
	case "function_call":
		return u.AsFunctionCall()
	case "function_call_output":
		return u.AsFunctionCallOutput()
	case "agent_message":
		return u.AsAgentMessage()
	case "multi_agent_call":
		return u.AsMultiAgentCall()
	case "multi_agent_call_output":
		return u.AsMultiAgentCallOutput()
	case "tool_search_call":
		return u.AsToolSearchCall()
	case "tool_search_output":
		return u.AsToolSearchOutput()
	case "additional_tools":
		return u.AsAdditionalTools()
	case "reasoning":
		return u.AsReasoning()
	case "compaction":
		return u.AsCompaction()
	case "image_generation_call":
		return u.AsImageGenerationCall()
	case "code_interpreter_call":
		return u.AsCodeInterpreterCall()
	case "local_shell_call":
		return u.AsLocalShellCall()
	case "local_shell_call_output":
		return u.AsLocalShellCallOutput()
	case "shell_call":
		return u.AsShellCall()
	case "shell_call_output":
		return u.AsShellCallOutput()
	case "apply_patch_call":
		return u.AsApplyPatchCall()
	case "apply_patch_call_output":
		return u.AsApplyPatchCallOutput()
	case "mcp_list_tools":
		return u.AsMcpListTools()
	case "mcp_approval_request":
		return u.AsMcpApprovalRequest()
	case "mcp_approval_response":
		return u.AsMcpApprovalResponse()
	case "mcp_call":
		return u.AsMcpCall()
	case "custom_tool_call_output":
		return u.AsCustomToolCallOutput()
	case "custom_tool_call":
		return u.AsCustomToolCall()
	case "compaction_trigger":
		return u.AsCompactionTrigger()
	case "item_reference":
		return u.AsItemReference()
	case "program":
		return u.AsProgram()
	case "program_output":
		return u.AsProgramOutput()
	}
	return nil
}

func (u BetaResponseInputItemUnion) AsMessage() (v BetaEasyInputMessage) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsInputMessage() (v BetaResponseInputItemMessage) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsOutputMessage() (v BetaResponseOutputMessage) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsFileSearchCall() (v BetaResponseFileSearchToolCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsComputerCall() (v BetaResponseComputerToolCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsComputerCallOutput() (v BetaResponseInputItemComputerCallOutput) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsWebSearchCall() (v BetaResponseFunctionWebSearch) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsFunctionCall() (v BetaResponseFunctionToolCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsFunctionCallOutput() (v BetaResponseInputItemFunctionCallOutput) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsAgentMessage() (v BetaResponseInputItemAgentMessage) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsMultiAgentCall() (v BetaResponseInputItemMultiAgentCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsMultiAgentCallOutput() (v BetaResponseInputItemMultiAgentCallOutput) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsToolSearchCall() (v BetaResponseInputItemToolSearchCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsToolSearchOutput() (v BetaResponseToolSearchOutputItemParamResp) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsAdditionalTools() (v BetaResponseInputItemAdditionalTools) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsReasoning() (v BetaResponseReasoningItem) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsCompaction() (v BetaResponseCompactionItemParamResp) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsImageGenerationCall() (v BetaResponseInputItemImageGenerationCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsCodeInterpreterCall() (v BetaResponseCodeInterpreterToolCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsLocalShellCall() (v BetaResponseInputItemLocalShellCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsLocalShellCallOutput() (v BetaResponseInputItemLocalShellCallOutput) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsShellCall() (v BetaResponseInputItemShellCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsShellCallOutput() (v BetaResponseInputItemShellCallOutput) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsApplyPatchCall() (v BetaResponseInputItemApplyPatchCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsApplyPatchCallOutput() (v BetaResponseInputItemApplyPatchCallOutput) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsMcpListTools() (v BetaResponseInputItemMcpListTools) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsMcpApprovalRequest() (v BetaResponseInputItemMcpApprovalRequest) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsMcpApprovalResponse() (v BetaResponseInputItemMcpApprovalResponse) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsMcpCall() (v BetaResponseInputItemMcpCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsCustomToolCallOutput() (v BetaResponseCustomToolCallOutput) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsCustomToolCall() (v BetaResponseCustomToolCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsCompactionTrigger() (v BetaResponseInputItemCompactionTrigger) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsItemReference() (v BetaResponseInputItemItemReference) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsProgram() (v BetaResponseInputItemProgram) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemUnion) AsProgramOutput() (v BetaResponseInputItemProgramOutput) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseInputItemUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseInputItemUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseInputItemUnionContent is an implicit subunion of
// [BetaResponseInputItemUnion]. BetaResponseInputItemUnionContent provides
// convenient access to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseInputItemUnion].
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfString OfInputItemContentList
// OfBetaResponseOutputMessageContentArray
// OfBetaResponseInputItemAgentMessageContentArray
// OfBetaResponseReasoningItemContentArray]
type BetaResponseInputItemUnionContent struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a
	// [BetaResponseInputMessageContentList] instead of an object.
	OfInputItemContentList BetaResponseInputMessageContentList `json:",inline"`
	// This field will be present if the value is a
	// [[]BetaResponseOutputMessageContentUnion] instead of an object.
	OfBetaResponseOutputMessageContentArray []BetaResponseOutputMessageContentUnion `json:",inline"`
	// This field will be present if the value is a
	// [[]BetaResponseInputItemAgentMessageContentUnion] instead of an object.
	OfBetaResponseInputItemAgentMessageContentArray []BetaResponseInputItemAgentMessageContentUnion `json:",inline"`
	// This field will be present if the value is a
	// [[]BetaResponseReasoningItemContent] instead of an object.
	OfBetaResponseReasoningItemContentArray []BetaResponseReasoningItemContent `json:",inline"`
	JSON                                    struct {
		OfString                                        respjson.Field
		OfInputItemContentList                          respjson.Field
		OfBetaResponseOutputMessageContentArray         respjson.Field
		OfBetaResponseInputItemAgentMessageContentArray respjson.Field
		OfBetaResponseReasoningItemContentArray         respjson.Field
		raw                                             string
	} `json:"-"`
}

func (r *BetaResponseInputItemUnionContent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseInputItemUnionAgent is an implicit subunion of
// [BetaResponseInputItemUnion]. BetaResponseInputItemUnionAgent provides
// convenient access to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseInputItemUnion].
type BetaResponseInputItemUnionAgent struct {
	AgentName string `json:"agent_name"`
	JSON      struct {
		AgentName respjson.Field
		raw       string
	} `json:"-"`
}

func (r *BetaResponseInputItemUnionAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseInputItemUnionAction is an implicit subunion of
// [BetaResponseInputItemUnion]. BetaResponseInputItemUnionAction provides
// convenient access to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseInputItemUnion].
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfBetaResponseInputItemMultiAgentCallOutputAction]
type BetaResponseInputItemUnionAction struct {
	// This field will be present if the value is a [string] instead of an object.
	OfBetaResponseInputItemMultiAgentCallOutputAction string `json:",inline"`
	// This field is from variant [BetaComputerActionUnion].
	Button string   `json:"button"`
	Type   string   `json:"type"`
	X      int64    `json:"x"`
	Y      int64    `json:"y"`
	Keys   []string `json:"keys"`
	// This field is from variant [BetaComputerActionUnion].
	Path []BetaComputerActionDragPath `json:"path"`
	// This field is from variant [BetaComputerActionUnion].
	ScrollX int64 `json:"scroll_x"`
	// This field is from variant [BetaComputerActionUnion].
	ScrollY int64 `json:"scroll_y"`
	// This field is from variant [BetaComputerActionUnion].
	Text string `json:"text"`
	// This field is from variant [BetaResponseFunctionWebSearchActionUnion].
	Queries []string `json:"queries"`
	// This field is from variant [BetaResponseFunctionWebSearchActionUnion].
	Query string `json:"query"`
	// This field is from variant [BetaResponseFunctionWebSearchActionUnion].
	Sources []BetaResponseFunctionWebSearchActionSearchSource `json:"sources"`
	URL     string                                            `json:"url"`
	// This field is from variant [BetaResponseFunctionWebSearchActionUnion].
	Pattern string `json:"pattern"`
	// This field is from variant [BetaResponseInputItemLocalShellCallAction].
	Command []string `json:"command"`
	// This field is from variant [BetaResponseInputItemLocalShellCallAction].
	Env       map[string]string `json:"env"`
	TimeoutMs int64             `json:"timeout_ms"`
	// This field is from variant [BetaResponseInputItemLocalShellCallAction].
	User string `json:"user"`
	// This field is from variant [BetaResponseInputItemLocalShellCallAction].
	WorkingDirectory string `json:"working_directory"`
	// This field is from variant [BetaResponseInputItemShellCallAction].
	Commands []string `json:"commands"`
	// This field is from variant [BetaResponseInputItemShellCallAction].
	MaxOutputLength int64 `json:"max_output_length"`
	JSON            struct {
		OfBetaResponseInputItemMultiAgentCallOutputAction respjson.Field
		Button                                            respjson.Field
		Type                                              respjson.Field
		X                                                 respjson.Field
		Y                                                 respjson.Field
		Keys                                              respjson.Field
		Path                                              respjson.Field
		ScrollX                                           respjson.Field
		ScrollY                                           respjson.Field
		Text                                              respjson.Field
		Queries                                           respjson.Field
		Query                                             respjson.Field
		Sources                                           respjson.Field
		URL                                               respjson.Field
		Pattern                                           respjson.Field
		Command                                           respjson.Field
		Env                                               respjson.Field
		TimeoutMs                                         respjson.Field
		User                                              respjson.Field
		WorkingDirectory                                  respjson.Field
		Commands                                          respjson.Field
		MaxOutputLength                                   respjson.Field
		raw                                               string
	} `json:"-"`
}

func (r *BetaResponseInputItemUnionAction) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseInputItemUnionOutput is an implicit subunion of
// [BetaResponseInputItemUnion]. BetaResponseInputItemUnionOutput provides
// convenient access to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseInputItemUnion].
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfString OfBetaResponseFunctionCallOutputItemArray
// OfBetaResponseInputItemMultiAgentCallOutputOutputArray
// OfBetaResponseFunctionShellCallOutputContentArray OfOutputContentList]
type BetaResponseInputItemUnionOutput struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a
	// [BetaResponseFunctionCallOutputItemList] instead of an object.
	OfBetaResponseFunctionCallOutputItemArray BetaResponseFunctionCallOutputItemList `json:",inline"`
	// This field will be present if the value is a
	// [[]BetaResponseInputItemMultiAgentCallOutputOutput] instead of an object.
	OfBetaResponseInputItemMultiAgentCallOutputOutputArray []BetaResponseInputItemMultiAgentCallOutputOutput `json:",inline"`
	// This field will be present if the value is a
	// [[]BetaResponseFunctionShellCallOutputContent] instead of an object.
	OfBetaResponseFunctionShellCallOutputContentArray []BetaResponseFunctionShellCallOutputContent `json:",inline"`
	// This field will be present if the value is a
	// [[]BetaResponseCustomToolCallOutputOutputOutputContentListItemUnion] instead of
	// an object.
	OfOutputContentList []BetaResponseCustomToolCallOutputOutputOutputContentListItemUnion `json:",inline"`
	// This field is from variant [BetaResponseComputerToolCallOutputScreenshot].
	Type constant.ComputerScreenshot `json:"type"`
	// This field is from variant [BetaResponseComputerToolCallOutputScreenshot].
	FileID string `json:"file_id"`
	// This field is from variant [BetaResponseComputerToolCallOutputScreenshot].
	ImageURL string `json:"image_url"`
	JSON     struct {
		OfString                                               respjson.Field
		OfBetaResponseFunctionCallOutputItemArray              respjson.Field
		OfBetaResponseInputItemMultiAgentCallOutputOutputArray respjson.Field
		OfBetaResponseFunctionShellCallOutputContentArray      respjson.Field
		OfOutputContentList                                    respjson.Field
		Type                                                   respjson.Field
		FileID                                                 respjson.Field
		ImageURL                                               respjson.Field
		raw                                                    string
	} `json:"-"`
}

func (r *BetaResponseInputItemUnionOutput) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseInputItemUnionArguments is an implicit subunion of
// [BetaResponseInputItemUnion]. BetaResponseInputItemUnionArguments provides
// convenient access to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseInputItemUnion].
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfString OfBetaResponseInputItemToolSearchCallArguments]
type BetaResponseInputItemUnionArguments struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a [any] instead of an object.
	OfBetaResponseInputItemToolSearchCallArguments any `json:",inline"`
	JSON                                           struct {
		OfString                                       respjson.Field
		OfBetaResponseInputItemToolSearchCallArguments respjson.Field
		raw                                            string
	} `json:"-"`
}

func (r *BetaResponseInputItemUnionArguments) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseInputItemUnionCaller is an implicit subunion of
// [BetaResponseInputItemUnion]. BetaResponseInputItemUnionCaller provides
// convenient access to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseInputItemUnion].
type BetaResponseInputItemUnionCaller struct {
	Type     string `json:"type"`
	CallerID string `json:"caller_id"`
	JSON     struct {
		Type     respjson.Field
		CallerID respjson.Field
		raw      string
	} `json:"-"`
}

func (r *BetaResponseInputItemUnionCaller) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseInputItemUnionTools is an implicit subunion of
// [BetaResponseInputItemUnion]. BetaResponseInputItemUnionTools provides
// convenient access to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseInputItemUnion].
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfBetaToolArray OfBetaResponseInputItemMcpListToolsTools]
type BetaResponseInputItemUnionTools struct {
	// This field will be present if the value is a [[]BetaToolUnion] instead of an
	// object.
	OfBetaToolArray []BetaToolUnion `json:",inline"`
	// This field will be present if the value is a
	// [[]BetaResponseInputItemMcpListToolsTool] instead of an object.
	OfBetaResponseInputItemMcpListToolsTools []BetaResponseInputItemMcpListToolsTool `json:",inline"`
	JSON                                     struct {
		OfBetaToolArray                          respjson.Field
		OfBetaResponseInputItemMcpListToolsTools respjson.Field
		raw                                      string
	} `json:"-"`
}

func (r *BetaResponseInputItemUnionTools) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseInputItemUnion to a
// BetaResponseInputItemUnionParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseInputItemUnionParam.Overrides()
func (r BetaResponseInputItemUnion) ToParam() BetaResponseInputItemUnionParam {
	return param.Override[BetaResponseInputItemUnionParam](json.RawMessage(r.RawJSON()))
}

// A message input to the model with a role indicating instruction following
// hierarchy. Instructions given with the `developer` or `system` role take
// precedence over instructions given with the `user` role.
type BetaResponseInputItemMessage struct {
	// A list of one or many input items to the model, containing different content
	// types.
	Content BetaResponseInputMessageContentList `json:"content" api:"required"`
	// The role of the message input. One of `user`, `system`, or `developer`.
	//
	// Any of "user", "system", "developer".
	Role string `json:"role" api:"required"`
	// The agent that produced this item.
	Agent BetaResponseInputItemMessageAgent `json:"agent" api:"nullable"`
	// The status of item. One of `in_progress`, `completed`, or `incomplete`.
	// Populated when items are returned via API.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status string `json:"status"`
	// The type of the message input. Always set to `message`.
	//
	// Any of "message".
	Type string `json:"type"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		Role        respjson.Field
		Agent       respjson.Field
		Status      respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemMessage) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemMessage) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseInputItemMessageAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemMessageAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemMessageAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The output of a computer tool call.
type BetaResponseInputItemComputerCallOutput struct {
	// The ID of the computer tool call that produced the output.
	CallID string `json:"call_id" api:"required"`
	// A computer screenshot image used with the computer use tool.
	Output BetaResponseComputerToolCallOutputScreenshot `json:"output" api:"required"`
	// The type of the computer tool call output. Always `computer_call_output`.
	Type constant.ComputerCallOutput `json:"type" default:"computer_call_output"`
	// The ID of the computer tool call output.
	ID string `json:"id" api:"nullable"`
	// The safety checks reported by the API that have been acknowledged by the
	// developer.
	AcknowledgedSafetyChecks []BetaResponseInputItemComputerCallOutputAcknowledgedSafetyCheck `json:"acknowledged_safety_checks" api:"nullable"`
	// The agent that produced this item.
	Agent BetaResponseInputItemComputerCallOutputAgent `json:"agent" api:"nullable"`
	// The status of the message input. One of `in_progress`, `completed`, or
	// `incomplete`. Populated when input items are returned via API.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status string `json:"status" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CallID                   respjson.Field
		Output                   respjson.Field
		Type                     respjson.Field
		ID                       respjson.Field
		AcknowledgedSafetyChecks respjson.Field
		Agent                    respjson.Field
		Status                   respjson.Field
		ExtraFields              map[string]respjson.Field
		raw                      string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemComputerCallOutput) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemComputerCallOutput) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A pending safety check for the computer call.
type BetaResponseInputItemComputerCallOutputAcknowledgedSafetyCheck struct {
	// The ID of the pending safety check.
	ID string `json:"id" api:"required"`
	// The type of the pending safety check.
	Code string `json:"code" api:"nullable"`
	// Details about the pending safety check.
	Message string `json:"message" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Code        respjson.Field
		Message     respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemComputerCallOutputAcknowledgedSafetyCheck) RawJSON() string {
	return r.JSON.raw
}
func (r *BetaResponseInputItemComputerCallOutputAcknowledgedSafetyCheck) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseInputItemComputerCallOutputAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemComputerCallOutputAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemComputerCallOutputAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The output of a function tool call.
type BetaResponseInputItemFunctionCallOutput struct {
	// The unique ID of the function tool call generated by the model.
	CallID string `json:"call_id" api:"required"`
	// Text, image, or file output of the function tool call.
	Output BetaResponseInputItemFunctionCallOutputOutputUnion `json:"output" api:"required"`
	// The type of the function tool call output. Always `function_call_output`.
	Type constant.FunctionCallOutput `json:"type" default:"function_call_output"`
	// The unique ID of the function tool call output. Populated when this item is
	// returned via API.
	ID string `json:"id" api:"nullable"`
	// The agent that produced this item.
	Agent BetaResponseInputItemFunctionCallOutputAgent `json:"agent" api:"nullable"`
	// The execution context that produced this tool call.
	Caller BetaResponseInputItemFunctionCallOutputCallerUnion `json:"caller" api:"nullable"`
	// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
	// Populated when items are returned via API.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status string `json:"status" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CallID      respjson.Field
		Output      respjson.Field
		Type        respjson.Field
		ID          respjson.Field
		Agent       respjson.Field
		Caller      respjson.Field
		Status      respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemFunctionCallOutput) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemFunctionCallOutput) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseInputItemFunctionCallOutputOutputUnion contains all possible
// properties and values from [string], [BetaResponseFunctionCallOutputItemList].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfString OfBetaResponseFunctionCallOutputItemArray]
type BetaResponseInputItemFunctionCallOutputOutputUnion struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a
	// [BetaResponseFunctionCallOutputItemList] instead of an object.
	OfBetaResponseFunctionCallOutputItemArray BetaResponseFunctionCallOutputItemList `json:",inline"`
	JSON                                      struct {
		OfString                                  respjson.Field
		OfBetaResponseFunctionCallOutputItemArray respjson.Field
		raw                                       string
	} `json:"-"`
}

func (u BetaResponseInputItemFunctionCallOutputOutputUnion) AsString() (v string) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemFunctionCallOutputOutputUnion) AsBetaResponseFunctionCallOutputItemArray() (v BetaResponseFunctionCallOutputItemList) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseInputItemFunctionCallOutputOutputUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseInputItemFunctionCallOutputOutputUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseInputItemFunctionCallOutputAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemFunctionCallOutputAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemFunctionCallOutputAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseInputItemFunctionCallOutputCallerUnion contains all possible
// properties and values from
// [BetaResponseInputItemFunctionCallOutputCallerDirect],
// [BetaResponseInputItemFunctionCallOutputCallerProgram].
//
// Use the [BetaResponseInputItemFunctionCallOutputCallerUnion.AsAny] method to
// switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseInputItemFunctionCallOutputCallerUnion struct {
	// Any of "direct", "program".
	Type string `json:"type"`
	// This field is from variant
	// [BetaResponseInputItemFunctionCallOutputCallerProgram].
	CallerID string `json:"caller_id"`
	JSON     struct {
		Type     respjson.Field
		CallerID respjson.Field
		raw      string
	} `json:"-"`
}

// anyBetaResponseInputItemFunctionCallOutputCaller is implemented by each variant
// of [BetaResponseInputItemFunctionCallOutputCallerUnion] to add type safety for
// the return type of [BetaResponseInputItemFunctionCallOutputCallerUnion.AsAny]
type anyBetaResponseInputItemFunctionCallOutputCaller interface {
	implBetaResponseInputItemFunctionCallOutputCallerUnion()
}

func (BetaResponseInputItemFunctionCallOutputCallerDirect) implBetaResponseInputItemFunctionCallOutputCallerUnion() {
}
func (BetaResponseInputItemFunctionCallOutputCallerProgram) implBetaResponseInputItemFunctionCallOutputCallerUnion() {
}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseInputItemFunctionCallOutputCallerUnion.AsAny().(type) {
//	case openai.BetaResponseInputItemFunctionCallOutputCallerDirect:
//	case openai.BetaResponseInputItemFunctionCallOutputCallerProgram:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseInputItemFunctionCallOutputCallerUnion) AsAny() anyBetaResponseInputItemFunctionCallOutputCaller {
	switch u.Type {
	case "direct":
		return u.AsDirect()
	case "program":
		return u.AsProgram()
	}
	return nil
}

func (u BetaResponseInputItemFunctionCallOutputCallerUnion) AsDirect() (v BetaResponseInputItemFunctionCallOutputCallerDirect) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemFunctionCallOutputCallerUnion) AsProgram() (v BetaResponseInputItemFunctionCallOutputCallerProgram) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseInputItemFunctionCallOutputCallerUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseInputItemFunctionCallOutputCallerUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseInputItemFunctionCallOutputCallerDirect struct {
	// The caller type. Always `direct`.
	Type constant.Direct `json:"type" default:"direct"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemFunctionCallOutputCallerDirect) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemFunctionCallOutputCallerDirect) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseInputItemFunctionCallOutputCallerProgram struct {
	// The call ID of the program item that produced this tool call.
	CallerID string `json:"caller_id" api:"required"`
	// The caller type. Always `program`.
	Type constant.Program `json:"type" default:"program"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CallerID    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemFunctionCallOutputCallerProgram) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemFunctionCallOutputCallerProgram) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A message routed between agents.
type BetaResponseInputItemAgentMessage struct {
	// The sending agent identity.
	Author string `json:"author" api:"required"`
	// Plaintext, image, or encrypted content sent between agents.
	Content []BetaResponseInputItemAgentMessageContentUnion `json:"content" api:"required"`
	// The destination agent identity.
	Recipient string `json:"recipient" api:"required"`
	// The item type. Always `agent_message`.
	Type constant.AgentMessage `json:"type" default:"agent_message"`
	// The unique ID of this agent message item.
	ID string `json:"id" api:"nullable"`
	// The agent that produced this item.
	Agent BetaResponseInputItemAgentMessageAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Author      respjson.Field
		Content     respjson.Field
		Recipient   respjson.Field
		Type        respjson.Field
		ID          respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemAgentMessage) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemAgentMessage) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseInputItemAgentMessageContentUnion contains all possible properties
// and values from [BetaResponseInputTextContent], [BetaResponseInputImageContent],
// [BetaResponseInputItemAgentMessageContentEncryptedContent].
//
// Use the [BetaResponseInputItemAgentMessageContentUnion.AsAny] method to switch
// on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseInputItemAgentMessageContentUnion struct {
	// This field is from variant [BetaResponseInputTextContent].
	Text string `json:"text"`
	// Any of "input_text", "input_image", "encrypted_content".
	Type string `json:"type"`
	// This field is a union of [BetaResponseInputTextContentPromptCacheBreakpoint],
	// [BetaResponseInputImageContentPromptCacheBreakpoint]
	PromptCacheBreakpoint BetaResponseInputItemAgentMessageContentUnionPromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
	// This field is from variant [BetaResponseInputImageContent].
	Detail BetaResponseInputImageContentDetail `json:"detail"`
	// This field is from variant [BetaResponseInputImageContent].
	FileID string `json:"file_id"`
	// This field is from variant [BetaResponseInputImageContent].
	ImageURL string `json:"image_url"`
	// This field is from variant
	// [BetaResponseInputItemAgentMessageContentEncryptedContent].
	EncryptedContent string `json:"encrypted_content"`
	JSON             struct {
		Text                  respjson.Field
		Type                  respjson.Field
		PromptCacheBreakpoint respjson.Field
		Detail                respjson.Field
		FileID                respjson.Field
		ImageURL              respjson.Field
		EncryptedContent      respjson.Field
		raw                   string
	} `json:"-"`
}

// anyBetaResponseInputItemAgentMessageContent is implemented by each variant of
// [BetaResponseInputItemAgentMessageContentUnion] to add type safety for the
// return type of [BetaResponseInputItemAgentMessageContentUnion.AsAny]
type anyBetaResponseInputItemAgentMessageContent interface {
	implBetaResponseInputItemAgentMessageContentUnion()
}

func (BetaResponseInputTextContent) implBetaResponseInputItemAgentMessageContentUnion()  {}
func (BetaResponseInputImageContent) implBetaResponseInputItemAgentMessageContentUnion() {}
func (BetaResponseInputItemAgentMessageContentEncryptedContent) implBetaResponseInputItemAgentMessageContentUnion() {
}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseInputItemAgentMessageContentUnion.AsAny().(type) {
//	case openai.BetaResponseInputTextContent:
//	case openai.BetaResponseInputImageContent:
//	case openai.BetaResponseInputItemAgentMessageContentEncryptedContent:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseInputItemAgentMessageContentUnion) AsAny() anyBetaResponseInputItemAgentMessageContent {
	switch u.Type {
	case "input_text":
		return u.AsInputText()
	case "input_image":
		return u.AsInputImage()
	case "encrypted_content":
		return u.AsEncryptedContent()
	}
	return nil
}

func (u BetaResponseInputItemAgentMessageContentUnion) AsInputText() (v BetaResponseInputTextContent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemAgentMessageContentUnion) AsInputImage() (v BetaResponseInputImageContent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemAgentMessageContentUnion) AsEncryptedContent() (v BetaResponseInputItemAgentMessageContentEncryptedContent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseInputItemAgentMessageContentUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseInputItemAgentMessageContentUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseInputItemAgentMessageContentUnionPromptCacheBreakpoint is an
// implicit subunion of [BetaResponseInputItemAgentMessageContentUnion].
// BetaResponseInputItemAgentMessageContentUnionPromptCacheBreakpoint provides
// convenient access to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseInputItemAgentMessageContentUnion].
type BetaResponseInputItemAgentMessageContentUnionPromptCacheBreakpoint struct {
	// This field is from variant [BetaResponseInputTextContentPromptCacheBreakpoint].
	Mode constant.Explicit `json:"mode"`
	JSON struct {
		Mode respjson.Field
		raw  string
	} `json:"-"`
}

func (r *BetaResponseInputItemAgentMessageContentUnionPromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Opaque encrypted content that Responses API decrypts inside trusted model
// execution.
type BetaResponseInputItemAgentMessageContentEncryptedContent struct {
	// Opaque encrypted content.
	EncryptedContent string `json:"encrypted_content" api:"required"`
	// The type of the input item. Always `encrypted_content`.
	Type constant.EncryptedContent `json:"type" default:"encrypted_content"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		EncryptedContent respjson.Field
		Type             respjson.Field
		ExtraFields      map[string]respjson.Field
		raw              string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemAgentMessageContentEncryptedContent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemAgentMessageContentEncryptedContent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseInputItemAgentMessageAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemAgentMessageAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemAgentMessageAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseInputItemMultiAgentCall struct {
	// The multi-agent action that was executed.
	//
	// Any of "spawn_agent", "interrupt_agent", "list_agents", "send_message",
	// "followup_task", "wait_agent".
	Action string `json:"action" api:"required"`
	// The action arguments as a JSON string.
	Arguments string `json:"arguments" api:"required"`
	// The unique ID linking this call to its output.
	CallID string `json:"call_id" api:"required"`
	// The item type. Always `multi_agent_call`.
	Type constant.MultiAgentCall `json:"type" default:"multi_agent_call"`
	// The unique ID of this multi-agent call.
	ID string `json:"id" api:"nullable"`
	// The agent that produced this item.
	Agent BetaResponseInputItemMultiAgentCallAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Action      respjson.Field
		Arguments   respjson.Field
		CallID      respjson.Field
		Type        respjson.Field
		ID          respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemMultiAgentCall) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemMultiAgentCall) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseInputItemMultiAgentCallAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemMultiAgentCallAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemMultiAgentCallAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseInputItemMultiAgentCallOutput struct {
	// The multi-agent action that produced this result.
	//
	// Any of "spawn_agent", "interrupt_agent", "list_agents", "send_message",
	// "followup_task", "wait_agent".
	Action string `json:"action" api:"required"`
	// The unique ID of the multi-agent call.
	CallID string `json:"call_id" api:"required"`
	// Text output returned by the multi-agent action.
	Output []BetaResponseInputItemMultiAgentCallOutputOutput `json:"output" api:"required"`
	// The item type. Always `multi_agent_call_output`.
	Type constant.MultiAgentCallOutput `json:"type" default:"multi_agent_call_output"`
	// The unique ID of this multi-agent call output.
	ID string `json:"id" api:"nullable"`
	// The agent that produced this item.
	Agent BetaResponseInputItemMultiAgentCallOutputAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Action      respjson.Field
		CallID      respjson.Field
		Output      respjson.Field
		Type        respjson.Field
		ID          respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemMultiAgentCallOutput) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemMultiAgentCallOutput) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseInputItemMultiAgentCallOutputOutput struct {
	// The text content.
	Text string `json:"text" api:"required"`
	// The content type. Always `output_text`.
	Type constant.OutputText `json:"type" default:"output_text"`
	// Citations associated with the text content.
	Annotations []BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnion `json:"annotations"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text        respjson.Field
		Type        respjson.Field
		Annotations respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemMultiAgentCallOutputOutput) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemMultiAgentCallOutputOutput) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnion contains all
// possible properties and values from
// [BetaResponseInputItemMultiAgentCallOutputOutputAnnotationFileCitation],
// [BetaResponseInputItemMultiAgentCallOutputOutputAnnotationURLCitation],
// [BetaResponseInputItemMultiAgentCallOutputOutputAnnotationContainerFileCitation].
//
// Use the [BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnion.AsAny]
// method to switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnion struct {
	FileID   string `json:"file_id"`
	Filename string `json:"filename"`
	// This field is from variant
	// [BetaResponseInputItemMultiAgentCallOutputOutputAnnotationFileCitation].
	Index int64 `json:"index"`
	// Any of "file_citation", "url_citation", "container_file_citation".
	Type       string `json:"type"`
	EndIndex   int64  `json:"end_index"`
	StartIndex int64  `json:"start_index"`
	// This field is from variant
	// [BetaResponseInputItemMultiAgentCallOutputOutputAnnotationURLCitation].
	Title string `json:"title"`
	// This field is from variant
	// [BetaResponseInputItemMultiAgentCallOutputOutputAnnotationURLCitation].
	URL string `json:"url"`
	// This field is from variant
	// [BetaResponseInputItemMultiAgentCallOutputOutputAnnotationContainerFileCitation].
	ContainerID string `json:"container_id"`
	JSON        struct {
		FileID      respjson.Field
		Filename    respjson.Field
		Index       respjson.Field
		Type        respjson.Field
		EndIndex    respjson.Field
		StartIndex  respjson.Field
		Title       respjson.Field
		URL         respjson.Field
		ContainerID respjson.Field
		raw         string
	} `json:"-"`
}

// anyBetaResponseInputItemMultiAgentCallOutputOutputAnnotation is implemented by
// each variant of [BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnion]
// to add type safety for the return type of
// [BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnion.AsAny]
type anyBetaResponseInputItemMultiAgentCallOutputOutputAnnotation interface {
	implBetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnion()
}

func (BetaResponseInputItemMultiAgentCallOutputOutputAnnotationFileCitation) implBetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnion() {
}
func (BetaResponseInputItemMultiAgentCallOutputOutputAnnotationURLCitation) implBetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnion() {
}
func (BetaResponseInputItemMultiAgentCallOutputOutputAnnotationContainerFileCitation) implBetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnion() {
}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnion.AsAny().(type) {
//	case openai.BetaResponseInputItemMultiAgentCallOutputOutputAnnotationFileCitation:
//	case openai.BetaResponseInputItemMultiAgentCallOutputOutputAnnotationURLCitation:
//	case openai.BetaResponseInputItemMultiAgentCallOutputOutputAnnotationContainerFileCitation:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnion) AsAny() anyBetaResponseInputItemMultiAgentCallOutputOutputAnnotation {
	switch u.Type {
	case "file_citation":
		return u.AsFileCitation()
	case "url_citation":
		return u.AsURLCitation()
	case "container_file_citation":
		return u.AsContainerFileCitation()
	}
	return nil
}

func (u BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnion) AsFileCitation() (v BetaResponseInputItemMultiAgentCallOutputOutputAnnotationFileCitation) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnion) AsURLCitation() (v BetaResponseInputItemMultiAgentCallOutputOutputAnnotationURLCitation) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnion) AsContainerFileCitation() (v BetaResponseInputItemMultiAgentCallOutputOutputAnnotationContainerFileCitation) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnion) RawJSON() string {
	return u.JSON.raw
}

func (r *BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseInputItemMultiAgentCallOutputOutputAnnotationFileCitation struct {
	// The ID of the file.
	FileID string `json:"file_id" api:"required"`
	// The filename of the file cited.
	Filename string `json:"filename" api:"required"`
	// The index of the file in the list of files.
	Index int64 `json:"index" api:"required"`
	// The citation type. Always `file_citation`.
	Type constant.FileCitation `json:"type" default:"file_citation"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FileID      respjson.Field
		Filename    respjson.Field
		Index       respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemMultiAgentCallOutputOutputAnnotationFileCitation) RawJSON() string {
	return r.JSON.raw
}
func (r *BetaResponseInputItemMultiAgentCallOutputOutputAnnotationFileCitation) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseInputItemMultiAgentCallOutputOutputAnnotationURLCitation struct {
	// The index of the last character of the citation in the message.
	EndIndex int64 `json:"end_index" api:"required"`
	// The index of the first character of the citation in the message.
	StartIndex int64 `json:"start_index" api:"required"`
	// The title of the cited resource.
	Title string `json:"title" api:"required"`
	// The citation type. Always `url_citation`.
	Type constant.URLCitation `json:"type" default:"url_citation"`
	// The URL of the cited resource.
	URL string `json:"url" api:"required" format:"uri"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		EndIndex    respjson.Field
		StartIndex  respjson.Field
		Title       respjson.Field
		Type        respjson.Field
		URL         respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemMultiAgentCallOutputOutputAnnotationURLCitation) RawJSON() string {
	return r.JSON.raw
}
func (r *BetaResponseInputItemMultiAgentCallOutputOutputAnnotationURLCitation) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseInputItemMultiAgentCallOutputOutputAnnotationContainerFileCitation struct {
	// The ID of the container.
	ContainerID string `json:"container_id" api:"required"`
	// The index of the last character of the citation in the message.
	EndIndex int64 `json:"end_index" api:"required"`
	// The ID of the container file.
	FileID string `json:"file_id" api:"required"`
	// The filename of the container file cited.
	Filename string `json:"filename" api:"required"`
	// The index of the first character of the citation in the message.
	StartIndex int64 `json:"start_index" api:"required"`
	// The citation type. Always `container_file_citation`.
	Type constant.ContainerFileCitation `json:"type" default:"container_file_citation"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ContainerID respjson.Field
		EndIndex    respjson.Field
		FileID      respjson.Field
		Filename    respjson.Field
		StartIndex  respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemMultiAgentCallOutputOutputAnnotationContainerFileCitation) RawJSON() string {
	return r.JSON.raw
}
func (r *BetaResponseInputItemMultiAgentCallOutputOutputAnnotationContainerFileCitation) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseInputItemMultiAgentCallOutputAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemMultiAgentCallOutputAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemMultiAgentCallOutputAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseInputItemToolSearchCall struct {
	// The arguments supplied to the tool search call.
	Arguments any `json:"arguments" api:"required"`
	// The item type. Always `tool_search_call`.
	Type constant.ToolSearchCall `json:"type" default:"tool_search_call"`
	// The unique ID of this tool search call.
	ID string `json:"id" api:"nullable"`
	// The agent that produced this item.
	Agent BetaResponseInputItemToolSearchCallAgent `json:"agent" api:"nullable"`
	// The unique ID of the tool search call generated by the model.
	CallID string `json:"call_id" api:"nullable"`
	// Whether tool search was executed by the server or by the client.
	//
	// Any of "server", "client".
	Execution string `json:"execution"`
	// The status of the tool search call.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status string `json:"status" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Arguments   respjson.Field
		Type        respjson.Field
		ID          respjson.Field
		Agent       respjson.Field
		CallID      respjson.Field
		Execution   respjson.Field
		Status      respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemToolSearchCall) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemToolSearchCall) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseInputItemToolSearchCallAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemToolSearchCallAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemToolSearchCallAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseInputItemAdditionalTools struct {
	// The role that provided the additional tools. Only `developer` is supported.
	Role constant.Developer `json:"role" default:"developer"`
	// A list of additional tools made available at this item.
	Tools []BetaToolUnion `json:"tools" api:"required"`
	// The item type. Always `additional_tools`.
	Type constant.AdditionalTools `json:"type" default:"additional_tools"`
	// The unique ID of this additional tools item.
	ID string `json:"id" api:"nullable"`
	// The agent that produced this item.
	Agent BetaResponseInputItemAdditionalToolsAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Role        respjson.Field
		Tools       respjson.Field
		Type        respjson.Field
		ID          respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemAdditionalTools) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemAdditionalTools) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseInputItemAdditionalToolsAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemAdditionalToolsAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemAdditionalToolsAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// An image generation request made by the model.
type BetaResponseInputItemImageGenerationCall struct {
	// The unique ID of the image generation call.
	ID string `json:"id" api:"required"`
	// The generated image encoded in base64.
	Result string `json:"result" api:"required"`
	// The status of the image generation call.
	//
	// Any of "in_progress", "completed", "generating", "failed".
	Status string `json:"status" api:"required"`
	// The type of the image generation call. Always `image_generation_call`.
	Type constant.ImageGenerationCall `json:"type" default:"image_generation_call"`
	// The agent that produced this item.
	Agent BetaResponseInputItemImageGenerationCallAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Result      respjson.Field
		Status      respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemImageGenerationCall) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemImageGenerationCall) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseInputItemImageGenerationCallAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemImageGenerationCallAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemImageGenerationCallAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool call to run a command on the local shell.
type BetaResponseInputItemLocalShellCall struct {
	// The unique ID of the local shell call.
	ID string `json:"id" api:"required"`
	// Execute a shell command on the server.
	Action BetaResponseInputItemLocalShellCallAction `json:"action" api:"required"`
	// The unique ID of the local shell tool call generated by the model.
	CallID string `json:"call_id" api:"required"`
	// The status of the local shell call.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status string `json:"status" api:"required"`
	// The type of the local shell call. Always `local_shell_call`.
	Type constant.LocalShellCall `json:"type" default:"local_shell_call"`
	// The agent that produced this item.
	Agent BetaResponseInputItemLocalShellCallAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Action      respjson.Field
		CallID      respjson.Field
		Status      respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemLocalShellCall) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemLocalShellCall) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Execute a shell command on the server.
type BetaResponseInputItemLocalShellCallAction struct {
	// The command to run.
	Command []string `json:"command" api:"required"`
	// Environment variables to set for the command.
	Env map[string]string `json:"env" api:"required"`
	// The type of the local shell action. Always `exec`.
	Type constant.Exec `json:"type" default:"exec"`
	// Optional timeout in milliseconds for the command.
	TimeoutMs int64 `json:"timeout_ms" api:"nullable"`
	// Optional user to run the command as.
	User string `json:"user" api:"nullable"`
	// Optional working directory to run the command in.
	WorkingDirectory string `json:"working_directory" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Command          respjson.Field
		Env              respjson.Field
		Type             respjson.Field
		TimeoutMs        respjson.Field
		User             respjson.Field
		WorkingDirectory respjson.Field
		ExtraFields      map[string]respjson.Field
		raw              string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemLocalShellCallAction) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemLocalShellCallAction) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseInputItemLocalShellCallAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemLocalShellCallAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemLocalShellCallAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The output of a local shell tool call.
type BetaResponseInputItemLocalShellCallOutput struct {
	// The unique ID of the local shell tool call generated by the model.
	ID string `json:"id" api:"required"`
	// A JSON string of the output of the local shell tool call.
	Output string `json:"output" api:"required"`
	// The type of the local shell tool call output. Always `local_shell_call_output`.
	Type constant.LocalShellCallOutput `json:"type" default:"local_shell_call_output"`
	// The agent that produced this item.
	Agent BetaResponseInputItemLocalShellCallOutputAgent `json:"agent" api:"nullable"`
	// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status string `json:"status" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Output      respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		Status      respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemLocalShellCallOutput) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemLocalShellCallOutput) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseInputItemLocalShellCallOutputAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemLocalShellCallOutputAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemLocalShellCallOutputAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool representing a request to execute one or more shell commands.
type BetaResponseInputItemShellCall struct {
	// The shell commands and limits that describe how to run the tool call.
	Action BetaResponseInputItemShellCallAction `json:"action" api:"required"`
	// The unique ID of the shell tool call generated by the model.
	CallID string `json:"call_id" api:"required"`
	// The type of the item. Always `shell_call`.
	Type constant.ShellCall `json:"type" default:"shell_call"`
	// The unique ID of the shell tool call. Populated when this item is returned via
	// API.
	ID string `json:"id" api:"nullable"`
	// The agent that produced this item.
	Agent BetaResponseInputItemShellCallAgent `json:"agent" api:"nullable"`
	// The execution context that produced this tool call.
	Caller BetaResponseInputItemShellCallCallerUnion `json:"caller" api:"nullable"`
	// The environment to execute the shell commands in.
	Environment BetaResponseInputItemShellCallEnvironmentUnion `json:"environment" api:"nullable"`
	// The status of the shell call. One of `in_progress`, `completed`, or
	// `incomplete`.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status string `json:"status" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Action      respjson.Field
		CallID      respjson.Field
		Type        respjson.Field
		ID          respjson.Field
		Agent       respjson.Field
		Caller      respjson.Field
		Environment respjson.Field
		Status      respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemShellCall) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemShellCall) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The shell commands and limits that describe how to run the tool call.
type BetaResponseInputItemShellCallAction struct {
	// Ordered shell commands for the execution environment to run.
	Commands []string `json:"commands" api:"required"`
	// Maximum number of UTF-8 characters to capture from combined stdout and stderr
	// output.
	MaxOutputLength int64 `json:"max_output_length" api:"nullable"`
	// Maximum wall-clock time in milliseconds to allow the shell commands to run.
	TimeoutMs int64 `json:"timeout_ms" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Commands        respjson.Field
		MaxOutputLength respjson.Field
		TimeoutMs       respjson.Field
		ExtraFields     map[string]respjson.Field
		raw             string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemShellCallAction) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemShellCallAction) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseInputItemShellCallAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemShellCallAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemShellCallAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseInputItemShellCallCallerUnion contains all possible properties and
// values from [BetaResponseInputItemShellCallCallerDirect],
// [BetaResponseInputItemShellCallCallerProgram].
//
// Use the [BetaResponseInputItemShellCallCallerUnion.AsAny] method to switch on
// the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseInputItemShellCallCallerUnion struct {
	// Any of "direct", "program".
	Type string `json:"type"`
	// This field is from variant [BetaResponseInputItemShellCallCallerProgram].
	CallerID string `json:"caller_id"`
	JSON     struct {
		Type     respjson.Field
		CallerID respjson.Field
		raw      string
	} `json:"-"`
}

// anyBetaResponseInputItemShellCallCaller is implemented by each variant of
// [BetaResponseInputItemShellCallCallerUnion] to add type safety for the return
// type of [BetaResponseInputItemShellCallCallerUnion.AsAny]
type anyBetaResponseInputItemShellCallCaller interface {
	implBetaResponseInputItemShellCallCallerUnion()
}

func (BetaResponseInputItemShellCallCallerDirect) implBetaResponseInputItemShellCallCallerUnion()  {}
func (BetaResponseInputItemShellCallCallerProgram) implBetaResponseInputItemShellCallCallerUnion() {}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseInputItemShellCallCallerUnion.AsAny().(type) {
//	case openai.BetaResponseInputItemShellCallCallerDirect:
//	case openai.BetaResponseInputItemShellCallCallerProgram:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseInputItemShellCallCallerUnion) AsAny() anyBetaResponseInputItemShellCallCaller {
	switch u.Type {
	case "direct":
		return u.AsDirect()
	case "program":
		return u.AsProgram()
	}
	return nil
}

func (u BetaResponseInputItemShellCallCallerUnion) AsDirect() (v BetaResponseInputItemShellCallCallerDirect) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemShellCallCallerUnion) AsProgram() (v BetaResponseInputItemShellCallCallerProgram) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseInputItemShellCallCallerUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseInputItemShellCallCallerUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseInputItemShellCallCallerDirect struct {
	// The caller type. Always `direct`.
	Type constant.Direct `json:"type" default:"direct"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemShellCallCallerDirect) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemShellCallCallerDirect) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseInputItemShellCallCallerProgram struct {
	// The call ID of the program item that produced this tool call.
	CallerID string `json:"caller_id" api:"required"`
	// The caller type. Always `program`.
	Type constant.Program `json:"type" default:"program"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CallerID    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemShellCallCallerProgram) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemShellCallCallerProgram) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseInputItemShellCallEnvironmentUnion contains all possible properties
// and values from [BetaLocalEnvironment], [BetaContainerReference].
//
// Use the [BetaResponseInputItemShellCallEnvironmentUnion.AsAny] method to switch
// on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseInputItemShellCallEnvironmentUnion struct {
	// Any of "local", "container_reference".
	Type string `json:"type"`
	// This field is from variant [BetaLocalEnvironment].
	Skills []BetaLocalSkill `json:"skills"`
	// This field is from variant [BetaContainerReference].
	ContainerID string `json:"container_id"`
	JSON        struct {
		Type        respjson.Field
		Skills      respjson.Field
		ContainerID respjson.Field
		raw         string
	} `json:"-"`
}

// anyBetaResponseInputItemShellCallEnvironment is implemented by each variant of
// [BetaResponseInputItemShellCallEnvironmentUnion] to add type safety for the
// return type of [BetaResponseInputItemShellCallEnvironmentUnion.AsAny]
type anyBetaResponseInputItemShellCallEnvironment interface {
	implBetaResponseInputItemShellCallEnvironmentUnion()
}

func (BetaLocalEnvironment) implBetaResponseInputItemShellCallEnvironmentUnion()   {}
func (BetaContainerReference) implBetaResponseInputItemShellCallEnvironmentUnion() {}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseInputItemShellCallEnvironmentUnion.AsAny().(type) {
//	case openai.BetaLocalEnvironment:
//	case openai.BetaContainerReference:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseInputItemShellCallEnvironmentUnion) AsAny() anyBetaResponseInputItemShellCallEnvironment {
	switch u.Type {
	case "local":
		return u.AsLocal()
	case "container_reference":
		return u.AsContainerReference()
	}
	return nil
}

func (u BetaResponseInputItemShellCallEnvironmentUnion) AsLocal() (v BetaLocalEnvironment) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemShellCallEnvironmentUnion) AsContainerReference() (v BetaContainerReference) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseInputItemShellCallEnvironmentUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseInputItemShellCallEnvironmentUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The streamed output items emitted by a shell tool call.
type BetaResponseInputItemShellCallOutput struct {
	// The unique ID of the shell tool call generated by the model.
	CallID string `json:"call_id" api:"required"`
	// Captured chunks of stdout and stderr output, along with their associated
	// outcomes.
	Output []BetaResponseFunctionShellCallOutputContent `json:"output" api:"required"`
	// The type of the item. Always `shell_call_output`.
	Type constant.ShellCallOutput `json:"type" default:"shell_call_output"`
	// The unique ID of the shell tool call output. Populated when this item is
	// returned via API.
	ID string `json:"id" api:"nullable"`
	// The agent that produced this item.
	Agent BetaResponseInputItemShellCallOutputAgent `json:"agent" api:"nullable"`
	// The execution context that produced this tool call.
	Caller BetaResponseInputItemShellCallOutputCallerUnion `json:"caller" api:"nullable"`
	// The maximum number of UTF-8 characters captured for this shell call's combined
	// output.
	MaxOutputLength int64 `json:"max_output_length" api:"nullable"`
	// The status of the shell call output.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status string `json:"status" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CallID          respjson.Field
		Output          respjson.Field
		Type            respjson.Field
		ID              respjson.Field
		Agent           respjson.Field
		Caller          respjson.Field
		MaxOutputLength respjson.Field
		Status          respjson.Field
		ExtraFields     map[string]respjson.Field
		raw             string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemShellCallOutput) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemShellCallOutput) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseInputItemShellCallOutputAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemShellCallOutputAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemShellCallOutputAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseInputItemShellCallOutputCallerUnion contains all possible properties
// and values from [BetaResponseInputItemShellCallOutputCallerDirect],
// [BetaResponseInputItemShellCallOutputCallerProgram].
//
// Use the [BetaResponseInputItemShellCallOutputCallerUnion.AsAny] method to switch
// on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseInputItemShellCallOutputCallerUnion struct {
	// Any of "direct", "program".
	Type string `json:"type"`
	// This field is from variant [BetaResponseInputItemShellCallOutputCallerProgram].
	CallerID string `json:"caller_id"`
	JSON     struct {
		Type     respjson.Field
		CallerID respjson.Field
		raw      string
	} `json:"-"`
}

// anyBetaResponseInputItemShellCallOutputCaller is implemented by each variant of
// [BetaResponseInputItemShellCallOutputCallerUnion] to add type safety for the
// return type of [BetaResponseInputItemShellCallOutputCallerUnion.AsAny]
type anyBetaResponseInputItemShellCallOutputCaller interface {
	implBetaResponseInputItemShellCallOutputCallerUnion()
}

func (BetaResponseInputItemShellCallOutputCallerDirect) implBetaResponseInputItemShellCallOutputCallerUnion() {
}
func (BetaResponseInputItemShellCallOutputCallerProgram) implBetaResponseInputItemShellCallOutputCallerUnion() {
}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseInputItemShellCallOutputCallerUnion.AsAny().(type) {
//	case openai.BetaResponseInputItemShellCallOutputCallerDirect:
//	case openai.BetaResponseInputItemShellCallOutputCallerProgram:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseInputItemShellCallOutputCallerUnion) AsAny() anyBetaResponseInputItemShellCallOutputCaller {
	switch u.Type {
	case "direct":
		return u.AsDirect()
	case "program":
		return u.AsProgram()
	}
	return nil
}

func (u BetaResponseInputItemShellCallOutputCallerUnion) AsDirect() (v BetaResponseInputItemShellCallOutputCallerDirect) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemShellCallOutputCallerUnion) AsProgram() (v BetaResponseInputItemShellCallOutputCallerProgram) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseInputItemShellCallOutputCallerUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseInputItemShellCallOutputCallerUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseInputItemShellCallOutputCallerDirect struct {
	// The caller type. Always `direct`.
	Type constant.Direct `json:"type" default:"direct"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemShellCallOutputCallerDirect) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemShellCallOutputCallerDirect) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseInputItemShellCallOutputCallerProgram struct {
	// The call ID of the program item that produced this tool call.
	CallerID string `json:"caller_id" api:"required"`
	// The caller type. Always `program`.
	Type constant.Program `json:"type" default:"program"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CallerID    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemShellCallOutputCallerProgram) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemShellCallOutputCallerProgram) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool call representing a request to create, delete, or update files using diff
// patches.
type BetaResponseInputItemApplyPatchCall struct {
	// The unique ID of the apply patch tool call generated by the model.
	CallID string `json:"call_id" api:"required"`
	// The specific create, delete, or update instruction for the apply_patch tool
	// call.
	Operation BetaResponseInputItemApplyPatchCallOperationUnion `json:"operation" api:"required"`
	// The status of the apply patch tool call. One of `in_progress` or `completed`.
	//
	// Any of "in_progress", "completed".
	Status string `json:"status" api:"required"`
	// The type of the item. Always `apply_patch_call`.
	Type constant.ApplyPatchCall `json:"type" default:"apply_patch_call"`
	// The unique ID of the apply patch tool call. Populated when this item is returned
	// via API.
	ID string `json:"id" api:"nullable"`
	// The agent that produced this item.
	Agent BetaResponseInputItemApplyPatchCallAgent `json:"agent" api:"nullable"`
	// The execution context that produced this tool call.
	Caller BetaResponseInputItemApplyPatchCallCallerUnion `json:"caller" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CallID      respjson.Field
		Operation   respjson.Field
		Status      respjson.Field
		Type        respjson.Field
		ID          respjson.Field
		Agent       respjson.Field
		Caller      respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemApplyPatchCall) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemApplyPatchCall) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseInputItemApplyPatchCallOperationUnion contains all possible
// properties and values from
// [BetaResponseInputItemApplyPatchCallOperationCreateFile],
// [BetaResponseInputItemApplyPatchCallOperationDeleteFile],
// [BetaResponseInputItemApplyPatchCallOperationUpdateFile].
//
// Use the [BetaResponseInputItemApplyPatchCallOperationUnion.AsAny] method to
// switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseInputItemApplyPatchCallOperationUnion struct {
	Diff string `json:"diff"`
	Path string `json:"path"`
	// Any of "create_file", "delete_file", "update_file".
	Type string `json:"type"`
	JSON struct {
		Diff respjson.Field
		Path respjson.Field
		Type respjson.Field
		raw  string
	} `json:"-"`
}

// anyBetaResponseInputItemApplyPatchCallOperation is implemented by each variant
// of [BetaResponseInputItemApplyPatchCallOperationUnion] to add type safety for
// the return type of [BetaResponseInputItemApplyPatchCallOperationUnion.AsAny]
type anyBetaResponseInputItemApplyPatchCallOperation interface {
	implBetaResponseInputItemApplyPatchCallOperationUnion()
}

func (BetaResponseInputItemApplyPatchCallOperationCreateFile) implBetaResponseInputItemApplyPatchCallOperationUnion() {
}
func (BetaResponseInputItemApplyPatchCallOperationDeleteFile) implBetaResponseInputItemApplyPatchCallOperationUnion() {
}
func (BetaResponseInputItemApplyPatchCallOperationUpdateFile) implBetaResponseInputItemApplyPatchCallOperationUnion() {
}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseInputItemApplyPatchCallOperationUnion.AsAny().(type) {
//	case openai.BetaResponseInputItemApplyPatchCallOperationCreateFile:
//	case openai.BetaResponseInputItemApplyPatchCallOperationDeleteFile:
//	case openai.BetaResponseInputItemApplyPatchCallOperationUpdateFile:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseInputItemApplyPatchCallOperationUnion) AsAny() anyBetaResponseInputItemApplyPatchCallOperation {
	switch u.Type {
	case "create_file":
		return u.AsCreateFile()
	case "delete_file":
		return u.AsDeleteFile()
	case "update_file":
		return u.AsUpdateFile()
	}
	return nil
}

func (u BetaResponseInputItemApplyPatchCallOperationUnion) AsCreateFile() (v BetaResponseInputItemApplyPatchCallOperationCreateFile) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemApplyPatchCallOperationUnion) AsDeleteFile() (v BetaResponseInputItemApplyPatchCallOperationDeleteFile) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemApplyPatchCallOperationUnion) AsUpdateFile() (v BetaResponseInputItemApplyPatchCallOperationUpdateFile) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseInputItemApplyPatchCallOperationUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseInputItemApplyPatchCallOperationUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Instruction for creating a new file via the apply_patch tool.
type BetaResponseInputItemApplyPatchCallOperationCreateFile struct {
	// Unified diff content to apply when creating the file.
	Diff string `json:"diff" api:"required"`
	// Path of the file to create relative to the workspace root.
	Path string `json:"path" api:"required"`
	// The operation type. Always `create_file`.
	Type constant.CreateFile `json:"type" default:"create_file"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Diff        respjson.Field
		Path        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemApplyPatchCallOperationCreateFile) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemApplyPatchCallOperationCreateFile) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Instruction for deleting an existing file via the apply_patch tool.
type BetaResponseInputItemApplyPatchCallOperationDeleteFile struct {
	// Path of the file to delete relative to the workspace root.
	Path string `json:"path" api:"required"`
	// The operation type. Always `delete_file`.
	Type constant.DeleteFile `json:"type" default:"delete_file"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Path        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemApplyPatchCallOperationDeleteFile) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemApplyPatchCallOperationDeleteFile) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Instruction for updating an existing file via the apply_patch tool.
type BetaResponseInputItemApplyPatchCallOperationUpdateFile struct {
	// Unified diff content to apply to the existing file.
	Diff string `json:"diff" api:"required"`
	// Path of the file to update relative to the workspace root.
	Path string `json:"path" api:"required"`
	// The operation type. Always `update_file`.
	Type constant.UpdateFile `json:"type" default:"update_file"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Diff        respjson.Field
		Path        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemApplyPatchCallOperationUpdateFile) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemApplyPatchCallOperationUpdateFile) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseInputItemApplyPatchCallAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemApplyPatchCallAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemApplyPatchCallAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseInputItemApplyPatchCallCallerUnion contains all possible properties
// and values from [BetaResponseInputItemApplyPatchCallCallerDirect],
// [BetaResponseInputItemApplyPatchCallCallerProgram].
//
// Use the [BetaResponseInputItemApplyPatchCallCallerUnion.AsAny] method to switch
// on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseInputItemApplyPatchCallCallerUnion struct {
	// Any of "direct", "program".
	Type string `json:"type"`
	// This field is from variant [BetaResponseInputItemApplyPatchCallCallerProgram].
	CallerID string `json:"caller_id"`
	JSON     struct {
		Type     respjson.Field
		CallerID respjson.Field
		raw      string
	} `json:"-"`
}

// anyBetaResponseInputItemApplyPatchCallCaller is implemented by each variant of
// [BetaResponseInputItemApplyPatchCallCallerUnion] to add type safety for the
// return type of [BetaResponseInputItemApplyPatchCallCallerUnion.AsAny]
type anyBetaResponseInputItemApplyPatchCallCaller interface {
	implBetaResponseInputItemApplyPatchCallCallerUnion()
}

func (BetaResponseInputItemApplyPatchCallCallerDirect) implBetaResponseInputItemApplyPatchCallCallerUnion() {
}
func (BetaResponseInputItemApplyPatchCallCallerProgram) implBetaResponseInputItemApplyPatchCallCallerUnion() {
}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseInputItemApplyPatchCallCallerUnion.AsAny().(type) {
//	case openai.BetaResponseInputItemApplyPatchCallCallerDirect:
//	case openai.BetaResponseInputItemApplyPatchCallCallerProgram:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseInputItemApplyPatchCallCallerUnion) AsAny() anyBetaResponseInputItemApplyPatchCallCaller {
	switch u.Type {
	case "direct":
		return u.AsDirect()
	case "program":
		return u.AsProgram()
	}
	return nil
}

func (u BetaResponseInputItemApplyPatchCallCallerUnion) AsDirect() (v BetaResponseInputItemApplyPatchCallCallerDirect) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemApplyPatchCallCallerUnion) AsProgram() (v BetaResponseInputItemApplyPatchCallCallerProgram) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseInputItemApplyPatchCallCallerUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseInputItemApplyPatchCallCallerUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseInputItemApplyPatchCallCallerDirect struct {
	// The caller type. Always `direct`.
	Type constant.Direct `json:"type" default:"direct"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemApplyPatchCallCallerDirect) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemApplyPatchCallCallerDirect) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseInputItemApplyPatchCallCallerProgram struct {
	// The call ID of the program item that produced this tool call.
	CallerID string `json:"caller_id" api:"required"`
	// The caller type. Always `program`.
	Type constant.Program `json:"type" default:"program"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CallerID    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemApplyPatchCallCallerProgram) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemApplyPatchCallCallerProgram) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The streamed output emitted by an apply patch tool call.
type BetaResponseInputItemApplyPatchCallOutput struct {
	// The unique ID of the apply patch tool call generated by the model.
	CallID string `json:"call_id" api:"required"`
	// The status of the apply patch tool call output. One of `completed` or `failed`.
	//
	// Any of "completed", "failed".
	Status string `json:"status" api:"required"`
	// The type of the item. Always `apply_patch_call_output`.
	Type constant.ApplyPatchCallOutput `json:"type" default:"apply_patch_call_output"`
	// The unique ID of the apply patch tool call output. Populated when this item is
	// returned via API.
	ID string `json:"id" api:"nullable"`
	// The agent that produced this item.
	Agent BetaResponseInputItemApplyPatchCallOutputAgent `json:"agent" api:"nullable"`
	// The execution context that produced this tool call.
	Caller BetaResponseInputItemApplyPatchCallOutputCallerUnion `json:"caller" api:"nullable"`
	// Optional human-readable log text from the apply patch tool (e.g., patch results
	// or errors).
	Output string `json:"output" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CallID      respjson.Field
		Status      respjson.Field
		Type        respjson.Field
		ID          respjson.Field
		Agent       respjson.Field
		Caller      respjson.Field
		Output      respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemApplyPatchCallOutput) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemApplyPatchCallOutput) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseInputItemApplyPatchCallOutputAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemApplyPatchCallOutputAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemApplyPatchCallOutputAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseInputItemApplyPatchCallOutputCallerUnion contains all possible
// properties and values from
// [BetaResponseInputItemApplyPatchCallOutputCallerDirect],
// [BetaResponseInputItemApplyPatchCallOutputCallerProgram].
//
// Use the [BetaResponseInputItemApplyPatchCallOutputCallerUnion.AsAny] method to
// switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseInputItemApplyPatchCallOutputCallerUnion struct {
	// Any of "direct", "program".
	Type string `json:"type"`
	// This field is from variant
	// [BetaResponseInputItemApplyPatchCallOutputCallerProgram].
	CallerID string `json:"caller_id"`
	JSON     struct {
		Type     respjson.Field
		CallerID respjson.Field
		raw      string
	} `json:"-"`
}

// anyBetaResponseInputItemApplyPatchCallOutputCaller is implemented by each
// variant of [BetaResponseInputItemApplyPatchCallOutputCallerUnion] to add type
// safety for the return type of
// [BetaResponseInputItemApplyPatchCallOutputCallerUnion.AsAny]
type anyBetaResponseInputItemApplyPatchCallOutputCaller interface {
	implBetaResponseInputItemApplyPatchCallOutputCallerUnion()
}

func (BetaResponseInputItemApplyPatchCallOutputCallerDirect) implBetaResponseInputItemApplyPatchCallOutputCallerUnion() {
}
func (BetaResponseInputItemApplyPatchCallOutputCallerProgram) implBetaResponseInputItemApplyPatchCallOutputCallerUnion() {
}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseInputItemApplyPatchCallOutputCallerUnion.AsAny().(type) {
//	case openai.BetaResponseInputItemApplyPatchCallOutputCallerDirect:
//	case openai.BetaResponseInputItemApplyPatchCallOutputCallerProgram:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseInputItemApplyPatchCallOutputCallerUnion) AsAny() anyBetaResponseInputItemApplyPatchCallOutputCaller {
	switch u.Type {
	case "direct":
		return u.AsDirect()
	case "program":
		return u.AsProgram()
	}
	return nil
}

func (u BetaResponseInputItemApplyPatchCallOutputCallerUnion) AsDirect() (v BetaResponseInputItemApplyPatchCallOutputCallerDirect) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseInputItemApplyPatchCallOutputCallerUnion) AsProgram() (v BetaResponseInputItemApplyPatchCallOutputCallerProgram) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseInputItemApplyPatchCallOutputCallerUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseInputItemApplyPatchCallOutputCallerUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseInputItemApplyPatchCallOutputCallerDirect struct {
	// The caller type. Always `direct`.
	Type constant.Direct `json:"type" default:"direct"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemApplyPatchCallOutputCallerDirect) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemApplyPatchCallOutputCallerDirect) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseInputItemApplyPatchCallOutputCallerProgram struct {
	// The call ID of the program item that produced this tool call.
	CallerID string `json:"caller_id" api:"required"`
	// The caller type. Always `program`.
	Type constant.Program `json:"type" default:"program"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CallerID    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemApplyPatchCallOutputCallerProgram) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemApplyPatchCallOutputCallerProgram) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A list of tools available on an MCP server.
type BetaResponseInputItemMcpListTools struct {
	// The unique ID of the list.
	ID string `json:"id" api:"required"`
	// The label of the MCP server.
	ServerLabel string `json:"server_label" api:"required"`
	// The tools available on the server.
	Tools []BetaResponseInputItemMcpListToolsTool `json:"tools" api:"required"`
	// The type of the item. Always `mcp_list_tools`.
	Type constant.McpListTools `json:"type" default:"mcp_list_tools"`
	// The agent that produced this item.
	Agent BetaResponseInputItemMcpListToolsAgent `json:"agent" api:"nullable"`
	// Error message if the server could not list tools.
	Error string `json:"error" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		ServerLabel respjson.Field
		Tools       respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		Error       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemMcpListTools) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemMcpListTools) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool available on an MCP server.
type BetaResponseInputItemMcpListToolsTool struct {
	// The JSON schema describing the tool's input.
	InputSchema any `json:"input_schema" api:"required"`
	// The name of the tool.
	Name string `json:"name" api:"required"`
	// Additional annotations about the tool.
	Annotations any `json:"annotations" api:"nullable"`
	// The description of the tool.
	Description string `json:"description" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		InputSchema respjson.Field
		Name        respjson.Field
		Annotations respjson.Field
		Description respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemMcpListToolsTool) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemMcpListToolsTool) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseInputItemMcpListToolsAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemMcpListToolsAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemMcpListToolsAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A request for human approval of a tool invocation.
type BetaResponseInputItemMcpApprovalRequest struct {
	// The unique ID of the approval request.
	ID string `json:"id" api:"required"`
	// A JSON string of arguments for the tool.
	Arguments string `json:"arguments" api:"required"`
	// The name of the tool to run.
	Name string `json:"name" api:"required"`
	// The label of the MCP server making the request.
	ServerLabel string `json:"server_label" api:"required"`
	// The type of the item. Always `mcp_approval_request`.
	Type constant.McpApprovalRequest `json:"type" default:"mcp_approval_request"`
	// The agent that produced this item.
	Agent BetaResponseInputItemMcpApprovalRequestAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Arguments   respjson.Field
		Name        respjson.Field
		ServerLabel respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemMcpApprovalRequest) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemMcpApprovalRequest) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseInputItemMcpApprovalRequestAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemMcpApprovalRequestAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemMcpApprovalRequestAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A response to an MCP approval request.
type BetaResponseInputItemMcpApprovalResponse struct {
	// The ID of the approval request being answered.
	ApprovalRequestID string `json:"approval_request_id" api:"required"`
	// Whether the request was approved.
	Approve bool `json:"approve" api:"required"`
	// The type of the item. Always `mcp_approval_response`.
	Type constant.McpApprovalResponse `json:"type" default:"mcp_approval_response"`
	// The unique ID of the approval response
	ID string `json:"id" api:"nullable"`
	// The agent that produced this item.
	Agent BetaResponseInputItemMcpApprovalResponseAgent `json:"agent" api:"nullable"`
	// Optional reason for the decision.
	Reason string `json:"reason" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ApprovalRequestID respjson.Field
		Approve           respjson.Field
		Type              respjson.Field
		ID                respjson.Field
		Agent             respjson.Field
		Reason            respjson.Field
		ExtraFields       map[string]respjson.Field
		raw               string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemMcpApprovalResponse) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemMcpApprovalResponse) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseInputItemMcpApprovalResponseAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemMcpApprovalResponseAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemMcpApprovalResponseAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// An invocation of a tool on an MCP server.
type BetaResponseInputItemMcpCall struct {
	// The unique ID of the tool call.
	ID string `json:"id" api:"required"`
	// A JSON string of the arguments passed to the tool.
	Arguments string `json:"arguments" api:"required"`
	// The name of the tool that was run.
	Name string `json:"name" api:"required"`
	// The label of the MCP server running the tool.
	ServerLabel string `json:"server_label" api:"required"`
	// The type of the item. Always `mcp_call`.
	Type constant.McpCall `json:"type" default:"mcp_call"`
	// The agent that produced this item.
	Agent BetaResponseInputItemMcpCallAgent `json:"agent" api:"nullable"`
	// Unique identifier for the MCP tool call approval request. Include this value in
	// a subsequent `mcp_approval_response` input to approve or reject the
	// corresponding tool call.
	ApprovalRequestID string `json:"approval_request_id" api:"nullable"`
	// The error from the tool call, if any.
	Error string `json:"error" api:"nullable"`
	// The output from the tool call.
	Output string `json:"output" api:"nullable"`
	// The status of the tool call. One of `in_progress`, `completed`, `incomplete`,
	// `calling`, or `failed`.
	//
	// Any of "in_progress", "completed", "incomplete", "calling", "failed".
	Status string `json:"status"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                respjson.Field
		Arguments         respjson.Field
		Name              respjson.Field
		ServerLabel       respjson.Field
		Type              respjson.Field
		Agent             respjson.Field
		ApprovalRequestID respjson.Field
		Error             respjson.Field
		Output            respjson.Field
		Status            respjson.Field
		ExtraFields       map[string]respjson.Field
		raw               string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemMcpCall) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemMcpCall) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseInputItemMcpCallAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemMcpCallAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemMcpCallAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Compacts the current context. Must be the final input item.
type BetaResponseInputItemCompactionTrigger struct {
	// The type of the item. Always `compaction_trigger`.
	Type constant.CompactionTrigger `json:"type" default:"compaction_trigger"`
	// The agent that produced this item.
	Agent BetaResponseInputItemCompactionTriggerAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemCompactionTrigger) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemCompactionTrigger) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseInputItemCompactionTriggerAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemCompactionTriggerAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemCompactionTriggerAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// An internal identifier for an item to reference.
type BetaResponseInputItemItemReference struct {
	// The ID of the item to reference.
	ID string `json:"id" api:"required"`
	// The agent that produced this item.
	Agent BetaResponseInputItemItemReferenceAgent `json:"agent" api:"nullable"`
	// The type of item to reference. Always `item_reference`.
	//
	// Any of "item_reference".
	Type string `json:"type" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Agent       respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemItemReference) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemItemReference) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseInputItemItemReferenceAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemItemReferenceAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemItemReferenceAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseInputItemProgram struct {
	// The unique ID of this program item.
	ID string `json:"id" api:"required"`
	// The stable call ID of the program item.
	CallID string `json:"call_id" api:"required"`
	// The JavaScript source executed by programmatic tool calling.
	Code string `json:"code" api:"required"`
	// Opaque program replay fingerprint that must be round-tripped.
	Fingerprint string `json:"fingerprint" api:"required"`
	// The item type. Always `program`.
	Type constant.Program `json:"type" default:"program"`
	// The agent that produced this item.
	Agent BetaResponseInputItemProgramAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CallID      respjson.Field
		Code        respjson.Field
		Fingerprint respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemProgram) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemProgram) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseInputItemProgramAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemProgramAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemProgramAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseInputItemProgramOutput struct {
	// The unique ID of this program output item.
	ID string `json:"id" api:"required"`
	// The call ID of the program item.
	CallID string `json:"call_id" api:"required"`
	// The result produced by the program item.
	Result string `json:"result" api:"required"`
	// The terminal status of the program output.
	//
	// Any of "completed", "incomplete".
	Status string `json:"status" api:"required"`
	// The item type. Always `program_output`.
	Type constant.ProgramOutput `json:"type" default:"program_output"`
	// The agent that produced this item.
	Agent BetaResponseInputItemProgramOutputAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CallID      respjson.Field
		Result      respjson.Field
		Status      respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemProgramOutput) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemProgramOutput) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseInputItemProgramOutputAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputItemProgramOutputAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputItemProgramOutputAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func BetaResponseInputItemParamOfMessage[
	T string | BetaResponseInputMessageContentListParam,
](content T, role BetaEasyInputMessageRole) BetaResponseInputItemUnionParam {
	var message BetaEasyInputMessageParam
	switch v := any(content).(type) {
	case string:
		message.Content.OfString = param.NewOpt(v)
	case BetaResponseInputMessageContentListParam:
		message.Content.OfInputItemContentList = v
	}
	message.Role = role
	return BetaResponseInputItemUnionParam{OfMessage: &message}
}

func BetaResponseInputItemParamOfInputMessage(content BetaResponseInputMessageContentListParam, role string) BetaResponseInputItemUnionParam {
	var message BetaResponseInputItemMessageParam
	message.Content = content
	message.Role = role
	return BetaResponseInputItemUnionParam{OfInputMessage: &message}
}

func BetaResponseInputItemParamOfOutputMessage(content []BetaResponseOutputMessageContentUnionParam, id string, status BetaResponseOutputMessageStatus) BetaResponseInputItemUnionParam {
	var message BetaResponseOutputMessageParam
	message.Content = content
	message.ID = id
	message.Status = status
	return BetaResponseInputItemUnionParam{OfOutputMessage: &message}
}

func BetaResponseInputItemParamOfFileSearchCall(id string, queries []string, status BetaResponseFileSearchToolCallStatus) BetaResponseInputItemUnionParam {
	var fileSearchCall BetaResponseFileSearchToolCallParam
	fileSearchCall.ID = id
	fileSearchCall.Queries = queries
	fileSearchCall.Status = status
	return BetaResponseInputItemUnionParam{OfFileSearchCall: &fileSearchCall}
}

func BetaResponseInputItemParamOfComputerCallOutput(callID string, output BetaResponseComputerToolCallOutputScreenshotParam) BetaResponseInputItemUnionParam {
	var computerCallOutput BetaResponseInputItemComputerCallOutputParam
	computerCallOutput.CallID = callID
	computerCallOutput.Output = output
	return BetaResponseInputItemUnionParam{OfComputerCallOutput: &computerCallOutput}
}

func BetaResponseInputItemParamOfWebSearchCall[
	T BetaResponseFunctionWebSearchActionSearchParam | BetaResponseFunctionWebSearchActionOpenPageParam | BetaResponseFunctionWebSearchActionFindInPageParam,
](action T, id string, status BetaResponseFunctionWebSearchStatus) BetaResponseInputItemUnionParam {
	var webSearchCall BetaResponseFunctionWebSearchParam
	switch v := any(action).(type) {
	case BetaResponseFunctionWebSearchActionSearchParam:
		webSearchCall.Action.OfSearch = &v
	case BetaResponseFunctionWebSearchActionOpenPageParam:
		webSearchCall.Action.OfOpenPage = &v
	case BetaResponseFunctionWebSearchActionFindInPageParam:
		webSearchCall.Action.OfFindInPage = &v
	}
	webSearchCall.ID = id
	webSearchCall.Status = status
	return BetaResponseInputItemUnionParam{OfWebSearchCall: &webSearchCall}
}

func BetaResponseInputItemParamOfFunctionCall(arguments string, callID string, name string) BetaResponseInputItemUnionParam {
	var functionCall BetaResponseFunctionToolCallParam
	functionCall.Arguments = arguments
	functionCall.CallID = callID
	functionCall.Name = name
	return BetaResponseInputItemUnionParam{OfFunctionCall: &functionCall}
}

func BetaResponseInputItemParamOfFunctionCallOutput[
	T string | BetaResponseFunctionCallOutputItemListParam,
](callID string, output T) BetaResponseInputItemUnionParam {
	var functionCallOutput BetaResponseInputItemFunctionCallOutputParam
	functionCallOutput.CallID = callID
	switch v := any(output).(type) {
	case string:
		functionCallOutput.Output.OfString = param.NewOpt(v)
	case BetaResponseFunctionCallOutputItemListParam:
		functionCallOutput.Output.OfBetaResponseFunctionCallOutputItemArray = v
	}
	return BetaResponseInputItemUnionParam{OfFunctionCallOutput: &functionCallOutput}
}

func BetaResponseInputItemParamOfAgentMessage(author string, content []BetaResponseInputItemAgentMessageContentUnionParam, recipient string) BetaResponseInputItemUnionParam {
	var agentMessage BetaResponseInputItemAgentMessageParam
	agentMessage.Author = author
	agentMessage.Content = content
	agentMessage.Recipient = recipient
	return BetaResponseInputItemUnionParam{OfAgentMessage: &agentMessage}
}

func BetaResponseInputItemParamOfMultiAgentCall(action string, arguments string, callID string) BetaResponseInputItemUnionParam {
	var multiAgentCall BetaResponseInputItemMultiAgentCallParam
	multiAgentCall.Action = action
	multiAgentCall.Arguments = arguments
	multiAgentCall.CallID = callID
	return BetaResponseInputItemUnionParam{OfMultiAgentCall: &multiAgentCall}
}

func BetaResponseInputItemParamOfMultiAgentCallOutput(action string, callID string, output []BetaResponseInputItemMultiAgentCallOutputOutputParam) BetaResponseInputItemUnionParam {
	var multiAgentCallOutput BetaResponseInputItemMultiAgentCallOutputParam
	multiAgentCallOutput.Action = action
	multiAgentCallOutput.CallID = callID
	multiAgentCallOutput.Output = output
	return BetaResponseInputItemUnionParam{OfMultiAgentCallOutput: &multiAgentCallOutput}
}

func BetaResponseInputItemParamOfToolSearchCall(arguments any) BetaResponseInputItemUnionParam {
	var toolSearchCall BetaResponseInputItemToolSearchCallParam
	toolSearchCall.Arguments = arguments
	return BetaResponseInputItemUnionParam{OfToolSearchCall: &toolSearchCall}
}

func BetaResponseInputItemParamOfToolSearchOutput(tools []BetaToolUnionParam) BetaResponseInputItemUnionParam {
	var toolSearchOutput BetaResponseToolSearchOutputItemParam
	toolSearchOutput.Tools = tools
	return BetaResponseInputItemUnionParam{OfToolSearchOutput: &toolSearchOutput}
}

func BetaResponseInputItemParamOfAdditionalTools(tools []BetaToolUnionParam) BetaResponseInputItemUnionParam {
	var additionalTools BetaResponseInputItemAdditionalToolsParam
	additionalTools.Tools = tools
	return BetaResponseInputItemUnionParam{OfAdditionalTools: &additionalTools}
}

func BetaResponseInputItemParamOfReasoning(id string, summary []BetaResponseReasoningItemSummaryParam) BetaResponseInputItemUnionParam {
	var reasoning BetaResponseReasoningItemParam
	reasoning.ID = id
	reasoning.Summary = summary
	return BetaResponseInputItemUnionParam{OfReasoning: &reasoning}
}

func BetaResponseInputItemParamOfCompaction(encryptedContent string) BetaResponseInputItemUnionParam {
	var compaction BetaResponseCompactionItemParam
	compaction.EncryptedContent = encryptedContent
	return BetaResponseInputItemUnionParam{OfCompaction: &compaction}
}

func BetaResponseInputItemParamOfImageGenerationCall(id string, result string, status string) BetaResponseInputItemUnionParam {
	var imageGenerationCall BetaResponseInputItemImageGenerationCallParam
	imageGenerationCall.ID = id
	imageGenerationCall.Result = param.NewOpt(result)
	imageGenerationCall.Status = status
	return BetaResponseInputItemUnionParam{OfImageGenerationCall: &imageGenerationCall}
}

func BetaResponseInputItemParamOfLocalShellCallOutput(id string, output string) BetaResponseInputItemUnionParam {
	var localShellCallOutput BetaResponseInputItemLocalShellCallOutputParam
	localShellCallOutput.ID = id
	localShellCallOutput.Output = output
	return BetaResponseInputItemUnionParam{OfLocalShellCallOutput: &localShellCallOutput}
}

func BetaResponseInputItemParamOfShellCall(action BetaResponseInputItemShellCallActionParam, callID string) BetaResponseInputItemUnionParam {
	var shellCall BetaResponseInputItemShellCallParam
	shellCall.Action = action
	shellCall.CallID = callID
	return BetaResponseInputItemUnionParam{OfShellCall: &shellCall}
}

func BetaResponseInputItemParamOfShellCallOutput(callID string, output []BetaResponseFunctionShellCallOutputContentParam) BetaResponseInputItemUnionParam {
	var shellCallOutput BetaResponseInputItemShellCallOutputParam
	shellCallOutput.CallID = callID
	shellCallOutput.Output = output
	return BetaResponseInputItemUnionParam{OfShellCallOutput: &shellCallOutput}
}

func BetaResponseInputItemParamOfApplyPatchCall[
	T BetaResponseInputItemApplyPatchCallOperationCreateFileParam | BetaResponseInputItemApplyPatchCallOperationDeleteFileParam | BetaResponseInputItemApplyPatchCallOperationUpdateFileParam,
](callID string, operation T, status string) BetaResponseInputItemUnionParam {
	var applyPatchCall BetaResponseInputItemApplyPatchCallParam
	applyPatchCall.CallID = callID
	switch v := any(operation).(type) {
	case BetaResponseInputItemApplyPatchCallOperationCreateFileParam:
		applyPatchCall.Operation.OfCreateFile = &v
	case BetaResponseInputItemApplyPatchCallOperationDeleteFileParam:
		applyPatchCall.Operation.OfDeleteFile = &v
	case BetaResponseInputItemApplyPatchCallOperationUpdateFileParam:
		applyPatchCall.Operation.OfUpdateFile = &v
	}
	applyPatchCall.Status = status
	return BetaResponseInputItemUnionParam{OfApplyPatchCall: &applyPatchCall}
}

func BetaResponseInputItemParamOfApplyPatchCallOutput(callID string, status string) BetaResponseInputItemUnionParam {
	var applyPatchCallOutput BetaResponseInputItemApplyPatchCallOutputParam
	applyPatchCallOutput.CallID = callID
	applyPatchCallOutput.Status = status
	return BetaResponseInputItemUnionParam{OfApplyPatchCallOutput: &applyPatchCallOutput}
}

func BetaResponseInputItemParamOfMcpListTools(id string, serverLabel string, tools []BetaResponseInputItemMcpListToolsToolParam) BetaResponseInputItemUnionParam {
	var mcpListTools BetaResponseInputItemMcpListToolsParam
	mcpListTools.ID = id
	mcpListTools.ServerLabel = serverLabel
	mcpListTools.Tools = tools
	return BetaResponseInputItemUnionParam{OfMcpListTools: &mcpListTools}
}

func BetaResponseInputItemParamOfMcpApprovalResponse(approvalRequestID string, approve bool) BetaResponseInputItemUnionParam {
	var mcpApprovalResponse BetaResponseInputItemMcpApprovalResponseParam
	mcpApprovalResponse.ApprovalRequestID = approvalRequestID
	mcpApprovalResponse.Approve = approve
	return BetaResponseInputItemUnionParam{OfMcpApprovalResponse: &mcpApprovalResponse}
}

func BetaResponseInputItemParamOfCustomToolCallOutput[
	T string | []BetaResponseCustomToolCallOutputOutputOutputContentListItemUnionParam,
](callID string, output T) BetaResponseInputItemUnionParam {
	var customToolCallOutput BetaResponseCustomToolCallOutputParam
	customToolCallOutput.CallID = callID
	switch v := any(output).(type) {
	case string:
		customToolCallOutput.Output.OfString = param.NewOpt(v)
	case []BetaResponseCustomToolCallOutputOutputOutputContentListItemUnionParam:
		customToolCallOutput.Output.OfOutputContentList = v
	}
	return BetaResponseInputItemUnionParam{OfCustomToolCallOutput: &customToolCallOutput}
}

func BetaResponseInputItemParamOfCustomToolCall(callID string, input string, name string) BetaResponseInputItemUnionParam {
	var customToolCall BetaResponseCustomToolCallParam
	customToolCall.CallID = callID
	customToolCall.Input = input
	customToolCall.Name = name
	return BetaResponseInputItemUnionParam{OfCustomToolCall: &customToolCall}
}

func BetaResponseInputItemParamOfItemReference(id string) BetaResponseInputItemUnionParam {
	var itemReference BetaResponseInputItemItemReferenceParam
	itemReference.ID = id
	return BetaResponseInputItemUnionParam{OfItemReference: &itemReference}
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseInputItemUnionParam struct {
	OfMessage              *BetaEasyInputMessageParam                      `json:",omitzero,inline"`
	OfInputMessage         *BetaResponseInputItemMessageParam              `json:",omitzero,inline"`
	OfOutputMessage        *BetaResponseOutputMessageParam                 `json:",omitzero,inline"`
	OfFileSearchCall       *BetaResponseFileSearchToolCallParam            `json:",omitzero,inline"`
	OfComputerCall         *BetaResponseComputerToolCallParam              `json:",omitzero,inline"`
	OfComputerCallOutput   *BetaResponseInputItemComputerCallOutputParam   `json:",omitzero,inline"`
	OfWebSearchCall        *BetaResponseFunctionWebSearchParam             `json:",omitzero,inline"`
	OfFunctionCall         *BetaResponseFunctionToolCallParam              `json:",omitzero,inline"`
	OfFunctionCallOutput   *BetaResponseInputItemFunctionCallOutputParam   `json:",omitzero,inline"`
	OfAgentMessage         *BetaResponseInputItemAgentMessageParam         `json:",omitzero,inline"`
	OfMultiAgentCall       *BetaResponseInputItemMultiAgentCallParam       `json:",omitzero,inline"`
	OfMultiAgentCallOutput *BetaResponseInputItemMultiAgentCallOutputParam `json:",omitzero,inline"`
	OfToolSearchCall       *BetaResponseInputItemToolSearchCallParam       `json:",omitzero,inline"`
	OfToolSearchOutput     *BetaResponseToolSearchOutputItemParam          `json:",omitzero,inline"`
	OfAdditionalTools      *BetaResponseInputItemAdditionalToolsParam      `json:",omitzero,inline"`
	OfReasoning            *BetaResponseReasoningItemParam                 `json:",omitzero,inline"`
	OfCompaction           *BetaResponseCompactionItemParam                `json:",omitzero,inline"`
	OfImageGenerationCall  *BetaResponseInputItemImageGenerationCallParam  `json:",omitzero,inline"`
	OfCodeInterpreterCall  *BetaResponseCodeInterpreterToolCallParam       `json:",omitzero,inline"`
	OfLocalShellCall       *BetaResponseInputItemLocalShellCallParam       `json:",omitzero,inline"`
	OfLocalShellCallOutput *BetaResponseInputItemLocalShellCallOutputParam `json:",omitzero,inline"`
	OfShellCall            *BetaResponseInputItemShellCallParam            `json:",omitzero,inline"`
	OfShellCallOutput      *BetaResponseInputItemShellCallOutputParam      `json:",omitzero,inline"`
	OfApplyPatchCall       *BetaResponseInputItemApplyPatchCallParam       `json:",omitzero,inline"`
	OfApplyPatchCallOutput *BetaResponseInputItemApplyPatchCallOutputParam `json:",omitzero,inline"`
	OfMcpListTools         *BetaResponseInputItemMcpListToolsParam         `json:",omitzero,inline"`
	OfMcpApprovalRequest   *BetaResponseInputItemMcpApprovalRequestParam   `json:",omitzero,inline"`
	OfMcpApprovalResponse  *BetaResponseInputItemMcpApprovalResponseParam  `json:",omitzero,inline"`
	OfMcpCall              *BetaResponseInputItemMcpCallParam              `json:",omitzero,inline"`
	OfCustomToolCallOutput *BetaResponseCustomToolCallOutputParam          `json:",omitzero,inline"`
	OfCustomToolCall       *BetaResponseCustomToolCallParam                `json:",omitzero,inline"`
	OfCompactionTrigger    *BetaResponseInputItemCompactionTriggerParam    `json:",omitzero,inline"`
	OfItemReference        *BetaResponseInputItemItemReferenceParam        `json:",omitzero,inline"`
	OfProgram              *BetaResponseInputItemProgramParam              `json:",omitzero,inline"`
	OfProgramOutput        *BetaResponseInputItemProgramOutputParam        `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseInputItemUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfMessage,
		u.OfInputMessage,
		u.OfOutputMessage,
		u.OfFileSearchCall,
		u.OfComputerCall,
		u.OfComputerCallOutput,
		u.OfWebSearchCall,
		u.OfFunctionCall,
		u.OfFunctionCallOutput,
		u.OfAgentMessage,
		u.OfMultiAgentCall,
		u.OfMultiAgentCallOutput,
		u.OfToolSearchCall,
		u.OfToolSearchOutput,
		u.OfAdditionalTools,
		u.OfReasoning,
		u.OfCompaction,
		u.OfImageGenerationCall,
		u.OfCodeInterpreterCall,
		u.OfLocalShellCall,
		u.OfLocalShellCallOutput,
		u.OfShellCall,
		u.OfShellCallOutput,
		u.OfApplyPatchCall,
		u.OfApplyPatchCallOutput,
		u.OfMcpListTools,
		u.OfMcpApprovalRequest,
		u.OfMcpApprovalResponse,
		u.OfMcpCall,
		u.OfCustomToolCallOutput,
		u.OfCustomToolCall,
		u.OfCompactionTrigger,
		u.OfItemReference,
		u.OfProgram,
		u.OfProgramOutput)
}
func (u *BetaResponseInputItemUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseInputItemUnionParam) asAny() any {
	if !param.IsOmitted(u.OfMessage) {
		return u.OfMessage
	} else if !param.IsOmitted(u.OfInputMessage) {
		return u.OfInputMessage
	} else if !param.IsOmitted(u.OfOutputMessage) {
		return u.OfOutputMessage
	} else if !param.IsOmitted(u.OfFileSearchCall) {
		return u.OfFileSearchCall
	} else if !param.IsOmitted(u.OfComputerCall) {
		return u.OfComputerCall
	} else if !param.IsOmitted(u.OfComputerCallOutput) {
		return u.OfComputerCallOutput
	} else if !param.IsOmitted(u.OfWebSearchCall) {
		return u.OfWebSearchCall
	} else if !param.IsOmitted(u.OfFunctionCall) {
		return u.OfFunctionCall
	} else if !param.IsOmitted(u.OfFunctionCallOutput) {
		return u.OfFunctionCallOutput
	} else if !param.IsOmitted(u.OfAgentMessage) {
		return u.OfAgentMessage
	} else if !param.IsOmitted(u.OfMultiAgentCall) {
		return u.OfMultiAgentCall
	} else if !param.IsOmitted(u.OfMultiAgentCallOutput) {
		return u.OfMultiAgentCallOutput
	} else if !param.IsOmitted(u.OfToolSearchCall) {
		return u.OfToolSearchCall
	} else if !param.IsOmitted(u.OfToolSearchOutput) {
		return u.OfToolSearchOutput
	} else if !param.IsOmitted(u.OfAdditionalTools) {
		return u.OfAdditionalTools
	} else if !param.IsOmitted(u.OfReasoning) {
		return u.OfReasoning
	} else if !param.IsOmitted(u.OfCompaction) {
		return u.OfCompaction
	} else if !param.IsOmitted(u.OfImageGenerationCall) {
		return u.OfImageGenerationCall
	} else if !param.IsOmitted(u.OfCodeInterpreterCall) {
		return u.OfCodeInterpreterCall
	} else if !param.IsOmitted(u.OfLocalShellCall) {
		return u.OfLocalShellCall
	} else if !param.IsOmitted(u.OfLocalShellCallOutput) {
		return u.OfLocalShellCallOutput
	} else if !param.IsOmitted(u.OfShellCall) {
		return u.OfShellCall
	} else if !param.IsOmitted(u.OfShellCallOutput) {
		return u.OfShellCallOutput
	} else if !param.IsOmitted(u.OfApplyPatchCall) {
		return u.OfApplyPatchCall
	} else if !param.IsOmitted(u.OfApplyPatchCallOutput) {
		return u.OfApplyPatchCallOutput
	} else if !param.IsOmitted(u.OfMcpListTools) {
		return u.OfMcpListTools
	} else if !param.IsOmitted(u.OfMcpApprovalRequest) {
		return u.OfMcpApprovalRequest
	} else if !param.IsOmitted(u.OfMcpApprovalResponse) {
		return u.OfMcpApprovalResponse
	} else if !param.IsOmitted(u.OfMcpCall) {
		return u.OfMcpCall
	} else if !param.IsOmitted(u.OfCustomToolCallOutput) {
		return u.OfCustomToolCallOutput
	} else if !param.IsOmitted(u.OfCustomToolCall) {
		return u.OfCustomToolCall
	} else if !param.IsOmitted(u.OfCompactionTrigger) {
		return u.OfCompactionTrigger
	} else if !param.IsOmitted(u.OfItemReference) {
		return u.OfItemReference
	} else if !param.IsOmitted(u.OfProgram) {
		return u.OfProgram
	} else if !param.IsOmitted(u.OfProgramOutput) {
		return u.OfProgramOutput
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetQueries() []string {
	if vt := u.OfFileSearchCall; vt != nil {
		return vt.Queries
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetResults() []BetaResponseFileSearchToolCallResultParam {
	if vt := u.OfFileSearchCall; vt != nil {
		return vt.Results
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetPendingSafetyChecks() []BetaResponseComputerToolCallPendingSafetyCheckParam {
	if vt := u.OfComputerCall; vt != nil {
		return vt.PendingSafetyChecks
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetActions() BetaComputerActionListParam {
	if vt := u.OfComputerCall; vt != nil {
		return vt.Actions
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetAcknowledgedSafetyChecks() []BetaResponseInputItemComputerCallOutputAcknowledgedSafetyCheckParam {
	if vt := u.OfComputerCallOutput; vt != nil {
		return vt.AcknowledgedSafetyChecks
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetAuthor() *string {
	if vt := u.OfAgentMessage; vt != nil {
		return &vt.Author
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetRecipient() *string {
	if vt := u.OfAgentMessage; vt != nil {
		return &vt.Recipient
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetSummary() []BetaResponseReasoningItemSummaryParam {
	if vt := u.OfReasoning; vt != nil {
		return vt.Summary
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetContainerID() *string {
	if vt := u.OfCodeInterpreterCall; vt != nil {
		return &vt.ContainerID
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetOutputs() []BetaResponseCodeInterpreterToolCallOutputUnionParam {
	if vt := u.OfCodeInterpreterCall; vt != nil {
		return vt.Outputs
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetEnvironment() *BetaResponseInputItemShellCallEnvironmentUnionParam {
	if vt := u.OfShellCall; vt != nil {
		return &vt.Environment
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetMaxOutputLength() *int64 {
	if vt := u.OfShellCallOutput; vt != nil && vt.MaxOutputLength.Valid() {
		return &vt.MaxOutputLength.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetOperation() *BetaResponseInputItemApplyPatchCallOperationUnionParam {
	if vt := u.OfApplyPatchCall; vt != nil {
		return &vt.Operation
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetApprove() *bool {
	if vt := u.OfMcpApprovalResponse; vt != nil {
		return &vt.Approve
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetReason() *string {
	if vt := u.OfMcpApprovalResponse; vt != nil && vt.Reason.Valid() {
		return &vt.Reason.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetInput() *string {
	if vt := u.OfCustomToolCall; vt != nil {
		return &vt.Input
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetFingerprint() *string {
	if vt := u.OfProgram; vt != nil {
		return &vt.Fingerprint
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetRole() *string {
	if vt := u.OfMessage; vt != nil {
		return (*string)(&vt.Role)
	} else if vt := u.OfInputMessage; vt != nil {
		return (*string)(&vt.Role)
	} else if vt := u.OfOutputMessage; vt != nil {
		return (*string)(&vt.Role)
	} else if vt := u.OfAdditionalTools; vt != nil {
		return (*string)(&vt.Role)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetPhase() *string {
	if vt := u.OfMessage; vt != nil {
		return (*string)(&vt.Phase)
	} else if vt := u.OfOutputMessage; vt != nil {
		return (*string)(&vt.Phase)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetType() *string {
	if vt := u.OfMessage; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfInputMessage; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfOutputMessage; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfFileSearchCall; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfComputerCall; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfComputerCallOutput; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfWebSearchCall; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfFunctionCall; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfFunctionCallOutput; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfAgentMessage; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfMultiAgentCall; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfMultiAgentCallOutput; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfToolSearchCall; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfToolSearchOutput; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfAdditionalTools; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfReasoning; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfCompaction; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfImageGenerationCall; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfCodeInterpreterCall; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfLocalShellCall; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfLocalShellCallOutput; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfShellCall; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfShellCallOutput; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfApplyPatchCall; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfApplyPatchCallOutput; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfMcpListTools; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfMcpApprovalRequest; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfMcpApprovalResponse; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfMcpCall; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfCustomToolCallOutput; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfCustomToolCall; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfCompactionTrigger; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfItemReference; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfProgram; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfProgramOutput; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetStatus() *string {
	if vt := u.OfInputMessage; vt != nil {
		return (*string)(&vt.Status)
	} else if vt := u.OfOutputMessage; vt != nil {
		return (*string)(&vt.Status)
	} else if vt := u.OfFileSearchCall; vt != nil {
		return (*string)(&vt.Status)
	} else if vt := u.OfComputerCall; vt != nil {
		return (*string)(&vt.Status)
	} else if vt := u.OfComputerCallOutput; vt != nil {
		return (*string)(&vt.Status)
	} else if vt := u.OfWebSearchCall; vt != nil {
		return (*string)(&vt.Status)
	} else if vt := u.OfFunctionCall; vt != nil {
		return (*string)(&vt.Status)
	} else if vt := u.OfFunctionCallOutput; vt != nil {
		return (*string)(&vt.Status)
	} else if vt := u.OfToolSearchCall; vt != nil {
		return (*string)(&vt.Status)
	} else if vt := u.OfToolSearchOutput; vt != nil {
		return (*string)(&vt.Status)
	} else if vt := u.OfReasoning; vt != nil {
		return (*string)(&vt.Status)
	} else if vt := u.OfImageGenerationCall; vt != nil {
		return (*string)(&vt.Status)
	} else if vt := u.OfCodeInterpreterCall; vt != nil {
		return (*string)(&vt.Status)
	} else if vt := u.OfLocalShellCall; vt != nil {
		return (*string)(&vt.Status)
	} else if vt := u.OfLocalShellCallOutput; vt != nil {
		return (*string)(&vt.Status)
	} else if vt := u.OfShellCall; vt != nil {
		return (*string)(&vt.Status)
	} else if vt := u.OfShellCallOutput; vt != nil {
		return (*string)(&vt.Status)
	} else if vt := u.OfApplyPatchCall; vt != nil {
		return (*string)(&vt.Status)
	} else if vt := u.OfApplyPatchCallOutput; vt != nil {
		return (*string)(&vt.Status)
	} else if vt := u.OfMcpCall; vt != nil {
		return (*string)(&vt.Status)
	} else if vt := u.OfProgramOutput; vt != nil {
		return (*string)(&vt.Status)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetID() *string {
	if vt := u.OfOutputMessage; vt != nil {
		return (*string)(&vt.ID)
	} else if vt := u.OfFileSearchCall; vt != nil {
		return (*string)(&vt.ID)
	} else if vt := u.OfComputerCall; vt != nil {
		return (*string)(&vt.ID)
	} else if vt := u.OfComputerCallOutput; vt != nil && vt.ID.Valid() {
		return &vt.ID.Value
	} else if vt := u.OfWebSearchCall; vt != nil {
		return (*string)(&vt.ID)
	} else if vt := u.OfFunctionCall; vt != nil && vt.ID.Valid() {
		return &vt.ID.Value
	} else if vt := u.OfFunctionCallOutput; vt != nil && vt.ID.Valid() {
		return &vt.ID.Value
	} else if vt := u.OfAgentMessage; vt != nil && vt.ID.Valid() {
		return &vt.ID.Value
	} else if vt := u.OfMultiAgentCall; vt != nil && vt.ID.Valid() {
		return &vt.ID.Value
	} else if vt := u.OfMultiAgentCallOutput; vt != nil && vt.ID.Valid() {
		return &vt.ID.Value
	} else if vt := u.OfToolSearchCall; vt != nil && vt.ID.Valid() {
		return &vt.ID.Value
	} else if vt := u.OfToolSearchOutput; vt != nil && vt.ID.Valid() {
		return &vt.ID.Value
	} else if vt := u.OfAdditionalTools; vt != nil && vt.ID.Valid() {
		return &vt.ID.Value
	} else if vt := u.OfReasoning; vt != nil {
		return (*string)(&vt.ID)
	} else if vt := u.OfCompaction; vt != nil && vt.ID.Valid() {
		return &vt.ID.Value
	} else if vt := u.OfImageGenerationCall; vt != nil {
		return (*string)(&vt.ID)
	} else if vt := u.OfCodeInterpreterCall; vt != nil {
		return (*string)(&vt.ID)
	} else if vt := u.OfLocalShellCall; vt != nil {
		return (*string)(&vt.ID)
	} else if vt := u.OfLocalShellCallOutput; vt != nil {
		return (*string)(&vt.ID)
	} else if vt := u.OfShellCall; vt != nil && vt.ID.Valid() {
		return &vt.ID.Value
	} else if vt := u.OfShellCallOutput; vt != nil && vt.ID.Valid() {
		return &vt.ID.Value
	} else if vt := u.OfApplyPatchCall; vt != nil && vt.ID.Valid() {
		return &vt.ID.Value
	} else if vt := u.OfApplyPatchCallOutput; vt != nil && vt.ID.Valid() {
		return &vt.ID.Value
	} else if vt := u.OfMcpListTools; vt != nil {
		return (*string)(&vt.ID)
	} else if vt := u.OfMcpApprovalRequest; vt != nil {
		return (*string)(&vt.ID)
	} else if vt := u.OfMcpApprovalResponse; vt != nil && vt.ID.Valid() {
		return &vt.ID.Value
	} else if vt := u.OfMcpCall; vt != nil {
		return (*string)(&vt.ID)
	} else if vt := u.OfCustomToolCallOutput; vt != nil && vt.ID.Valid() {
		return &vt.ID.Value
	} else if vt := u.OfCustomToolCall; vt != nil && vt.ID.Valid() {
		return &vt.ID.Value
	} else if vt := u.OfItemReference; vt != nil {
		return (*string)(&vt.ID)
	} else if vt := u.OfProgram; vt != nil {
		return (*string)(&vt.ID)
	} else if vt := u.OfProgramOutput; vt != nil {
		return (*string)(&vt.ID)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetCallID() *string {
	if vt := u.OfComputerCall; vt != nil {
		return (*string)(&vt.CallID)
	} else if vt := u.OfComputerCallOutput; vt != nil {
		return (*string)(&vt.CallID)
	} else if vt := u.OfFunctionCall; vt != nil {
		return (*string)(&vt.CallID)
	} else if vt := u.OfFunctionCallOutput; vt != nil {
		return (*string)(&vt.CallID)
	} else if vt := u.OfMultiAgentCall; vt != nil {
		return (*string)(&vt.CallID)
	} else if vt := u.OfMultiAgentCallOutput; vt != nil {
		return (*string)(&vt.CallID)
	} else if vt := u.OfToolSearchCall; vt != nil && vt.CallID.Valid() {
		return &vt.CallID.Value
	} else if vt := u.OfToolSearchOutput; vt != nil && vt.CallID.Valid() {
		return &vt.CallID.Value
	} else if vt := u.OfLocalShellCall; vt != nil {
		return (*string)(&vt.CallID)
	} else if vt := u.OfShellCall; vt != nil {
		return (*string)(&vt.CallID)
	} else if vt := u.OfShellCallOutput; vt != nil {
		return (*string)(&vt.CallID)
	} else if vt := u.OfApplyPatchCall; vt != nil {
		return (*string)(&vt.CallID)
	} else if vt := u.OfApplyPatchCallOutput; vt != nil {
		return (*string)(&vt.CallID)
	} else if vt := u.OfCustomToolCallOutput; vt != nil {
		return (*string)(&vt.CallID)
	} else if vt := u.OfCustomToolCall; vt != nil {
		return (*string)(&vt.CallID)
	} else if vt := u.OfProgram; vt != nil {
		return (*string)(&vt.CallID)
	} else if vt := u.OfProgramOutput; vt != nil {
		return (*string)(&vt.CallID)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetName() *string {
	if vt := u.OfFunctionCall; vt != nil {
		return (*string)(&vt.Name)
	} else if vt := u.OfMcpApprovalRequest; vt != nil {
		return (*string)(&vt.Name)
	} else if vt := u.OfMcpCall; vt != nil {
		return (*string)(&vt.Name)
	} else if vt := u.OfCustomToolCall; vt != nil {
		return (*string)(&vt.Name)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetNamespace() *string {
	if vt := u.OfFunctionCall; vt != nil && vt.Namespace.Valid() {
		return &vt.Namespace.Value
	} else if vt := u.OfCustomToolCall; vt != nil && vt.Namespace.Valid() {
		return &vt.Namespace.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetExecution() *string {
	if vt := u.OfToolSearchCall; vt != nil {
		return (*string)(&vt.Execution)
	} else if vt := u.OfToolSearchOutput; vt != nil {
		return (*string)(&vt.Execution)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetEncryptedContent() *string {
	if vt := u.OfReasoning; vt != nil && vt.EncryptedContent.Valid() {
		return &vt.EncryptedContent.Value
	} else if vt := u.OfCompaction; vt != nil {
		return (*string)(&vt.EncryptedContent)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetResult() *string {
	if vt := u.OfImageGenerationCall; vt != nil && vt.Result.Valid() {
		return &vt.Result.Value
	} else if vt := u.OfProgramOutput; vt != nil {
		return (*string)(&vt.Result)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetCode() *string {
	if vt := u.OfCodeInterpreterCall; vt != nil && vt.Code.Valid() {
		return &vt.Code.Value
	} else if vt := u.OfProgram; vt != nil {
		return (*string)(&vt.Code)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetServerLabel() *string {
	if vt := u.OfMcpListTools; vt != nil {
		return (*string)(&vt.ServerLabel)
	} else if vt := u.OfMcpApprovalRequest; vt != nil {
		return (*string)(&vt.ServerLabel)
	} else if vt := u.OfMcpCall; vt != nil {
		return (*string)(&vt.ServerLabel)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetError() *string {
	if vt := u.OfMcpListTools; vt != nil && vt.Error.Valid() {
		return &vt.Error.Value
	} else if vt := u.OfMcpCall; vt != nil && vt.Error.Valid() {
		return &vt.Error.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemUnionParam) GetApprovalRequestID() *string {
	if vt := u.OfMcpApprovalResponse; vt != nil {
		return (*string)(&vt.ApprovalRequestID)
	} else if vt := u.OfMcpCall; vt != nil && vt.ApprovalRequestID.Valid() {
		return &vt.ApprovalRequestID.Value
	}
	return nil
}

// Returns a subunion which exports methods to access subproperties
//
// Or use AsAny() to get the underlying value
func (u BetaResponseInputItemUnionParam) GetContent() (res betaResponseInputItemUnionParamContent) {
	if vt := u.OfMessage; vt != nil {
		res.any = vt.Content.asAny()
	} else if vt := u.OfInputMessage; vt != nil {
		res.any = &vt.Content
	} else if vt := u.OfOutputMessage; vt != nil {
		res.any = &vt.Content
	} else if vt := u.OfAgentMessage; vt != nil {
		res.any = &vt.Content
	} else if vt := u.OfReasoning; vt != nil {
		res.any = &vt.Content
	}
	return
}

// Can have the runtime types [*string],
// [*BetaResponseInputMessageContentListParam],
// [_[]BetaResponseOutputMessageContentUnionParam],
// [_[]BetaResponseInputItemAgentMessageContentUnionParam],
// [\*[]BetaResponseReasoningItemContentParam]
type betaResponseInputItemUnionParamContent struct{ any }

// Use the following switch statement to get the type of the union:
//
//	switch u.AsAny().(type) {
//	case *string:
//	case *openai.BetaResponseInputMessageContentListParam:
//	case *[]openai.BetaResponseOutputMessageContentUnionParam:
//	case *[]openai.BetaResponseInputItemAgentMessageContentUnionParam:
//	case *[]openai.BetaResponseReasoningItemContentParam:
//	default:
//	    fmt.Errorf("not present")
//	}
func (u betaResponseInputItemUnionParamContent) AsAny() any { return u.any }

// Returns a subunion which exports methods to access subproperties
//
// Or use AsAny() to get the underlying value
func (u BetaResponseInputItemUnionParam) GetAgent() (res betaResponseInputItemUnionParamAgent) {
	if vt := u.OfInputMessage; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfOutputMessage; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfFileSearchCall; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfComputerCall; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfComputerCallOutput; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfWebSearchCall; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfFunctionCall; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfFunctionCallOutput; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfAgentMessage; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfMultiAgentCall; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfMultiAgentCallOutput; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfToolSearchCall; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfToolSearchOutput; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfAdditionalTools; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfReasoning; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfCompaction; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfImageGenerationCall; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfCodeInterpreterCall; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfLocalShellCall; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfLocalShellCallOutput; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfShellCall; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfShellCallOutput; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfApplyPatchCall; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfApplyPatchCallOutput; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfMcpListTools; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfMcpApprovalRequest; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfMcpApprovalResponse; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfMcpCall; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfCustomToolCallOutput; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfCustomToolCall; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfCompactionTrigger; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfItemReference; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfProgram; vt != nil {
		res.any = &vt.Agent
	} else if vt := u.OfProgramOutput; vt != nil {
		res.any = &vt.Agent
	}
	return
}

// Can have the runtime types [*BetaResponseInputItemMessageAgentParam],
// [*BetaResponseOutputMessageAgentParam],
// [*BetaResponseFileSearchToolCallAgentParam],
// [*BetaResponseComputerToolCallAgentParam],
// [*BetaResponseInputItemComputerCallOutputAgentParam],
// [*BetaResponseFunctionWebSearchAgentParam],
// [*BetaResponseFunctionToolCallAgentParam],
// [*BetaResponseInputItemFunctionCallOutputAgentParam],
// [*BetaResponseInputItemAgentMessageAgentParam],
// [*BetaResponseInputItemMultiAgentCallAgentParam],
// [*BetaResponseInputItemMultiAgentCallOutputAgentParam],
// [*BetaResponseInputItemToolSearchCallAgentParam],
// [*BetaResponseToolSearchOutputItemParamAgent],
// [*BetaResponseInputItemAdditionalToolsAgentParam],
// [*BetaResponseReasoningItemAgentParam], [*BetaResponseCompactionItemParamAgent],
// [*BetaResponseInputItemImageGenerationCallAgentParam],
// [*BetaResponseCodeInterpreterToolCallAgentParam],
// [*BetaResponseInputItemLocalShellCallAgentParam],
// [*BetaResponseInputItemLocalShellCallOutputAgentParam],
// [*BetaResponseInputItemShellCallAgentParam],
// [*BetaResponseInputItemShellCallOutputAgentParam],
// [*BetaResponseInputItemApplyPatchCallAgentParam],
// [*BetaResponseInputItemApplyPatchCallOutputAgentParam],
// [*BetaResponseInputItemMcpListToolsAgentParam],
// [*BetaResponseInputItemMcpApprovalRequestAgentParam],
// [*BetaResponseInputItemMcpApprovalResponseAgentParam],
// [*BetaResponseInputItemMcpCallAgentParam],
// [*BetaResponseCustomToolCallOutputAgentParam],
// [*BetaResponseCustomToolCallAgentParam],
// [*BetaResponseInputItemCompactionTriggerAgentParam],
// [*BetaResponseInputItemItemReferenceAgentParam],
// [*BetaResponseInputItemProgramAgentParam],
// [*BetaResponseInputItemProgramOutputAgentParam]
type betaResponseInputItemUnionParamAgent struct{ any }

// Use the following switch statement to get the type of the union:
//
//	switch u.AsAny().(type) {
//	case *openai.BetaResponseInputItemMessageAgentParam:
//	case *openai.BetaResponseOutputMessageAgentParam:
//	case *openai.BetaResponseFileSearchToolCallAgentParam:
//	case *openai.BetaResponseComputerToolCallAgentParam:
//	case *openai.BetaResponseInputItemComputerCallOutputAgentParam:
//	case *openai.BetaResponseFunctionWebSearchAgentParam:
//	case *openai.BetaResponseFunctionToolCallAgentParam:
//	case *openai.BetaResponseInputItemFunctionCallOutputAgentParam:
//	case *openai.BetaResponseInputItemAgentMessageAgentParam:
//	case *openai.BetaResponseInputItemMultiAgentCallAgentParam:
//	case *openai.BetaResponseInputItemMultiAgentCallOutputAgentParam:
//	case *openai.BetaResponseInputItemToolSearchCallAgentParam:
//	case *openai.BetaResponseToolSearchOutputItemParamAgent:
//	case *openai.BetaResponseInputItemAdditionalToolsAgentParam:
//	case *openai.BetaResponseReasoningItemAgentParam:
//	case *openai.BetaResponseCompactionItemParamAgent:
//	case *openai.BetaResponseInputItemImageGenerationCallAgentParam:
//	case *openai.BetaResponseCodeInterpreterToolCallAgentParam:
//	case *openai.BetaResponseInputItemLocalShellCallAgentParam:
//	case *openai.BetaResponseInputItemLocalShellCallOutputAgentParam:
//	case *openai.BetaResponseInputItemShellCallAgentParam:
//	case *openai.BetaResponseInputItemShellCallOutputAgentParam:
//	case *openai.BetaResponseInputItemApplyPatchCallAgentParam:
//	case *openai.BetaResponseInputItemApplyPatchCallOutputAgentParam:
//	case *openai.BetaResponseInputItemMcpListToolsAgentParam:
//	case *openai.BetaResponseInputItemMcpApprovalRequestAgentParam:
//	case *openai.BetaResponseInputItemMcpApprovalResponseAgentParam:
//	case *openai.BetaResponseInputItemMcpCallAgentParam:
//	case *openai.BetaResponseCustomToolCallOutputAgentParam:
//	case *openai.BetaResponseCustomToolCallAgentParam:
//	case *openai.BetaResponseInputItemCompactionTriggerAgentParam:
//	case *openai.BetaResponseInputItemItemReferenceAgentParam:
//	case *openai.BetaResponseInputItemProgramAgentParam:
//	case *openai.BetaResponseInputItemProgramOutputAgentParam:
//	default:
//	    fmt.Errorf("not present")
//	}
func (u betaResponseInputItemUnionParamAgent) AsAny() any { return u.any }

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseInputItemUnionParamAgent) GetAgentName() *string {
	switch vt := u.any.(type) {
	case *BetaResponseInputItemMessageAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseOutputMessageAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseFileSearchToolCallAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseComputerToolCallAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseInputItemComputerCallOutputAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseFunctionWebSearchAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseFunctionToolCallAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseInputItemFunctionCallOutputAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseInputItemAgentMessageAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseInputItemMultiAgentCallAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseInputItemMultiAgentCallOutputAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseInputItemToolSearchCallAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseToolSearchOutputItemParamAgent:
		return (*string)(&vt.AgentName)
	case *BetaResponseInputItemAdditionalToolsAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseReasoningItemAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseCompactionItemParamAgent:
		return (*string)(&vt.AgentName)
	case *BetaResponseInputItemImageGenerationCallAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseCodeInterpreterToolCallAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseInputItemLocalShellCallAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseInputItemLocalShellCallOutputAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseInputItemShellCallAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseInputItemShellCallOutputAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseInputItemApplyPatchCallAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseInputItemApplyPatchCallOutputAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseInputItemMcpListToolsAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseInputItemMcpApprovalRequestAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseInputItemMcpApprovalResponseAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseInputItemMcpCallAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseCustomToolCallOutputAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseCustomToolCallAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseInputItemCompactionTriggerAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseInputItemItemReferenceAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseInputItemProgramAgentParam:
		return (*string)(&vt.AgentName)
	case *BetaResponseInputItemProgramOutputAgentParam:
		return (*string)(&vt.AgentName)
	}
	return nil
}

// Returns a subunion which exports methods to access subproperties
//
// Or use AsAny() to get the underlying value
func (u BetaResponseInputItemUnionParam) GetAction() (res betaResponseInputItemUnionParamAction) {
	if vt := u.OfComputerCall; vt != nil {
		res.any = vt.Action.asAny()
	} else if vt := u.OfWebSearchCall; vt != nil {
		res.any = vt.Action.asAny()
	} else if vt := u.OfMultiAgentCall; vt != nil {
		res.any = &vt.Action
	} else if vt := u.OfMultiAgentCallOutput; vt != nil {
		res.any = &vt.Action
	} else if vt := u.OfLocalShellCall; vt != nil {
		res.any = &vt.Action
	} else if vt := u.OfShellCall; vt != nil {
		res.any = &vt.Action
	}
	return
}

// Can have the runtime types [*BetaComputerActionClickParam],
// [*BetaComputerActionDoubleClickParam], [*BetaComputerActionDragParam],
// [*BetaComputerActionKeypressParam], [*BetaComputerActionMoveParam],
// [*BetaComputerActionScreenshotParam], [*BetaComputerActionScrollParam],
// [*BetaComputerActionTypeParam], [*BetaComputerActionWaitParam],
// [*BetaResponseFunctionWebSearchActionSearchParam],
// [*BetaResponseFunctionWebSearchActionOpenPageParam],
// [*BetaResponseFunctionWebSearchActionFindInPageParam], [*string],
// [*BetaResponseInputItemLocalShellCallActionParam],
// [*BetaResponseInputItemShellCallActionParam]
type betaResponseInputItemUnionParamAction struct{ any }

// Use the following switch statement to get the type of the union:
//
//	switch u.AsAny().(type) {
//	case *openai.BetaComputerActionClickParam:
//	case *openai.BetaComputerActionDoubleClickParam:
//	case *openai.BetaComputerActionDragParam:
//	case *openai.BetaComputerActionKeypressParam:
//	case *openai.BetaComputerActionMoveParam:
//	case *openai.BetaComputerActionScreenshotParam:
//	case *openai.BetaComputerActionScrollParam:
//	case *openai.BetaComputerActionTypeParam:
//	case *openai.BetaComputerActionWaitParam:
//	case *openai.BetaResponseFunctionWebSearchActionSearchParam:
//	case *openai.BetaResponseFunctionWebSearchActionOpenPageParam:
//	case *openai.BetaResponseFunctionWebSearchActionFindInPageParam:
//	case *string:
//	case *openai.BetaResponseInputItemLocalShellCallActionParam:
//	case *openai.BetaResponseInputItemShellCallActionParam:
//	default:
//	    fmt.Errorf("not present")
//	}
func (u betaResponseInputItemUnionParamAction) AsAny() any { return u.any }

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseInputItemUnionParamAction) GetButton() *string {
	switch vt := u.any.(type) {
	case *BetaComputerActionUnionParam:
		return vt.GetButton()
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseInputItemUnionParamAction) GetPath() []BetaComputerActionDragPathParam {
	switch vt := u.any.(type) {
	case *BetaComputerActionUnionParam:
		return vt.GetPath()
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseInputItemUnionParamAction) GetScrollX() *int64 {
	switch vt := u.any.(type) {
	case *BetaComputerActionUnionParam:
		return vt.GetScrollX()
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseInputItemUnionParamAction) GetScrollY() *int64 {
	switch vt := u.any.(type) {
	case *BetaComputerActionUnionParam:
		return vt.GetScrollY()
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseInputItemUnionParamAction) GetText() *string {
	switch vt := u.any.(type) {
	case *BetaComputerActionUnionParam:
		return vt.GetText()
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseInputItemUnionParamAction) GetQueries() []string {
	switch vt := u.any.(type) {
	case *BetaResponseFunctionWebSearchActionUnionParam:
		return vt.GetQueries()
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseInputItemUnionParamAction) GetQuery() *string {
	switch vt := u.any.(type) {
	case *BetaResponseFunctionWebSearchActionUnionParam:
		return vt.GetQuery()
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseInputItemUnionParamAction) GetSources() []BetaResponseFunctionWebSearchActionSearchSourceParam {
	switch vt := u.any.(type) {
	case *BetaResponseFunctionWebSearchActionUnionParam:
		return vt.GetSources()
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseInputItemUnionParamAction) GetPattern() *string {
	switch vt := u.any.(type) {
	case *BetaResponseFunctionWebSearchActionUnionParam:
		return vt.GetPattern()
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseInputItemUnionParamAction) GetCommand() []string {
	switch vt := u.any.(type) {
	case *BetaResponseInputItemLocalShellCallActionParam:
		return vt.Command
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseInputItemUnionParamAction) GetEnv() map[string]string {
	switch vt := u.any.(type) {
	case *BetaResponseInputItemLocalShellCallActionParam:
		return vt.Env
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseInputItemUnionParamAction) GetUser() *string {
	switch vt := u.any.(type) {
	case *BetaResponseInputItemLocalShellCallActionParam:
		return paramutil.AddrIfPresent(vt.User)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseInputItemUnionParamAction) GetWorkingDirectory() *string {
	switch vt := u.any.(type) {
	case *BetaResponseInputItemLocalShellCallActionParam:
		return paramutil.AddrIfPresent(vt.WorkingDirectory)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseInputItemUnionParamAction) GetCommands() []string {
	switch vt := u.any.(type) {
	case *BetaResponseInputItemShellCallActionParam:
		return vt.Commands
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseInputItemUnionParamAction) GetMaxOutputLength() *int64 {
	switch vt := u.any.(type) {
	case *BetaResponseInputItemShellCallActionParam:
		return paramutil.AddrIfPresent(vt.MaxOutputLength)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseInputItemUnionParamAction) GetType() *string {
	switch vt := u.any.(type) {
	case *BetaComputerActionUnionParam:
		return vt.GetType()
	case *BetaResponseFunctionWebSearchActionUnionParam:
		return vt.GetType()
	case *BetaResponseInputItemLocalShellCallActionParam:
		return (*string)(&vt.Type)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseInputItemUnionParamAction) GetX() *int64 {
	switch vt := u.any.(type) {
	case *BetaComputerActionUnionParam:
		return vt.GetX()
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseInputItemUnionParamAction) GetY() *int64 {
	switch vt := u.any.(type) {
	case *BetaComputerActionUnionParam:
		return vt.GetY()
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseInputItemUnionParamAction) GetURL() *string {
	switch vt := u.any.(type) {
	case *BetaResponseFunctionWebSearchActionUnionParam:
		return vt.GetURL()
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseInputItemUnionParamAction) GetTimeoutMs() *int64 {
	switch vt := u.any.(type) {
	case *BetaResponseInputItemLocalShellCallActionParam:
		return paramutil.AddrIfPresent(vt.TimeoutMs)
	case *BetaResponseInputItemShellCallActionParam:
		return paramutil.AddrIfPresent(vt.TimeoutMs)
	}
	return nil
}

// Returns a pointer to the underlying variant's Keys property, if present.
func (u betaResponseInputItemUnionParamAction) GetKeys() []string {
	switch vt := u.any.(type) {
	case *BetaComputerActionUnionParam:
		return vt.GetKeys()
	}
	return nil
}

// Returns a subunion which exports methods to access subproperties
//
// Or use AsAny() to get the underlying value
func (u BetaResponseInputItemUnionParam) GetOutput() (res betaResponseInputItemUnionParamOutput) {
	if vt := u.OfComputerCallOutput; vt != nil {
		res.any = &vt.Output
	} else if vt := u.OfFunctionCallOutput; vt != nil {
		res.any = vt.Output.asAny()
	} else if vt := u.OfMultiAgentCallOutput; vt != nil {
		res.any = &vt.Output
	} else if vt := u.OfLocalShellCallOutput; vt != nil {
		res.any = &vt.Output
	} else if vt := u.OfShellCallOutput; vt != nil {
		res.any = &vt.Output
	} else if vt := u.OfApplyPatchCallOutput; vt != nil && vt.Output.Valid() {
		res.any = &vt.Output.Value
	} else if vt := u.OfMcpCall; vt != nil && vt.Output.Valid() {
		res.any = &vt.Output.Value
	} else if vt := u.OfCustomToolCallOutput; vt != nil {
		res.any = vt.Output.asAny()
	}
	return
}

// Can have the runtime types [*BetaResponseComputerToolCallOutputScreenshotParam],
// [*string], [*BetaResponseFunctionCallOutputItemListParam],
// [_[]BetaResponseInputItemMultiAgentCallOutputOutputParam],
// [_[]BetaResponseFunctionShellCallOutputContentParam],
// [\*[]BetaResponseCustomToolCallOutputOutputOutputContentListItemUnionParam]
type betaResponseInputItemUnionParamOutput struct{ any }

// Use the following switch statement to get the type of the union:
//
//	switch u.AsAny().(type) {
//	case *openai.BetaResponseComputerToolCallOutputScreenshotParam:
//	case *string:
//	case *openai.BetaResponseFunctionCallOutputItemListParam:
//	case *[]openai.BetaResponseInputItemMultiAgentCallOutputOutputParam:
//	case *[]openai.BetaResponseFunctionShellCallOutputContentParam:
//	case *[]openai.BetaResponseCustomToolCallOutputOutputOutputContentListItemUnionParam:
//	default:
//	    fmt.Errorf("not present")
//	}
func (u betaResponseInputItemUnionParamOutput) AsAny() any { return u.any }

// Returns a subunion which exports methods to access subproperties
//
// Or use AsAny() to get the underlying value
func (u BetaResponseInputItemUnionParam) GetArguments() (res betaResponseInputItemUnionParamArguments) {
	if vt := u.OfFunctionCall; vt != nil {
		res.any = &vt.Arguments
	} else if vt := u.OfMultiAgentCall; vt != nil {
		res.any = &vt.Arguments
	} else if vt := u.OfToolSearchCall; vt != nil {
		res.any = &vt.Arguments
	} else if vt := u.OfMcpApprovalRequest; vt != nil {
		res.any = &vt.Arguments
	} else if vt := u.OfMcpCall; vt != nil {
		res.any = &vt.Arguments
	}
	return
}

// Can have the runtime types [*string], [*any]
type betaResponseInputItemUnionParamArguments struct{ any }

// Use the following switch statement to get the type of the union:
//
//	switch u.AsAny().(type) {
//	case *string:
//	case *any:
//	default:
//	    fmt.Errorf("not present")
//	}
func (u betaResponseInputItemUnionParamArguments) AsAny() any { return u.any }

// Returns a subunion which exports methods to access subproperties
//
// Or use AsAny() to get the underlying value
func (u BetaResponseInputItemUnionParam) GetCaller() (res betaResponseInputItemUnionParamCaller) {
	if vt := u.OfFunctionCall; vt != nil {
		res.any = vt.Caller.asAny()
	} else if vt := u.OfFunctionCallOutput; vt != nil {
		res.any = vt.Caller.asAny()
	} else if vt := u.OfShellCall; vt != nil {
		res.any = vt.Caller.asAny()
	} else if vt := u.OfShellCallOutput; vt != nil {
		res.any = vt.Caller.asAny()
	} else if vt := u.OfApplyPatchCall; vt != nil {
		res.any = vt.Caller.asAny()
	} else if vt := u.OfApplyPatchCallOutput; vt != nil {
		res.any = vt.Caller.asAny()
	} else if vt := u.OfCustomToolCallOutput; vt != nil {
		res.any = vt.Caller.asAny()
	} else if vt := u.OfCustomToolCall; vt != nil {
		res.any = vt.Caller.asAny()
	}
	return
}

// Can have the runtime types [*BetaResponseFunctionToolCallCallerDirectParam],
// [*BetaResponseFunctionToolCallCallerProgramParam],
// [*BetaResponseInputItemFunctionCallOutputCallerDirectParam],
// [*BetaResponseInputItemFunctionCallOutputCallerProgramParam],
// [*BetaResponseInputItemShellCallCallerDirectParam],
// [*BetaResponseInputItemShellCallCallerProgramParam],
// [*BetaResponseInputItemShellCallOutputCallerDirectParam],
// [*BetaResponseInputItemShellCallOutputCallerProgramParam],
// [*BetaResponseInputItemApplyPatchCallCallerDirectParam],
// [*BetaResponseInputItemApplyPatchCallCallerProgramParam],
// [*BetaResponseInputItemApplyPatchCallOutputCallerDirectParam],
// [*BetaResponseInputItemApplyPatchCallOutputCallerProgramParam],
// [*BetaResponseCustomToolCallOutputCallerDirectParam],
// [*BetaResponseCustomToolCallOutputCallerProgramParam],
// [*BetaResponseCustomToolCallCallerDirectParam],
// [*BetaResponseCustomToolCallCallerProgramParam]
type betaResponseInputItemUnionParamCaller struct{ any }

// Use the following switch statement to get the type of the union:
//
//	switch u.AsAny().(type) {
//	case *openai.BetaResponseFunctionToolCallCallerDirectParam:
//	case *openai.BetaResponseFunctionToolCallCallerProgramParam:
//	case *openai.BetaResponseInputItemFunctionCallOutputCallerDirectParam:
//	case *openai.BetaResponseInputItemFunctionCallOutputCallerProgramParam:
//	case *openai.BetaResponseInputItemShellCallCallerDirectParam:
//	case *openai.BetaResponseInputItemShellCallCallerProgramParam:
//	case *openai.BetaResponseInputItemShellCallOutputCallerDirectParam:
//	case *openai.BetaResponseInputItemShellCallOutputCallerProgramParam:
//	case *openai.BetaResponseInputItemApplyPatchCallCallerDirectParam:
//	case *openai.BetaResponseInputItemApplyPatchCallCallerProgramParam:
//	case *openai.BetaResponseInputItemApplyPatchCallOutputCallerDirectParam:
//	case *openai.BetaResponseInputItemApplyPatchCallOutputCallerProgramParam:
//	case *openai.BetaResponseCustomToolCallOutputCallerDirectParam:
//	case *openai.BetaResponseCustomToolCallOutputCallerProgramParam:
//	case *openai.BetaResponseCustomToolCallCallerDirectParam:
//	case *openai.BetaResponseCustomToolCallCallerProgramParam:
//	default:
//	    fmt.Errorf("not present")
//	}
func (u betaResponseInputItemUnionParamCaller) AsAny() any { return u.any }

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseInputItemUnionParamCaller) GetType() *string {
	switch vt := u.any.(type) {
	case *BetaResponseFunctionToolCallCallerUnionParam:
		return vt.GetType()
	case *BetaResponseInputItemFunctionCallOutputCallerUnionParam:
		return vt.GetType()
	case *BetaResponseInputItemShellCallCallerUnionParam:
		return vt.GetType()
	case *BetaResponseInputItemShellCallOutputCallerUnionParam:
		return vt.GetType()
	case *BetaResponseInputItemApplyPatchCallCallerUnionParam:
		return vt.GetType()
	case *BetaResponseInputItemApplyPatchCallOutputCallerUnionParam:
		return vt.GetType()
	case *BetaResponseCustomToolCallOutputCallerUnionParam:
		return vt.GetType()
	case *BetaResponseCustomToolCallCallerUnionParam:
		return vt.GetType()
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseInputItemUnionParamCaller) GetCallerID() *string {
	switch vt := u.any.(type) {
	case *BetaResponseFunctionToolCallCallerUnionParam:
		return vt.GetCallerID()
	case *BetaResponseInputItemFunctionCallOutputCallerUnionParam:
		return vt.GetCallerID()
	case *BetaResponseInputItemShellCallCallerUnionParam:
		return vt.GetCallerID()
	case *BetaResponseInputItemShellCallOutputCallerUnionParam:
		return vt.GetCallerID()
	case *BetaResponseInputItemApplyPatchCallCallerUnionParam:
		return vt.GetCallerID()
	case *BetaResponseInputItemApplyPatchCallOutputCallerUnionParam:
		return vt.GetCallerID()
	case *BetaResponseCustomToolCallOutputCallerUnionParam:
		return vt.GetCallerID()
	case *BetaResponseCustomToolCallCallerUnionParam:
		return vt.GetCallerID()
	}
	return nil
}

// Returns a subunion which exports methods to access subproperties
//
// Or use AsAny() to get the underlying value
func (u BetaResponseInputItemUnionParam) GetTools() (res betaResponseInputItemUnionParamTools) {
	if vt := u.OfToolSearchOutput; vt != nil {
		res.any = &vt.Tools
	} else if vt := u.OfAdditionalTools; vt != nil {
		res.any = &vt.Tools
	} else if vt := u.OfMcpListTools; vt != nil {
		res.any = &vt.Tools
	}
	return
}

// Can have the runtime types [_[]BetaToolUnionParam],
// [_[]BetaResponseInputItemMcpListToolsToolParam]
type betaResponseInputItemUnionParamTools struct{ any }

// Use the following switch statement to get the type of the union:
//
//	switch u.AsAny().(type) {
//	case *[]openai.BetaToolUnionParam:
//	case *[]openai.BetaResponseInputItemMcpListToolsToolParam:
//	default:
//	    fmt.Errorf("not present")
//	}
func (u betaResponseInputItemUnionParamTools) AsAny() any { return u.any }

func init() {
	apijson.RegisterUnion[BetaResponseInputItemUnionParam](
		"type",
		apijson.Discriminator[BetaEasyInputMessageParam]("message"),
		apijson.Discriminator[BetaResponseInputItemMessageParam]("message"),
		apijson.Discriminator[BetaResponseOutputMessageParam]("message"),
		apijson.Discriminator[BetaResponseFileSearchToolCallParam]("file_search_call"),
		apijson.Discriminator[BetaResponseComputerToolCallParam]("computer_call"),
		apijson.Discriminator[BetaResponseInputItemComputerCallOutputParam]("computer_call_output"),
		apijson.Discriminator[BetaResponseFunctionWebSearchParam]("web_search_call"),
		apijson.Discriminator[BetaResponseFunctionToolCallParam]("function_call"),
		apijson.Discriminator[BetaResponseInputItemFunctionCallOutputParam]("function_call_output"),
		apijson.Discriminator[BetaResponseInputItemAgentMessageParam]("agent_message"),
		apijson.Discriminator[BetaResponseInputItemMultiAgentCallParam]("multi_agent_call"),
		apijson.Discriminator[BetaResponseInputItemMultiAgentCallOutputParam]("multi_agent_call_output"),
		apijson.Discriminator[BetaResponseInputItemToolSearchCallParam]("tool_search_call"),
		apijson.Discriminator[BetaResponseToolSearchOutputItemParam]("tool_search_output"),
		apijson.Discriminator[BetaResponseInputItemAdditionalToolsParam]("additional_tools"),
		apijson.Discriminator[BetaResponseReasoningItemParam]("reasoning"),
		apijson.Discriminator[BetaResponseCompactionItemParam]("compaction"),
		apijson.Discriminator[BetaResponseInputItemImageGenerationCallParam]("image_generation_call"),
		apijson.Discriminator[BetaResponseCodeInterpreterToolCallParam]("code_interpreter_call"),
		apijson.Discriminator[BetaResponseInputItemLocalShellCallParam]("local_shell_call"),
		apijson.Discriminator[BetaResponseInputItemLocalShellCallOutputParam]("local_shell_call_output"),
		apijson.Discriminator[BetaResponseInputItemShellCallParam]("shell_call"),
		apijson.Discriminator[BetaResponseInputItemShellCallOutputParam]("shell_call_output"),
		apijson.Discriminator[BetaResponseInputItemApplyPatchCallParam]("apply_patch_call"),
		apijson.Discriminator[BetaResponseInputItemApplyPatchCallOutputParam]("apply_patch_call_output"),
		apijson.Discriminator[BetaResponseInputItemMcpListToolsParam]("mcp_list_tools"),
		apijson.Discriminator[BetaResponseInputItemMcpApprovalRequestParam]("mcp_approval_request"),
		apijson.Discriminator[BetaResponseInputItemMcpApprovalResponseParam]("mcp_approval_response"),
		apijson.Discriminator[BetaResponseInputItemMcpCallParam]("mcp_call"),
		apijson.Discriminator[BetaResponseCustomToolCallOutputParam]("custom_tool_call_output"),
		apijson.Discriminator[BetaResponseCustomToolCallParam]("custom_tool_call"),
		apijson.Discriminator[BetaResponseInputItemCompactionTriggerParam]("compaction_trigger"),
		apijson.Discriminator[BetaResponseInputItemItemReferenceParam]("item_reference"),
		apijson.Discriminator[BetaResponseInputItemProgramParam]("program"),
		apijson.Discriminator[BetaResponseInputItemProgramOutputParam]("program_output"),
	)
}

// A message input to the model with a role indicating instruction following
// hierarchy. Instructions given with the `developer` or `system` role take
// precedence over instructions given with the `user` role.
//
// The properties Content, Role are required.
type BetaResponseInputItemMessageParam struct {
	// A list of one or many input items to the model, containing different content
	// types.
	Content BetaResponseInputMessageContentListParam `json:"content,omitzero" api:"required"`
	// The role of the message input. One of `user`, `system`, or `developer`.
	//
	// Any of "user", "system", "developer".
	Role string `json:"role,omitzero" api:"required"`
	// The agent that produced this item.
	Agent BetaResponseInputItemMessageAgentParam `json:"agent,omitzero"`
	// The status of item. One of `in_progress`, `completed`, or `incomplete`.
	// Populated when items are returned via API.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status string `json:"status,omitzero"`
	// The type of the message input. Always set to `message`.
	//
	// Any of "message".
	Type string `json:"type,omitzero"`
	paramObj
}

func (r BetaResponseInputItemMessageParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemMessageParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemMessageParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaResponseInputItemMessageParam](
		"role", "user", "system", "developer",
	)
	apijson.RegisterFieldValidator[BetaResponseInputItemMessageParam](
		"status", "in_progress", "completed", "incomplete",
	)
	apijson.RegisterFieldValidator[BetaResponseInputItemMessageParam](
		"type", "message",
	)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseInputItemMessageAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseInputItemMessageAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemMessageAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemMessageAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The output of a computer tool call.
//
// The properties CallID, Output, Type are required.
type BetaResponseInputItemComputerCallOutputParam struct {
	// The ID of the computer tool call that produced the output.
	CallID string `json:"call_id" api:"required"`
	// A computer screenshot image used with the computer use tool.
	Output BetaResponseComputerToolCallOutputScreenshotParam `json:"output,omitzero" api:"required"`
	// The ID of the computer tool call output.
	ID param.Opt[string] `json:"id,omitzero"`
	// The safety checks reported by the API that have been acknowledged by the
	// developer.
	AcknowledgedSafetyChecks []BetaResponseInputItemComputerCallOutputAcknowledgedSafetyCheckParam `json:"acknowledged_safety_checks,omitzero"`
	// The agent that produced this item.
	Agent BetaResponseInputItemComputerCallOutputAgentParam `json:"agent,omitzero"`
	// The status of the message input. One of `in_progress`, `completed`, or
	// `incomplete`. Populated when input items are returned via API.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status string `json:"status,omitzero"`
	// The type of the computer tool call output. Always `computer_call_output`.
	//
	// This field can be elided, and will marshal its zero value as
	// "computer_call_output".
	Type constant.ComputerCallOutput `json:"type" default:"computer_call_output"`
	paramObj
}

func (r BetaResponseInputItemComputerCallOutputParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemComputerCallOutputParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemComputerCallOutputParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaResponseInputItemComputerCallOutputParam](
		"status", "in_progress", "completed", "incomplete",
	)
}

// A pending safety check for the computer call.
//
// The property ID is required.
type BetaResponseInputItemComputerCallOutputAcknowledgedSafetyCheckParam struct {
	// The ID of the pending safety check.
	ID string `json:"id" api:"required"`
	// The type of the pending safety check.
	Code param.Opt[string] `json:"code,omitzero"`
	// Details about the pending safety check.
	Message param.Opt[string] `json:"message,omitzero"`
	paramObj
}

func (r BetaResponseInputItemComputerCallOutputAcknowledgedSafetyCheckParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemComputerCallOutputAcknowledgedSafetyCheckParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemComputerCallOutputAcknowledgedSafetyCheckParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseInputItemComputerCallOutputAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseInputItemComputerCallOutputAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemComputerCallOutputAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemComputerCallOutputAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The output of a function tool call.
//
// The properties CallID, Output, Type are required.
type BetaResponseInputItemFunctionCallOutputParam struct {
	// The unique ID of the function tool call generated by the model.
	CallID string `json:"call_id" api:"required"`
	// Text, image, or file output of the function tool call.
	Output BetaResponseInputItemFunctionCallOutputOutputUnionParam `json:"output,omitzero" api:"required"`
	// The unique ID of the function tool call output. Populated when this item is
	// returned via API.
	ID param.Opt[string] `json:"id,omitzero"`
	// The agent that produced this item.
	Agent BetaResponseInputItemFunctionCallOutputAgentParam `json:"agent,omitzero"`
	// The execution context that produced this tool call.
	Caller BetaResponseInputItemFunctionCallOutputCallerUnionParam `json:"caller,omitzero"`
	// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
	// Populated when items are returned via API.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status string `json:"status,omitzero"`
	// The type of the function tool call output. Always `function_call_output`.
	//
	// This field can be elided, and will marshal its zero value as
	// "function_call_output".
	Type constant.FunctionCallOutput `json:"type" default:"function_call_output"`
	paramObj
}

func (r BetaResponseInputItemFunctionCallOutputParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemFunctionCallOutputParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemFunctionCallOutputParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaResponseInputItemFunctionCallOutputParam](
		"status", "in_progress", "completed", "incomplete",
	)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseInputItemFunctionCallOutputOutputUnionParam struct {
	OfString                                  param.Opt[string]                           `json:",omitzero,inline"`
	OfBetaResponseFunctionCallOutputItemArray BetaResponseFunctionCallOutputItemListParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseInputItemFunctionCallOutputOutputUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfString, u.OfBetaResponseFunctionCallOutputItemArray)
}
func (u *BetaResponseInputItemFunctionCallOutputOutputUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseInputItemFunctionCallOutputOutputUnionParam) asAny() any {
	if !param.IsOmitted(u.OfString) {
		return &u.OfString.Value
	} else if !param.IsOmitted(u.OfBetaResponseFunctionCallOutputItemArray) {
		return &u.OfBetaResponseFunctionCallOutputItemArray
	}
	return nil
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseInputItemFunctionCallOutputAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseInputItemFunctionCallOutputAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemFunctionCallOutputAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemFunctionCallOutputAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseInputItemFunctionCallOutputCallerUnionParam struct {
	OfDirect  *BetaResponseInputItemFunctionCallOutputCallerDirectParam  `json:",omitzero,inline"`
	OfProgram *BetaResponseInputItemFunctionCallOutputCallerProgramParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseInputItemFunctionCallOutputCallerUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfDirect, u.OfProgram)
}
func (u *BetaResponseInputItemFunctionCallOutputCallerUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseInputItemFunctionCallOutputCallerUnionParam) asAny() any {
	if !param.IsOmitted(u.OfDirect) {
		return u.OfDirect
	} else if !param.IsOmitted(u.OfProgram) {
		return u.OfProgram
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemFunctionCallOutputCallerUnionParam) GetCallerID() *string {
	if vt := u.OfProgram; vt != nil {
		return &vt.CallerID
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemFunctionCallOutputCallerUnionParam) GetType() *string {
	if vt := u.OfDirect; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfProgram; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaResponseInputItemFunctionCallOutputCallerUnionParam](
		"type",
		apijson.Discriminator[BetaResponseInputItemFunctionCallOutputCallerDirectParam]("direct"),
		apijson.Discriminator[BetaResponseInputItemFunctionCallOutputCallerProgramParam]("program"),
	)
}

func NewBetaResponseInputItemFunctionCallOutputCallerDirectParam() BetaResponseInputItemFunctionCallOutputCallerDirectParam {
	return BetaResponseInputItemFunctionCallOutputCallerDirectParam{
		Type: "direct",
	}
}

// This struct has a constant value, construct it with
// [NewBetaResponseInputItemFunctionCallOutputCallerDirectParam].
type BetaResponseInputItemFunctionCallOutputCallerDirectParam struct {
	// The caller type. Always `direct`.
	Type constant.Direct `json:"type" default:"direct"`
	paramObj
}

func (r BetaResponseInputItemFunctionCallOutputCallerDirectParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemFunctionCallOutputCallerDirectParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemFunctionCallOutputCallerDirectParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The properties CallerID, Type are required.
type BetaResponseInputItemFunctionCallOutputCallerProgramParam struct {
	// The call ID of the program item that produced this tool call.
	CallerID string `json:"caller_id" api:"required"`
	// The caller type. Always `program`.
	//
	// This field can be elided, and will marshal its zero value as "program".
	Type constant.Program `json:"type" default:"program"`
	paramObj
}

func (r BetaResponseInputItemFunctionCallOutputCallerProgramParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemFunctionCallOutputCallerProgramParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemFunctionCallOutputCallerProgramParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A message routed between agents.
//
// The properties Author, Content, Recipient, Type are required.
type BetaResponseInputItemAgentMessageParam struct {
	// The sending agent identity.
	Author string `json:"author" api:"required"`
	// Plaintext, image, or encrypted content sent between agents.
	Content []BetaResponseInputItemAgentMessageContentUnionParam `json:"content,omitzero" api:"required"`
	// The destination agent identity.
	Recipient string `json:"recipient" api:"required"`
	// The unique ID of this agent message item.
	ID param.Opt[string] `json:"id,omitzero"`
	// The agent that produced this item.
	Agent BetaResponseInputItemAgentMessageAgentParam `json:"agent,omitzero"`
	// The item type. Always `agent_message`.
	//
	// This field can be elided, and will marshal its zero value as "agent_message".
	Type constant.AgentMessage `json:"type" default:"agent_message"`
	paramObj
}

func (r BetaResponseInputItemAgentMessageParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemAgentMessageParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemAgentMessageParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseInputItemAgentMessageContentUnionParam struct {
	OfInputText        *BetaResponseInputTextContentParam                             `json:",omitzero,inline"`
	OfInputImage       *BetaResponseInputImageContentParam                            `json:",omitzero,inline"`
	OfEncryptedContent *BetaResponseInputItemAgentMessageContentEncryptedContentParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseInputItemAgentMessageContentUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfInputText, u.OfInputImage, u.OfEncryptedContent)
}
func (u *BetaResponseInputItemAgentMessageContentUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseInputItemAgentMessageContentUnionParam) asAny() any {
	if !param.IsOmitted(u.OfInputText) {
		return u.OfInputText
	} else if !param.IsOmitted(u.OfInputImage) {
		return u.OfInputImage
	} else if !param.IsOmitted(u.OfEncryptedContent) {
		return u.OfEncryptedContent
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemAgentMessageContentUnionParam) GetText() *string {
	if vt := u.OfInputText; vt != nil {
		return &vt.Text
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemAgentMessageContentUnionParam) GetDetail() *string {
	if vt := u.OfInputImage; vt != nil {
		return (*string)(&vt.Detail)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemAgentMessageContentUnionParam) GetFileID() *string {
	if vt := u.OfInputImage; vt != nil && vt.FileID.Valid() {
		return &vt.FileID.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemAgentMessageContentUnionParam) GetImageURL() *string {
	if vt := u.OfInputImage; vt != nil && vt.ImageURL.Valid() {
		return &vt.ImageURL.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemAgentMessageContentUnionParam) GetEncryptedContent() *string {
	if vt := u.OfEncryptedContent; vt != nil {
		return &vt.EncryptedContent
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemAgentMessageContentUnionParam) GetType() *string {
	if vt := u.OfInputText; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfInputImage; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfEncryptedContent; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

// Returns a subunion which exports methods to access subproperties
//
// Or use AsAny() to get the underlying value
func (u BetaResponseInputItemAgentMessageContentUnionParam) GetPromptCacheBreakpoint() (res betaResponseInputItemAgentMessageContentUnionParamPromptCacheBreakpoint) {
	if vt := u.OfInputText; vt != nil {
		res.any = &vt.PromptCacheBreakpoint
	} else if vt := u.OfInputImage; vt != nil {
		res.any = &vt.PromptCacheBreakpoint
	}
	return
}

// Can have the runtime types
// [*BetaResponseInputTextContentPromptCacheBreakpointParam],
// [*BetaResponseInputImageContentPromptCacheBreakpointParam]
type betaResponseInputItemAgentMessageContentUnionParamPromptCacheBreakpoint struct{ any }

// Use the following switch statement to get the type of the union:
//
//	switch u.AsAny().(type) {
//	case *openai.BetaResponseInputTextContentPromptCacheBreakpointParam:
//	case *openai.BetaResponseInputImageContentPromptCacheBreakpointParam:
//	default:
//	    fmt.Errorf("not present")
//	}
func (u betaResponseInputItemAgentMessageContentUnionParamPromptCacheBreakpoint) AsAny() any {
	return u.any
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponseInputItemAgentMessageContentUnionParamPromptCacheBreakpoint) GetMode() *string {
	switch vt := u.any.(type) {
	case *BetaResponseInputTextContentPromptCacheBreakpointParam:
		return (*string)(&vt.Mode)
	case *BetaResponseInputImageContentPromptCacheBreakpointParam:
		return (*string)(&vt.Mode)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaResponseInputItemAgentMessageContentUnionParam](
		"type",
		apijson.Discriminator[BetaResponseInputTextContentParam]("input_text"),
		apijson.Discriminator[BetaResponseInputImageContentParam]("input_image"),
		apijson.Discriminator[BetaResponseInputItemAgentMessageContentEncryptedContentParam]("encrypted_content"),
	)
}

// Opaque encrypted content that Responses API decrypts inside trusted model
// execution.
//
// The properties EncryptedContent, Type are required.
type BetaResponseInputItemAgentMessageContentEncryptedContentParam struct {
	// Opaque encrypted content.
	EncryptedContent string `json:"encrypted_content" api:"required"`
	// The type of the input item. Always `encrypted_content`.
	//
	// This field can be elided, and will marshal its zero value as
	// "encrypted_content".
	Type constant.EncryptedContent `json:"type" default:"encrypted_content"`
	paramObj
}

func (r BetaResponseInputItemAgentMessageContentEncryptedContentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemAgentMessageContentEncryptedContentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemAgentMessageContentEncryptedContentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseInputItemAgentMessageAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseInputItemAgentMessageAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemAgentMessageAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemAgentMessageAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The properties Action, Arguments, CallID, Type are required.
type BetaResponseInputItemMultiAgentCallParam struct {
	// The multi-agent action that was executed.
	//
	// Any of "spawn_agent", "interrupt_agent", "list_agents", "send_message",
	// "followup_task", "wait_agent".
	Action string `json:"action,omitzero" api:"required"`
	// The action arguments as a JSON string.
	Arguments string `json:"arguments" api:"required"`
	// The unique ID linking this call to its output.
	CallID string `json:"call_id" api:"required"`
	// The unique ID of this multi-agent call.
	ID param.Opt[string] `json:"id,omitzero"`
	// The agent that produced this item.
	Agent BetaResponseInputItemMultiAgentCallAgentParam `json:"agent,omitzero"`
	// The item type. Always `multi_agent_call`.
	//
	// This field can be elided, and will marshal its zero value as "multi_agent_call".
	Type constant.MultiAgentCall `json:"type" default:"multi_agent_call"`
	paramObj
}

func (r BetaResponseInputItemMultiAgentCallParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemMultiAgentCallParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemMultiAgentCallParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaResponseInputItemMultiAgentCallParam](
		"action", "spawn_agent", "interrupt_agent", "list_agents", "send_message", "followup_task", "wait_agent",
	)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseInputItemMultiAgentCallAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseInputItemMultiAgentCallAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemMultiAgentCallAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemMultiAgentCallAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The properties Action, CallID, Output, Type are required.
type BetaResponseInputItemMultiAgentCallOutputParam struct {
	// The multi-agent action that produced this result.
	//
	// Any of "spawn_agent", "interrupt_agent", "list_agents", "send_message",
	// "followup_task", "wait_agent".
	Action string `json:"action,omitzero" api:"required"`
	// The unique ID of the multi-agent call.
	CallID string `json:"call_id" api:"required"`
	// Text output returned by the multi-agent action.
	Output []BetaResponseInputItemMultiAgentCallOutputOutputParam `json:"output,omitzero" api:"required"`
	// The unique ID of this multi-agent call output.
	ID param.Opt[string] `json:"id,omitzero"`
	// The agent that produced this item.
	Agent BetaResponseInputItemMultiAgentCallOutputAgentParam `json:"agent,omitzero"`
	// The item type. Always `multi_agent_call_output`.
	//
	// This field can be elided, and will marshal its zero value as
	// "multi_agent_call_output".
	Type constant.MultiAgentCallOutput `json:"type" default:"multi_agent_call_output"`
	paramObj
}

func (r BetaResponseInputItemMultiAgentCallOutputParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemMultiAgentCallOutputParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemMultiAgentCallOutputParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaResponseInputItemMultiAgentCallOutputParam](
		"action", "spawn_agent", "interrupt_agent", "list_agents", "send_message", "followup_task", "wait_agent",
	)
}

// The properties Text, Type are required.
type BetaResponseInputItemMultiAgentCallOutputOutputParam struct {
	// The text content.
	Text string `json:"text" api:"required"`
	// Citations associated with the text content.
	Annotations []BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnionParam `json:"annotations,omitzero"`
	// The content type. Always `output_text`.
	//
	// This field can be elided, and will marshal its zero value as "output_text".
	Type constant.OutputText `json:"type" default:"output_text"`
	paramObj
}

func (r BetaResponseInputItemMultiAgentCallOutputOutputParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemMultiAgentCallOutputOutputParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemMultiAgentCallOutputOutputParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnionParam struct {
	OfFileCitation          *BetaResponseInputItemMultiAgentCallOutputOutputAnnotationFileCitationParam          `json:",omitzero,inline"`
	OfURLCitation           *BetaResponseInputItemMultiAgentCallOutputOutputAnnotationURLCitationParam           `json:",omitzero,inline"`
	OfContainerFileCitation *BetaResponseInputItemMultiAgentCallOutputOutputAnnotationContainerFileCitationParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfFileCitation, u.OfURLCitation, u.OfContainerFileCitation)
}
func (u *BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnionParam) asAny() any {
	if !param.IsOmitted(u.OfFileCitation) {
		return u.OfFileCitation
	} else if !param.IsOmitted(u.OfURLCitation) {
		return u.OfURLCitation
	} else if !param.IsOmitted(u.OfContainerFileCitation) {
		return u.OfContainerFileCitation
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnionParam) GetIndex() *int64 {
	if vt := u.OfFileCitation; vt != nil {
		return &vt.Index
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnionParam) GetTitle() *string {
	if vt := u.OfURLCitation; vt != nil {
		return &vt.Title
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnionParam) GetURL() *string {
	if vt := u.OfURLCitation; vt != nil {
		return &vt.URL
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnionParam) GetContainerID() *string {
	if vt := u.OfContainerFileCitation; vt != nil {
		return &vt.ContainerID
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnionParam) GetFileID() *string {
	if vt := u.OfFileCitation; vt != nil {
		return (*string)(&vt.FileID)
	} else if vt := u.OfContainerFileCitation; vt != nil {
		return (*string)(&vt.FileID)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnionParam) GetFilename() *string {
	if vt := u.OfFileCitation; vt != nil {
		return (*string)(&vt.Filename)
	} else if vt := u.OfContainerFileCitation; vt != nil {
		return (*string)(&vt.Filename)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnionParam) GetType() *string {
	if vt := u.OfFileCitation; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfURLCitation; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfContainerFileCitation; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnionParam) GetEndIndex() *int64 {
	if vt := u.OfURLCitation; vt != nil {
		return (*int64)(&vt.EndIndex)
	} else if vt := u.OfContainerFileCitation; vt != nil {
		return (*int64)(&vt.EndIndex)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnionParam) GetStartIndex() *int64 {
	if vt := u.OfURLCitation; vt != nil {
		return (*int64)(&vt.StartIndex)
	} else if vt := u.OfContainerFileCitation; vt != nil {
		return (*int64)(&vt.StartIndex)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaResponseInputItemMultiAgentCallOutputOutputAnnotationUnionParam](
		"type",
		apijson.Discriminator[BetaResponseInputItemMultiAgentCallOutputOutputAnnotationFileCitationParam]("file_citation"),
		apijson.Discriminator[BetaResponseInputItemMultiAgentCallOutputOutputAnnotationURLCitationParam]("url_citation"),
		apijson.Discriminator[BetaResponseInputItemMultiAgentCallOutputOutputAnnotationContainerFileCitationParam]("container_file_citation"),
	)
}

// The properties FileID, Filename, Index, Type are required.
type BetaResponseInputItemMultiAgentCallOutputOutputAnnotationFileCitationParam struct {
	// The ID of the file.
	FileID string `json:"file_id" api:"required"`
	// The filename of the file cited.
	Filename string `json:"filename" api:"required"`
	// The index of the file in the list of files.
	Index int64 `json:"index" api:"required"`
	// The citation type. Always `file_citation`.
	//
	// This field can be elided, and will marshal its zero value as "file_citation".
	Type constant.FileCitation `json:"type" default:"file_citation"`
	paramObj
}

func (r BetaResponseInputItemMultiAgentCallOutputOutputAnnotationFileCitationParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemMultiAgentCallOutputOutputAnnotationFileCitationParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemMultiAgentCallOutputOutputAnnotationFileCitationParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The properties EndIndex, StartIndex, Title, Type, URL are required.
type BetaResponseInputItemMultiAgentCallOutputOutputAnnotationURLCitationParam struct {
	// The index of the last character of the citation in the message.
	EndIndex int64 `json:"end_index" api:"required"`
	// The index of the first character of the citation in the message.
	StartIndex int64 `json:"start_index" api:"required"`
	// The title of the cited resource.
	Title string `json:"title" api:"required"`
	// The URL of the cited resource.
	URL string `json:"url" api:"required" format:"uri"`
	// The citation type. Always `url_citation`.
	//
	// This field can be elided, and will marshal its zero value as "url_citation".
	Type constant.URLCitation `json:"type" default:"url_citation"`
	paramObj
}

func (r BetaResponseInputItemMultiAgentCallOutputOutputAnnotationURLCitationParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemMultiAgentCallOutputOutputAnnotationURLCitationParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemMultiAgentCallOutputOutputAnnotationURLCitationParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The properties ContainerID, EndIndex, FileID, Filename, StartIndex, Type are
// required.
type BetaResponseInputItemMultiAgentCallOutputOutputAnnotationContainerFileCitationParam struct {
	// The ID of the container.
	ContainerID string `json:"container_id" api:"required"`
	// The index of the last character of the citation in the message.
	EndIndex int64 `json:"end_index" api:"required"`
	// The ID of the container file.
	FileID string `json:"file_id" api:"required"`
	// The filename of the container file cited.
	Filename string `json:"filename" api:"required"`
	// The index of the first character of the citation in the message.
	StartIndex int64 `json:"start_index" api:"required"`
	// The citation type. Always `container_file_citation`.
	//
	// This field can be elided, and will marshal its zero value as
	// "container_file_citation".
	Type constant.ContainerFileCitation `json:"type" default:"container_file_citation"`
	paramObj
}

func (r BetaResponseInputItemMultiAgentCallOutputOutputAnnotationContainerFileCitationParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemMultiAgentCallOutputOutputAnnotationContainerFileCitationParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemMultiAgentCallOutputOutputAnnotationContainerFileCitationParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseInputItemMultiAgentCallOutputAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseInputItemMultiAgentCallOutputAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemMultiAgentCallOutputAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemMultiAgentCallOutputAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The properties Arguments, Type are required.
type BetaResponseInputItemToolSearchCallParam struct {
	// The arguments supplied to the tool search call.
	Arguments any `json:"arguments,omitzero" api:"required"`
	// The unique ID of this tool search call.
	ID param.Opt[string] `json:"id,omitzero"`
	// The unique ID of the tool search call generated by the model.
	CallID param.Opt[string] `json:"call_id,omitzero"`
	// The agent that produced this item.
	Agent BetaResponseInputItemToolSearchCallAgentParam `json:"agent,omitzero"`
	// The status of the tool search call.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status string `json:"status,omitzero"`
	// Whether tool search was executed by the server or by the client.
	//
	// Any of "server", "client".
	Execution string `json:"execution,omitzero"`
	// The item type. Always `tool_search_call`.
	//
	// This field can be elided, and will marshal its zero value as "tool_search_call".
	Type constant.ToolSearchCall `json:"type" default:"tool_search_call"`
	paramObj
}

func (r BetaResponseInputItemToolSearchCallParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemToolSearchCallParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemToolSearchCallParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaResponseInputItemToolSearchCallParam](
		"execution", "server", "client",
	)
	apijson.RegisterFieldValidator[BetaResponseInputItemToolSearchCallParam](
		"status", "in_progress", "completed", "incomplete",
	)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseInputItemToolSearchCallAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseInputItemToolSearchCallAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemToolSearchCallAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemToolSearchCallAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The properties Role, Tools, Type are required.
type BetaResponseInputItemAdditionalToolsParam struct {
	// A list of additional tools made available at this item.
	Tools []BetaToolUnionParam `json:"tools,omitzero" api:"required"`
	// The unique ID of this additional tools item.
	ID param.Opt[string] `json:"id,omitzero"`
	// The agent that produced this item.
	Agent BetaResponseInputItemAdditionalToolsAgentParam `json:"agent,omitzero"`
	// The role that provided the additional tools. Only `developer` is supported.
	//
	// This field can be elided, and will marshal its zero value as "developer".
	Role constant.Developer `json:"role" default:"developer"`
	// The item type. Always `additional_tools`.
	//
	// This field can be elided, and will marshal its zero value as "additional_tools".
	Type constant.AdditionalTools `json:"type" default:"additional_tools"`
	paramObj
}

func (r BetaResponseInputItemAdditionalToolsParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemAdditionalToolsParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemAdditionalToolsParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseInputItemAdditionalToolsAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseInputItemAdditionalToolsAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemAdditionalToolsAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemAdditionalToolsAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// An image generation request made by the model.
//
// The properties ID, Result, Status, Type are required.
type BetaResponseInputItemImageGenerationCallParam struct {
	// The generated image encoded in base64.
	Result param.Opt[string] `json:"result,omitzero" api:"required"`
	// The unique ID of the image generation call.
	ID string `json:"id" api:"required"`
	// The status of the image generation call.
	//
	// Any of "in_progress", "completed", "generating", "failed".
	Status string `json:"status,omitzero" api:"required"`
	// The agent that produced this item.
	Agent BetaResponseInputItemImageGenerationCallAgentParam `json:"agent,omitzero"`
	// The type of the image generation call. Always `image_generation_call`.
	//
	// This field can be elided, and will marshal its zero value as
	// "image_generation_call".
	Type constant.ImageGenerationCall `json:"type" default:"image_generation_call"`
	paramObj
}

func (r BetaResponseInputItemImageGenerationCallParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemImageGenerationCallParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemImageGenerationCallParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaResponseInputItemImageGenerationCallParam](
		"status", "in_progress", "completed", "generating", "failed",
	)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseInputItemImageGenerationCallAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseInputItemImageGenerationCallAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemImageGenerationCallAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemImageGenerationCallAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool call to run a command on the local shell.
//
// The properties ID, Action, CallID, Status, Type are required.
type BetaResponseInputItemLocalShellCallParam struct {
	// The unique ID of the local shell call.
	ID string `json:"id" api:"required"`
	// Execute a shell command on the server.
	Action BetaResponseInputItemLocalShellCallActionParam `json:"action,omitzero" api:"required"`
	// The unique ID of the local shell tool call generated by the model.
	CallID string `json:"call_id" api:"required"`
	// The status of the local shell call.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status string `json:"status,omitzero" api:"required"`
	// The agent that produced this item.
	Agent BetaResponseInputItemLocalShellCallAgentParam `json:"agent,omitzero"`
	// The type of the local shell call. Always `local_shell_call`.
	//
	// This field can be elided, and will marshal its zero value as "local_shell_call".
	Type constant.LocalShellCall `json:"type" default:"local_shell_call"`
	paramObj
}

func (r BetaResponseInputItemLocalShellCallParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemLocalShellCallParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemLocalShellCallParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaResponseInputItemLocalShellCallParam](
		"status", "in_progress", "completed", "incomplete",
	)
}

// Execute a shell command on the server.
//
// The properties Command, Env, Type are required.
type BetaResponseInputItemLocalShellCallActionParam struct {
	// The command to run.
	Command []string `json:"command,omitzero" api:"required"`
	// Environment variables to set for the command.
	Env map[string]string `json:"env,omitzero" api:"required"`
	// Optional timeout in milliseconds for the command.
	TimeoutMs param.Opt[int64] `json:"timeout_ms,omitzero"`
	// Optional user to run the command as.
	User param.Opt[string] `json:"user,omitzero"`
	// Optional working directory to run the command in.
	WorkingDirectory param.Opt[string] `json:"working_directory,omitzero"`
	// The type of the local shell action. Always `exec`.
	//
	// This field can be elided, and will marshal its zero value as "exec".
	Type constant.Exec `json:"type" default:"exec"`
	paramObj
}

func (r BetaResponseInputItemLocalShellCallActionParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemLocalShellCallActionParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemLocalShellCallActionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseInputItemLocalShellCallAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseInputItemLocalShellCallAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemLocalShellCallAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemLocalShellCallAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The output of a local shell tool call.
//
// The properties ID, Output, Type are required.
type BetaResponseInputItemLocalShellCallOutputParam struct {
	// The unique ID of the local shell tool call generated by the model.
	ID string `json:"id" api:"required"`
	// A JSON string of the output of the local shell tool call.
	Output string `json:"output" api:"required"`
	// The agent that produced this item.
	Agent BetaResponseInputItemLocalShellCallOutputAgentParam `json:"agent,omitzero"`
	// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status string `json:"status,omitzero"`
	// The type of the local shell tool call output. Always `local_shell_call_output`.
	//
	// This field can be elided, and will marshal its zero value as
	// "local_shell_call_output".
	Type constant.LocalShellCallOutput `json:"type" default:"local_shell_call_output"`
	paramObj
}

func (r BetaResponseInputItemLocalShellCallOutputParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemLocalShellCallOutputParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemLocalShellCallOutputParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaResponseInputItemLocalShellCallOutputParam](
		"status", "in_progress", "completed", "incomplete",
	)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseInputItemLocalShellCallOutputAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseInputItemLocalShellCallOutputAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemLocalShellCallOutputAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemLocalShellCallOutputAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool representing a request to execute one or more shell commands.
//
// The properties Action, CallID, Type are required.
type BetaResponseInputItemShellCallParam struct {
	// The shell commands and limits that describe how to run the tool call.
	Action BetaResponseInputItemShellCallActionParam `json:"action,omitzero" api:"required"`
	// The unique ID of the shell tool call generated by the model.
	CallID string `json:"call_id" api:"required"`
	// The unique ID of the shell tool call. Populated when this item is returned via
	// API.
	ID param.Opt[string] `json:"id,omitzero"`
	// The agent that produced this item.
	Agent BetaResponseInputItemShellCallAgentParam `json:"agent,omitzero"`
	// The execution context that produced this tool call.
	Caller BetaResponseInputItemShellCallCallerUnionParam `json:"caller,omitzero"`
	// The environment to execute the shell commands in.
	Environment BetaResponseInputItemShellCallEnvironmentUnionParam `json:"environment,omitzero"`
	// The status of the shell call. One of `in_progress`, `completed`, or
	// `incomplete`.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status string `json:"status,omitzero"`
	// The type of the item. Always `shell_call`.
	//
	// This field can be elided, and will marshal its zero value as "shell_call".
	Type constant.ShellCall `json:"type" default:"shell_call"`
	paramObj
}

func (r BetaResponseInputItemShellCallParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemShellCallParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemShellCallParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaResponseInputItemShellCallParam](
		"status", "in_progress", "completed", "incomplete",
	)
}

// The shell commands and limits that describe how to run the tool call.
//
// The property Commands is required.
type BetaResponseInputItemShellCallActionParam struct {
	// Ordered shell commands for the execution environment to run.
	Commands []string `json:"commands,omitzero" api:"required"`
	// Maximum number of UTF-8 characters to capture from combined stdout and stderr
	// output.
	MaxOutputLength param.Opt[int64] `json:"max_output_length,omitzero"`
	// Maximum wall-clock time in milliseconds to allow the shell commands to run.
	TimeoutMs param.Opt[int64] `json:"timeout_ms,omitzero"`
	paramObj
}

func (r BetaResponseInputItemShellCallActionParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemShellCallActionParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemShellCallActionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseInputItemShellCallAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseInputItemShellCallAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemShellCallAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemShellCallAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseInputItemShellCallCallerUnionParam struct {
	OfDirect  *BetaResponseInputItemShellCallCallerDirectParam  `json:",omitzero,inline"`
	OfProgram *BetaResponseInputItemShellCallCallerProgramParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseInputItemShellCallCallerUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfDirect, u.OfProgram)
}
func (u *BetaResponseInputItemShellCallCallerUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseInputItemShellCallCallerUnionParam) asAny() any {
	if !param.IsOmitted(u.OfDirect) {
		return u.OfDirect
	} else if !param.IsOmitted(u.OfProgram) {
		return u.OfProgram
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemShellCallCallerUnionParam) GetCallerID() *string {
	if vt := u.OfProgram; vt != nil {
		return &vt.CallerID
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemShellCallCallerUnionParam) GetType() *string {
	if vt := u.OfDirect; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfProgram; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaResponseInputItemShellCallCallerUnionParam](
		"type",
		apijson.Discriminator[BetaResponseInputItemShellCallCallerDirectParam]("direct"),
		apijson.Discriminator[BetaResponseInputItemShellCallCallerProgramParam]("program"),
	)
}

func NewBetaResponseInputItemShellCallCallerDirectParam() BetaResponseInputItemShellCallCallerDirectParam {
	return BetaResponseInputItemShellCallCallerDirectParam{
		Type: "direct",
	}
}

// This struct has a constant value, construct it with
// [NewBetaResponseInputItemShellCallCallerDirectParam].
type BetaResponseInputItemShellCallCallerDirectParam struct {
	// The caller type. Always `direct`.
	Type constant.Direct `json:"type" default:"direct"`
	paramObj
}

func (r BetaResponseInputItemShellCallCallerDirectParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemShellCallCallerDirectParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemShellCallCallerDirectParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The properties CallerID, Type are required.
type BetaResponseInputItemShellCallCallerProgramParam struct {
	// The call ID of the program item that produced this tool call.
	CallerID string `json:"caller_id" api:"required"`
	// The caller type. Always `program`.
	//
	// This field can be elided, and will marshal its zero value as "program".
	Type constant.Program `json:"type" default:"program"`
	paramObj
}

func (r BetaResponseInputItemShellCallCallerProgramParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemShellCallCallerProgramParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemShellCallCallerProgramParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseInputItemShellCallEnvironmentUnionParam struct {
	OfLocal              *BetaLocalEnvironmentParam   `json:",omitzero,inline"`
	OfContainerReference *BetaContainerReferenceParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseInputItemShellCallEnvironmentUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfLocal, u.OfContainerReference)
}
func (u *BetaResponseInputItemShellCallEnvironmentUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseInputItemShellCallEnvironmentUnionParam) asAny() any {
	if !param.IsOmitted(u.OfLocal) {
		return u.OfLocal
	} else if !param.IsOmitted(u.OfContainerReference) {
		return u.OfContainerReference
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemShellCallEnvironmentUnionParam) GetSkills() []BetaLocalSkillParam {
	if vt := u.OfLocal; vt != nil {
		return vt.Skills
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemShellCallEnvironmentUnionParam) GetContainerID() *string {
	if vt := u.OfContainerReference; vt != nil {
		return &vt.ContainerID
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemShellCallEnvironmentUnionParam) GetType() *string {
	if vt := u.OfLocal; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfContainerReference; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaResponseInputItemShellCallEnvironmentUnionParam](
		"type",
		apijson.Discriminator[BetaLocalEnvironmentParam]("local"),
		apijson.Discriminator[BetaContainerReferenceParam]("container_reference"),
	)
}

// The streamed output items emitted by a shell tool call.
//
// The properties CallID, Output, Type are required.
type BetaResponseInputItemShellCallOutputParam struct {
	// The unique ID of the shell tool call generated by the model.
	CallID string `json:"call_id" api:"required"`
	// Captured chunks of stdout and stderr output, along with their associated
	// outcomes.
	Output []BetaResponseFunctionShellCallOutputContentParam `json:"output,omitzero" api:"required"`
	// The unique ID of the shell tool call output. Populated when this item is
	// returned via API.
	ID param.Opt[string] `json:"id,omitzero"`
	// The maximum number of UTF-8 characters captured for this shell call's combined
	// output.
	MaxOutputLength param.Opt[int64] `json:"max_output_length,omitzero"`
	// The agent that produced this item.
	Agent BetaResponseInputItemShellCallOutputAgentParam `json:"agent,omitzero"`
	// The execution context that produced this tool call.
	Caller BetaResponseInputItemShellCallOutputCallerUnionParam `json:"caller,omitzero"`
	// The status of the shell call output.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status string `json:"status,omitzero"`
	// The type of the item. Always `shell_call_output`.
	//
	// This field can be elided, and will marshal its zero value as
	// "shell_call_output".
	Type constant.ShellCallOutput `json:"type" default:"shell_call_output"`
	paramObj
}

func (r BetaResponseInputItemShellCallOutputParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemShellCallOutputParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemShellCallOutputParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaResponseInputItemShellCallOutputParam](
		"status", "in_progress", "completed", "incomplete",
	)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseInputItemShellCallOutputAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseInputItemShellCallOutputAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemShellCallOutputAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemShellCallOutputAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseInputItemShellCallOutputCallerUnionParam struct {
	OfDirect  *BetaResponseInputItemShellCallOutputCallerDirectParam  `json:",omitzero,inline"`
	OfProgram *BetaResponseInputItemShellCallOutputCallerProgramParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseInputItemShellCallOutputCallerUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfDirect, u.OfProgram)
}
func (u *BetaResponseInputItemShellCallOutputCallerUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseInputItemShellCallOutputCallerUnionParam) asAny() any {
	if !param.IsOmitted(u.OfDirect) {
		return u.OfDirect
	} else if !param.IsOmitted(u.OfProgram) {
		return u.OfProgram
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemShellCallOutputCallerUnionParam) GetCallerID() *string {
	if vt := u.OfProgram; vt != nil {
		return &vt.CallerID
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemShellCallOutputCallerUnionParam) GetType() *string {
	if vt := u.OfDirect; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfProgram; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaResponseInputItemShellCallOutputCallerUnionParam](
		"type",
		apijson.Discriminator[BetaResponseInputItemShellCallOutputCallerDirectParam]("direct"),
		apijson.Discriminator[BetaResponseInputItemShellCallOutputCallerProgramParam]("program"),
	)
}

func NewBetaResponseInputItemShellCallOutputCallerDirectParam() BetaResponseInputItemShellCallOutputCallerDirectParam {
	return BetaResponseInputItemShellCallOutputCallerDirectParam{
		Type: "direct",
	}
}

// This struct has a constant value, construct it with
// [NewBetaResponseInputItemShellCallOutputCallerDirectParam].
type BetaResponseInputItemShellCallOutputCallerDirectParam struct {
	// The caller type. Always `direct`.
	Type constant.Direct `json:"type" default:"direct"`
	paramObj
}

func (r BetaResponseInputItemShellCallOutputCallerDirectParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemShellCallOutputCallerDirectParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemShellCallOutputCallerDirectParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The properties CallerID, Type are required.
type BetaResponseInputItemShellCallOutputCallerProgramParam struct {
	// The call ID of the program item that produced this tool call.
	CallerID string `json:"caller_id" api:"required"`
	// The caller type. Always `program`.
	//
	// This field can be elided, and will marshal its zero value as "program".
	Type constant.Program `json:"type" default:"program"`
	paramObj
}

func (r BetaResponseInputItemShellCallOutputCallerProgramParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemShellCallOutputCallerProgramParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemShellCallOutputCallerProgramParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool call representing a request to create, delete, or update files using diff
// patches.
//
// The properties CallID, Operation, Status, Type are required.
type BetaResponseInputItemApplyPatchCallParam struct {
	// The unique ID of the apply patch tool call generated by the model.
	CallID string `json:"call_id" api:"required"`
	// The specific create, delete, or update instruction for the apply_patch tool
	// call.
	Operation BetaResponseInputItemApplyPatchCallOperationUnionParam `json:"operation,omitzero" api:"required"`
	// The status of the apply patch tool call. One of `in_progress` or `completed`.
	//
	// Any of "in_progress", "completed".
	Status string `json:"status,omitzero" api:"required"`
	// The unique ID of the apply patch tool call. Populated when this item is returned
	// via API.
	ID param.Opt[string] `json:"id,omitzero"`
	// The agent that produced this item.
	Agent BetaResponseInputItemApplyPatchCallAgentParam `json:"agent,omitzero"`
	// The execution context that produced this tool call.
	Caller BetaResponseInputItemApplyPatchCallCallerUnionParam `json:"caller,omitzero"`
	// The type of the item. Always `apply_patch_call`.
	//
	// This field can be elided, and will marshal its zero value as "apply_patch_call".
	Type constant.ApplyPatchCall `json:"type" default:"apply_patch_call"`
	paramObj
}

func (r BetaResponseInputItemApplyPatchCallParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemApplyPatchCallParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemApplyPatchCallParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaResponseInputItemApplyPatchCallParam](
		"status", "in_progress", "completed",
	)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseInputItemApplyPatchCallOperationUnionParam struct {
	OfCreateFile *BetaResponseInputItemApplyPatchCallOperationCreateFileParam `json:",omitzero,inline"`
	OfDeleteFile *BetaResponseInputItemApplyPatchCallOperationDeleteFileParam `json:",omitzero,inline"`
	OfUpdateFile *BetaResponseInputItemApplyPatchCallOperationUpdateFileParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseInputItemApplyPatchCallOperationUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfCreateFile, u.OfDeleteFile, u.OfUpdateFile)
}
func (u *BetaResponseInputItemApplyPatchCallOperationUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseInputItemApplyPatchCallOperationUnionParam) asAny() any {
	if !param.IsOmitted(u.OfCreateFile) {
		return u.OfCreateFile
	} else if !param.IsOmitted(u.OfDeleteFile) {
		return u.OfDeleteFile
	} else if !param.IsOmitted(u.OfUpdateFile) {
		return u.OfUpdateFile
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemApplyPatchCallOperationUnionParam) GetDiff() *string {
	if vt := u.OfCreateFile; vt != nil {
		return (*string)(&vt.Diff)
	} else if vt := u.OfUpdateFile; vt != nil {
		return (*string)(&vt.Diff)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemApplyPatchCallOperationUnionParam) GetPath() *string {
	if vt := u.OfCreateFile; vt != nil {
		return (*string)(&vt.Path)
	} else if vt := u.OfDeleteFile; vt != nil {
		return (*string)(&vt.Path)
	} else if vt := u.OfUpdateFile; vt != nil {
		return (*string)(&vt.Path)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemApplyPatchCallOperationUnionParam) GetType() *string {
	if vt := u.OfCreateFile; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfDeleteFile; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfUpdateFile; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaResponseInputItemApplyPatchCallOperationUnionParam](
		"type",
		apijson.Discriminator[BetaResponseInputItemApplyPatchCallOperationCreateFileParam]("create_file"),
		apijson.Discriminator[BetaResponseInputItemApplyPatchCallOperationDeleteFileParam]("delete_file"),
		apijson.Discriminator[BetaResponseInputItemApplyPatchCallOperationUpdateFileParam]("update_file"),
	)
}

// Instruction for creating a new file via the apply_patch tool.
//
// The properties Diff, Path, Type are required.
type BetaResponseInputItemApplyPatchCallOperationCreateFileParam struct {
	// Unified diff content to apply when creating the file.
	Diff string `json:"diff" api:"required"`
	// Path of the file to create relative to the workspace root.
	Path string `json:"path" api:"required"`
	// The operation type. Always `create_file`.
	//
	// This field can be elided, and will marshal its zero value as "create_file".
	Type constant.CreateFile `json:"type" default:"create_file"`
	paramObj
}

func (r BetaResponseInputItemApplyPatchCallOperationCreateFileParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemApplyPatchCallOperationCreateFileParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemApplyPatchCallOperationCreateFileParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Instruction for deleting an existing file via the apply_patch tool.
//
// The properties Path, Type are required.
type BetaResponseInputItemApplyPatchCallOperationDeleteFileParam struct {
	// Path of the file to delete relative to the workspace root.
	Path string `json:"path" api:"required"`
	// The operation type. Always `delete_file`.
	//
	// This field can be elided, and will marshal its zero value as "delete_file".
	Type constant.DeleteFile `json:"type" default:"delete_file"`
	paramObj
}

func (r BetaResponseInputItemApplyPatchCallOperationDeleteFileParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemApplyPatchCallOperationDeleteFileParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemApplyPatchCallOperationDeleteFileParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Instruction for updating an existing file via the apply_patch tool.
//
// The properties Diff, Path, Type are required.
type BetaResponseInputItemApplyPatchCallOperationUpdateFileParam struct {
	// Unified diff content to apply to the existing file.
	Diff string `json:"diff" api:"required"`
	// Path of the file to update relative to the workspace root.
	Path string `json:"path" api:"required"`
	// The operation type. Always `update_file`.
	//
	// This field can be elided, and will marshal its zero value as "update_file".
	Type constant.UpdateFile `json:"type" default:"update_file"`
	paramObj
}

func (r BetaResponseInputItemApplyPatchCallOperationUpdateFileParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemApplyPatchCallOperationUpdateFileParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemApplyPatchCallOperationUpdateFileParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseInputItemApplyPatchCallAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseInputItemApplyPatchCallAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemApplyPatchCallAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemApplyPatchCallAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseInputItemApplyPatchCallCallerUnionParam struct {
	OfDirect  *BetaResponseInputItemApplyPatchCallCallerDirectParam  `json:",omitzero,inline"`
	OfProgram *BetaResponseInputItemApplyPatchCallCallerProgramParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseInputItemApplyPatchCallCallerUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfDirect, u.OfProgram)
}
func (u *BetaResponseInputItemApplyPatchCallCallerUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseInputItemApplyPatchCallCallerUnionParam) asAny() any {
	if !param.IsOmitted(u.OfDirect) {
		return u.OfDirect
	} else if !param.IsOmitted(u.OfProgram) {
		return u.OfProgram
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemApplyPatchCallCallerUnionParam) GetCallerID() *string {
	if vt := u.OfProgram; vt != nil {
		return &vt.CallerID
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemApplyPatchCallCallerUnionParam) GetType() *string {
	if vt := u.OfDirect; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfProgram; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaResponseInputItemApplyPatchCallCallerUnionParam](
		"type",
		apijson.Discriminator[BetaResponseInputItemApplyPatchCallCallerDirectParam]("direct"),
		apijson.Discriminator[BetaResponseInputItemApplyPatchCallCallerProgramParam]("program"),
	)
}

func NewBetaResponseInputItemApplyPatchCallCallerDirectParam() BetaResponseInputItemApplyPatchCallCallerDirectParam {
	return BetaResponseInputItemApplyPatchCallCallerDirectParam{
		Type: "direct",
	}
}

// This struct has a constant value, construct it with
// [NewBetaResponseInputItemApplyPatchCallCallerDirectParam].
type BetaResponseInputItemApplyPatchCallCallerDirectParam struct {
	// The caller type. Always `direct`.
	Type constant.Direct `json:"type" default:"direct"`
	paramObj
}

func (r BetaResponseInputItemApplyPatchCallCallerDirectParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemApplyPatchCallCallerDirectParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemApplyPatchCallCallerDirectParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The properties CallerID, Type are required.
type BetaResponseInputItemApplyPatchCallCallerProgramParam struct {
	// The call ID of the program item that produced this tool call.
	CallerID string `json:"caller_id" api:"required"`
	// The caller type. Always `program`.
	//
	// This field can be elided, and will marshal its zero value as "program".
	Type constant.Program `json:"type" default:"program"`
	paramObj
}

func (r BetaResponseInputItemApplyPatchCallCallerProgramParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemApplyPatchCallCallerProgramParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemApplyPatchCallCallerProgramParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The streamed output emitted by an apply patch tool call.
//
// The properties CallID, Status, Type are required.
type BetaResponseInputItemApplyPatchCallOutputParam struct {
	// The unique ID of the apply patch tool call generated by the model.
	CallID string `json:"call_id" api:"required"`
	// The status of the apply patch tool call output. One of `completed` or `failed`.
	//
	// Any of "completed", "failed".
	Status string `json:"status,omitzero" api:"required"`
	// The unique ID of the apply patch tool call output. Populated when this item is
	// returned via API.
	ID param.Opt[string] `json:"id,omitzero"`
	// Optional human-readable log text from the apply patch tool (e.g., patch results
	// or errors).
	Output param.Opt[string] `json:"output,omitzero"`
	// The agent that produced this item.
	Agent BetaResponseInputItemApplyPatchCallOutputAgentParam `json:"agent,omitzero"`
	// The execution context that produced this tool call.
	Caller BetaResponseInputItemApplyPatchCallOutputCallerUnionParam `json:"caller,omitzero"`
	// The type of the item. Always `apply_patch_call_output`.
	//
	// This field can be elided, and will marshal its zero value as
	// "apply_patch_call_output".
	Type constant.ApplyPatchCallOutput `json:"type" default:"apply_patch_call_output"`
	paramObj
}

func (r BetaResponseInputItemApplyPatchCallOutputParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemApplyPatchCallOutputParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemApplyPatchCallOutputParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaResponseInputItemApplyPatchCallOutputParam](
		"status", "completed", "failed",
	)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseInputItemApplyPatchCallOutputAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseInputItemApplyPatchCallOutputAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemApplyPatchCallOutputAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemApplyPatchCallOutputAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseInputItemApplyPatchCallOutputCallerUnionParam struct {
	OfDirect  *BetaResponseInputItemApplyPatchCallOutputCallerDirectParam  `json:",omitzero,inline"`
	OfProgram *BetaResponseInputItemApplyPatchCallOutputCallerProgramParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseInputItemApplyPatchCallOutputCallerUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfDirect, u.OfProgram)
}
func (u *BetaResponseInputItemApplyPatchCallOutputCallerUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseInputItemApplyPatchCallOutputCallerUnionParam) asAny() any {
	if !param.IsOmitted(u.OfDirect) {
		return u.OfDirect
	} else if !param.IsOmitted(u.OfProgram) {
		return u.OfProgram
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemApplyPatchCallOutputCallerUnionParam) GetCallerID() *string {
	if vt := u.OfProgram; vt != nil {
		return &vt.CallerID
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseInputItemApplyPatchCallOutputCallerUnionParam) GetType() *string {
	if vt := u.OfDirect; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfProgram; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaResponseInputItemApplyPatchCallOutputCallerUnionParam](
		"type",
		apijson.Discriminator[BetaResponseInputItemApplyPatchCallOutputCallerDirectParam]("direct"),
		apijson.Discriminator[BetaResponseInputItemApplyPatchCallOutputCallerProgramParam]("program"),
	)
}

func NewBetaResponseInputItemApplyPatchCallOutputCallerDirectParam() BetaResponseInputItemApplyPatchCallOutputCallerDirectParam {
	return BetaResponseInputItemApplyPatchCallOutputCallerDirectParam{
		Type: "direct",
	}
}

// This struct has a constant value, construct it with
// [NewBetaResponseInputItemApplyPatchCallOutputCallerDirectParam].
type BetaResponseInputItemApplyPatchCallOutputCallerDirectParam struct {
	// The caller type. Always `direct`.
	Type constant.Direct `json:"type" default:"direct"`
	paramObj
}

func (r BetaResponseInputItemApplyPatchCallOutputCallerDirectParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemApplyPatchCallOutputCallerDirectParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemApplyPatchCallOutputCallerDirectParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The properties CallerID, Type are required.
type BetaResponseInputItemApplyPatchCallOutputCallerProgramParam struct {
	// The call ID of the program item that produced this tool call.
	CallerID string `json:"caller_id" api:"required"`
	// The caller type. Always `program`.
	//
	// This field can be elided, and will marshal its zero value as "program".
	Type constant.Program `json:"type" default:"program"`
	paramObj
}

func (r BetaResponseInputItemApplyPatchCallOutputCallerProgramParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemApplyPatchCallOutputCallerProgramParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemApplyPatchCallOutputCallerProgramParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A list of tools available on an MCP server.
//
// The properties ID, ServerLabel, Tools, Type are required.
type BetaResponseInputItemMcpListToolsParam struct {
	// The unique ID of the list.
	ID string `json:"id" api:"required"`
	// The label of the MCP server.
	ServerLabel string `json:"server_label" api:"required"`
	// The tools available on the server.
	Tools []BetaResponseInputItemMcpListToolsToolParam `json:"tools,omitzero" api:"required"`
	// Error message if the server could not list tools.
	Error param.Opt[string] `json:"error,omitzero"`
	// The agent that produced this item.
	Agent BetaResponseInputItemMcpListToolsAgentParam `json:"agent,omitzero"`
	// The type of the item. Always `mcp_list_tools`.
	//
	// This field can be elided, and will marshal its zero value as "mcp_list_tools".
	Type constant.McpListTools `json:"type" default:"mcp_list_tools"`
	paramObj
}

func (r BetaResponseInputItemMcpListToolsParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemMcpListToolsParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemMcpListToolsParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool available on an MCP server.
//
// The properties InputSchema, Name are required.
type BetaResponseInputItemMcpListToolsToolParam struct {
	// The JSON schema describing the tool's input.
	InputSchema any `json:"input_schema,omitzero" api:"required"`
	// The name of the tool.
	Name string `json:"name" api:"required"`
	// The description of the tool.
	Description param.Opt[string] `json:"description,omitzero"`
	// Additional annotations about the tool.
	Annotations any `json:"annotations,omitzero"`
	paramObj
}

func (r BetaResponseInputItemMcpListToolsToolParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemMcpListToolsToolParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemMcpListToolsToolParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseInputItemMcpListToolsAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseInputItemMcpListToolsAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemMcpListToolsAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemMcpListToolsAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A request for human approval of a tool invocation.
//
// The properties ID, Arguments, Name, ServerLabel, Type are required.
type BetaResponseInputItemMcpApprovalRequestParam struct {
	// The unique ID of the approval request.
	ID string `json:"id" api:"required"`
	// A JSON string of arguments for the tool.
	Arguments string `json:"arguments" api:"required"`
	// The name of the tool to run.
	Name string `json:"name" api:"required"`
	// The label of the MCP server making the request.
	ServerLabel string `json:"server_label" api:"required"`
	// The agent that produced this item.
	Agent BetaResponseInputItemMcpApprovalRequestAgentParam `json:"agent,omitzero"`
	// The type of the item. Always `mcp_approval_request`.
	//
	// This field can be elided, and will marshal its zero value as
	// "mcp_approval_request".
	Type constant.McpApprovalRequest `json:"type" default:"mcp_approval_request"`
	paramObj
}

func (r BetaResponseInputItemMcpApprovalRequestParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemMcpApprovalRequestParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemMcpApprovalRequestParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseInputItemMcpApprovalRequestAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseInputItemMcpApprovalRequestAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemMcpApprovalRequestAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemMcpApprovalRequestAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A response to an MCP approval request.
//
// The properties ApprovalRequestID, Approve, Type are required.
type BetaResponseInputItemMcpApprovalResponseParam struct {
	// The ID of the approval request being answered.
	ApprovalRequestID string `json:"approval_request_id" api:"required"`
	// Whether the request was approved.
	Approve bool `json:"approve" api:"required"`
	// The unique ID of the approval response
	ID param.Opt[string] `json:"id,omitzero"`
	// Optional reason for the decision.
	Reason param.Opt[string] `json:"reason,omitzero"`
	// The agent that produced this item.
	Agent BetaResponseInputItemMcpApprovalResponseAgentParam `json:"agent,omitzero"`
	// The type of the item. Always `mcp_approval_response`.
	//
	// This field can be elided, and will marshal its zero value as
	// "mcp_approval_response".
	Type constant.McpApprovalResponse `json:"type" default:"mcp_approval_response"`
	paramObj
}

func (r BetaResponseInputItemMcpApprovalResponseParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemMcpApprovalResponseParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemMcpApprovalResponseParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseInputItemMcpApprovalResponseAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseInputItemMcpApprovalResponseAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemMcpApprovalResponseAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemMcpApprovalResponseAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// An invocation of a tool on an MCP server.
//
// The properties ID, Arguments, Name, ServerLabel, Type are required.
type BetaResponseInputItemMcpCallParam struct {
	// The unique ID of the tool call.
	ID string `json:"id" api:"required"`
	// A JSON string of the arguments passed to the tool.
	Arguments string `json:"arguments" api:"required"`
	// The name of the tool that was run.
	Name string `json:"name" api:"required"`
	// The label of the MCP server running the tool.
	ServerLabel string `json:"server_label" api:"required"`
	// Unique identifier for the MCP tool call approval request. Include this value in
	// a subsequent `mcp_approval_response` input to approve or reject the
	// corresponding tool call.
	ApprovalRequestID param.Opt[string] `json:"approval_request_id,omitzero"`
	// The error from the tool call, if any.
	Error param.Opt[string] `json:"error,omitzero"`
	// The output from the tool call.
	Output param.Opt[string] `json:"output,omitzero"`
	// The agent that produced this item.
	Agent BetaResponseInputItemMcpCallAgentParam `json:"agent,omitzero"`
	// The status of the tool call. One of `in_progress`, `completed`, `incomplete`,
	// `calling`, or `failed`.
	//
	// Any of "in_progress", "completed", "incomplete", "calling", "failed".
	Status string `json:"status,omitzero"`
	// The type of the item. Always `mcp_call`.
	//
	// This field can be elided, and will marshal its zero value as "mcp_call".
	Type constant.McpCall `json:"type" default:"mcp_call"`
	paramObj
}

func (r BetaResponseInputItemMcpCallParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemMcpCallParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemMcpCallParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaResponseInputItemMcpCallParam](
		"status", "in_progress", "completed", "incomplete", "calling", "failed",
	)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseInputItemMcpCallAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseInputItemMcpCallAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemMcpCallAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemMcpCallAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Compacts the current context. Must be the final input item.
//
// The property Type is required.
type BetaResponseInputItemCompactionTriggerParam struct {
	// The agent that produced this item.
	Agent BetaResponseInputItemCompactionTriggerAgentParam `json:"agent,omitzero"`
	// The type of the item. Always `compaction_trigger`.
	//
	// This field can be elided, and will marshal its zero value as
	// "compaction_trigger".
	Type constant.CompactionTrigger `json:"type" default:"compaction_trigger"`
	paramObj
}

func (r BetaResponseInputItemCompactionTriggerParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemCompactionTriggerParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemCompactionTriggerParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseInputItemCompactionTriggerAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseInputItemCompactionTriggerAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemCompactionTriggerAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemCompactionTriggerAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// An internal identifier for an item to reference.
//
// The property ID is required.
type BetaResponseInputItemItemReferenceParam struct {
	// The ID of the item to reference.
	ID string `json:"id" api:"required"`
	// The agent that produced this item.
	Agent BetaResponseInputItemItemReferenceAgentParam `json:"agent,omitzero"`
	// The type of item to reference. Always `item_reference`.
	//
	// Any of "item_reference".
	Type string `json:"type,omitzero"`
	paramObj
}

func (r BetaResponseInputItemItemReferenceParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemItemReferenceParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemItemReferenceParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaResponseInputItemItemReferenceParam](
		"type", "item_reference",
	)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseInputItemItemReferenceAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseInputItemItemReferenceAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemItemReferenceAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemItemReferenceAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The properties ID, CallID, Code, Fingerprint, Type are required.
type BetaResponseInputItemProgramParam struct {
	// The unique ID of this program item.
	ID string `json:"id" api:"required"`
	// The stable call ID of the program item.
	CallID string `json:"call_id" api:"required"`
	// The JavaScript source executed by programmatic tool calling.
	Code string `json:"code" api:"required"`
	// Opaque program replay fingerprint that must be round-tripped.
	Fingerprint string `json:"fingerprint" api:"required"`
	// The agent that produced this item.
	Agent BetaResponseInputItemProgramAgentParam `json:"agent,omitzero"`
	// The item type. Always `program`.
	//
	// This field can be elided, and will marshal its zero value as "program".
	Type constant.Program `json:"type" default:"program"`
	paramObj
}

func (r BetaResponseInputItemProgramParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemProgramParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemProgramParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseInputItemProgramAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseInputItemProgramAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemProgramAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemProgramAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The properties ID, CallID, Result, Status, Type are required.
type BetaResponseInputItemProgramOutputParam struct {
	// The unique ID of this program output item.
	ID string `json:"id" api:"required"`
	// The call ID of the program item.
	CallID string `json:"call_id" api:"required"`
	// The result produced by the program item.
	Result string `json:"result" api:"required"`
	// The terminal status of the program output.
	//
	// Any of "completed", "incomplete".
	Status string `json:"status,omitzero" api:"required"`
	// The agent that produced this item.
	Agent BetaResponseInputItemProgramOutputAgentParam `json:"agent,omitzero"`
	// The item type. Always `program_output`.
	//
	// This field can be elided, and will marshal its zero value as "program_output".
	Type constant.ProgramOutput `json:"type" default:"program_output"`
	paramObj
}

func (r BetaResponseInputItemProgramOutputParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemProgramOutputParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemProgramOutputParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaResponseInputItemProgramOutputParam](
		"status", "completed", "incomplete",
	)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseInputItemProgramOutputAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseInputItemProgramOutputAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputItemProgramOutputAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputItemProgramOutputAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseInputMessageContentList []BetaResponseInputContentUnion

type BetaResponseInputMessageContentListParam []BetaResponseInputContentUnionParam

type BetaResponseInputMessageItem struct {
	// The unique ID of the message input.
	ID string `json:"id" api:"required"`
	// A list of one or many input items to the model, containing different content
	// types.
	Content BetaResponseInputMessageContentList `json:"content" api:"required"`
	// The role of the message input. One of `user`, `system`, or `developer`.
	//
	// Any of "user", "system", "developer".
	Role BetaResponseInputMessageItemRole `json:"role" api:"required"`
	// The type of the message input. Always set to `message`.
	Type constant.Message `json:"type" default:"message"`
	// The agent that produced this item.
	Agent BetaResponseInputMessageItemAgent `json:"agent" api:"nullable"`
	// The status of item. One of `in_progress`, `completed`, or `incomplete`.
	// Populated when items are returned via API.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status BetaResponseInputMessageItemStatus `json:"status"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Content     respjson.Field
		Role        respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		Status      respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputMessageItem) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputMessageItem) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The role of the message input. One of `user`, `system`, or `developer`.
type BetaResponseInputMessageItemRole string

const (
	BetaResponseInputMessageItemRoleUser      BetaResponseInputMessageItemRole = "user"
	BetaResponseInputMessageItemRoleSystem    BetaResponseInputMessageItemRole = "system"
	BetaResponseInputMessageItemRoleDeveloper BetaResponseInputMessageItemRole = "developer"
)

// The agent that produced this item.
type BetaResponseInputMessageItemAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputMessageItemAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputMessageItemAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The status of item. One of `in_progress`, `completed`, or `incomplete`.
// Populated when items are returned via API.
type BetaResponseInputMessageItemStatus string

const (
	BetaResponseInputMessageItemStatusInProgress BetaResponseInputMessageItemStatus = "in_progress"
	BetaResponseInputMessageItemStatusCompleted  BetaResponseInputMessageItemStatus = "completed"
	BetaResponseInputMessageItemStatusIncomplete BetaResponseInputMessageItemStatus = "incomplete"
)

// A text input to the model.
type BetaResponseInputText struct {
	// The text input to the model.
	Text string `json:"text" api:"required"`
	// The type of the input item. Always `input_text`.
	Type constant.InputText `json:"type" default:"input_text"`
	// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
	// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
	// token block.
	PromptCacheBreakpoint BetaResponseInputTextPromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text                  respjson.Field
		Type                  respjson.Field
		PromptCacheBreakpoint respjson.Field
		ExtraFields           map[string]respjson.Field
		raw                   string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputText) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputText) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseInputText to a BetaResponseInputTextParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseInputTextParam.Overrides()
func (r BetaResponseInputText) ToParam() BetaResponseInputTextParam {
	return param.Override[BetaResponseInputTextParam](json.RawMessage(r.RawJSON()))
}

// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
// token block.
type BetaResponseInputTextPromptCacheBreakpoint struct {
	// The breakpoint mode. Always `explicit`.
	Mode constant.Explicit `json:"mode" default:"explicit"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Mode        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputTextPromptCacheBreakpoint) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputTextPromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A text input to the model.
//
// The properties Text, Type are required.
type BetaResponseInputTextParam struct {
	// The text input to the model.
	Text string `json:"text" api:"required"`
	// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
	// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
	// token block.
	PromptCacheBreakpoint BetaResponseInputTextPromptCacheBreakpointParam `json:"prompt_cache_breakpoint,omitzero"`
	// The type of the input item. Always `input_text`.
	//
	// This field can be elided, and will marshal its zero value as "input_text".
	Type constant.InputText `json:"type" default:"input_text"`
	paramObj
}

func (r BetaResponseInputTextParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputTextParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputTextParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func NewBetaResponseInputTextPromptCacheBreakpointParam() BetaResponseInputTextPromptCacheBreakpointParam {
	return BetaResponseInputTextPromptCacheBreakpointParam{
		Mode: "explicit",
	}
}

// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
// token block.
//
// This struct has a constant value, construct it with
// [NewBetaResponseInputTextPromptCacheBreakpointParam].
type BetaResponseInputTextPromptCacheBreakpointParam struct {
	// The breakpoint mode. Always `explicit`.
	Mode constant.Explicit `json:"mode" default:"explicit"`
	paramObj
}

func (r BetaResponseInputTextPromptCacheBreakpointParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputTextPromptCacheBreakpointParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputTextPromptCacheBreakpointParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A text input to the model.
type BetaResponseInputTextContent struct {
	// The text input to the model.
	Text string `json:"text" api:"required"`
	// The type of the input item. Always `input_text`.
	Type constant.InputText `json:"type" default:"input_text"`
	// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
	// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
	// token block.
	PromptCacheBreakpoint BetaResponseInputTextContentPromptCacheBreakpoint `json:"prompt_cache_breakpoint" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text                  respjson.Field
		Type                  respjson.Field
		PromptCacheBreakpoint respjson.Field
		ExtraFields           map[string]respjson.Field
		raw                   string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputTextContent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputTextContent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseInputTextContent to a
// BetaResponseInputTextContentParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseInputTextContentParam.Overrides()
func (r BetaResponseInputTextContent) ToParam() BetaResponseInputTextContentParam {
	return param.Override[BetaResponseInputTextContentParam](json.RawMessage(r.RawJSON()))
}

// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
// token block.
type BetaResponseInputTextContentPromptCacheBreakpoint struct {
	// The breakpoint mode. Always `explicit`.
	Mode constant.Explicit `json:"mode" default:"explicit"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Mode        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseInputTextContentPromptCacheBreakpoint) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseInputTextContentPromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A text input to the model.
//
// The properties Text, Type are required.
type BetaResponseInputTextContentParam struct {
	// The text input to the model.
	Text string `json:"text" api:"required"`
	// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
	// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
	// token block.
	PromptCacheBreakpoint BetaResponseInputTextContentPromptCacheBreakpointParam `json:"prompt_cache_breakpoint,omitzero"`
	// The type of the input item. Always `input_text`.
	//
	// This field can be elided, and will marshal its zero value as "input_text".
	Type constant.InputText `json:"type" default:"input_text"`
	paramObj
}

func (r BetaResponseInputTextContentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputTextContentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputTextContentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func NewBetaResponseInputTextContentPromptCacheBreakpointParam() BetaResponseInputTextContentPromptCacheBreakpointParam {
	return BetaResponseInputTextContentPromptCacheBreakpointParam{
		Mode: "explicit",
	}
}

// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
// token block.
//
// This struct has a constant value, construct it with
// [NewBetaResponseInputTextContentPromptCacheBreakpointParam].
type BetaResponseInputTextContentPromptCacheBreakpointParam struct {
	// The breakpoint mode. Always `explicit`.
	Mode constant.Explicit `json:"mode" default:"explicit"`
	paramObj
}

func (r BetaResponseInputTextContentPromptCacheBreakpointParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseInputTextContentPromptCacheBreakpointParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseInputTextContentPromptCacheBreakpointParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseItemUnion contains all possible properties and values from
// [BetaResponseInputMessageItem], [BetaResponseOutputMessage],
// [BetaResponseFileSearchToolCall], [BetaResponseComputerToolCall],
// [BetaResponseComputerToolCallOutputItem], [BetaResponseFunctionWebSearch],
// [BetaResponseFunctionToolCallItem], [BetaResponseFunctionToolCallOutputItem],
// [BetaResponseItemAgentMessage], [BetaResponseItemMultiAgentCall],
// [BetaResponseItemMultiAgentCallOutput], [BetaResponseToolSearchCall],
// [BetaResponseToolSearchOutputItem], [BetaResponseItemAdditionalTools],
// [BetaResponseReasoningItem], [BetaResponseItemProgram],
// [BetaResponseItemProgramOutput], [BetaResponseCompactionItem],
// [BetaResponseItemImageGenerationCall], [BetaResponseCodeInterpreterToolCall],
// [BetaResponseItemLocalShellCall], [BetaResponseItemLocalShellCallOutput],
// [BetaResponseFunctionShellToolCall], [BetaResponseFunctionShellToolCallOutput],
// [BetaResponseApplyPatchToolCall], [BetaResponseApplyPatchToolCallOutput],
// [BetaResponseItemMcpListTools], [BetaResponseItemMcpApprovalRequest],
// [BetaResponseItemMcpApprovalResponse], [BetaResponseItemMcpCall],
// [BetaResponseCustomToolCallItem], [BetaResponseCustomToolCallOutputItem].
//
// Use the [BetaResponseItemUnion.AsAny] method to switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseItemUnion struct {
	ID string `json:"id"`
	// This field is a union of [BetaResponseInputMessageContentList],
	// [[]BetaResponseOutputMessageContentUnion],
	// [[]BetaResponseItemAgentMessageContentUnion],
	// [[]BetaResponseReasoningItemContent]
	Content BetaResponseItemUnionContent `json:"content"`
	Role    string                       `json:"role"`
	// Any of "message", "message", "file_search_call", "computer_call",
	// "computer_call_output", "web_search_call", "function_call",
	// "function_call_output", "agent_message", "multi_agent_call",
	// "multi_agent_call_output", "tool_search_call", "tool_search_output",
	// "additional_tools", "reasoning", "program", "program_output", "compaction",
	// "image_generation_call", "code_interpreter_call", "local_shell_call",
	// "local_shell_call_output", "shell_call", "shell_call_output",
	// "apply_patch_call", "apply_patch_call_output", "mcp_list_tools",
	// "mcp_approval_request", "mcp_approval_response", "mcp_call", "custom_tool_call",
	// "custom_tool_call_output".
	Type string `json:"type"`
	// This field is a union of [BetaResponseInputMessageItemAgent],
	// [BetaResponseOutputMessageAgent], [BetaResponseFileSearchToolCallAgent],
	// [BetaResponseComputerToolCallAgent],
	// [BetaResponseComputerToolCallOutputItemAgent],
	// [BetaResponseFunctionWebSearchAgent], [BetaResponseFunctionToolCallAgent],
	// [BetaResponseFunctionToolCallOutputItemAgent],
	// [BetaResponseItemAgentMessageAgent], [BetaResponseItemMultiAgentCallAgent],
	// [BetaResponseItemMultiAgentCallOutputAgent], [BetaResponseToolSearchCallAgent],
	// [BetaResponseToolSearchOutputItemAgent], [BetaResponseItemAdditionalToolsAgent],
	// [BetaResponseReasoningItemAgent], [BetaResponseItemProgramAgent],
	// [BetaResponseItemProgramOutputAgent], [BetaResponseCompactionItemAgent],
	// [BetaResponseItemImageGenerationCallAgent],
	// [BetaResponseCodeInterpreterToolCallAgent],
	// [BetaResponseItemLocalShellCallAgent],
	// [BetaResponseItemLocalShellCallOutputAgent],
	// [BetaResponseFunctionShellToolCallAgent],
	// [BetaResponseFunctionShellToolCallOutputAgent],
	// [BetaResponseApplyPatchToolCallAgent],
	// [BetaResponseApplyPatchToolCallOutputAgent],
	// [BetaResponseItemMcpListToolsAgent], [BetaResponseItemMcpApprovalRequestAgent],
	// [BetaResponseItemMcpApprovalResponseAgent], [BetaResponseItemMcpCallAgent],
	// [BetaResponseCustomToolCallAgent], [BetaResponseCustomToolCallOutputAgent]
	Agent  BetaResponseItemUnionAgent `json:"agent"`
	Status string                     `json:"status"`
	// This field is from variant [BetaResponseOutputMessage].
	Phase BetaResponseOutputMessagePhase `json:"phase"`
	// This field is from variant [BetaResponseFileSearchToolCall].
	Queries []string `json:"queries"`
	// This field is from variant [BetaResponseFileSearchToolCall].
	Results []BetaResponseFileSearchToolCallResult `json:"results"`
	CallID  string                                 `json:"call_id"`
	// This field is from variant [BetaResponseComputerToolCall].
	PendingSafetyChecks []BetaResponseComputerToolCallPendingSafetyCheck `json:"pending_safety_checks"`
	// This field is a union of [BetaComputerActionUnion],
	// [BetaResponseFunctionWebSearchActionUnion], [string], [string],
	// [BetaResponseItemLocalShellCallAction],
	// [BetaResponseFunctionShellToolCallAction]
	Action BetaResponseItemUnionAction `json:"action"`
	// This field is from variant [BetaResponseComputerToolCall].
	Actions BetaComputerActionList `json:"actions"`
	// This field is a union of [BetaResponseComputerToolCallOutputScreenshot],
	// [BetaResponseFunctionToolCallOutputItemOutputUnion], [[]BetaResponseOutputText],
	// [string], [[]BetaResponseFunctionShellToolCallOutputOutput], [string], [string],
	// [BetaResponseCustomToolCallOutputOutputUnion]
	Output BetaResponseItemUnionOutput `json:"output"`
	// This field is from variant [BetaResponseComputerToolCallOutputItem].
	AcknowledgedSafetyChecks []BetaResponseComputerToolCallOutputItemAcknowledgedSafetyCheck `json:"acknowledged_safety_checks"`
	CreatedBy                string                                                          `json:"created_by"`
	// This field is a union of [string], [string], [any], [string], [string]
	Arguments BetaResponseItemUnionArguments `json:"arguments"`
	Name      string                         `json:"name"`
	// This field is a union of [BetaResponseFunctionToolCallCallerUnion],
	// [BetaResponseFunctionToolCallOutputItemCallerUnion],
	// [BetaResponseFunctionShellToolCallCallerUnion],
	// [BetaResponseFunctionShellToolCallOutputCallerUnion],
	// [BetaResponseApplyPatchToolCallCallerUnion],
	// [BetaResponseApplyPatchToolCallOutputCallerUnion],
	// [BetaResponseCustomToolCallCallerUnion],
	// [BetaResponseCustomToolCallOutputCallerUnion]
	Caller    BetaResponseItemUnionCaller `json:"caller"`
	Namespace string                      `json:"namespace"`
	// This field is from variant [BetaResponseItemAgentMessage].
	Author string `json:"author"`
	// This field is from variant [BetaResponseItemAgentMessage].
	Recipient string `json:"recipient"`
	Execution string `json:"execution"`
	// This field is a union of [[]BetaToolUnion], [[]BetaToolUnion],
	// [[]BetaResponseItemMcpListToolsTool]
	Tools BetaResponseItemUnionTools `json:"tools"`
	// This field is from variant [BetaResponseReasoningItem].
	Summary          []BetaResponseReasoningItemSummary `json:"summary"`
	EncryptedContent string                             `json:"encrypted_content"`
	Code             string                             `json:"code"`
	// This field is from variant [BetaResponseItemProgram].
	Fingerprint string `json:"fingerprint"`
	Result      string `json:"result"`
	// This field is from variant [BetaResponseCodeInterpreterToolCall].
	ContainerID string `json:"container_id"`
	// This field is from variant [BetaResponseCodeInterpreterToolCall].
	Outputs []BetaResponseCodeInterpreterToolCallOutputUnion `json:"outputs"`
	// This field is from variant [BetaResponseFunctionShellToolCall].
	Environment BetaResponseFunctionShellToolCallEnvironmentUnion `json:"environment"`
	// This field is from variant [BetaResponseFunctionShellToolCallOutput].
	MaxOutputLength int64 `json:"max_output_length"`
	// This field is from variant [BetaResponseApplyPatchToolCall].
	Operation         BetaResponseApplyPatchToolCallOperationUnion `json:"operation"`
	ServerLabel       string                                       `json:"server_label"`
	Error             string                                       `json:"error"`
	ApprovalRequestID string                                       `json:"approval_request_id"`
	// This field is from variant [BetaResponseItemMcpApprovalResponse].
	Approve bool `json:"approve"`
	// This field is from variant [BetaResponseItemMcpApprovalResponse].
	Reason string `json:"reason"`
	// This field is from variant [BetaResponseCustomToolCallItem].
	Input string `json:"input"`
	JSON  struct {
		ID                       respjson.Field
		Content                  respjson.Field
		Role                     respjson.Field
		Type                     respjson.Field
		Agent                    respjson.Field
		Status                   respjson.Field
		Phase                    respjson.Field
		Queries                  respjson.Field
		Results                  respjson.Field
		CallID                   respjson.Field
		PendingSafetyChecks      respjson.Field
		Action                   respjson.Field
		Actions                  respjson.Field
		Output                   respjson.Field
		AcknowledgedSafetyChecks respjson.Field
		CreatedBy                respjson.Field
		Arguments                respjson.Field
		Name                     respjson.Field
		Caller                   respjson.Field
		Namespace                respjson.Field
		Author                   respjson.Field
		Recipient                respjson.Field
		Execution                respjson.Field
		Tools                    respjson.Field
		Summary                  respjson.Field
		EncryptedContent         respjson.Field
		Code                     respjson.Field
		Fingerprint              respjson.Field
		Result                   respjson.Field
		ContainerID              respjson.Field
		Outputs                  respjson.Field
		Environment              respjson.Field
		MaxOutputLength          respjson.Field
		Operation                respjson.Field
		ServerLabel              respjson.Field
		Error                    respjson.Field
		ApprovalRequestID        respjson.Field
		Approve                  respjson.Field
		Reason                   respjson.Field
		Input                    respjson.Field
		raw                      string
	} `json:"-"`
}

// anyBetaResponseItem is implemented by each variant of [BetaResponseItemUnion] to
// add type safety for the return type of [BetaResponseItemUnion.AsAny]
type anyBetaResponseItem interface {
	implBetaResponseItemUnion()
}

func (BetaResponseInputMessageItem) implBetaResponseItemUnion()            {}
func (BetaResponseOutputMessage) implBetaResponseItemUnion()               {}
func (BetaResponseFileSearchToolCall) implBetaResponseItemUnion()          {}
func (BetaResponseComputerToolCall) implBetaResponseItemUnion()            {}
func (BetaResponseComputerToolCallOutputItem) implBetaResponseItemUnion()  {}
func (BetaResponseFunctionWebSearch) implBetaResponseItemUnion()           {}
func (BetaResponseFunctionToolCallItem) implBetaResponseItemUnion()        {}
func (BetaResponseFunctionToolCallOutputItem) implBetaResponseItemUnion()  {}
func (BetaResponseItemAgentMessage) implBetaResponseItemUnion()            {}
func (BetaResponseItemMultiAgentCall) implBetaResponseItemUnion()          {}
func (BetaResponseItemMultiAgentCallOutput) implBetaResponseItemUnion()    {}
func (BetaResponseToolSearchCall) implBetaResponseItemUnion()              {}
func (BetaResponseToolSearchOutputItem) implBetaResponseItemUnion()        {}
func (BetaResponseItemAdditionalTools) implBetaResponseItemUnion()         {}
func (BetaResponseReasoningItem) implBetaResponseItemUnion()               {}
func (BetaResponseItemProgram) implBetaResponseItemUnion()                 {}
func (BetaResponseItemProgramOutput) implBetaResponseItemUnion()           {}
func (BetaResponseCompactionItem) implBetaResponseItemUnion()              {}
func (BetaResponseItemImageGenerationCall) implBetaResponseItemUnion()     {}
func (BetaResponseCodeInterpreterToolCall) implBetaResponseItemUnion()     {}
func (BetaResponseItemLocalShellCall) implBetaResponseItemUnion()          {}
func (BetaResponseItemLocalShellCallOutput) implBetaResponseItemUnion()    {}
func (BetaResponseFunctionShellToolCall) implBetaResponseItemUnion()       {}
func (BetaResponseFunctionShellToolCallOutput) implBetaResponseItemUnion() {}
func (BetaResponseApplyPatchToolCall) implBetaResponseItemUnion()          {}
func (BetaResponseApplyPatchToolCallOutput) implBetaResponseItemUnion()    {}
func (BetaResponseItemMcpListTools) implBetaResponseItemUnion()            {}
func (BetaResponseItemMcpApprovalRequest) implBetaResponseItemUnion()      {}
func (BetaResponseItemMcpApprovalResponse) implBetaResponseItemUnion()     {}
func (BetaResponseItemMcpCall) implBetaResponseItemUnion()                 {}
func (BetaResponseCustomToolCallItem) implBetaResponseItemUnion()          {}
func (BetaResponseCustomToolCallOutputItem) implBetaResponseItemUnion()    {}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseItemUnion.AsAny().(type) {
//	case openai.BetaResponseInputMessageItem:
//	case openai.BetaResponseOutputMessage:
//	case openai.BetaResponseFileSearchToolCall:
//	case openai.BetaResponseComputerToolCall:
//	case openai.BetaResponseComputerToolCallOutputItem:
//	case openai.BetaResponseFunctionWebSearch:
//	case openai.BetaResponseFunctionToolCallItem:
//	case openai.BetaResponseFunctionToolCallOutputItem:
//	case openai.BetaResponseItemAgentMessage:
//	case openai.BetaResponseItemMultiAgentCall:
//	case openai.BetaResponseItemMultiAgentCallOutput:
//	case openai.BetaResponseToolSearchCall:
//	case openai.BetaResponseToolSearchOutputItem:
//	case openai.BetaResponseItemAdditionalTools:
//	case openai.BetaResponseReasoningItem:
//	case openai.BetaResponseItemProgram:
//	case openai.BetaResponseItemProgramOutput:
//	case openai.BetaResponseCompactionItem:
//	case openai.BetaResponseItemImageGenerationCall:
//	case openai.BetaResponseCodeInterpreterToolCall:
//	case openai.BetaResponseItemLocalShellCall:
//	case openai.BetaResponseItemLocalShellCallOutput:
//	case openai.BetaResponseFunctionShellToolCall:
//	case openai.BetaResponseFunctionShellToolCallOutput:
//	case openai.BetaResponseApplyPatchToolCall:
//	case openai.BetaResponseApplyPatchToolCallOutput:
//	case openai.BetaResponseItemMcpListTools:
//	case openai.BetaResponseItemMcpApprovalRequest:
//	case openai.BetaResponseItemMcpApprovalResponse:
//	case openai.BetaResponseItemMcpCall:
//	case openai.BetaResponseCustomToolCallItem:
//	case openai.BetaResponseCustomToolCallOutputItem:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseItemUnion) AsAny() anyBetaResponseItem {
	switch u.Type {
	case "message":
		return u.AsOutputMessage()
	case "file_search_call":
		return u.AsFileSearchCall()
	case "computer_call":
		return u.AsComputerCall()
	case "computer_call_output":
		return u.AsComputerCallOutput()
	case "web_search_call":
		return u.AsWebSearchCall()
	case "function_call":
		return u.AsFunctionCall()
	case "function_call_output":
		return u.AsFunctionCallOutput()
	case "agent_message":
		return u.AsAgentMessage()
	case "multi_agent_call":
		return u.AsMultiAgentCall()
	case "multi_agent_call_output":
		return u.AsMultiAgentCallOutput()
	case "tool_search_call":
		return u.AsToolSearchCall()
	case "tool_search_output":
		return u.AsToolSearchOutput()
	case "additional_tools":
		return u.AsAdditionalTools()
	case "reasoning":
		return u.AsReasoning()
	case "program":
		return u.AsProgram()
	case "program_output":
		return u.AsProgramOutput()
	case "compaction":
		return u.AsCompaction()
	case "image_generation_call":
		return u.AsImageGenerationCall()
	case "code_interpreter_call":
		return u.AsCodeInterpreterCall()
	case "local_shell_call":
		return u.AsLocalShellCall()
	case "local_shell_call_output":
		return u.AsLocalShellCallOutput()
	case "shell_call":
		return u.AsShellCall()
	case "shell_call_output":
		return u.AsShellCallOutput()
	case "apply_patch_call":
		return u.AsApplyPatchCall()
	case "apply_patch_call_output":
		return u.AsApplyPatchCallOutput()
	case "mcp_list_tools":
		return u.AsMcpListTools()
	case "mcp_approval_request":
		return u.AsMcpApprovalRequest()
	case "mcp_approval_response":
		return u.AsMcpApprovalResponse()
	case "mcp_call":
		return u.AsMcpCall()
	case "custom_tool_call":
		return u.AsCustomToolCall()
	case "custom_tool_call_output":
		return u.AsCustomToolCallOutput()
	}
	return nil
}

func (u BetaResponseItemUnion) AsMessage() (v BetaResponseInputMessageItem) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsOutputMessage() (v BetaResponseOutputMessage) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsFileSearchCall() (v BetaResponseFileSearchToolCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsComputerCall() (v BetaResponseComputerToolCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsComputerCallOutput() (v BetaResponseComputerToolCallOutputItem) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsWebSearchCall() (v BetaResponseFunctionWebSearch) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsFunctionCall() (v BetaResponseFunctionToolCallItem) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsFunctionCallOutput() (v BetaResponseFunctionToolCallOutputItem) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsAgentMessage() (v BetaResponseItemAgentMessage) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsMultiAgentCall() (v BetaResponseItemMultiAgentCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsMultiAgentCallOutput() (v BetaResponseItemMultiAgentCallOutput) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsToolSearchCall() (v BetaResponseToolSearchCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsToolSearchOutput() (v BetaResponseToolSearchOutputItem) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsAdditionalTools() (v BetaResponseItemAdditionalTools) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsReasoning() (v BetaResponseReasoningItem) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsProgram() (v BetaResponseItemProgram) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsProgramOutput() (v BetaResponseItemProgramOutput) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsCompaction() (v BetaResponseCompactionItem) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsImageGenerationCall() (v BetaResponseItemImageGenerationCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsCodeInterpreterCall() (v BetaResponseCodeInterpreterToolCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsLocalShellCall() (v BetaResponseItemLocalShellCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsLocalShellCallOutput() (v BetaResponseItemLocalShellCallOutput) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsShellCall() (v BetaResponseFunctionShellToolCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsShellCallOutput() (v BetaResponseFunctionShellToolCallOutput) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsApplyPatchCall() (v BetaResponseApplyPatchToolCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsApplyPatchCallOutput() (v BetaResponseApplyPatchToolCallOutput) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsMcpListTools() (v BetaResponseItemMcpListTools) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsMcpApprovalRequest() (v BetaResponseItemMcpApprovalRequest) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsMcpApprovalResponse() (v BetaResponseItemMcpApprovalResponse) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsMcpCall() (v BetaResponseItemMcpCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsCustomToolCall() (v BetaResponseCustomToolCallItem) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemUnion) AsCustomToolCallOutput() (v BetaResponseCustomToolCallOutputItem) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseItemUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseItemUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseItemUnionContent is an implicit subunion of [BetaResponseItemUnion].
// BetaResponseItemUnionContent provides convenient access to the sub-properties of
// the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseItemUnion].
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfInputItemContentList OfBetaResponseOutputMessageContentArray
// OfBetaResponseItemAgentMessageContentArray
// OfBetaResponseReasoningItemContentArray]
type BetaResponseItemUnionContent struct {
	// This field will be present if the value is a
	// [BetaResponseInputMessageContentList] instead of an object.
	OfInputItemContentList BetaResponseInputMessageContentList `json:",inline"`
	// This field will be present if the value is a
	// [[]BetaResponseOutputMessageContentUnion] instead of an object.
	OfBetaResponseOutputMessageContentArray []BetaResponseOutputMessageContentUnion `json:",inline"`
	// This field will be present if the value is a
	// [[]BetaResponseItemAgentMessageContentUnion] instead of an object.
	OfBetaResponseItemAgentMessageContentArray []BetaResponseItemAgentMessageContentUnion `json:",inline"`
	// This field will be present if the value is a
	// [[]BetaResponseReasoningItemContent] instead of an object.
	OfBetaResponseReasoningItemContentArray []BetaResponseReasoningItemContent `json:",inline"`
	JSON                                    struct {
		OfInputItemContentList                     respjson.Field
		OfBetaResponseOutputMessageContentArray    respjson.Field
		OfBetaResponseItemAgentMessageContentArray respjson.Field
		OfBetaResponseReasoningItemContentArray    respjson.Field
		raw                                        string
	} `json:"-"`
}

func (r *BetaResponseItemUnionContent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseItemUnionAgent is an implicit subunion of [BetaResponseItemUnion].
// BetaResponseItemUnionAgent provides convenient access to the sub-properties of
// the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseItemUnion].
type BetaResponseItemUnionAgent struct {
	AgentName string `json:"agent_name"`
	JSON      struct {
		AgentName respjson.Field
		raw       string
	} `json:"-"`
}

func (r *BetaResponseItemUnionAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseItemUnionAction is an implicit subunion of [BetaResponseItemUnion].
// BetaResponseItemUnionAction provides convenient access to the sub-properties of
// the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseItemUnion].
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfBetaResponseItemMultiAgentCallOutputAction]
type BetaResponseItemUnionAction struct {
	// This field will be present if the value is a [string] instead of an object.
	OfBetaResponseItemMultiAgentCallOutputAction string `json:",inline"`
	// This field is from variant [BetaComputerActionUnion].
	Button string   `json:"button"`
	Type   string   `json:"type"`
	X      int64    `json:"x"`
	Y      int64    `json:"y"`
	Keys   []string `json:"keys"`
	// This field is from variant [BetaComputerActionUnion].
	Path []BetaComputerActionDragPath `json:"path"`
	// This field is from variant [BetaComputerActionUnion].
	ScrollX int64 `json:"scroll_x"`
	// This field is from variant [BetaComputerActionUnion].
	ScrollY int64 `json:"scroll_y"`
	// This field is from variant [BetaComputerActionUnion].
	Text string `json:"text"`
	// This field is from variant [BetaResponseFunctionWebSearchActionUnion].
	Queries []string `json:"queries"`
	// This field is from variant [BetaResponseFunctionWebSearchActionUnion].
	Query string `json:"query"`
	// This field is from variant [BetaResponseFunctionWebSearchActionUnion].
	Sources []BetaResponseFunctionWebSearchActionSearchSource `json:"sources"`
	URL     string                                            `json:"url"`
	// This field is from variant [BetaResponseFunctionWebSearchActionUnion].
	Pattern string `json:"pattern"`
	// This field is from variant [BetaResponseItemLocalShellCallAction].
	Command []string `json:"command"`
	// This field is from variant [BetaResponseItemLocalShellCallAction].
	Env       map[string]string `json:"env"`
	TimeoutMs int64             `json:"timeout_ms"`
	// This field is from variant [BetaResponseItemLocalShellCallAction].
	User string `json:"user"`
	// This field is from variant [BetaResponseItemLocalShellCallAction].
	WorkingDirectory string `json:"working_directory"`
	// This field is from variant [BetaResponseFunctionShellToolCallAction].
	Commands []string `json:"commands"`
	// This field is from variant [BetaResponseFunctionShellToolCallAction].
	MaxOutputLength int64 `json:"max_output_length"`
	JSON            struct {
		OfBetaResponseItemMultiAgentCallOutputAction respjson.Field
		Button                                       respjson.Field
		Type                                         respjson.Field
		X                                            respjson.Field
		Y                                            respjson.Field
		Keys                                         respjson.Field
		Path                                         respjson.Field
		ScrollX                                      respjson.Field
		ScrollY                                      respjson.Field
		Text                                         respjson.Field
		Queries                                      respjson.Field
		Query                                        respjson.Field
		Sources                                      respjson.Field
		URL                                          respjson.Field
		Pattern                                      respjson.Field
		Command                                      respjson.Field
		Env                                          respjson.Field
		TimeoutMs                                    respjson.Field
		User                                         respjson.Field
		WorkingDirectory                             respjson.Field
		Commands                                     respjson.Field
		MaxOutputLength                              respjson.Field
		raw                                          string
	} `json:"-"`
}

func (r *BetaResponseItemUnionAction) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseItemUnionOutput is an implicit subunion of [BetaResponseItemUnion].
// BetaResponseItemUnionOutput provides convenient access to the sub-properties of
// the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseItemUnion].
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfString OfOutputContentList OfBetaResponseOutputTextArray
// OfBetaResponseFunctionShellToolCallOutputOutputArray]
type BetaResponseItemUnionOutput struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a
	// [[]BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion]
	// instead of an object.
	OfOutputContentList []BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion `json:",inline"`
	// This field will be present if the value is a [[]BetaResponseOutputText] instead
	// of an object.
	OfBetaResponseOutputTextArray []BetaResponseOutputText `json:",inline"`
	// This field will be present if the value is a
	// [[]BetaResponseFunctionShellToolCallOutputOutput] instead of an object.
	OfBetaResponseFunctionShellToolCallOutputOutputArray []BetaResponseFunctionShellToolCallOutputOutput `json:",inline"`
	// This field is from variant [BetaResponseComputerToolCallOutputScreenshot].
	Type constant.ComputerScreenshot `json:"type"`
	// This field is from variant [BetaResponseComputerToolCallOutputScreenshot].
	FileID string `json:"file_id"`
	// This field is from variant [BetaResponseComputerToolCallOutputScreenshot].
	ImageURL string `json:"image_url"`
	JSON     struct {
		OfString                                             respjson.Field
		OfOutputContentList                                  respjson.Field
		OfBetaResponseOutputTextArray                        respjson.Field
		OfBetaResponseFunctionShellToolCallOutputOutputArray respjson.Field
		Type                                                 respjson.Field
		FileID                                               respjson.Field
		ImageURL                                             respjson.Field
		raw                                                  string
	} `json:"-"`
}

func (r *BetaResponseItemUnionOutput) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseItemUnionArguments is an implicit subunion of
// [BetaResponseItemUnion]. BetaResponseItemUnionArguments provides convenient
// access to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseItemUnion].
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfString OfBetaResponseToolSearchCallArguments]
type BetaResponseItemUnionArguments struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a [any] instead of an object.
	OfBetaResponseToolSearchCallArguments any `json:",inline"`
	JSON                                  struct {
		OfString                              respjson.Field
		OfBetaResponseToolSearchCallArguments respjson.Field
		raw                                   string
	} `json:"-"`
}

func (r *BetaResponseItemUnionArguments) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseItemUnionCaller is an implicit subunion of [BetaResponseItemUnion].
// BetaResponseItemUnionCaller provides convenient access to the sub-properties of
// the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseItemUnion].
type BetaResponseItemUnionCaller struct {
	Type     string `json:"type"`
	CallerID string `json:"caller_id"`
	JSON     struct {
		Type     respjson.Field
		CallerID respjson.Field
		raw      string
	} `json:"-"`
}

func (r *BetaResponseItemUnionCaller) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseItemUnionTools is an implicit subunion of [BetaResponseItemUnion].
// BetaResponseItemUnionTools provides convenient access to the sub-properties of
// the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseItemUnion].
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfBetaToolArray OfBetaResponseItemMcpListToolsTools]
type BetaResponseItemUnionTools struct {
	// This field will be present if the value is a [[]BetaToolUnion] instead of an
	// object.
	OfBetaToolArray []BetaToolUnion `json:",inline"`
	// This field will be present if the value is a
	// [[]BetaResponseItemMcpListToolsTool] instead of an object.
	OfBetaResponseItemMcpListToolsTools []BetaResponseItemMcpListToolsTool `json:",inline"`
	JSON                                struct {
		OfBetaToolArray                     respjson.Field
		OfBetaResponseItemMcpListToolsTools respjson.Field
		raw                                 string
	} `json:"-"`
}

func (r *BetaResponseItemUnionTools) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseItemAgentMessage struct {
	// The unique ID of the agent message.
	ID string `json:"id" api:"required"`
	// The sending agent identity.
	Author string `json:"author" api:"required"`
	// Encrypted content sent between agents.
	Content []BetaResponseItemAgentMessageContentUnion `json:"content" api:"required"`
	// The destination agent identity.
	Recipient string `json:"recipient" api:"required"`
	// The type of the item. Always `agent_message`.
	Type constant.AgentMessage `json:"type" default:"agent_message"`
	// The agent that produced this item.
	Agent BetaResponseItemAgentMessageAgent `json:"agent"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Author      respjson.Field
		Content     respjson.Field
		Recipient   respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemAgentMessage) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemAgentMessage) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseItemAgentMessageContentUnion contains all possible properties and
// values from [BetaResponseInputText], [BetaResponseOutputText],
// [BetaResponseItemAgentMessageContentText],
// [BetaResponseItemAgentMessageContentSummaryText],
// [BetaResponseItemAgentMessageContentReasoningText], [BetaResponseOutputRefusal],
// [BetaResponseInputImage],
// [BetaResponseItemAgentMessageContentComputerScreenshot],
// [BetaResponseInputFile], [BetaResponseItemAgentMessageContentEncryptedContent].
//
// Use the [BetaResponseItemAgentMessageContentUnion.AsAny] method to switch on the
// variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseItemAgentMessageContentUnion struct {
	Text string `json:"text"`
	// Any of "input_text", "output_text", "text", "summary_text", "reasoning_text",
	// "refusal", "input_image", "computer_screenshot", "input_file",
	// "encrypted_content".
	Type string `json:"type"`
	// This field is a union of [BetaResponseInputTextPromptCacheBreakpoint],
	// [BetaResponseInputImagePromptCacheBreakpoint],
	// [BetaResponseItemAgentMessageContentComputerScreenshotPromptCacheBreakpoint],
	// [BetaResponseInputFilePromptCacheBreakpoint]
	PromptCacheBreakpoint BetaResponseItemAgentMessageContentUnionPromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
	// This field is from variant [BetaResponseOutputText].
	Annotations []BetaResponseOutputTextAnnotationUnion `json:"annotations"`
	// This field is from variant [BetaResponseOutputText].
	Logprobs []BetaResponseOutputTextLogprob `json:"logprobs"`
	// This field is from variant [BetaResponseOutputRefusal].
	Refusal  string `json:"refusal"`
	Detail   string `json:"detail"`
	FileID   string `json:"file_id"`
	ImageURL string `json:"image_url"`
	// This field is from variant [BetaResponseInputFile].
	FileData string `json:"file_data"`
	// This field is from variant [BetaResponseInputFile].
	FileURL string `json:"file_url"`
	// This field is from variant [BetaResponseInputFile].
	Filename string `json:"filename"`
	// This field is from variant
	// [BetaResponseItemAgentMessageContentEncryptedContent].
	EncryptedContent string `json:"encrypted_content"`
	JSON             struct {
		Text                  respjson.Field
		Type                  respjson.Field
		PromptCacheBreakpoint respjson.Field
		Annotations           respjson.Field
		Logprobs              respjson.Field
		Refusal               respjson.Field
		Detail                respjson.Field
		FileID                respjson.Field
		ImageURL              respjson.Field
		FileData              respjson.Field
		FileURL               respjson.Field
		Filename              respjson.Field
		EncryptedContent      respjson.Field
		raw                   string
	} `json:"-"`
}

// anyBetaResponseItemAgentMessageContent is implemented by each variant of
// [BetaResponseItemAgentMessageContentUnion] to add type safety for the return
// type of [BetaResponseItemAgentMessageContentUnion.AsAny]
type anyBetaResponseItemAgentMessageContent interface {
	implBetaResponseItemAgentMessageContentUnion()
}

func (BetaResponseInputText) implBetaResponseItemAgentMessageContentUnion()                   {}
func (BetaResponseOutputText) implBetaResponseItemAgentMessageContentUnion()                  {}
func (BetaResponseItemAgentMessageContentText) implBetaResponseItemAgentMessageContentUnion() {}
func (BetaResponseItemAgentMessageContentSummaryText) implBetaResponseItemAgentMessageContentUnion() {
}
func (BetaResponseItemAgentMessageContentReasoningText) implBetaResponseItemAgentMessageContentUnion() {
}
func (BetaResponseOutputRefusal) implBetaResponseItemAgentMessageContentUnion() {}
func (BetaResponseInputImage) implBetaResponseItemAgentMessageContentUnion()    {}
func (BetaResponseItemAgentMessageContentComputerScreenshot) implBetaResponseItemAgentMessageContentUnion() {
}
func (BetaResponseInputFile) implBetaResponseItemAgentMessageContentUnion() {}
func (BetaResponseItemAgentMessageContentEncryptedContent) implBetaResponseItemAgentMessageContentUnion() {
}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseItemAgentMessageContentUnion.AsAny().(type) {
//	case openai.BetaResponseInputText:
//	case openai.BetaResponseOutputText:
//	case openai.BetaResponseItemAgentMessageContentText:
//	case openai.BetaResponseItemAgentMessageContentSummaryText:
//	case openai.BetaResponseItemAgentMessageContentReasoningText:
//	case openai.BetaResponseOutputRefusal:
//	case openai.BetaResponseInputImage:
//	case openai.BetaResponseItemAgentMessageContentComputerScreenshot:
//	case openai.BetaResponseInputFile:
//	case openai.BetaResponseItemAgentMessageContentEncryptedContent:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseItemAgentMessageContentUnion) AsAny() anyBetaResponseItemAgentMessageContent {
	switch u.Type {
	case "input_text":
		return u.AsInputText()
	case "output_text":
		return u.AsOutputText()
	case "text":
		return u.AsText()
	case "summary_text":
		return u.AsSummaryText()
	case "reasoning_text":
		return u.AsReasoningText()
	case "refusal":
		return u.AsRefusal()
	case "input_image":
		return u.AsInputImage()
	case "computer_screenshot":
		return u.AsComputerScreenshot()
	case "input_file":
		return u.AsInputFile()
	case "encrypted_content":
		return u.AsEncryptedContent()
	}
	return nil
}

func (u BetaResponseItemAgentMessageContentUnion) AsInputText() (v BetaResponseInputText) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemAgentMessageContentUnion) AsOutputText() (v BetaResponseOutputText) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemAgentMessageContentUnion) AsText() (v BetaResponseItemAgentMessageContentText) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemAgentMessageContentUnion) AsSummaryText() (v BetaResponseItemAgentMessageContentSummaryText) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemAgentMessageContentUnion) AsReasoningText() (v BetaResponseItemAgentMessageContentReasoningText) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemAgentMessageContentUnion) AsRefusal() (v BetaResponseOutputRefusal) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemAgentMessageContentUnion) AsInputImage() (v BetaResponseInputImage) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemAgentMessageContentUnion) AsComputerScreenshot() (v BetaResponseItemAgentMessageContentComputerScreenshot) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemAgentMessageContentUnion) AsInputFile() (v BetaResponseInputFile) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseItemAgentMessageContentUnion) AsEncryptedContent() (v BetaResponseItemAgentMessageContentEncryptedContent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseItemAgentMessageContentUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseItemAgentMessageContentUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseItemAgentMessageContentUnionPromptCacheBreakpoint is an implicit
// subunion of [BetaResponseItemAgentMessageContentUnion].
// BetaResponseItemAgentMessageContentUnionPromptCacheBreakpoint provides
// convenient access to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseItemAgentMessageContentUnion].
type BetaResponseItemAgentMessageContentUnionPromptCacheBreakpoint struct {
	// This field is from variant [BetaResponseInputTextPromptCacheBreakpoint].
	Mode constant.Explicit `json:"mode"`
	JSON struct {
		Mode respjson.Field
		raw  string
	} `json:"-"`
}

func (r *BetaResponseItemAgentMessageContentUnionPromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A text content.
type BetaResponseItemAgentMessageContentText struct {
	Text string        `json:"text" api:"required"`
	Type constant.Text `json:"type" default:"text"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemAgentMessageContentText) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemAgentMessageContentText) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A summary text from the model.
type BetaResponseItemAgentMessageContentSummaryText struct {
	// A summary of the reasoning output from the model so far.
	Text string `json:"text" api:"required"`
	// The type of the object. Always `summary_text`.
	Type constant.SummaryText `json:"type" default:"summary_text"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemAgentMessageContentSummaryText) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemAgentMessageContentSummaryText) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Reasoning text from the model.
type BetaResponseItemAgentMessageContentReasoningText struct {
	// The reasoning text from the model.
	Text string `json:"text" api:"required"`
	// The type of the reasoning text. Always `reasoning_text`.
	Type constant.ReasoningText `json:"type" default:"reasoning_text"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemAgentMessageContentReasoningText) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemAgentMessageContentReasoningText) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A screenshot of a computer.
type BetaResponseItemAgentMessageContentComputerScreenshot struct {
	// The detail level of the screenshot image to be sent to the model. One of `high`,
	// `low`, `auto`, or `original`. Defaults to `auto`.
	//
	// Any of "low", "high", "auto", "original".
	Detail string `json:"detail" api:"required"`
	// The identifier of an uploaded file that contains the screenshot.
	FileID string `json:"file_id" api:"required"`
	// The URL of the screenshot image.
	ImageURL string `json:"image_url" api:"required" format:"uri"`
	// Specifies the event type. For a computer screenshot, this property is always set
	// to `computer_screenshot`.
	Type constant.ComputerScreenshot `json:"type" default:"computer_screenshot"`
	// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
	// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
	// token block.
	PromptCacheBreakpoint BetaResponseItemAgentMessageContentComputerScreenshotPromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Detail                respjson.Field
		FileID                respjson.Field
		ImageURL              respjson.Field
		Type                  respjson.Field
		PromptCacheBreakpoint respjson.Field
		ExtraFields           map[string]respjson.Field
		raw                   string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemAgentMessageContentComputerScreenshot) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemAgentMessageContentComputerScreenshot) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
// token block.
type BetaResponseItemAgentMessageContentComputerScreenshotPromptCacheBreakpoint struct {
	// The breakpoint mode. Always `explicit`.
	Mode constant.Explicit `json:"mode" default:"explicit"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Mode        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemAgentMessageContentComputerScreenshotPromptCacheBreakpoint) RawJSON() string {
	return r.JSON.raw
}
func (r *BetaResponseItemAgentMessageContentComputerScreenshotPromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Opaque encrypted content that Responses API decrypts inside trusted model
// execution.
type BetaResponseItemAgentMessageContentEncryptedContent struct {
	// Opaque encrypted content.
	EncryptedContent string `json:"encrypted_content" api:"required"`
	// The type of the input item. Always `encrypted_content`.
	Type constant.EncryptedContent `json:"type" default:"encrypted_content"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		EncryptedContent respjson.Field
		Type             respjson.Field
		ExtraFields      map[string]respjson.Field
		raw              string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemAgentMessageContentEncryptedContent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemAgentMessageContentEncryptedContent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseItemAgentMessageAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemAgentMessageAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemAgentMessageAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseItemMultiAgentCall struct {
	// The unique ID of the multi-agent call item.
	ID string `json:"id" api:"required"`
	// The multi-agent action to execute.
	//
	// Any of "spawn_agent", "interrupt_agent", "list_agents", "send_message",
	// "followup_task", "wait_agent".
	Action string `json:"action" api:"required"`
	// The JSON string of arguments generated for the action.
	Arguments string `json:"arguments" api:"required"`
	// The unique ID linking this call to its output.
	CallID string `json:"call_id" api:"required"`
	// The type of the multi-agent call. Always `multi_agent_call`.
	Type constant.MultiAgentCall `json:"type" default:"multi_agent_call"`
	// The agent that produced this item.
	Agent BetaResponseItemMultiAgentCallAgent `json:"agent"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Action      respjson.Field
		Arguments   respjson.Field
		CallID      respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemMultiAgentCall) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemMultiAgentCall) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseItemMultiAgentCallAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemMultiAgentCallAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemMultiAgentCallAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseItemMultiAgentCallOutput struct {
	// The unique ID of the multi-agent call output item.
	ID string `json:"id" api:"required"`
	// The multi-agent action that produced this result.
	//
	// Any of "spawn_agent", "interrupt_agent", "list_agents", "send_message",
	// "followup_task", "wait_agent".
	Action string `json:"action" api:"required"`
	// The unique ID of the multi-agent call.
	CallID string `json:"call_id" api:"required"`
	// Text output returned by the multi-agent action.
	Output []BetaResponseOutputText `json:"output" api:"required"`
	// The type of the multi-agent result. Always `multi_agent_call_output`.
	Type constant.MultiAgentCallOutput `json:"type" default:"multi_agent_call_output"`
	// The agent that produced this item.
	Agent BetaResponseItemMultiAgentCallOutputAgent `json:"agent"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Action      respjson.Field
		CallID      respjson.Field
		Output      respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemMultiAgentCallOutput) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemMultiAgentCallOutput) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseItemMultiAgentCallOutputAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemMultiAgentCallOutputAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemMultiAgentCallOutputAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseItemAdditionalTools struct {
	// The unique ID of the additional tools item.
	ID string `json:"id" api:"required"`
	// The role that provided the additional tools.
	//
	// Any of "unknown", "user", "assistant", "system", "critic", "discriminator",
	// "developer", "tool".
	Role string `json:"role" api:"required"`
	// The additional tool definitions made available at this item.
	Tools []BetaToolUnion `json:"tools" api:"required"`
	// The type of the item. Always `additional_tools`.
	Type constant.AdditionalTools `json:"type" default:"additional_tools"`
	// The agent that produced this item.
	Agent BetaResponseItemAdditionalToolsAgent `json:"agent"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Role        respjson.Field
		Tools       respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemAdditionalTools) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemAdditionalTools) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseItemAdditionalToolsAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemAdditionalToolsAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemAdditionalToolsAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseItemProgram struct {
	// The unique ID of the program item.
	ID string `json:"id" api:"required"`
	// The stable call ID of the program item.
	CallID string `json:"call_id" api:"required"`
	// The JavaScript source executed by programmatic tool calling.
	Code string `json:"code" api:"required"`
	// Opaque program replay fingerprint that must be round-tripped.
	Fingerprint string `json:"fingerprint" api:"required"`
	// The type of the item. Always `program`.
	Type constant.Program `json:"type" default:"program"`
	// The agent that produced this item.
	Agent BetaResponseItemProgramAgent `json:"agent"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CallID      respjson.Field
		Code        respjson.Field
		Fingerprint respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemProgram) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemProgram) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseItemProgramAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemProgramAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemProgramAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseItemProgramOutput struct {
	// The unique ID of the program output item.
	ID string `json:"id" api:"required"`
	// The call ID of the program item.
	CallID string `json:"call_id" api:"required"`
	// The result produced by the program item.
	Result string `json:"result" api:"required"`
	// The terminal status of the program output item.
	//
	// Any of "completed", "incomplete".
	Status string `json:"status" api:"required"`
	// The type of the item. Always `program_output`.
	Type constant.ProgramOutput `json:"type" default:"program_output"`
	// The agent that produced this item.
	Agent BetaResponseItemProgramOutputAgent `json:"agent"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CallID      respjson.Field
		Result      respjson.Field
		Status      respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemProgramOutput) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemProgramOutput) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseItemProgramOutputAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemProgramOutputAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemProgramOutputAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// An image generation request made by the model.
type BetaResponseItemImageGenerationCall struct {
	// The unique ID of the image generation call.
	ID string `json:"id" api:"required"`
	// The generated image encoded in base64.
	Result string `json:"result" api:"required"`
	// The status of the image generation call.
	//
	// Any of "in_progress", "completed", "generating", "failed".
	Status string `json:"status" api:"required"`
	// The type of the image generation call. Always `image_generation_call`.
	Type constant.ImageGenerationCall `json:"type" default:"image_generation_call"`
	// The agent that produced this item.
	Agent BetaResponseItemImageGenerationCallAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Result      respjson.Field
		Status      respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemImageGenerationCall) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemImageGenerationCall) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseItemImageGenerationCallAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemImageGenerationCallAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemImageGenerationCallAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool call to run a command on the local shell.
type BetaResponseItemLocalShellCall struct {
	// The unique ID of the local shell call.
	ID string `json:"id" api:"required"`
	// Execute a shell command on the server.
	Action BetaResponseItemLocalShellCallAction `json:"action" api:"required"`
	// The unique ID of the local shell tool call generated by the model.
	CallID string `json:"call_id" api:"required"`
	// The status of the local shell call.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status string `json:"status" api:"required"`
	// The type of the local shell call. Always `local_shell_call`.
	Type constant.LocalShellCall `json:"type" default:"local_shell_call"`
	// The agent that produced this item.
	Agent BetaResponseItemLocalShellCallAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Action      respjson.Field
		CallID      respjson.Field
		Status      respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemLocalShellCall) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemLocalShellCall) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Execute a shell command on the server.
type BetaResponseItemLocalShellCallAction struct {
	// The command to run.
	Command []string `json:"command" api:"required"`
	// Environment variables to set for the command.
	Env map[string]string `json:"env" api:"required"`
	// The type of the local shell action. Always `exec`.
	Type constant.Exec `json:"type" default:"exec"`
	// Optional timeout in milliseconds for the command.
	TimeoutMs int64 `json:"timeout_ms" api:"nullable"`
	// Optional user to run the command as.
	User string `json:"user" api:"nullable"`
	// Optional working directory to run the command in.
	WorkingDirectory string `json:"working_directory" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Command          respjson.Field
		Env              respjson.Field
		Type             respjson.Field
		TimeoutMs        respjson.Field
		User             respjson.Field
		WorkingDirectory respjson.Field
		ExtraFields      map[string]respjson.Field
		raw              string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemLocalShellCallAction) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemLocalShellCallAction) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseItemLocalShellCallAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemLocalShellCallAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemLocalShellCallAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The output of a local shell tool call.
type BetaResponseItemLocalShellCallOutput struct {
	// The unique ID of the local shell tool call generated by the model.
	ID string `json:"id" api:"required"`
	// A JSON string of the output of the local shell tool call.
	Output string `json:"output" api:"required"`
	// The type of the local shell tool call output. Always `local_shell_call_output`.
	Type constant.LocalShellCallOutput `json:"type" default:"local_shell_call_output"`
	// The agent that produced this item.
	Agent BetaResponseItemLocalShellCallOutputAgent `json:"agent" api:"nullable"`
	// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status string `json:"status" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Output      respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		Status      respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemLocalShellCallOutput) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemLocalShellCallOutput) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseItemLocalShellCallOutputAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemLocalShellCallOutputAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemLocalShellCallOutputAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A list of tools available on an MCP server.
type BetaResponseItemMcpListTools struct {
	// The unique ID of the list.
	ID string `json:"id" api:"required"`
	// The label of the MCP server.
	ServerLabel string `json:"server_label" api:"required"`
	// The tools available on the server.
	Tools []BetaResponseItemMcpListToolsTool `json:"tools" api:"required"`
	// The type of the item. Always `mcp_list_tools`.
	Type constant.McpListTools `json:"type" default:"mcp_list_tools"`
	// The agent that produced this item.
	Agent BetaResponseItemMcpListToolsAgent `json:"agent" api:"nullable"`
	// Error message if the server could not list tools.
	Error string `json:"error" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		ServerLabel respjson.Field
		Tools       respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		Error       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemMcpListTools) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemMcpListTools) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool available on an MCP server.
type BetaResponseItemMcpListToolsTool struct {
	// The JSON schema describing the tool's input.
	InputSchema any `json:"input_schema" api:"required"`
	// The name of the tool.
	Name string `json:"name" api:"required"`
	// Additional annotations about the tool.
	Annotations any `json:"annotations" api:"nullable"`
	// The description of the tool.
	Description string `json:"description" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		InputSchema respjson.Field
		Name        respjson.Field
		Annotations respjson.Field
		Description respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemMcpListToolsTool) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemMcpListToolsTool) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseItemMcpListToolsAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemMcpListToolsAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemMcpListToolsAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A request for human approval of a tool invocation.
type BetaResponseItemMcpApprovalRequest struct {
	// The unique ID of the approval request.
	ID string `json:"id" api:"required"`
	// A JSON string of arguments for the tool.
	Arguments string `json:"arguments" api:"required"`
	// The name of the tool to run.
	Name string `json:"name" api:"required"`
	// The label of the MCP server making the request.
	ServerLabel string `json:"server_label" api:"required"`
	// The type of the item. Always `mcp_approval_request`.
	Type constant.McpApprovalRequest `json:"type" default:"mcp_approval_request"`
	// The agent that produced this item.
	Agent BetaResponseItemMcpApprovalRequestAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Arguments   respjson.Field
		Name        respjson.Field
		ServerLabel respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemMcpApprovalRequest) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemMcpApprovalRequest) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseItemMcpApprovalRequestAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemMcpApprovalRequestAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemMcpApprovalRequestAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A response to an MCP approval request.
type BetaResponseItemMcpApprovalResponse struct {
	// The unique ID of the approval response
	ID string `json:"id" api:"required"`
	// The ID of the approval request being answered.
	ApprovalRequestID string `json:"approval_request_id" api:"required"`
	// Whether the request was approved.
	Approve bool `json:"approve" api:"required"`
	// The type of the item. Always `mcp_approval_response`.
	Type constant.McpApprovalResponse `json:"type" default:"mcp_approval_response"`
	// The agent that produced this item.
	Agent BetaResponseItemMcpApprovalResponseAgent `json:"agent" api:"nullable"`
	// Optional reason for the decision.
	Reason string `json:"reason" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                respjson.Field
		ApprovalRequestID respjson.Field
		Approve           respjson.Field
		Type              respjson.Field
		Agent             respjson.Field
		Reason            respjson.Field
		ExtraFields       map[string]respjson.Field
		raw               string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemMcpApprovalResponse) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemMcpApprovalResponse) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseItemMcpApprovalResponseAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemMcpApprovalResponseAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemMcpApprovalResponseAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// An invocation of a tool on an MCP server.
type BetaResponseItemMcpCall struct {
	// The unique ID of the tool call.
	ID string `json:"id" api:"required"`
	// A JSON string of the arguments passed to the tool.
	Arguments string `json:"arguments" api:"required"`
	// The name of the tool that was run.
	Name string `json:"name" api:"required"`
	// The label of the MCP server running the tool.
	ServerLabel string `json:"server_label" api:"required"`
	// The type of the item. Always `mcp_call`.
	Type constant.McpCall `json:"type" default:"mcp_call"`
	// The agent that produced this item.
	Agent BetaResponseItemMcpCallAgent `json:"agent" api:"nullable"`
	// Unique identifier for the MCP tool call approval request. Include this value in
	// a subsequent `mcp_approval_response` input to approve or reject the
	// corresponding tool call.
	ApprovalRequestID string `json:"approval_request_id" api:"nullable"`
	// The error from the tool call, if any.
	Error string `json:"error" api:"nullable"`
	// The output from the tool call.
	Output string `json:"output" api:"nullable"`
	// The status of the tool call. One of `in_progress`, `completed`, `incomplete`,
	// `calling`, or `failed`.
	//
	// Any of "in_progress", "completed", "incomplete", "calling", "failed".
	Status string `json:"status"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                respjson.Field
		Arguments         respjson.Field
		Name              respjson.Field
		ServerLabel       respjson.Field
		Type              respjson.Field
		Agent             respjson.Field
		ApprovalRequestID respjson.Field
		Error             respjson.Field
		Output            respjson.Field
		Status            respjson.Field
		ExtraFields       map[string]respjson.Field
		raw               string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemMcpCall) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemMcpCall) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseItemMcpCallAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseItemMcpCallAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseItemMcpCallAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Represents the use of a local environment to perform shell actions.
type BetaResponseLocalEnvironment struct {
	// The environment type. Always `local`.
	Type constant.Local `json:"type" default:"local"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseLocalEnvironment) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseLocalEnvironment) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when there is a delta (partial update) to the arguments of an MCP tool
// call.
type BetaResponseMcpCallArgumentsDeltaEvent struct {
	// A JSON string containing the partial update to the arguments for the MCP tool
	// call.
	Delta string `json:"delta" api:"required"`
	// The unique identifier of the MCP tool call item being processed.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item in the response's output array.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always 'response.mcp_call_arguments.delta'.
	Type constant.ResponseMcpCallArgumentsDelta `json:"type" default:"response.mcp_call_arguments.delta"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseMcpCallArgumentsDeltaEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Delta          respjson.Field
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseMcpCallArgumentsDeltaEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseMcpCallArgumentsDeltaEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseMcpCallArgumentsDeltaEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseMcpCallArgumentsDeltaEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseMcpCallArgumentsDeltaEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when the arguments for an MCP tool call are finalized.
type BetaResponseMcpCallArgumentsDoneEvent struct {
	// A JSON string containing the finalized arguments for the MCP tool call.
	Arguments string `json:"arguments" api:"required"`
	// The unique identifier of the MCP tool call item being processed.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item in the response's output array.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always 'response.mcp_call_arguments.done'.
	Type constant.ResponseMcpCallArgumentsDone `json:"type" default:"response.mcp_call_arguments.done"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseMcpCallArgumentsDoneEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Arguments      respjson.Field
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseMcpCallArgumentsDoneEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseMcpCallArgumentsDoneEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseMcpCallArgumentsDoneEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseMcpCallArgumentsDoneEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseMcpCallArgumentsDoneEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when an MCP tool call has completed successfully.
type BetaResponseMcpCallCompletedEvent struct {
	// The ID of the MCP tool call item that completed.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item that completed.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always 'response.mcp_call.completed'.
	Type constant.ResponseMcpCallCompleted `json:"type" default:"response.mcp_call.completed"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseMcpCallCompletedEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseMcpCallCompletedEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseMcpCallCompletedEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseMcpCallCompletedEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseMcpCallCompletedEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseMcpCallCompletedEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when an MCP tool call has failed.
type BetaResponseMcpCallFailedEvent struct {
	// The ID of the MCP tool call item that failed.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item that failed.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always 'response.mcp_call.failed'.
	Type constant.ResponseMcpCallFailed `json:"type" default:"response.mcp_call.failed"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseMcpCallFailedEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseMcpCallFailedEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseMcpCallFailedEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseMcpCallFailedEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseMcpCallFailedEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseMcpCallFailedEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when an MCP tool call is in progress.
type BetaResponseMcpCallInProgressEvent struct {
	// The unique identifier of the MCP tool call item being processed.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item in the response's output array.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always 'response.mcp_call.in_progress'.
	Type constant.ResponseMcpCallInProgress `json:"type" default:"response.mcp_call.in_progress"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseMcpCallInProgressEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseMcpCallInProgressEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseMcpCallInProgressEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseMcpCallInProgressEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseMcpCallInProgressEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseMcpCallInProgressEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when the list of available MCP tools has been successfully retrieved.
type BetaResponseMcpListToolsCompletedEvent struct {
	// The ID of the MCP tool call item that produced this output.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item that was processed.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always 'response.mcp_list_tools.completed'.
	Type constant.ResponseMcpListToolsCompleted `json:"type" default:"response.mcp_list_tools.completed"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseMcpListToolsCompletedEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseMcpListToolsCompletedEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseMcpListToolsCompletedEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseMcpListToolsCompletedEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseMcpListToolsCompletedEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseMcpListToolsCompletedEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when the attempt to list available MCP tools has failed.
type BetaResponseMcpListToolsFailedEvent struct {
	// The ID of the MCP tool call item that failed.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item that failed.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always 'response.mcp_list_tools.failed'.
	Type constant.ResponseMcpListToolsFailed `json:"type" default:"response.mcp_list_tools.failed"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseMcpListToolsFailedEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseMcpListToolsFailedEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseMcpListToolsFailedEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseMcpListToolsFailedEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseMcpListToolsFailedEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseMcpListToolsFailedEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when the system is in the process of retrieving the list of available
// MCP tools.
type BetaResponseMcpListToolsInProgressEvent struct {
	// The ID of the MCP tool call item that is being processed.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item that is being processed.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always 'response.mcp_list_tools.in_progress'.
	Type constant.ResponseMcpListToolsInProgress `json:"type" default:"response.mcp_list_tools.in_progress"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseMcpListToolsInProgressEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseMcpListToolsInProgressEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseMcpListToolsInProgressEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseMcpListToolsInProgressEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseMcpListToolsInProgressEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseMcpListToolsInProgressEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseOutputItemUnion contains all possible properties and values from
// [BetaResponseOutputMessage], [BetaResponseFileSearchToolCall],
// [BetaResponseFunctionToolCall], [BetaResponseFunctionToolCallOutputItem],
// [BetaResponseOutputItemAgentMessage], [BetaResponseOutputItemMultiAgentCall],
// [BetaResponseOutputItemMultiAgentCallOutput], [BetaResponseFunctionWebSearch],
// [BetaResponseComputerToolCall], [BetaResponseComputerToolCallOutputItem],
// [BetaResponseReasoningItem], [BetaResponseOutputItemProgram],
// [BetaResponseOutputItemProgramOutput], [BetaResponseToolSearchCall],
// [BetaResponseToolSearchOutputItem], [BetaResponseOutputItemAdditionalTools],
// [BetaResponseCompactionItem], [BetaResponseOutputItemImageGenerationCall],
// [BetaResponseCodeInterpreterToolCall], [BetaResponseOutputItemLocalShellCall],
// [BetaResponseOutputItemLocalShellCallOutput],
// [BetaResponseFunctionShellToolCall], [BetaResponseFunctionShellToolCallOutput],
// [BetaResponseApplyPatchToolCall], [BetaResponseApplyPatchToolCallOutput],
// [BetaResponseOutputItemMcpCall], [BetaResponseOutputItemMcpListTools],
// [BetaResponseOutputItemMcpApprovalRequest],
// [BetaResponseOutputItemMcpApprovalResponse], [BetaResponseCustomToolCall],
// [BetaResponseCustomToolCallOutputItem].
//
// Use the [BetaResponseOutputItemUnion.AsAny] method to switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseOutputItemUnion struct {
	ID string `json:"id"`
	// This field is a union of [[]BetaResponseOutputMessageContentUnion],
	// [[]BetaResponseOutputItemAgentMessageContentUnion],
	// [[]BetaResponseReasoningItemContent]
	Content BetaResponseOutputItemUnionContent `json:"content"`
	Role    string                             `json:"role"`
	Status  string                             `json:"status"`
	// Any of "message", "file_search_call", "function_call", "function_call_output",
	// "agent_message", "multi_agent_call", "multi_agent_call_output",
	// "web_search_call", "computer_call", "computer_call_output", "reasoning",
	// "program", "program_output", "tool_search_call", "tool_search_output",
	// "additional_tools", "compaction", "image_generation_call",
	// "code_interpreter_call", "local_shell_call", "local_shell_call_output",
	// "shell_call", "shell_call_output", "apply_patch_call",
	// "apply_patch_call_output", "mcp_call", "mcp_list_tools", "mcp_approval_request",
	// "mcp_approval_response", "custom_tool_call", "custom_tool_call_output".
	Type string `json:"type"`
	// This field is a union of [BetaResponseOutputMessageAgent],
	// [BetaResponseFileSearchToolCallAgent], [BetaResponseFunctionToolCallAgent],
	// [BetaResponseFunctionToolCallOutputItemAgent],
	// [BetaResponseOutputItemAgentMessageAgent],
	// [BetaResponseOutputItemMultiAgentCallAgent],
	// [BetaResponseOutputItemMultiAgentCallOutputAgent],
	// [BetaResponseFunctionWebSearchAgent], [BetaResponseComputerToolCallAgent],
	// [BetaResponseComputerToolCallOutputItemAgent], [BetaResponseReasoningItemAgent],
	// [BetaResponseOutputItemProgramAgent],
	// [BetaResponseOutputItemProgramOutputAgent], [BetaResponseToolSearchCallAgent],
	// [BetaResponseToolSearchOutputItemAgent],
	// [BetaResponseOutputItemAdditionalToolsAgent], [BetaResponseCompactionItemAgent],
	// [BetaResponseOutputItemImageGenerationCallAgent],
	// [BetaResponseCodeInterpreterToolCallAgent],
	// [BetaResponseOutputItemLocalShellCallAgent],
	// [BetaResponseOutputItemLocalShellCallOutputAgent],
	// [BetaResponseFunctionShellToolCallAgent],
	// [BetaResponseFunctionShellToolCallOutputAgent],
	// [BetaResponseApplyPatchToolCallAgent],
	// [BetaResponseApplyPatchToolCallOutputAgent],
	// [BetaResponseOutputItemMcpCallAgent], [BetaResponseOutputItemMcpListToolsAgent],
	// [BetaResponseOutputItemMcpApprovalRequestAgent],
	// [BetaResponseOutputItemMcpApprovalResponseAgent],
	// [BetaResponseCustomToolCallAgent], [BetaResponseCustomToolCallOutputAgent]
	Agent BetaResponseOutputItemUnionAgent `json:"agent"`
	// This field is from variant [BetaResponseOutputMessage].
	Phase BetaResponseOutputMessagePhase `json:"phase"`
	// This field is from variant [BetaResponseFileSearchToolCall].
	Queries []string `json:"queries"`
	// This field is from variant [BetaResponseFileSearchToolCall].
	Results []BetaResponseFileSearchToolCallResult `json:"results"`
	// This field is a union of [string], [string], [any], [string], [string]
	Arguments BetaResponseOutputItemUnionArguments `json:"arguments"`
	CallID    string                               `json:"call_id"`
	Name      string                               `json:"name"`
	// This field is a union of [BetaResponseFunctionToolCallCallerUnion],
	// [BetaResponseFunctionToolCallOutputItemCallerUnion],
	// [BetaResponseFunctionShellToolCallCallerUnion],
	// [BetaResponseFunctionShellToolCallOutputCallerUnion],
	// [BetaResponseApplyPatchToolCallCallerUnion],
	// [BetaResponseApplyPatchToolCallOutputCallerUnion],
	// [BetaResponseCustomToolCallCallerUnion],
	// [BetaResponseCustomToolCallOutputCallerUnion]
	Caller    BetaResponseOutputItemUnionCaller `json:"caller"`
	Namespace string                            `json:"namespace"`
	// This field is a union of [BetaResponseFunctionToolCallOutputItemOutputUnion],
	// [[]BetaResponseOutputText], [BetaResponseComputerToolCallOutputScreenshot],
	// [string], [[]BetaResponseFunctionShellToolCallOutputOutput], [string], [string],
	// [BetaResponseCustomToolCallOutputOutputUnion]
	Output    BetaResponseOutputItemUnionOutput `json:"output"`
	CreatedBy string                            `json:"created_by"`
	// This field is from variant [BetaResponseOutputItemAgentMessage].
	Author string `json:"author"`
	// This field is from variant [BetaResponseOutputItemAgentMessage].
	Recipient string `json:"recipient"`
	// This field is a union of [string], [string],
	// [BetaResponseFunctionWebSearchActionUnion], [BetaComputerActionUnion],
	// [BetaResponseOutputItemLocalShellCallAction],
	// [BetaResponseFunctionShellToolCallAction]
	Action BetaResponseOutputItemUnionAction `json:"action"`
	// This field is from variant [BetaResponseComputerToolCall].
	PendingSafetyChecks []BetaResponseComputerToolCallPendingSafetyCheck `json:"pending_safety_checks"`
	// This field is from variant [BetaResponseComputerToolCall].
	Actions BetaComputerActionList `json:"actions"`
	// This field is from variant [BetaResponseComputerToolCallOutputItem].
	AcknowledgedSafetyChecks []BetaResponseComputerToolCallOutputItemAcknowledgedSafetyCheck `json:"acknowledged_safety_checks"`
	// This field is from variant [BetaResponseReasoningItem].
	Summary          []BetaResponseReasoningItemSummary `json:"summary"`
	EncryptedContent string                             `json:"encrypted_content"`
	Code             string                             `json:"code"`
	// This field is from variant [BetaResponseOutputItemProgram].
	Fingerprint string `json:"fingerprint"`
	Result      string `json:"result"`
	Execution   string `json:"execution"`
	// This field is a union of [[]BetaToolUnion], [[]BetaToolUnion],
	// [[]BetaResponseOutputItemMcpListToolsTool]
	Tools BetaResponseOutputItemUnionTools `json:"tools"`
	// This field is from variant [BetaResponseCodeInterpreterToolCall].
	ContainerID string `json:"container_id"`
	// This field is from variant [BetaResponseCodeInterpreterToolCall].
	Outputs []BetaResponseCodeInterpreterToolCallOutputUnion `json:"outputs"`
	// This field is from variant [BetaResponseFunctionShellToolCall].
	Environment BetaResponseFunctionShellToolCallEnvironmentUnion `json:"environment"`
	// This field is from variant [BetaResponseFunctionShellToolCallOutput].
	MaxOutputLength int64 `json:"max_output_length"`
	// This field is from variant [BetaResponseApplyPatchToolCall].
	Operation         BetaResponseApplyPatchToolCallOperationUnion `json:"operation"`
	ServerLabel       string                                       `json:"server_label"`
	ApprovalRequestID string                                       `json:"approval_request_id"`
	Error             string                                       `json:"error"`
	// This field is from variant [BetaResponseOutputItemMcpApprovalResponse].
	Approve bool `json:"approve"`
	// This field is from variant [BetaResponseOutputItemMcpApprovalResponse].
	Reason string `json:"reason"`
	// This field is from variant [BetaResponseCustomToolCall].
	Input string `json:"input"`
	JSON  struct {
		ID                       respjson.Field
		Content                  respjson.Field
		Role                     respjson.Field
		Status                   respjson.Field
		Type                     respjson.Field
		Agent                    respjson.Field
		Phase                    respjson.Field
		Queries                  respjson.Field
		Results                  respjson.Field
		Arguments                respjson.Field
		CallID                   respjson.Field
		Name                     respjson.Field
		Caller                   respjson.Field
		Namespace                respjson.Field
		Output                   respjson.Field
		CreatedBy                respjson.Field
		Author                   respjson.Field
		Recipient                respjson.Field
		Action                   respjson.Field
		PendingSafetyChecks      respjson.Field
		Actions                  respjson.Field
		AcknowledgedSafetyChecks respjson.Field
		Summary                  respjson.Field
		EncryptedContent         respjson.Field
		Code                     respjson.Field
		Fingerprint              respjson.Field
		Result                   respjson.Field
		Execution                respjson.Field
		Tools                    respjson.Field
		ContainerID              respjson.Field
		Outputs                  respjson.Field
		Environment              respjson.Field
		MaxOutputLength          respjson.Field
		Operation                respjson.Field
		ServerLabel              respjson.Field
		ApprovalRequestID        respjson.Field
		Error                    respjson.Field
		Approve                  respjson.Field
		Reason                   respjson.Field
		Input                    respjson.Field
		raw                      string
	} `json:"-"`
}

// anyBetaResponseOutputItem is implemented by each variant of
// [BetaResponseOutputItemUnion] to add type safety for the return type of
// [BetaResponseOutputItemUnion.AsAny]
type anyBetaResponseOutputItem interface {
	implBetaResponseOutputItemUnion()
}

func (BetaResponseOutputMessage) implBetaResponseOutputItemUnion()                  {}
func (BetaResponseFileSearchToolCall) implBetaResponseOutputItemUnion()             {}
func (BetaResponseFunctionToolCall) implBetaResponseOutputItemUnion()               {}
func (BetaResponseFunctionToolCallOutputItem) implBetaResponseOutputItemUnion()     {}
func (BetaResponseOutputItemAgentMessage) implBetaResponseOutputItemUnion()         {}
func (BetaResponseOutputItemMultiAgentCall) implBetaResponseOutputItemUnion()       {}
func (BetaResponseOutputItemMultiAgentCallOutput) implBetaResponseOutputItemUnion() {}
func (BetaResponseFunctionWebSearch) implBetaResponseOutputItemUnion()              {}
func (BetaResponseComputerToolCall) implBetaResponseOutputItemUnion()               {}
func (BetaResponseComputerToolCallOutputItem) implBetaResponseOutputItemUnion()     {}
func (BetaResponseReasoningItem) implBetaResponseOutputItemUnion()                  {}
func (BetaResponseOutputItemProgram) implBetaResponseOutputItemUnion()              {}
func (BetaResponseOutputItemProgramOutput) implBetaResponseOutputItemUnion()        {}
func (BetaResponseToolSearchCall) implBetaResponseOutputItemUnion()                 {}
func (BetaResponseToolSearchOutputItem) implBetaResponseOutputItemUnion()           {}
func (BetaResponseOutputItemAdditionalTools) implBetaResponseOutputItemUnion()      {}
func (BetaResponseCompactionItem) implBetaResponseOutputItemUnion()                 {}
func (BetaResponseOutputItemImageGenerationCall) implBetaResponseOutputItemUnion()  {}
func (BetaResponseCodeInterpreterToolCall) implBetaResponseOutputItemUnion()        {}
func (BetaResponseOutputItemLocalShellCall) implBetaResponseOutputItemUnion()       {}
func (BetaResponseOutputItemLocalShellCallOutput) implBetaResponseOutputItemUnion() {}
func (BetaResponseFunctionShellToolCall) implBetaResponseOutputItemUnion()          {}
func (BetaResponseFunctionShellToolCallOutput) implBetaResponseOutputItemUnion()    {}
func (BetaResponseApplyPatchToolCall) implBetaResponseOutputItemUnion()             {}
func (BetaResponseApplyPatchToolCallOutput) implBetaResponseOutputItemUnion()       {}
func (BetaResponseOutputItemMcpCall) implBetaResponseOutputItemUnion()              {}
func (BetaResponseOutputItemMcpListTools) implBetaResponseOutputItemUnion()         {}
func (BetaResponseOutputItemMcpApprovalRequest) implBetaResponseOutputItemUnion()   {}
func (BetaResponseOutputItemMcpApprovalResponse) implBetaResponseOutputItemUnion()  {}
func (BetaResponseCustomToolCall) implBetaResponseOutputItemUnion()                 {}
func (BetaResponseCustomToolCallOutputItem) implBetaResponseOutputItemUnion()       {}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseOutputItemUnion.AsAny().(type) {
//	case openai.BetaResponseOutputMessage:
//	case openai.BetaResponseFileSearchToolCall:
//	case openai.BetaResponseFunctionToolCall:
//	case openai.BetaResponseFunctionToolCallOutputItem:
//	case openai.BetaResponseOutputItemAgentMessage:
//	case openai.BetaResponseOutputItemMultiAgentCall:
//	case openai.BetaResponseOutputItemMultiAgentCallOutput:
//	case openai.BetaResponseFunctionWebSearch:
//	case openai.BetaResponseComputerToolCall:
//	case openai.BetaResponseComputerToolCallOutputItem:
//	case openai.BetaResponseReasoningItem:
//	case openai.BetaResponseOutputItemProgram:
//	case openai.BetaResponseOutputItemProgramOutput:
//	case openai.BetaResponseToolSearchCall:
//	case openai.BetaResponseToolSearchOutputItem:
//	case openai.BetaResponseOutputItemAdditionalTools:
//	case openai.BetaResponseCompactionItem:
//	case openai.BetaResponseOutputItemImageGenerationCall:
//	case openai.BetaResponseCodeInterpreterToolCall:
//	case openai.BetaResponseOutputItemLocalShellCall:
//	case openai.BetaResponseOutputItemLocalShellCallOutput:
//	case openai.BetaResponseFunctionShellToolCall:
//	case openai.BetaResponseFunctionShellToolCallOutput:
//	case openai.BetaResponseApplyPatchToolCall:
//	case openai.BetaResponseApplyPatchToolCallOutput:
//	case openai.BetaResponseOutputItemMcpCall:
//	case openai.BetaResponseOutputItemMcpListTools:
//	case openai.BetaResponseOutputItemMcpApprovalRequest:
//	case openai.BetaResponseOutputItemMcpApprovalResponse:
//	case openai.BetaResponseCustomToolCall:
//	case openai.BetaResponseCustomToolCallOutputItem:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseOutputItemUnion) AsAny() anyBetaResponseOutputItem {
	switch u.Type {
	case "message":
		return u.AsMessage()
	case "file_search_call":
		return u.AsFileSearchCall()
	case "function_call":
		return u.AsFunctionCall()
	case "function_call_output":
		return u.AsFunctionCallOutput()
	case "agent_message":
		return u.AsAgentMessage()
	case "multi_agent_call":
		return u.AsMultiAgentCall()
	case "multi_agent_call_output":
		return u.AsMultiAgentCallOutput()
	case "web_search_call":
		return u.AsWebSearchCall()
	case "computer_call":
		return u.AsComputerCall()
	case "computer_call_output":
		return u.AsComputerCallOutput()
	case "reasoning":
		return u.AsReasoning()
	case "program":
		return u.AsProgram()
	case "program_output":
		return u.AsProgramOutput()
	case "tool_search_call":
		return u.AsToolSearchCall()
	case "tool_search_output":
		return u.AsToolSearchOutput()
	case "additional_tools":
		return u.AsAdditionalTools()
	case "compaction":
		return u.AsCompaction()
	case "image_generation_call":
		return u.AsImageGenerationCall()
	case "code_interpreter_call":
		return u.AsCodeInterpreterCall()
	case "local_shell_call":
		return u.AsLocalShellCall()
	case "local_shell_call_output":
		return u.AsLocalShellCallOutput()
	case "shell_call":
		return u.AsShellCall()
	case "shell_call_output":
		return u.AsShellCallOutput()
	case "apply_patch_call":
		return u.AsApplyPatchCall()
	case "apply_patch_call_output":
		return u.AsApplyPatchCallOutput()
	case "mcp_call":
		return u.AsMcpCall()
	case "mcp_list_tools":
		return u.AsMcpListTools()
	case "mcp_approval_request":
		return u.AsMcpApprovalRequest()
	case "mcp_approval_response":
		return u.AsMcpApprovalResponse()
	case "custom_tool_call":
		return u.AsCustomToolCall()
	case "custom_tool_call_output":
		return u.AsCustomToolCallOutput()
	}
	return nil
}

func (u BetaResponseOutputItemUnion) AsMessage() (v BetaResponseOutputMessage) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsFileSearchCall() (v BetaResponseFileSearchToolCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsFunctionCall() (v BetaResponseFunctionToolCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsFunctionCallOutput() (v BetaResponseFunctionToolCallOutputItem) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsAgentMessage() (v BetaResponseOutputItemAgentMessage) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsMultiAgentCall() (v BetaResponseOutputItemMultiAgentCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsMultiAgentCallOutput() (v BetaResponseOutputItemMultiAgentCallOutput) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsWebSearchCall() (v BetaResponseFunctionWebSearch) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsComputerCall() (v BetaResponseComputerToolCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsComputerCallOutput() (v BetaResponseComputerToolCallOutputItem) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsReasoning() (v BetaResponseReasoningItem) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsProgram() (v BetaResponseOutputItemProgram) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsProgramOutput() (v BetaResponseOutputItemProgramOutput) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsToolSearchCall() (v BetaResponseToolSearchCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsToolSearchOutput() (v BetaResponseToolSearchOutputItem) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsAdditionalTools() (v BetaResponseOutputItemAdditionalTools) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsCompaction() (v BetaResponseCompactionItem) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsImageGenerationCall() (v BetaResponseOutputItemImageGenerationCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsCodeInterpreterCall() (v BetaResponseCodeInterpreterToolCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsLocalShellCall() (v BetaResponseOutputItemLocalShellCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsLocalShellCallOutput() (v BetaResponseOutputItemLocalShellCallOutput) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsShellCall() (v BetaResponseFunctionShellToolCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsShellCallOutput() (v BetaResponseFunctionShellToolCallOutput) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsApplyPatchCall() (v BetaResponseApplyPatchToolCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsApplyPatchCallOutput() (v BetaResponseApplyPatchToolCallOutput) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsMcpCall() (v BetaResponseOutputItemMcpCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsMcpListTools() (v BetaResponseOutputItemMcpListTools) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsMcpApprovalRequest() (v BetaResponseOutputItemMcpApprovalRequest) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsMcpApprovalResponse() (v BetaResponseOutputItemMcpApprovalResponse) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsCustomToolCall() (v BetaResponseCustomToolCall) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemUnion) AsCustomToolCallOutput() (v BetaResponseCustomToolCallOutputItem) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseOutputItemUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseOutputItemUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseOutputItemUnionContent is an implicit subunion of
// [BetaResponseOutputItemUnion]. BetaResponseOutputItemUnionContent provides
// convenient access to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseOutputItemUnion].
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfBetaResponseOutputMessageContentArray
// OfBetaResponseOutputItemAgentMessageContentArray
// OfBetaResponseReasoningItemContentArray]
type BetaResponseOutputItemUnionContent struct {
	// This field will be present if the value is a
	// [[]BetaResponseOutputMessageContentUnion] instead of an object.
	OfBetaResponseOutputMessageContentArray []BetaResponseOutputMessageContentUnion `json:",inline"`
	// This field will be present if the value is a
	// [[]BetaResponseOutputItemAgentMessageContentUnion] instead of an object.
	OfBetaResponseOutputItemAgentMessageContentArray []BetaResponseOutputItemAgentMessageContentUnion `json:",inline"`
	// This field will be present if the value is a
	// [[]BetaResponseReasoningItemContent] instead of an object.
	OfBetaResponseReasoningItemContentArray []BetaResponseReasoningItemContent `json:",inline"`
	JSON                                    struct {
		OfBetaResponseOutputMessageContentArray          respjson.Field
		OfBetaResponseOutputItemAgentMessageContentArray respjson.Field
		OfBetaResponseReasoningItemContentArray          respjson.Field
		raw                                              string
	} `json:"-"`
}

func (r *BetaResponseOutputItemUnionContent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseOutputItemUnionAgent is an implicit subunion of
// [BetaResponseOutputItemUnion]. BetaResponseOutputItemUnionAgent provides
// convenient access to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseOutputItemUnion].
type BetaResponseOutputItemUnionAgent struct {
	AgentName string `json:"agent_name"`
	JSON      struct {
		AgentName respjson.Field
		raw       string
	} `json:"-"`
}

func (r *BetaResponseOutputItemUnionAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseOutputItemUnionArguments is an implicit subunion of
// [BetaResponseOutputItemUnion]. BetaResponseOutputItemUnionArguments provides
// convenient access to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseOutputItemUnion].
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfString OfBetaResponseToolSearchCallArguments]
type BetaResponseOutputItemUnionArguments struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a [any] instead of an object.
	OfBetaResponseToolSearchCallArguments any `json:",inline"`
	JSON                                  struct {
		OfString                              respjson.Field
		OfBetaResponseToolSearchCallArguments respjson.Field
		raw                                   string
	} `json:"-"`
}

func (r *BetaResponseOutputItemUnionArguments) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseOutputItemUnionCaller is an implicit subunion of
// [BetaResponseOutputItemUnion]. BetaResponseOutputItemUnionCaller provides
// convenient access to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseOutputItemUnion].
type BetaResponseOutputItemUnionCaller struct {
	Type     string `json:"type"`
	CallerID string `json:"caller_id"`
	JSON     struct {
		Type     respjson.Field
		CallerID respjson.Field
		raw      string
	} `json:"-"`
}

func (r *BetaResponseOutputItemUnionCaller) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseOutputItemUnionOutput is an implicit subunion of
// [BetaResponseOutputItemUnion]. BetaResponseOutputItemUnionOutput provides
// convenient access to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseOutputItemUnion].
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfString OfOutputContentList OfBetaResponseOutputTextArray
// OfBetaResponseFunctionShellToolCallOutputOutputArray]
type BetaResponseOutputItemUnionOutput struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a
	// [[]BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion]
	// instead of an object.
	OfOutputContentList []BetaResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion `json:",inline"`
	// This field will be present if the value is a [[]BetaResponseOutputText] instead
	// of an object.
	OfBetaResponseOutputTextArray []BetaResponseOutputText `json:",inline"`
	// This field will be present if the value is a
	// [[]BetaResponseFunctionShellToolCallOutputOutput] instead of an object.
	OfBetaResponseFunctionShellToolCallOutputOutputArray []BetaResponseFunctionShellToolCallOutputOutput `json:",inline"`
	// This field is from variant [BetaResponseComputerToolCallOutputScreenshot].
	Type constant.ComputerScreenshot `json:"type"`
	// This field is from variant [BetaResponseComputerToolCallOutputScreenshot].
	FileID string `json:"file_id"`
	// This field is from variant [BetaResponseComputerToolCallOutputScreenshot].
	ImageURL string `json:"image_url"`
	JSON     struct {
		OfString                                             respjson.Field
		OfOutputContentList                                  respjson.Field
		OfBetaResponseOutputTextArray                        respjson.Field
		OfBetaResponseFunctionShellToolCallOutputOutputArray respjson.Field
		Type                                                 respjson.Field
		FileID                                               respjson.Field
		ImageURL                                             respjson.Field
		raw                                                  string
	} `json:"-"`
}

func (r *BetaResponseOutputItemUnionOutput) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseOutputItemUnionAction is an implicit subunion of
// [BetaResponseOutputItemUnion]. BetaResponseOutputItemUnionAction provides
// convenient access to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseOutputItemUnion].
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfBetaResponseOutputItemMultiAgentCallOutputAction]
type BetaResponseOutputItemUnionAction struct {
	// This field will be present if the value is a [string] instead of an object.
	OfBetaResponseOutputItemMultiAgentCallOutputAction string `json:",inline"`
	Type                                               string `json:"type"`
	// This field is from variant [BetaResponseFunctionWebSearchActionUnion].
	Queries []string `json:"queries"`
	// This field is from variant [BetaResponseFunctionWebSearchActionUnion].
	Query string `json:"query"`
	// This field is from variant [BetaResponseFunctionWebSearchActionUnion].
	Sources []BetaResponseFunctionWebSearchActionSearchSource `json:"sources"`
	URL     string                                            `json:"url"`
	// This field is from variant [BetaResponseFunctionWebSearchActionUnion].
	Pattern string `json:"pattern"`
	// This field is from variant [BetaComputerActionUnion].
	Button string   `json:"button"`
	X      int64    `json:"x"`
	Y      int64    `json:"y"`
	Keys   []string `json:"keys"`
	// This field is from variant [BetaComputerActionUnion].
	Path []BetaComputerActionDragPath `json:"path"`
	// This field is from variant [BetaComputerActionUnion].
	ScrollX int64 `json:"scroll_x"`
	// This field is from variant [BetaComputerActionUnion].
	ScrollY int64 `json:"scroll_y"`
	// This field is from variant [BetaComputerActionUnion].
	Text string `json:"text"`
	// This field is from variant [BetaResponseOutputItemLocalShellCallAction].
	Command []string `json:"command"`
	// This field is from variant [BetaResponseOutputItemLocalShellCallAction].
	Env       map[string]string `json:"env"`
	TimeoutMs int64             `json:"timeout_ms"`
	// This field is from variant [BetaResponseOutputItemLocalShellCallAction].
	User string `json:"user"`
	// This field is from variant [BetaResponseOutputItemLocalShellCallAction].
	WorkingDirectory string `json:"working_directory"`
	// This field is from variant [BetaResponseFunctionShellToolCallAction].
	Commands []string `json:"commands"`
	// This field is from variant [BetaResponseFunctionShellToolCallAction].
	MaxOutputLength int64 `json:"max_output_length"`
	JSON            struct {
		OfBetaResponseOutputItemMultiAgentCallOutputAction respjson.Field
		Type                                               respjson.Field
		Queries                                            respjson.Field
		Query                                              respjson.Field
		Sources                                            respjson.Field
		URL                                                respjson.Field
		Pattern                                            respjson.Field
		Button                                             respjson.Field
		X                                                  respjson.Field
		Y                                                  respjson.Field
		Keys                                               respjson.Field
		Path                                               respjson.Field
		ScrollX                                            respjson.Field
		ScrollY                                            respjson.Field
		Text                                               respjson.Field
		Command                                            respjson.Field
		Env                                                respjson.Field
		TimeoutMs                                          respjson.Field
		User                                               respjson.Field
		WorkingDirectory                                   respjson.Field
		Commands                                           respjson.Field
		MaxOutputLength                                    respjson.Field
		raw                                                string
	} `json:"-"`
}

func (r *BetaResponseOutputItemUnionAction) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseOutputItemUnionTools is an implicit subunion of
// [BetaResponseOutputItemUnion]. BetaResponseOutputItemUnionTools provides
// convenient access to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseOutputItemUnion].
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfBetaToolArray OfBetaResponseOutputItemMcpListToolsTools]
type BetaResponseOutputItemUnionTools struct {
	// This field will be present if the value is a [[]BetaToolUnion] instead of an
	// object.
	OfBetaToolArray []BetaToolUnion `json:",inline"`
	// This field will be present if the value is a
	// [[]BetaResponseOutputItemMcpListToolsTool] instead of an object.
	OfBetaResponseOutputItemMcpListToolsTools []BetaResponseOutputItemMcpListToolsTool `json:",inline"`
	JSON                                      struct {
		OfBetaToolArray                           respjson.Field
		OfBetaResponseOutputItemMcpListToolsTools respjson.Field
		raw                                       string
	} `json:"-"`
}

func (r *BetaResponseOutputItemUnionTools) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseOutputItemAgentMessage struct {
	// The unique ID of the agent message.
	ID string `json:"id" api:"required"`
	// The sending agent identity.
	Author string `json:"author" api:"required"`
	// Encrypted content sent between agents.
	Content []BetaResponseOutputItemAgentMessageContentUnion `json:"content" api:"required"`
	// The destination agent identity.
	Recipient string `json:"recipient" api:"required"`
	// The type of the item. Always `agent_message`.
	Type constant.AgentMessage `json:"type" default:"agent_message"`
	// The agent that produced this item.
	Agent BetaResponseOutputItemAgentMessageAgent `json:"agent"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Author      respjson.Field
		Content     respjson.Field
		Recipient   respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemAgentMessage) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemAgentMessage) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseOutputItemAgentMessageContentUnion contains all possible properties
// and values from [BetaResponseInputText], [BetaResponseOutputText],
// [BetaResponseOutputItemAgentMessageContentText],
// [BetaResponseOutputItemAgentMessageContentSummaryText],
// [BetaResponseOutputItemAgentMessageContentReasoningText],
// [BetaResponseOutputRefusal], [BetaResponseInputImage],
// [BetaResponseOutputItemAgentMessageContentComputerScreenshot],
// [BetaResponseInputFile],
// [BetaResponseOutputItemAgentMessageContentEncryptedContent].
//
// Use the [BetaResponseOutputItemAgentMessageContentUnion.AsAny] method to switch
// on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseOutputItemAgentMessageContentUnion struct {
	Text string `json:"text"`
	// Any of "input_text", "output_text", "text", "summary_text", "reasoning_text",
	// "refusal", "input_image", "computer_screenshot", "input_file",
	// "encrypted_content".
	Type string `json:"type"`
	// This field is a union of [BetaResponseInputTextPromptCacheBreakpoint],
	// [BetaResponseInputImagePromptCacheBreakpoint],
	// [BetaResponseOutputItemAgentMessageContentComputerScreenshotPromptCacheBreakpoint],
	// [BetaResponseInputFilePromptCacheBreakpoint]
	PromptCacheBreakpoint BetaResponseOutputItemAgentMessageContentUnionPromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
	// This field is from variant [BetaResponseOutputText].
	Annotations []BetaResponseOutputTextAnnotationUnion `json:"annotations"`
	// This field is from variant [BetaResponseOutputText].
	Logprobs []BetaResponseOutputTextLogprob `json:"logprobs"`
	// This field is from variant [BetaResponseOutputRefusal].
	Refusal  string `json:"refusal"`
	Detail   string `json:"detail"`
	FileID   string `json:"file_id"`
	ImageURL string `json:"image_url"`
	// This field is from variant [BetaResponseInputFile].
	FileData string `json:"file_data"`
	// This field is from variant [BetaResponseInputFile].
	FileURL string `json:"file_url"`
	// This field is from variant [BetaResponseInputFile].
	Filename string `json:"filename"`
	// This field is from variant
	// [BetaResponseOutputItemAgentMessageContentEncryptedContent].
	EncryptedContent string `json:"encrypted_content"`
	JSON             struct {
		Text                  respjson.Field
		Type                  respjson.Field
		PromptCacheBreakpoint respjson.Field
		Annotations           respjson.Field
		Logprobs              respjson.Field
		Refusal               respjson.Field
		Detail                respjson.Field
		FileID                respjson.Field
		ImageURL              respjson.Field
		FileData              respjson.Field
		FileURL               respjson.Field
		Filename              respjson.Field
		EncryptedContent      respjson.Field
		raw                   string
	} `json:"-"`
}

// anyBetaResponseOutputItemAgentMessageContent is implemented by each variant of
// [BetaResponseOutputItemAgentMessageContentUnion] to add type safety for the
// return type of [BetaResponseOutputItemAgentMessageContentUnion.AsAny]
type anyBetaResponseOutputItemAgentMessageContent interface {
	implBetaResponseOutputItemAgentMessageContentUnion()
}

func (BetaResponseInputText) implBetaResponseOutputItemAgentMessageContentUnion()  {}
func (BetaResponseOutputText) implBetaResponseOutputItemAgentMessageContentUnion() {}
func (BetaResponseOutputItemAgentMessageContentText) implBetaResponseOutputItemAgentMessageContentUnion() {
}
func (BetaResponseOutputItemAgentMessageContentSummaryText) implBetaResponseOutputItemAgentMessageContentUnion() {
}
func (BetaResponseOutputItemAgentMessageContentReasoningText) implBetaResponseOutputItemAgentMessageContentUnion() {
}
func (BetaResponseOutputRefusal) implBetaResponseOutputItemAgentMessageContentUnion() {}
func (BetaResponseInputImage) implBetaResponseOutputItemAgentMessageContentUnion()    {}
func (BetaResponseOutputItemAgentMessageContentComputerScreenshot) implBetaResponseOutputItemAgentMessageContentUnion() {
}
func (BetaResponseInputFile) implBetaResponseOutputItemAgentMessageContentUnion() {}
func (BetaResponseOutputItemAgentMessageContentEncryptedContent) implBetaResponseOutputItemAgentMessageContentUnion() {
}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseOutputItemAgentMessageContentUnion.AsAny().(type) {
//	case openai.BetaResponseInputText:
//	case openai.BetaResponseOutputText:
//	case openai.BetaResponseOutputItemAgentMessageContentText:
//	case openai.BetaResponseOutputItemAgentMessageContentSummaryText:
//	case openai.BetaResponseOutputItemAgentMessageContentReasoningText:
//	case openai.BetaResponseOutputRefusal:
//	case openai.BetaResponseInputImage:
//	case openai.BetaResponseOutputItemAgentMessageContentComputerScreenshot:
//	case openai.BetaResponseInputFile:
//	case openai.BetaResponseOutputItemAgentMessageContentEncryptedContent:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseOutputItemAgentMessageContentUnion) AsAny() anyBetaResponseOutputItemAgentMessageContent {
	switch u.Type {
	case "input_text":
		return u.AsInputText()
	case "output_text":
		return u.AsOutputText()
	case "text":
		return u.AsText()
	case "summary_text":
		return u.AsSummaryText()
	case "reasoning_text":
		return u.AsReasoningText()
	case "refusal":
		return u.AsRefusal()
	case "input_image":
		return u.AsInputImage()
	case "computer_screenshot":
		return u.AsComputerScreenshot()
	case "input_file":
		return u.AsInputFile()
	case "encrypted_content":
		return u.AsEncryptedContent()
	}
	return nil
}

func (u BetaResponseOutputItemAgentMessageContentUnion) AsInputText() (v BetaResponseInputText) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemAgentMessageContentUnion) AsOutputText() (v BetaResponseOutputText) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemAgentMessageContentUnion) AsText() (v BetaResponseOutputItemAgentMessageContentText) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemAgentMessageContentUnion) AsSummaryText() (v BetaResponseOutputItemAgentMessageContentSummaryText) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemAgentMessageContentUnion) AsReasoningText() (v BetaResponseOutputItemAgentMessageContentReasoningText) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemAgentMessageContentUnion) AsRefusal() (v BetaResponseOutputRefusal) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemAgentMessageContentUnion) AsInputImage() (v BetaResponseInputImage) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemAgentMessageContentUnion) AsComputerScreenshot() (v BetaResponseOutputItemAgentMessageContentComputerScreenshot) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemAgentMessageContentUnion) AsInputFile() (v BetaResponseInputFile) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputItemAgentMessageContentUnion) AsEncryptedContent() (v BetaResponseOutputItemAgentMessageContentEncryptedContent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseOutputItemAgentMessageContentUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseOutputItemAgentMessageContentUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseOutputItemAgentMessageContentUnionPromptCacheBreakpoint is an
// implicit subunion of [BetaResponseOutputItemAgentMessageContentUnion].
// BetaResponseOutputItemAgentMessageContentUnionPromptCacheBreakpoint provides
// convenient access to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseOutputItemAgentMessageContentUnion].
type BetaResponseOutputItemAgentMessageContentUnionPromptCacheBreakpoint struct {
	// This field is from variant [BetaResponseInputTextPromptCacheBreakpoint].
	Mode constant.Explicit `json:"mode"`
	JSON struct {
		Mode respjson.Field
		raw  string
	} `json:"-"`
}

func (r *BetaResponseOutputItemAgentMessageContentUnionPromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A text content.
type BetaResponseOutputItemAgentMessageContentText struct {
	Text string        `json:"text" api:"required"`
	Type constant.Text `json:"type" default:"text"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemAgentMessageContentText) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemAgentMessageContentText) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A summary text from the model.
type BetaResponseOutputItemAgentMessageContentSummaryText struct {
	// A summary of the reasoning output from the model so far.
	Text string `json:"text" api:"required"`
	// The type of the object. Always `summary_text`.
	Type constant.SummaryText `json:"type" default:"summary_text"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemAgentMessageContentSummaryText) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemAgentMessageContentSummaryText) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Reasoning text from the model.
type BetaResponseOutputItemAgentMessageContentReasoningText struct {
	// The reasoning text from the model.
	Text string `json:"text" api:"required"`
	// The type of the reasoning text. Always `reasoning_text`.
	Type constant.ReasoningText `json:"type" default:"reasoning_text"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemAgentMessageContentReasoningText) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemAgentMessageContentReasoningText) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A screenshot of a computer.
type BetaResponseOutputItemAgentMessageContentComputerScreenshot struct {
	// The detail level of the screenshot image to be sent to the model. One of `high`,
	// `low`, `auto`, or `original`. Defaults to `auto`.
	//
	// Any of "low", "high", "auto", "original".
	Detail string `json:"detail" api:"required"`
	// The identifier of an uploaded file that contains the screenshot.
	FileID string `json:"file_id" api:"required"`
	// The URL of the screenshot image.
	ImageURL string `json:"image_url" api:"required" format:"uri"`
	// Specifies the event type. For a computer screenshot, this property is always set
	// to `computer_screenshot`.
	Type constant.ComputerScreenshot `json:"type" default:"computer_screenshot"`
	// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
	// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
	// token block.
	PromptCacheBreakpoint BetaResponseOutputItemAgentMessageContentComputerScreenshotPromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Detail                respjson.Field
		FileID                respjson.Field
		ImageURL              respjson.Field
		Type                  respjson.Field
		PromptCacheBreakpoint respjson.Field
		ExtraFields           map[string]respjson.Field
		raw                   string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemAgentMessageContentComputerScreenshot) RawJSON() string {
	return r.JSON.raw
}
func (r *BetaResponseOutputItemAgentMessageContentComputerScreenshot) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
// from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
// token block.
type BetaResponseOutputItemAgentMessageContentComputerScreenshotPromptCacheBreakpoint struct {
	// The breakpoint mode. Always `explicit`.
	Mode constant.Explicit `json:"mode" default:"explicit"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Mode        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemAgentMessageContentComputerScreenshotPromptCacheBreakpoint) RawJSON() string {
	return r.JSON.raw
}
func (r *BetaResponseOutputItemAgentMessageContentComputerScreenshotPromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Opaque encrypted content that Responses API decrypts inside trusted model
// execution.
type BetaResponseOutputItemAgentMessageContentEncryptedContent struct {
	// Opaque encrypted content.
	EncryptedContent string `json:"encrypted_content" api:"required"`
	// The type of the input item. Always `encrypted_content`.
	Type constant.EncryptedContent `json:"type" default:"encrypted_content"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		EncryptedContent respjson.Field
		Type             respjson.Field
		ExtraFields      map[string]respjson.Field
		raw              string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemAgentMessageContentEncryptedContent) RawJSON() string {
	return r.JSON.raw
}
func (r *BetaResponseOutputItemAgentMessageContentEncryptedContent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseOutputItemAgentMessageAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemAgentMessageAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemAgentMessageAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseOutputItemMultiAgentCall struct {
	// The unique ID of the multi-agent call item.
	ID string `json:"id" api:"required"`
	// The multi-agent action to execute.
	//
	// Any of "spawn_agent", "interrupt_agent", "list_agents", "send_message",
	// "followup_task", "wait_agent".
	Action string `json:"action" api:"required"`
	// The JSON string of arguments generated for the action.
	Arguments string `json:"arguments" api:"required"`
	// The unique ID linking this call to its output.
	CallID string `json:"call_id" api:"required"`
	// The type of the multi-agent call. Always `multi_agent_call`.
	Type constant.MultiAgentCall `json:"type" default:"multi_agent_call"`
	// The agent that produced this item.
	Agent BetaResponseOutputItemMultiAgentCallAgent `json:"agent"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Action      respjson.Field
		Arguments   respjson.Field
		CallID      respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemMultiAgentCall) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemMultiAgentCall) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseOutputItemMultiAgentCallAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemMultiAgentCallAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemMultiAgentCallAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseOutputItemMultiAgentCallOutput struct {
	// The unique ID of the multi-agent call output item.
	ID string `json:"id" api:"required"`
	// The multi-agent action that produced this result.
	//
	// Any of "spawn_agent", "interrupt_agent", "list_agents", "send_message",
	// "followup_task", "wait_agent".
	Action string `json:"action" api:"required"`
	// The unique ID of the multi-agent call.
	CallID string `json:"call_id" api:"required"`
	// Text output returned by the multi-agent action.
	Output []BetaResponseOutputText `json:"output" api:"required"`
	// The type of the multi-agent result. Always `multi_agent_call_output`.
	Type constant.MultiAgentCallOutput `json:"type" default:"multi_agent_call_output"`
	// The agent that produced this item.
	Agent BetaResponseOutputItemMultiAgentCallOutputAgent `json:"agent"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Action      respjson.Field
		CallID      respjson.Field
		Output      respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemMultiAgentCallOutput) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemMultiAgentCallOutput) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseOutputItemMultiAgentCallOutputAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemMultiAgentCallOutputAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemMultiAgentCallOutputAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseOutputItemProgram struct {
	// The unique ID of the program item.
	ID string `json:"id" api:"required"`
	// The stable call ID of the program item.
	CallID string `json:"call_id" api:"required"`
	// The JavaScript source executed by programmatic tool calling.
	Code string `json:"code" api:"required"`
	// Opaque program replay fingerprint that must be round-tripped.
	Fingerprint string `json:"fingerprint" api:"required"`
	// The type of the item. Always `program`.
	Type constant.Program `json:"type" default:"program"`
	// The agent that produced this item.
	Agent BetaResponseOutputItemProgramAgent `json:"agent"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CallID      respjson.Field
		Code        respjson.Field
		Fingerprint respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemProgram) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemProgram) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseOutputItemProgramAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemProgramAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemProgramAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseOutputItemProgramOutput struct {
	// The unique ID of the program output item.
	ID string `json:"id" api:"required"`
	// The call ID of the program item.
	CallID string `json:"call_id" api:"required"`
	// The result produced by the program item.
	Result string `json:"result" api:"required"`
	// The terminal status of the program output item.
	//
	// Any of "completed", "incomplete".
	Status string `json:"status" api:"required"`
	// The type of the item. Always `program_output`.
	Type constant.ProgramOutput `json:"type" default:"program_output"`
	// The agent that produced this item.
	Agent BetaResponseOutputItemProgramOutputAgent `json:"agent"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CallID      respjson.Field
		Result      respjson.Field
		Status      respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemProgramOutput) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemProgramOutput) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseOutputItemProgramOutputAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemProgramOutputAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemProgramOutputAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseOutputItemAdditionalTools struct {
	// The unique ID of the additional tools item.
	ID string `json:"id" api:"required"`
	// The role that provided the additional tools.
	//
	// Any of "unknown", "user", "assistant", "system", "critic", "discriminator",
	// "developer", "tool".
	Role string `json:"role" api:"required"`
	// The additional tool definitions made available at this item.
	Tools []BetaToolUnion `json:"tools" api:"required"`
	// The type of the item. Always `additional_tools`.
	Type constant.AdditionalTools `json:"type" default:"additional_tools"`
	// The agent that produced this item.
	Agent BetaResponseOutputItemAdditionalToolsAgent `json:"agent"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Role        respjson.Field
		Tools       respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemAdditionalTools) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemAdditionalTools) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseOutputItemAdditionalToolsAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemAdditionalToolsAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemAdditionalToolsAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// An image generation request made by the model.
type BetaResponseOutputItemImageGenerationCall struct {
	// The unique ID of the image generation call.
	ID string `json:"id" api:"required"`
	// The generated image encoded in base64.
	Result string `json:"result" api:"required"`
	// The status of the image generation call.
	//
	// Any of "in_progress", "completed", "generating", "failed".
	Status string `json:"status" api:"required"`
	// The type of the image generation call. Always `image_generation_call`.
	Type constant.ImageGenerationCall `json:"type" default:"image_generation_call"`
	// The agent that produced this item.
	Agent BetaResponseOutputItemImageGenerationCallAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Result      respjson.Field
		Status      respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemImageGenerationCall) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemImageGenerationCall) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseOutputItemImageGenerationCallAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemImageGenerationCallAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemImageGenerationCallAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool call to run a command on the local shell.
type BetaResponseOutputItemLocalShellCall struct {
	// The unique ID of the local shell call.
	ID string `json:"id" api:"required"`
	// Execute a shell command on the server.
	Action BetaResponseOutputItemLocalShellCallAction `json:"action" api:"required"`
	// The unique ID of the local shell tool call generated by the model.
	CallID string `json:"call_id" api:"required"`
	// The status of the local shell call.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status string `json:"status" api:"required"`
	// The type of the local shell call. Always `local_shell_call`.
	Type constant.LocalShellCall `json:"type" default:"local_shell_call"`
	// The agent that produced this item.
	Agent BetaResponseOutputItemLocalShellCallAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Action      respjson.Field
		CallID      respjson.Field
		Status      respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemLocalShellCall) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemLocalShellCall) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Execute a shell command on the server.
type BetaResponseOutputItemLocalShellCallAction struct {
	// The command to run.
	Command []string `json:"command" api:"required"`
	// Environment variables to set for the command.
	Env map[string]string `json:"env" api:"required"`
	// The type of the local shell action. Always `exec`.
	Type constant.Exec `json:"type" default:"exec"`
	// Optional timeout in milliseconds for the command.
	TimeoutMs int64 `json:"timeout_ms" api:"nullable"`
	// Optional user to run the command as.
	User string `json:"user" api:"nullable"`
	// Optional working directory to run the command in.
	WorkingDirectory string `json:"working_directory" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Command          respjson.Field
		Env              respjson.Field
		Type             respjson.Field
		TimeoutMs        respjson.Field
		User             respjson.Field
		WorkingDirectory respjson.Field
		ExtraFields      map[string]respjson.Field
		raw              string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemLocalShellCallAction) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemLocalShellCallAction) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseOutputItemLocalShellCallAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemLocalShellCallAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemLocalShellCallAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The output of a local shell tool call.
type BetaResponseOutputItemLocalShellCallOutput struct {
	// The unique ID of the local shell tool call generated by the model.
	ID string `json:"id" api:"required"`
	// A JSON string of the output of the local shell tool call.
	Output string `json:"output" api:"required"`
	// The type of the local shell tool call output. Always `local_shell_call_output`.
	Type constant.LocalShellCallOutput `json:"type" default:"local_shell_call_output"`
	// The agent that produced this item.
	Agent BetaResponseOutputItemLocalShellCallOutputAgent `json:"agent" api:"nullable"`
	// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status string `json:"status" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Output      respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		Status      respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemLocalShellCallOutput) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemLocalShellCallOutput) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseOutputItemLocalShellCallOutputAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemLocalShellCallOutputAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemLocalShellCallOutputAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// An invocation of a tool on an MCP server.
type BetaResponseOutputItemMcpCall struct {
	// The unique ID of the tool call.
	ID string `json:"id" api:"required"`
	// A JSON string of the arguments passed to the tool.
	Arguments string `json:"arguments" api:"required"`
	// The name of the tool that was run.
	Name string `json:"name" api:"required"`
	// The label of the MCP server running the tool.
	ServerLabel string `json:"server_label" api:"required"`
	// The type of the item. Always `mcp_call`.
	Type constant.McpCall `json:"type" default:"mcp_call"`
	// The agent that produced this item.
	Agent BetaResponseOutputItemMcpCallAgent `json:"agent" api:"nullable"`
	// Unique identifier for the MCP tool call approval request. Include this value in
	// a subsequent `mcp_approval_response` input to approve or reject the
	// corresponding tool call.
	ApprovalRequestID string `json:"approval_request_id" api:"nullable"`
	// The error from the tool call, if any.
	Error string `json:"error" api:"nullable"`
	// The output from the tool call.
	Output string `json:"output" api:"nullable"`
	// The status of the tool call. One of `in_progress`, `completed`, `incomplete`,
	// `calling`, or `failed`.
	//
	// Any of "in_progress", "completed", "incomplete", "calling", "failed".
	Status string `json:"status"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                respjson.Field
		Arguments         respjson.Field
		Name              respjson.Field
		ServerLabel       respjson.Field
		Type              respjson.Field
		Agent             respjson.Field
		ApprovalRequestID respjson.Field
		Error             respjson.Field
		Output            respjson.Field
		Status            respjson.Field
		ExtraFields       map[string]respjson.Field
		raw               string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemMcpCall) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemMcpCall) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseOutputItemMcpCallAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemMcpCallAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemMcpCallAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A list of tools available on an MCP server.
type BetaResponseOutputItemMcpListTools struct {
	// The unique ID of the list.
	ID string `json:"id" api:"required"`
	// The label of the MCP server.
	ServerLabel string `json:"server_label" api:"required"`
	// The tools available on the server.
	Tools []BetaResponseOutputItemMcpListToolsTool `json:"tools" api:"required"`
	// The type of the item. Always `mcp_list_tools`.
	Type constant.McpListTools `json:"type" default:"mcp_list_tools"`
	// The agent that produced this item.
	Agent BetaResponseOutputItemMcpListToolsAgent `json:"agent" api:"nullable"`
	// Error message if the server could not list tools.
	Error string `json:"error" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		ServerLabel respjson.Field
		Tools       respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		Error       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemMcpListTools) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemMcpListTools) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool available on an MCP server.
type BetaResponseOutputItemMcpListToolsTool struct {
	// The JSON schema describing the tool's input.
	InputSchema any `json:"input_schema" api:"required"`
	// The name of the tool.
	Name string `json:"name" api:"required"`
	// Additional annotations about the tool.
	Annotations any `json:"annotations" api:"nullable"`
	// The description of the tool.
	Description string `json:"description" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		InputSchema respjson.Field
		Name        respjson.Field
		Annotations respjson.Field
		Description respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemMcpListToolsTool) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemMcpListToolsTool) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseOutputItemMcpListToolsAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemMcpListToolsAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemMcpListToolsAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A request for human approval of a tool invocation.
type BetaResponseOutputItemMcpApprovalRequest struct {
	// The unique ID of the approval request.
	ID string `json:"id" api:"required"`
	// A JSON string of arguments for the tool.
	Arguments string `json:"arguments" api:"required"`
	// The name of the tool to run.
	Name string `json:"name" api:"required"`
	// The label of the MCP server making the request.
	ServerLabel string `json:"server_label" api:"required"`
	// The type of the item. Always `mcp_approval_request`.
	Type constant.McpApprovalRequest `json:"type" default:"mcp_approval_request"`
	// The agent that produced this item.
	Agent BetaResponseOutputItemMcpApprovalRequestAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Arguments   respjson.Field
		Name        respjson.Field
		ServerLabel respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemMcpApprovalRequest) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemMcpApprovalRequest) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseOutputItemMcpApprovalRequestAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemMcpApprovalRequestAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemMcpApprovalRequestAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A response to an MCP approval request.
type BetaResponseOutputItemMcpApprovalResponse struct {
	// The unique ID of the approval response
	ID string `json:"id" api:"required"`
	// The ID of the approval request being answered.
	ApprovalRequestID string `json:"approval_request_id" api:"required"`
	// Whether the request was approved.
	Approve bool `json:"approve" api:"required"`
	// The type of the item. Always `mcp_approval_response`.
	Type constant.McpApprovalResponse `json:"type" default:"mcp_approval_response"`
	// The agent that produced this item.
	Agent BetaResponseOutputItemMcpApprovalResponseAgent `json:"agent" api:"nullable"`
	// Optional reason for the decision.
	Reason string `json:"reason" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                respjson.Field
		ApprovalRequestID respjson.Field
		Approve           respjson.Field
		Type              respjson.Field
		Agent             respjson.Field
		Reason            respjson.Field
		ExtraFields       map[string]respjson.Field
		raw               string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemMcpApprovalResponse) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemMcpApprovalResponse) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseOutputItemMcpApprovalResponseAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemMcpApprovalResponseAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemMcpApprovalResponseAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when a new output item is added.
type BetaResponseOutputItemAddedEvent struct {
	// The output item that was added.
	Item BetaResponseOutputItemUnion `json:"item" api:"required"`
	// The index of the output item that was added.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.output_item.added`.
	Type constant.ResponseOutputItemAdded `json:"type" default:"response.output_item.added"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseOutputItemAddedEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Item           respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemAddedEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemAddedEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseOutputItemAddedEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemAddedEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemAddedEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when an output item is marked done.
type BetaResponseOutputItemDoneEvent struct {
	// The output item that was marked done.
	Item BetaResponseOutputItemUnion `json:"item" api:"required"`
	// The index of the output item that was marked done.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.output_item.done`.
	Type constant.ResponseOutputItemDone `json:"type" default:"response.output_item.done"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseOutputItemDoneEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Item           respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemDoneEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemDoneEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseOutputItemDoneEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputItemDoneEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputItemDoneEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// An output message from the model.
type BetaResponseOutputMessage struct {
	// The unique ID of the output message.
	ID string `json:"id" api:"required"`
	// The content of the output message.
	Content []BetaResponseOutputMessageContentUnion `json:"content" api:"required"`
	// The role of the output message. Always `assistant`.
	Role constant.Assistant `json:"role" default:"assistant"`
	// The status of the message input. One of `in_progress`, `completed`, or
	// `incomplete`. Populated when input items are returned via API.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status BetaResponseOutputMessageStatus `json:"status" api:"required"`
	// The type of the output message. Always `message`.
	Type constant.Message `json:"type" default:"message"`
	// The agent that produced this item.
	Agent BetaResponseOutputMessageAgent `json:"agent" api:"nullable"`
	// Labels an `assistant` message as intermediate commentary (`commentary`) or the
	// final answer (`final_answer`). For models like `gpt-5.3-codex` and beyond, when
	// sending follow-up requests, preserve and resend phase on all assistant messages
	// — dropping it can degrade performance. Not used for user messages.
	//
	// Any of "commentary", "final_answer".
	Phase BetaResponseOutputMessagePhase `json:"phase" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Content     respjson.Field
		Role        respjson.Field
		Status      respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		Phase       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputMessage) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputMessage) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseOutputMessage to a
// BetaResponseOutputMessageParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseOutputMessageParam.Overrides()
func (r BetaResponseOutputMessage) ToParam() BetaResponseOutputMessageParam {
	return param.Override[BetaResponseOutputMessageParam](json.RawMessage(r.RawJSON()))
}

// BetaResponseOutputMessageContentUnion contains all possible properties and
// values from [BetaResponseOutputText], [BetaResponseOutputRefusal].
//
// Use the [BetaResponseOutputMessageContentUnion.AsAny] method to switch on the
// variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseOutputMessageContentUnion struct {
	// This field is from variant [BetaResponseOutputText].
	Annotations []BetaResponseOutputTextAnnotationUnion `json:"annotations"`
	// This field is from variant [BetaResponseOutputText].
	Text string `json:"text"`
	// Any of "output_text", "refusal".
	Type string `json:"type"`
	// This field is from variant [BetaResponseOutputText].
	Logprobs []BetaResponseOutputTextLogprob `json:"logprobs"`
	// This field is from variant [BetaResponseOutputRefusal].
	Refusal string `json:"refusal"`
	JSON    struct {
		Annotations respjson.Field
		Text        respjson.Field
		Type        respjson.Field
		Logprobs    respjson.Field
		Refusal     respjson.Field
		raw         string
	} `json:"-"`
}

// anyBetaResponseOutputMessageContent is implemented by each variant of
// [BetaResponseOutputMessageContentUnion] to add type safety for the return type
// of [BetaResponseOutputMessageContentUnion.AsAny]
type anyBetaResponseOutputMessageContent interface {
	implBetaResponseOutputMessageContentUnion()
}

func (BetaResponseOutputText) implBetaResponseOutputMessageContentUnion()    {}
func (BetaResponseOutputRefusal) implBetaResponseOutputMessageContentUnion() {}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseOutputMessageContentUnion.AsAny().(type) {
//	case openai.BetaResponseOutputText:
//	case openai.BetaResponseOutputRefusal:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseOutputMessageContentUnion) AsAny() anyBetaResponseOutputMessageContent {
	switch u.Type {
	case "output_text":
		return u.AsOutputText()
	case "refusal":
		return u.AsRefusal()
	}
	return nil
}

func (u BetaResponseOutputMessageContentUnion) AsOutputText() (v BetaResponseOutputText) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputMessageContentUnion) AsRefusal() (v BetaResponseOutputRefusal) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseOutputMessageContentUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseOutputMessageContentUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The status of the message input. One of `in_progress`, `completed`, or
// `incomplete`. Populated when input items are returned via API.
type BetaResponseOutputMessageStatus string

const (
	BetaResponseOutputMessageStatusInProgress BetaResponseOutputMessageStatus = "in_progress"
	BetaResponseOutputMessageStatusCompleted  BetaResponseOutputMessageStatus = "completed"
	BetaResponseOutputMessageStatusIncomplete BetaResponseOutputMessageStatus = "incomplete"
)

// The agent that produced this item.
type BetaResponseOutputMessageAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputMessageAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputMessageAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Labels an `assistant` message as intermediate commentary (`commentary`) or the
// final answer (`final_answer`). For models like `gpt-5.3-codex` and beyond, when
// sending follow-up requests, preserve and resend phase on all assistant messages
// — dropping it can degrade performance. Not used for user messages.
type BetaResponseOutputMessagePhase string

const (
	BetaResponseOutputMessagePhaseCommentary  BetaResponseOutputMessagePhase = "commentary"
	BetaResponseOutputMessagePhaseFinalAnswer BetaResponseOutputMessagePhase = "final_answer"
)

// An output message from the model.
//
// The properties ID, Content, Role, Status, Type are required.
type BetaResponseOutputMessageParam struct {
	// The unique ID of the output message.
	ID string `json:"id,omitzero" api:"required"`
	// The content of the output message.
	Content []BetaResponseOutputMessageContentUnionParam `json:"content,omitzero" api:"required"`
	// The status of the message input. One of `in_progress`, `completed`, or
	// `incomplete`. Populated when input items are returned via API.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status BetaResponseOutputMessageStatus `json:"status,omitzero" api:"required"`
	// The agent that produced this item.
	Agent BetaResponseOutputMessageAgentParam `json:"agent,omitzero"`
	// Labels an `assistant` message as intermediate commentary (`commentary`) or the
	// final answer (`final_answer`). For models like `gpt-5.3-codex` and beyond, when
	// sending follow-up requests, preserve and resend phase on all assistant messages
	// — dropping it can degrade performance. Not used for user messages.
	//
	// Any of "commentary", "final_answer".
	Phase BetaResponseOutputMessagePhase `json:"phase,omitzero"`
	// The role of the output message. Always `assistant`.
	//
	// This field can be elided, and will marshal its zero value as "assistant".
	Role constant.Assistant `json:"role" default:"assistant"`
	// The type of the output message. Always `message`.
	//
	// This field can be elided, and will marshal its zero value as "message".
	Type constant.Message `json:"type" default:"message"`
	paramObj
}

func (r BetaResponseOutputMessageParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseOutputMessageParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseOutputMessageParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseOutputMessageContentUnionParam struct {
	OfOutputText *BetaResponseOutputTextParam    `json:",omitzero,inline"`
	OfRefusal    *BetaResponseOutputRefusalParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseOutputMessageContentUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfOutputText, u.OfRefusal)
}
func (u *BetaResponseOutputMessageContentUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseOutputMessageContentUnionParam) asAny() any {
	if !param.IsOmitted(u.OfOutputText) {
		return u.OfOutputText
	} else if !param.IsOmitted(u.OfRefusal) {
		return u.OfRefusal
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseOutputMessageContentUnionParam) GetAnnotations() []BetaResponseOutputTextAnnotationUnionParam {
	if vt := u.OfOutputText; vt != nil {
		return vt.Annotations
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseOutputMessageContentUnionParam) GetText() *string {
	if vt := u.OfOutputText; vt != nil {
		return &vt.Text
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseOutputMessageContentUnionParam) GetLogprobs() []BetaResponseOutputTextLogprobParam {
	if vt := u.OfOutputText; vt != nil {
		return vt.Logprobs
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseOutputMessageContentUnionParam) GetRefusal() *string {
	if vt := u.OfRefusal; vt != nil {
		return &vt.Refusal
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseOutputMessageContentUnionParam) GetType() *string {
	if vt := u.OfOutputText; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfRefusal; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaResponseOutputMessageContentUnionParam](
		"type",
		apijson.Discriminator[BetaResponseOutputTextParam]("output_text"),
		apijson.Discriminator[BetaResponseOutputRefusalParam]("refusal"),
	)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseOutputMessageAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseOutputMessageAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseOutputMessageAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseOutputMessageAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A refusal from the model.
type BetaResponseOutputRefusal struct {
	// The refusal explanation from the model.
	Refusal string `json:"refusal" api:"required"`
	// The type of the refusal. Always `refusal`.
	Type constant.Refusal `json:"type" default:"refusal"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Refusal     respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputRefusal) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputRefusal) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseOutputRefusal to a
// BetaResponseOutputRefusalParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseOutputRefusalParam.Overrides()
func (r BetaResponseOutputRefusal) ToParam() BetaResponseOutputRefusalParam {
	return param.Override[BetaResponseOutputRefusalParam](json.RawMessage(r.RawJSON()))
}

// A refusal from the model.
//
// The properties Refusal, Type are required.
type BetaResponseOutputRefusalParam struct {
	// The refusal explanation from the model.
	Refusal string `json:"refusal" api:"required"`
	// The type of the refusal. Always `refusal`.
	//
	// This field can be elided, and will marshal its zero value as "refusal".
	Type constant.Refusal `json:"type" default:"refusal"`
	paramObj
}

func (r BetaResponseOutputRefusalParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseOutputRefusalParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseOutputRefusalParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A text output from the model.
type BetaResponseOutputText struct {
	// The annotations of the text output.
	Annotations []BetaResponseOutputTextAnnotationUnion `json:"annotations" api:"required"`
	// The text output from the model.
	Text string `json:"text" api:"required"`
	// The type of the output text. Always `output_text`.
	Type     constant.OutputText             `json:"type" default:"output_text"`
	Logprobs []BetaResponseOutputTextLogprob `json:"logprobs"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Annotations respjson.Field
		Text        respjson.Field
		Type        respjson.Field
		Logprobs    respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputText) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputText) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseOutputText to a BetaResponseOutputTextParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseOutputTextParam.Overrides()
func (r BetaResponseOutputText) ToParam() BetaResponseOutputTextParam {
	return param.Override[BetaResponseOutputTextParam](json.RawMessage(r.RawJSON()))
}

// BetaResponseOutputTextAnnotationUnion contains all possible properties and
// values from [BetaResponseOutputTextAnnotationFileCitation],
// [BetaResponseOutputTextAnnotationURLCitation],
// [BetaResponseOutputTextAnnotationContainerFileCitation],
// [BetaResponseOutputTextAnnotationFilePath].
//
// Use the [BetaResponseOutputTextAnnotationUnion.AsAny] method to switch on the
// variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseOutputTextAnnotationUnion struct {
	FileID   string `json:"file_id"`
	Filename string `json:"filename"`
	Index    int64  `json:"index"`
	// Any of "file_citation", "url_citation", "container_file_citation", "file_path".
	Type       string `json:"type"`
	EndIndex   int64  `json:"end_index"`
	StartIndex int64  `json:"start_index"`
	// This field is from variant [BetaResponseOutputTextAnnotationURLCitation].
	Title string `json:"title"`
	// This field is from variant [BetaResponseOutputTextAnnotationURLCitation].
	URL string `json:"url"`
	// This field is from variant
	// [BetaResponseOutputTextAnnotationContainerFileCitation].
	ContainerID string `json:"container_id"`
	JSON        struct {
		FileID      respjson.Field
		Filename    respjson.Field
		Index       respjson.Field
		Type        respjson.Field
		EndIndex    respjson.Field
		StartIndex  respjson.Field
		Title       respjson.Field
		URL         respjson.Field
		ContainerID respjson.Field
		raw         string
	} `json:"-"`
}

// anyBetaResponseOutputTextAnnotation is implemented by each variant of
// [BetaResponseOutputTextAnnotationUnion] to add type safety for the return type
// of [BetaResponseOutputTextAnnotationUnion.AsAny]
type anyBetaResponseOutputTextAnnotation interface {
	implBetaResponseOutputTextAnnotationUnion()
}

func (BetaResponseOutputTextAnnotationFileCitation) implBetaResponseOutputTextAnnotationUnion() {}
func (BetaResponseOutputTextAnnotationURLCitation) implBetaResponseOutputTextAnnotationUnion()  {}
func (BetaResponseOutputTextAnnotationContainerFileCitation) implBetaResponseOutputTextAnnotationUnion() {
}
func (BetaResponseOutputTextAnnotationFilePath) implBetaResponseOutputTextAnnotationUnion() {}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseOutputTextAnnotationUnion.AsAny().(type) {
//	case openai.BetaResponseOutputTextAnnotationFileCitation:
//	case openai.BetaResponseOutputTextAnnotationURLCitation:
//	case openai.BetaResponseOutputTextAnnotationContainerFileCitation:
//	case openai.BetaResponseOutputTextAnnotationFilePath:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseOutputTextAnnotationUnion) AsAny() anyBetaResponseOutputTextAnnotation {
	switch u.Type {
	case "file_citation":
		return u.AsFileCitation()
	case "url_citation":
		return u.AsURLCitation()
	case "container_file_citation":
		return u.AsContainerFileCitation()
	case "file_path":
		return u.AsFilePath()
	}
	return nil
}

func (u BetaResponseOutputTextAnnotationUnion) AsFileCitation() (v BetaResponseOutputTextAnnotationFileCitation) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputTextAnnotationUnion) AsURLCitation() (v BetaResponseOutputTextAnnotationURLCitation) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputTextAnnotationUnion) AsContainerFileCitation() (v BetaResponseOutputTextAnnotationContainerFileCitation) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseOutputTextAnnotationUnion) AsFilePath() (v BetaResponseOutputTextAnnotationFilePath) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseOutputTextAnnotationUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseOutputTextAnnotationUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A citation to a file.
type BetaResponseOutputTextAnnotationFileCitation struct {
	// The ID of the file.
	FileID string `json:"file_id" api:"required"`
	// The filename of the file cited.
	Filename string `json:"filename" api:"required"`
	// The index of the file in the list of files.
	Index int64 `json:"index" api:"required"`
	// The type of the file citation. Always `file_citation`.
	Type constant.FileCitation `json:"type" default:"file_citation"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FileID      respjson.Field
		Filename    respjson.Field
		Index       respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputTextAnnotationFileCitation) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputTextAnnotationFileCitation) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A citation for a web resource used to generate a model response.
type BetaResponseOutputTextAnnotationURLCitation struct {
	// The index of the last character of the URL citation in the message.
	EndIndex int64 `json:"end_index" api:"required"`
	// The index of the first character of the URL citation in the message.
	StartIndex int64 `json:"start_index" api:"required"`
	// The title of the web resource.
	Title string `json:"title" api:"required"`
	// The type of the URL citation. Always `url_citation`.
	Type constant.URLCitation `json:"type" default:"url_citation"`
	// The URL of the web resource.
	URL string `json:"url" api:"required" format:"uri"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		EndIndex    respjson.Field
		StartIndex  respjson.Field
		Title       respjson.Field
		Type        respjson.Field
		URL         respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputTextAnnotationURLCitation) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputTextAnnotationURLCitation) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A citation for a container file used to generate a model response.
type BetaResponseOutputTextAnnotationContainerFileCitation struct {
	// The ID of the container file.
	ContainerID string `json:"container_id" api:"required"`
	// The index of the last character of the container file citation in the message.
	EndIndex int64 `json:"end_index" api:"required"`
	// The ID of the file.
	FileID string `json:"file_id" api:"required"`
	// The filename of the container file cited.
	Filename string `json:"filename" api:"required"`
	// The index of the first character of the container file citation in the message.
	StartIndex int64 `json:"start_index" api:"required"`
	// The type of the container file citation. Always `container_file_citation`.
	Type constant.ContainerFileCitation `json:"type" default:"container_file_citation"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ContainerID respjson.Field
		EndIndex    respjson.Field
		FileID      respjson.Field
		Filename    respjson.Field
		StartIndex  respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputTextAnnotationContainerFileCitation) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputTextAnnotationContainerFileCitation) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A path to a file.
type BetaResponseOutputTextAnnotationFilePath struct {
	// The ID of the file.
	FileID string `json:"file_id" api:"required"`
	// The index of the file in the list of files.
	Index int64 `json:"index" api:"required"`
	// The type of the file path. Always `file_path`.
	Type constant.FilePath `json:"type" default:"file_path"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FileID      respjson.Field
		Index       respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputTextAnnotationFilePath) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputTextAnnotationFilePath) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The log probability of a token.
type BetaResponseOutputTextLogprob struct {
	Token       string                                    `json:"token" api:"required"`
	Bytes       []int64                                   `json:"bytes" api:"required"`
	Logprob     float64                                   `json:"logprob" api:"required"`
	TopLogprobs []BetaResponseOutputTextLogprobTopLogprob `json:"top_logprobs" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Token       respjson.Field
		Bytes       respjson.Field
		Logprob     respjson.Field
		TopLogprobs respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputTextLogprob) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputTextLogprob) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The top log probability of a token.
type BetaResponseOutputTextLogprobTopLogprob struct {
	Token   string  `json:"token" api:"required"`
	Bytes   []int64 `json:"bytes" api:"required"`
	Logprob float64 `json:"logprob" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Token       respjson.Field
		Bytes       respjson.Field
		Logprob     respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputTextLogprobTopLogprob) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputTextLogprobTopLogprob) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A text output from the model.
//
// The properties Annotations, Text, Type are required.
type BetaResponseOutputTextParam struct {
	// The annotations of the text output.
	Annotations []BetaResponseOutputTextAnnotationUnionParam `json:"annotations,omitzero" api:"required"`
	// The text output from the model.
	Text     string                               `json:"text" api:"required"`
	Logprobs []BetaResponseOutputTextLogprobParam `json:"logprobs,omitzero"`
	// The type of the output text. Always `output_text`.
	//
	// This field can be elided, and will marshal its zero value as "output_text".
	Type constant.OutputText `json:"type" default:"output_text"`
	paramObj
}

func (r BetaResponseOutputTextParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseOutputTextParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseOutputTextParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseOutputTextAnnotationUnionParam struct {
	OfFileCitation          *BetaResponseOutputTextAnnotationFileCitationParam          `json:",omitzero,inline"`
	OfURLCitation           *BetaResponseOutputTextAnnotationURLCitationParam           `json:",omitzero,inline"`
	OfContainerFileCitation *BetaResponseOutputTextAnnotationContainerFileCitationParam `json:",omitzero,inline"`
	OfFilePath              *BetaResponseOutputTextAnnotationFilePathParam              `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseOutputTextAnnotationUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfFileCitation, u.OfURLCitation, u.OfContainerFileCitation, u.OfFilePath)
}
func (u *BetaResponseOutputTextAnnotationUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseOutputTextAnnotationUnionParam) asAny() any {
	if !param.IsOmitted(u.OfFileCitation) {
		return u.OfFileCitation
	} else if !param.IsOmitted(u.OfURLCitation) {
		return u.OfURLCitation
	} else if !param.IsOmitted(u.OfContainerFileCitation) {
		return u.OfContainerFileCitation
	} else if !param.IsOmitted(u.OfFilePath) {
		return u.OfFilePath
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseOutputTextAnnotationUnionParam) GetTitle() *string {
	if vt := u.OfURLCitation; vt != nil {
		return &vt.Title
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseOutputTextAnnotationUnionParam) GetURL() *string {
	if vt := u.OfURLCitation; vt != nil {
		return &vt.URL
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseOutputTextAnnotationUnionParam) GetContainerID() *string {
	if vt := u.OfContainerFileCitation; vt != nil {
		return &vt.ContainerID
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseOutputTextAnnotationUnionParam) GetFileID() *string {
	if vt := u.OfFileCitation; vt != nil {
		return (*string)(&vt.FileID)
	} else if vt := u.OfContainerFileCitation; vt != nil {
		return (*string)(&vt.FileID)
	} else if vt := u.OfFilePath; vt != nil {
		return (*string)(&vt.FileID)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseOutputTextAnnotationUnionParam) GetFilename() *string {
	if vt := u.OfFileCitation; vt != nil {
		return (*string)(&vt.Filename)
	} else if vt := u.OfContainerFileCitation; vt != nil {
		return (*string)(&vt.Filename)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseOutputTextAnnotationUnionParam) GetIndex() *int64 {
	if vt := u.OfFileCitation; vt != nil {
		return (*int64)(&vt.Index)
	} else if vt := u.OfFilePath; vt != nil {
		return (*int64)(&vt.Index)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseOutputTextAnnotationUnionParam) GetType() *string {
	if vt := u.OfFileCitation; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfURLCitation; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfContainerFileCitation; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfFilePath; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseOutputTextAnnotationUnionParam) GetEndIndex() *int64 {
	if vt := u.OfURLCitation; vt != nil {
		return (*int64)(&vt.EndIndex)
	} else if vt := u.OfContainerFileCitation; vt != nil {
		return (*int64)(&vt.EndIndex)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseOutputTextAnnotationUnionParam) GetStartIndex() *int64 {
	if vt := u.OfURLCitation; vt != nil {
		return (*int64)(&vt.StartIndex)
	} else if vt := u.OfContainerFileCitation; vt != nil {
		return (*int64)(&vt.StartIndex)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaResponseOutputTextAnnotationUnionParam](
		"type",
		apijson.Discriminator[BetaResponseOutputTextAnnotationFileCitationParam]("file_citation"),
		apijson.Discriminator[BetaResponseOutputTextAnnotationURLCitationParam]("url_citation"),
		apijson.Discriminator[BetaResponseOutputTextAnnotationContainerFileCitationParam]("container_file_citation"),
		apijson.Discriminator[BetaResponseOutputTextAnnotationFilePathParam]("file_path"),
	)
}

// A citation to a file.
//
// The properties FileID, Filename, Index, Type are required.
type BetaResponseOutputTextAnnotationFileCitationParam struct {
	// The ID of the file.
	FileID string `json:"file_id" api:"required"`
	// The filename of the file cited.
	Filename string `json:"filename" api:"required"`
	// The index of the file in the list of files.
	Index int64 `json:"index" api:"required"`
	// The type of the file citation. Always `file_citation`.
	//
	// This field can be elided, and will marshal its zero value as "file_citation".
	Type constant.FileCitation `json:"type" default:"file_citation"`
	paramObj
}

func (r BetaResponseOutputTextAnnotationFileCitationParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseOutputTextAnnotationFileCitationParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseOutputTextAnnotationFileCitationParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A citation for a web resource used to generate a model response.
//
// The properties EndIndex, StartIndex, Title, Type, URL are required.
type BetaResponseOutputTextAnnotationURLCitationParam struct {
	// The index of the last character of the URL citation in the message.
	EndIndex int64 `json:"end_index" api:"required"`
	// The index of the first character of the URL citation in the message.
	StartIndex int64 `json:"start_index" api:"required"`
	// The title of the web resource.
	Title string `json:"title" api:"required"`
	// The URL of the web resource.
	URL string `json:"url" api:"required" format:"uri"`
	// The type of the URL citation. Always `url_citation`.
	//
	// This field can be elided, and will marshal its zero value as "url_citation".
	Type constant.URLCitation `json:"type" default:"url_citation"`
	paramObj
}

func (r BetaResponseOutputTextAnnotationURLCitationParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseOutputTextAnnotationURLCitationParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseOutputTextAnnotationURLCitationParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A citation for a container file used to generate a model response.
//
// The properties ContainerID, EndIndex, FileID, Filename, StartIndex, Type are
// required.
type BetaResponseOutputTextAnnotationContainerFileCitationParam struct {
	// The ID of the container file.
	ContainerID string `json:"container_id" api:"required"`
	// The index of the last character of the container file citation in the message.
	EndIndex int64 `json:"end_index" api:"required"`
	// The ID of the file.
	FileID string `json:"file_id" api:"required"`
	// The filename of the container file cited.
	Filename string `json:"filename" api:"required"`
	// The index of the first character of the container file citation in the message.
	StartIndex int64 `json:"start_index" api:"required"`
	// The type of the container file citation. Always `container_file_citation`.
	//
	// This field can be elided, and will marshal its zero value as
	// "container_file_citation".
	Type constant.ContainerFileCitation `json:"type" default:"container_file_citation"`
	paramObj
}

func (r BetaResponseOutputTextAnnotationContainerFileCitationParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseOutputTextAnnotationContainerFileCitationParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseOutputTextAnnotationContainerFileCitationParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A path to a file.
//
// The properties FileID, Index, Type are required.
type BetaResponseOutputTextAnnotationFilePathParam struct {
	// The ID of the file.
	FileID string `json:"file_id" api:"required"`
	// The index of the file in the list of files.
	Index int64 `json:"index" api:"required"`
	// The type of the file path. Always `file_path`.
	//
	// This field can be elided, and will marshal its zero value as "file_path".
	Type constant.FilePath `json:"type" default:"file_path"`
	paramObj
}

func (r BetaResponseOutputTextAnnotationFilePathParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseOutputTextAnnotationFilePathParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseOutputTextAnnotationFilePathParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The log probability of a token.
//
// The properties Token, Bytes, Logprob, TopLogprobs are required.
type BetaResponseOutputTextLogprobParam struct {
	Token       string                                         `json:"token" api:"required"`
	Bytes       []int64                                        `json:"bytes,omitzero" api:"required"`
	Logprob     float64                                        `json:"logprob" api:"required"`
	TopLogprobs []BetaResponseOutputTextLogprobTopLogprobParam `json:"top_logprobs,omitzero" api:"required"`
	paramObj
}

func (r BetaResponseOutputTextLogprobParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseOutputTextLogprobParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseOutputTextLogprobParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The top log probability of a token.
//
// The properties Token, Bytes, Logprob are required.
type BetaResponseOutputTextLogprobTopLogprobParam struct {
	Token   string  `json:"token" api:"required"`
	Bytes   []int64 `json:"bytes,omitzero" api:"required"`
	Logprob float64 `json:"logprob" api:"required"`
	paramObj
}

func (r BetaResponseOutputTextLogprobTopLogprobParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseOutputTextLogprobTopLogprobParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseOutputTextLogprobTopLogprobParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when an annotation is added to output text content.
type BetaResponseOutputTextAnnotationAddedEvent struct {
	// The annotation object being added. (See annotation schema for details.)
	Annotation any `json:"annotation" api:"required"`
	// The index of the annotation within the content part.
	AnnotationIndex int64 `json:"annotation_index" api:"required"`
	// The index of the content part within the output item.
	ContentIndex int64 `json:"content_index" api:"required"`
	// The unique identifier of the item to which the annotation is being added.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item in the response's output array.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always 'response.output_text.annotation.added'.
	Type constant.ResponseOutputTextAnnotationAdded `json:"type" default:"response.output_text.annotation.added"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseOutputTextAnnotationAddedEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Annotation      respjson.Field
		AnnotationIndex respjson.Field
		ContentIndex    respjson.Field
		ItemID          respjson.Field
		OutputIndex     respjson.Field
		SequenceNumber  respjson.Field
		Type            respjson.Field
		Agent           respjson.Field
		ExtraFields     map[string]respjson.Field
		raw             string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputTextAnnotationAddedEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputTextAnnotationAddedEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseOutputTextAnnotationAddedEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseOutputTextAnnotationAddedEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseOutputTextAnnotationAddedEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Reference to a prompt template and its variables.
// [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
type BetaResponsePrompt struct {
	// The unique identifier of the prompt template to use.
	ID string `json:"id" api:"required"`
	// Optional map of values to substitute in for variables in your prompt. The
	// substitution values can either be strings, or other Response input types like
	// images or files.
	Variables map[string]BetaResponsePromptVariableUnion `json:"variables" api:"nullable"`
	// Optional version of the prompt template.
	Version string `json:"version" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Variables   respjson.Field
		Version     respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponsePrompt) RawJSON() string { return r.JSON.raw }
func (r *BetaResponsePrompt) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponsePrompt to a BetaResponsePromptParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponsePromptParam.Overrides()
func (r BetaResponsePrompt) ToParam() BetaResponsePromptParam {
	return param.Override[BetaResponsePromptParam](json.RawMessage(r.RawJSON()))
}

// BetaResponsePromptVariableUnion contains all possible properties and values from
// [string], [BetaResponseInputText], [BetaResponseInputImage],
// [BetaResponseInputFile].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfString]
type BetaResponsePromptVariableUnion struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field is from variant [BetaResponseInputText].
	Text string `json:"text"`
	Type string `json:"type"`
	// This field is a union of [BetaResponseInputTextPromptCacheBreakpoint],
	// [BetaResponseInputImagePromptCacheBreakpoint],
	// [BetaResponseInputFilePromptCacheBreakpoint]
	PromptCacheBreakpoint BetaResponsePromptVariableUnionPromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
	Detail                string                                               `json:"detail"`
	FileID                string                                               `json:"file_id"`
	// This field is from variant [BetaResponseInputImage].
	ImageURL string `json:"image_url"`
	// This field is from variant [BetaResponseInputFile].
	FileData string `json:"file_data"`
	// This field is from variant [BetaResponseInputFile].
	FileURL string `json:"file_url"`
	// This field is from variant [BetaResponseInputFile].
	Filename string `json:"filename"`
	JSON     struct {
		OfString              respjson.Field
		Text                  respjson.Field
		Type                  respjson.Field
		PromptCacheBreakpoint respjson.Field
		Detail                respjson.Field
		FileID                respjson.Field
		ImageURL              respjson.Field
		FileData              respjson.Field
		FileURL               respjson.Field
		Filename              respjson.Field
		raw                   string
	} `json:"-"`
}

func (u BetaResponsePromptVariableUnion) AsString() (v string) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponsePromptVariableUnion) AsInputText() (v BetaResponseInputText) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponsePromptVariableUnion) AsInputImage() (v BetaResponseInputImage) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponsePromptVariableUnion) AsInputFile() (v BetaResponseInputFile) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponsePromptVariableUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponsePromptVariableUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponsePromptVariableUnionPromptCacheBreakpoint is an implicit subunion of
// [BetaResponsePromptVariableUnion].
// BetaResponsePromptVariableUnionPromptCacheBreakpoint provides convenient access
// to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponsePromptVariableUnion].
type BetaResponsePromptVariableUnionPromptCacheBreakpoint struct {
	// This field is from variant [BetaResponseInputTextPromptCacheBreakpoint].
	Mode constant.Explicit `json:"mode"`
	JSON struct {
		Mode respjson.Field
		raw  string
	} `json:"-"`
}

func (r *BetaResponsePromptVariableUnionPromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Reference to a prompt template and its variables.
// [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
//
// The property ID is required.
type BetaResponsePromptParam struct {
	// The unique identifier of the prompt template to use.
	ID string `json:"id" api:"required"`
	// Optional version of the prompt template.
	Version param.Opt[string] `json:"version,omitzero"`
	// Optional map of values to substitute in for variables in your prompt. The
	// substitution values can either be strings, or other Response input types like
	// images or files.
	Variables map[string]BetaResponsePromptVariableUnionParam `json:"variables,omitzero"`
	paramObj
}

func (r BetaResponsePromptParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponsePromptParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponsePromptParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponsePromptVariableUnionParam struct {
	OfString     param.Opt[string]            `json:",omitzero,inline"`
	OfInputText  *BetaResponseInputTextParam  `json:",omitzero,inline"`
	OfInputImage *BetaResponseInputImageParam `json:",omitzero,inline"`
	OfInputFile  *BetaResponseInputFileParam  `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponsePromptVariableUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfString, u.OfInputText, u.OfInputImage, u.OfInputFile)
}
func (u *BetaResponsePromptVariableUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponsePromptVariableUnionParam) asAny() any {
	if !param.IsOmitted(u.OfString) {
		return &u.OfString.Value
	} else if !param.IsOmitted(u.OfInputText) {
		return u.OfInputText
	} else if !param.IsOmitted(u.OfInputImage) {
		return u.OfInputImage
	} else if !param.IsOmitted(u.OfInputFile) {
		return u.OfInputFile
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponsePromptVariableUnionParam) GetText() *string {
	if vt := u.OfInputText; vt != nil {
		return &vt.Text
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponsePromptVariableUnionParam) GetImageURL() *string {
	if vt := u.OfInputImage; vt != nil && vt.ImageURL.Valid() {
		return &vt.ImageURL.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponsePromptVariableUnionParam) GetFileData() *string {
	if vt := u.OfInputFile; vt != nil && vt.FileData.Valid() {
		return &vt.FileData.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponsePromptVariableUnionParam) GetFileURL() *string {
	if vt := u.OfInputFile; vt != nil && vt.FileURL.Valid() {
		return &vt.FileURL.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponsePromptVariableUnionParam) GetFilename() *string {
	if vt := u.OfInputFile; vt != nil && vt.Filename.Valid() {
		return &vt.Filename.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponsePromptVariableUnionParam) GetType() *string {
	if vt := u.OfInputText; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfInputImage; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfInputFile; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponsePromptVariableUnionParam) GetDetail() *string {
	if vt := u.OfInputImage; vt != nil {
		return (*string)(&vt.Detail)
	} else if vt := u.OfInputFile; vt != nil {
		return (*string)(&vt.Detail)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponsePromptVariableUnionParam) GetFileID() *string {
	if vt := u.OfInputImage; vt != nil && vt.FileID.Valid() {
		return &vt.FileID.Value
	} else if vt := u.OfInputFile; vt != nil && vt.FileID.Valid() {
		return &vt.FileID.Value
	}
	return nil
}

// Returns a subunion which exports methods to access subproperties
//
// Or use AsAny() to get the underlying value
func (u BetaResponsePromptVariableUnionParam) GetPromptCacheBreakpoint() (res betaResponsePromptVariableUnionParamPromptCacheBreakpoint) {
	if vt := u.OfInputText; vt != nil {
		res.any = &vt.PromptCacheBreakpoint
	} else if vt := u.OfInputImage; vt != nil {
		res.any = &vt.PromptCacheBreakpoint
	} else if vt := u.OfInputFile; vt != nil {
		res.any = &vt.PromptCacheBreakpoint
	}
	return
}

// Can have the runtime types [*BetaResponseInputTextPromptCacheBreakpointParam],
// [*BetaResponseInputImagePromptCacheBreakpointParam],
// [*BetaResponseInputFilePromptCacheBreakpointParam]
type betaResponsePromptVariableUnionParamPromptCacheBreakpoint struct{ any }

// Use the following switch statement to get the type of the union:
//
//	switch u.AsAny().(type) {
//	case *openai.BetaResponseInputTextPromptCacheBreakpointParam:
//	case *openai.BetaResponseInputImagePromptCacheBreakpointParam:
//	case *openai.BetaResponseInputFilePromptCacheBreakpointParam:
//	default:
//	    fmt.Errorf("not present")
//	}
func (u betaResponsePromptVariableUnionParamPromptCacheBreakpoint) AsAny() any { return u.any }

// Returns a pointer to the underlying variant's property, if present.
func (u betaResponsePromptVariableUnionParamPromptCacheBreakpoint) GetMode() *string {
	switch vt := u.any.(type) {
	case *BetaResponseInputTextPromptCacheBreakpointParam:
		return (*string)(&vt.Mode)
	case *BetaResponseInputImagePromptCacheBreakpointParam:
		return (*string)(&vt.Mode)
	case *BetaResponseInputFilePromptCacheBreakpointParam:
		return (*string)(&vt.Mode)
	}
	return nil
}

// Emitted when a response is queued and waiting to be processed.
type BetaResponseQueuedEvent struct {
	// The full response object that is queued.
	Response BetaResponse `json:"response" api:"required"`
	// The sequence number for this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always 'response.queued'.
	Type constant.ResponseQueued `json:"type" default:"response.queued"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseQueuedEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Response       respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseQueuedEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseQueuedEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseQueuedEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseQueuedEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseQueuedEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A description of the chain of thought used by a reasoning model while generating
// a response. Be sure to include these items in your `input` to the Responses API
// for subsequent turns of a conversation if you are manually
// [managing context](https://platform.openai.com/docs/guides/conversation-state).
type BetaResponseReasoningItem struct {
	// The unique identifier of the reasoning content.
	ID string `json:"id" api:"required"`
	// Reasoning summary content.
	Summary []BetaResponseReasoningItemSummary `json:"summary" api:"required"`
	// The type of the object. Always `reasoning`.
	Type constant.Reasoning `json:"type" default:"reasoning"`
	// The agent that produced this item.
	Agent BetaResponseReasoningItemAgent `json:"agent" api:"nullable"`
	// Reasoning text content.
	Content []BetaResponseReasoningItemContent `json:"content"`
	// The encrypted content of the reasoning item. This is populated by default for
	// reasoning items returned by `POST /v1/responses` and WebSocket `response.create`
	// requests.
	EncryptedContent string `json:"encrypted_content" api:"nullable"`
	// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
	// Populated when items are returned via API.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status BetaResponseReasoningItemStatus `json:"status"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID               respjson.Field
		Summary          respjson.Field
		Type             respjson.Field
		Agent            respjson.Field
		Content          respjson.Field
		EncryptedContent respjson.Field
		Status           respjson.Field
		ExtraFields      map[string]respjson.Field
		raw              string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseReasoningItem) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseReasoningItem) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseReasoningItem to a
// BetaResponseReasoningItemParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseReasoningItemParam.Overrides()
func (r BetaResponseReasoningItem) ToParam() BetaResponseReasoningItemParam {
	return param.Override[BetaResponseReasoningItemParam](json.RawMessage(r.RawJSON()))
}

// A summary text from the model.
type BetaResponseReasoningItemSummary struct {
	// A summary of the reasoning output from the model so far.
	Text string `json:"text" api:"required"`
	// The type of the object. Always `summary_text`.
	Type constant.SummaryText `json:"type" default:"summary_text"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseReasoningItemSummary) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseReasoningItemSummary) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
type BetaResponseReasoningItemAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseReasoningItemAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseReasoningItemAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Reasoning text from the model.
type BetaResponseReasoningItemContent struct {
	// The reasoning text from the model.
	Text string `json:"text" api:"required"`
	// The type of the reasoning text. Always `reasoning_text`.
	Type constant.ReasoningText `json:"type" default:"reasoning_text"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseReasoningItemContent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseReasoningItemContent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
// Populated when items are returned via API.
type BetaResponseReasoningItemStatus string

const (
	BetaResponseReasoningItemStatusInProgress BetaResponseReasoningItemStatus = "in_progress"
	BetaResponseReasoningItemStatusCompleted  BetaResponseReasoningItemStatus = "completed"
	BetaResponseReasoningItemStatusIncomplete BetaResponseReasoningItemStatus = "incomplete"
)

// A description of the chain of thought used by a reasoning model while generating
// a response. Be sure to include these items in your `input` to the Responses API
// for subsequent turns of a conversation if you are manually
// [managing context](https://platform.openai.com/docs/guides/conversation-state).
//
// The properties ID, Summary, Type are required.
type BetaResponseReasoningItemParam struct {
	// The unique identifier of the reasoning content.
	ID string `json:"id" api:"required"`
	// Reasoning summary content.
	Summary []BetaResponseReasoningItemSummaryParam `json:"summary,omitzero" api:"required"`
	// The encrypted content of the reasoning item. This is populated by default for
	// reasoning items returned by `POST /v1/responses` and WebSocket `response.create`
	// requests.
	EncryptedContent param.Opt[string] `json:"encrypted_content,omitzero"`
	// The agent that produced this item.
	Agent BetaResponseReasoningItemAgentParam `json:"agent,omitzero"`
	// Reasoning text content.
	Content []BetaResponseReasoningItemContentParam `json:"content,omitzero"`
	// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
	// Populated when items are returned via API.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status BetaResponseReasoningItemStatus `json:"status,omitzero"`
	// The type of the object. Always `reasoning`.
	//
	// This field can be elided, and will marshal its zero value as "reasoning".
	Type constant.Reasoning `json:"type" default:"reasoning"`
	paramObj
}

func (r BetaResponseReasoningItemParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseReasoningItemParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseReasoningItemParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A summary text from the model.
//
// The properties Text, Type are required.
type BetaResponseReasoningItemSummaryParam struct {
	// A summary of the reasoning output from the model so far.
	Text string `json:"text" api:"required"`
	// The type of the object. Always `summary_text`.
	//
	// This field can be elided, and will marshal its zero value as "summary_text".
	Type constant.SummaryText `json:"type" default:"summary_text"`
	paramObj
}

func (r BetaResponseReasoningItemSummaryParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseReasoningItemSummaryParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseReasoningItemSummaryParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseReasoningItemAgentParam struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseReasoningItemAgentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseReasoningItemAgentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseReasoningItemAgentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Reasoning text from the model.
//
// The properties Text, Type are required.
type BetaResponseReasoningItemContentParam struct {
	// The reasoning text from the model.
	Text string `json:"text" api:"required"`
	// The type of the reasoning text. Always `reasoning_text`.
	//
	// This field can be elided, and will marshal its zero value as "reasoning_text".
	Type constant.ReasoningText `json:"type" default:"reasoning_text"`
	paramObj
}

func (r BetaResponseReasoningItemContentParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseReasoningItemContentParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseReasoningItemContentParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when a new reasoning summary part is added.
type BetaResponseReasoningSummaryPartAddedEvent struct {
	// The ID of the item this summary part is associated with.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item this summary part is associated with.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The summary part that was added.
	Part BetaResponseReasoningSummaryPartAddedEventPart `json:"part" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The index of the summary part within the reasoning summary.
	SummaryIndex int64 `json:"summary_index" api:"required"`
	// The type of the event. Always `response.reasoning_summary_part.added`.
	Type constant.ResponseReasoningSummaryPartAdded `json:"type" default:"response.reasoning_summary_part.added"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseReasoningSummaryPartAddedEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		Part           respjson.Field
		SequenceNumber respjson.Field
		SummaryIndex   respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseReasoningSummaryPartAddedEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseReasoningSummaryPartAddedEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The summary part that was added.
type BetaResponseReasoningSummaryPartAddedEventPart struct {
	// The text of the summary part.
	Text string `json:"text" api:"required"`
	// The type of the summary part. Always `summary_text`.
	Type constant.SummaryText `json:"type" default:"summary_text"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseReasoningSummaryPartAddedEventPart) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseReasoningSummaryPartAddedEventPart) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseReasoningSummaryPartAddedEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseReasoningSummaryPartAddedEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseReasoningSummaryPartAddedEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when a reasoning summary part is completed.
type BetaResponseReasoningSummaryPartDoneEvent struct {
	// The ID of the item this summary part is associated with.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item this summary part is associated with.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The completed summary part.
	Part BetaResponseReasoningSummaryPartDoneEventPart `json:"part" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The index of the summary part within the reasoning summary.
	SummaryIndex int64 `json:"summary_index" api:"required"`
	// The type of the event. Always `response.reasoning_summary_part.done`.
	Type constant.ResponseReasoningSummaryPartDone `json:"type" default:"response.reasoning_summary_part.done"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseReasoningSummaryPartDoneEventAgent `json:"agent" api:"nullable"`
	// The completion status of the summary part. Omitted when the part completed
	// normally and set to `incomplete` when generation was interrupted.
	//
	// Any of "incomplete".
	Status BetaResponseReasoningSummaryPartDoneEventStatus `json:"status"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		Part           respjson.Field
		SequenceNumber respjson.Field
		SummaryIndex   respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		Status         respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseReasoningSummaryPartDoneEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseReasoningSummaryPartDoneEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The completed summary part.
type BetaResponseReasoningSummaryPartDoneEventPart struct {
	// The text of the summary part.
	Text string `json:"text" api:"required"`
	// The type of the summary part. Always `summary_text`.
	Type constant.SummaryText `json:"type" default:"summary_text"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseReasoningSummaryPartDoneEventPart) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseReasoningSummaryPartDoneEventPart) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseReasoningSummaryPartDoneEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseReasoningSummaryPartDoneEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseReasoningSummaryPartDoneEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The completion status of the summary part. Omitted when the part completed
// normally and set to `incomplete` when generation was interrupted.
type BetaResponseReasoningSummaryPartDoneEventStatus string

const (
	BetaResponseReasoningSummaryPartDoneEventStatusIncomplete BetaResponseReasoningSummaryPartDoneEventStatus = "incomplete"
)

// Emitted when a delta is added to a reasoning summary text.
type BetaResponseReasoningSummaryTextDeltaEvent struct {
	// The text delta that was added to the summary.
	Delta string `json:"delta" api:"required"`
	// The ID of the item this summary text delta is associated with.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item this summary text delta is associated with.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The index of the summary part within the reasoning summary.
	SummaryIndex int64 `json:"summary_index" api:"required"`
	// The type of the event. Always `response.reasoning_summary_text.delta`.
	Type constant.ResponseReasoningSummaryTextDelta `json:"type" default:"response.reasoning_summary_text.delta"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseReasoningSummaryTextDeltaEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Delta          respjson.Field
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		SummaryIndex   respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseReasoningSummaryTextDeltaEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseReasoningSummaryTextDeltaEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseReasoningSummaryTextDeltaEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseReasoningSummaryTextDeltaEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseReasoningSummaryTextDeltaEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when a reasoning summary text is completed.
type BetaResponseReasoningSummaryTextDoneEvent struct {
	// The ID of the item this summary text is associated with.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item this summary text is associated with.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The index of the summary part within the reasoning summary.
	SummaryIndex int64 `json:"summary_index" api:"required"`
	// The full text of the completed reasoning summary.
	Text string `json:"text" api:"required"`
	// The type of the event. Always `response.reasoning_summary_text.done`.
	Type constant.ResponseReasoningSummaryTextDone `json:"type" default:"response.reasoning_summary_text.done"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseReasoningSummaryTextDoneEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		SummaryIndex   respjson.Field
		Text           respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseReasoningSummaryTextDoneEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseReasoningSummaryTextDoneEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseReasoningSummaryTextDoneEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseReasoningSummaryTextDoneEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseReasoningSummaryTextDoneEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when a delta is added to a reasoning text.
type BetaResponseReasoningTextDeltaEvent struct {
	// The index of the reasoning content part this delta is associated with.
	ContentIndex int64 `json:"content_index" api:"required"`
	// The text delta that was added to the reasoning content.
	Delta string `json:"delta" api:"required"`
	// The ID of the item this reasoning text delta is associated with.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item this reasoning text delta is associated with.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.reasoning_text.delta`.
	Type constant.ResponseReasoningTextDelta `json:"type" default:"response.reasoning_text.delta"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseReasoningTextDeltaEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ContentIndex   respjson.Field
		Delta          respjson.Field
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseReasoningTextDeltaEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseReasoningTextDeltaEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseReasoningTextDeltaEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseReasoningTextDeltaEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseReasoningTextDeltaEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when a reasoning text is completed.
type BetaResponseReasoningTextDoneEvent struct {
	// The index of the reasoning content part.
	ContentIndex int64 `json:"content_index" api:"required"`
	// The ID of the item this reasoning text is associated with.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item this reasoning text is associated with.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The full text of the completed reasoning content.
	Text string `json:"text" api:"required"`
	// The type of the event. Always `response.reasoning_text.done`.
	Type constant.ResponseReasoningTextDone `json:"type" default:"response.reasoning_text.done"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseReasoningTextDoneEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ContentIndex   respjson.Field
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Text           respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseReasoningTextDoneEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseReasoningTextDoneEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseReasoningTextDoneEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseReasoningTextDoneEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseReasoningTextDoneEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when there is a partial refusal text.
type BetaResponseRefusalDeltaEvent struct {
	// The index of the content part that the refusal text is added to.
	ContentIndex int64 `json:"content_index" api:"required"`
	// The refusal text that is added.
	Delta string `json:"delta" api:"required"`
	// The ID of the output item that the refusal text is added to.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item that the refusal text is added to.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.refusal.delta`.
	Type constant.ResponseRefusalDelta `json:"type" default:"response.refusal.delta"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseRefusalDeltaEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ContentIndex   respjson.Field
		Delta          respjson.Field
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseRefusalDeltaEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseRefusalDeltaEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseRefusalDeltaEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseRefusalDeltaEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseRefusalDeltaEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when refusal text is finalized.
type BetaResponseRefusalDoneEvent struct {
	// The index of the content part that the refusal text is finalized.
	ContentIndex int64 `json:"content_index" api:"required"`
	// The ID of the output item that the refusal text is finalized.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item that the refusal text is finalized.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The refusal text that is finalized.
	Refusal string `json:"refusal" api:"required"`
	// The sequence number of this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.refusal.done`.
	Type constant.ResponseRefusalDone `json:"type" default:"response.refusal.done"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseRefusalDoneEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ContentIndex   respjson.Field
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		Refusal        respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseRefusalDoneEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseRefusalDoneEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseRefusalDoneEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseRefusalDoneEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseRefusalDoneEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The status of the response generation. One of `completed`, `failed`,
// `in_progress`, `cancelled`, `queued`, or `incomplete`.
type BetaResponseStatus string

const (
	BetaResponseStatusCompleted  BetaResponseStatus = "completed"
	BetaResponseStatusFailed     BetaResponseStatus = "failed"
	BetaResponseStatusInProgress BetaResponseStatus = "in_progress"
	BetaResponseStatusCancelled  BetaResponseStatus = "cancelled"
	BetaResponseStatusQueued     BetaResponseStatus = "queued"
	BetaResponseStatusIncomplete BetaResponseStatus = "incomplete"
)

// BetaResponseStreamEventUnion contains all possible properties and values from
// [BetaResponseAudioDeltaEvent], [BetaResponseAudioDoneEvent],
// [BetaResponseAudioTranscriptDeltaEvent], [BetaResponseAudioTranscriptDoneEvent],
// [BetaResponseCodeInterpreterCallCodeDeltaEvent],
// [BetaResponseCodeInterpreterCallCodeDoneEvent],
// [BetaResponseCodeInterpreterCallCompletedEvent],
// [BetaResponseCodeInterpreterCallInProgressEvent],
// [BetaResponseCodeInterpreterCallInterpretingEvent],
// [BetaResponseCompletedEvent], [BetaResponseContentPartAddedEvent],
// [BetaResponseContentPartDoneEvent], [BetaResponseCreatedEvent],
// [BetaResponseErrorEvent], [BetaResponseFileSearchCallCompletedEvent],
// [BetaResponseFileSearchCallInProgressEvent],
// [BetaResponseFileSearchCallSearchingEvent],
// [BetaResponseFunctionCallArgumentsDeltaEvent],
// [BetaResponseFunctionCallArgumentsDoneEvent], [BetaResponseInProgressEvent],
// [BetaResponseFailedEvent], [BetaResponseIncompleteEvent],
// [BetaResponseOutputItemAddedEvent], [BetaResponseOutputItemDoneEvent],
// [BetaResponseReasoningSummaryPartAddedEvent],
// [BetaResponseReasoningSummaryPartDoneEvent],
// [BetaResponseReasoningSummaryTextDeltaEvent],
// [BetaResponseReasoningSummaryTextDoneEvent],
// [BetaResponseReasoningTextDeltaEvent], [BetaResponseReasoningTextDoneEvent],
// [BetaResponseRefusalDeltaEvent], [BetaResponseRefusalDoneEvent],
// [BetaResponseTextDeltaEvent], [BetaResponseTextDoneEvent],
// [BetaResponseWebSearchCallCompletedEvent],
// [BetaResponseWebSearchCallInProgressEvent],
// [BetaResponseWebSearchCallSearchingEvent],
// [BetaResponseImageGenCallCompletedEvent],
// [BetaResponseImageGenCallGeneratingEvent],
// [BetaResponseImageGenCallInProgressEvent],
// [BetaResponseImageGenCallPartialImageEvent],
// [BetaResponseMcpCallArgumentsDeltaEvent],
// [BetaResponseMcpCallArgumentsDoneEvent], [BetaResponseMcpCallCompletedEvent],
// [BetaResponseMcpCallFailedEvent], [BetaResponseMcpCallInProgressEvent],
// [BetaResponseMcpListToolsCompletedEvent], [BetaResponseMcpListToolsFailedEvent],
// [BetaResponseMcpListToolsInProgressEvent],
// [BetaResponseOutputTextAnnotationAddedEvent], [BetaResponseQueuedEvent],
// [BetaResponseCustomToolCallInputDeltaEvent],
// [BetaResponseCustomToolCallInputDoneEvent].
//
// Use the [BetaResponseStreamEventUnion.AsAny] method to switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaResponseStreamEventUnion struct {
	Delta          string `json:"delta"`
	SequenceNumber int64  `json:"sequence_number"`
	// Any of "response.audio.delta", "response.audio.done",
	// "response.audio.transcript.delta", "response.audio.transcript.done",
	// "response.code_interpreter_call_code.delta",
	// "response.code_interpreter_call_code.done",
	// "response.code_interpreter_call.completed",
	// "response.code_interpreter_call.in_progress",
	// "response.code_interpreter_call.interpreting", "response.completed",
	// "response.content_part.added", "response.content_part.done", "response.created",
	// "error", "response.file_search_call.completed",
	// "response.file_search_call.in_progress", "response.file_search_call.searching",
	// "response.function_call_arguments.delta",
	// "response.function_call_arguments.done", "response.in_progress",
	// "response.failed", "response.incomplete", "response.output_item.added",
	// "response.output_item.done", "response.reasoning_summary_part.added",
	// "response.reasoning_summary_part.done", "response.reasoning_summary_text.delta",
	// "response.reasoning_summary_text.done", "response.reasoning_text.delta",
	// "response.reasoning_text.done", "response.refusal.delta",
	// "response.refusal.done", "response.output_text.delta",
	// "response.output_text.done", "response.web_search_call.completed",
	// "response.web_search_call.in_progress", "response.web_search_call.searching",
	// "response.image_generation_call.completed",
	// "response.image_generation_call.generating",
	// "response.image_generation_call.in_progress",
	// "response.image_generation_call.partial_image",
	// "response.mcp_call_arguments.delta", "response.mcp_call_arguments.done",
	// "response.mcp_call.completed", "response.mcp_call.failed",
	// "response.mcp_call.in_progress", "response.mcp_list_tools.completed",
	// "response.mcp_list_tools.failed", "response.mcp_list_tools.in_progress",
	// "response.output_text.annotation.added", "response.queued",
	// "response.custom_tool_call_input.delta", "response.custom_tool_call_input.done".
	Type string `json:"type"`
	// This field is a union of [BetaResponseAudioDeltaEventAgent],
	// [BetaResponseAudioDoneEventAgent], [BetaResponseAudioTranscriptDeltaEventAgent],
	// [BetaResponseAudioTranscriptDoneEventAgent],
	// [BetaResponseCodeInterpreterCallCodeDeltaEventAgent],
	// [BetaResponseCodeInterpreterCallCodeDoneEventAgent],
	// [BetaResponseCodeInterpreterCallCompletedEventAgent],
	// [BetaResponseCodeInterpreterCallInProgressEventAgent],
	// [BetaResponseCodeInterpreterCallInterpretingEventAgent],
	// [BetaResponseCompletedEventAgent], [BetaResponseContentPartAddedEventAgent],
	// [BetaResponseContentPartDoneEventAgent], [BetaResponseCreatedEventAgent],
	// [BetaResponseErrorEventAgent], [BetaResponseFileSearchCallCompletedEventAgent],
	// [BetaResponseFileSearchCallInProgressEventAgent],
	// [BetaResponseFileSearchCallSearchingEventAgent],
	// [BetaResponseFunctionCallArgumentsDeltaEventAgent],
	// [BetaResponseFunctionCallArgumentsDoneEventAgent],
	// [BetaResponseInProgressEventAgent], [BetaResponseFailedEventAgent],
	// [BetaResponseIncompleteEventAgent], [BetaResponseOutputItemAddedEventAgent],
	// [BetaResponseOutputItemDoneEventAgent],
	// [BetaResponseReasoningSummaryPartAddedEventAgent],
	// [BetaResponseReasoningSummaryPartDoneEventAgent],
	// [BetaResponseReasoningSummaryTextDeltaEventAgent],
	// [BetaResponseReasoningSummaryTextDoneEventAgent],
	// [BetaResponseReasoningTextDeltaEventAgent],
	// [BetaResponseReasoningTextDoneEventAgent], [BetaResponseRefusalDeltaEventAgent],
	// [BetaResponseRefusalDoneEventAgent], [BetaResponseTextDeltaEventAgent],
	// [BetaResponseTextDoneEventAgent],
	// [BetaResponseWebSearchCallCompletedEventAgent],
	// [BetaResponseWebSearchCallInProgressEventAgent],
	// [BetaResponseWebSearchCallSearchingEventAgent],
	// [BetaResponseImageGenCallCompletedEventAgent],
	// [BetaResponseImageGenCallGeneratingEventAgent],
	// [BetaResponseImageGenCallInProgressEventAgent],
	// [BetaResponseImageGenCallPartialImageEventAgent],
	// [BetaResponseMcpCallArgumentsDeltaEventAgent],
	// [BetaResponseMcpCallArgumentsDoneEventAgent],
	// [BetaResponseMcpCallCompletedEventAgent], [BetaResponseMcpCallFailedEventAgent],
	// [BetaResponseMcpCallInProgressEventAgent],
	// [BetaResponseMcpListToolsCompletedEventAgent],
	// [BetaResponseMcpListToolsFailedEventAgent],
	// [BetaResponseMcpListToolsInProgressEventAgent],
	// [BetaResponseOutputTextAnnotationAddedEventAgent],
	// [BetaResponseQueuedEventAgent],
	// [BetaResponseCustomToolCallInputDeltaEventAgent],
	// [BetaResponseCustomToolCallInputDoneEventAgent]
	Agent       BetaResponseStreamEventUnionAgent `json:"agent"`
	ItemID      string                            `json:"item_id"`
	OutputIndex int64                             `json:"output_index"`
	Code        string                            `json:"code"`
	// This field is from variant [BetaResponseCompletedEvent].
	Response     BetaResponse `json:"response"`
	ContentIndex int64        `json:"content_index"`
	// This field is a union of [BetaResponseContentPartAddedEventPartUnion],
	// [BetaResponseContentPartDoneEventPartUnion],
	// [BetaResponseReasoningSummaryPartAddedEventPart],
	// [BetaResponseReasoningSummaryPartDoneEventPart]
	Part BetaResponseStreamEventUnionPart `json:"part"`
	// This field is from variant [BetaResponseErrorEvent].
	Message string `json:"message"`
	// This field is from variant [BetaResponseErrorEvent].
	Param     string `json:"param"`
	Arguments string `json:"arguments"`
	// This field is from variant [BetaResponseFunctionCallArgumentsDoneEvent].
	Name string `json:"name"`
	// This field is from variant [BetaResponseOutputItemAddedEvent].
	Item         BetaResponseOutputItemUnion `json:"item"`
	SummaryIndex int64                       `json:"summary_index"`
	// This field is from variant [BetaResponseReasoningSummaryPartDoneEvent].
	Status BetaResponseReasoningSummaryPartDoneEventStatus `json:"status"`
	Text   string                                          `json:"text"`
	// This field is from variant [BetaResponseRefusalDoneEvent].
	Refusal string `json:"refusal"`
	// This field is a union of [[]BetaResponseTextDeltaEventLogprob],
	// [[]BetaResponseTextDoneEventLogprob]
	Logprobs BetaResponseStreamEventUnionLogprobs `json:"logprobs"`
	// This field is from variant [BetaResponseImageGenCallPartialImageEvent].
	PartialImageB64 string `json:"partial_image_b64"`
	// This field is from variant [BetaResponseImageGenCallPartialImageEvent].
	PartialImageIndex int64 `json:"partial_image_index"`
	// This field is from variant [BetaResponseOutputTextAnnotationAddedEvent].
	Annotation any `json:"annotation"`
	// This field is from variant [BetaResponseOutputTextAnnotationAddedEvent].
	AnnotationIndex int64 `json:"annotation_index"`
	// This field is from variant [BetaResponseCustomToolCallInputDoneEvent].
	Input string `json:"input"`
	JSON  struct {
		Delta             respjson.Field
		SequenceNumber    respjson.Field
		Type              respjson.Field
		Agent             respjson.Field
		ItemID            respjson.Field
		OutputIndex       respjson.Field
		Code              respjson.Field
		Response          respjson.Field
		ContentIndex      respjson.Field
		Part              respjson.Field
		Message           respjson.Field
		Param             respjson.Field
		Arguments         respjson.Field
		Name              respjson.Field
		Item              respjson.Field
		SummaryIndex      respjson.Field
		Status            respjson.Field
		Text              respjson.Field
		Refusal           respjson.Field
		Logprobs          respjson.Field
		PartialImageB64   respjson.Field
		PartialImageIndex respjson.Field
		Annotation        respjson.Field
		AnnotationIndex   respjson.Field
		Input             respjson.Field
		raw               string
	} `json:"-"`
}

// anyBetaResponseStreamEvent is implemented by each variant of
// [BetaResponseStreamEventUnion] to add type safety for the return type of
// [BetaResponseStreamEventUnion.AsAny]
type anyBetaResponseStreamEvent interface {
	implBetaResponseStreamEventUnion()
}

func (BetaResponseAudioDeltaEvent) implBetaResponseStreamEventUnion()                      {}
func (BetaResponseAudioDoneEvent) implBetaResponseStreamEventUnion()                       {}
func (BetaResponseAudioTranscriptDeltaEvent) implBetaResponseStreamEventUnion()            {}
func (BetaResponseAudioTranscriptDoneEvent) implBetaResponseStreamEventUnion()             {}
func (BetaResponseCodeInterpreterCallCodeDeltaEvent) implBetaResponseStreamEventUnion()    {}
func (BetaResponseCodeInterpreterCallCodeDoneEvent) implBetaResponseStreamEventUnion()     {}
func (BetaResponseCodeInterpreterCallCompletedEvent) implBetaResponseStreamEventUnion()    {}
func (BetaResponseCodeInterpreterCallInProgressEvent) implBetaResponseStreamEventUnion()   {}
func (BetaResponseCodeInterpreterCallInterpretingEvent) implBetaResponseStreamEventUnion() {}
func (BetaResponseCompletedEvent) implBetaResponseStreamEventUnion()                       {}
func (BetaResponseContentPartAddedEvent) implBetaResponseStreamEventUnion()                {}
func (BetaResponseContentPartDoneEvent) implBetaResponseStreamEventUnion()                 {}
func (BetaResponseCreatedEvent) implBetaResponseStreamEventUnion()                         {}
func (BetaResponseErrorEvent) implBetaResponseStreamEventUnion()                           {}
func (BetaResponseFileSearchCallCompletedEvent) implBetaResponseStreamEventUnion()         {}
func (BetaResponseFileSearchCallInProgressEvent) implBetaResponseStreamEventUnion()        {}
func (BetaResponseFileSearchCallSearchingEvent) implBetaResponseStreamEventUnion()         {}
func (BetaResponseFunctionCallArgumentsDeltaEvent) implBetaResponseStreamEventUnion()      {}
func (BetaResponseFunctionCallArgumentsDoneEvent) implBetaResponseStreamEventUnion()       {}
func (BetaResponseInProgressEvent) implBetaResponseStreamEventUnion()                      {}
func (BetaResponseFailedEvent) implBetaResponseStreamEventUnion()                          {}
func (BetaResponseIncompleteEvent) implBetaResponseStreamEventUnion()                      {}
func (BetaResponseOutputItemAddedEvent) implBetaResponseStreamEventUnion()                 {}
func (BetaResponseOutputItemDoneEvent) implBetaResponseStreamEventUnion()                  {}
func (BetaResponseReasoningSummaryPartAddedEvent) implBetaResponseStreamEventUnion()       {}
func (BetaResponseReasoningSummaryPartDoneEvent) implBetaResponseStreamEventUnion()        {}
func (BetaResponseReasoningSummaryTextDeltaEvent) implBetaResponseStreamEventUnion()       {}
func (BetaResponseReasoningSummaryTextDoneEvent) implBetaResponseStreamEventUnion()        {}
func (BetaResponseReasoningTextDeltaEvent) implBetaResponseStreamEventUnion()              {}
func (BetaResponseReasoningTextDoneEvent) implBetaResponseStreamEventUnion()               {}
func (BetaResponseRefusalDeltaEvent) implBetaResponseStreamEventUnion()                    {}
func (BetaResponseRefusalDoneEvent) implBetaResponseStreamEventUnion()                     {}
func (BetaResponseTextDeltaEvent) implBetaResponseStreamEventUnion()                       {}
func (BetaResponseTextDoneEvent) implBetaResponseStreamEventUnion()                        {}
func (BetaResponseWebSearchCallCompletedEvent) implBetaResponseStreamEventUnion()          {}
func (BetaResponseWebSearchCallInProgressEvent) implBetaResponseStreamEventUnion()         {}
func (BetaResponseWebSearchCallSearchingEvent) implBetaResponseStreamEventUnion()          {}
func (BetaResponseImageGenCallCompletedEvent) implBetaResponseStreamEventUnion()           {}
func (BetaResponseImageGenCallGeneratingEvent) implBetaResponseStreamEventUnion()          {}
func (BetaResponseImageGenCallInProgressEvent) implBetaResponseStreamEventUnion()          {}
func (BetaResponseImageGenCallPartialImageEvent) implBetaResponseStreamEventUnion()        {}
func (BetaResponseMcpCallArgumentsDeltaEvent) implBetaResponseStreamEventUnion()           {}
func (BetaResponseMcpCallArgumentsDoneEvent) implBetaResponseStreamEventUnion()            {}
func (BetaResponseMcpCallCompletedEvent) implBetaResponseStreamEventUnion()                {}
func (BetaResponseMcpCallFailedEvent) implBetaResponseStreamEventUnion()                   {}
func (BetaResponseMcpCallInProgressEvent) implBetaResponseStreamEventUnion()               {}
func (BetaResponseMcpListToolsCompletedEvent) implBetaResponseStreamEventUnion()           {}
func (BetaResponseMcpListToolsFailedEvent) implBetaResponseStreamEventUnion()              {}
func (BetaResponseMcpListToolsInProgressEvent) implBetaResponseStreamEventUnion()          {}
func (BetaResponseOutputTextAnnotationAddedEvent) implBetaResponseStreamEventUnion()       {}
func (BetaResponseQueuedEvent) implBetaResponseStreamEventUnion()                          {}
func (BetaResponseCustomToolCallInputDeltaEvent) implBetaResponseStreamEventUnion()        {}
func (BetaResponseCustomToolCallInputDoneEvent) implBetaResponseStreamEventUnion()         {}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaResponseStreamEventUnion.AsAny().(type) {
//	case openai.BetaResponseAudioDeltaEvent:
//	case openai.BetaResponseAudioDoneEvent:
//	case openai.BetaResponseAudioTranscriptDeltaEvent:
//	case openai.BetaResponseAudioTranscriptDoneEvent:
//	case openai.BetaResponseCodeInterpreterCallCodeDeltaEvent:
//	case openai.BetaResponseCodeInterpreterCallCodeDoneEvent:
//	case openai.BetaResponseCodeInterpreterCallCompletedEvent:
//	case openai.BetaResponseCodeInterpreterCallInProgressEvent:
//	case openai.BetaResponseCodeInterpreterCallInterpretingEvent:
//	case openai.BetaResponseCompletedEvent:
//	case openai.BetaResponseContentPartAddedEvent:
//	case openai.BetaResponseContentPartDoneEvent:
//	case openai.BetaResponseCreatedEvent:
//	case openai.BetaResponseErrorEvent:
//	case openai.BetaResponseFileSearchCallCompletedEvent:
//	case openai.BetaResponseFileSearchCallInProgressEvent:
//	case openai.BetaResponseFileSearchCallSearchingEvent:
//	case openai.BetaResponseFunctionCallArgumentsDeltaEvent:
//	case openai.BetaResponseFunctionCallArgumentsDoneEvent:
//	case openai.BetaResponseInProgressEvent:
//	case openai.BetaResponseFailedEvent:
//	case openai.BetaResponseIncompleteEvent:
//	case openai.BetaResponseOutputItemAddedEvent:
//	case openai.BetaResponseOutputItemDoneEvent:
//	case openai.BetaResponseReasoningSummaryPartAddedEvent:
//	case openai.BetaResponseReasoningSummaryPartDoneEvent:
//	case openai.BetaResponseReasoningSummaryTextDeltaEvent:
//	case openai.BetaResponseReasoningSummaryTextDoneEvent:
//	case openai.BetaResponseReasoningTextDeltaEvent:
//	case openai.BetaResponseReasoningTextDoneEvent:
//	case openai.BetaResponseRefusalDeltaEvent:
//	case openai.BetaResponseRefusalDoneEvent:
//	case openai.BetaResponseTextDeltaEvent:
//	case openai.BetaResponseTextDoneEvent:
//	case openai.BetaResponseWebSearchCallCompletedEvent:
//	case openai.BetaResponseWebSearchCallInProgressEvent:
//	case openai.BetaResponseWebSearchCallSearchingEvent:
//	case openai.BetaResponseImageGenCallCompletedEvent:
//	case openai.BetaResponseImageGenCallGeneratingEvent:
//	case openai.BetaResponseImageGenCallInProgressEvent:
//	case openai.BetaResponseImageGenCallPartialImageEvent:
//	case openai.BetaResponseMcpCallArgumentsDeltaEvent:
//	case openai.BetaResponseMcpCallArgumentsDoneEvent:
//	case openai.BetaResponseMcpCallCompletedEvent:
//	case openai.BetaResponseMcpCallFailedEvent:
//	case openai.BetaResponseMcpCallInProgressEvent:
//	case openai.BetaResponseMcpListToolsCompletedEvent:
//	case openai.BetaResponseMcpListToolsFailedEvent:
//	case openai.BetaResponseMcpListToolsInProgressEvent:
//	case openai.BetaResponseOutputTextAnnotationAddedEvent:
//	case openai.BetaResponseQueuedEvent:
//	case openai.BetaResponseCustomToolCallInputDeltaEvent:
//	case openai.BetaResponseCustomToolCallInputDoneEvent:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaResponseStreamEventUnion) AsAny() anyBetaResponseStreamEvent {
	switch u.Type {
	case "response.audio.delta":
		return u.AsResponseAudioDelta()
	case "response.audio.done":
		return u.AsResponseAudioDone()
	case "response.audio.transcript.delta":
		return u.AsResponseAudioTranscriptDelta()
	case "response.audio.transcript.done":
		return u.AsResponseAudioTranscriptDone()
	case "response.code_interpreter_call_code.delta":
		return u.AsResponseCodeInterpreterCallCodeDelta()
	case "response.code_interpreter_call_code.done":
		return u.AsResponseCodeInterpreterCallCodeDone()
	case "response.code_interpreter_call.completed":
		return u.AsResponseCodeInterpreterCallCompleted()
	case "response.code_interpreter_call.in_progress":
		return u.AsResponseCodeInterpreterCallInProgress()
	case "response.code_interpreter_call.interpreting":
		return u.AsResponseCodeInterpreterCallInterpreting()
	case "response.completed":
		return u.AsResponseCompleted()
	case "response.content_part.added":
		return u.AsResponseContentPartAdded()
	case "response.content_part.done":
		return u.AsResponseContentPartDone()
	case "response.created":
		return u.AsResponseCreated()
	case "error":
		return u.AsError()
	case "response.file_search_call.completed":
		return u.AsResponseFileSearchCallCompleted()
	case "response.file_search_call.in_progress":
		return u.AsResponseFileSearchCallInProgress()
	case "response.file_search_call.searching":
		return u.AsResponseFileSearchCallSearching()
	case "response.function_call_arguments.delta":
		return u.AsResponseFunctionCallArgumentsDelta()
	case "response.function_call_arguments.done":
		return u.AsResponseFunctionCallArgumentsDone()
	case "response.in_progress":
		return u.AsResponseInProgress()
	case "response.failed":
		return u.AsResponseFailed()
	case "response.incomplete":
		return u.AsResponseIncomplete()
	case "response.output_item.added":
		return u.AsResponseOutputItemAdded()
	case "response.output_item.done":
		return u.AsResponseOutputItemDone()
	case "response.reasoning_summary_part.added":
		return u.AsResponseReasoningSummaryPartAdded()
	case "response.reasoning_summary_part.done":
		return u.AsResponseReasoningSummaryPartDone()
	case "response.reasoning_summary_text.delta":
		return u.AsResponseReasoningSummaryTextDelta()
	case "response.reasoning_summary_text.done":
		return u.AsResponseReasoningSummaryTextDone()
	case "response.reasoning_text.delta":
		return u.AsResponseReasoningTextDelta()
	case "response.reasoning_text.done":
		return u.AsResponseReasoningTextDone()
	case "response.refusal.delta":
		return u.AsResponseRefusalDelta()
	case "response.refusal.done":
		return u.AsResponseRefusalDone()
	case "response.output_text.delta":
		return u.AsResponseOutputTextDelta()
	case "response.output_text.done":
		return u.AsResponseOutputTextDone()
	case "response.web_search_call.completed":
		return u.AsResponseWebSearchCallCompleted()
	case "response.web_search_call.in_progress":
		return u.AsResponseWebSearchCallInProgress()
	case "response.web_search_call.searching":
		return u.AsResponseWebSearchCallSearching()
	case "response.image_generation_call.completed":
		return u.AsResponseImageGenerationCallCompleted()
	case "response.image_generation_call.generating":
		return u.AsResponseImageGenerationCallGenerating()
	case "response.image_generation_call.in_progress":
		return u.AsResponseImageGenerationCallInProgress()
	case "response.image_generation_call.partial_image":
		return u.AsResponseImageGenerationCallPartialImage()
	case "response.mcp_call_arguments.delta":
		return u.AsResponseMcpCallArgumentsDelta()
	case "response.mcp_call_arguments.done":
		return u.AsResponseMcpCallArgumentsDone()
	case "response.mcp_call.completed":
		return u.AsResponseMcpCallCompleted()
	case "response.mcp_call.failed":
		return u.AsResponseMcpCallFailed()
	case "response.mcp_call.in_progress":
		return u.AsResponseMcpCallInProgress()
	case "response.mcp_list_tools.completed":
		return u.AsResponseMcpListToolsCompleted()
	case "response.mcp_list_tools.failed":
		return u.AsResponseMcpListToolsFailed()
	case "response.mcp_list_tools.in_progress":
		return u.AsResponseMcpListToolsInProgress()
	case "response.output_text.annotation.added":
		return u.AsResponseOutputTextAnnotationAdded()
	case "response.queued":
		return u.AsResponseQueued()
	case "response.custom_tool_call_input.delta":
		return u.AsResponseCustomToolCallInputDelta()
	case "response.custom_tool_call_input.done":
		return u.AsResponseCustomToolCallInputDone()
	}
	return nil
}

func (u BetaResponseStreamEventUnion) AsResponseAudioDelta() (v BetaResponseAudioDeltaEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseAudioDone() (v BetaResponseAudioDoneEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseAudioTranscriptDelta() (v BetaResponseAudioTranscriptDeltaEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseAudioTranscriptDone() (v BetaResponseAudioTranscriptDoneEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseCodeInterpreterCallCodeDelta() (v BetaResponseCodeInterpreterCallCodeDeltaEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseCodeInterpreterCallCodeDone() (v BetaResponseCodeInterpreterCallCodeDoneEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseCodeInterpreterCallCompleted() (v BetaResponseCodeInterpreterCallCompletedEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseCodeInterpreterCallInProgress() (v BetaResponseCodeInterpreterCallInProgressEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseCodeInterpreterCallInterpreting() (v BetaResponseCodeInterpreterCallInterpretingEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseCompleted() (v BetaResponseCompletedEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseContentPartAdded() (v BetaResponseContentPartAddedEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseContentPartDone() (v BetaResponseContentPartDoneEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseCreated() (v BetaResponseCreatedEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsError() (v BetaResponseErrorEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseFileSearchCallCompleted() (v BetaResponseFileSearchCallCompletedEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseFileSearchCallInProgress() (v BetaResponseFileSearchCallInProgressEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseFileSearchCallSearching() (v BetaResponseFileSearchCallSearchingEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseFunctionCallArgumentsDelta() (v BetaResponseFunctionCallArgumentsDeltaEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseFunctionCallArgumentsDone() (v BetaResponseFunctionCallArgumentsDoneEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseInProgress() (v BetaResponseInProgressEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseFailed() (v BetaResponseFailedEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseIncomplete() (v BetaResponseIncompleteEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseOutputItemAdded() (v BetaResponseOutputItemAddedEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseOutputItemDone() (v BetaResponseOutputItemDoneEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseReasoningSummaryPartAdded() (v BetaResponseReasoningSummaryPartAddedEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseReasoningSummaryPartDone() (v BetaResponseReasoningSummaryPartDoneEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseReasoningSummaryTextDelta() (v BetaResponseReasoningSummaryTextDeltaEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseReasoningSummaryTextDone() (v BetaResponseReasoningSummaryTextDoneEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseReasoningTextDelta() (v BetaResponseReasoningTextDeltaEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseReasoningTextDone() (v BetaResponseReasoningTextDoneEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseRefusalDelta() (v BetaResponseRefusalDeltaEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseRefusalDone() (v BetaResponseRefusalDoneEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseOutputTextDelta() (v BetaResponseTextDeltaEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseOutputTextDone() (v BetaResponseTextDoneEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseWebSearchCallCompleted() (v BetaResponseWebSearchCallCompletedEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseWebSearchCallInProgress() (v BetaResponseWebSearchCallInProgressEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseWebSearchCallSearching() (v BetaResponseWebSearchCallSearchingEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseImageGenerationCallCompleted() (v BetaResponseImageGenCallCompletedEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseImageGenerationCallGenerating() (v BetaResponseImageGenCallGeneratingEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseImageGenerationCallInProgress() (v BetaResponseImageGenCallInProgressEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseImageGenerationCallPartialImage() (v BetaResponseImageGenCallPartialImageEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseMcpCallArgumentsDelta() (v BetaResponseMcpCallArgumentsDeltaEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseMcpCallArgumentsDone() (v BetaResponseMcpCallArgumentsDoneEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseMcpCallCompleted() (v BetaResponseMcpCallCompletedEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseMcpCallFailed() (v BetaResponseMcpCallFailedEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseMcpCallInProgress() (v BetaResponseMcpCallInProgressEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseMcpListToolsCompleted() (v BetaResponseMcpListToolsCompletedEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseMcpListToolsFailed() (v BetaResponseMcpListToolsFailedEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseMcpListToolsInProgress() (v BetaResponseMcpListToolsInProgressEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseOutputTextAnnotationAdded() (v BetaResponseOutputTextAnnotationAddedEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseQueued() (v BetaResponseQueuedEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseCustomToolCallInputDelta() (v BetaResponseCustomToolCallInputDeltaEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaResponseStreamEventUnion) AsResponseCustomToolCallInputDone() (v BetaResponseCustomToolCallInputDoneEvent) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaResponseStreamEventUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaResponseStreamEventUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseStreamEventUnionAgent is an implicit subunion of
// [BetaResponseStreamEventUnion]. BetaResponseStreamEventUnionAgent provides
// convenient access to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseStreamEventUnion].
type BetaResponseStreamEventUnionAgent struct {
	AgentName string `json:"agent_name"`
	JSON      struct {
		AgentName respjson.Field
		raw       string
	} `json:"-"`
}

func (r *BetaResponseStreamEventUnionAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseStreamEventUnionPart is an implicit subunion of
// [BetaResponseStreamEventUnion]. BetaResponseStreamEventUnionPart provides
// convenient access to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseStreamEventUnion].
type BetaResponseStreamEventUnionPart struct {
	// This field is from variant [BetaResponseContentPartAddedEventPartUnion],
	// [BetaResponseContentPartDoneEventPartUnion].
	Annotations []BetaResponseOutputTextAnnotationUnion `json:"annotations"`
	Text        string                                  `json:"text"`
	Type        string                                  `json:"type"`
	// This field is from variant [BetaResponseContentPartAddedEventPartUnion],
	// [BetaResponseContentPartDoneEventPartUnion].
	Logprobs []BetaResponseOutputTextLogprob `json:"logprobs"`
	// This field is from variant [BetaResponseContentPartAddedEventPartUnion],
	// [BetaResponseContentPartDoneEventPartUnion].
	Refusal string `json:"refusal"`
	JSON    struct {
		Annotations respjson.Field
		Text        respjson.Field
		Type        respjson.Field
		Logprobs    respjson.Field
		Refusal     respjson.Field
		raw         string
	} `json:"-"`
}

func (r *BetaResponseStreamEventUnionPart) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaResponseStreamEventUnionLogprobs is an implicit subunion of
// [BetaResponseStreamEventUnion]. BetaResponseStreamEventUnionLogprobs provides
// convenient access to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaResponseStreamEventUnion].
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfBetaResponseTextDeltaEventLogprobs
// OfBetaResponseTextDoneEventLogprobs]
type BetaResponseStreamEventUnionLogprobs struct {
	// This field will be present if the value is a
	// [[]BetaResponseTextDeltaEventLogprob] instead of an object.
	OfBetaResponseTextDeltaEventLogprobs []BetaResponseTextDeltaEventLogprob `json:",inline"`
	// This field will be present if the value is a
	// [[]BetaResponseTextDoneEventLogprob] instead of an object.
	OfBetaResponseTextDoneEventLogprobs []BetaResponseTextDoneEventLogprob `json:",inline"`
	JSON                                struct {
		OfBetaResponseTextDeltaEventLogprobs respjson.Field
		OfBetaResponseTextDoneEventLogprobs  respjson.Field
		raw                                  string
	} `json:"-"`
}

func (r *BetaResponseStreamEventUnionLogprobs) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Configuration options for a text response from the model. Can be plain text or
// structured JSON data. Learn more:
//
// - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
// - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
type BetaResponseTextConfig struct {
	// An object specifying the format that the model must output.
	//
	// Configuring `{ "type": "json_schema" }` enables Structured Outputs, which
	// ensures the model will match your supplied JSON schema. Learn more in the
	// [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
	//
	// The default format is `{ "type": "text" }` with no additional options.
	//
	// **Not recommended for gpt-4o and newer models:**
	//
	// Setting to `{ "type": "json_object" }` enables the older JSON mode, which
	// ensures the message the model generates is valid JSON. Using `json_schema` is
	// preferred for models that support it.
	Format BetaResponseFormatTextConfigUnion `json:"format"`
	// Constrains the verbosity of the model's response. Lower values will result in
	// more concise responses, while higher values will result in more verbose
	// responses. Currently supported values are `low`, `medium`, and `high`. The
	// default is `medium`.
	//
	// Any of "low", "medium", "high".
	Verbosity BetaResponseTextConfigVerbosity `json:"verbosity" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Format      respjson.Field
		Verbosity   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseTextConfig) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseTextConfig) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseTextConfig to a BetaResponseTextConfigParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseTextConfigParam.Overrides()
func (r BetaResponseTextConfig) ToParam() BetaResponseTextConfigParam {
	return param.Override[BetaResponseTextConfigParam](json.RawMessage(r.RawJSON()))
}

// Constrains the verbosity of the model's response. Lower values will result in
// more concise responses, while higher values will result in more verbose
// responses. Currently supported values are `low`, `medium`, and `high`. The
// default is `medium`.
type BetaResponseTextConfigVerbosity string

const (
	BetaResponseTextConfigVerbosityLow    BetaResponseTextConfigVerbosity = "low"
	BetaResponseTextConfigVerbosityMedium BetaResponseTextConfigVerbosity = "medium"
	BetaResponseTextConfigVerbosityHigh   BetaResponseTextConfigVerbosity = "high"
)

// Configuration options for a text response from the model. Can be plain text or
// structured JSON data. Learn more:
//
// - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
// - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
type BetaResponseTextConfigParam struct {
	// Constrains the verbosity of the model's response. Lower values will result in
	// more concise responses, while higher values will result in more verbose
	// responses. Currently supported values are `low`, `medium`, and `high`. The
	// default is `medium`.
	//
	// Any of "low", "medium", "high".
	Verbosity BetaResponseTextConfigVerbosity `json:"verbosity,omitzero"`
	// An object specifying the format that the model must output.
	//
	// Configuring `{ "type": "json_schema" }` enables Structured Outputs, which
	// ensures the model will match your supplied JSON schema. Learn more in the
	// [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
	//
	// The default format is `{ "type": "text" }` with no additional options.
	//
	// **Not recommended for gpt-4o and newer models:**
	//
	// Setting to `{ "type": "json_object" }` enables the older JSON mode, which
	// ensures the message the model generates is valid JSON. Using `json_schema` is
	// preferred for models that support it.
	Format BetaResponseFormatTextConfigUnionParam `json:"format,omitzero"`
	paramObj
}

func (r BetaResponseTextConfigParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseTextConfigParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseTextConfigParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when there is an additional text delta.
type BetaResponseTextDeltaEvent struct {
	// The index of the content part that the text delta was added to.
	ContentIndex int64 `json:"content_index" api:"required"`
	// The text delta that was added.
	Delta string `json:"delta" api:"required"`
	// The ID of the output item that the text delta was added to.
	ItemID string `json:"item_id" api:"required"`
	// The log probabilities of the tokens in the delta.
	Logprobs []BetaResponseTextDeltaEventLogprob `json:"logprobs" api:"required"`
	// The index of the output item that the text delta was added to.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number for this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.output_text.delta`.
	Type constant.ResponseOutputTextDelta `json:"type" default:"response.output_text.delta"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseTextDeltaEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ContentIndex   respjson.Field
		Delta          respjson.Field
		ItemID         respjson.Field
		Logprobs       respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseTextDeltaEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseTextDeltaEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A logprob is the logarithmic probability that the model assigns to producing a
// particular token at a given position in the sequence. Less-negative (higher)
// logprob values indicate greater model confidence in that token choice.
type BetaResponseTextDeltaEventLogprob struct {
	// A possible text token.
	Token string `json:"token" api:"required"`
	// The log probability of this token.
	Logprob float64 `json:"logprob" api:"required"`
	// The log probabilities of up to 20 of the most likely tokens.
	TopLogprobs []BetaResponseTextDeltaEventLogprobTopLogprob `json:"top_logprobs"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Token       respjson.Field
		Logprob     respjson.Field
		TopLogprobs respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseTextDeltaEventLogprob) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseTextDeltaEventLogprob) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseTextDeltaEventLogprobTopLogprob struct {
	// A possible text token.
	Token string `json:"token"`
	// The log probability of this token.
	Logprob float64 `json:"logprob"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Token       respjson.Field
		Logprob     respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseTextDeltaEventLogprobTopLogprob) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseTextDeltaEventLogprobTopLogprob) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseTextDeltaEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseTextDeltaEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseTextDeltaEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when text content is finalized.
type BetaResponseTextDoneEvent struct {
	// The index of the content part that the text content is finalized.
	ContentIndex int64 `json:"content_index" api:"required"`
	// The ID of the output item that the text content is finalized.
	ItemID string `json:"item_id" api:"required"`
	// The log probabilities of the tokens in the delta.
	Logprobs []BetaResponseTextDoneEventLogprob `json:"logprobs" api:"required"`
	// The index of the output item that the text content is finalized.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number for this event.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The text content that is finalized.
	Text string `json:"text" api:"required"`
	// The type of the event. Always `response.output_text.done`.
	Type constant.ResponseOutputTextDone `json:"type" default:"response.output_text.done"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseTextDoneEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ContentIndex   respjson.Field
		ItemID         respjson.Field
		Logprobs       respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Text           respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseTextDoneEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseTextDoneEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A logprob is the logarithmic probability that the model assigns to producing a
// particular token at a given position in the sequence. Less-negative (higher)
// logprob values indicate greater model confidence in that token choice.
type BetaResponseTextDoneEventLogprob struct {
	// A possible text token.
	Token string `json:"token" api:"required"`
	// The log probability of this token.
	Logprob float64 `json:"logprob" api:"required"`
	// The log probabilities of up to 20 of the most likely tokens.
	TopLogprobs []BetaResponseTextDoneEventLogprobTopLogprob `json:"top_logprobs"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Token       respjson.Field
		Logprob     respjson.Field
		TopLogprobs respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseTextDoneEventLogprob) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseTextDoneEventLogprob) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseTextDoneEventLogprobTopLogprob struct {
	// A possible text token.
	Token string `json:"token"`
	// The log probability of this token.
	Logprob float64 `json:"logprob"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Token       respjson.Field
		Logprob     respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseTextDoneEventLogprobTopLogprob) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseTextDoneEventLogprobTopLogprob) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseTextDoneEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseTextDoneEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseTextDoneEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseToolSearchCall struct {
	// The unique ID of the tool search call item.
	ID string `json:"id" api:"required"`
	// Arguments used for the tool search call.
	Arguments any `json:"arguments" api:"required"`
	// The unique ID of the tool search call generated by the model.
	CallID string `json:"call_id" api:"required"`
	// Whether tool search was executed by the server or by the client.
	//
	// Any of "server", "client".
	Execution BetaResponseToolSearchCallExecution `json:"execution" api:"required"`
	// The status of the tool search call item that was recorded.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status BetaResponseToolSearchCallStatus `json:"status" api:"required"`
	// The type of the item. Always `tool_search_call`.
	Type constant.ToolSearchCall `json:"type" default:"tool_search_call"`
	// The agent that produced this item.
	Agent BetaResponseToolSearchCallAgent `json:"agent"`
	// The identifier of the actor that created the item.
	CreatedBy string `json:"created_by"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Arguments   respjson.Field
		CallID      respjson.Field
		Execution   respjson.Field
		Status      respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		CreatedBy   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseToolSearchCall) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseToolSearchCall) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Whether tool search was executed by the server or by the client.
type BetaResponseToolSearchCallExecution string

const (
	BetaResponseToolSearchCallExecutionServer BetaResponseToolSearchCallExecution = "server"
	BetaResponseToolSearchCallExecutionClient BetaResponseToolSearchCallExecution = "client"
)

// The status of the tool search call item that was recorded.
type BetaResponseToolSearchCallStatus string

const (
	BetaResponseToolSearchCallStatusInProgress BetaResponseToolSearchCallStatus = "in_progress"
	BetaResponseToolSearchCallStatusCompleted  BetaResponseToolSearchCallStatus = "completed"
	BetaResponseToolSearchCallStatusIncomplete BetaResponseToolSearchCallStatus = "incomplete"
)

// The agent that produced this item.
type BetaResponseToolSearchCallAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseToolSearchCallAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseToolSearchCallAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseToolSearchOutputItem struct {
	// The unique ID of the tool search output item.
	ID string `json:"id" api:"required"`
	// The unique ID of the tool search call generated by the model.
	CallID string `json:"call_id" api:"required"`
	// Whether tool search was executed by the server or by the client.
	//
	// Any of "server", "client".
	Execution BetaResponseToolSearchOutputItemExecution `json:"execution" api:"required"`
	// The status of the tool search output item that was recorded.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status BetaResponseToolSearchOutputItemStatus `json:"status" api:"required"`
	// The loaded tool definitions returned by tool search.
	Tools []BetaToolUnion `json:"tools" api:"required"`
	// The type of the item. Always `tool_search_output`.
	Type constant.ToolSearchOutput `json:"type" default:"tool_search_output"`
	// The agent that produced this item.
	Agent BetaResponseToolSearchOutputItemAgent `json:"agent"`
	// The identifier of the actor that created the item.
	CreatedBy string `json:"created_by"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CallID      respjson.Field
		Execution   respjson.Field
		Status      respjson.Field
		Tools       respjson.Field
		Type        respjson.Field
		Agent       respjson.Field
		CreatedBy   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseToolSearchOutputItem) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseToolSearchOutputItem) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Whether tool search was executed by the server or by the client.
type BetaResponseToolSearchOutputItemExecution string

const (
	BetaResponseToolSearchOutputItemExecutionServer BetaResponseToolSearchOutputItemExecution = "server"
	BetaResponseToolSearchOutputItemExecutionClient BetaResponseToolSearchOutputItemExecution = "client"
)

// The status of the tool search output item that was recorded.
type BetaResponseToolSearchOutputItemStatus string

const (
	BetaResponseToolSearchOutputItemStatusInProgress BetaResponseToolSearchOutputItemStatus = "in_progress"
	BetaResponseToolSearchOutputItemStatusCompleted  BetaResponseToolSearchOutputItemStatus = "completed"
	BetaResponseToolSearchOutputItemStatusIncomplete BetaResponseToolSearchOutputItemStatus = "incomplete"
)

// The agent that produced this item.
type BetaResponseToolSearchOutputItemAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseToolSearchOutputItemAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseToolSearchOutputItemAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaResponseToolSearchOutputItemParamResp struct {
	// The loaded tool definitions returned by the tool search output.
	Tools []BetaToolUnion `json:"tools" api:"required"`
	// The item type. Always `tool_search_output`.
	Type constant.ToolSearchOutput `json:"type" default:"tool_search_output"`
	// The unique ID of this tool search output.
	ID string `json:"id" api:"nullable"`
	// The agent that produced this item.
	Agent BetaResponseToolSearchOutputItemParamAgentResp `json:"agent" api:"nullable"`
	// The unique ID of the tool search call generated by the model.
	CallID string `json:"call_id" api:"nullable"`
	// Whether tool search was executed by the server or by the client.
	//
	// Any of "server", "client".
	Execution BetaResponseToolSearchOutputItemParamExecution `json:"execution"`
	// The status of the tool search output.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status BetaResponseToolSearchOutputItemParamStatus `json:"status" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Tools       respjson.Field
		Type        respjson.Field
		ID          respjson.Field
		Agent       respjson.Field
		CallID      respjson.Field
		Execution   respjson.Field
		Status      respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseToolSearchOutputItemParamResp) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseToolSearchOutputItemParamResp) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaResponseToolSearchOutputItemParamResp to a
// BetaResponseToolSearchOutputItemParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaResponseToolSearchOutputItemParam.Overrides()
func (r BetaResponseToolSearchOutputItemParamResp) ToParam() BetaResponseToolSearchOutputItemParam {
	return param.Override[BetaResponseToolSearchOutputItemParam](json.RawMessage(r.RawJSON()))
}

// The agent that produced this item.
type BetaResponseToolSearchOutputItemParamAgentResp struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseToolSearchOutputItemParamAgentResp) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseToolSearchOutputItemParamAgentResp) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Whether tool search was executed by the server or by the client.
type BetaResponseToolSearchOutputItemParamExecution string

const (
	BetaResponseToolSearchOutputItemParamExecutionServer BetaResponseToolSearchOutputItemParamExecution = "server"
	BetaResponseToolSearchOutputItemParamExecutionClient BetaResponseToolSearchOutputItemParamExecution = "client"
)

// The status of the tool search output.
type BetaResponseToolSearchOutputItemParamStatus string

const (
	BetaResponseToolSearchOutputItemParamStatusInProgress BetaResponseToolSearchOutputItemParamStatus = "in_progress"
	BetaResponseToolSearchOutputItemParamStatusCompleted  BetaResponseToolSearchOutputItemParamStatus = "completed"
	BetaResponseToolSearchOutputItemParamStatusIncomplete BetaResponseToolSearchOutputItemParamStatus = "incomplete"
)

// The properties Tools, Type are required.
type BetaResponseToolSearchOutputItemParam struct {
	// The loaded tool definitions returned by the tool search output.
	Tools []BetaToolUnionParam `json:"tools,omitzero" api:"required"`
	// The unique ID of this tool search output.
	ID param.Opt[string] `json:"id,omitzero"`
	// The unique ID of the tool search call generated by the model.
	CallID param.Opt[string] `json:"call_id,omitzero"`
	// The agent that produced this item.
	Agent BetaResponseToolSearchOutputItemParamAgent `json:"agent,omitzero"`
	// The status of the tool search output.
	//
	// Any of "in_progress", "completed", "incomplete".
	Status BetaResponseToolSearchOutputItemParamStatus `json:"status,omitzero"`
	// Whether tool search was executed by the server or by the client.
	//
	// Any of "server", "client".
	Execution BetaResponseToolSearchOutputItemParamExecution `json:"execution,omitzero"`
	// The item type. Always `tool_search_output`.
	//
	// This field can be elided, and will marshal its zero value as
	// "tool_search_output".
	Type constant.ToolSearchOutput `json:"type" default:"tool_search_output"`
	paramObj
}

func (r BetaResponseToolSearchOutputItemParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseToolSearchOutputItemParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseToolSearchOutputItemParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that produced this item.
//
// The property AgentName is required.
type BetaResponseToolSearchOutputItemParamAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	paramObj
}

func (r BetaResponseToolSearchOutputItemParamAgent) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseToolSearchOutputItemParamAgent
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseToolSearchOutputItemParamAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Represents token usage details including input tokens, output tokens, a
// breakdown of output tokens, and the total tokens used.
type BetaResponseUsage struct {
	// The number of input tokens.
	InputTokens int64 `json:"input_tokens" api:"required"`
	// A detailed breakdown of the input tokens.
	InputTokensDetails BetaResponseUsageInputTokensDetails `json:"input_tokens_details" api:"required"`
	// The number of output tokens.
	OutputTokens int64 `json:"output_tokens" api:"required"`
	// A detailed breakdown of the output tokens.
	OutputTokensDetails BetaResponseUsageOutputTokensDetails `json:"output_tokens_details" api:"required"`
	// The total number of tokens used.
	TotalTokens int64 `json:"total_tokens" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		InputTokens         respjson.Field
		InputTokensDetails  respjson.Field
		OutputTokens        respjson.Field
		OutputTokensDetails respjson.Field
		TotalTokens         respjson.Field
		ExtraFields         map[string]respjson.Field
		raw                 string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseUsage) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseUsage) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A detailed breakdown of the input tokens.
type BetaResponseUsageInputTokensDetails struct {
	// The number of input tokens that were written to the cache.
	CacheWriteTokens int64 `json:"cache_write_tokens" api:"required"`
	// The number of tokens that were retrieved from the cache.
	// [More on prompt caching](https://platform.openai.com/docs/guides/prompt-caching).
	CachedTokens int64 `json:"cached_tokens" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CacheWriteTokens respjson.Field
		CachedTokens     respjson.Field
		ExtraFields      map[string]respjson.Field
		raw              string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseUsageInputTokensDetails) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseUsageInputTokensDetails) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A detailed breakdown of the output tokens.
type BetaResponseUsageOutputTokensDetails struct {
	// The number of reasoning tokens.
	ReasoningTokens int64 `json:"reasoning_tokens" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ReasoningTokens respjson.Field
		ExtraFields     map[string]respjson.Field
		raw             string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseUsageOutputTokensDetails) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseUsageOutputTokensDetails) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when a web search call is completed.
type BetaResponseWebSearchCallCompletedEvent struct {
	// Unique ID for the output item associated with the web search call.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item that the web search call is associated with.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of the web search call being processed.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.web_search_call.completed`.
	Type constant.ResponseWebSearchCallCompleted `json:"type" default:"response.web_search_call.completed"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseWebSearchCallCompletedEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseWebSearchCallCompletedEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseWebSearchCallCompletedEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseWebSearchCallCompletedEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseWebSearchCallCompletedEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseWebSearchCallCompletedEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when a web search call is initiated.
type BetaResponseWebSearchCallInProgressEvent struct {
	// Unique ID for the output item associated with the web search call.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item that the web search call is associated with.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of the web search call being processed.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.web_search_call.in_progress`.
	Type constant.ResponseWebSearchCallInProgress `json:"type" default:"response.web_search_call.in_progress"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseWebSearchCallInProgressEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseWebSearchCallInProgressEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseWebSearchCallInProgressEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseWebSearchCallInProgressEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseWebSearchCallInProgressEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseWebSearchCallInProgressEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Emitted when a web search call is executing.
type BetaResponseWebSearchCallSearchingEvent struct {
	// Unique ID for the output item associated with the web search call.
	ItemID string `json:"item_id" api:"required"`
	// The index of the output item that the web search call is associated with.
	OutputIndex int64 `json:"output_index" api:"required"`
	// The sequence number of the web search call being processed.
	SequenceNumber int64 `json:"sequence_number" api:"required"`
	// The type of the event. Always `response.web_search_call.searching`.
	Type constant.ResponseWebSearchCallSearching `json:"type" default:"response.web_search_call.searching"`
	// The agent that owns this multi-agent streaming event.
	Agent BetaResponseWebSearchCallSearchingEventAgent `json:"agent" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ItemID         respjson.Field
		OutputIndex    respjson.Field
		SequenceNumber respjson.Field
		Type           respjson.Field
		Agent          respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseWebSearchCallSearchingEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseWebSearchCallSearchingEvent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The agent that owns this multi-agent streaming event.
type BetaResponseWebSearchCallSearchingEventAgent struct {
	// The canonical name of the agent that produced this item.
	AgentName string `json:"agent_name" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AgentName   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaResponseWebSearchCallSearchingEventAgent) RawJSON() string { return r.JSON.raw }
func (r *BetaResponseWebSearchCallSearchingEventAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaSkillReference struct {
	// The ID of the referenced skill.
	SkillID string `json:"skill_id" api:"required"`
	// References a skill created with the /v1/skills endpoint.
	Type constant.SkillReference `json:"type" default:"skill_reference"`
	// Optional skill version. Use a positive integer or 'latest'. Omit for default.
	Version string `json:"version"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		SkillID     respjson.Field
		Type        respjson.Field
		Version     respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaSkillReference) RawJSON() string { return r.JSON.raw }
func (r *BetaSkillReference) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaSkillReference to a BetaSkillReferenceParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaSkillReferenceParam.Overrides()
func (r BetaSkillReference) ToParam() BetaSkillReferenceParam {
	return param.Override[BetaSkillReferenceParam](json.RawMessage(r.RawJSON()))
}

// The properties SkillID, Type are required.
type BetaSkillReferenceParam struct {
	// The ID of the referenced skill.
	SkillID string `json:"skill_id" api:"required"`
	// Optional skill version. Use a positive integer or 'latest'. Omit for default.
	Version param.Opt[string] `json:"version,omitzero"`
	// References a skill created with the /v1/skills endpoint.
	//
	// This field can be elided, and will marshal its zero value as "skill_reference".
	Type constant.SkillReference `json:"type" default:"skill_reference"`
	paramObj
}

func (r BetaSkillReferenceParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaSkillReferenceParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaSkillReferenceParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaToolUnion contains all possible properties and values from
// [BetaFunctionTool], [BetaFileSearchTool], [BetaComputerTool],
// [BetaComputerUsePreviewTool], [BetaWebSearchTool], [BetaToolMcp],
// [BetaToolCodeInterpreter], [BetaToolProgrammaticToolCalling],
// [BetaToolImageGeneration], [BetaToolLocalShell], [BetaFunctionShellTool],
// [BetaCustomTool], [BetaNamespaceTool], [BetaToolSearchTool],
// [BetaWebSearchPreviewTool], [BetaApplyPatchTool].
//
// Use the [BetaToolUnion.AsAny] method to switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaToolUnion struct {
	Name       string `json:"name"`
	Parameters any    `json:"parameters"`
	// This field is from variant [BetaFunctionTool].
	Strict bool `json:"strict"`
	// Any of "function", "file_search", "computer", "computer_use_preview", nil,
	// "mcp", "code_interpreter", "programmatic_tool_calling", "image_generation",
	// "local_shell", "shell", "custom", "namespace", "tool_search", nil,
	// "apply_patch".
	Type           string   `json:"type"`
	AllowedCallers []string `json:"allowed_callers"`
	DeferLoading   bool     `json:"defer_loading"`
	Description    string   `json:"description"`
	// This field is from variant [BetaFunctionTool].
	OutputSchema map[string]any `json:"output_schema"`
	// This field is from variant [BetaFileSearchTool].
	VectorStoreIDs []string `json:"vector_store_ids"`
	// This field is a union of [BetaFileSearchToolFiltersUnion],
	// [BetaWebSearchToolFilters]
	Filters BetaToolUnionFilters `json:"filters"`
	// This field is from variant [BetaFileSearchTool].
	MaxNumResults int64 `json:"max_num_results"`
	// This field is from variant [BetaFileSearchTool].
	RankingOptions BetaFileSearchToolRankingOptions `json:"ranking_options"`
	// This field is from variant [BetaComputerUsePreviewTool].
	DisplayHeight int64 `json:"display_height"`
	// This field is from variant [BetaComputerUsePreviewTool].
	DisplayWidth int64 `json:"display_width"`
	// This field is a union of [BetaComputerUsePreviewToolEnvironment],
	// [BetaFunctionShellToolEnvironmentUnion]
	Environment       BetaToolUnionEnvironment `json:"environment"`
	SearchContextSize string                   `json:"search_context_size"`
	// This field is a union of [BetaWebSearchToolUserLocation],
	// [BetaWebSearchPreviewToolUserLocation]
	UserLocation BetaToolUnionUserLocation `json:"user_location"`
	// This field is from variant [BetaToolMcp].
	ServerLabel string `json:"server_label"`
	// This field is from variant [BetaToolMcp].
	AllowedTools BetaToolMcpAllowedToolsUnion `json:"allowed_tools"`
	// This field is from variant [BetaToolMcp].
	Authorization string `json:"authorization"`
	// This field is from variant [BetaToolMcp].
	ConnectorID string `json:"connector_id"`
	// This field is from variant [BetaToolMcp].
	Headers map[string]string `json:"headers"`
	// This field is from variant [BetaToolMcp].
	RequireApproval BetaToolMcpRequireApprovalUnion `json:"require_approval"`
	// This field is from variant [BetaToolMcp].
	ServerDescription string `json:"server_description"`
	// This field is from variant [BetaToolMcp].
	ServerURL string `json:"server_url"`
	// This field is from variant [BetaToolMcp].
	TunnelID string `json:"tunnel_id"`
	// This field is from variant [BetaToolCodeInterpreter].
	Container BetaToolCodeInterpreterContainerUnion `json:"container"`
	// This field is from variant [BetaToolImageGeneration].
	Action string `json:"action"`
	// This field is from variant [BetaToolImageGeneration].
	Background string `json:"background"`
	// This field is from variant [BetaToolImageGeneration].
	InputFidelity string `json:"input_fidelity"`
	// This field is from variant [BetaToolImageGeneration].
	InputImageMask BetaToolImageGenerationInputImageMask `json:"input_image_mask"`
	// This field is from variant [BetaToolImageGeneration].
	Model string `json:"model"`
	// This field is from variant [BetaToolImageGeneration].
	Moderation string `json:"moderation"`
	// This field is from variant [BetaToolImageGeneration].
	OutputCompression int64 `json:"output_compression"`
	// This field is from variant [BetaToolImageGeneration].
	OutputFormat string `json:"output_format"`
	// This field is from variant [BetaToolImageGeneration].
	PartialImages int64 `json:"partial_images"`
	// This field is from variant [BetaToolImageGeneration].
	Quality string `json:"quality"`
	// This field is from variant [BetaToolImageGeneration].
	Size string `json:"size"`
	// This field is from variant [BetaCustomTool].
	Format BetaCustomToolFormatUnion `json:"format"`
	// This field is from variant [BetaNamespaceTool].
	Tools []BetaNamespaceToolToolUnion `json:"tools"`
	// This field is from variant [BetaToolSearchTool].
	Execution BetaToolSearchToolExecution `json:"execution"`
	// This field is from variant [BetaWebSearchPreviewTool].
	SearchContentTypes []string `json:"search_content_types"`
	JSON               struct {
		Name               respjson.Field
		Parameters         respjson.Field
		Strict             respjson.Field
		Type               respjson.Field
		AllowedCallers     respjson.Field
		DeferLoading       respjson.Field
		Description        respjson.Field
		OutputSchema       respjson.Field
		VectorStoreIDs     respjson.Field
		Filters            respjson.Field
		MaxNumResults      respjson.Field
		RankingOptions     respjson.Field
		DisplayHeight      respjson.Field
		DisplayWidth       respjson.Field
		Environment        respjson.Field
		SearchContextSize  respjson.Field
		UserLocation       respjson.Field
		ServerLabel        respjson.Field
		AllowedTools       respjson.Field
		Authorization      respjson.Field
		ConnectorID        respjson.Field
		Headers            respjson.Field
		RequireApproval    respjson.Field
		ServerDescription  respjson.Field
		ServerURL          respjson.Field
		TunnelID           respjson.Field
		Container          respjson.Field
		Action             respjson.Field
		Background         respjson.Field
		InputFidelity      respjson.Field
		InputImageMask     respjson.Field
		Model              respjson.Field
		Moderation         respjson.Field
		OutputCompression  respjson.Field
		OutputFormat       respjson.Field
		PartialImages      respjson.Field
		Quality            respjson.Field
		Size               respjson.Field
		Format             respjson.Field
		Tools              respjson.Field
		Execution          respjson.Field
		SearchContentTypes respjson.Field
		raw                string
	} `json:"-"`
}

func (u BetaToolUnion) AsFunction() (v BetaFunctionTool) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaToolUnion) AsFileSearch() (v BetaFileSearchTool) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaToolUnion) AsComputer() (v BetaComputerTool) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaToolUnion) AsComputerUsePreview() (v BetaComputerUsePreviewTool) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaToolUnion) AsWebSearch() (v BetaWebSearchTool) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaToolUnion) AsMcp() (v BetaToolMcp) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaToolUnion) AsCodeInterpreter() (v BetaToolCodeInterpreter) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaToolUnion) AsProgrammaticToolCalling() (v BetaToolProgrammaticToolCalling) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaToolUnion) AsImageGeneration() (v BetaToolImageGeneration) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaToolUnion) AsLocalShell() (v BetaToolLocalShell) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaToolUnion) AsShell() (v BetaFunctionShellTool) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaToolUnion) AsCustom() (v BetaCustomTool) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaToolUnion) AsNamespace() (v BetaNamespaceTool) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaToolUnion) AsToolSearch() (v BetaToolSearchTool) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaToolUnion) AsWebSearchPreview() (v BetaWebSearchPreviewTool) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaToolUnion) AsApplyPatch() (v BetaApplyPatchTool) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaToolUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaToolUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaToolUnionFilters is an implicit subunion of [BetaToolUnion].
// BetaToolUnionFilters provides convenient access to the sub-properties of the
// union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaToolUnion].
type BetaToolUnionFilters struct {
	// This field is from variant [BetaFileSearchToolFiltersUnion].
	Key  string `json:"key"`
	Type string `json:"type"`
	// This field is from variant [BetaFileSearchToolFiltersUnion].
	Value BetaFileSearchToolFiltersComparisonFilterValueUnion `json:"value"`
	// This field is from variant [BetaFileSearchToolFiltersUnion].
	Filters []BetaFileSearchToolFiltersCompoundFilterFilter `json:"filters"`
	// This field is from variant [BetaWebSearchToolFilters].
	AllowedDomains []string `json:"allowed_domains"`
	JSON           struct {
		Key            respjson.Field
		Type           respjson.Field
		Value          respjson.Field
		Filters        respjson.Field
		AllowedDomains respjson.Field
		raw            string
	} `json:"-"`
}

func (r *BetaToolUnionFilters) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaToolUnionEnvironment is an implicit subunion of [BetaToolUnion].
// BetaToolUnionEnvironment provides convenient access to the sub-properties of the
// union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaToolUnion].
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfBetaComputerUsePreviewToolEnvironment]
type BetaToolUnionEnvironment struct {
	// This field will be present if the value is a
	// [BetaComputerUsePreviewToolEnvironment] instead of an object.
	OfBetaComputerUsePreviewToolEnvironment BetaComputerUsePreviewToolEnvironment `json:",inline"`
	Type                                    string                                `json:"type"`
	// This field is from variant [BetaFunctionShellToolEnvironmentUnion].
	FileIDs []string `json:"file_ids"`
	// This field is from variant [BetaFunctionShellToolEnvironmentUnion].
	MemoryLimit BetaContainerAutoMemoryLimit `json:"memory_limit"`
	// This field is from variant [BetaFunctionShellToolEnvironmentUnion].
	NetworkPolicy BetaContainerAutoNetworkPolicyUnion `json:"network_policy"`
	// This field is a union of [[]BetaContainerAutoSkillUnion], [[]BetaLocalSkill]
	Skills BetaToolUnionEnvironmentSkills `json:"skills"`
	// This field is from variant [BetaFunctionShellToolEnvironmentUnion].
	ContainerID string `json:"container_id"`
	JSON        struct {
		OfBetaComputerUsePreviewToolEnvironment respjson.Field
		Type                                    respjson.Field
		FileIDs                                 respjson.Field
		MemoryLimit                             respjson.Field
		NetworkPolicy                           respjson.Field
		Skills                                  respjson.Field
		ContainerID                             respjson.Field
		raw                                     string
	} `json:"-"`
}

func (r *BetaToolUnionEnvironment) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaToolUnionEnvironmentSkills is an implicit subunion of [BetaToolUnion].
// BetaToolUnionEnvironmentSkills provides convenient access to the sub-properties
// of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaToolUnion].
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfBetaContainerAutoSkills OfBetaLocalSkillArray]
type BetaToolUnionEnvironmentSkills struct {
	// This field will be present if the value is a [[]BetaContainerAutoSkillUnion]
	// instead of an object.
	OfBetaContainerAutoSkills []BetaContainerAutoSkillUnion `json:",inline"`
	// This field will be present if the value is a [[]BetaLocalSkill] instead of an
	// object.
	OfBetaLocalSkillArray []BetaLocalSkill `json:",inline"`
	JSON                  struct {
		OfBetaContainerAutoSkills respjson.Field
		OfBetaLocalSkillArray     respjson.Field
		raw                       string
	} `json:"-"`
}

func (r *BetaToolUnionEnvironmentSkills) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaToolUnionUserLocation is an implicit subunion of [BetaToolUnion].
// BetaToolUnionUserLocation provides convenient access to the sub-properties of
// the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaToolUnion].
type BetaToolUnionUserLocation struct {
	City     string `json:"city"`
	Country  string `json:"country"`
	Region   string `json:"region"`
	Timezone string `json:"timezone"`
	Type     string `json:"type"`
	JSON     struct {
		City     respjson.Field
		Country  respjson.Field
		Region   respjson.Field
		Timezone respjson.Field
		Type     respjson.Field
		raw      string
	} `json:"-"`
}

func (r *BetaToolUnionUserLocation) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaToolUnion to a BetaToolUnionParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaToolUnionParam.Overrides()
func (r BetaToolUnion) ToParam() BetaToolUnionParam {
	return param.Override[BetaToolUnionParam](json.RawMessage(r.RawJSON()))
}

// Give the model access to additional tools via remote Model Context Protocol
// (MCP) servers.
// [Learn more about MCP](https://platform.openai.com/docs/guides/tools-remote-mcp).
type BetaToolMcp struct {
	// A label for this MCP server, used to identify it in tool calls.
	ServerLabel string `json:"server_label" api:"required"`
	// The type of the MCP tool. Always `mcp`.
	Type constant.Mcp `json:"type" default:"mcp"`
	// The tool invocation context(s).
	//
	// Any of "direct", "programmatic".
	AllowedCallers []string `json:"allowed_callers" api:"nullable"`
	// List of allowed tool names or a filter object.
	AllowedTools BetaToolMcpAllowedToolsUnion `json:"allowed_tools" api:"nullable"`
	// An OAuth access token that can be used with a remote MCP server, either with a
	// custom MCP server URL or a service connector. Your application must handle the
	// OAuth authorization flow and provide the token here.
	Authorization string `json:"authorization"`
	// Identifier for service connectors, like those available in ChatGPT. One of
	// `server_url`, `connector_id`, or `tunnel_id` must be provided. Learn more about
	// service connectors
	// [here](https://platform.openai.com/docs/guides/tools-remote-mcp#connectors).
	//
	// Currently supported `connector_id` values are:
	//
	// - Dropbox: `connector_dropbox`
	// - Gmail: `connector_gmail`
	// - Google Calendar: `connector_googlecalendar`
	// - Google Drive: `connector_googledrive`
	// - Microsoft Teams: `connector_microsoftteams`
	// - Outlook Calendar: `connector_outlookcalendar`
	// - Outlook Email: `connector_outlookemail`
	// - SharePoint: `connector_sharepoint`
	//
	// Any of "connector_dropbox", "connector_gmail", "connector_googlecalendar",
	// "connector_googledrive", "connector_microsoftteams",
	// "connector_outlookcalendar", "connector_outlookemail", "connector_sharepoint".
	ConnectorID string `json:"connector_id"`
	// Whether this MCP tool is deferred and discovered via tool search.
	DeferLoading bool `json:"defer_loading"`
	// Optional HTTP headers to send to the MCP server. Use for authentication or other
	// purposes.
	Headers map[string]string `json:"headers" api:"nullable"`
	// Specify which of the MCP server's tools require approval.
	RequireApproval BetaToolMcpRequireApprovalUnion `json:"require_approval" api:"nullable"`
	// Optional description of the MCP server, used to provide more context.
	ServerDescription string `json:"server_description"`
	// The URL for the MCP server. One of `server_url`, `connector_id`, or `tunnel_id`
	// must be provided.
	ServerURL string `json:"server_url" format:"uri"`
	// The Secure MCP Tunnel ID to use instead of a direct server URL. One of
	// `server_url`, `connector_id`, or `tunnel_id` must be provided.
	TunnelID string `json:"tunnel_id"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ServerLabel       respjson.Field
		Type              respjson.Field
		AllowedCallers    respjson.Field
		AllowedTools      respjson.Field
		Authorization     respjson.Field
		ConnectorID       respjson.Field
		DeferLoading      respjson.Field
		Headers           respjson.Field
		RequireApproval   respjson.Field
		ServerDescription respjson.Field
		ServerURL         respjson.Field
		TunnelID          respjson.Field
		ExtraFields       map[string]respjson.Field
		raw               string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaToolMcp) RawJSON() string { return r.JSON.raw }
func (r *BetaToolMcp) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaToolMcpAllowedToolsUnion contains all possible properties and values from
// [[]string], [BetaToolMcpAllowedToolsMcpToolFilter].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfMcpAllowedTools]
type BetaToolMcpAllowedToolsUnion struct {
	// This field will be present if the value is a [[]string] instead of an object.
	OfMcpAllowedTools []string `json:",inline"`
	// This field is from variant [BetaToolMcpAllowedToolsMcpToolFilter].
	ReadOnly bool `json:"read_only"`
	// This field is from variant [BetaToolMcpAllowedToolsMcpToolFilter].
	ToolNames []string `json:"tool_names"`
	JSON      struct {
		OfMcpAllowedTools respjson.Field
		ReadOnly          respjson.Field
		ToolNames         respjson.Field
		raw               string
	} `json:"-"`
}

func (u BetaToolMcpAllowedToolsUnion) AsMcpAllowedTools() (v []string) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaToolMcpAllowedToolsUnion) AsMcpToolFilter() (v BetaToolMcpAllowedToolsMcpToolFilter) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaToolMcpAllowedToolsUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaToolMcpAllowedToolsUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A filter object to specify which tools are allowed.
type BetaToolMcpAllowedToolsMcpToolFilter struct {
	// Indicates whether or not a tool modifies data or is read-only. If an MCP server
	// is
	// [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
	// it will match this filter.
	ReadOnly bool `json:"read_only"`
	// List of allowed tool names.
	ToolNames []string `json:"tool_names"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ReadOnly    respjson.Field
		ToolNames   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaToolMcpAllowedToolsMcpToolFilter) RawJSON() string { return r.JSON.raw }
func (r *BetaToolMcpAllowedToolsMcpToolFilter) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaToolMcpRequireApprovalUnion contains all possible properties and values from
// [BetaToolMcpRequireApprovalMcpToolApprovalFilter], [string].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfMcpToolApprovalSetting]
type BetaToolMcpRequireApprovalUnion struct {
	// This field will be present if the value is a [string] instead of an object.
	OfMcpToolApprovalSetting string `json:",inline"`
	// This field is from variant [BetaToolMcpRequireApprovalMcpToolApprovalFilter].
	Always BetaToolMcpRequireApprovalMcpToolApprovalFilterAlways `json:"always"`
	// This field is from variant [BetaToolMcpRequireApprovalMcpToolApprovalFilter].
	Never BetaToolMcpRequireApprovalMcpToolApprovalFilterNever `json:"never"`
	JSON  struct {
		OfMcpToolApprovalSetting respjson.Field
		Always                   respjson.Field
		Never                    respjson.Field
		raw                      string
	} `json:"-"`
}

func (u BetaToolMcpRequireApprovalUnion) AsMcpToolApprovalFilter() (v BetaToolMcpRequireApprovalMcpToolApprovalFilter) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaToolMcpRequireApprovalUnion) AsMcpToolApprovalSetting() (v string) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaToolMcpRequireApprovalUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaToolMcpRequireApprovalUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Specify which of the MCP server's tools require approval. Can be `always`,
// `never`, or a filter object associated with tools that require approval.
type BetaToolMcpRequireApprovalMcpToolApprovalFilter struct {
	// A filter object to specify which tools are allowed.
	Always BetaToolMcpRequireApprovalMcpToolApprovalFilterAlways `json:"always"`
	// A filter object to specify which tools are allowed.
	Never BetaToolMcpRequireApprovalMcpToolApprovalFilterNever `json:"never"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Always      respjson.Field
		Never       respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaToolMcpRequireApprovalMcpToolApprovalFilter) RawJSON() string { return r.JSON.raw }
func (r *BetaToolMcpRequireApprovalMcpToolApprovalFilter) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A filter object to specify which tools are allowed.
type BetaToolMcpRequireApprovalMcpToolApprovalFilterAlways struct {
	// Indicates whether or not a tool modifies data or is read-only. If an MCP server
	// is
	// [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
	// it will match this filter.
	ReadOnly bool `json:"read_only"`
	// List of allowed tool names.
	ToolNames []string `json:"tool_names"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ReadOnly    respjson.Field
		ToolNames   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaToolMcpRequireApprovalMcpToolApprovalFilterAlways) RawJSON() string { return r.JSON.raw }
func (r *BetaToolMcpRequireApprovalMcpToolApprovalFilterAlways) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A filter object to specify which tools are allowed.
type BetaToolMcpRequireApprovalMcpToolApprovalFilterNever struct {
	// Indicates whether or not a tool modifies data or is read-only. If an MCP server
	// is
	// [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
	// it will match this filter.
	ReadOnly bool `json:"read_only"`
	// List of allowed tool names.
	ToolNames []string `json:"tool_names"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ReadOnly    respjson.Field
		ToolNames   respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaToolMcpRequireApprovalMcpToolApprovalFilterNever) RawJSON() string { return r.JSON.raw }
func (r *BetaToolMcpRequireApprovalMcpToolApprovalFilterNever) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Specify a single approval policy for all tools. One of `always` or `never`. When
// set to `always`, all tools will require approval. When set to `never`, all tools
// will not require approval.
type BetaToolMcpRequireApprovalMcpToolApprovalSetting string

const (
	BetaToolMcpRequireApprovalMcpToolApprovalSettingAlways BetaToolMcpRequireApprovalMcpToolApprovalSetting = "always"
	BetaToolMcpRequireApprovalMcpToolApprovalSettingNever  BetaToolMcpRequireApprovalMcpToolApprovalSetting = "never"
)

// A tool that runs Python code to help generate a response to a prompt.
type BetaToolCodeInterpreter struct {
	// The code interpreter container. Can be a container ID or an object that
	// specifies uploaded file IDs to make available to your code, along with an
	// optional `memory_limit` setting.
	Container BetaToolCodeInterpreterContainerUnion `json:"container" api:"required"`
	// The type of the code interpreter tool. Always `code_interpreter`.
	Type constant.CodeInterpreter `json:"type" default:"code_interpreter"`
	// The tool invocation context(s).
	//
	// Any of "direct", "programmatic".
	AllowedCallers []string `json:"allowed_callers" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Container      respjson.Field
		Type           respjson.Field
		AllowedCallers respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaToolCodeInterpreter) RawJSON() string { return r.JSON.raw }
func (r *BetaToolCodeInterpreter) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaToolCodeInterpreterContainerUnion contains all possible properties and
// values from [string], [BetaToolCodeInterpreterContainerCodeInterpreterToolAuto].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfString]
type BetaToolCodeInterpreterContainerUnion struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field is from variant
	// [BetaToolCodeInterpreterContainerCodeInterpreterToolAuto].
	Type constant.Auto `json:"type"`
	// This field is from variant
	// [BetaToolCodeInterpreterContainerCodeInterpreterToolAuto].
	FileIDs []string `json:"file_ids"`
	// This field is from variant
	// [BetaToolCodeInterpreterContainerCodeInterpreterToolAuto].
	MemoryLimit string `json:"memory_limit"`
	// This field is from variant
	// [BetaToolCodeInterpreterContainerCodeInterpreterToolAuto].
	NetworkPolicy BetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnion `json:"network_policy"`
	JSON          struct {
		OfString      respjson.Field
		Type          respjson.Field
		FileIDs       respjson.Field
		MemoryLimit   respjson.Field
		NetworkPolicy respjson.Field
		raw           string
	} `json:"-"`
}

func (u BetaToolCodeInterpreterContainerUnion) AsString() (v string) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaToolCodeInterpreterContainerUnion) AsCodeInterpreterToolAuto() (v BetaToolCodeInterpreterContainerCodeInterpreterToolAuto) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaToolCodeInterpreterContainerUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaToolCodeInterpreterContainerUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Configuration for a code interpreter container. Optionally specify the IDs of
// the files to run the code on.
type BetaToolCodeInterpreterContainerCodeInterpreterToolAuto struct {
	// Always `auto`.
	Type constant.Auto `json:"type" default:"auto"`
	// An optional list of uploaded files to make available to your code.
	FileIDs []string `json:"file_ids"`
	// The memory limit for the code interpreter container.
	//
	// Any of "1g", "4g", "16g", "64g".
	MemoryLimit string `json:"memory_limit" api:"nullable"`
	// Network access policy for the container.
	NetworkPolicy BetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnion `json:"network_policy"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type          respjson.Field
		FileIDs       respjson.Field
		MemoryLimit   respjson.Field
		NetworkPolicy respjson.Field
		ExtraFields   map[string]respjson.Field
		raw           string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaToolCodeInterpreterContainerCodeInterpreterToolAuto) RawJSON() string { return r.JSON.raw }
func (r *BetaToolCodeInterpreterContainerCodeInterpreterToolAuto) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// BetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnion
// contains all possible properties and values from
// [BetaContainerNetworkPolicyDisabled], [BetaContainerNetworkPolicyAllowlist].
//
// Use the
// [BetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnion.AsAny]
// method to switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnion struct {
	// Any of "disabled", "allowlist".
	Type string `json:"type"`
	// This field is from variant [BetaContainerNetworkPolicyAllowlist].
	AllowedDomains []string `json:"allowed_domains"`
	// This field is from variant [BetaContainerNetworkPolicyAllowlist].
	DomainSecrets []BetaContainerNetworkPolicyDomainSecret `json:"domain_secrets"`
	JSON          struct {
		Type           respjson.Field
		AllowedDomains respjson.Field
		DomainSecrets  respjson.Field
		raw            string
	} `json:"-"`
}

// anyBetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicy is
// implemented by each variant of
// [BetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnion] to
// add type safety for the return type of
// [BetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnion.AsAny]
type anyBetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicy interface {
	implBetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnion()
}

func (BetaContainerNetworkPolicyDisabled) implBetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnion() {
}
func (BetaContainerNetworkPolicyAllowlist) implBetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnion() {
}

// Use the following switch statement to find the correct variant
//
//	switch variant := BetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnion.AsAny().(type) {
//	case openai.BetaContainerNetworkPolicyDisabled:
//	case openai.BetaContainerNetworkPolicyAllowlist:
//	default:
//	  fmt.Errorf("no variant present")
//	}
func (u BetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnion) AsAny() anyBetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicy {
	switch u.Type {
	case "disabled":
		return u.AsDisabled()
	case "allowlist":
		return u.AsAllowlist()
	}
	return nil
}

func (u BetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnion) AsDisabled() (v BetaContainerNetworkPolicyDisabled) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

func (u BetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnion) AsAllowlist() (v BetaContainerNetworkPolicyAllowlist) {
	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
	return
}

// Returns the unmodified JSON received from the API
func (u BetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnion) RawJSON() string {
	return u.JSON.raw
}

func (r *BetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

type BetaToolProgrammaticToolCalling struct {
	// The type of the tool. Always `programmatic_tool_calling`.
	Type constant.ProgrammaticToolCalling `json:"type" default:"programmatic_tool_calling"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaToolProgrammaticToolCalling) RawJSON() string { return r.JSON.raw }
func (r *BetaToolProgrammaticToolCalling) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool that generates images using the GPT image models.
type BetaToolImageGeneration struct {
	// The type of the image generation tool. Always `image_generation`.
	Type constant.ImageGeneration `json:"type" default:"image_generation"`
	// Whether to generate a new image or edit an existing image. Default: `auto`.
	//
	// Any of "generate", "edit", "auto".
	Action string `json:"action"`
	// Allows to set transparency for the background of the generated image(s). This
	// parameter is only supported for GPT image models that support transparent
	// backgrounds. Must be one of `transparent`, `opaque`, or `auto` (default value).
	// When `auto` is used, the model will automatically determine the best background
	// for the image.
	//
	// `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent
	// backgrounds. Requests with `background` set to `transparent` will return an
	// error for these models; use `opaque` or `auto` instead.
	//
	// If `transparent`, the output format needs to support transparency, so it should
	// be set to either `png` (default value) or `webp`.
	//
	// Any of "transparent", "opaque", "auto".
	Background string `json:"background"`
	// Control how much effort the model will exert to match the style and features,
	// especially facial features, of input images. This parameter is only supported
	// for `gpt-image-1` and `gpt-image-1.5` and later models, unsupported for
	// `gpt-image-1-mini`. Supports `high` and `low`. Defaults to `low`.
	//
	// Any of "high", "low".
	InputFidelity string `json:"input_fidelity" api:"nullable"`
	// Optional mask for inpainting. Contains `image_url` (string, optional) and
	// `file_id` (string, optional).
	InputImageMask BetaToolImageGenerationInputImageMask `json:"input_image_mask"`
	// The image generation model to use. Default: `gpt-image-1`.
	Model string `json:"model"`
	// Moderation level for the generated image. Default: `auto`.
	//
	// Any of "auto", "low".
	Moderation string `json:"moderation"`
	// Compression level for the output image. Default: 100.
	OutputCompression int64 `json:"output_compression"`
	// The output format of the generated image. One of `png`, `webp`, or `jpeg`.
	// Default: `png`.
	//
	// Any of "png", "webp", "jpeg".
	OutputFormat string `json:"output_format"`
	// Number of partial images to generate in streaming mode, from 0 (default value)
	// to 3.
	PartialImages int64 `json:"partial_images"`
	// The quality of the generated image. One of `low`, `medium`, `high`, or `auto`.
	// Default: `auto`.
	//
	// Any of "low", "medium", "high", "auto".
	Quality string `json:"quality"`
	// The size of the generated images. For `gpt-image-2` and
	// `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT`
	// strings, for example `1536x864`. Width and height must both be divisible by 16
	// and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above
	// `2560x1440` are experimental, and the maximum supported resolution is
	// `3840x2160`. The requested size must also satisfy the model's current pixel and
	// edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are
	// supported by the GPT image models; `auto` is supported for models that allow
	// automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or
	// `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or
	// `1024x1792`.
	Size string `json:"size"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type              respjson.Field
		Action            respjson.Field
		Background        respjson.Field
		InputFidelity     respjson.Field
		InputImageMask    respjson.Field
		Model             respjson.Field
		Moderation        respjson.Field
		OutputCompression respjson.Field
		OutputFormat      respjson.Field
		PartialImages     respjson.Field
		Quality           respjson.Field
		Size              respjson.Field
		ExtraFields       map[string]respjson.Field
		raw               string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaToolImageGeneration) RawJSON() string { return r.JSON.raw }
func (r *BetaToolImageGeneration) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Optional mask for inpainting. Contains `image_url` (string, optional) and
// `file_id` (string, optional).
type BetaToolImageGenerationInputImageMask struct {
	// File ID for the mask image.
	FileID string `json:"file_id"`
	// Base64-encoded mask image.
	ImageURL string `json:"image_url"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FileID      respjson.Field
		ImageURL    respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaToolImageGenerationInputImageMask) RawJSON() string { return r.JSON.raw }
func (r *BetaToolImageGenerationInputImageMask) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool that allows the model to execute shell commands in a local environment.
type BetaToolLocalShell struct {
	// The type of the local shell tool. Always `local_shell`.
	Type constant.LocalShell `json:"type" default:"local_shell"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaToolLocalShell) RawJSON() string { return r.JSON.raw }
func (r *BetaToolLocalShell) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func BetaToolParamOfFunction(name string, parameters map[string]any, strict bool) BetaToolUnionParam {
	var function BetaFunctionToolParam
	function.Name = name
	function.Parameters = parameters
	function.Strict = param.NewOpt(strict)
	return BetaToolUnionParam{OfFunction: &function}
}

func BetaToolParamOfFileSearch(vectorStoreIDs []string) BetaToolUnionParam {
	var fileSearch BetaFileSearchToolParam
	fileSearch.VectorStoreIDs = vectorStoreIDs
	return BetaToolUnionParam{OfFileSearch: &fileSearch}
}

func BetaToolParamOfComputerUsePreview(displayHeight int64, displayWidth int64, environment BetaComputerUsePreviewToolEnvironment) BetaToolUnionParam {
	var computerUsePreview BetaComputerUsePreviewToolParam
	computerUsePreview.DisplayHeight = displayHeight
	computerUsePreview.DisplayWidth = displayWidth
	computerUsePreview.Environment = environment
	return BetaToolUnionParam{OfComputerUsePreview: &computerUsePreview}
}

func BetaToolParamOfWebSearch(type_ BetaWebSearchToolType) BetaToolUnionParam {
	var variant BetaWebSearchToolParam
	variant.Type = type_
	return BetaToolUnionParam{OfWebSearch: &variant}
}

func BetaToolParamOfMcp(serverLabel string) BetaToolUnionParam {
	var mcp BetaToolMcpParam
	mcp.ServerLabel = serverLabel
	return BetaToolUnionParam{OfMcp: &mcp}
}

func BetaToolParamOfCodeInterpreter[
	T string | BetaToolCodeInterpreterContainerCodeInterpreterToolAutoParam,
](container T) BetaToolUnionParam {
	var codeInterpreter BetaToolCodeInterpreterParam
	switch v := any(container).(type) {
	case string:
		codeInterpreter.Container.OfString = param.NewOpt(v)
	case BetaToolCodeInterpreterContainerCodeInterpreterToolAutoParam:
		codeInterpreter.Container.OfCodeInterpreterToolAuto = &v
	}
	return BetaToolUnionParam{OfCodeInterpreter: &codeInterpreter}
}

func BetaToolParamOfCustom(name string) BetaToolUnionParam {
	var custom BetaCustomToolParam
	custom.Name = name
	return BetaToolUnionParam{OfCustom: &custom}
}

func BetaToolParamOfNamespace(description string, name string, tools []BetaNamespaceToolToolUnionParam) BetaToolUnionParam {
	var namespace BetaNamespaceToolParam
	namespace.Description = description
	namespace.Name = name
	namespace.Tools = tools
	return BetaToolUnionParam{OfNamespace: &namespace}
}

func BetaToolParamOfWebSearchPreview(type_ BetaWebSearchPreviewToolType) BetaToolUnionParam {
	var variant BetaWebSearchPreviewToolParam
	variant.Type = type_
	return BetaToolUnionParam{OfWebSearchPreview: &variant}
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaToolUnionParam struct {
	OfFunction                *BetaFunctionToolParam                `json:",omitzero,inline"`
	OfFileSearch              *BetaFileSearchToolParam              `json:",omitzero,inline"`
	OfComputer                *BetaComputerToolParam                `json:",omitzero,inline"`
	OfComputerUsePreview      *BetaComputerUsePreviewToolParam      `json:",omitzero,inline"`
	OfWebSearch               *BetaWebSearchToolParam               `json:",omitzero,inline"`
	OfMcp                     *BetaToolMcpParam                     `json:",omitzero,inline"`
	OfCodeInterpreter         *BetaToolCodeInterpreterParam         `json:",omitzero,inline"`
	OfProgrammaticToolCalling *BetaToolProgrammaticToolCallingParam `json:",omitzero,inline"`
	OfImageGeneration         *BetaToolImageGenerationParam         `json:",omitzero,inline"`
	OfLocalShell              *BetaToolLocalShellParam              `json:",omitzero,inline"`
	OfShell                   *BetaFunctionShellToolParam           `json:",omitzero,inline"`
	OfCustom                  *BetaCustomToolParam                  `json:",omitzero,inline"`
	OfNamespace               *BetaNamespaceToolParam               `json:",omitzero,inline"`
	OfToolSearch              *BetaToolSearchToolParam              `json:",omitzero,inline"`
	OfWebSearchPreview        *BetaWebSearchPreviewToolParam        `json:",omitzero,inline"`
	OfApplyPatch              *BetaApplyPatchToolParam              `json:",omitzero,inline"`
	paramUnion
}

func (u BetaToolUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfFunction,
		u.OfFileSearch,
		u.OfComputer,
		u.OfComputerUsePreview,
		u.OfWebSearch,
		u.OfMcp,
		u.OfCodeInterpreter,
		u.OfProgrammaticToolCalling,
		u.OfImageGeneration,
		u.OfLocalShell,
		u.OfShell,
		u.OfCustom,
		u.OfNamespace,
		u.OfToolSearch,
		u.OfWebSearchPreview,
		u.OfApplyPatch)
}
func (u *BetaToolUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaToolUnionParam) asAny() any {
	if !param.IsOmitted(u.OfFunction) {
		return u.OfFunction
	} else if !param.IsOmitted(u.OfFileSearch) {
		return u.OfFileSearch
	} else if !param.IsOmitted(u.OfComputer) {
		return u.OfComputer
	} else if !param.IsOmitted(u.OfComputerUsePreview) {
		return u.OfComputerUsePreview
	} else if !param.IsOmitted(u.OfWebSearch) {
		return u.OfWebSearch
	} else if !param.IsOmitted(u.OfMcp) {
		return u.OfMcp
	} else if !param.IsOmitted(u.OfCodeInterpreter) {
		return u.OfCodeInterpreter
	} else if !param.IsOmitted(u.OfProgrammaticToolCalling) {
		return u.OfProgrammaticToolCalling
	} else if !param.IsOmitted(u.OfImageGeneration) {
		return u.OfImageGeneration
	} else if !param.IsOmitted(u.OfLocalShell) {
		return u.OfLocalShell
	} else if !param.IsOmitted(u.OfShell) {
		return u.OfShell
	} else if !param.IsOmitted(u.OfCustom) {
		return u.OfCustom
	} else if !param.IsOmitted(u.OfNamespace) {
		return u.OfNamespace
	} else if !param.IsOmitted(u.OfToolSearch) {
		return u.OfToolSearch
	} else if !param.IsOmitted(u.OfWebSearchPreview) {
		return u.OfWebSearchPreview
	} else if !param.IsOmitted(u.OfApplyPatch) {
		return u.OfApplyPatch
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetStrict() *bool {
	if vt := u.OfFunction; vt != nil && vt.Strict.Valid() {
		return &vt.Strict.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetOutputSchema() map[string]any {
	if vt := u.OfFunction; vt != nil {
		return vt.OutputSchema
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetVectorStoreIDs() []string {
	if vt := u.OfFileSearch; vt != nil {
		return vt.VectorStoreIDs
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetMaxNumResults() *int64 {
	if vt := u.OfFileSearch; vt != nil && vt.MaxNumResults.Valid() {
		return &vt.MaxNumResults.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetRankingOptions() *BetaFileSearchToolRankingOptionsParam {
	if vt := u.OfFileSearch; vt != nil {
		return &vt.RankingOptions
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetDisplayHeight() *int64 {
	if vt := u.OfComputerUsePreview; vt != nil {
		return &vt.DisplayHeight
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetDisplayWidth() *int64 {
	if vt := u.OfComputerUsePreview; vt != nil {
		return &vt.DisplayWidth
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetServerLabel() *string {
	if vt := u.OfMcp; vt != nil {
		return &vt.ServerLabel
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetAllowedTools() *BetaToolMcpAllowedToolsUnionParam {
	if vt := u.OfMcp; vt != nil {
		return &vt.AllowedTools
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetAuthorization() *string {
	if vt := u.OfMcp; vt != nil && vt.Authorization.Valid() {
		return &vt.Authorization.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetConnectorID() *string {
	if vt := u.OfMcp; vt != nil {
		return &vt.ConnectorID
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetHeaders() map[string]string {
	if vt := u.OfMcp; vt != nil {
		return vt.Headers
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetRequireApproval() *BetaToolMcpRequireApprovalUnionParam {
	if vt := u.OfMcp; vt != nil {
		return &vt.RequireApproval
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetServerDescription() *string {
	if vt := u.OfMcp; vt != nil && vt.ServerDescription.Valid() {
		return &vt.ServerDescription.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetServerURL() *string {
	if vt := u.OfMcp; vt != nil && vt.ServerURL.Valid() {
		return &vt.ServerURL.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetTunnelID() *string {
	if vt := u.OfMcp; vt != nil && vt.TunnelID.Valid() {
		return &vt.TunnelID.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetContainer() *BetaToolCodeInterpreterContainerUnionParam {
	if vt := u.OfCodeInterpreter; vt != nil {
		return &vt.Container
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetAction() *string {
	if vt := u.OfImageGeneration; vt != nil {
		return &vt.Action
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetBackground() *string {
	if vt := u.OfImageGeneration; vt != nil {
		return &vt.Background
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetInputFidelity() *string {
	if vt := u.OfImageGeneration; vt != nil {
		return &vt.InputFidelity
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetInputImageMask() *BetaToolImageGenerationInputImageMaskParam {
	if vt := u.OfImageGeneration; vt != nil {
		return &vt.InputImageMask
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetModel() *string {
	if vt := u.OfImageGeneration; vt != nil {
		return &vt.Model
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetModeration() *string {
	if vt := u.OfImageGeneration; vt != nil {
		return &vt.Moderation
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetOutputCompression() *int64 {
	if vt := u.OfImageGeneration; vt != nil && vt.OutputCompression.Valid() {
		return &vt.OutputCompression.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetOutputFormat() *string {
	if vt := u.OfImageGeneration; vt != nil {
		return &vt.OutputFormat
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetPartialImages() *int64 {
	if vt := u.OfImageGeneration; vt != nil && vt.PartialImages.Valid() {
		return &vt.PartialImages.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetQuality() *string {
	if vt := u.OfImageGeneration; vt != nil {
		return &vt.Quality
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetSize() *string {
	if vt := u.OfImageGeneration; vt != nil {
		return &vt.Size
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetFormat() *BetaCustomToolFormatUnionParam {
	if vt := u.OfCustom; vt != nil {
		return &vt.Format
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetTools() []BetaNamespaceToolToolUnionParam {
	if vt := u.OfNamespace; vt != nil {
		return vt.Tools
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetExecution() *string {
	if vt := u.OfToolSearch; vt != nil {
		return (*string)(&vt.Execution)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetSearchContentTypes() []string {
	if vt := u.OfWebSearchPreview; vt != nil {
		return vt.SearchContentTypes
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetName() *string {
	if vt := u.OfFunction; vt != nil {
		return (*string)(&vt.Name)
	} else if vt := u.OfCustom; vt != nil {
		return (*string)(&vt.Name)
	} else if vt := u.OfNamespace; vt != nil {
		return (*string)(&vt.Name)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetType() *string {
	if vt := u.OfFunction; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfFileSearch; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfComputer; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfComputerUsePreview; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfWebSearch; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfMcp; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfCodeInterpreter; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfProgrammaticToolCalling; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfImageGeneration; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfLocalShell; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfShell; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfCustom; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfNamespace; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfToolSearch; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfWebSearchPreview; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfApplyPatch; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetDeferLoading() *bool {
	if vt := u.OfFunction; vt != nil && vt.DeferLoading.Valid() {
		return &vt.DeferLoading.Value
	} else if vt := u.OfMcp; vt != nil && vt.DeferLoading.Valid() {
		return &vt.DeferLoading.Value
	} else if vt := u.OfCustom; vt != nil && vt.DeferLoading.Valid() {
		return &vt.DeferLoading.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetDescription() *string {
	if vt := u.OfFunction; vt != nil && vt.Description.Valid() {
		return &vt.Description.Value
	} else if vt := u.OfCustom; vt != nil && vt.Description.Valid() {
		return &vt.Description.Value
	} else if vt := u.OfNamespace; vt != nil {
		return (*string)(&vt.Description)
	} else if vt := u.OfToolSearch; vt != nil && vt.Description.Valid() {
		return &vt.Description.Value
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolUnionParam) GetSearchContextSize() *string {
	if vt := u.OfWebSearch; vt != nil {
		return (*string)(&vt.SearchContextSize)
	} else if vt := u.OfWebSearchPreview; vt != nil {
		return (*string)(&vt.SearchContextSize)
	}
	return nil
}

// Returns a subunion which exports methods to access subproperties
//
// Or use AsAny() to get the underlying value
func (u BetaToolUnionParam) GetParameters() (res betaToolUnionParamParameters) {
	if vt := u.OfFunction; vt != nil {
		res.any = &vt.Parameters
	} else if vt := u.OfToolSearch; vt != nil {
		res.any = &vt.Parameters
	}
	return
}

// Can have the runtime types [*map[string]any], [*any]
type betaToolUnionParamParameters struct{ any }

// Use the following switch statement to get the type of the union:
//
//	switch u.AsAny().(type) {
//	case *map[string]any:
//	case *any:
//	default:
//	    fmt.Errorf("not present")
//	}
func (u betaToolUnionParamParameters) AsAny() any { return u.any }

// Returns a pointer to the underlying variant's AllowedCallers property, if
// present.
func (u BetaToolUnionParam) GetAllowedCallers() []string {
	if vt := u.OfFunction; vt != nil {
		return vt.AllowedCallers
	} else if vt := u.OfMcp; vt != nil {
		return vt.AllowedCallers
	} else if vt := u.OfCodeInterpreter; vt != nil {
		return vt.AllowedCallers
	} else if vt := u.OfShell; vt != nil {
		return vt.AllowedCallers
	} else if vt := u.OfCustom; vt != nil {
		return vt.AllowedCallers
	} else if vt := u.OfApplyPatch; vt != nil {
		return vt.AllowedCallers
	}
	return nil
}

// Returns a subunion which exports methods to access subproperties
//
// Or use AsAny() to get the underlying value
func (u BetaToolUnionParam) GetFilters() (res betaToolUnionParamFilters) {
	if vt := u.OfFileSearch; vt != nil {
		res.any = vt.Filters.asAny()
	} else if vt := u.OfWebSearch; vt != nil {
		res.any = &vt.Filters
	}
	return
}

// Can have the runtime types [*BetaFileSearchToolFiltersComparisonFilterParam],
// [*BetaFileSearchToolFiltersCompoundFilterParam],
// [*BetaWebSearchToolFiltersParam]
type betaToolUnionParamFilters struct{ any }

// Use the following switch statement to get the type of the union:
//
//	switch u.AsAny().(type) {
//	case *openai.BetaFileSearchToolFiltersComparisonFilterParam:
//	case *openai.BetaFileSearchToolFiltersCompoundFilterParam:
//	case *openai.BetaWebSearchToolFiltersParam:
//	default:
//	    fmt.Errorf("not present")
//	}
func (u betaToolUnionParamFilters) AsAny() any { return u.any }

// Returns a pointer to the underlying variant's property, if present.
func (u betaToolUnionParamFilters) GetKey() *string {
	switch vt := u.any.(type) {
	case *BetaFileSearchToolFiltersUnionParam:
		return vt.GetKey()
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaToolUnionParamFilters) GetValue() *BetaFileSearchToolFiltersComparisonFilterValueUnionParam {
	switch vt := u.any.(type) {
	case *BetaFileSearchToolFiltersUnionParam:
		return vt.GetValue()
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaToolUnionParamFilters) GetFilters() []BetaFileSearchToolFiltersCompoundFilterFilterParam {
	switch vt := u.any.(type) {
	case *BetaFileSearchToolFiltersUnionParam:
		return vt.GetFilters()
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaToolUnionParamFilters) GetAllowedDomains() []string {
	switch vt := u.any.(type) {
	case *BetaWebSearchToolFiltersParam:
		return vt.AllowedDomains
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaToolUnionParamFilters) GetType() *string {
	switch vt := u.any.(type) {
	case *BetaFileSearchToolFiltersUnionParam:
		return vt.GetType()
	}
	return nil
}

// Returns a subunion which exports methods to access subproperties
//
// Or use AsAny() to get the underlying value
func (u BetaToolUnionParam) GetEnvironment() (res betaToolUnionParamEnvironment) {
	if vt := u.OfComputerUsePreview; vt != nil {
		res.any = (*string)(&vt.Environment)
	} else if vt := u.OfShell; vt != nil {
		res.any = vt.Environment.asAny()
	}
	return
}

// Can have the runtime types [*string], [*BetaContainerAutoParam],
// [*BetaLocalEnvironmentParam], [*BetaContainerReferenceParam]
type betaToolUnionParamEnvironment struct{ any }

// Use the following switch statement to get the type of the union:
//
//	switch u.AsAny().(type) {
//	case *string:
//	case *openai.BetaContainerAutoParam:
//	case *openai.BetaLocalEnvironmentParam:
//	case *openai.BetaContainerReferenceParam:
//	default:
//	    fmt.Errorf("not present")
//	}
func (u betaToolUnionParamEnvironment) AsAny() any { return u.any }

// Returns a pointer to the underlying variant's property, if present.
func (u betaToolUnionParamEnvironment) GetFileIDs() []string {
	switch vt := u.any.(type) {
	case *BetaFunctionShellToolEnvironmentUnionParam:
		return vt.GetFileIDs()
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaToolUnionParamEnvironment) GetMemoryLimit() *string {
	switch vt := u.any.(type) {
	case *BetaFunctionShellToolEnvironmentUnionParam:
		return vt.GetMemoryLimit()
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaToolUnionParamEnvironment) GetNetworkPolicy() *BetaContainerAutoNetworkPolicyUnionParam {
	switch vt := u.any.(type) {
	case *BetaFunctionShellToolEnvironmentUnionParam:
		return vt.GetNetworkPolicy()
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaToolUnionParamEnvironment) GetContainerID() *string {
	switch vt := u.any.(type) {
	case *BetaFunctionShellToolEnvironmentUnionParam:
		return vt.GetContainerID()
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaToolUnionParamEnvironment) GetType() *string {
	switch vt := u.any.(type) {
	case *BetaFunctionShellToolEnvironmentUnionParam:
		return vt.GetType()
	}
	return nil
}

// Returns a subunion which exports methods to access subproperties
//
// Or use AsAny() to get the underlying value
func (u betaToolUnionParamEnvironment) GetSkills() (res betaToolUnionParamEnvironmentSkills) {
	switch vt := u.any.(type) {
	case *BetaFunctionShellToolEnvironmentUnionParam:
		res.any = vt.GetSkills()
	}
	return res
}

// Can have the runtime types [_[]BetaContainerAutoSkillUnionParam],
// [_[]BetaLocalSkillParam]
type betaToolUnionParamEnvironmentSkills struct{ any }

// Use the following switch statement to get the type of the union:
//
//	switch u.AsAny().(type) {
//	case *[]openai.BetaContainerAutoSkillUnionParam:
//	case *[]openai.BetaLocalSkillParam:
//	default:
//	    fmt.Errorf("not present")
//	}
func (u betaToolUnionParamEnvironmentSkills) AsAny() any { return u.any }

// Returns a subunion which exports methods to access subproperties
//
// Or use AsAny() to get the underlying value
func (u BetaToolUnionParam) GetUserLocation() (res betaToolUnionParamUserLocation) {
	if vt := u.OfWebSearch; vt != nil {
		res.any = &vt.UserLocation
	} else if vt := u.OfWebSearchPreview; vt != nil {
		res.any = &vt.UserLocation
	}
	return
}

// Can have the runtime types [*BetaWebSearchToolUserLocationParam],
// [*BetaWebSearchPreviewToolUserLocationParam]
type betaToolUnionParamUserLocation struct{ any }

// Use the following switch statement to get the type of the union:
//
//	switch u.AsAny().(type) {
//	case *openai.BetaWebSearchToolUserLocationParam:
//	case *openai.BetaWebSearchPreviewToolUserLocationParam:
//	default:
//	    fmt.Errorf("not present")
//	}
func (u betaToolUnionParamUserLocation) AsAny() any { return u.any }

// Returns a pointer to the underlying variant's property, if present.
func (u betaToolUnionParamUserLocation) GetCity() *string {
	switch vt := u.any.(type) {
	case *BetaWebSearchToolUserLocationParam:
		return paramutil.AddrIfPresent(vt.City)
	case *BetaWebSearchPreviewToolUserLocationParam:
		return paramutil.AddrIfPresent(vt.City)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaToolUnionParamUserLocation) GetCountry() *string {
	switch vt := u.any.(type) {
	case *BetaWebSearchToolUserLocationParam:
		return paramutil.AddrIfPresent(vt.Country)
	case *BetaWebSearchPreviewToolUserLocationParam:
		return paramutil.AddrIfPresent(vt.Country)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaToolUnionParamUserLocation) GetRegion() *string {
	switch vt := u.any.(type) {
	case *BetaWebSearchToolUserLocationParam:
		return paramutil.AddrIfPresent(vt.Region)
	case *BetaWebSearchPreviewToolUserLocationParam:
		return paramutil.AddrIfPresent(vt.Region)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaToolUnionParamUserLocation) GetTimezone() *string {
	switch vt := u.any.(type) {
	case *BetaWebSearchToolUserLocationParam:
		return paramutil.AddrIfPresent(vt.Timezone)
	case *BetaWebSearchPreviewToolUserLocationParam:
		return paramutil.AddrIfPresent(vt.Timezone)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u betaToolUnionParamUserLocation) GetType() *string {
	switch vt := u.any.(type) {
	case *BetaWebSearchToolUserLocationParam:
		return (*string)(&vt.Type)
	case *BetaWebSearchPreviewToolUserLocationParam:
		return (*string)(&vt.Type)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaToolUnionParam](
		"type",
		apijson.Discriminator[BetaFunctionToolParam]("function"),
		apijson.Discriminator[BetaFileSearchToolParam]("file_search"),
		apijson.Discriminator[BetaComputerToolParam]("computer"),
		apijson.Discriminator[BetaComputerUsePreviewToolParam]("computer_use_preview"),
		apijson.Discriminator[BetaWebSearchToolParam]("web_search"),
		apijson.Discriminator[BetaWebSearchToolParam]("web_search_2025_08_26"),
		apijson.Discriminator[BetaToolMcpParam]("mcp"),
		apijson.Discriminator[BetaToolCodeInterpreterParam]("code_interpreter"),
		apijson.Discriminator[BetaToolProgrammaticToolCallingParam]("programmatic_tool_calling"),
		apijson.Discriminator[BetaToolImageGenerationParam]("image_generation"),
		apijson.Discriminator[BetaToolLocalShellParam]("local_shell"),
		apijson.Discriminator[BetaFunctionShellToolParam]("shell"),
		apijson.Discriminator[BetaCustomToolParam]("custom"),
		apijson.Discriminator[BetaNamespaceToolParam]("namespace"),
		apijson.Discriminator[BetaToolSearchToolParam]("tool_search"),
		apijson.Discriminator[BetaWebSearchPreviewToolParam]("web_search_preview"),
		apijson.Discriminator[BetaWebSearchPreviewToolParam]("web_search_preview_2025_03_11"),
		apijson.Discriminator[BetaApplyPatchToolParam]("apply_patch"),
	)
}

// Give the model access to additional tools via remote Model Context Protocol
// (MCP) servers.
// [Learn more about MCP](https://platform.openai.com/docs/guides/tools-remote-mcp).
//
// The properties ServerLabel, Type are required.
type BetaToolMcpParam struct {
	// A label for this MCP server, used to identify it in tool calls.
	ServerLabel string `json:"server_label" api:"required"`
	// An OAuth access token that can be used with a remote MCP server, either with a
	// custom MCP server URL or a service connector. Your application must handle the
	// OAuth authorization flow and provide the token here.
	Authorization param.Opt[string] `json:"authorization,omitzero"`
	// Whether this MCP tool is deferred and discovered via tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// Optional description of the MCP server, used to provide more context.
	ServerDescription param.Opt[string] `json:"server_description,omitzero"`
	// The URL for the MCP server. One of `server_url`, `connector_id`, or `tunnel_id`
	// must be provided.
	ServerURL param.Opt[string] `json:"server_url,omitzero" format:"uri"`
	// The Secure MCP Tunnel ID to use instead of a direct server URL. One of
	// `server_url`, `connector_id`, or `tunnel_id` must be provided.
	TunnelID param.Opt[string] `json:"tunnel_id,omitzero"`
	// The tool invocation context(s).
	//
	// Any of "direct", "programmatic".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// List of allowed tool names or a filter object.
	AllowedTools BetaToolMcpAllowedToolsUnionParam `json:"allowed_tools,omitzero"`
	// Optional HTTP headers to send to the MCP server. Use for authentication or other
	// purposes.
	Headers map[string]string `json:"headers,omitzero"`
	// Specify which of the MCP server's tools require approval.
	RequireApproval BetaToolMcpRequireApprovalUnionParam `json:"require_approval,omitzero"`
	// Identifier for service connectors, like those available in ChatGPT. One of
	// `server_url`, `connector_id`, or `tunnel_id` must be provided. Learn more about
	// service connectors
	// [here](https://platform.openai.com/docs/guides/tools-remote-mcp#connectors).
	//
	// Currently supported `connector_id` values are:
	//
	// - Dropbox: `connector_dropbox`
	// - Gmail: `connector_gmail`
	// - Google Calendar: `connector_googlecalendar`
	// - Google Drive: `connector_googledrive`
	// - Microsoft Teams: `connector_microsoftteams`
	// - Outlook Calendar: `connector_outlookcalendar`
	// - Outlook Email: `connector_outlookemail`
	// - SharePoint: `connector_sharepoint`
	//
	// Any of "connector_dropbox", "connector_gmail", "connector_googlecalendar",
	// "connector_googledrive", "connector_microsoftteams",
	// "connector_outlookcalendar", "connector_outlookemail", "connector_sharepoint".
	ConnectorID string `json:"connector_id,omitzero"`
	// The type of the MCP tool. Always `mcp`.
	//
	// This field can be elided, and will marshal its zero value as "mcp".
	Type constant.Mcp `json:"type" default:"mcp"`
	paramObj
}

func (r BetaToolMcpParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaToolMcpParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaToolMcpParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaToolMcpParam](
		"connector_id", "connector_dropbox", "connector_gmail", "connector_googlecalendar", "connector_googledrive", "connector_microsoftteams", "connector_outlookcalendar", "connector_outlookemail", "connector_sharepoint",
	)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaToolMcpAllowedToolsUnionParam struct {
	OfMcpAllowedTools []string                                   `json:",omitzero,inline"`
	OfMcpToolFilter   *BetaToolMcpAllowedToolsMcpToolFilterParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaToolMcpAllowedToolsUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfMcpAllowedTools, u.OfMcpToolFilter)
}
func (u *BetaToolMcpAllowedToolsUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaToolMcpAllowedToolsUnionParam) asAny() any {
	if !param.IsOmitted(u.OfMcpAllowedTools) {
		return &u.OfMcpAllowedTools
	} else if !param.IsOmitted(u.OfMcpToolFilter) {
		return u.OfMcpToolFilter
	}
	return nil
}

// A filter object to specify which tools are allowed.
type BetaToolMcpAllowedToolsMcpToolFilterParam struct {
	// Indicates whether or not a tool modifies data or is read-only. If an MCP server
	// is
	// [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
	// it will match this filter.
	ReadOnly param.Opt[bool] `json:"read_only,omitzero"`
	// List of allowed tool names.
	ToolNames []string `json:"tool_names,omitzero"`
	paramObj
}

func (r BetaToolMcpAllowedToolsMcpToolFilterParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaToolMcpAllowedToolsMcpToolFilterParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaToolMcpAllowedToolsMcpToolFilterParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaToolMcpRequireApprovalUnionParam struct {
	OfMcpToolApprovalFilter *BetaToolMcpRequireApprovalMcpToolApprovalFilterParam `json:",omitzero,inline"`
	// Check if union is this variant with
	// !param.IsOmitted(union.OfMcpToolApprovalSetting)
	OfMcpToolApprovalSetting param.Opt[string] `json:",omitzero,inline"`
	paramUnion
}

func (u BetaToolMcpRequireApprovalUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfMcpToolApprovalFilter, u.OfMcpToolApprovalSetting)
}
func (u *BetaToolMcpRequireApprovalUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaToolMcpRequireApprovalUnionParam) asAny() any {
	if !param.IsOmitted(u.OfMcpToolApprovalFilter) {
		return u.OfMcpToolApprovalFilter
	} else if !param.IsOmitted(u.OfMcpToolApprovalSetting) {
		return &u.OfMcpToolApprovalSetting
	}
	return nil
}

// Specify which of the MCP server's tools require approval. Can be `always`,
// `never`, or a filter object associated with tools that require approval.
type BetaToolMcpRequireApprovalMcpToolApprovalFilterParam struct {
	// A filter object to specify which tools are allowed.
	Always BetaToolMcpRequireApprovalMcpToolApprovalFilterAlwaysParam `json:"always,omitzero"`
	// A filter object to specify which tools are allowed.
	Never BetaToolMcpRequireApprovalMcpToolApprovalFilterNeverParam `json:"never,omitzero"`
	paramObj
}

func (r BetaToolMcpRequireApprovalMcpToolApprovalFilterParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaToolMcpRequireApprovalMcpToolApprovalFilterParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaToolMcpRequireApprovalMcpToolApprovalFilterParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A filter object to specify which tools are allowed.
type BetaToolMcpRequireApprovalMcpToolApprovalFilterAlwaysParam struct {
	// Indicates whether or not a tool modifies data or is read-only. If an MCP server
	// is
	// [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
	// it will match this filter.
	ReadOnly param.Opt[bool] `json:"read_only,omitzero"`
	// List of allowed tool names.
	ToolNames []string `json:"tool_names,omitzero"`
	paramObj
}

func (r BetaToolMcpRequireApprovalMcpToolApprovalFilterAlwaysParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaToolMcpRequireApprovalMcpToolApprovalFilterAlwaysParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaToolMcpRequireApprovalMcpToolApprovalFilterAlwaysParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A filter object to specify which tools are allowed.
type BetaToolMcpRequireApprovalMcpToolApprovalFilterNeverParam struct {
	// Indicates whether or not a tool modifies data or is read-only. If an MCP server
	// is
	// [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
	// it will match this filter.
	ReadOnly param.Opt[bool] `json:"read_only,omitzero"`
	// List of allowed tool names.
	ToolNames []string `json:"tool_names,omitzero"`
	paramObj
}

func (r BetaToolMcpRequireApprovalMcpToolApprovalFilterNeverParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaToolMcpRequireApprovalMcpToolApprovalFilterNeverParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaToolMcpRequireApprovalMcpToolApprovalFilterNeverParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool that runs Python code to help generate a response to a prompt.
//
// The properties Container, Type are required.
type BetaToolCodeInterpreterParam struct {
	// The code interpreter container. Can be a container ID or an object that
	// specifies uploaded file IDs to make available to your code, along with an
	// optional `memory_limit` setting.
	Container BetaToolCodeInterpreterContainerUnionParam `json:"container,omitzero" api:"required"`
	// The tool invocation context(s).
	//
	// Any of "direct", "programmatic".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// The type of the code interpreter tool. Always `code_interpreter`.
	//
	// This field can be elided, and will marshal its zero value as "code_interpreter".
	Type constant.CodeInterpreter `json:"type" default:"code_interpreter"`
	paramObj
}

func (r BetaToolCodeInterpreterParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaToolCodeInterpreterParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaToolCodeInterpreterParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaToolCodeInterpreterContainerUnionParam struct {
	OfString                  param.Opt[string]                                             `json:",omitzero,inline"`
	OfCodeInterpreterToolAuto *BetaToolCodeInterpreterContainerCodeInterpreterToolAutoParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaToolCodeInterpreterContainerUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfString, u.OfCodeInterpreterToolAuto)
}
func (u *BetaToolCodeInterpreterContainerUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaToolCodeInterpreterContainerUnionParam) asAny() any {
	if !param.IsOmitted(u.OfString) {
		return &u.OfString.Value
	} else if !param.IsOmitted(u.OfCodeInterpreterToolAuto) {
		return u.OfCodeInterpreterToolAuto
	}
	return nil
}

// Configuration for a code interpreter container. Optionally specify the IDs of
// the files to run the code on.
//
// The property Type is required.
type BetaToolCodeInterpreterContainerCodeInterpreterToolAutoParam struct {
	// The memory limit for the code interpreter container.
	//
	// Any of "1g", "4g", "16g", "64g".
	MemoryLimit string `json:"memory_limit,omitzero"`
	// An optional list of uploaded files to make available to your code.
	FileIDs []string `json:"file_ids,omitzero"`
	// Network access policy for the container.
	NetworkPolicy BetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnionParam `json:"network_policy,omitzero"`
	// Always `auto`.
	//
	// This field can be elided, and will marshal its zero value as "auto".
	Type constant.Auto `json:"type" default:"auto"`
	paramObj
}

func (r BetaToolCodeInterpreterContainerCodeInterpreterToolAutoParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaToolCodeInterpreterContainerCodeInterpreterToolAutoParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaToolCodeInterpreterContainerCodeInterpreterToolAutoParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaToolCodeInterpreterContainerCodeInterpreterToolAutoParam](
		"memory_limit", "1g", "4g", "16g", "64g",
	)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnionParam struct {
	OfDisabled  *BetaContainerNetworkPolicyDisabledParam  `json:",omitzero,inline"`
	OfAllowlist *BetaContainerNetworkPolicyAllowlistParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnionParam) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfDisabled, u.OfAllowlist)
}
func (u *BetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnionParam) asAny() any {
	if !param.IsOmitted(u.OfDisabled) {
		return u.OfDisabled
	} else if !param.IsOmitted(u.OfAllowlist) {
		return u.OfAllowlist
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnionParam) GetAllowedDomains() []string {
	if vt := u.OfAllowlist; vt != nil {
		return vt.AllowedDomains
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnionParam) GetDomainSecrets() []BetaContainerNetworkPolicyDomainSecretParam {
	if vt := u.OfAllowlist; vt != nil {
		return vt.DomainSecrets
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnionParam) GetType() *string {
	if vt := u.OfDisabled; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfAllowlist; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

func init() {
	apijson.RegisterUnion[BetaToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnionParam](
		"type",
		apijson.Discriminator[BetaContainerNetworkPolicyDisabledParam]("disabled"),
		apijson.Discriminator[BetaContainerNetworkPolicyAllowlistParam]("allowlist"),
	)
}

func NewBetaToolProgrammaticToolCallingParam() BetaToolProgrammaticToolCallingParam {
	return BetaToolProgrammaticToolCallingParam{
		Type: "programmatic_tool_calling",
	}
}

// This struct has a constant value, construct it with
// [NewBetaToolProgrammaticToolCallingParam].
type BetaToolProgrammaticToolCallingParam struct {
	// The type of the tool. Always `programmatic_tool_calling`.
	Type constant.ProgrammaticToolCalling `json:"type" default:"programmatic_tool_calling"`
	paramObj
}

func (r BetaToolProgrammaticToolCallingParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaToolProgrammaticToolCallingParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaToolProgrammaticToolCallingParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// A tool that generates images using the GPT image models.
//
// The property Type is required.
type BetaToolImageGenerationParam struct {
	// Compression level for the output image. Default: 100.
	OutputCompression param.Opt[int64] `json:"output_compression,omitzero"`
	// Number of partial images to generate in streaming mode, from 0 (default value)
	// to 3.
	PartialImages param.Opt[int64] `json:"partial_images,omitzero"`
	// Control how much effort the model will exert to match the style and features,
	// especially facial features, of input images. This parameter is only supported
	// for `gpt-image-1` and `gpt-image-1.5` and later models, unsupported for
	// `gpt-image-1-mini`. Supports `high` and `low`. Defaults to `low`.
	//
	// Any of "high", "low".
	InputFidelity string `json:"input_fidelity,omitzero"`
	// Whether to generate a new image or edit an existing image. Default: `auto`.
	//
	// Any of "generate", "edit", "auto".
	Action string `json:"action,omitzero"`
	// Allows to set transparency for the background of the generated image(s). This
	// parameter is only supported for GPT image models that support transparent
	// backgrounds. Must be one of `transparent`, `opaque`, or `auto` (default value).
	// When `auto` is used, the model will automatically determine the best background
	// for the image.
	//
	// `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent
	// backgrounds. Requests with `background` set to `transparent` will return an
	// error for these models; use `opaque` or `auto` instead.
	//
	// If `transparent`, the output format needs to support transparency, so it should
	// be set to either `png` (default value) or `webp`.
	//
	// Any of "transparent", "opaque", "auto".
	Background string `json:"background,omitzero"`
	// Optional mask for inpainting. Contains `image_url` (string, optional) and
	// `file_id` (string, optional).
	InputImageMask BetaToolImageGenerationInputImageMaskParam `json:"input_image_mask,omitzero"`
	// The image generation model to use. Default: `gpt-image-1`.
	Model string `json:"model,omitzero"`
	// Moderation level for the generated image. Default: `auto`.
	//
	// Any of "auto", "low".
	Moderation string `json:"moderation,omitzero"`
	// The output format of the generated image. One of `png`, `webp`, or `jpeg`.
	// Default: `png`.
	//
	// Any of "png", "webp", "jpeg".
	OutputFormat string `json:"output_format,omitzero"`
	// The quality of the generated image. One of `low`, `medium`, `high`, or `auto`.
	// Default: `auto`.
	//
	// Any of "low", "medium", "high", "auto".
	Quality string `json:"quality,omitzero"`
	// The size of the generated images. For `gpt-image-2` and
	// `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT`
	// strings, for example `1536x864`. Width and height must both be divisible by 16
	// and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above
	// `2560x1440` are experimental, and the maximum supported resolution is
	// `3840x2160`. The requested size must also satisfy the model's current pixel and
	// edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are
	// supported by the GPT image models; `auto` is supported for models that allow
	// automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or
	// `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or
	// `1024x1792`.
	Size string `json:"size,omitzero"`
	// The type of the image generation tool. Always `image_generation`.
	//
	// This field can be elided, and will marshal its zero value as "image_generation".
	Type constant.ImageGeneration `json:"type" default:"image_generation"`
	paramObj
}

func (r BetaToolImageGenerationParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaToolImageGenerationParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaToolImageGenerationParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaToolImageGenerationParam](
		"action", "generate", "edit", "auto",
	)
	apijson.RegisterFieldValidator[BetaToolImageGenerationParam](
		"background", "transparent", "opaque", "auto",
	)
	apijson.RegisterFieldValidator[BetaToolImageGenerationParam](
		"input_fidelity", "high", "low",
	)
	apijson.RegisterFieldValidator[BetaToolImageGenerationParam](
		"moderation", "auto", "low",
	)
	apijson.RegisterFieldValidator[BetaToolImageGenerationParam](
		"output_format", "png", "webp", "jpeg",
	)
	apijson.RegisterFieldValidator[BetaToolImageGenerationParam](
		"quality", "low", "medium", "high", "auto",
	)
}

// Optional mask for inpainting. Contains `image_url` (string, optional) and
// `file_id` (string, optional).
type BetaToolImageGenerationInputImageMaskParam struct {
	// File ID for the mask image.
	FileID param.Opt[string] `json:"file_id,omitzero"`
	// Base64-encoded mask image.
	ImageURL param.Opt[string] `json:"image_url,omitzero"`
	paramObj
}

func (r BetaToolImageGenerationInputImageMaskParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaToolImageGenerationInputImageMaskParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaToolImageGenerationInputImageMaskParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func NewBetaToolLocalShellParam() BetaToolLocalShellParam {
	return BetaToolLocalShellParam{
		Type: "local_shell",
	}
}

// A tool that allows the model to execute shell commands in a local environment.
//
// This struct has a constant value, construct it with
// [NewBetaToolLocalShellParam].
type BetaToolLocalShellParam struct {
	// The type of the local shell tool. Always `local_shell`.
	Type constant.LocalShell `json:"type" default:"local_shell"`
	paramObj
}

func (r BetaToolLocalShellParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaToolLocalShellParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaToolLocalShellParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Constrains the tools available to the model to a pre-defined set.
type BetaToolChoiceAllowed struct {
	// Constrains the tools available to the model to a pre-defined set.
	//
	// `auto` allows the model to pick from among the allowed tools and generate a
	// message.
	//
	// `required` requires the model to call one or more of the allowed tools.
	//
	// Any of "auto", "required".
	Mode BetaToolChoiceAllowedMode `json:"mode" api:"required"`
	// A list of tool definitions that the model should be allowed to call.
	//
	// For the Responses API, the list of tool definitions might look like:
	//
	// ```json
	// [
	//
	//	{ "type": "function", "name": "get_weather" },
	//	{ "type": "mcp", "server_label": "deepwiki" },
	//	{ "type": "image_generation" }
	//
	// ]
	// ```
	Tools []map[string]any `json:"tools" api:"required"`
	// Allowed tool configuration type. Always `allowed_tools`.
	Type constant.AllowedTools `json:"type" default:"allowed_tools"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Mode        respjson.Field
		Tools       respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaToolChoiceAllowed) RawJSON() string { return r.JSON.raw }
func (r *BetaToolChoiceAllowed) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaToolChoiceAllowed to a BetaToolChoiceAllowedParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaToolChoiceAllowedParam.Overrides()
func (r BetaToolChoiceAllowed) ToParam() BetaToolChoiceAllowedParam {
	return param.Override[BetaToolChoiceAllowedParam](json.RawMessage(r.RawJSON()))
}

// Constrains the tools available to the model to a pre-defined set.
//
// `auto` allows the model to pick from among the allowed tools and generate a
// message.
//
// `required` requires the model to call one or more of the allowed tools.
type BetaToolChoiceAllowedMode string

const (
	BetaToolChoiceAllowedModeAuto     BetaToolChoiceAllowedMode = "auto"
	BetaToolChoiceAllowedModeRequired BetaToolChoiceAllowedMode = "required"
)

// Constrains the tools available to the model to a pre-defined set.
//
// The properties Mode, Tools, Type are required.
type BetaToolChoiceAllowedParam struct {
	// Constrains the tools available to the model to a pre-defined set.
	//
	// `auto` allows the model to pick from among the allowed tools and generate a
	// message.
	//
	// `required` requires the model to call one or more of the allowed tools.
	//
	// Any of "auto", "required".
	Mode BetaToolChoiceAllowedMode `json:"mode,omitzero" api:"required"`
	// A list of tool definitions that the model should be allowed to call.
	//
	// For the Responses API, the list of tool definitions might look like:
	//
	// ```json
	// [
	//
	//	{ "type": "function", "name": "get_weather" },
	//	{ "type": "mcp", "server_label": "deepwiki" },
	//	{ "type": "image_generation" }
	//
	// ]
	// ```
	Tools []map[string]any `json:"tools,omitzero" api:"required"`
	// Allowed tool configuration type. Always `allowed_tools`.
	//
	// This field can be elided, and will marshal its zero value as "allowed_tools".
	Type constant.AllowedTools `json:"type" default:"allowed_tools"`
	paramObj
}

func (r BetaToolChoiceAllowedParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaToolChoiceAllowedParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaToolChoiceAllowedParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Forces the model to call the apply_patch tool when executing a tool call.
type BetaToolChoiceApplyPatch struct {
	// The tool to call. Always `apply_patch`.
	Type constant.ApplyPatch `json:"type" default:"apply_patch"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaToolChoiceApplyPatch) RawJSON() string { return r.JSON.raw }
func (r *BetaToolChoiceApplyPatch) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaToolChoiceApplyPatch to a
// BetaToolChoiceApplyPatchParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaToolChoiceApplyPatchParam.Overrides()
func (r BetaToolChoiceApplyPatch) ToParam() BetaToolChoiceApplyPatchParam {
	return param.Override[BetaToolChoiceApplyPatchParam](json.RawMessage(r.RawJSON()))
}

func NewBetaToolChoiceApplyPatchParam() BetaToolChoiceApplyPatchParam {
	return BetaToolChoiceApplyPatchParam{
		Type: "apply_patch",
	}
}

// Forces the model to call the apply_patch tool when executing a tool call.
//
// This struct has a constant value, construct it with
// [NewBetaToolChoiceApplyPatchParam].
type BetaToolChoiceApplyPatchParam struct {
	// The tool to call. Always `apply_patch`.
	Type constant.ApplyPatch `json:"type" default:"apply_patch"`
	paramObj
}

func (r BetaToolChoiceApplyPatchParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaToolChoiceApplyPatchParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaToolChoiceApplyPatchParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Use this option to force the model to call a specific custom tool.
type BetaToolChoiceCustom struct {
	// The name of the custom tool to call.
	Name string `json:"name" api:"required"`
	// For custom tool calling, the type is always `custom`.
	Type constant.Custom `json:"type" default:"custom"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Name        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaToolChoiceCustom) RawJSON() string { return r.JSON.raw }
func (r *BetaToolChoiceCustom) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaToolChoiceCustom to a BetaToolChoiceCustomParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaToolChoiceCustomParam.Overrides()
func (r BetaToolChoiceCustom) ToParam() BetaToolChoiceCustomParam {
	return param.Override[BetaToolChoiceCustomParam](json.RawMessage(r.RawJSON()))
}

// Use this option to force the model to call a specific custom tool.
//
// The properties Name, Type are required.
type BetaToolChoiceCustomParam struct {
	// The name of the custom tool to call.
	Name string `json:"name" api:"required"`
	// For custom tool calling, the type is always `custom`.
	//
	// This field can be elided, and will marshal its zero value as "custom".
	Type constant.Custom `json:"type" default:"custom"`
	paramObj
}

func (r BetaToolChoiceCustomParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaToolChoiceCustomParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaToolChoiceCustomParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Use this option to force the model to call a specific function.
type BetaToolChoiceFunction struct {
	// The name of the function to call.
	Name string `json:"name" api:"required"`
	// For function calling, the type is always `function`.
	Type constant.Function `json:"type" default:"function"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Name        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaToolChoiceFunction) RawJSON() string { return r.JSON.raw }
func (r *BetaToolChoiceFunction) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaToolChoiceFunction to a BetaToolChoiceFunctionParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaToolChoiceFunctionParam.Overrides()
func (r BetaToolChoiceFunction) ToParam() BetaToolChoiceFunctionParam {
	return param.Override[BetaToolChoiceFunctionParam](json.RawMessage(r.RawJSON()))
}

// Use this option to force the model to call a specific function.
//
// The properties Name, Type are required.
type BetaToolChoiceFunctionParam struct {
	// The name of the function to call.
	Name string `json:"name" api:"required"`
	// For function calling, the type is always `function`.
	//
	// This field can be elided, and will marshal its zero value as "function".
	Type constant.Function `json:"type" default:"function"`
	paramObj
}

func (r BetaToolChoiceFunctionParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaToolChoiceFunctionParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaToolChoiceFunctionParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Use this option to force the model to call a specific tool on a remote MCP
// server.
type BetaToolChoiceMcp struct {
	// The label of the MCP server to use.
	ServerLabel string `json:"server_label" api:"required"`
	// For MCP tools, the type is always `mcp`.
	Type constant.Mcp `json:"type" default:"mcp"`
	// The name of the tool to call on the server.
	Name string `json:"name" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ServerLabel respjson.Field
		Type        respjson.Field
		Name        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaToolChoiceMcp) RawJSON() string { return r.JSON.raw }
func (r *BetaToolChoiceMcp) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaToolChoiceMcp to a BetaToolChoiceMcpParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaToolChoiceMcpParam.Overrides()
func (r BetaToolChoiceMcp) ToParam() BetaToolChoiceMcpParam {
	return param.Override[BetaToolChoiceMcpParam](json.RawMessage(r.RawJSON()))
}

// Use this option to force the model to call a specific tool on a remote MCP
// server.
//
// The properties ServerLabel, Type are required.
type BetaToolChoiceMcpParam struct {
	// The label of the MCP server to use.
	ServerLabel string `json:"server_label" api:"required"`
	// The name of the tool to call on the server.
	Name param.Opt[string] `json:"name,omitzero"`
	// For MCP tools, the type is always `mcp`.
	//
	// This field can be elided, and will marshal its zero value as "mcp".
	Type constant.Mcp `json:"type" default:"mcp"`
	paramObj
}

func (r BetaToolChoiceMcpParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaToolChoiceMcpParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaToolChoiceMcpParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Controls which (if any) tool is called by the model.
//
// `none` means the model will not call any tool and instead generates a message.
//
// `auto` means the model can pick between generating a message or calling one or
// more tools.
//
// `required` means the model must call one or more tools.
type BetaToolChoiceOptions string

const (
	BetaToolChoiceOptionsNone     BetaToolChoiceOptions = "none"
	BetaToolChoiceOptionsAuto     BetaToolChoiceOptions = "auto"
	BetaToolChoiceOptionsRequired BetaToolChoiceOptions = "required"
)

// Forces the model to call the shell tool when a tool call is required.
type BetaToolChoiceShell struct {
	// The tool to call. Always `shell`.
	Type constant.Shell `json:"type" default:"shell"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaToolChoiceShell) RawJSON() string { return r.JSON.raw }
func (r *BetaToolChoiceShell) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaToolChoiceShell to a BetaToolChoiceShellParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaToolChoiceShellParam.Overrides()
func (r BetaToolChoiceShell) ToParam() BetaToolChoiceShellParam {
	return param.Override[BetaToolChoiceShellParam](json.RawMessage(r.RawJSON()))
}

func NewBetaToolChoiceShellParam() BetaToolChoiceShellParam {
	return BetaToolChoiceShellParam{
		Type: "shell",
	}
}

// Forces the model to call the shell tool when a tool call is required.
//
// This struct has a constant value, construct it with
// [NewBetaToolChoiceShellParam].
type BetaToolChoiceShellParam struct {
	// The tool to call. Always `shell`.
	Type constant.Shell `json:"type" default:"shell"`
	paramObj
}

func (r BetaToolChoiceShellParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaToolChoiceShellParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaToolChoiceShellParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Indicates that the model should use a built-in tool to generate a response.
// [Learn more about built-in tools](https://platform.openai.com/docs/guides/tools).
type BetaToolChoiceTypes struct {
	// The type of hosted tool the model should to use. Learn more about
	// [built-in tools](https://platform.openai.com/docs/guides/tools).
	//
	// Allowed values are:
	//
	// - `file_search`
	// - `web_search_preview`
	// - `computer`
	// - `computer_use_preview`
	// - `computer_use`
	// - `code_interpreter`
	// - `image_generation`
	//
	// Any of "file_search", "web_search_preview", "computer", "computer_use_preview",
	// "computer_use", "web_search_preview_2025_03_11", "image_generation",
	// "code_interpreter".
	Type BetaToolChoiceTypesType `json:"type" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaToolChoiceTypes) RawJSON() string { return r.JSON.raw }
func (r *BetaToolChoiceTypes) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaToolChoiceTypes to a BetaToolChoiceTypesParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaToolChoiceTypesParam.Overrides()
func (r BetaToolChoiceTypes) ToParam() BetaToolChoiceTypesParam {
	return param.Override[BetaToolChoiceTypesParam](json.RawMessage(r.RawJSON()))
}

// The type of hosted tool the model should to use. Learn more about
// [built-in tools](https://platform.openai.com/docs/guides/tools).
//
// Allowed values are:
//
// - `file_search`
// - `web_search_preview`
// - `computer`
// - `computer_use_preview`
// - `computer_use`
// - `code_interpreter`
// - `image_generation`
type BetaToolChoiceTypesType string

const (
	BetaToolChoiceTypesTypeFileSearch                 BetaToolChoiceTypesType = "file_search"
	BetaToolChoiceTypesTypeWebSearchPreview           BetaToolChoiceTypesType = "web_search_preview"
	BetaToolChoiceTypesTypeComputer                   BetaToolChoiceTypesType = "computer"
	BetaToolChoiceTypesTypeComputerUsePreview         BetaToolChoiceTypesType = "computer_use_preview"
	BetaToolChoiceTypesTypeComputerUse                BetaToolChoiceTypesType = "computer_use"
	BetaToolChoiceTypesTypeWebSearchPreview2025_03_11 BetaToolChoiceTypesType = "web_search_preview_2025_03_11"
	BetaToolChoiceTypesTypeImageGeneration            BetaToolChoiceTypesType = "image_generation"
	BetaToolChoiceTypesTypeCodeInterpreter            BetaToolChoiceTypesType = "code_interpreter"
)

// Indicates that the model should use a built-in tool to generate a response.
// [Learn more about built-in tools](https://platform.openai.com/docs/guides/tools).
//
// The property Type is required.
type BetaToolChoiceTypesParam struct {
	// The type of hosted tool the model should to use. Learn more about
	// [built-in tools](https://platform.openai.com/docs/guides/tools).
	//
	// Allowed values are:
	//
	// - `file_search`
	// - `web_search_preview`
	// - `computer`
	// - `computer_use_preview`
	// - `computer_use`
	// - `code_interpreter`
	// - `image_generation`
	//
	// Any of "file_search", "web_search_preview", "computer", "computer_use_preview",
	// "computer_use", "web_search_preview_2025_03_11", "image_generation",
	// "code_interpreter".
	Type BetaToolChoiceTypesType `json:"type,omitzero" api:"required"`
	paramObj
}

func (r BetaToolChoiceTypesParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaToolChoiceTypesParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaToolChoiceTypesParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Hosted or BYOT tool search configuration for deferred tools.
type BetaToolSearchTool struct {
	// The type of the tool. Always `tool_search`.
	Type constant.ToolSearch `json:"type" default:"tool_search"`
	// Description shown to the model for a client-executed tool search tool.
	Description string `json:"description" api:"nullable"`
	// Whether tool search is executed by the server or by the client.
	//
	// Any of "server", "client".
	Execution BetaToolSearchToolExecution `json:"execution"`
	// Parameter schema for a client-executed tool search tool.
	Parameters any `json:"parameters" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		Description respjson.Field
		Execution   respjson.Field
		Parameters  respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaToolSearchTool) RawJSON() string { return r.JSON.raw }
func (r *BetaToolSearchTool) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaToolSearchTool to a BetaToolSearchToolParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaToolSearchToolParam.Overrides()
func (r BetaToolSearchTool) ToParam() BetaToolSearchToolParam {
	return param.Override[BetaToolSearchToolParam](json.RawMessage(r.RawJSON()))
}

// Whether tool search is executed by the server or by the client.
type BetaToolSearchToolExecution string

const (
	BetaToolSearchToolExecutionServer BetaToolSearchToolExecution = "server"
	BetaToolSearchToolExecutionClient BetaToolSearchToolExecution = "client"
)

// Hosted or BYOT tool search configuration for deferred tools.
//
// The property Type is required.
type BetaToolSearchToolParam struct {
	// Description shown to the model for a client-executed tool search tool.
	Description param.Opt[string] `json:"description,omitzero"`
	// Parameter schema for a client-executed tool search tool.
	Parameters any `json:"parameters,omitzero"`
	// Whether tool search is executed by the server or by the client.
	//
	// Any of "server", "client".
	Execution BetaToolSearchToolExecution `json:"execution,omitzero"`
	// The type of the tool. Always `tool_search`.
	//
	// This field can be elided, and will marshal its zero value as "tool_search".
	Type constant.ToolSearch `json:"type" default:"tool_search"`
	paramObj
}

func (r BetaToolSearchToolParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaToolSearchToolParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaToolSearchToolParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// This tool searches the web for relevant results to use in a response. Learn more
// about the
// [web search tool](https://platform.openai.com/docs/guides/tools-web-search).
type BetaWebSearchPreviewTool struct {
	// The type of the web search tool. One of `web_search_preview` or
	// `web_search_preview_2025_03_11`.
	//
	// Any of "web_search_preview", "web_search_preview_2025_03_11".
	Type BetaWebSearchPreviewToolType `json:"type" api:"required"`
	// Any of "text", "image".
	SearchContentTypes []string `json:"search_content_types"`
	// High level guidance for the amount of context window space to use for the
	// search. One of `low`, `medium`, or `high`. `medium` is the default.
	//
	// Any of "low", "medium", "high".
	SearchContextSize BetaWebSearchPreviewToolSearchContextSize `json:"search_context_size"`
	// The user's location.
	UserLocation BetaWebSearchPreviewToolUserLocation `json:"user_location" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type               respjson.Field
		SearchContentTypes respjson.Field
		SearchContextSize  respjson.Field
		UserLocation       respjson.Field
		ExtraFields        map[string]respjson.Field
		raw                string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaWebSearchPreviewTool) RawJSON() string { return r.JSON.raw }
func (r *BetaWebSearchPreviewTool) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaWebSearchPreviewTool to a
// BetaWebSearchPreviewToolParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaWebSearchPreviewToolParam.Overrides()
func (r BetaWebSearchPreviewTool) ToParam() BetaWebSearchPreviewToolParam {
	return param.Override[BetaWebSearchPreviewToolParam](json.RawMessage(r.RawJSON()))
}

// The type of the web search tool. One of `web_search_preview` or
// `web_search_preview_2025_03_11`.
type BetaWebSearchPreviewToolType string

const (
	BetaWebSearchPreviewToolTypeWebSearchPreview           BetaWebSearchPreviewToolType = "web_search_preview"
	BetaWebSearchPreviewToolTypeWebSearchPreview2025_03_11 BetaWebSearchPreviewToolType = "web_search_preview_2025_03_11"
)

// High level guidance for the amount of context window space to use for the
// search. One of `low`, `medium`, or `high`. `medium` is the default.
type BetaWebSearchPreviewToolSearchContextSize string

const (
	BetaWebSearchPreviewToolSearchContextSizeLow    BetaWebSearchPreviewToolSearchContextSize = "low"
	BetaWebSearchPreviewToolSearchContextSizeMedium BetaWebSearchPreviewToolSearchContextSize = "medium"
	BetaWebSearchPreviewToolSearchContextSizeHigh   BetaWebSearchPreviewToolSearchContextSize = "high"
)

// The user's location.
type BetaWebSearchPreviewToolUserLocation struct {
	// The type of location approximation. Always `approximate`.
	Type constant.Approximate `json:"type" default:"approximate"`
	// Free text input for the city of the user, e.g. `San Francisco`.
	City string `json:"city" api:"nullable"`
	// The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of
	// the user, e.g. `US`.
	Country string `json:"country" api:"nullable"`
	// Free text input for the region of the user, e.g. `California`.
	Region string `json:"region" api:"nullable"`
	// The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the
	// user, e.g. `America/Los_Angeles`.
	Timezone string `json:"timezone" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		City        respjson.Field
		Country     respjson.Field
		Region      respjson.Field
		Timezone    respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaWebSearchPreviewToolUserLocation) RawJSON() string { return r.JSON.raw }
func (r *BetaWebSearchPreviewToolUserLocation) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// This tool searches the web for relevant results to use in a response. Learn more
// about the
// [web search tool](https://platform.openai.com/docs/guides/tools-web-search).
//
// The property Type is required.
type BetaWebSearchPreviewToolParam struct {
	// The type of the web search tool. One of `web_search_preview` or
	// `web_search_preview_2025_03_11`.
	//
	// Any of "web_search_preview", "web_search_preview_2025_03_11".
	Type BetaWebSearchPreviewToolType `json:"type,omitzero" api:"required"`
	// The user's location.
	UserLocation BetaWebSearchPreviewToolUserLocationParam `json:"user_location,omitzero"`
	// Any of "text", "image".
	SearchContentTypes []string `json:"search_content_types,omitzero"`
	// High level guidance for the amount of context window space to use for the
	// search. One of `low`, `medium`, or `high`. `medium` is the default.
	//
	// Any of "low", "medium", "high".
	SearchContextSize BetaWebSearchPreviewToolSearchContextSize `json:"search_context_size,omitzero"`
	paramObj
}

func (r BetaWebSearchPreviewToolParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaWebSearchPreviewToolParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaWebSearchPreviewToolParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The user's location.
//
// The property Type is required.
type BetaWebSearchPreviewToolUserLocationParam struct {
	// Free text input for the city of the user, e.g. `San Francisco`.
	City param.Opt[string] `json:"city,omitzero"`
	// The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of
	// the user, e.g. `US`.
	Country param.Opt[string] `json:"country,omitzero"`
	// Free text input for the region of the user, e.g. `California`.
	Region param.Opt[string] `json:"region,omitzero"`
	// The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the
	// user, e.g. `America/Los_Angeles`.
	Timezone param.Opt[string] `json:"timezone,omitzero"`
	// The type of location approximation. Always `approximate`.
	//
	// This field can be elided, and will marshal its zero value as "approximate".
	Type constant.Approximate `json:"type" default:"approximate"`
	paramObj
}

func (r BetaWebSearchPreviewToolUserLocationParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaWebSearchPreviewToolUserLocationParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaWebSearchPreviewToolUserLocationParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Search the Internet for sources related to the prompt. Learn more about the
// [web search tool](https://platform.openai.com/docs/guides/tools-web-search).
type BetaWebSearchTool struct {
	// The type of the web search tool. One of `web_search` or `web_search_2025_08_26`.
	//
	// Any of "web_search", "web_search_2025_08_26".
	Type BetaWebSearchToolType `json:"type" api:"required"`
	// Filters for the search.
	Filters BetaWebSearchToolFilters `json:"filters" api:"nullable"`
	// High level guidance for the amount of context window space to use for the
	// search. One of `low`, `medium`, or `high`. `medium` is the default.
	//
	// Any of "low", "medium", "high".
	SearchContextSize BetaWebSearchToolSearchContextSize `json:"search_context_size"`
	// The approximate location of the user.
	UserLocation BetaWebSearchToolUserLocation `json:"user_location" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type              respjson.Field
		Filters           respjson.Field
		SearchContextSize respjson.Field
		UserLocation      respjson.Field
		ExtraFields       map[string]respjson.Field
		raw               string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaWebSearchTool) RawJSON() string { return r.JSON.raw }
func (r *BetaWebSearchTool) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// ToParam converts this BetaWebSearchTool to a BetaWebSearchToolParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// BetaWebSearchToolParam.Overrides()
func (r BetaWebSearchTool) ToParam() BetaWebSearchToolParam {
	return param.Override[BetaWebSearchToolParam](json.RawMessage(r.RawJSON()))
}

// The type of the web search tool. One of `web_search` or `web_search_2025_08_26`.
type BetaWebSearchToolType string

const (
	BetaWebSearchToolTypeWebSearch           BetaWebSearchToolType = "web_search"
	BetaWebSearchToolTypeWebSearch2025_08_26 BetaWebSearchToolType = "web_search_2025_08_26"
)

// Filters for the search.
type BetaWebSearchToolFilters struct {
	// Allowed domains for the search. If not provided, all domains are allowed.
	// Subdomains of the provided domains are allowed as well.
	//
	// Example: `["pubmed.ncbi.nlm.nih.gov"]`
	AllowedDomains []string `json:"allowed_domains" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AllowedDomains respjson.Field
		ExtraFields    map[string]respjson.Field
		raw            string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaWebSearchToolFilters) RawJSON() string { return r.JSON.raw }
func (r *BetaWebSearchToolFilters) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// High level guidance for the amount of context window space to use for the
// search. One of `low`, `medium`, or `high`. `medium` is the default.
type BetaWebSearchToolSearchContextSize string

const (
	BetaWebSearchToolSearchContextSizeLow    BetaWebSearchToolSearchContextSize = "low"
	BetaWebSearchToolSearchContextSizeMedium BetaWebSearchToolSearchContextSize = "medium"
	BetaWebSearchToolSearchContextSizeHigh   BetaWebSearchToolSearchContextSize = "high"
)

// The approximate location of the user.
type BetaWebSearchToolUserLocation struct {
	// Free text input for the city of the user, e.g. `San Francisco`.
	City string `json:"city" api:"nullable"`
	// The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of
	// the user, e.g. `US`.
	Country string `json:"country" api:"nullable"`
	// Free text input for the region of the user, e.g. `California`.
	Region string `json:"region" api:"nullable"`
	// The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the
	// user, e.g. `America/Los_Angeles`.
	Timezone string `json:"timezone" api:"nullable"`
	// The type of location approximation. Always `approximate`.
	//
	// Any of "approximate".
	Type string `json:"type"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		City        respjson.Field
		Country     respjson.Field
		Region      respjson.Field
		Timezone    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		raw         string
	} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BetaWebSearchToolUserLocation) RawJSON() string { return r.JSON.raw }
func (r *BetaWebSearchToolUserLocation) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Search the Internet for sources related to the prompt. Learn more about the
// [web search tool](https://platform.openai.com/docs/guides/tools-web-search).
//
// The property Type is required.
type BetaWebSearchToolParam struct {
	// The type of the web search tool. One of `web_search` or `web_search_2025_08_26`.
	//
	// Any of "web_search", "web_search_2025_08_26".
	Type BetaWebSearchToolType `json:"type,omitzero" api:"required"`
	// Filters for the search.
	Filters BetaWebSearchToolFiltersParam `json:"filters,omitzero"`
	// The approximate location of the user.
	UserLocation BetaWebSearchToolUserLocationParam `json:"user_location,omitzero"`
	// High level guidance for the amount of context window space to use for the
	// search. One of `low`, `medium`, or `high`. `medium` is the default.
	//
	// Any of "low", "medium", "high".
	SearchContextSize BetaWebSearchToolSearchContextSize `json:"search_context_size,omitzero"`
	paramObj
}

func (r BetaWebSearchToolParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaWebSearchToolParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaWebSearchToolParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Filters for the search.
type BetaWebSearchToolFiltersParam struct {
	// Allowed domains for the search. If not provided, all domains are allowed.
	// Subdomains of the provided domains are allowed as well.
	//
	// Example: `["pubmed.ncbi.nlm.nih.gov"]`
	AllowedDomains []string `json:"allowed_domains,omitzero"`
	paramObj
}

func (r BetaWebSearchToolFiltersParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaWebSearchToolFiltersParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaWebSearchToolFiltersParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The approximate location of the user.
type BetaWebSearchToolUserLocationParam struct {
	// Free text input for the city of the user, e.g. `San Francisco`.
	City param.Opt[string] `json:"city,omitzero"`
	// The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of
	// the user, e.g. `US`.
	Country param.Opt[string] `json:"country,omitzero"`
	// Free text input for the region of the user, e.g. `California`.
	Region param.Opt[string] `json:"region,omitzero"`
	// The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the
	// user, e.g. `America/Los_Angeles`.
	Timezone param.Opt[string] `json:"timezone,omitzero"`
	// The type of location approximation. Always `approximate`.
	//
	// Any of "approximate".
	Type string `json:"type,omitzero"`
	paramObj
}

func (r BetaWebSearchToolUserLocationParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaWebSearchToolUserLocationParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaWebSearchToolUserLocationParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaWebSearchToolUserLocationParam](
		"type", "approximate",
	)
}

type BetaResponseNewParams struct {
	// Whether to run the model response in the background.
	// [Learn more](https://platform.openai.com/docs/guides/background).
	Background param.Opt[bool] `json:"background,omitzero"`
	// A system (or developer) message inserted into the model's context.
	//
	// When using along with `previous_response_id`, the instructions from a previous
	// response will not be carried over to the next response. This makes it simple to
	// swap out system (or developer) messages in new responses.
	Instructions param.Opt[string] `json:"instructions,omitzero"`
	// An upper bound for the number of tokens that can be generated for a response,
	// including visible output tokens and
	// [reasoning tokens](https://platform.openai.com/docs/guides/reasoning).
	MaxOutputTokens param.Opt[int64] `json:"max_output_tokens,omitzero"`
	// The maximum number of total calls to built-in tools that can be processed in a
	// response. This maximum number applies across all built-in tool calls, not per
	// individual tool. Any further attempts to call a tool by the model will be
	// ignored.
	MaxToolCalls param.Opt[int64] `json:"max_tool_calls,omitzero"`
	// Whether to allow the model to run tool calls in parallel.
	ParallelToolCalls param.Opt[bool] `json:"parallel_tool_calls,omitzero"`
	// The unique ID of the previous response to the model. Use this to create
	// multi-turn conversations. Learn more about
	// [conversation state](https://platform.openai.com/docs/guides/conversation-state).
	// Cannot be used in conjunction with `conversation`.
	PreviousResponseID param.Opt[string] `json:"previous_response_id,omitzero"`
	// Used by OpenAI to cache responses for similar requests to optimize your cache
	// hit rates. Replaces the `user` field.
	// [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
	PromptCacheKey param.Opt[string] `json:"prompt_cache_key,omitzero"`
	// A stable identifier used to help detect users of your application that may be
	// violating OpenAI's usage policies. The IDs should be a string that uniquely
	// identifies each user, with a maximum length of 64 characters. We recommend
	// hashing their username or email address, in order to avoid sending us any
	// identifying information.
	// [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
	SafetyIdentifier param.Opt[string] `json:"safety_identifier,omitzero"`
	// Whether to store the generated model response for later retrieval via API.
	Store param.Opt[bool] `json:"store,omitzero"`
	// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
	// make the output more random, while lower values like 0.2 will make it more
	// focused and deterministic. We generally recommend altering this or `top_p` but
	// not both.
	Temperature param.Opt[float64] `json:"temperature,omitzero"`
	// An integer between 0 and 20 specifying the maximum number of most likely tokens
	// to return at each token position, each with an associated log probability. In
	// some cases, the number of returned tokens may be fewer than requested.
	TopLogprobs param.Opt[int64] `json:"top_logprobs,omitzero"`
	// An alternative to sampling with temperature, called nucleus sampling, where the
	// model considers the results of the tokens with top_p probability mass. So 0.1
	// means only the tokens comprising the top 10% probability mass are considered.
	//
	// We generally recommend altering this or `temperature` but not both.
	TopP param.Opt[float64] `json:"top_p,omitzero"`
	// This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
	// `prompt_cache_key` instead to maintain caching optimizations. A stable
	// identifier for your end-users. Used to boost cache hit rates by better bucketing
	// similar requests and to help OpenAI detect and prevent abuse.
	// [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
	User param.Opt[string] `json:"user,omitzero"`
	// Context management configuration for this request.
	ContextManagement []BetaResponseNewParamsContextManagement `json:"context_management,omitzero"`
	// The conversation that this response belongs to. Items from this conversation are
	// prepended to `input_items` for this response request. Input items and output
	// items from this response are automatically added to this conversation after this
	// response completes.
	Conversation BetaResponseNewParamsConversationUnion `json:"conversation,omitzero"`
	// Specify additional output data to include in the model response. Currently
	// supported values are:
	//
	//   - `web_search_call.action.sources`: Include the sources of the web search tool
	//     call.
	//   - `code_interpreter_call.outputs`: Includes the outputs of python code execution
	//     in code interpreter tool call items.
	//   - `computer_call_output.output.image_url`: Include image urls from the computer
	//     call output.
	//   - `file_search_call.results`: Include the search results of the file search tool
	//     call.
	//   - `message.input_image.image_url`: Include image urls from the input message.
	//   - `message.output_text.logprobs`: Include logprobs with assistant messages.
	//   - `reasoning.encrypted_content`: Includes an encrypted version of reasoning
	//     tokens in reasoning item outputs. This enables reasoning items to be used in
	//     multi-turn conversations when using the Responses API statelessly (like when
	//     the `store` parameter is set to `false`, or when an organization is enrolled
	//     in the zero data retention program).
	Include []BetaResponseIncludable `json:"include,omitzero"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata map[string]string `json:"metadata,omitzero"`
	// Configuration for running moderation on the input and output of this response.
	Moderation BetaResponseNewParamsModeration `json:"moderation,omitzero"`
	// Configuration for server-hosted multi-agent execution.
	MultiAgent BetaResponseNewParamsMultiAgent `json:"multi_agent,omitzero"`
	// Reference to a prompt template and its variables.
	// [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
	Prompt BetaResponsePromptParam `json:"prompt,omitzero"`
	// Deprecated. Use `prompt_cache_options.ttl` instead.
	//
	// The retention policy for the prompt cache. Set to `24h` to enable extended
	// prompt caching, which keeps cached prefixes active for longer, up to a maximum
	// of 24 hours.
	// [Learn more](https://platform.openai.com/docs/guides/prompt-caching#prompt-cache-retention).
	// This field expresses a maximum retention policy, while
	// `prompt_cache_options.ttl` expresses a minimum cache lifetime. The two fields
	// are independent and do not interact. For `gpt-5.5`, `gpt-5.5-pro`, and future
	// models, only `24h` is supported.
	//
	// For older models that support both `in_memory` and `24h`, the default depends on
	// your organization's data retention policy:
	//
	//   - Organizations without ZDR enabled default to `24h`.
	//   - Organizations with ZDR enabled default to `in_memory` when
	//     `prompt_cache_retention` is not specified.
	//
	// Any of "in_memory", "24h".
	PromptCacheRetention BetaResponseNewParamsPromptCacheRetention `json:"prompt_cache_retention,omitzero"`
	// **gpt-5 and o-series models only**
	//
	// Configuration options for
	// [reasoning models](https://platform.openai.com/docs/guides/reasoning).
	Reasoning BetaResponseNewParamsReasoning `json:"reasoning,omitzero"`
	// Specifies the processing type used for serving the request.
	//
	//   - If set to 'auto', then the request will be processed with the service tier
	//     configured in the Project settings. Unless otherwise configured, the Project
	//     will use 'default'.
	//   - If set to 'default', then the request will be processed with the standard
	//     pricing and performance for the selected model.
	//   - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
	//     '[priority](https://openai.com/api-priority-processing/)', then the request
	//     will be processed with the corresponding service tier.
	//   - When not set, the default behavior is 'auto'.
	//
	// When the `service_tier` parameter is set, the response body will include the
	// `service_tier` value based on the processing mode actually used to serve the
	// request. This response value may be different from the value set in the
	// parameter.
	//
	// Any of "auto", "default", "flex", "scale", "priority".
	ServiceTier BetaResponseNewParamsServiceTier `json:"service_tier,omitzero"`
	// Options for streaming responses. Only set this when you set `stream: true`.
	StreamOptions BetaResponseNewParamsStreamOptions `json:"stream_options,omitzero"`
	// The truncation strategy to use for the model response.
	//
	//   - `auto`: If the input to this Response exceeds the model's context window size,
	//     the model will truncate the response to fit the context window by dropping
	//     items from the beginning of the conversation.
	//   - `disabled` (default): If the input size will exceed the context window size
	//     for a model, the request will fail with a 400 error.
	//
	// Any of "auto", "disabled".
	Truncation BetaResponseNewParamsTruncation `json:"truncation,omitzero"`
	// Text, image, or file inputs to the model, used to generate a response.
	//
	// Learn more:
	//
	// - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
	// - [Image inputs](https://platform.openai.com/docs/guides/images)
	// - [File inputs](https://platform.openai.com/docs/guides/pdf-files)
	// - [Conversation state](https://platform.openai.com/docs/guides/conversation-state)
	// - [Function calling](https://platform.openai.com/docs/guides/function-calling)
	Input BetaResponseNewParamsInputUnion `json:"input,omitzero"`
	// Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a
	// wide range of models with different capabilities, performance characteristics,
	// and price points. Refer to the
	// [model guide](https://platform.openai.com/docs/models) to browse and compare
	// available models.
	Model BetaResponseNewParamsModel `json:"model,omitzero"`
	// Options for prompt caching. Supported for `gpt-5.6` and later models. By
	// default, OpenAI automatically chooses one implicit cache breakpoint. You can add
	// explicit breakpoints to content blocks with `prompt_cache_breakpoint`. Each
	// request can write up to four breakpoints. For cache matching, OpenAI considers
	// up to the latest 80 breakpoints in the conversation, without a content-block
	// lookback limit. Set `mode` to `explicit` to disable the implicit breakpoint. The
	// `ttl` defaults to `30m`, which is currently the only supported value. See the
	// [prompt caching guide](https://platform.openai.com/docs/guides/prompt-caching)
	// for current details.
	PromptCacheOptions BetaResponseNewParamsPromptCacheOptions `json:"prompt_cache_options,omitzero"`
	// Configuration options for a text response from the model. Can be plain text or
	// structured JSON data. Learn more:
	//
	// - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
	// - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
	Text BetaResponseTextConfigParam `json:"text,omitzero"`
	// How the model should select which tool (or tools) to use when generating a
	// response. See the `tools` parameter to see how to specify which tools the model
	// can call.
	ToolChoice BetaResponseNewParamsToolChoiceUnion `json:"tool_choice,omitzero"`
	// An array of tools the model may call while generating a response. You can
	// specify which tool to use by setting the `tool_choice` parameter.
	//
	// We support the following categories of tools:
	//
	//   - **Built-in tools**: Tools that are provided by OpenAI that extend the model's
	//     capabilities, like
	//     [web search](https://platform.openai.com/docs/guides/tools-web-search) or
	//     [file search](https://platform.openai.com/docs/guides/tools-file-search).
	//     Learn more about
	//     [built-in tools](https://platform.openai.com/docs/guides/tools).
	//   - **MCP Tools**: Integrations with third-party systems via custom MCP servers or
	//     predefined connectors such as Google Drive and SharePoint. Learn more about
	//     [MCP Tools](https://platform.openai.com/docs/guides/tools-connectors-mcp).
	//   - **Function calls (custom tools)**: Functions that are defined by you, enabling
	//     the model to call your own code with strongly typed arguments and outputs.
	//     Learn more about
	//     [function calling](https://platform.openai.com/docs/guides/function-calling).
	//     You can also use custom tools to call your own code.
	Tools []BetaToolUnionParam `json:"tools,omitzero"`
	// Any of "responses_multi_agent=v1".
	Betas []string `header:"openai-beta,omitzero" json:"-"`
	paramObj
}

func (r BetaResponseNewParams) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseNewParams
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseNewParams) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The property Type is required.
type BetaResponseNewParamsContextManagement struct {
	// The context management entry type. Currently only 'compaction' is supported.
	Type string `json:"type" api:"required"`
	// Token threshold at which compaction should be triggered for this entry.
	CompactThreshold param.Opt[int64] `json:"compact_threshold,omitzero"`
	paramObj
}

func (r BetaResponseNewParamsContextManagement) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseNewParamsContextManagement
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseNewParamsContextManagement) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseNewParamsConversationUnion struct {
	OfString             param.Opt[string]              `json:",omitzero,inline"`
	OfConversationObject *BetaResponseConversationParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseNewParamsConversationUnion) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfString, u.OfConversationObject)
}
func (u *BetaResponseNewParamsConversationUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseNewParamsConversationUnion) asAny() any {
	if !param.IsOmitted(u.OfString) {
		return &u.OfString.Value
	} else if !param.IsOmitted(u.OfConversationObject) {
		return u.OfConversationObject
	}
	return nil
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseNewParamsInputUnion struct {
	OfString        param.Opt[string]      `json:",omitzero,inline"`
	OfInputItemList BetaResponseInputParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseNewParamsInputUnion) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfString, u.OfInputItemList)
}
func (u *BetaResponseNewParamsInputUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseNewParamsInputUnion) asAny() any {
	if !param.IsOmitted(u.OfString) {
		return &u.OfString.Value
	} else if !param.IsOmitted(u.OfInputItemList) {
		return &u.OfInputItemList
	}
	return nil
}

// Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a
// wide range of models with different capabilities, performance characteristics,
// and price points. Refer to the
// [model guide](https://platform.openai.com/docs/models) to browse and compare
// available models.
type BetaResponseNewParamsModel string

const (
	BetaResponseNewParamsModelGPT5_6Sol                        BetaResponseNewParamsModel = "gpt-5.6-sol"
	BetaResponseNewParamsModelGPT5_6Terra                      BetaResponseNewParamsModel = "gpt-5.6-terra"
	BetaResponseNewParamsModelGPT5_6Luna                       BetaResponseNewParamsModel = "gpt-5.6-luna"
	BetaResponseNewParamsModelGPT5_4                           BetaResponseNewParamsModel = "gpt-5.4"
	BetaResponseNewParamsModelGPT5_4Mini                       BetaResponseNewParamsModel = "gpt-5.4-mini"
	BetaResponseNewParamsModelGPT5_4Nano                       BetaResponseNewParamsModel = "gpt-5.4-nano"
	BetaResponseNewParamsModelGPT5_4Mini2026_03_17             BetaResponseNewParamsModel = "gpt-5.4-mini-2026-03-17"
	BetaResponseNewParamsModelGPT5_4Nano2026_03_17             BetaResponseNewParamsModel = "gpt-5.4-nano-2026-03-17"
	BetaResponseNewParamsModelGPT5_3ChatLatest                 BetaResponseNewParamsModel = "gpt-5.3-chat-latest"
	BetaResponseNewParamsModelGPT5_2                           BetaResponseNewParamsModel = "gpt-5.2"
	BetaResponseNewParamsModelGPT5_2_2025_12_11                BetaResponseNewParamsModel = "gpt-5.2-2025-12-11"
	BetaResponseNewParamsModelGPT5_2ChatLatest                 BetaResponseNewParamsModel = "gpt-5.2-chat-latest"
	BetaResponseNewParamsModelGPT5_2Pro                        BetaResponseNewParamsModel = "gpt-5.2-pro"
	BetaResponseNewParamsModelGPT5_2Pro2025_12_11              BetaResponseNewParamsModel = "gpt-5.2-pro-2025-12-11"
	BetaResponseNewParamsModelGPT5_1                           BetaResponseNewParamsModel = "gpt-5.1"
	BetaResponseNewParamsModelGPT5_1_2025_11_13                BetaResponseNewParamsModel = "gpt-5.1-2025-11-13"
	BetaResponseNewParamsModelGPT5_1Codex                      BetaResponseNewParamsModel = "gpt-5.1-codex"
	BetaResponseNewParamsModelGPT5_1Mini                       BetaResponseNewParamsModel = "gpt-5.1-mini"
	BetaResponseNewParamsModelGPT5_1ChatLatest                 BetaResponseNewParamsModel = "gpt-5.1-chat-latest"
	BetaResponseNewParamsModelGPT5                             BetaResponseNewParamsModel = "gpt-5"
	BetaResponseNewParamsModelGPT5Mini                         BetaResponseNewParamsModel = "gpt-5-mini"
	BetaResponseNewParamsModelGPT5Nano                         BetaResponseNewParamsModel = "gpt-5-nano"
	BetaResponseNewParamsModelGPT5_2025_08_07                  BetaResponseNewParamsModel = "gpt-5-2025-08-07"
	BetaResponseNewParamsModelGPT5Mini2025_08_07               BetaResponseNewParamsModel = "gpt-5-mini-2025-08-07"
	BetaResponseNewParamsModelGPT5Nano2025_08_07               BetaResponseNewParamsModel = "gpt-5-nano-2025-08-07"
	BetaResponseNewParamsModelGPT5ChatLatest                   BetaResponseNewParamsModel = "gpt-5-chat-latest"
	BetaResponseNewParamsModelGPT4_1                           BetaResponseNewParamsModel = "gpt-4.1"
	BetaResponseNewParamsModelGPT4_1Mini                       BetaResponseNewParamsModel = "gpt-4.1-mini"
	BetaResponseNewParamsModelGPT4_1Nano                       BetaResponseNewParamsModel = "gpt-4.1-nano"
	BetaResponseNewParamsModelGPT4_1_2025_04_14                BetaResponseNewParamsModel = "gpt-4.1-2025-04-14"
	BetaResponseNewParamsModelGPT4_1Mini2025_04_14             BetaResponseNewParamsModel = "gpt-4.1-mini-2025-04-14"
	BetaResponseNewParamsModelGPT4_1Nano2025_04_14             BetaResponseNewParamsModel = "gpt-4.1-nano-2025-04-14"
	BetaResponseNewParamsModelO4Mini                           BetaResponseNewParamsModel = "o4-mini"
	BetaResponseNewParamsModelO4Mini2025_04_16                 BetaResponseNewParamsModel = "o4-mini-2025-04-16"
	BetaResponseNewParamsModelO3                               BetaResponseNewParamsModel = "o3"
	BetaResponseNewParamsModelO3_2025_04_16                    BetaResponseNewParamsModel = "o3-2025-04-16"
	BetaResponseNewParamsModelO3Mini                           BetaResponseNewParamsModel = "o3-mini"
	BetaResponseNewParamsModelO3Mini2025_01_31                 BetaResponseNewParamsModel = "o3-mini-2025-01-31"
	BetaResponseNewParamsModelO1                               BetaResponseNewParamsModel = "o1"
	BetaResponseNewParamsModelO1_2024_12_17                    BetaResponseNewParamsModel = "o1-2024-12-17"
	BetaResponseNewParamsModelO1Preview                        BetaResponseNewParamsModel = "o1-preview"
	BetaResponseNewParamsModelO1Preview2024_09_12              BetaResponseNewParamsModel = "o1-preview-2024-09-12"
	BetaResponseNewParamsModelO1Mini                           BetaResponseNewParamsModel = "o1-mini"
	BetaResponseNewParamsModelO1Mini2024_09_12                 BetaResponseNewParamsModel = "o1-mini-2024-09-12"
	BetaResponseNewParamsModelGPT4o                            BetaResponseNewParamsModel = "gpt-4o"
	BetaResponseNewParamsModelGPT4o2024_11_20                  BetaResponseNewParamsModel = "gpt-4o-2024-11-20"
	BetaResponseNewParamsModelGPT4o2024_08_06                  BetaResponseNewParamsModel = "gpt-4o-2024-08-06"
	BetaResponseNewParamsModelGPT4o2024_05_13                  BetaResponseNewParamsModel = "gpt-4o-2024-05-13"
	BetaResponseNewParamsModelGPT4oAudioPreview                BetaResponseNewParamsModel = "gpt-4o-audio-preview"
	BetaResponseNewParamsModelGPT4oAudioPreview2024_10_01      BetaResponseNewParamsModel = "gpt-4o-audio-preview-2024-10-01"
	BetaResponseNewParamsModelGPT4oAudioPreview2024_12_17      BetaResponseNewParamsModel = "gpt-4o-audio-preview-2024-12-17"
	BetaResponseNewParamsModelGPT4oAudioPreview2025_06_03      BetaResponseNewParamsModel = "gpt-4o-audio-preview-2025-06-03"
	BetaResponseNewParamsModelGPT4oMiniAudioPreview            BetaResponseNewParamsModel = "gpt-4o-mini-audio-preview"
	BetaResponseNewParamsModelGPT4oMiniAudioPreview2024_12_17  BetaResponseNewParamsModel = "gpt-4o-mini-audio-preview-2024-12-17"
	BetaResponseNewParamsModelGPT4oSearchPreview               BetaResponseNewParamsModel = "gpt-4o-search-preview"
	BetaResponseNewParamsModelGPT4oMiniSearchPreview           BetaResponseNewParamsModel = "gpt-4o-mini-search-preview"
	BetaResponseNewParamsModelGPT4oSearchPreview2025_03_11     BetaResponseNewParamsModel = "gpt-4o-search-preview-2025-03-11"
	BetaResponseNewParamsModelGPT4oMiniSearchPreview2025_03_11 BetaResponseNewParamsModel = "gpt-4o-mini-search-preview-2025-03-11"
	BetaResponseNewParamsModelChatgpt4oLatest                  BetaResponseNewParamsModel = "chatgpt-4o-latest"
	BetaResponseNewParamsModelCodexMiniLatest                  BetaResponseNewParamsModel = "codex-mini-latest"
	BetaResponseNewParamsModelGPT4oMini                        BetaResponseNewParamsModel = "gpt-4o-mini"
	BetaResponseNewParamsModelGPT4oMini2024_07_18              BetaResponseNewParamsModel = "gpt-4o-mini-2024-07-18"
	BetaResponseNewParamsModelGPT4Turbo                        BetaResponseNewParamsModel = "gpt-4-turbo"
	BetaResponseNewParamsModelGPT4Turbo2024_04_09              BetaResponseNewParamsModel = "gpt-4-turbo-2024-04-09"
	BetaResponseNewParamsModelGPT4_0125Preview                 BetaResponseNewParamsModel = "gpt-4-0125-preview"
	BetaResponseNewParamsModelGPT4TurboPreview                 BetaResponseNewParamsModel = "gpt-4-turbo-preview"
	BetaResponseNewParamsModelGPT4_1106Preview                 BetaResponseNewParamsModel = "gpt-4-1106-preview"
	BetaResponseNewParamsModelGPT4VisionPreview                BetaResponseNewParamsModel = "gpt-4-vision-preview"
	BetaResponseNewParamsModelGPT4                             BetaResponseNewParamsModel = "gpt-4"
	BetaResponseNewParamsModelGPT4_0314                        BetaResponseNewParamsModel = "gpt-4-0314"
	BetaResponseNewParamsModelGPT4_0613                        BetaResponseNewParamsModel = "gpt-4-0613"
	BetaResponseNewParamsModelGPT4_32k                         BetaResponseNewParamsModel = "gpt-4-32k"
	BetaResponseNewParamsModelGPT4_32k0314                     BetaResponseNewParamsModel = "gpt-4-32k-0314"
	BetaResponseNewParamsModelGPT4_32k0613                     BetaResponseNewParamsModel = "gpt-4-32k-0613"
	BetaResponseNewParamsModelGPT3_5Turbo                      BetaResponseNewParamsModel = "gpt-3.5-turbo"
	BetaResponseNewParamsModelGPT3_5Turbo16k                   BetaResponseNewParamsModel = "gpt-3.5-turbo-16k"
	BetaResponseNewParamsModelGPT3_5Turbo0301                  BetaResponseNewParamsModel = "gpt-3.5-turbo-0301"
	BetaResponseNewParamsModelGPT3_5Turbo0613                  BetaResponseNewParamsModel = "gpt-3.5-turbo-0613"
	BetaResponseNewParamsModelGPT3_5Turbo1106                  BetaResponseNewParamsModel = "gpt-3.5-turbo-1106"
	BetaResponseNewParamsModelGPT3_5Turbo0125                  BetaResponseNewParamsModel = "gpt-3.5-turbo-0125"
	BetaResponseNewParamsModelGPT3_5Turbo16k0613               BetaResponseNewParamsModel = "gpt-3.5-turbo-16k-0613"
	BetaResponseNewParamsModelO1Pro                            BetaResponseNewParamsModel = "o1-pro"
	BetaResponseNewParamsModelO1Pro2025_03_19                  BetaResponseNewParamsModel = "o1-pro-2025-03-19"
	BetaResponseNewParamsModelO3Pro                            BetaResponseNewParamsModel = "o3-pro"
	BetaResponseNewParamsModelO3Pro2025_06_10                  BetaResponseNewParamsModel = "o3-pro-2025-06-10"
	BetaResponseNewParamsModelO3DeepResearch                   BetaResponseNewParamsModel = "o3-deep-research"
	BetaResponseNewParamsModelO3DeepResearch2025_06_26         BetaResponseNewParamsModel = "o3-deep-research-2025-06-26"
	BetaResponseNewParamsModelO4MiniDeepResearch               BetaResponseNewParamsModel = "o4-mini-deep-research"
	BetaResponseNewParamsModelO4MiniDeepResearch2025_06_26     BetaResponseNewParamsModel = "o4-mini-deep-research-2025-06-26"
	BetaResponseNewParamsModelComputerUsePreview               BetaResponseNewParamsModel = "computer-use-preview"
	BetaResponseNewParamsModelComputerUsePreview2025_03_11     BetaResponseNewParamsModel = "computer-use-preview-2025-03-11"
	BetaResponseNewParamsModelGPT5Codex                        BetaResponseNewParamsModel = "gpt-5-codex"
	BetaResponseNewParamsModelGPT5Pro                          BetaResponseNewParamsModel = "gpt-5-pro"
	BetaResponseNewParamsModelGPT5Pro2025_10_06                BetaResponseNewParamsModel = "gpt-5-pro-2025-10-06"
	BetaResponseNewParamsModelGPT5_1CodexMax                   BetaResponseNewParamsModel = "gpt-5.1-codex-max"
)

// Configuration for running moderation on the input and output of this response.
//
// The property Model is required.
type BetaResponseNewParamsModeration struct {
	// The moderation model to use for moderated completions, e.g.
	// 'omni-moderation-latest'.
	Model string `json:"model" api:"required"`
	// The policy to apply to moderated response input and output.
	Policy BetaResponseNewParamsModerationPolicy `json:"policy,omitzero"`
	paramObj
}

func (r BetaResponseNewParamsModeration) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseNewParamsModeration
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseNewParamsModeration) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The policy to apply to moderated response input and output.
type BetaResponseNewParamsModerationPolicy struct {
	// The moderation policy for the response input.
	Input BetaResponseNewParamsModerationPolicyInput `json:"input,omitzero"`
	// The moderation policy for the response output.
	Output BetaResponseNewParamsModerationPolicyOutput `json:"output,omitzero"`
	paramObj
}

func (r BetaResponseNewParamsModerationPolicy) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseNewParamsModerationPolicy
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseNewParamsModerationPolicy) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The moderation policy for the response input.
//
// The property Mode is required.
type BetaResponseNewParamsModerationPolicyInput struct {
	// Any of "score", "block".
	Mode string `json:"mode,omitzero" api:"required"`
	paramObj
}

func (r BetaResponseNewParamsModerationPolicyInput) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseNewParamsModerationPolicyInput
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseNewParamsModerationPolicyInput) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaResponseNewParamsModerationPolicyInput](
		"mode", "score", "block",
	)
}

// The moderation policy for the response output.
//
// The property Mode is required.
type BetaResponseNewParamsModerationPolicyOutput struct {
	// Any of "score", "block".
	Mode string `json:"mode,omitzero" api:"required"`
	paramObj
}

func (r BetaResponseNewParamsModerationPolicyOutput) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseNewParamsModerationPolicyOutput
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseNewParamsModerationPolicyOutput) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaResponseNewParamsModerationPolicyOutput](
		"mode", "score", "block",
	)
}

// Configuration for server-hosted multi-agent execution.
//
// The property Enabled is required.
type BetaResponseNewParamsMultiAgent struct {
	// Whether to enable server-hosted multi-agent execution for this response.
	Enabled bool `json:"enabled" api:"required"`
	// `max_concurrent_subagents` sets the maximum number of subagents that can be
	// active simultaneously across the entire agent tree. It includes all
	// descendants—children, grandchildren, and deeper subagents—but excludes the root
	// agent. The API does not impose a fixed upper bound on this setting. The default
	// is `3`, which is recommended for most workloads. Multi-agent runs also have no
	// fixed limit on tree depth or the total number of subagents created during a run.
	MaxConcurrentSubagents param.Opt[int64] `json:"max_concurrent_subagents,omitzero"`
	paramObj
}

func (r BetaResponseNewParamsMultiAgent) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseNewParamsMultiAgent
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseNewParamsMultiAgent) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Options for prompt caching. Supported for `gpt-5.6` and later models. By
// default, OpenAI automatically chooses one implicit cache breakpoint. You can add
// explicit breakpoints to content blocks with `prompt_cache_breakpoint`. Each
// request can write up to four breakpoints. For cache matching, OpenAI considers
// up to the latest 80 breakpoints in the conversation, without a content-block
// lookback limit. Set `mode` to `explicit` to disable the implicit breakpoint. The
// `ttl` defaults to `30m`, which is currently the only supported value. See the
// [prompt caching guide](https://platform.openai.com/docs/guides/prompt-caching)
// for current details.
type BetaResponseNewParamsPromptCacheOptions struct {
	// Controls whether OpenAI automatically creates an implicit cache breakpoint.
	// Defaults to `implicit`. With `implicit`, OpenAI creates one implicit breakpoint
	// and writes up to the latest three explicit breakpoints in the request. With
	// `explicit`, OpenAI does not create an implicit breakpoint and writes up to the
	// latest four explicit breakpoints. If there are no explicit breakpoints, the
	// request does not use prompt caching.
	//
	// Any of "implicit", "explicit".
	Mode string `json:"mode,omitzero"`
	// The minimum lifetime applied to every implicit and explicit cache breakpoint
	// written by the request. Defaults to `30m`, which is currently the only supported
	// value. The backend may retain cache entries for longer.
	//
	// Any of "30m".
	Ttl string `json:"ttl,omitzero"`
	paramObj
}

func (r BetaResponseNewParamsPromptCacheOptions) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseNewParamsPromptCacheOptions
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseNewParamsPromptCacheOptions) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaResponseNewParamsPromptCacheOptions](
		"mode", "implicit", "explicit",
	)
	apijson.RegisterFieldValidator[BetaResponseNewParamsPromptCacheOptions](
		"ttl", "30m",
	)
}

// Deprecated. Use `prompt_cache_options.ttl` instead.
//
// The retention policy for the prompt cache. Set to `24h` to enable extended
// prompt caching, which keeps cached prefixes active for longer, up to a maximum
// of 24 hours.
// [Learn more](https://platform.openai.com/docs/guides/prompt-caching#prompt-cache-retention).
// This field expresses a maximum retention policy, while
// `prompt_cache_options.ttl` expresses a minimum cache lifetime. The two fields
// are independent and do not interact. For `gpt-5.5`, `gpt-5.5-pro`, and future
// models, only `24h` is supported.
//
// For older models that support both `in_memory` and `24h`, the default depends on
// your organization's data retention policy:
//
//   - Organizations without ZDR enabled default to `24h`.
//   - Organizations with ZDR enabled default to `in_memory` when
//     `prompt_cache_retention` is not specified.
type BetaResponseNewParamsPromptCacheRetention string

const (
	BetaResponseNewParamsPromptCacheRetentionInMemory BetaResponseNewParamsPromptCacheRetention = "in_memory"
	BetaResponseNewParamsPromptCacheRetention24h      BetaResponseNewParamsPromptCacheRetention = "24h"
)

// **gpt-5 and o-series models only**
//
// Configuration options for
// [reasoning models](https://platform.openai.com/docs/guides/reasoning).
type BetaResponseNewParamsReasoning struct {
	// Controls which reasoning items are rendered back to the model on later turns. If
	// omitted or set to `auto`, the model determines the context mode. The `gpt-5.6`
	// model family defaults to `all_turns`; earlier models default to `current_turn`.
	//
	// When returned on a response, this is the effective reasoning context mode used
	// for the response.
	//
	// Any of "auto", "current_turn", "all_turns".
	Context string `json:"context,omitzero"`
	// Constrains effort on reasoning for reasoning models. Currently supported values
	// are `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. Reducing
	// reasoning effort can result in faster responses and fewer tokens used on
	// reasoning in a response. Not all reasoning models support every value. See the
	// [reasoning guide](https://platform.openai.com/docs/guides/reasoning) for
	// model-specific support.
	//
	// Any of "none", "minimal", "low", "medium", "high", "xhigh", "max".
	Effort string `json:"effort,omitzero"`
	// **Deprecated:** use `summary` instead.
	//
	// A summary of the reasoning performed by the model. This can be useful for
	// debugging and understanding the model's reasoning process. One of `auto`,
	// `concise`, or `detailed`.
	//
	// Any of "auto", "concise", "detailed".
	//
	// Deprecated: deprecated
	GenerateSummary string `json:"generate_summary,omitzero"`
	// A summary of the reasoning performed by the model. This can be useful for
	// debugging and understanding the model's reasoning process. One of `auto`,
	// `concise`, or `detailed`.
	//
	// `concise` is supported for `computer-use-preview` models and all reasoning
	// models after `gpt-5`.
	//
	// Any of "auto", "concise", "detailed".
	Summary string `json:"summary,omitzero"`
	// Controls the reasoning execution mode for the request.
	//
	// When returned on a response, this is the effective execution mode.
	Mode string `json:"mode,omitzero"`
	paramObj
}

func (r BetaResponseNewParamsReasoning) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseNewParamsReasoning
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseNewParamsReasoning) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaResponseNewParamsReasoning](
		"context", "auto", "current_turn", "all_turns",
	)
	apijson.RegisterFieldValidator[BetaResponseNewParamsReasoning](
		"effort", "none", "minimal", "low", "medium", "high", "xhigh", "max",
	)
	apijson.RegisterFieldValidator[BetaResponseNewParamsReasoning](
		"generate_summary", "auto", "concise", "detailed",
	)
	apijson.RegisterFieldValidator[BetaResponseNewParamsReasoning](
		"summary", "auto", "concise", "detailed",
	)
}

// Specifies the processing type used for serving the request.
//
//   - If set to 'auto', then the request will be processed with the service tier
//     configured in the Project settings. Unless otherwise configured, the Project
//     will use 'default'.
//   - If set to 'default', then the request will be processed with the standard
//     pricing and performance for the selected model.
//   - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
//     '[priority](https://openai.com/api-priority-processing/)', then the request
//     will be processed with the corresponding service tier.
//   - When not set, the default behavior is 'auto'.
//
// When the `service_tier` parameter is set, the response body will include the
// `service_tier` value based on the processing mode actually used to serve the
// request. This response value may be different from the value set in the
// parameter.
type BetaResponseNewParamsServiceTier string

const (
	BetaResponseNewParamsServiceTierAuto     BetaResponseNewParamsServiceTier = "auto"
	BetaResponseNewParamsServiceTierDefault  BetaResponseNewParamsServiceTier = "default"
	BetaResponseNewParamsServiceTierFlex     BetaResponseNewParamsServiceTier = "flex"
	BetaResponseNewParamsServiceTierScale    BetaResponseNewParamsServiceTier = "scale"
	BetaResponseNewParamsServiceTierPriority BetaResponseNewParamsServiceTier = "priority"
)

// Options for streaming responses. Only set this when you set `stream: true`.
type BetaResponseNewParamsStreamOptions struct {
	// When true, stream obfuscation will be enabled. Stream obfuscation adds random
	// characters to an `obfuscation` field on streaming delta events to normalize
	// payload sizes as a mitigation to certain side-channel attacks. These obfuscation
	// fields are included by default, but add a small amount of overhead to the data
	// stream. You can set `include_obfuscation` to false to optimize for bandwidth if
	// you trust the network links between your application and the OpenAI API.
	IncludeObfuscation param.Opt[bool] `json:"include_obfuscation,omitzero"`
	paramObj
}

func (r BetaResponseNewParamsStreamOptions) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseNewParamsStreamOptions
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseNewParamsStreamOptions) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseNewParamsToolChoiceUnion struct {
	// Check if union is this variant with !param.IsOmitted(union.OfToolChoiceMode)
	OfToolChoiceMode                                                     param.Opt[BetaToolChoiceOptions]                                         `json:",omitzero,inline"`
	OfAllowedTools                                                       *BetaToolChoiceAllowedParam                                              `json:",omitzero,inline"`
	OfHostedTool                                                         *BetaToolChoiceTypesParam                                                `json:",omitzero,inline"`
	OfFunctionTool                                                       *BetaToolChoiceFunctionParam                                             `json:",omitzero,inline"`
	OfMcpTool                                                            *BetaToolChoiceMcpParam                                                  `json:",omitzero,inline"`
	OfCustomTool                                                         *BetaToolChoiceCustomParam                                               `json:",omitzero,inline"`
	OfBetaResponseNewsToolChoiceBetaSpecificProgrammaticToolCallingParam *BetaResponseNewParamsToolChoiceBetaSpecificProgrammaticToolCallingParam `json:",omitzero,inline"`
	OfSpecificApplyPatchToolChoice                                       *BetaToolChoiceApplyPatchParam                                           `json:",omitzero,inline"`
	OfSpecificShellToolChoice                                            *BetaToolChoiceShellParam                                                `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseNewParamsToolChoiceUnion) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfToolChoiceMode,
		u.OfAllowedTools,
		u.OfHostedTool,
		u.OfFunctionTool,
		u.OfMcpTool,
		u.OfCustomTool,
		u.OfBetaResponseNewsToolChoiceBetaSpecificProgrammaticToolCallingParam,
		u.OfSpecificApplyPatchToolChoice,
		u.OfSpecificShellToolChoice)
}
func (u *BetaResponseNewParamsToolChoiceUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseNewParamsToolChoiceUnion) asAny() any {
	if !param.IsOmitted(u.OfToolChoiceMode) {
		return &u.OfToolChoiceMode
	} else if !param.IsOmitted(u.OfAllowedTools) {
		return u.OfAllowedTools
	} else if !param.IsOmitted(u.OfHostedTool) {
		return u.OfHostedTool
	} else if !param.IsOmitted(u.OfFunctionTool) {
		return u.OfFunctionTool
	} else if !param.IsOmitted(u.OfMcpTool) {
		return u.OfMcpTool
	} else if !param.IsOmitted(u.OfCustomTool) {
		return u.OfCustomTool
	} else if !param.IsOmitted(u.OfBetaResponseNewsToolChoiceBetaSpecificProgrammaticToolCallingParam) {
		return u.OfBetaResponseNewsToolChoiceBetaSpecificProgrammaticToolCallingParam
	} else if !param.IsOmitted(u.OfSpecificApplyPatchToolChoice) {
		return u.OfSpecificApplyPatchToolChoice
	} else if !param.IsOmitted(u.OfSpecificShellToolChoice) {
		return u.OfSpecificShellToolChoice
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseNewParamsToolChoiceUnion) GetMode() *string {
	if vt := u.OfAllowedTools; vt != nil {
		return (*string)(&vt.Mode)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseNewParamsToolChoiceUnion) GetTools() []map[string]any {
	if vt := u.OfAllowedTools; vt != nil {
		return vt.Tools
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseNewParamsToolChoiceUnion) GetServerLabel() *string {
	if vt := u.OfMcpTool; vt != nil {
		return &vt.ServerLabel
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseNewParamsToolChoiceUnion) GetType() *string {
	if vt := u.OfAllowedTools; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfHostedTool; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfFunctionTool; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfMcpTool; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfCustomTool; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfBetaResponseNewsToolChoiceBetaSpecificProgrammaticToolCallingParam; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfSpecificApplyPatchToolChoice; vt != nil {
		return (*string)(&vt.Type)
	} else if vt := u.OfSpecificShellToolChoice; vt != nil {
		return (*string)(&vt.Type)
	}
	return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u BetaResponseNewParamsToolChoiceUnion) GetName() *string {
	if vt := u.OfFunctionTool; vt != nil {
		return (*string)(&vt.Name)
	} else if vt := u.OfMcpTool; vt != nil && vt.Name.Valid() {
		return &vt.Name.Value
	} else if vt := u.OfCustomTool; vt != nil {
		return (*string)(&vt.Name)
	}
	return nil
}

func NewBetaResponseNewParamsToolChoiceBetaSpecificProgrammaticToolCallingParam() BetaResponseNewParamsToolChoiceBetaSpecificProgrammaticToolCallingParam {
	return BetaResponseNewParamsToolChoiceBetaSpecificProgrammaticToolCallingParam{
		Type: "programmatic_tool_calling",
	}
}

// This struct has a constant value, construct it with
// [NewBetaResponseNewParamsToolChoiceBetaSpecificProgrammaticToolCallingParam].
type BetaResponseNewParamsToolChoiceBetaSpecificProgrammaticToolCallingParam struct {
	// The tool to call. Always `programmatic_tool_calling`.
	Type constant.ProgrammaticToolCalling `json:"type" default:"programmatic_tool_calling"`
	paramObj
}

func (r BetaResponseNewParamsToolChoiceBetaSpecificProgrammaticToolCallingParam) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseNewParamsToolChoiceBetaSpecificProgrammaticToolCallingParam
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseNewParamsToolChoiceBetaSpecificProgrammaticToolCallingParam) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// The truncation strategy to use for the model response.
//
//   - `auto`: If the input to this Response exceeds the model's context window size,
//     the model will truncate the response to fit the context window by dropping
//     items from the beginning of the conversation.
//   - `disabled` (default): If the input size will exceed the context window size
//     for a model, the request will fail with a 400 error.
type BetaResponseNewParamsTruncation string

const (
	BetaResponseNewParamsTruncationAuto     BetaResponseNewParamsTruncation = "auto"
	BetaResponseNewParamsTruncationDisabled BetaResponseNewParamsTruncation = "disabled"
)

type BetaResponseGetParams struct {
	// When true, stream obfuscation will be enabled. Stream obfuscation adds random
	// characters to an `obfuscation` field on streaming delta events to normalize
	// payload sizes as a mitigation to certain side-channel attacks. These obfuscation
	// fields are included by default, but add a small amount of overhead to the data
	// stream. You can set `include_obfuscation` to false to optimize for bandwidth if
	// you trust the network links between your application and the OpenAI API.
	IncludeObfuscation param.Opt[bool] `query:"include_obfuscation,omitzero" json:"-"`
	// The sequence number of the event after which to start streaming.
	StartingAfter param.Opt[int64] `query:"starting_after,omitzero" json:"-"`
	// Additional fields to include in the response. See the `include` parameter for
	// Response creation above for more information.
	Include []BetaResponseIncludable `query:"include,omitzero" json:"-"`
	// Any of "responses_multi_agent=v1".
	Betas []string `header:"openai-beta,omitzero" json:"-"`
	paramObj
}

// URLQuery serializes [BetaResponseGetParams]'s query parameters as `url.Values`.
func (r BetaResponseGetParams) URLQuery() (v url.Values, err error) {
	return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
		ArrayFormat:  apiquery.ArrayQueryFormatBrackets,
		NestedFormat: apiquery.NestedQueryFormatBrackets,
	})
}

type BetaResponseDeleteParams struct {
	// Any of "responses_multi_agent=v1".
	Betas []string `header:"openai-beta,omitzero" json:"-"`
	paramObj
}

type BetaResponseCancelParams struct {
	// Any of "responses_multi_agent=v1".
	Betas []string `header:"openai-beta,omitzero" json:"-"`
	paramObj
}

type BetaResponseCompactParams struct {
	// Model ID used to generate the response, like `gpt-5` or `o3`. OpenAI offers a
	// wide range of models with different capabilities, performance characteristics,
	// and price points. Refer to the
	// [model guide](https://platform.openai.com/docs/models) to browse and compare
	// available models.
	Model BetaResponseCompactParamsModel `json:"model,omitzero" api:"required"`
	// A system (or developer) message inserted into the model's context. When used
	// along with `previous_response_id`, the instructions from a previous response
	// will not be carried over to the next response. This makes it simple to swap out
	// system (or developer) messages in new responses.
	Instructions param.Opt[string] `json:"instructions,omitzero"`
	// The unique ID of the previous response to the model. Use this to create
	// multi-turn conversations. Learn more about
	// [conversation state](https://platform.openai.com/docs/guides/conversation-state).
	// Cannot be used in conjunction with `conversation`.
	PreviousResponseID param.Opt[string] `json:"previous_response_id,omitzero"`
	// A key to use when reading from or writing to the prompt cache.
	PromptCacheKey param.Opt[string] `json:"prompt_cache_key,omitzero"`
	// Text, image, or file inputs to the model, used to generate a response
	Input BetaResponseCompactParamsInputUnion `json:"input,omitzero"`
	// Options for prompt caching. Supported for `gpt-5.6` and later models. By
	// default, OpenAI automatically chooses one implicit cache breakpoint. You can add
	// explicit breakpoints to content blocks with `prompt_cache_breakpoint`. Each
	// request can write up to four breakpoints. For cache matching, OpenAI considers
	// up to the latest 80 breakpoints in the conversation, without a content-block
	// lookback limit. Set `mode` to `explicit` to disable the implicit breakpoint. The
	// `ttl` defaults to `30m`, which is currently the only supported value. See the
	// [prompt caching guide](https://platform.openai.com/docs/guides/prompt-caching)
	// for current details.
	PromptCacheOptions BetaResponseCompactParamsPromptCacheOptions `json:"prompt_cache_options,omitzero"`
	// How long to retain a prompt cache entry created by this request.
	//
	// Any of "in_memory", "24h".
	PromptCacheRetention BetaResponseCompactParamsPromptCacheRetention `json:"prompt_cache_retention,omitzero"`
	// The service tier to use for this request.
	//
	// Any of "auto", "default", "flex", "priority".
	ServiceTier BetaResponseCompactParamsServiceTier `json:"service_tier,omitzero"`
	// Any of "responses_multi_agent=v1".
	Betas []string `header:"openai-beta,omitzero" json:"-"`
	paramObj
}

func (r BetaResponseCompactParams) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseCompactParams
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseCompactParams) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

// Model ID used to generate the response, like `gpt-5` or `o3`. OpenAI offers a
// wide range of models with different capabilities, performance characteristics,
// and price points. Refer to the
// [model guide](https://platform.openai.com/docs/models) to browse and compare
// available models.
type BetaResponseCompactParamsModel string

const (
	BetaResponseCompactParamsModelGPT5_6Sol                        BetaResponseCompactParamsModel = "gpt-5.6-sol"
	BetaResponseCompactParamsModelGPT5_6Terra                      BetaResponseCompactParamsModel = "gpt-5.6-terra"
	BetaResponseCompactParamsModelGPT5_6Luna                       BetaResponseCompactParamsModel = "gpt-5.6-luna"
	BetaResponseCompactParamsModelGPT5_4                           BetaResponseCompactParamsModel = "gpt-5.4"
	BetaResponseCompactParamsModelGPT5_4Mini                       BetaResponseCompactParamsModel = "gpt-5.4-mini"
	BetaResponseCompactParamsModelGPT5_4Nano                       BetaResponseCompactParamsModel = "gpt-5.4-nano"
	BetaResponseCompactParamsModelGPT5_4Mini2026_03_17             BetaResponseCompactParamsModel = "gpt-5.4-mini-2026-03-17"
	BetaResponseCompactParamsModelGPT5_4Nano2026_03_17             BetaResponseCompactParamsModel = "gpt-5.4-nano-2026-03-17"
	BetaResponseCompactParamsModelGPT5_3ChatLatest                 BetaResponseCompactParamsModel = "gpt-5.3-chat-latest"
	BetaResponseCompactParamsModelGPT5_2                           BetaResponseCompactParamsModel = "gpt-5.2"
	BetaResponseCompactParamsModelGPT5_2_2025_12_11                BetaResponseCompactParamsModel = "gpt-5.2-2025-12-11"
	BetaResponseCompactParamsModelGPT5_2ChatLatest                 BetaResponseCompactParamsModel = "gpt-5.2-chat-latest"
	BetaResponseCompactParamsModelGPT5_2Pro                        BetaResponseCompactParamsModel = "gpt-5.2-pro"
	BetaResponseCompactParamsModelGPT5_2Pro2025_12_11              BetaResponseCompactParamsModel = "gpt-5.2-pro-2025-12-11"
	BetaResponseCompactParamsModelGPT5_1                           BetaResponseCompactParamsModel = "gpt-5.1"
	BetaResponseCompactParamsModelGPT5_1_2025_11_13                BetaResponseCompactParamsModel = "gpt-5.1-2025-11-13"
	BetaResponseCompactParamsModelGPT5_1Codex                      BetaResponseCompactParamsModel = "gpt-5.1-codex"
	BetaResponseCompactParamsModelGPT5_1Mini                       BetaResponseCompactParamsModel = "gpt-5.1-mini"
	BetaResponseCompactParamsModelGPT5_1ChatLatest                 BetaResponseCompactParamsModel = "gpt-5.1-chat-latest"
	BetaResponseCompactParamsModelGPT5                             BetaResponseCompactParamsModel = "gpt-5"
	BetaResponseCompactParamsModelGPT5Mini                         BetaResponseCompactParamsModel = "gpt-5-mini"
	BetaResponseCompactParamsModelGPT5Nano                         BetaResponseCompactParamsModel = "gpt-5-nano"
	BetaResponseCompactParamsModelGPT5_2025_08_07                  BetaResponseCompactParamsModel = "gpt-5-2025-08-07"
	BetaResponseCompactParamsModelGPT5Mini2025_08_07               BetaResponseCompactParamsModel = "gpt-5-mini-2025-08-07"
	BetaResponseCompactParamsModelGPT5Nano2025_08_07               BetaResponseCompactParamsModel = "gpt-5-nano-2025-08-07"
	BetaResponseCompactParamsModelGPT5ChatLatest                   BetaResponseCompactParamsModel = "gpt-5-chat-latest"
	BetaResponseCompactParamsModelGPT4_1                           BetaResponseCompactParamsModel = "gpt-4.1"
	BetaResponseCompactParamsModelGPT4_1Mini                       BetaResponseCompactParamsModel = "gpt-4.1-mini"
	BetaResponseCompactParamsModelGPT4_1Nano                       BetaResponseCompactParamsModel = "gpt-4.1-nano"
	BetaResponseCompactParamsModelGPT4_1_2025_04_14                BetaResponseCompactParamsModel = "gpt-4.1-2025-04-14"
	BetaResponseCompactParamsModelGPT4_1Mini2025_04_14             BetaResponseCompactParamsModel = "gpt-4.1-mini-2025-04-14"
	BetaResponseCompactParamsModelGPT4_1Nano2025_04_14             BetaResponseCompactParamsModel = "gpt-4.1-nano-2025-04-14"
	BetaResponseCompactParamsModelO4Mini                           BetaResponseCompactParamsModel = "o4-mini"
	BetaResponseCompactParamsModelO4Mini2025_04_16                 BetaResponseCompactParamsModel = "o4-mini-2025-04-16"
	BetaResponseCompactParamsModelO3                               BetaResponseCompactParamsModel = "o3"
	BetaResponseCompactParamsModelO3_2025_04_16                    BetaResponseCompactParamsModel = "o3-2025-04-16"
	BetaResponseCompactParamsModelO3Mini                           BetaResponseCompactParamsModel = "o3-mini"
	BetaResponseCompactParamsModelO3Mini2025_01_31                 BetaResponseCompactParamsModel = "o3-mini-2025-01-31"
	BetaResponseCompactParamsModelO1                               BetaResponseCompactParamsModel = "o1"
	BetaResponseCompactParamsModelO1_2024_12_17                    BetaResponseCompactParamsModel = "o1-2024-12-17"
	BetaResponseCompactParamsModelO1Preview                        BetaResponseCompactParamsModel = "o1-preview"
	BetaResponseCompactParamsModelO1Preview2024_09_12              BetaResponseCompactParamsModel = "o1-preview-2024-09-12"
	BetaResponseCompactParamsModelO1Mini                           BetaResponseCompactParamsModel = "o1-mini"
	BetaResponseCompactParamsModelO1Mini2024_09_12                 BetaResponseCompactParamsModel = "o1-mini-2024-09-12"
	BetaResponseCompactParamsModelGPT4o                            BetaResponseCompactParamsModel = "gpt-4o"
	BetaResponseCompactParamsModelGPT4o2024_11_20                  BetaResponseCompactParamsModel = "gpt-4o-2024-11-20"
	BetaResponseCompactParamsModelGPT4o2024_08_06                  BetaResponseCompactParamsModel = "gpt-4o-2024-08-06"
	BetaResponseCompactParamsModelGPT4o2024_05_13                  BetaResponseCompactParamsModel = "gpt-4o-2024-05-13"
	BetaResponseCompactParamsModelGPT4oAudioPreview                BetaResponseCompactParamsModel = "gpt-4o-audio-preview"
	BetaResponseCompactParamsModelGPT4oAudioPreview2024_10_01      BetaResponseCompactParamsModel = "gpt-4o-audio-preview-2024-10-01"
	BetaResponseCompactParamsModelGPT4oAudioPreview2024_12_17      BetaResponseCompactParamsModel = "gpt-4o-audio-preview-2024-12-17"
	BetaResponseCompactParamsModelGPT4oAudioPreview2025_06_03      BetaResponseCompactParamsModel = "gpt-4o-audio-preview-2025-06-03"
	BetaResponseCompactParamsModelGPT4oMiniAudioPreview            BetaResponseCompactParamsModel = "gpt-4o-mini-audio-preview"
	BetaResponseCompactParamsModelGPT4oMiniAudioPreview2024_12_17  BetaResponseCompactParamsModel = "gpt-4o-mini-audio-preview-2024-12-17"
	BetaResponseCompactParamsModelGPT4oSearchPreview               BetaResponseCompactParamsModel = "gpt-4o-search-preview"
	BetaResponseCompactParamsModelGPT4oMiniSearchPreview           BetaResponseCompactParamsModel = "gpt-4o-mini-search-preview"
	BetaResponseCompactParamsModelGPT4oSearchPreview2025_03_11     BetaResponseCompactParamsModel = "gpt-4o-search-preview-2025-03-11"
	BetaResponseCompactParamsModelGPT4oMiniSearchPreview2025_03_11 BetaResponseCompactParamsModel = "gpt-4o-mini-search-preview-2025-03-11"
	BetaResponseCompactParamsModelChatgpt4oLatest                  BetaResponseCompactParamsModel = "chatgpt-4o-latest"
	BetaResponseCompactParamsModelCodexMiniLatest                  BetaResponseCompactParamsModel = "codex-mini-latest"
	BetaResponseCompactParamsModelGPT4oMini                        BetaResponseCompactParamsModel = "gpt-4o-mini"
	BetaResponseCompactParamsModelGPT4oMini2024_07_18              BetaResponseCompactParamsModel = "gpt-4o-mini-2024-07-18"
	BetaResponseCompactParamsModelGPT4Turbo                        BetaResponseCompactParamsModel = "gpt-4-turbo"
	BetaResponseCompactParamsModelGPT4Turbo2024_04_09              BetaResponseCompactParamsModel = "gpt-4-turbo-2024-04-09"
	BetaResponseCompactParamsModelGPT4_0125Preview                 BetaResponseCompactParamsModel = "gpt-4-0125-preview"
	BetaResponseCompactParamsModelGPT4TurboPreview                 BetaResponseCompactParamsModel = "gpt-4-turbo-preview"
	BetaResponseCompactParamsModelGPT4_1106Preview                 BetaResponseCompactParamsModel = "gpt-4-1106-preview"
	BetaResponseCompactParamsModelGPT4VisionPreview                BetaResponseCompactParamsModel = "gpt-4-vision-preview"
	BetaResponseCompactParamsModelGPT4                             BetaResponseCompactParamsModel = "gpt-4"
	BetaResponseCompactParamsModelGPT4_0314                        BetaResponseCompactParamsModel = "gpt-4-0314"
	BetaResponseCompactParamsModelGPT4_0613                        BetaResponseCompactParamsModel = "gpt-4-0613"
	BetaResponseCompactParamsModelGPT4_32k                         BetaResponseCompactParamsModel = "gpt-4-32k"
	BetaResponseCompactParamsModelGPT4_32k0314                     BetaResponseCompactParamsModel = "gpt-4-32k-0314"
	BetaResponseCompactParamsModelGPT4_32k0613                     BetaResponseCompactParamsModel = "gpt-4-32k-0613"
	BetaResponseCompactParamsModelGPT3_5Turbo                      BetaResponseCompactParamsModel = "gpt-3.5-turbo"
	BetaResponseCompactParamsModelGPT3_5Turbo16k                   BetaResponseCompactParamsModel = "gpt-3.5-turbo-16k"
	BetaResponseCompactParamsModelGPT3_5Turbo0301                  BetaResponseCompactParamsModel = "gpt-3.5-turbo-0301"
	BetaResponseCompactParamsModelGPT3_5Turbo0613                  BetaResponseCompactParamsModel = "gpt-3.5-turbo-0613"
	BetaResponseCompactParamsModelGPT3_5Turbo1106                  BetaResponseCompactParamsModel = "gpt-3.5-turbo-1106"
	BetaResponseCompactParamsModelGPT3_5Turbo0125                  BetaResponseCompactParamsModel = "gpt-3.5-turbo-0125"
	BetaResponseCompactParamsModelGPT3_5Turbo16k0613               BetaResponseCompactParamsModel = "gpt-3.5-turbo-16k-0613"
	BetaResponseCompactParamsModelO1Pro                            BetaResponseCompactParamsModel = "o1-pro"
	BetaResponseCompactParamsModelO1Pro2025_03_19                  BetaResponseCompactParamsModel = "o1-pro-2025-03-19"
	BetaResponseCompactParamsModelO3Pro                            BetaResponseCompactParamsModel = "o3-pro"
	BetaResponseCompactParamsModelO3Pro2025_06_10                  BetaResponseCompactParamsModel = "o3-pro-2025-06-10"
	BetaResponseCompactParamsModelO3DeepResearch                   BetaResponseCompactParamsModel = "o3-deep-research"
	BetaResponseCompactParamsModelO3DeepResearch2025_06_26         BetaResponseCompactParamsModel = "o3-deep-research-2025-06-26"
	BetaResponseCompactParamsModelO4MiniDeepResearch               BetaResponseCompactParamsModel = "o4-mini-deep-research"
	BetaResponseCompactParamsModelO4MiniDeepResearch2025_06_26     BetaResponseCompactParamsModel = "o4-mini-deep-research-2025-06-26"
	BetaResponseCompactParamsModelComputerUsePreview               BetaResponseCompactParamsModel = "computer-use-preview"
	BetaResponseCompactParamsModelComputerUsePreview2025_03_11     BetaResponseCompactParamsModel = "computer-use-preview-2025-03-11"
	BetaResponseCompactParamsModelGPT5Codex                        BetaResponseCompactParamsModel = "gpt-5-codex"
	BetaResponseCompactParamsModelGPT5Pro                          BetaResponseCompactParamsModel = "gpt-5-pro"
	BetaResponseCompactParamsModelGPT5Pro2025_10_06                BetaResponseCompactParamsModel = "gpt-5-pro-2025-10-06"
	BetaResponseCompactParamsModelGPT5_1CodexMax                   BetaResponseCompactParamsModel = "gpt-5.1-codex-max"
)

// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaResponseCompactParamsInputUnion struct {
	OfString                     param.Opt[string]                 `json:",omitzero,inline"`
	OfBetaResponseInputItemArray []BetaResponseInputItemUnionParam `json:",omitzero,inline"`
	paramUnion
}

func (u BetaResponseCompactParamsInputUnion) MarshalJSON() ([]byte, error) {
	return param.MarshalUnion(u, u.OfString, u.OfBetaResponseInputItemArray)
}
func (u *BetaResponseCompactParamsInputUnion) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, u)
}

func (u *BetaResponseCompactParamsInputUnion) asAny() any {
	if !param.IsOmitted(u.OfString) {
		return &u.OfString.Value
	} else if !param.IsOmitted(u.OfBetaResponseInputItemArray) {
		return &u.OfBetaResponseInputItemArray
	}
	return nil
}

// Options for prompt caching. Supported for `gpt-5.6` and later models. By
// default, OpenAI automatically chooses one implicit cache breakpoint. You can add
// explicit breakpoints to content blocks with `prompt_cache_breakpoint`. Each
// request can write up to four breakpoints. For cache matching, OpenAI considers
// up to the latest 80 breakpoints in the conversation, without a content-block
// lookback limit. Set `mode` to `explicit` to disable the implicit breakpoint. The
// `ttl` defaults to `30m`, which is currently the only supported value. See the
// [prompt caching guide](https://platform.openai.com/docs/guides/prompt-caching)
// for current details.
type BetaResponseCompactParamsPromptCacheOptions struct {
	// Controls whether OpenAI automatically creates an implicit cache breakpoint.
	// Defaults to `implicit`. With `implicit`, OpenAI creates one implicit breakpoint
	// and writes up to the latest three explicit breakpoints in the request. With
	// `explicit`, OpenAI does not create an implicit breakpoint and writes up to the
	// latest four explicit breakpoints. If there are no explicit breakpoints, the
	// request does not use prompt caching.
	//
	// Any of "implicit", "explicit".
	Mode string `json:"mode,omitzero"`
	// The minimum lifetime applied to every implicit and explicit cache breakpoint
	// written by the request. Defaults to `30m`, which is currently the only supported
	// value. The backend may retain cache entries for longer.
	//
	// Any of "30m".
	Ttl string `json:"ttl,omitzero"`
	paramObj
}

func (r BetaResponseCompactParamsPromptCacheOptions) MarshalJSON() (data []byte, err error) {
	type shadow BetaResponseCompactParamsPromptCacheOptions
	return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaResponseCompactParamsPromptCacheOptions) UnmarshalJSON(data []byte) error {
	return apijson.UnmarshalRoot(data, r)
}

func init() {
	apijson.RegisterFieldValidator[BetaResponseCompactParamsPromptCacheOptions](
		"mode", "implicit", "explicit",
	)
	apijson.RegisterFieldValidator[BetaResponseCompactParamsPromptCacheOptions](
		"ttl", "30m",
	)
}

// How long to retain a prompt cache entry created by this request.
type BetaResponseCompactParamsPromptCacheRetention string

const (
	BetaResponseCompactParamsPromptCacheRetentionInMemory BetaResponseCompactParamsPromptCacheRetention = "in_memory"
	BetaResponseCompactParamsPromptCacheRetention24h      BetaResponseCompactParamsPromptCacheRetention = "24h"
)

// The service tier to use for this request.
type BetaResponseCompactParamsServiceTier string

const (
	BetaResponseCompactParamsServiceTierAuto     BetaResponseCompactParamsServiceTier = "auto"
	BetaResponseCompactParamsServiceTierDefault  BetaResponseCompactParamsServiceTier = "default"
	BetaResponseCompactParamsServiceTierFlex     BetaResponseCompactParamsServiceTier = "flex"
	BetaResponseCompactParamsServiceTierPriority BetaResponseCompactParamsServiceTier = "priority"
)
