From 280c698015eba5f6bd47e2fce038eb401f6ef0f2 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Mon, 16 Jun 2025 18:28:22 +0000
Subject: [PATCH] feat(api): add reusable prompt IDs
---
.stats.yml | 6 +-
api.md | 4 +
chatcompletion.go | 9 +-
finetuningjob.go | 10 +-
image.go | 21 +
image_test.go | 20 +-
responses/response.go | 1265 +++++++++++++++++++++++++++++++++++-
responses/response_test.go | 9 +
8 files changed, 1300 insertions(+), 44 deletions(-)
diff --git a/.stats.yml b/.stats.yml
index 38eac25..447b2e8 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 97
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-3ae9c18dd7ccfc3ac5206f24394665f563a19015cfa8847b2801a2694d012abc.yml
-openapi_spec_hash: 48175b03b58805cd5c80793c66fd54e5
-config_hash: 4caff63b74a41f71006987db702f2918
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-9e41d2d5471d2c28bff0d616f4476f5b0e6c541ef4cb51bdaaef5fdf5e13c8b2.yml
+openapi_spec_hash: 86f765e18d00e32cf2ce9db7ab84d946
+config_hash: fd2af1d5eff0995bb7dc02ac9a34851d
diff --git a/api.md b/api.md
index 4f2df86..a156c8d 100644
--- a/api.md
+++ b/api.md
@@ -595,6 +595,7 @@ Params Types:
- responses.ResponseOutputMessageParam
- responses.ResponseOutputRefusalParam
- responses.ResponseOutputTextParam
+- responses.ResponsePromptParam
- responses.ResponseReasoningItemParam
- responses.ResponseTextConfigParam
- responses.ToolUnionParam
@@ -606,6 +607,7 @@ Params Types:
Response Types:
- responses.ComputerTool
+- responses.EasyInputMessage
- responses.FileSearchTool
- responses.FunctionTool
- responses.Response
@@ -650,6 +652,7 @@ Response Types:
- responses.ResponseInputContentUnion
- responses.ResponseInputFile
- responses.ResponseInputImage
+- responses.ResponseInputItemUnion
- responses.ResponseInputMessageContentList
- responses.ResponseInputMessageItem
- responses.ResponseInputText
@@ -669,6 +672,7 @@ Response Types:
- responses.ResponseOutputRefusal
- responses.ResponseOutputText
- responses.ResponseOutputTextAnnotationAddedEvent
+- responses.ResponsePrompt
- responses.ResponseQueuedEvent
- responses.ResponseReasoningDeltaEvent
- responses.ResponseReasoningDoneEvent
diff --git a/chatcompletion.go b/chatcompletion.go
index 98680ec..00b5162 100644
--- a/chatcompletion.go
+++ b/chatcompletion.go
@@ -193,7 +193,7 @@ type ChatCompletion struct {
// When this parameter is set, the response body will include the `service_tier`
// utilized.
//
- // Any of "auto", "default", "flex".
+ // Any of "auto", "default", "flex", "scale".
ServiceTier ChatCompletionServiceTier `json:"service_tier,nullable"`
// This fingerprint represents the backend configuration that the model runs with.
//
@@ -300,6 +300,7 @@ const (
ChatCompletionServiceTierAuto ChatCompletionServiceTier = "auto"
ChatCompletionServiceTierDefault ChatCompletionServiceTier = "default"
ChatCompletionServiceTierFlex ChatCompletionServiceTier = "flex"
+ ChatCompletionServiceTierScale ChatCompletionServiceTier = "scale"
)
// Messages sent by the model in response to user messages.
@@ -588,7 +589,7 @@ type ChatCompletionChunk struct {
// When this parameter is set, the response body will include the `service_tier`
// utilized.
//
- // Any of "auto", "default", "flex".
+ // Any of "auto", "default", "flex", "scale".
ServiceTier ChatCompletionChunkServiceTier `json:"service_tier,nullable"`
// This fingerprint represents the backend configuration that the model runs with.
// Can be used in conjunction with the `seed` request parameter to understand when
@@ -810,6 +811,7 @@ const (
ChatCompletionChunkServiceTierAuto ChatCompletionChunkServiceTier = "auto"
ChatCompletionChunkServiceTierDefault ChatCompletionChunkServiceTier = "default"
ChatCompletionChunkServiceTierFlex ChatCompletionChunkServiceTier = "flex"
+ ChatCompletionChunkServiceTierScale ChatCompletionChunkServiceTier = "scale"
)
func TextContentPart(text string) ChatCompletionContentPartUnionParam {
@@ -2221,7 +2223,7 @@ type ChatCompletionNewParams struct {
// When this parameter is set, the response body will include the `service_tier`
// utilized.
//
- // Any of "auto", "default", "flex".
+ // Any of "auto", "default", "flex", "scale".
ServiceTier ChatCompletionNewParamsServiceTier `json:"service_tier,omitzero"`
// Not supported with latest reasoning models `o3` and `o4-mini`.
//
@@ -2428,6 +2430,7 @@ const (
ChatCompletionNewParamsServiceTierAuto ChatCompletionNewParamsServiceTier = "auto"
ChatCompletionNewParamsServiceTierDefault ChatCompletionNewParamsServiceTier = "default"
ChatCompletionNewParamsServiceTierFlex ChatCompletionNewParamsServiceTier = "flex"
+ ChatCompletionNewParamsServiceTierScale ChatCompletionNewParamsServiceTier = "scale"
)
// Only one field can be non-zero.
diff --git a/finetuningjob.go b/finetuningjob.go
index 43ce46f..5776f03 100644
--- a/finetuningjob.go
+++ b/finetuningjob.go
@@ -48,7 +48,7 @@ func NewFineTuningJobService(opts ...option.RequestOption) (r FineTuningJobServi
// Response includes details of the enqueued job including job status and the name
// of the fine-tuned models once complete.
//
-// [Learn more about fine-tuning](https://platform.openai.com/docs/guides/fine-tuning)
+// [Learn more about fine-tuning](https://platform.openai.com/docs/guides/model-optimization)
func (r *FineTuningJobService) New(ctx context.Context, body FineTuningJobNewParams, opts ...option.RequestOption) (res *FineTuningJob, err error) {
opts = append(r.Options[:], opts...)
path := "fine_tuning/jobs"
@@ -58,7 +58,7 @@ func (r *FineTuningJobService) New(ctx context.Context, body FineTuningJobNewPar
// Get info about a fine-tuning job.
//
-// [Learn more about fine-tuning](https://platform.openai.com/docs/guides/fine-tuning)
+// [Learn more about fine-tuning](https://platform.openai.com/docs/guides/model-optimization)
func (r *FineTuningJobService) Get(ctx context.Context, fineTuningJobID string, opts ...option.RequestOption) (res *FineTuningJob, err error) {
opts = append(r.Options[:], opts...)
if fineTuningJobID == "" {
@@ -590,7 +590,8 @@ type FineTuningJobNewParams struct {
// [preference](https://platform.openai.com/docs/api-reference/fine-tuning/preference-input)
// format.
//
- // See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning)
+ // See the
+ // [fine-tuning guide](https://platform.openai.com/docs/guides/model-optimization)
// for more details.
TrainingFile string `json:"training_file,required"`
// The seed controls the reproducibility of the job. Passing in the same seed and
@@ -613,7 +614,8 @@ type FineTuningJobNewParams struct {
// Your dataset must be formatted as a JSONL file. You must upload your file with
// the purpose `fine-tune`.
//
- // See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning)
+ // See the
+ // [fine-tuning guide](https://platform.openai.com/docs/guides/model-optimization)
// for more details.
ValidationFile param.Opt[string] `json:"validation_file,omitzero"`
// A list of integrations to enable for your fine-tuning job.
diff --git a/image.go b/image.go
index b2f296b..16e8164 100644
--- a/image.go
+++ b/image.go
@@ -249,6 +249,10 @@ type ImageEditParams struct {
Prompt string `json:"prompt,required"`
// The number of images to generate. Must be between 1 and 10.
N param.Opt[int64] `json:"n,omitzero"`
+ // The compression level (0-100%) for the generated images. This parameter is only
+ // supported for `gpt-image-1` with the `webp` or `jpeg` output formats, and
+ // defaults to 100.
+ OutputCompression param.Opt[int64] `json:"output_compression,omitzero"`
// A unique identifier representing your end-user, which can help OpenAI to monitor
// and detect abuse.
// [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
@@ -267,6 +271,12 @@ type ImageEditParams struct {
// supported. Defaults to `dall-e-2` unless a parameter specific to `gpt-image-1`
// is used.
Model ImageModel `json:"model,omitzero"`
+ // The format in which the generated images are returned. This parameter is only
+ // supported for `gpt-image-1`. Must be one of `png`, `jpeg`, or `webp`. The
+ // default value is `png`.
+ //
+ // Any of "png", "jpeg", "webp".
+ OutputFormat ImageEditParamsOutputFormat `json:"output_format,omitzero"`
// The quality of the image that will be generated. `high`, `medium` and `low` are
// only supported for `gpt-image-1`. `dall-e-2` only supports `standard` quality.
// Defaults to `auto`.
@@ -352,6 +362,17 @@ const (
ImageEditParamsBackgroundAuto ImageEditParamsBackground = "auto"
)
+// The format in which the generated images are returned. This parameter is only
+// supported for `gpt-image-1`. Must be one of `png`, `jpeg`, or `webp`. The
+// default value is `png`.
+type ImageEditParamsOutputFormat string
+
+const (
+ ImageEditParamsOutputFormatPNG ImageEditParamsOutputFormat = "png"
+ ImageEditParamsOutputFormatJPEG ImageEditParamsOutputFormat = "jpeg"
+ ImageEditParamsOutputFormatWebP ImageEditParamsOutputFormat = "webp"
+)
+
// The quality of the image that will be generated. `high`, `medium` and `low` are
// only supported for `gpt-image-1`. `dall-e-2` only supports `standard` quality.
// Defaults to `auto`.
diff --git a/image_test.go b/image_test.go
index 570afa2..7eda8c5 100644
--- a/image_test.go
+++ b/image_test.go
@@ -60,15 +60,17 @@ func TestImageEditWithOptionalParams(t *testing.T) {
Image: openai.ImageEditParamsImageUnion{
OfFile: io.Reader(bytes.NewBuffer([]byte("some file contents"))),
},
- Prompt: "A cute baby sea otter wearing a beret",
- Background: openai.ImageEditParamsBackgroundTransparent,
- Mask: io.Reader(bytes.NewBuffer([]byte("some file contents"))),
- Model: openai.ImageModelDallE2,
- N: openai.Int(1),
- Quality: openai.ImageEditParamsQualityHigh,
- ResponseFormat: openai.ImageEditParamsResponseFormatURL,
- Size: openai.ImageEditParamsSize1024x1024,
- User: openai.String("user-1234"),
+ Prompt: "A cute baby sea otter wearing a beret",
+ Background: openai.ImageEditParamsBackgroundTransparent,
+ Mask: io.Reader(bytes.NewBuffer([]byte("some file contents"))),
+ Model: openai.ImageModelDallE2,
+ N: openai.Int(1),
+ OutputCompression: openai.Int(100),
+ OutputFormat: openai.ImageEditParamsOutputFormatPNG,
+ Quality: openai.ImageEditParamsQualityHigh,
+ ResponseFormat: openai.ImageEditParamsResponseFormatURL,
+ Size: openai.ImageEditParamsSize1024x1024,
+ User: openai.String("user-1234"),
})
if err != nil {
var apierr *openai.Error
diff --git a/responses/response.go b/responses/response.go
index ac4770b..1b16c33 100644
--- a/responses/response.go
+++ b/responses/response.go
@@ -220,6 +220,104 @@ func (r *ComputerToolParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+// 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 EasyInputMessage struct {
+ // Text, image, or audio input to the model, used to generate a response. Can also
+ // contain previous assistant responses.
+ Content EasyInputMessageContentUnion `json:"content,required"`
+ // The role of the message input. One of `user`, `assistant`, `system`, or
+ // `developer`.
+ //
+ // Any of "user", "assistant", "system", "developer".
+ Role EasyInputMessageRole `json:"role,required"`
+ // The type of the message input. Always `message`.
+ //
+ // Any of "message".
+ Type EasyInputMessageType `json:"type"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ Content respjson.Field
+ Role respjson.Field
+ Type respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r EasyInputMessage) RawJSON() string { return r.JSON.raw }
+func (r *EasyInputMessage) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// ToParam converts this EasyInputMessage to a EasyInputMessageParam.
+//
+// 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
+// EasyInputMessageParam.Overrides()
+func (r EasyInputMessage) ToParam() EasyInputMessageParam {
+ return param.Override[EasyInputMessageParam](json.RawMessage(r.RawJSON()))
+}
+
+// EasyInputMessageContentUnion contains all possible properties and values from
+// [string], [ResponseInputMessageContentList].
+//
+// 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 EasyInputMessageContentUnion 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 [ResponseInputMessageContentList]
+ // instead of an object.
+ OfInputItemContentList ResponseInputMessageContentList `json:",inline"`
+ JSON struct {
+ OfString respjson.Field
+ OfInputItemContentList respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+func (u EasyInputMessageContentUnion) AsString() (v string) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u EasyInputMessageContentUnion) AsInputItemContentList() (v ResponseInputMessageContentList) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+// Returns the unmodified JSON received from the API
+func (u EasyInputMessageContentUnion) RawJSON() string { return u.JSON.raw }
+
+func (r *EasyInputMessageContentUnion) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// The role of the message input. One of `user`, `assistant`, `system`, or
+// `developer`.
+type EasyInputMessageRole string
+
+const (
+ EasyInputMessageRoleUser EasyInputMessageRole = "user"
+ EasyInputMessageRoleAssistant EasyInputMessageRole = "assistant"
+ EasyInputMessageRoleSystem EasyInputMessageRole = "system"
+ EasyInputMessageRoleDeveloper EasyInputMessageRole = "developer"
+)
+
+// The type of the message input. Always `message`.
+type EasyInputMessageType string
+
+const (
+ EasyInputMessageTypeMessage EasyInputMessageType = "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
@@ -276,24 +374,6 @@ func (u *EasyInputMessageContentUnionParam) asAny() any {
return nil
}
-// The role of the message input. One of `user`, `assistant`, `system`, or
-// `developer`.
-type EasyInputMessageRole string
-
-const (
- EasyInputMessageRoleUser EasyInputMessageRole = "user"
- EasyInputMessageRoleAssistant EasyInputMessageRole = "assistant"
- EasyInputMessageRoleSystem EasyInputMessageRole = "system"
- EasyInputMessageRoleDeveloper EasyInputMessageRole = "developer"
-)
-
-// The type of the message input. Always `message`.
-type EasyInputMessageType string
-
-const (
- EasyInputMessageTypeMessage EasyInputMessageType = "message"
-)
-
// 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).
@@ -596,13 +676,12 @@ type Response struct {
Error ResponseError `json:"error,required"`
// Details about why the response is incomplete.
IncompleteDetails ResponseIncompleteDetails `json:"incomplete_details,required"`
- // Inserts a system (or developer) message as the first item in the model's
- // context.
+ // 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 string `json:"instructions,required"`
+ Instructions ResponseInstructionsUnion `json:"instructions,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.
@@ -669,6 +748,9 @@ type Response struct {
// multi-turn conversations. Learn more about
// [conversation state](https://platform.openai.com/docs/guides/conversation-state).
PreviousResponseID string `json:"previous_response_id,nullable"`
+ // Reference to a prompt template and its variables.
+ // [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
+ Prompt ResponsePrompt `json:"prompt,nullable"`
// **o-series models only**
//
// Configuration options for
@@ -692,7 +774,7 @@ type Response struct {
// When this parameter is set, the response body will include the `service_tier`
// utilized.
//
- // Any of "auto", "default", "flex".
+ // Any of "auto", "default", "flex", "scale".
ServiceTier ResponseServiceTier `json:"service_tier,nullable"`
// The status of the response generation. One of `completed`, `failed`,
// `in_progress`, `cancelled`, `queued`, or `incomplete`.
@@ -742,6 +824,7 @@ type Response struct {
Background respjson.Field
MaxOutputTokens respjson.Field
PreviousResponseID respjson.Field
+ Prompt respjson.Field
Reasoning respjson.Field
ServiceTier respjson.Field
Status respjson.Field
@@ -792,6 +875,43 @@ func (r *ResponseIncompleteDetails) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+// ResponseInstructionsUnion contains all possible properties and values from
+// [string], [[]ResponseInputItemUnion].
+//
+// 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 ResponseInstructionsUnion 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 [[]ResponseInputItemUnion] instead
+ // of an object.
+ OfInputItemList []ResponseInputItemUnion `json:",inline"`
+ JSON struct {
+ OfString respjson.Field
+ OfInputItemList respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+func (u ResponseInstructionsUnion) AsString() (v string) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInstructionsUnion) AsInputItemList() (v []ResponseInputItemUnion) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+// Returns the unmodified JSON received from the API
+func (u ResponseInstructionsUnion) RawJSON() string { return u.JSON.raw }
+
+func (r *ResponseInstructionsUnion) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// ResponseToolChoiceUnion contains all possible properties and values from
// [ToolChoiceOptions], [ToolChoiceTypes], [ToolChoiceFunction].
//
@@ -859,6 +979,7 @@ const (
ResponseServiceTierAuto ResponseServiceTier = "auto"
ResponseServiceTierDefault ResponseServiceTier = "default"
ResponseServiceTierFlex ResponseServiceTier = "flex"
+ ResponseServiceTierScale ResponseServiceTier = "scale"
)
// The truncation strategy to use for the model response.
@@ -4298,6 +4419,882 @@ func (r *ResponseInputImageParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+// ResponseInputItemUnion contains all possible properties and values from
+// [EasyInputMessage], [ResponseInputItemMessage], [ResponseOutputMessage],
+// [ResponseFileSearchToolCall], [ResponseComputerToolCall],
+// [ResponseInputItemComputerCallOutput], [ResponseFunctionWebSearch],
+// [ResponseFunctionToolCall], [ResponseInputItemFunctionCallOutput],
+// [ResponseReasoningItem], [ResponseInputItemImageGenerationCall],
+// [ResponseCodeInterpreterToolCall], [ResponseInputItemLocalShellCall],
+// [ResponseInputItemLocalShellCallOutput], [ResponseInputItemMcpListTools],
+// [ResponseInputItemMcpApprovalRequest], [ResponseInputItemMcpApprovalResponse],
+// [ResponseInputItemMcpCall], [ResponseInputItemItemReference].
+//
+// Use the [ResponseInputItemUnion.AsAny] method to switch on the variant.
+//
+// Use the methods beginning with 'As' to cast the union to one of its variants.
+type ResponseInputItemUnion struct {
+ // This field is a union of [EasyInputMessageContentUnion],
+ // [ResponseInputMessageContentList], [[]ResponseOutputMessageContentUnion]
+ Content ResponseInputItemUnionContent `json:"content"`
+ Role string `json:"role"`
+ // Any of "message", "message", "message", "file_search_call", "computer_call",
+ // "computer_call_output", "web_search_call", "function_call",
+ // "function_call_output", "reasoning", "image_generation_call",
+ // "code_interpreter_call", "local_shell_call", "local_shell_call_output",
+ // "mcp_list_tools", "mcp_approval_request", "mcp_approval_response", "mcp_call",
+ // "item_reference".
+ Type string `json:"type"`
+ Status string `json:"status"`
+ ID string `json:"id"`
+ // This field is from variant [ResponseFileSearchToolCall].
+ Queries []string `json:"queries"`
+ // This field is a union of [[]ResponseFileSearchToolCallResult],
+ // [[]ResponseCodeInterpreterToolCallResultUnion]
+ Results ResponseInputItemUnionResults `json:"results"`
+ // This field is a union of [ResponseComputerToolCallActionUnion],
+ // [ResponseInputItemLocalShellCallAction]
+ Action ResponseInputItemUnionAction `json:"action"`
+ CallID string `json:"call_id"`
+ // This field is from variant [ResponseComputerToolCall].
+ PendingSafetyChecks []ResponseComputerToolCallPendingSafetyCheck `json:"pending_safety_checks"`
+ // This field is a union of [ResponseComputerToolCallOutputScreenshot], [string],
+ // [string], [string]
+ Output ResponseInputItemUnionOutput `json:"output"`
+ // This field is from variant [ResponseInputItemComputerCallOutput].
+ AcknowledgedSafetyChecks []ResponseInputItemComputerCallOutputAcknowledgedSafetyCheck `json:"acknowledged_safety_checks"`
+ Arguments string `json:"arguments"`
+ Name string `json:"name"`
+ // This field is from variant [ResponseReasoningItem].
+ Summary []ResponseReasoningItemSummary `json:"summary"`
+ // This field is from variant [ResponseReasoningItem].
+ EncryptedContent string `json:"encrypted_content"`
+ // This field is from variant [ResponseInputItemImageGenerationCall].
+ Result string `json:"result"`
+ // This field is from variant [ResponseCodeInterpreterToolCall].
+ Code string `json:"code"`
+ // This field is from variant [ResponseCodeInterpreterToolCall].
+ ContainerID string `json:"container_id"`
+ ServerLabel string `json:"server_label"`
+ // This field is from variant [ResponseInputItemMcpListTools].
+ Tools []ResponseInputItemMcpListToolsTool `json:"tools"`
+ Error string `json:"error"`
+ // This field is from variant [ResponseInputItemMcpApprovalResponse].
+ ApprovalRequestID string `json:"approval_request_id"`
+ // This field is from variant [ResponseInputItemMcpApprovalResponse].
+ Approve bool `json:"approve"`
+ // This field is from variant [ResponseInputItemMcpApprovalResponse].
+ Reason string `json:"reason"`
+ JSON struct {
+ Content respjson.Field
+ Role respjson.Field
+ Type respjson.Field
+ Status respjson.Field
+ ID respjson.Field
+ Queries respjson.Field
+ Results respjson.Field
+ Action respjson.Field
+ CallID respjson.Field
+ PendingSafetyChecks respjson.Field
+ Output respjson.Field
+ AcknowledgedSafetyChecks respjson.Field
+ Arguments respjson.Field
+ Name respjson.Field
+ Summary respjson.Field
+ EncryptedContent respjson.Field
+ Result respjson.Field
+ Code respjson.Field
+ ContainerID respjson.Field
+ ServerLabel respjson.Field
+ Tools respjson.Field
+ Error respjson.Field
+ ApprovalRequestID respjson.Field
+ Approve respjson.Field
+ Reason respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// anyResponseInputItem is implemented by each variant of [ResponseInputItemUnion]
+// to add type safety for the return type of [ResponseInputItemUnion.AsAny]
+type anyResponseInputItem interface {
+ implResponseInputItemUnion()
+}
+
+func (EasyInputMessage) implResponseInputItemUnion() {}
+func (ResponseInputItemMessage) implResponseInputItemUnion() {}
+func (ResponseOutputMessage) implResponseInputItemUnion() {}
+func (ResponseFileSearchToolCall) implResponseInputItemUnion() {}
+func (ResponseComputerToolCall) implResponseInputItemUnion() {}
+func (ResponseInputItemComputerCallOutput) implResponseInputItemUnion() {}
+func (ResponseFunctionWebSearch) implResponseInputItemUnion() {}
+func (ResponseFunctionToolCall) implResponseInputItemUnion() {}
+func (ResponseInputItemFunctionCallOutput) implResponseInputItemUnion() {}
+func (ResponseReasoningItem) implResponseInputItemUnion() {}
+func (ResponseInputItemImageGenerationCall) implResponseInputItemUnion() {}
+func (ResponseCodeInterpreterToolCall) implResponseInputItemUnion() {}
+func (ResponseInputItemLocalShellCall) implResponseInputItemUnion() {}
+func (ResponseInputItemLocalShellCallOutput) implResponseInputItemUnion() {}
+func (ResponseInputItemMcpListTools) implResponseInputItemUnion() {}
+func (ResponseInputItemMcpApprovalRequest) implResponseInputItemUnion() {}
+func (ResponseInputItemMcpApprovalResponse) implResponseInputItemUnion() {}
+func (ResponseInputItemMcpCall) implResponseInputItemUnion() {}
+func (ResponseInputItemItemReference) implResponseInputItemUnion() {}
+
+// Use the following switch statement to find the correct variant
+//
+// switch variant := ResponseInputItemUnion.AsAny().(type) {
+// case responses.EasyInputMessage:
+// case responses.ResponseInputItemMessage:
+// case responses.ResponseOutputMessage:
+// case responses.ResponseFileSearchToolCall:
+// case responses.ResponseComputerToolCall:
+// case responses.ResponseInputItemComputerCallOutput:
+// case responses.ResponseFunctionWebSearch:
+// case responses.ResponseFunctionToolCall:
+// case responses.ResponseInputItemFunctionCallOutput:
+// case responses.ResponseReasoningItem:
+// case responses.ResponseInputItemImageGenerationCall:
+// case responses.ResponseCodeInterpreterToolCall:
+// case responses.ResponseInputItemLocalShellCall:
+// case responses.ResponseInputItemLocalShellCallOutput:
+// case responses.ResponseInputItemMcpListTools:
+// case responses.ResponseInputItemMcpApprovalRequest:
+// case responses.ResponseInputItemMcpApprovalResponse:
+// case responses.ResponseInputItemMcpCall:
+// case responses.ResponseInputItemItemReference:
+// default:
+// fmt.Errorf("no variant present")
+// }
+func (u ResponseInputItemUnion) AsAny() anyResponseInputItem {
+ 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 "reasoning":
+ return u.AsReasoning()
+ 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 "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 "item_reference":
+ return u.AsItemReference()
+ }
+ return nil
+}
+
+func (u ResponseInputItemUnion) AsMessage() (v EasyInputMessage) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInputItemUnion) AsInputMessage() (v ResponseInputItemMessage) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInputItemUnion) AsOutputMessage() (v ResponseOutputMessage) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInputItemUnion) AsFileSearchCall() (v ResponseFileSearchToolCall) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInputItemUnion) AsComputerCall() (v ResponseComputerToolCall) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInputItemUnion) AsComputerCallOutput() (v ResponseInputItemComputerCallOutput) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInputItemUnion) AsWebSearchCall() (v ResponseFunctionWebSearch) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInputItemUnion) AsFunctionCall() (v ResponseFunctionToolCall) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInputItemUnion) AsFunctionCallOutput() (v ResponseInputItemFunctionCallOutput) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInputItemUnion) AsReasoning() (v ResponseReasoningItem) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInputItemUnion) AsImageGenerationCall() (v ResponseInputItemImageGenerationCall) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInputItemUnion) AsCodeInterpreterCall() (v ResponseCodeInterpreterToolCall) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInputItemUnion) AsLocalShellCall() (v ResponseInputItemLocalShellCall) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInputItemUnion) AsLocalShellCallOutput() (v ResponseInputItemLocalShellCallOutput) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInputItemUnion) AsMcpListTools() (v ResponseInputItemMcpListTools) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInputItemUnion) AsMcpApprovalRequest() (v ResponseInputItemMcpApprovalRequest) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInputItemUnion) AsMcpApprovalResponse() (v ResponseInputItemMcpApprovalResponse) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInputItemUnion) AsMcpCall() (v ResponseInputItemMcpCall) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInputItemUnion) AsItemReference() (v ResponseInputItemItemReference) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+// Returns the unmodified JSON received from the API
+func (u ResponseInputItemUnion) RawJSON() string { return u.JSON.raw }
+
+func (r *ResponseInputItemUnion) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// ResponseInputItemUnionContent is an implicit subunion of
+// [ResponseInputItemUnion]. ResponseInputItemUnionContent provides convenient
+// access to the sub-properties of the union.
+//
+// For type safety it is recommended to directly use a variant of the
+// [ResponseInputItemUnion].
+//
+// If the underlying value is not a json object, one of the following properties
+// will be valid: OfString OfInputItemContentList
+// OfResponseOutputMessageContentArray]
+type ResponseInputItemUnionContent 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 [ResponseInputMessageContentList]
+ // instead of an object.
+ OfInputItemContentList ResponseInputMessageContentList `json:",inline"`
+ // This field will be present if the value is a
+ // [[]ResponseOutputMessageContentUnion] instead of an object.
+ OfResponseOutputMessageContentArray []ResponseOutputMessageContentUnion `json:",inline"`
+ JSON struct {
+ OfString respjson.Field
+ OfInputItemContentList respjson.Field
+ OfResponseOutputMessageContentArray respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+func (r *ResponseInputItemUnionContent) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// ResponseInputItemUnionResults is an implicit subunion of
+// [ResponseInputItemUnion]. ResponseInputItemUnionResults provides convenient
+// access to the sub-properties of the union.
+//
+// For type safety it is recommended to directly use a variant of the
+// [ResponseInputItemUnion].
+//
+// If the underlying value is not a json object, one of the following properties
+// will be valid: OfResponseFileSearchToolCallResults
+// OfResponseCodeInterpreterToolCallResults]
+type ResponseInputItemUnionResults struct {
+ // This field will be present if the value is a
+ // [[]ResponseFileSearchToolCallResult] instead of an object.
+ OfResponseFileSearchToolCallResults []ResponseFileSearchToolCallResult `json:",inline"`
+ // This field will be present if the value is a
+ // [[]ResponseCodeInterpreterToolCallResultUnion] instead of an object.
+ OfResponseCodeInterpreterToolCallResults []ResponseCodeInterpreterToolCallResultUnion `json:",inline"`
+ JSON struct {
+ OfResponseFileSearchToolCallResults respjson.Field
+ OfResponseCodeInterpreterToolCallResults respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+func (r *ResponseInputItemUnionResults) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// ResponseInputItemUnionAction is an implicit subunion of
+// [ResponseInputItemUnion]. ResponseInputItemUnionAction provides convenient
+// access to the sub-properties of the union.
+//
+// For type safety it is recommended to directly use a variant of the
+// [ResponseInputItemUnion].
+type ResponseInputItemUnionAction struct {
+ // This field is from variant [ResponseComputerToolCallActionUnion].
+ Button string `json:"button"`
+ Type string `json:"type"`
+ X int64 `json:"x"`
+ Y int64 `json:"y"`
+ // This field is from variant [ResponseComputerToolCallActionUnion].
+ Path []ResponseComputerToolCallActionDragPath `json:"path"`
+ // This field is from variant [ResponseComputerToolCallActionUnion].
+ Keys []string `json:"keys"`
+ // This field is from variant [ResponseComputerToolCallActionUnion].
+ ScrollX int64 `json:"scroll_x"`
+ // This field is from variant [ResponseComputerToolCallActionUnion].
+ ScrollY int64 `json:"scroll_y"`
+ // This field is from variant [ResponseComputerToolCallActionUnion].
+ Text string `json:"text"`
+ // This field is from variant [ResponseInputItemLocalShellCallAction].
+ Command []string `json:"command"`
+ // This field is from variant [ResponseInputItemLocalShellCallAction].
+ Env map[string]string `json:"env"`
+ // This field is from variant [ResponseInputItemLocalShellCallAction].
+ TimeoutMs int64 `json:"timeout_ms"`
+ // This field is from variant [ResponseInputItemLocalShellCallAction].
+ User string `json:"user"`
+ // This field is from variant [ResponseInputItemLocalShellCallAction].
+ WorkingDirectory string `json:"working_directory"`
+ JSON struct {
+ Button respjson.Field
+ Type respjson.Field
+ X respjson.Field
+ Y respjson.Field
+ Path respjson.Field
+ Keys 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
+ raw string
+ } `json:"-"`
+}
+
+func (r *ResponseInputItemUnionAction) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// ResponseInputItemUnionOutput is an implicit subunion of
+// [ResponseInputItemUnion]. ResponseInputItemUnionOutput provides convenient
+// access to the sub-properties of the union.
+//
+// For type safety it is recommended to directly use a variant of the
+// [ResponseInputItemUnion].
+//
+// If the underlying value is not a json object, one of the following properties
+// will be valid: OfString]
+type ResponseInputItemUnionOutput 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 [ResponseComputerToolCallOutputScreenshot].
+ Type constant.ComputerScreenshot `json:"type"`
+ // This field is from variant [ResponseComputerToolCallOutputScreenshot].
+ FileID string `json:"file_id"`
+ // This field is from variant [ResponseComputerToolCallOutputScreenshot].
+ ImageURL string `json:"image_url"`
+ JSON struct {
+ OfString respjson.Field
+ Type respjson.Field
+ FileID respjson.Field
+ ImageURL respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+func (r *ResponseInputItemUnionOutput) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// ToParam converts this ResponseInputItemUnion to a ResponseInputItemUnionParam.
+//
+// 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
+// ResponseInputItemUnionParam.Overrides()
+func (r ResponseInputItemUnion) ToParam() ResponseInputItemUnionParam {
+ return param.Override[ResponseInputItemUnionParam](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 ResponseInputItemMessage struct {
+ // A list of one or many input items to the model, containing different content
+ // types.
+ Content ResponseInputMessageContentList `json:"content,required"`
+ // The role of the message input. One of `user`, `system`, or `developer`.
+ //
+ // Any of "user", "system", "developer".
+ Role string `json:"role,required"`
+ // 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
+ Status respjson.Field
+ Type respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseInputItemMessage) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemMessage) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// The output of a computer tool call.
+type ResponseInputItemComputerCallOutput struct {
+ // The ID of the computer tool call that produced the output.
+ CallID string `json:"call_id,required"`
+ // A computer screenshot image used with the computer use tool.
+ Output ResponseComputerToolCallOutputScreenshot `json:"output,required"`
+ // The type of the computer tool call output. Always `computer_call_output`.
+ Type constant.ComputerCallOutput `json:"type,required"`
+ // The ID of the computer tool call output.
+ ID string `json:"id,nullable"`
+ // The safety checks reported by the API that have been acknowledged by the
+ // developer.
+ AcknowledgedSafetyChecks []ResponseInputItemComputerCallOutputAcknowledgedSafetyCheck `json:"acknowledged_safety_checks,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,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
+ Status respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseInputItemComputerCallOutput) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemComputerCallOutput) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// A pending safety check for the computer call.
+type ResponseInputItemComputerCallOutputAcknowledgedSafetyCheck struct {
+ // The ID of the pending safety check.
+ ID string `json:"id,required"`
+ // The type of the pending safety check.
+ Code string `json:"code,nullable"`
+ // Details about the pending safety check.
+ Message string `json:"message,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 ResponseInputItemComputerCallOutputAcknowledgedSafetyCheck) RawJSON() string {
+ return r.JSON.raw
+}
+func (r *ResponseInputItemComputerCallOutputAcknowledgedSafetyCheck) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// The output of a function tool call.
+type ResponseInputItemFunctionCallOutput struct {
+ // The unique ID of the function tool call generated by the model.
+ CallID string `json:"call_id,required"`
+ // A JSON string of the output of the function tool call.
+ Output string `json:"output,required"`
+ // The type of the function tool call output. Always `function_call_output`.
+ Type constant.FunctionCallOutput `json:"type,required"`
+ // The unique ID of the function tool call output. Populated when this item is
+ // returned via API.
+ ID string `json:"id,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,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
+ Status respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseInputItemFunctionCallOutput) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemFunctionCallOutput) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// An image generation request made by the model.
+type ResponseInputItemImageGenerationCall struct {
+ // The unique ID of the image generation call.
+ ID string `json:"id,required"`
+ // The generated image encoded in base64.
+ Result string `json:"result,required"`
+ // The status of the image generation call.
+ //
+ // Any of "in_progress", "completed", "generating", "failed".
+ Status string `json:"status,required"`
+ // The type of the image generation call. Always `image_generation_call`.
+ Type constant.ImageGenerationCall `json:"type,required"`
+ // 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
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseInputItemImageGenerationCall) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemImageGenerationCall) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// A tool call to run a command on the local shell.
+type ResponseInputItemLocalShellCall struct {
+ // The unique ID of the local shell call.
+ ID string `json:"id,required"`
+ // Execute a shell command on the server.
+ Action ResponseInputItemLocalShellCallAction `json:"action,required"`
+ // The unique ID of the local shell tool call generated by the model.
+ CallID string `json:"call_id,required"`
+ // The status of the local shell call.
+ //
+ // Any of "in_progress", "completed", "incomplete".
+ Status string `json:"status,required"`
+ // The type of the local shell call. Always `local_shell_call`.
+ Type constant.LocalShellCall `json:"type,required"`
+ // 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
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseInputItemLocalShellCall) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemLocalShellCall) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// Execute a shell command on the server.
+type ResponseInputItemLocalShellCallAction struct {
+ // The command to run.
+ Command []string `json:"command,required"`
+ // Environment variables to set for the command.
+ Env map[string]string `json:"env,required"`
+ // The type of the local shell action. Always `exec`.
+ Type constant.Exec `json:"type,required"`
+ // Optional timeout in milliseconds for the command.
+ TimeoutMs int64 `json:"timeout_ms,nullable"`
+ // Optional user to run the command as.
+ User string `json:"user,nullable"`
+ // Optional working directory to run the command in.
+ WorkingDirectory string `json:"working_directory,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 ResponseInputItemLocalShellCallAction) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemLocalShellCallAction) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// The output of a local shell tool call.
+type ResponseInputItemLocalShellCallOutput struct {
+ // The unique ID of the local shell tool call generated by the model.
+ ID string `json:"id,required"`
+ // A JSON string of the output of the local shell tool call.
+ Output string `json:"output,required"`
+ // The type of the local shell tool call output. Always `local_shell_call_output`.
+ Type constant.LocalShellCallOutput `json:"type,required"`
+ // The status of the item. One of `in_progress`, `completed`, or `incomplete`.
+ //
+ // Any of "in_progress", "completed", "incomplete".
+ Status string `json:"status,nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Output respjson.Field
+ Type respjson.Field
+ Status respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseInputItemLocalShellCallOutput) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemLocalShellCallOutput) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// A list of tools available on an MCP server.
+type ResponseInputItemMcpListTools struct {
+ // The unique ID of the list.
+ ID string `json:"id,required"`
+ // The label of the MCP server.
+ ServerLabel string `json:"server_label,required"`
+ // The tools available on the server.
+ Tools []ResponseInputItemMcpListToolsTool `json:"tools,required"`
+ // The type of the item. Always `mcp_list_tools`.
+ Type constant.McpListTools `json:"type,required"`
+ // Error message if the server could not list tools.
+ Error string `json:"error,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
+ Error respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseInputItemMcpListTools) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemMcpListTools) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// A tool available on an MCP server.
+type ResponseInputItemMcpListToolsTool struct {
+ // The JSON schema describing the tool's input.
+ InputSchema any `json:"input_schema,required"`
+ // The name of the tool.
+ Name string `json:"name,required"`
+ // Additional annotations about the tool.
+ Annotations any `json:"annotations,nullable"`
+ // The description of the tool.
+ Description string `json:"description,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 ResponseInputItemMcpListToolsTool) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemMcpListToolsTool) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// A request for human approval of a tool invocation.
+type ResponseInputItemMcpApprovalRequest struct {
+ // The unique ID of the approval request.
+ ID string `json:"id,required"`
+ // A JSON string of arguments for the tool.
+ Arguments string `json:"arguments,required"`
+ // The name of the tool to run.
+ Name string `json:"name,required"`
+ // The label of the MCP server making the request.
+ ServerLabel string `json:"server_label,required"`
+ // The type of the item. Always `mcp_approval_request`.
+ Type constant.McpApprovalRequest `json:"type,required"`
+ // 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
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseInputItemMcpApprovalRequest) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemMcpApprovalRequest) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// A response to an MCP approval request.
+type ResponseInputItemMcpApprovalResponse struct {
+ // The ID of the approval request being answered.
+ ApprovalRequestID string `json:"approval_request_id,required"`
+ // Whether the request was approved.
+ Approve bool `json:"approve,required"`
+ // The type of the item. Always `mcp_approval_response`.
+ Type constant.McpApprovalResponse `json:"type,required"`
+ // The unique ID of the approval response
+ ID string `json:"id,nullable"`
+ // Optional reason for the decision.
+ Reason string `json:"reason,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
+ Reason respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseInputItemMcpApprovalResponse) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemMcpApprovalResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// An invocation of a tool on an MCP server.
+type ResponseInputItemMcpCall struct {
+ // The unique ID of the tool call.
+ ID string `json:"id,required"`
+ // A JSON string of the arguments passed to the tool.
+ Arguments string `json:"arguments,required"`
+ // The name of the tool that was run.
+ Name string `json:"name,required"`
+ // The label of the MCP server running the tool.
+ ServerLabel string `json:"server_label,required"`
+ // The type of the item. Always `mcp_call`.
+ Type constant.McpCall `json:"type,required"`
+ // The error from the tool call, if any.
+ Error string `json:"error,nullable"`
+ // The output from the tool call.
+ Output string `json:"output,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
+ Error respjson.Field
+ Output respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseInputItemMcpCall) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemMcpCall) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// An internal identifier for an item to reference.
+type ResponseInputItemItemReference struct {
+ // The ID of the item to reference.
+ ID string `json:"id,required"`
+ // The type of item to reference. Always `item_reference`.
+ //
+ // Any of "item_reference".
+ Type string `json:"type,nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Type respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseInputItemItemReference) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemItemReference) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
func ResponseInputItemParamOfMessage[T string | ResponseInputMessageContentListParam](content T, role EasyInputMessageRole) ResponseInputItemUnionParam {
var message EasyInputMessageParam
switch v := any(content).(type) {
@@ -7944,6 +8941,221 @@ func (r *ResponseOutputTextAnnotationAddedEvent) UnmarshalJSON(data []byte) erro
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 ResponsePrompt struct {
+ // The unique identifier of the prompt template to use.
+ ID string `json:"id,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]ResponsePromptVariableUnion `json:"variables,nullable"`
+ // Optional version of the prompt template.
+ Version string `json:"version,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 ResponsePrompt) RawJSON() string { return r.JSON.raw }
+func (r *ResponsePrompt) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// ToParam converts this ResponsePrompt to a ResponsePromptParam.
+//
+// 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
+// ResponsePromptParam.Overrides()
+func (r ResponsePrompt) ToParam() ResponsePromptParam {
+ return param.Override[ResponsePromptParam](json.RawMessage(r.RawJSON()))
+}
+
+// ResponsePromptVariableUnion contains all possible properties and values from
+// [string], [ResponseInputText], [ResponseInputImage], [ResponseInputFile].
+//
+// 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 ResponsePromptVariableUnion 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 [ResponseInputText].
+ Text string `json:"text"`
+ Type string `json:"type"`
+ // This field is from variant [ResponseInputImage].
+ Detail ResponseInputImageDetail `json:"detail"`
+ FileID string `json:"file_id"`
+ // This field is from variant [ResponseInputImage].
+ ImageURL string `json:"image_url"`
+ // This field is from variant [ResponseInputFile].
+ FileData string `json:"file_data"`
+ // This field is from variant [ResponseInputFile].
+ Filename string `json:"filename"`
+ JSON struct {
+ OfString respjson.Field
+ Text respjson.Field
+ Type respjson.Field
+ Detail respjson.Field
+ FileID respjson.Field
+ ImageURL respjson.Field
+ FileData respjson.Field
+ Filename respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+func (u ResponsePromptVariableUnion) AsString() (v string) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponsePromptVariableUnion) AsInputText() (v ResponseInputText) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponsePromptVariableUnion) AsInputImage() (v ResponseInputImage) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponsePromptVariableUnion) AsInputFile() (v ResponseInputFile) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+// Returns the unmodified JSON received from the API
+func (u ResponsePromptVariableUnion) RawJSON() string { return u.JSON.raw }
+
+func (r *ResponsePromptVariableUnion) 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 ResponsePromptParam struct {
+ // The unique identifier of the prompt template to use.
+ ID string `json:"id,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]ResponsePromptVariableUnionParam `json:"variables,omitzero"`
+ paramObj
+}
+
+func (r ResponsePromptParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponsePromptParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponsePromptParam) 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 ResponsePromptVariableUnionParam struct {
+ OfString param.Opt[string] `json:",omitzero,inline"`
+ OfInputText *ResponseInputTextParam `json:",omitzero,inline"`
+ OfInputImage *ResponseInputImageParam `json:",omitzero,inline"`
+ OfInputFile *ResponseInputFileParam `json:",omitzero,inline"`
+ paramUnion
+}
+
+func (u ResponsePromptVariableUnionParam) MarshalJSON() ([]byte, error) {
+ return param.MarshalUnion(u, u.OfString, u.OfInputText, u.OfInputImage, u.OfInputFile)
+}
+func (u *ResponsePromptVariableUnionParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, u)
+}
+
+func (u *ResponsePromptVariableUnionParam) 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 ResponsePromptVariableUnionParam) 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 ResponsePromptVariableUnionParam) 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 ResponsePromptVariableUnionParam) 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 ResponsePromptVariableUnionParam) 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 ResponsePromptVariableUnionParam) 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 ResponsePromptVariableUnionParam) 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 ResponsePromptVariableUnionParam) 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
+}
+
// Emitted when a response is queued and waiting to be processed.
type ResponseQueuedEvent struct {
// The full response object that is queued.
@@ -11051,8 +12263,7 @@ type ResponseNewParams 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"`
- // Inserts a system (or developer) message as the first item in the model's
- // context.
+ // 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
@@ -11108,6 +12319,9 @@ type ResponseNewParams struct {
// Keys are strings with a maximum length of 64 characters. Values are strings with
// a maximum length of 512 characters.
Metadata shared.Metadata `json:"metadata,omitzero"`
+ // Reference to a prompt template and its variables.
+ // [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
+ Prompt ResponsePromptParam `json:"prompt,omitzero"`
// Specifies the latency tier to use for processing the request. This parameter is
// relevant for customers subscribed to the scale tier service:
//
@@ -11126,7 +12340,7 @@ type ResponseNewParams struct {
// When this parameter is set, the response body will include the `service_tier`
// utilized.
//
- // Any of "auto", "default", "flex".
+ // Any of "auto", "default", "flex", "scale".
ServiceTier ResponseNewParamsServiceTier `json:"service_tier,omitzero"`
// The truncation strategy to use for the model response.
//
@@ -11227,6 +12441,7 @@ const (
ResponseNewParamsServiceTierAuto ResponseNewParamsServiceTier = "auto"
ResponseNewParamsServiceTierDefault ResponseNewParamsServiceTier = "default"
ResponseNewParamsServiceTierFlex ResponseNewParamsServiceTier = "flex"
+ ResponseNewParamsServiceTierScale ResponseNewParamsServiceTier = "scale"
)
// Only one field can be non-zero.
diff --git a/responses/response_test.go b/responses/response_test.go
index 81286c8..03c4e46 100644
--- a/responses/response_test.go
+++ b/responses/response_test.go
@@ -41,6 +41,15 @@ func TestResponseNewWithOptionalParams(t *testing.T) {
},
ParallelToolCalls: openai.Bool(true),
PreviousResponseID: openai.String("previous_response_id"),
+ Prompt: responses.ResponsePromptParam{
+ ID: "id",
+ Variables: map[string]responses.ResponsePromptVariableUnionParam{
+ "foo": {
+ OfString: openai.String("string"),
+ },
+ },
+ Version: openai.String("version"),
+ },
Reasoning: shared.ReasoningParam{
Effort: shared.ReasoningEffortLow,
GenerateSummary: shared.ReasoningGenerateSummaryAuto,