diff --git a/go.mod b/go.mod index e3f660eb1..1a6cd25fd 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/openshift/file-integrity-operator -go 1.25.8 +go 1.25.11 require ( github.com/cenkalti/backoff/v4 v4.3.0 @@ -18,13 +18,13 @@ require ( github.com/prometheus-operator/prometheus-operator/pkg/client v0.90.1 github.com/prometheus/client_golang v1.23.2 github.com/prometheus/client_model v0.6.2 - github.com/prometheus/prometheus v0.311.2 + github.com/prometheus/prometheus v0.311.3 github.com/securego/gosec/v2 v2.25.1-0.20260423132557-24ee992e9515 github.com/sirupsen/logrus v1.9.4 github.com/spf13/cobra v1.10.2 github.com/stretchr/testify v1.11.1 - golang.org/x/mod v0.35.0 - golang.org/x/net v0.53.0 + golang.org/x/mod v0.38.0 + golang.org/x/net v0.57.0 gopkg.in/yaml.v3 v3.0.1 k8s.io/api v0.35.4 k8s.io/apiextensions-apiserver v0.35.4 @@ -40,31 +40,31 @@ require ( cloud.google.com/go/auth v0.20.0 // indirect cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect cloud.google.com/go/compute/metadata v0.9.0 // indirect - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0 // indirect - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.22.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.14.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/internal v1.12.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.7.1 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.7.2 // indirect github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b // indirect github.com/anthropics/anthropic-sdk-go v1.37.0 // indirect - github.com/aws/aws-sdk-go-v2 v1.41.5 // indirect - github.com/aws/aws-sdk-go-v2/config v1.32.14 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.19.14 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.21 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.21 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.21 // indirect - github.com/aws/aws-sdk-go-v2/internal/ini v1.8.6 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.7 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.21 // indirect - github.com/aws/aws-sdk-go-v2/service/signin v1.0.9 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.30.15 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.19 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.41.10 // indirect - github.com/aws/smithy-go v1.25.0 // indirect + github.com/aws/aws-sdk-go-v2 v1.43.0 // indirect + github.com/aws/aws-sdk-go-v2/config v1.32.31 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.19.30 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.31 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.31 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.31 // indirect + github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.32 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.13 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.31 // indirect + github.com/aws/aws-sdk-go-v2/service/signin v1.5.0 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.33.0 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.38.0 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.45.0 // indirect + github.com/aws/smithy-go v1.27.3 // indirect github.com/bahlo/generic-list-go v0.2.0 // indirect github.com/basgys/goxml2json v1.1.1-0.20231018121955-e66ee54ceaad // indirect github.com/bboreham/go-loser v0.0.0-20230920113527-fcc2c21820a3 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/buger/jsonparser v1.1.2 // indirect + github.com/buger/jsonparser v1.2.0 // indirect github.com/ccojocar/zxcvbn-go v1.0.4 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/coreos/go-semver v0.3.1 // indirect @@ -80,12 +80,12 @@ require ( github.com/fatih/color v1.19.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.9.0 // indirect - github.com/fxamacker/cbor/v2 v2.9.1 // indirect + github.com/fxamacker/cbor/v2 v2.9.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-logr/zapr v1.3.0 // indirect github.com/go-openapi/analysis v0.25.0 // indirect github.com/go-openapi/errors v0.22.7 // indirect - github.com/go-openapi/jsonpointer v0.22.5 // indirect + github.com/go-openapi/jsonpointer v0.23.2 // indirect github.com/go-openapi/jsonreference v0.21.5 // indirect github.com/go-openapi/loads v0.23.3 // indirect github.com/go-openapi/spec v0.22.4 // indirect @@ -94,7 +94,7 @@ require ( github.com/go-openapi/swag/cmdutils v0.26.0 // indirect github.com/go-openapi/swag/conv v0.26.0 // indirect github.com/go-openapi/swag/fileutils v0.26.0 // indirect - github.com/go-openapi/swag/jsonname v0.26.0 // indirect + github.com/go-openapi/swag/jsonname v0.26.1 // indirect github.com/go-openapi/swag/jsonutils v0.26.0 // indirect github.com/go-openapi/swag/loading v0.26.0 // indirect github.com/go-openapi/swag/mangling v0.26.0 // indirect @@ -116,7 +116,7 @@ require ( github.com/google/uuid v1.6.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.15 // indirect github.com/googleapis/gax-go/v2 v2.22.0 // indirect - github.com/gookit/color v1.6.0 // indirect + github.com/gookit/color v1.6.1 // indirect github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 // indirect github.com/grafana/regexp v0.0.0-20250905093917-f7b3be9d1853 // indirect github.com/hashicorp/go-version v1.9.0 // indirect @@ -124,13 +124,13 @@ require ( github.com/jpillora/backoff v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/julienschmidt/httprouter v1.3.0 // indirect - github.com/klauspost/compress v1.18.5 // indirect + github.com/klauspost/compress v1.18.7 // indirect github.com/knadh/koanf/maps v0.1.2 // indirect github.com/knadh/koanf/providers/confmap v1.0.0 // indirect - github.com/knadh/koanf/v2 v2.3.4 // indirect + github.com/knadh/koanf/v2 v2.3.5 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/mattn/go-colorable v0.1.14 // indirect - github.com/mattn/go-isatty v0.0.21 // indirect + github.com/mattn/go-isatty v0.0.24 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -139,26 +139,26 @@ require ( github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect github.com/nxadm/tail v1.4.8 // indirect github.com/oklog/ulid/v2 v2.1.1 // indirect - github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics v0.150.0 // indirect - github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.150.0 // indirect - github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor v0.150.0 // indirect - github.com/openai/openai-go/v3 v3.32.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics v0.157.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.157.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor v0.157.0 // indirect + github.com/openai/openai-go/v3 v3.45.0 // indirect github.com/pb33f/jsonpath v0.8.2 // indirect - github.com/pb33f/libopenapi v0.36.1 // indirect - github.com/pb33f/libopenapi-validator v0.13.4 // indirect + github.com/pb33f/libopenapi v0.38.7 // indirect + github.com/pb33f/libopenapi-validator v0.14.0 // indirect github.com/pb33f/ordered-map/v2 v2.3.1 // indirect github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/alertmanager v0.32.0 // indirect - github.com/prometheus/client_golang/exp v0.0.0-20260415123413-5f35560ef2c7 // indirect - github.com/prometheus/common v0.67.5 // indirect + github.com/prometheus/client_golang/exp v0.0.0-20260702112354-832cec72badf // indirect + github.com/prometheus/common v0.69.0 // indirect github.com/prometheus/otlptranslator v1.0.0 // indirect github.com/prometheus/procfs v0.20.1 // indirect github.com/prometheus/sigv4 v0.4.1 // indirect - github.com/puzpuzpuz/xsync/v4 v4.4.0 // indirect + github.com/puzpuzpuz/xsync/v4 v4.5.0 // indirect github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 // indirect github.com/spf13/pflag v1.0.10 // indirect - github.com/tidwall/gjson v1.18.0 // indirect + github.com/tidwall/gjson v1.19.0 // indirect github.com/tidwall/match v1.2.0 // indirect github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/sjson v1.2.5 // indirect @@ -166,41 +166,41 @@ require ( github.com/x448/float16 v0.8.4 // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect go.opentelemetry.io/auto/sdk v1.2.1 // indirect - go.opentelemetry.io/collector/component v1.56.0 // indirect - go.opentelemetry.io/collector/confmap v1.56.0 // indirect - go.opentelemetry.io/collector/confmap/xconfmap v0.150.0 // indirect - go.opentelemetry.io/collector/consumer v1.56.0 // indirect - go.opentelemetry.io/collector/featuregate v1.56.0 // indirect - go.opentelemetry.io/collector/internal/componentalias v0.150.0 // indirect - go.opentelemetry.io/collector/pdata v1.56.0 // indirect - go.opentelemetry.io/collector/pipeline v1.56.0 // indirect - go.opentelemetry.io/collector/processor v1.56.0 // indirect + go.opentelemetry.io/collector/component v1.63.0 // indirect + go.opentelemetry.io/collector/confmap v1.63.0 // indirect + go.opentelemetry.io/collector/confmap/xconfmap v0.157.0 // indirect + go.opentelemetry.io/collector/consumer v1.63.0 // indirect + go.opentelemetry.io/collector/featuregate v1.63.0 // indirect + go.opentelemetry.io/collector/internal/componentalias v0.157.0 // indirect + go.opentelemetry.io/collector/pdata v1.63.0 // indirect + go.opentelemetry.io/collector/pipeline v1.63.0 // indirect + go.opentelemetry.io/collector/processor v1.63.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.68.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.68.0 // indirect - go.opentelemetry.io/otel v1.43.0 // indirect - go.opentelemetry.io/otel/metric v1.43.0 // indirect - go.opentelemetry.io/otel/trace v1.43.0 // indirect + go.opentelemetry.io/otel v1.44.0 // indirect + go.opentelemetry.io/otel/metric v1.44.0 // indirect + go.opentelemetry.io/otel/trace v1.44.0 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/goleak v1.3.0 // indirect go.uber.org/multierr v1.11.0 // indirect - go.uber.org/zap v1.27.1 // indirect + go.uber.org/zap v1.28.0 // indirect go.yaml.in/yaml/v2 v2.4.4 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect - go.yaml.in/yaml/v4 v4.0.0-rc.4 // indirect - golang.org/x/crypto v0.50.0 // indirect + go.yaml.in/yaml/v4 v4.0.0-rc.6 // indirect + golang.org/x/crypto v0.54.0 // indirect golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f // indirect golang.org/x/oauth2 v0.36.0 // indirect - golang.org/x/sync v0.20.0 // indirect - golang.org/x/sys v0.43.0 // indirect - golang.org/x/term v0.42.0 // indirect - golang.org/x/text v0.36.0 // indirect + golang.org/x/sync v0.22.0 // indirect + golang.org/x/sys v0.47.0 // indirect + golang.org/x/term v0.45.0 // indirect + golang.org/x/text v0.40.0 // indirect golang.org/x/time v0.15.0 // indirect - golang.org/x/tools v0.44.0 // indirect + golang.org/x/tools v0.48.0 // indirect gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect google.golang.org/api v0.276.0 // indirect google.golang.org/genai v1.54.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478 // indirect - google.golang.org/grpc v1.80.0 // indirect + google.golang.org/grpc v1.82.0 // indirect google.golang.org/protobuf v1.36.11 // indirect gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect diff --git a/go.sum b/go.sum index 49f9dee7a..a7c8344a6 100644 --- a/go.sum +++ b/go.sum @@ -8,12 +8,12 @@ cloud.google.com/go/auth/oauth2adapt v0.2.8 h1:keo8NaayQZ6wimpNSmW5OPc283g65QNIi cloud.google.com/go/auth/oauth2adapt v0.2.8/go.mod h1:XQ9y31RkqZCcwJWNSx2Xvric3RrU88hAYYbjDWYDL+c= cloud.google.com/go/compute/metadata v0.9.0 h1:pDUj4QMoPejqq20dK0Pg2N4yG9zIkYGdBtwLoEkH9Zs= cloud.google.com/go/compute/metadata v0.9.0/go.mod h1:E0bWwX5wTnLPedCKqk3pJmVgCBSM6qQI1yTBdEb3C10= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0 h1:fou+2+WFTib47nS+nz/ozhEBnvU96bKHy6LjRsY4E28= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0/go.mod h1:t76Ruy8AHvUAC8GfMWJMa0ElSbuIcO03NLpynfbgsPA= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1 h1:Hk5QBxZQC1jb2Fwj6mpzme37xbCDdNTxU7O9eb5+LB4= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1/go.mod h1:IYus9qsFobWIc2YVwe/WPjcnyCkPKtnHAqUYeebc8z0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2 h1:yz1bePFlP5Vws5+8ez6T3HWXPmwOK7Yvq8QxDBD3SKY= -github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2/go.mod h1:Pa9ZNPuoNu/GztvBSKk9J1cDJW6vk/n0zLtV4mgd8N8= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.22.0 h1:aokoqcHvaGjiM3VpjKDfMMnF/8epJ+Q1HLJ7CudztqE= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.22.0/go.mod h1:/WYEx9pcM9Y+Dd/APJaNlSvVSvzl54rrMdZT5+Oi2LM= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.14.0 h1:CU4+EJeJi3TKYWEcYuSdWsjzw0nVsK/H0MSQOiPcymU= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.14.0/go.mod h1:q0+UTSRvShwUCrR/s5HtyInYphN7Wvxb7snFM3u+SLA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.4.0 h1:xFaZZ+IubdftrDHnGGwZ6QvQ3KHTtWl2MCK+GMt2vxs= +github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.4.0/go.mod h1:mCBhUhlMjLLJKr5aqw2TNS/VqJOie8MzWq3DAMJeKso= github.com/Azure/azure-sdk-for-go/sdk/internal v1.12.0 h1:fhqpLE3UEXi9lPaBRpQ6XuRW0nU7hgg4zlmZZa+a9q4= github.com/Azure/azure-sdk-for-go/sdk/internal v1.12.0/go.mod h1:7dCRMLwisfRH3dBupKeNCioWYUZ4SS09Z14H+7i8ZoY= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5 v5.7.0 h1:LkHbJbgF3YyvC53aqYGR+wWQDn2Rdp9AQdGndf9QvY4= @@ -22,8 +22,8 @@ github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4 v4.3 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4 v4.3.0/go.mod h1:Y/HgrePTmGy9HjdSGTqZNa+apUpTVIEVKXJyARP2lrk= github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1/go.mod h1:tCcJZ0uHAmvjsVYzEFivsRTN00oz5BEsRgQHu5JZ9WE= -github.com/AzureAD/microsoft-authentication-library-for-go v1.7.1 h1:edShSHV3DV90+kt+CMaEXEzR9QF7wFrPJxVGz2blMIU= -github.com/AzureAD/microsoft-authentication-library-for-go v1.7.1/go.mod h1:HKpQxkWaGLJ+D/5H8QRpyQXA1eKjxkFlOMwck5+33Jk= +github.com/AzureAD/microsoft-authentication-library-for-go v1.7.2 h1:RHK7bS+HQMslb1sZpAokUt+zTVmue0hKSs2C791hhzU= +github.com/AzureAD/microsoft-authentication-library-for-go v1.7.2/go.mod h1:HKpQxkWaGLJ+D/5H8QRpyQXA1eKjxkFlOMwck5+33Jk= github.com/Code-Hex/go-generics-cache v1.5.1 h1:6vhZGc5M7Y/YD8cIUcY8kcuQLB4cHR7U+0KMqAA0KcU= github.com/Code-Hex/go-generics-cache v1.5.1/go.mod h1:qxcC9kRVrct9rHeiYpFWSoW1vxyillCVzX13KZG8dl4= github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= @@ -39,46 +39,46 @@ github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8 github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g= github.com/armon/go-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJA= github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= -github.com/aws/aws-sdk-go-v2 v1.41.5 h1:dj5kopbwUsVUVFgO4Fi5BIT3t4WyqIDjGKCangnV/yY= -github.com/aws/aws-sdk-go-v2 v1.41.5/go.mod h1:mwsPRE8ceUUpiTgF7QmQIJ7lgsKUPQOUl3o72QBrE1o= -github.com/aws/aws-sdk-go-v2/config v1.32.14 h1:opVIRo/ZbbI8OIqSOKmpFaY7IwfFUOCCXBsUpJOwDdI= -github.com/aws/aws-sdk-go-v2/config v1.32.14/go.mod h1:U4/V0uKxh0Tl5sxmCBZ3AecYny4UNlVmObYjKuuaiOo= -github.com/aws/aws-sdk-go-v2/credentials v1.19.14 h1:n+UcGWAIZHkXzYt87uMFBv/l8THYELoX6gVcUvgl6fI= -github.com/aws/aws-sdk-go-v2/credentials v1.19.14/go.mod h1:cJKuyWB59Mqi0jM3nFYQRmnHVQIcgoxjEMAbLkpr62w= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.21 h1:NUS3K4BTDArQqNu2ih7yeDLaS3bmHD0YndtA6UP884g= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.21/go.mod h1:YWNWJQNjKigKY1RHVJCuupeWDrrHjRqHm0N9rdrWzYI= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.21 h1:Rgg6wvjjtX8bNHcvi9OnXWwcE0a2vGpbwmtICOsvcf4= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.21/go.mod h1:A/kJFst/nm//cyqonihbdpQZwiUhhzpqTsdbhDdRF9c= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.21 h1:PEgGVtPoB6NTpPrBgqSE5hE/o47Ij9qk/SEZFbUOe9A= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.21/go.mod h1:p+hz+PRAYlY3zcpJhPwXlLC4C+kqn70WIHwnzAfs6ps= -github.com/aws/aws-sdk-go-v2/internal/ini v1.8.6 h1:qYQ4pzQ2Oz6WpQ8T3HvGHnZydA72MnLuFK9tJwmrbHw= -github.com/aws/aws-sdk-go-v2/internal/ini v1.8.6/go.mod h1:O3h0IK87yXci+kg6flUKzJnWeziQUKciKrLjcatSNcY= +github.com/aws/aws-sdk-go-v2 v1.43.0 h1:fharf/WhbRAVZ1du0QL7roNFxZ6T/sWr+4Ni617bwSI= +github.com/aws/aws-sdk-go-v2 v1.43.0/go.mod h1:5pKeft2eJj+gElQ38Jqg4ibCqh+/AK33/0X3hip7IjM= +github.com/aws/aws-sdk-go-v2/config v1.32.31 h1:n4nY9O3QKoHIkL85EX+V8RcMFtOhlpTFhGArg915PXk= +github.com/aws/aws-sdk-go-v2/config v1.32.31/go.mod h1:PN0NYDCCoOpGGsZ2+elDUidmHfQBPyYzN2GCgl8HEBs= +github.com/aws/aws-sdk-go-v2/credentials v1.19.30 h1:TTCvvzFU6gXa4iJecNG/0F/B0oYTiazoRECr2XyLHrY= +github.com/aws/aws-sdk-go-v2/credentials v1.19.30/go.mod h1:jKxAp2AEncnliinzpgOSZDFv6+VjvWhjw/AtbfsWT9U= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.31 h1:kfVL5wAunCJycL6MOQ6aNh6PlAYEymflcjuKmrWUA0o= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.31/go.mod h1:nWfRNDAppujCQgOUd43lKT4yeLv9z3nJ3bw1G3BgQKo= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.31 h1:Z8F3hfCY33IGpJjFAnv0wvtv1FIKj1GHmRDEYqy64tw= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.31/go.mod h1:aVyUoytEyOViR6jhq6jula0xkc5NfBE2hgeF6BvOrao= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.31 h1:hyOxUyXdh3AyjE93gBgsfziJag9ACwcs+ZpDBLzi8mw= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.31/go.mod h1:OERqI9k0draSLB8O8woxY3q25ZWTELRK4RRoLMuMZFo= +github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.32 h1:0MrUL35H/Y4kdFfItoR5jCgtDQ4Z/8LudAoIHRfA4hE= +github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.32/go.mod h1:2tNZkuWz54arj8mHVf+8Y7cKkcD8Wr/fBpENgEXpjLc= github.com/aws/aws-sdk-go-v2/service/ec2 v1.296.0 h1:98Miqj16un1WLNyM1RjVDhXYumhqZrQfAeG8i4jPG6o= github.com/aws/aws-sdk-go-v2/service/ec2 v1.296.0/go.mod h1:T6ndRfdhnXLIY5oKBHjYZDVj706los2zGdpThppquvA= github.com/aws/aws-sdk-go-v2/service/ecs v1.74.0 h1:YS5TXaEvzDb+sV+wdQFUtuCAk0GeFR9Ai6HFdxpz6q8= github.com/aws/aws-sdk-go-v2/service/ecs v1.74.0/go.mod h1:10kBgdaNJz0FO/+JWDUH+0rtSjkn5yafgavDDmmhFzs= github.com/aws/aws-sdk-go-v2/service/elasticache v1.51.12 h1:S066ajzfPRCSW4lsSHOYglne6SNi2CHt1u5omzW1RBg= github.com/aws/aws-sdk-go-v2/service/elasticache v1.51.12/go.mod h1:86SE4NcXxbxr8KTG3yOyDmd4HyiFmKl8TexXnhYJ+Bw= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.7 h1:5EniKhLZe4xzL7a+fU3C2tfUN4nWIqlLesfrjkuPFTY= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.7/go.mod h1:x0nZssQ3qZSnIcePWLvcoFisRXJzcTVvYpAAdYX8+GI= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.21 h1:c31//R3xgIJMSC8S6hEVq+38DcvUlgFY0FM6mSI5oto= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.21/go.mod h1:r6+pf23ouCB718FUxaqzZdbpYFyDtehyZcmP5KL9FkA= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.13 h1:mbRIur/BiHK6SKPjoBIXSE/hJ6g6JGRLuxQy1jGjlN4= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.13/go.mod h1:ITg9em2KbJx1s0y4aqRX5OYWG6HBZ5TVR//OdpEZ2CQ= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.31 h1:w2SIhW92DZPFrSL4ksVCr8IYff5OZwIcxg8+95tzvAI= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.31/go.mod h1:wAhpCQbkov+IcvjozJbd2xRCoZybUEHNkcFunssNACg= github.com/aws/aws-sdk-go-v2/service/kafka v1.49.1 h1:BgBatWcQIFqF1l6KGHjv66V0d/ISnWrTwxDx/Jf6EJM= github.com/aws/aws-sdk-go-v2/service/kafka v1.49.1/go.mod h1:pMpys+PlrN//vj8j5s0oOAMJjauj81VkHzIZxPVWOro= github.com/aws/aws-sdk-go-v2/service/lightsail v1.51.0 h1:cg6PxzoIide2wiEyLfikOFN+XwHafwR8p5+L9U1E8dQ= github.com/aws/aws-sdk-go-v2/service/lightsail v1.51.0/go.mod h1:YvX7hjUWecrKX8fBkbEncyddEW85xjNH+u5JHioITOw= github.com/aws/aws-sdk-go-v2/service/rds v1.117.0 h1:T1Xe9sYxSUUQOvd1RsFeVk/IXFPdqSiN0atXu/Hy/8A= github.com/aws/aws-sdk-go-v2/service/rds v1.117.0/go.mod h1:QbXW4coAMakHQhf1qhE0eVVCen9gwB/Kvn+HHHKhpGY= -github.com/aws/aws-sdk-go-v2/service/signin v1.0.9 h1:QKZH0S178gCmFEgst8hN0mCX1KxLgHBKKY/CLqwP8lg= -github.com/aws/aws-sdk-go-v2/service/signin v1.0.9/go.mod h1:7yuQJoT+OoH8aqIxw9vwF+8KpvLZ8AWmvmUWHsGQZvI= -github.com/aws/aws-sdk-go-v2/service/sso v1.30.15 h1:lFd1+ZSEYJZYvv9d6kXzhkZu07si3f+GQ1AaYwa2LUM= -github.com/aws/aws-sdk-go-v2/service/sso v1.30.15/go.mod h1:WSvS1NLr7JaPunCXqpJnWk1Bjo7IxzZXrZi1QQCkuqM= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.19 h1:dzztQ1YmfPrxdrOiuZRMF6fuOwWlWpD2StNLTceKpys= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.19/go.mod h1:YO8TrYtFdl5w/4vmjL8zaBSsiNp3w0L1FfKVKenZT7w= -github.com/aws/aws-sdk-go-v2/service/sts v1.41.10 h1:p8ogvvLugcR/zLBXTXrTkj0RYBUdErbMnAFFp12Lm/U= -github.com/aws/aws-sdk-go-v2/service/sts v1.41.10/go.mod h1:60dv0eZJfeVXfbT1tFJinbHrDfSJ2GZl4Q//OSSNAVw= -github.com/aws/smithy-go v1.25.0 h1:Sz/XJ64rwuiKtB6j98nDIPyYrV1nVNJ4YU74gttcl5U= -github.com/aws/smithy-go v1.25.0/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc= +github.com/aws/aws-sdk-go-v2/service/signin v1.5.0 h1:OHH5iTQvVGmfHjX/5Q+vFuA/Rf2x6/95aJ/75QCQSm4= +github.com/aws/aws-sdk-go-v2/service/signin v1.5.0/go.mod h1:mCF3AK9PpL49oOrhniUXWAfhVBVQ/XbytoE5eccZUIs= +github.com/aws/aws-sdk-go-v2/service/sso v1.33.0 h1:CaJyYhxBE0M/HJX/YvSaSmQlsI91VHB0lKU8LtLxL3A= +github.com/aws/aws-sdk-go-v2/service/sso v1.33.0/go.mod h1:+e6BMRMPjBQoCw/WovYR9GLy2IU0z4Q77smOB1DraSg= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.38.0 h1:tC323YV77QdafeBr6LUhLDTsboyuyHLNRwAyCP44kGU= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.38.0/go.mod h1:SfLK1sgviHmbI+MozR9iDwDjL4cdCVZtahsjoR+z7wg= +github.com/aws/aws-sdk-go-v2/service/sts v1.45.0 h1:Pd6PNlp4t8PTXxqzstICl52Wsy78vpjFZ7PRUj44mJc= +github.com/aws/aws-sdk-go-v2/service/sts v1.45.0/go.mod h1:rmQ0TnHzuLPmabgjPcsywhsSOmaBDgzR4zvDxSPsGdg= +github.com/aws/smithy-go v1.27.3 h1:F3Zb497UhhskkfpJmfkXswyo+t0sh9OTBnIHjogWbVY= +github.com/aws/smithy-go v1.27.3/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc= github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk= github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= github.com/basgys/goxml2json v1.1.1-0.20231018121955-e66ee54ceaad h1:3swAvbzgfaI6nKuDDU7BiKfZRdF+h2ZwKgMHd8Ha4t8= @@ -91,8 +91,8 @@ github.com/bitly/go-simplejson v0.5.1 h1:xgwPbetQScXt1gh9BmoJ6j9JMr3TElvuIyjR8pg github.com/bitly/go-simplejson v0.5.1/go.mod h1:YOPVLzCfwK14b4Sff3oP1AmGhI9T9Vsg84etUnlyp+Q= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= -github.com/buger/jsonparser v1.1.2 h1:frqHqw7otoVbk5M8LlE/L7HTnIq2v9RX6EJ48i9AxJk= -github.com/buger/jsonparser v1.1.2/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= +github.com/buger/jsonparser v1.2.0 h1:4EFcvK1kD4jyj6YqNK6skK6w+y7FHHBR+XBCtxwu/6g= +github.com/buger/jsonparser v1.2.0/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= github.com/ccojocar/zxcvbn-go v1.0.4 h1:FWnCIRMXPj43ukfX000kvBZvV6raSxakYr1nzyNrUcc= github.com/ccojocar/zxcvbn-go v1.0.4/go.mod h1:3GxGX+rHmueTUMvm5ium7irpyjmm7ikxYFOSJB21Das= github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= @@ -101,8 +101,8 @@ github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1x github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cncf/xds/go v0.0.0-20251210132809-ee656c7534f5 h1:6xNmx7iTtyBRev0+D/Tv1FZd4SCg8axKApyNyRsAt/w= -github.com/cncf/xds/go v0.0.0-20251210132809-ee656c7534f5/go.mod h1:KdCmV+x/BuvyMxRnYBlmVaq4OLiKW6iRQfvC62cvdkI= +github.com/cncf/xds/go v0.0.0-20260202195803-dba9d589def2 h1:aBangftG7EVZoUb69Os8IaYg++6uMOdKK83QtkkvJik= +github.com/cncf/xds/go v0.0.0-20260202195803-dba9d589def2/go.mod h1:qwXFYgsP6T7XnJtbKlf1HP8AjxZZyzxMmc+Lq5GjlU4= github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI= github.com/containerd/errdefs v1.0.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M= github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE= @@ -126,8 +126,8 @@ github.com/digitalocean/godo v1.178.0 h1:+B4xGOaoFwwwpM7TKhoyGHdmFg5eF9zDB1YfOLv github.com/digitalocean/godo v1.178.0/go.mod h1:xQsWpVCCbkDrWisHA72hPzPlnC+4W5w/McZY5ij9uvU= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= -github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ= -github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= +github.com/dlclark/regexp2 v1.12.0 h1:0j4c5qQmnC6XOWNjP3PIXURXN2gWx76rd3KvgdPkCz8= +github.com/dlclark/regexp2 v1.12.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= github.com/docker/docker v28.5.2+incompatible h1:DBX0Y0zAjZbSrm1uzOkdr1onVghKaftjlSWt4AFexzM= @@ -159,8 +159,8 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= -github.com/fxamacker/cbor/v2 v2.9.1 h1:2rWm8B193Ll4VdjsJY28jxs70IdDsHRWgQYAI80+rMQ= -github.com/fxamacker/cbor/v2 v2.9.1/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ= +github.com/fxamacker/cbor/v2 v2.9.2 h1:X4Ksno9+x3cz0TZv69ec1hxP/+tymuR8PXQJyDwfh78= +github.com/fxamacker/cbor/v2 v2.9.2/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -172,8 +172,8 @@ github.com/go-openapi/analysis v0.25.0 h1:EnjAq1yO8wEO9HbPmY8vLPEIkdZuuFhCAKBPvC github.com/go-openapi/analysis v0.25.0/go.mod h1:5WFTRE43WLkPG9r9OtlMfqkkvUTYLVVCIxLlEpyF8kE= github.com/go-openapi/errors v0.22.7 h1:JLFBGC0Apwdzw3484MmBqspjPbwa2SHvpDm0u5aGhUA= github.com/go-openapi/errors v0.22.7/go.mod h1://QW6SD9OsWtH6gHllUCddOXDL0tk0ZGNYHwsw4sW3w= -github.com/go-openapi/jsonpointer v0.22.5 h1:8on/0Yp4uTb9f4XvTrM2+1CPrV05QPZXu+rvu2o9jcA= -github.com/go-openapi/jsonpointer v0.22.5/go.mod h1:gyUR3sCvGSWchA2sUBJGluYMbe1zazrYWIkWPjjMUY0= +github.com/go-openapi/jsonpointer v0.23.2 h1:DK7R/3zAt4xTytxNkw7jARGPFI7rkaSsii58n8X45x0= +github.com/go-openapi/jsonpointer v0.23.2/go.mod h1:noUOckXtq7b4bVkqw0sbHKieq9uEZRN7p6EF/dalc4w= github.com/go-openapi/jsonreference v0.21.5 h1:6uCGVXU/aNF13AQNggxfysJ+5ZcU4nEAe+pJyVWRdiE= github.com/go-openapi/jsonreference v0.21.5/go.mod h1:u25Bw85sX4E2jzFodh1FOKMTZLcfifd1Q+iKKOUxExw= github.com/go-openapi/loads v0.23.3 h1:g5Xap1JfwKkUnZdn+S0L3SzBDpcTIYzZ5Qaag0YDkKQ= @@ -190,8 +190,8 @@ github.com/go-openapi/swag/conv v0.26.0 h1:5yGGsPYI1ZCva93U0AoKi/iZrNhaJEjr324YV github.com/go-openapi/swag/conv v0.26.0/go.mod h1:tpAmIL7X58VPnHHiSO4uE3jBeRamGsFsfdDeDtb5ECE= github.com/go-openapi/swag/fileutils v0.26.0 h1:WJoPRvsA7QRiiWluowkLJa9jaYR7FCuxmDvnCgaRRxU= github.com/go-openapi/swag/fileutils v0.26.0/go.mod h1:0WDJ7lp67eNjPMO50wAWYlKvhOb6CQ37rzR7wrgI8Tc= -github.com/go-openapi/swag/jsonname v0.26.0 h1:gV1NFX9M8avo0YSpmWogqfQISigCmpaiNci8cGECU5w= -github.com/go-openapi/swag/jsonname v0.26.0/go.mod h1:urBBR8bZNoDYGr653ynhIx+gTeIz0ARZxHkAPktJK2M= +github.com/go-openapi/swag/jsonname v0.26.1 h1:VReupaV6WxlAsCn0e4DUfgV6bPmINnPpyJDLqSfNPcE= +github.com/go-openapi/swag/jsonname v0.26.1/go.mod h1:OvdW6BoWoj33pTfi7x9vFrgmT+fk7aw0BRwvCE0YOuc= github.com/go-openapi/swag/jsonutils v0.26.0 h1:FawFML2iAXsPqmERscuMPIHmFsoP1tOqWkxBaKNMsnA= github.com/go-openapi/swag/jsonutils v0.26.0/go.mod h1:2VmA0CJlyFqgawOaPI9psnjFDqzyivIqLYN34t9p91E= github.com/go-openapi/swag/jsonutils/fixtures_test v0.26.0 h1:apqeINu/ICHouqiRZbyFvuDge5jCmmLTqGQ9V95EaOM= @@ -210,8 +210,8 @@ github.com/go-openapi/swag/yamlutils v0.26.0 h1:H7O8l/8NJJQ/oiReEN+oMpnGMyt8G0hl github.com/go-openapi/swag/yamlutils v0.26.0/go.mod h1:1evKEGAtP37Pkwcc7EWMF0hedX0/x3Rkvei2wtG/TbU= github.com/go-openapi/testify/enable/yaml/v2 v2.4.2 h1:5zRca5jw7lzVREKCZVNBpysDNBjj74rBh0N2BGQbSR0= github.com/go-openapi/testify/enable/yaml/v2 v2.4.2/go.mod h1:XVevPw5hUXuV+5AkI1u1PeAm27EQVrhXTTCPAF85LmE= -github.com/go-openapi/testify/v2 v2.4.2 h1:tiByHpvE9uHrrKjOszax7ZvKB7QOgizBWGBLuq0ePx4= -github.com/go-openapi/testify/v2 v2.4.2/go.mod h1:SgsVHtfooshd0tublTtJ50FPKhujf47YRqauXXOUxfw= +github.com/go-openapi/testify/v2 v2.6.0 h1:5PKH2HE7YJ/LuRPQGvSxBRlFXNQhSetBLlGAgUEu3ug= +github.com/go-openapi/testify/v2 v2.6.0/go.mod h1:SgsVHtfooshd0tublTtJ50FPKhujf47YRqauXXOUxfw= github.com/go-openapi/validate v0.25.2 h1:12NsfLAwGegqbGWr2CnvT65X/Q2USJipmJ9b7xDJZz0= github.com/go-openapi/validate v0.25.2/go.mod h1:Pgl1LpPPGFnZ+ys4/hTlDiRYQdI1ocKypgE+8Q8BLfY= github.com/go-resty/resty/v2 v2.17.2 h1:FQW5oHYcIlkCNrMD2lloGScxcHJ0gkjshV3qcQAyHQk= @@ -272,8 +272,8 @@ github.com/googleapis/gax-go/v2 v2.22.0 h1:PjIWBpgGIVKGoCXuiCoP64altEJCj3/Ei+kSU github.com/googleapis/gax-go/v2 v2.22.0/go.mod h1:irWBbALSr0Sk3qlqb9SyJ1h68WjgeFuiOzI4Rqw5+aY= github.com/gookit/assert v0.1.1 h1:lh3GcawXe/p+cU7ESTZ5Ui3Sm/x8JWpIis4/1aF0mY0= github.com/gookit/assert v0.1.1/go.mod h1:jS5bmIVQZTIwk42uXl4lyj4iaaxx32tqH16CFj0VX2E= -github.com/gookit/color v1.6.0 h1:JjJXBTk1ETNyqyilJhkTXJYYigHG24TM9Xa2M1xAhRA= -github.com/gookit/color v1.6.0/go.mod h1:9ACFc7/1IpHGBW8RwuDm/0YEnhg3dwwXpoMsmtyHfjs= +github.com/gookit/color v1.6.1 h1:KoTnDxJPRgrL0SoX0f8rCFg2zI0t4E3GZZBMo2nN8LU= +github.com/gookit/color v1.6.1/go.mod h1:9ACFc7/1IpHGBW8RwuDm/0YEnhg3dwwXpoMsmtyHfjs= github.com/gophercloud/gophercloud/v2 v2.11.1 h1:jCs4vLH8sJgRqrPzqVfWgl7uI6JnIIlsgeIRM0uHjxY= github.com/gophercloud/gophercloud/v2 v2.11.1/go.mod h1:Rm0YvKQ4QYX2rY9XaDKnjRzSGwlG5ge4h6ABYnmkKQM= github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 h1:JeSE6pjso5THxAzdVpqr6/geYxZytqFMBCOtn/ujyeo= @@ -325,14 +325,14 @@ github.com/keybase/go-keychain v0.0.1 h1:way+bWYa6lDppZoZcgMbYsvC7GxljxrskdNInRt github.com/keybase/go-keychain v0.0.1/go.mod h1:PdEILRW3i9D8JcdM+FmY6RwkHGnhHxXwkPPMeUgOK1k= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.18.5 h1:/h1gH5Ce+VWNLSWqPzOVn6XBO+vJbCNGvjoaGBFW2IE= -github.com/klauspost/compress v1.18.5/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ= +github.com/klauspost/compress v1.18.7 h1:aUyZsS4kH3QTKurYhAOwAHxllVPnOthb3vPfnF1Ehjw= +github.com/klauspost/compress v1.18.7/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ= github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo= github.com/knadh/koanf/maps v0.1.2/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI= github.com/knadh/koanf/providers/confmap v1.0.0 h1:mHKLJTE7iXEys6deO5p6olAiZdG5zwp8Aebir+/EaRE= github.com/knadh/koanf/providers/confmap v1.0.0/go.mod h1:txHYHiI2hAtF0/0sCmcuol4IDcuQbKTybiB1nOcUo1A= -github.com/knadh/koanf/v2 v2.3.4 h1:fnynNSDlujWE+v83hAp8wKr/cdoxHLO0629SN+U8Urc= -github.com/knadh/koanf/v2 v2.3.4/go.mod h1:gRb40VRAbd4iJMYYD5IxZ6hfuopFcXBpc9bbQpZwo28= +github.com/knadh/koanf/v2 v2.3.5 h1:2dXJUYaKGm4SGYeoAtBviq9+02JZo/pxQ2ssOd60rJg= +github.com/knadh/koanf/v2 v2.3.5/go.mod h1:gRb40VRAbd4iJMYYD5IxZ6hfuopFcXBpc9bbQpZwo28= github.com/kolo/xmlrpc v0.0.0-20220921171641-a4b6fa1dd06b h1:udzkj9S/zlT5X367kqJis0QP7YMxobob6zhzq6Yre00= github.com/kolo/xmlrpc v0.0.0-20220921171641-a4b6fa1dd06b/go.mod h1:pcaDhQK0/NJZEvtCO0qQPPropqV0sJOJ6YW7X+9kRwM= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -345,8 +345,8 @@ github.com/linode/linodego v1.66.0 h1:rK8QJFaV53LWOEJvb/evhTg/dP5ElvtuZmx4iv4RJd github.com/linode/linodego v1.66.0/go.mod h1:12ykGs9qsvxE+OU3SXuW2w+DTruWF35FPlXC7gGk2tU= github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= -github.com/mattn/go-isatty v0.0.21 h1:xYae+lCNBP7QuW4PUnNG61ffM4hVIfm+zUzDuSzYLGs= -github.com/mattn/go-isatty v0.0.21/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4= +github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI= +github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A= github.com/miekg/dns v1.1.72 h1:vhmr+TF2A3tuoGNkLDFK9zi36F2LS+hKTRW0Uf8kbzI= github.com/miekg/dns v1.1.72/go.mod h1:+EuEPhdHOsfk6Wk5TT2CzssZdqkmFhf8r+aVyDEToIs= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= @@ -384,14 +384,14 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.39.1 h1:1IJLAad4zjPn2PsnhH70V4DKRFlrCzGBNrNaru+Vf28= github.com/onsi/gomega v1.39.1/go.mod h1:hL6yVALoTOxeWudERyfppUcZXjMwIMLnuSfruD2lcfg= -github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics v0.150.0 h1:kRIR4xDIE94IGdHMrYlfMjzlxInL8f9UO9jz+R4iHEc= -github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics v0.150.0/go.mod h1:aOBH3hR2zVgVFUbpTSjxuHTCkx+rvg7OWDNnTYUDB3w= -github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.150.0 h1:eMU3aV8tUWhTlZwrW/eHbw3JCxsUDXqLKqswqj/vtlQ= -github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.150.0/go.mod h1:qYh2PcJsgK0qJ0+vjLYow+E2DAJ7o1MuZ3r0hakgxiE= -github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor v0.150.0 h1:Jg2Ets7VwgAZUmnaptx7TJTnjPG7nYZhGOeaveTpC/8= -github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor v0.150.0/go.mod h1:SdJHLLrcNFtcPIY4NUTLyx4+0gZZRyOTJfrVLUVxILQ= -github.com/openai/openai-go/v3 v3.32.0 h1:aHp/3wkX1W6jB8zTtf9xV0aK0qPFSVDqS7AHmlJ4hXs= -github.com/openai/openai-go/v3 v3.32.0/go.mod h1:cdufnVK14cWcT9qA1rRtrXx4FTRsgbDPW7Ia7SS5cZo= +github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics v0.157.0 h1:WzyLbYQ5GswNa/3Jma/bYYbn2ziLoQct2VEoN5u1j74= +github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics v0.157.0/go.mod h1:TmipmukIEZQwvWXuFMaSnDBlaNzgsyiHcv54luc76pk= +github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.157.0 h1:oQWc2BKFkPqo14Zh+qDEWZItxJacKSubLjtFirojFnk= +github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.157.0/go.mod h1:fMeXcxEg6tHlCPRjf2jQ6KavnvDrwoGvJ8q8ihDk3BE= +github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor v0.157.0 h1:y/Uf4K+H3WOWIFEbqymmBcw6s5QQe/hxTy23UERke7w= +github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor v0.157.0/go.mod h1:2J1/XjEfj6pQkRGOjE81TjDFUxH+v0JnMtELt0VhOtA= +github.com/openai/openai-go/v3 v3.45.0 h1:bmSSXh5EhTrFA7AFYFLBs4NmeIuWB8iUSk+gGKUTmkA= +github.com/openai/openai-go/v3 v3.45.0/go.mod h1:b8MgNMpR3lPifYnaOH8XwcG8qRHwhzZxuDgM9lL7h5k= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= @@ -406,12 +406,14 @@ github.com/ovh/go-ovh v1.9.0 h1:6K8VoL3BYjVV3In9tPJUdT7qMx9h0GExN9EXx1r2kKE= github.com/ovh/go-ovh v1.9.0/go.mod h1:cTVDnl94z4tl8pP1uZ/8jlVxntjSIf09bNcQ5TJSC7c= github.com/pb33f/jsonpath v0.8.2 h1:Ou4C7zjYClBm97dfZjDCjdZGusJoynv/vrtiEKNfj2Y= github.com/pb33f/jsonpath v0.8.2/go.mod h1:zBV5LJW4OQOPatmQE2QdKpGQJvhDTlE5IEj6ASaRNTo= -github.com/pb33f/libopenapi v0.36.1 h1:CNZ52e+/W9fA1kAgL8EePDQQrKPfN9+HdLR6XAxUEpw= -github.com/pb33f/libopenapi v0.36.1/go.mod h1:MsDdUlQ1CdrIDO5v26JfgBxQs7kcaOUEpMP3EqU6bI4= -github.com/pb33f/libopenapi-validator v0.13.4 h1:/6NJtmPIZYPT2mEbMAz+BfSoGoCNrwYL46ikEaFy0pM= -github.com/pb33f/libopenapi-validator v0.13.4/go.mod h1:e6HLPJM493yfJmnNn81fb3Mt6Iyy8Knd1iuzyyW1A9Y= +github.com/pb33f/libopenapi v0.38.7 h1:Q2jfgRPdnU38WW8wQvrX2HEPGiqsxj01PX1BHmAEihc= +github.com/pb33f/libopenapi v0.38.7/go.mod h1:naZ03Auhn7i+RJtMv8ck8l7Ag8E2/x2w66j9vsDFL38= +github.com/pb33f/libopenapi-validator v0.14.0 h1:K9cdv1kL6cZdQmSbzitkVcWCJKyRmmSZryZqgUqIv+Y= +github.com/pb33f/libopenapi-validator v0.14.0/go.mod h1:EU6yVajX6rWwUAC4OWfsVPPwAZ7k29fruoZnMnzdKjI= github.com/pb33f/ordered-map/v2 v2.3.1 h1:5319HDO0aw4DA4gzi+zv4FXU9UlSs3xGZ40wcP1nBjY= github.com/pb33f/ordered-map/v2 v2.3.1/go.mod h1:qxFQgd0PkVUtOMCkTapqotNgzRhMPL7VvaHKbd1HnmQ= +github.com/pb33f/testify v0.1.0 h1:g48/HDU/jn2COspS4nM0scptxiKTJ4DnbX/4ehK6IZ8= +github.com/pb33f/testify v0.1.0/go.mod h1:nq283P/jJ8hXMmdhAqfj7BJIz0y+6IOHj9q0044rKt4= github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o= github.com/pborman/uuid v1.2.1 h1:+ZZIw58t/ozdjRaXh/3awHfmWRbzYxJoAdNJxe/3pvw= github.com/pborman/uuid v1.2.1/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= @@ -432,22 +434,22 @@ github.com/prometheus/alertmanager v0.32.0 h1:JER/KWXvbmSo6cd8EtnP7y+0VWKG8RiYH+ github.com/prometheus/alertmanager v0.32.0/go.mod h1:0Dy9faTtMgpVYxJVxV0o65elTxHnSRCF/7gy5BKGZiE= github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o= github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg= -github.com/prometheus/client_golang/exp v0.0.0-20260415123413-5f35560ef2c7 h1:Lnvc2rQ+WB2Ep1YOOdWfzDY5wuMxqpDzKiifi3pTdpg= -github.com/prometheus/client_golang/exp v0.0.0-20260415123413-5f35560ef2c7/go.mod h1:xA9/W/d/j+zeg2Kp3UgOF+E2rbq7KNVa5PLJPJBE0lw= +github.com/prometheus/client_golang/exp v0.0.0-20260702112354-832cec72badf h1:ADcMVtO61/zZwZ8MCgIk/Tt6Vq6zqzJ9akod1M7bdmE= +github.com/prometheus/client_golang/exp v0.0.0-20260702112354-832cec72badf/go.mod h1:51yJyeRLbMrcL3LmLZXzQFDIsRngI86ZGPnUmDsWGBU= github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk= github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE= -github.com/prometheus/common v0.67.5 h1:pIgK94WWlQt1WLwAC5j2ynLaBRDiinoAb86HZHTUGI4= -github.com/prometheus/common v0.67.5/go.mod h1:SjE/0MzDEEAyrdr5Gqc6G+sXI67maCxzaT3A2+HqjUw= +github.com/prometheus/common v0.69.0 h1:OA85nJQS/T/MaYh/Q2CcgDKSGWqNIgrBDvDH85CuiNk= +github.com/prometheus/common v0.69.0/go.mod h1:ZzL3f6u94qUxh9p+tJTrF+FvBS1XXbbRAZCQkytAL0Y= github.com/prometheus/otlptranslator v1.0.0 h1:s0LJW/iN9dkIH+EnhiD3BlkkP5QVIUVEoIwkU+A6qos= github.com/prometheus/otlptranslator v1.0.0/go.mod h1:vRYWnXvI6aWGpsdY/mOT/cbeVRBlPWtBNDb7kGR3uKM= github.com/prometheus/procfs v0.20.1 h1:XwbrGOIplXW/AU3YhIhLODXMJYyC1isLFfYCsTEycfc= github.com/prometheus/procfs v0.20.1/go.mod h1:o9EMBZGRyvDrSPH1RqdxhojkuXstoe4UlK79eF5TGGo= -github.com/prometheus/prometheus v0.311.2 h1:6fBxp93y08GAZGNT1o3bIhgV/AMYvBFfU+ltDNEsHg8= -github.com/prometheus/prometheus v0.311.2/go.mod h1:gjsCxTKtHO1Q8T9333u1s+lUR1OjPyM7ruuGH8RvVyo= +github.com/prometheus/prometheus v0.311.3 h1:3IrVxQv6v5i/ZCGi6OrYeBhtCwaPTn6Z3DYruXoYm3M= +github.com/prometheus/prometheus v0.311.3/go.mod h1:gjsCxTKtHO1Q8T9333u1s+lUR1OjPyM7ruuGH8RvVyo= github.com/prometheus/sigv4 v0.4.1 h1:EIc3j+8NBea9u1iV6O5ZAN8uvPq2xOIUPcqCTivHuXs= github.com/prometheus/sigv4 v0.4.1/go.mod h1:eu+ZbRvsc5TPiHwqh77OWuCnWK73IdkETYY46P4dXOU= -github.com/puzpuzpuz/xsync/v4 v4.4.0 h1:vlSN6/CkEY0pY8KaB0yqo/pCLZvp9nhdbBdjipT4gWo= -github.com/puzpuzpuz/xsync/v4 v4.4.0/go.mod h1:VJDmTCJMBt8igNxnkQd86r+8KUeN1quSfNKu5bLYFQo= +github.com/puzpuzpuz/xsync/v4 v4.5.0 h1:vOSWu6b57/emh+L/Cw0BeQfvxa/cogFywXHeGUxQxAg= +github.com/puzpuzpuz/xsync/v4 v4.5.0/go.mod h1:VJDmTCJMBt8igNxnkQd86r+8KUeN1quSfNKu5bLYFQo= github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -484,8 +486,8 @@ github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8 github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= -github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.19.0 h1:xwxm7n691Uf3u5OFjzngavjGTh55KX5q/9w9xHW88JU= +github.com/tidwall/gjson v1.19.0/go.mod h1:V37/opeE/JbLUOfH0QTXiNez2l0RUjYUhpT4szFQAfc= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/match v1.2.0 h1:0pt8FlkOwjN2fPt4bIl4BoNxb98gGHN2ObFEDkrfZnM= github.com/tidwall/match v1.2.0/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= @@ -507,60 +509,60 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= -go.opentelemetry.io/collector/component v1.56.0 h1:fOCs36Dxg95w2RQCVI2i5IsHc5IbZ99vmbipK9FM7pQ= -go.opentelemetry.io/collector/component v1.56.0/go.mod h1:MkAjcSc2T0BiYf/uARZdTlfnxBB9BwmvY6v08D+qeY4= -go.opentelemetry.io/collector/component/componentstatus v0.150.0 h1:Jy/9quAWwDN9BqMEzZn0BEzVxxWARa1b/wvBQW6yPxs= -go.opentelemetry.io/collector/component/componentstatus v0.150.0/go.mod h1:FFmyHgPqwtvkezi9Z9NYgXxY0m3N0oUMMd/HIAEq8vY= -go.opentelemetry.io/collector/component/componenttest v0.150.0 h1:pT7avT/Pfn8tAOOlmFWgtOaGvXY0nxSwrivnhOl/LH0= -go.opentelemetry.io/collector/component/componenttest v0.150.0/go.mod h1:D+7mfbcZ/TfneQRZNtVwH+/YKQdalc1joa9NhH1BGPk= -go.opentelemetry.io/collector/confmap v1.56.0 h1:YjLll5L77Z3up94t/pdOMaH35kwd28EtjBORewfIjmA= -go.opentelemetry.io/collector/confmap v1.56.0/go.mod h1:iprN8aL/euBXig6bpLZSZqi+8CZIgE9/Pm6y3qb1QWY= -go.opentelemetry.io/collector/confmap/xconfmap v0.150.0 h1:PR+c4/Ly4Plx862jJ1Cg+HFewMrHsWaN9eKxrYBhtK4= -go.opentelemetry.io/collector/confmap/xconfmap v0.150.0/go.mod h1:WDLyne6Zmoi5OZ46Hfg4z/5KhsBG1mFuYjoK20VcDcA= -go.opentelemetry.io/collector/consumer v1.56.0 h1:olhuaTI3cic6VfcraXt3qqsv1v4Qxf55gHxOO1uIVXw= -go.opentelemetry.io/collector/consumer v1.56.0/go.mod h1:FpnfeTLQAdcOtzrkQ36Z+E5aconIymkv9xpJuAdLvy0= -go.opentelemetry.io/collector/consumer/consumertest v0.150.0 h1:DQtVy0BUTQqHKKOyM0hYnxV8H2kKHjayc8aMMa2fow0= -go.opentelemetry.io/collector/consumer/consumertest v0.150.0/go.mod h1:2mgIllFOgoq+SQ7QfXzaZn65pa6OZWobcy3yj+Ik9Ug= -go.opentelemetry.io/collector/consumer/xconsumer v0.150.0 h1:URO73bAV00wTH9bJeloqaiLgS3Q80GNci+nm1iZ3W6Q= -go.opentelemetry.io/collector/consumer/xconsumer v0.150.0/go.mod h1:BMcOInfcRUpVZ2R4qa3vNglvU6mWL+0dhAayH87YSB8= -go.opentelemetry.io/collector/featuregate v1.56.0 h1:NjcbOZkdCSXddAJmFLdO+pv1gmAgrU6sC5PBga2KlKI= -go.opentelemetry.io/collector/featuregate v1.56.0/go.mod h1:4ga1QBMPEejXXmpyJS8lmaRpknJ3Lb9Bvk6e420bUFU= -go.opentelemetry.io/collector/internal/componentalias v0.150.0 h1:qvcJr0m/fFgsc3x6Oya3RNDOZp/WyfmOKIv9jtvoLYw= -go.opentelemetry.io/collector/internal/componentalias v0.150.0/go.mod h1:abuQP8ELgPpCSq6xbHM1b2hPOGqaKxUeLgHHdU/XGP0= -go.opentelemetry.io/collector/internal/testutil v0.150.0 h1:J4PLQGPfbLVaL5eI1aMc0m0TMixV9wzBhNhoHU00J0I= -go.opentelemetry.io/collector/internal/testutil v0.150.0/go.mod h1:Jkjs6rkqs973LqgZ0Fe3zrokQRKULYXPIf4HuqStiEE= -go.opentelemetry.io/collector/pdata v1.56.0 h1:W+QAfN2Iz8SNss1T5JNzRWFnw+7oP1vXBQH9ZuOJkXY= -go.opentelemetry.io/collector/pdata v1.56.0/go.mod h1:usR9utboXufbD1rp1oJy+3smQXXpZ+CsI3WN7QsiOs0= -go.opentelemetry.io/collector/pdata/pprofile v0.150.0 h1:Ae+FxmYXDdcqeLqIAdNSO3YGxco7RS2mIMTdjvavfso= -go.opentelemetry.io/collector/pdata/pprofile v0.150.0/go.mod h1:tEBeGysY/LpIh39NLoQQl3qmUBOF9wyH5p/fmn7smzM= -go.opentelemetry.io/collector/pdata/testdata v0.150.0 h1:nZE3UNuDYd9lfXTk/n5UplPwXBD4tptDIZH5PvWhHKQ= -go.opentelemetry.io/collector/pdata/testdata v0.150.0/go.mod h1:RPOOH2KNevfhu7adoEXVTNtPPZsHwbrSOQKeFZE/220= -go.opentelemetry.io/collector/pipeline v1.56.0 h1:KfyCes/EPC2hpBhU28z9WnJzSRlBYS5FfMHOYAXHbXw= -go.opentelemetry.io/collector/pipeline v1.56.0/go.mod h1:RD90NG3Jbk965Xaqym3JyHkuol4uZJjQVUkD9ddXJIs= -go.opentelemetry.io/collector/processor v1.56.0 h1:5UGXZorhoWg0gnhvDZWYIOUp2dEWfWH28vE+/wV3cMA= -go.opentelemetry.io/collector/processor v1.56.0/go.mod h1:ptpRRg6r9YdXGSKdQcsM6ePH6ZkkkMnlNY8OxIC4Q7c= -go.opentelemetry.io/collector/processor/processortest v0.150.0 h1:M3p/ZcAAKnh/3aZgTgXngWU+9C0Yx/sQLgZNPBP/ZSo= -go.opentelemetry.io/collector/processor/processortest v0.150.0/go.mod h1:szMO3iQ+CDQLCq6y8+deTUc6FbLKi9zNqwtm5+umZk8= -go.opentelemetry.io/collector/processor/xprocessor v0.150.0 h1:tyIM+WT6NRRkynTGtPwPYDRvWlv3YVt9PDteLscW2mU= -go.opentelemetry.io/collector/processor/xprocessor v0.150.0/go.mod h1:m7uoLC+a9G3EOr9v2+fItUMV0EOFrL+RUkPAspBLK1w= +go.opentelemetry.io/collector/component v1.63.0 h1:l98ZCxfCTt/O6dYB0JVKKtewaFLe/a6N2qQe61Tbf2o= +go.opentelemetry.io/collector/component v1.63.0/go.mod h1:yLGMmT7jUiqvuGvkqlfR1CBi0dRkSV67tq22I08ZMPk= +go.opentelemetry.io/collector/component/componentstatus v0.157.0 h1:6aARK84axselDP/YGM1cKVPvg6eIyN7Bg9x8x5GzJb4= +go.opentelemetry.io/collector/component/componentstatus v0.157.0/go.mod h1:R1nsiV3JluCaffVfjDmglZ0cU3jJUsiaMXgsAZfc670= +go.opentelemetry.io/collector/component/componenttest v0.157.0 h1:kTMapOVJ3YMKf5Lu2j/FdcKipn90KkIrnHkKca8uNfk= +go.opentelemetry.io/collector/component/componenttest v0.157.0/go.mod h1:AUzvlwDat8AHaNRDm+dzQ59uaEXQO1qTWccjkRjqq00= +go.opentelemetry.io/collector/confmap v1.63.0 h1:1THBabHoQc8t/9r6ztMsghiO1OxDPZpYtn0cuwwsxYI= +go.opentelemetry.io/collector/confmap v1.63.0/go.mod h1:ksJNAmLTiMkBjMYwXFW1MRRfXYnRsHXA0fW+ZGwb/1U= +go.opentelemetry.io/collector/confmap/xconfmap v0.157.0 h1:jZV8p2wMQhq0ktl1/LAFGOXMCzzfMq56r80r41kKoEs= +go.opentelemetry.io/collector/confmap/xconfmap v0.157.0/go.mod h1:W1wZk6YJ3+IyvIZEmkXH/ejwkUtBV2zCThY6ewZYd6E= +go.opentelemetry.io/collector/consumer v1.63.0 h1:0eOZh0qmDg6HCJaiUqI9FAb4BD4fKJNNO+ygMV/WW0w= +go.opentelemetry.io/collector/consumer v1.63.0/go.mod h1:IVhjv4d+PmSf4Ttz/guJFbWJtRM3Ld3nRcZ12gxy6PA= +go.opentelemetry.io/collector/consumer/consumertest v0.157.0 h1:zehAVaLn67AWLhhi/LrUY0Tv06XWx5LYCvvmu7xHXHU= +go.opentelemetry.io/collector/consumer/consumertest v0.157.0/go.mod h1:HRxCIepTczx1uWnm3VPPNbt0k+N9fG/ENZDF1dGrkQc= +go.opentelemetry.io/collector/consumer/xconsumer v0.157.0 h1:DPbDCHDwbwVa0OoikTktkbXAobN7EgC4XbYaNJIyooI= +go.opentelemetry.io/collector/consumer/xconsumer v0.157.0/go.mod h1:IepWZ5ZNBUuS5OiCPQaD/Q1buqriiItxaaMYD7nqYdc= +go.opentelemetry.io/collector/featuregate v1.63.0 h1:6EWX1C5AtmIh8hFH97DwK6R7R8Jk3fTLxAUfZPXGutY= +go.opentelemetry.io/collector/featuregate v1.63.0/go.mod h1:4ga1QBMPEejXXmpyJS8lmaRpknJ3Lb9Bvk6e420bUFU= +go.opentelemetry.io/collector/internal/componentalias v0.157.0 h1:bvVANHVkXRhoRBc92rDsbiC0OHlu9/EbRqPROD9qrPc= +go.opentelemetry.io/collector/internal/componentalias v0.157.0/go.mod h1:PCLANRXGlMhf9NmU+JPFHtZuY4WpMOsccXlDHTDTu1w= +go.opentelemetry.io/collector/internal/testutil v0.157.0 h1:plojUQwFC5l1ex9KUDaLmCFY/mTxEmf3zrlP7M23IEw= +go.opentelemetry.io/collector/internal/testutil v0.157.0/go.mod h1:Jkjs6rkqs973LqgZ0Fe3zrokQRKULYXPIf4HuqStiEE= +go.opentelemetry.io/collector/pdata v1.63.0 h1:fY2xSG2MnyoBwA4GUhzoogGZMuNS0qHpCoODqaKwiVQ= +go.opentelemetry.io/collector/pdata v1.63.0/go.mod h1:jzozYYhQEkTQ/CCbCBNC+hYUeju9S2J8HIqIDHdxZWk= +go.opentelemetry.io/collector/pdata/pprofile v0.157.0 h1:YRTPhwWzdG0pfJmb8p/qpQm1EdX+JfV20qzwG3ypDqI= +go.opentelemetry.io/collector/pdata/pprofile v0.157.0/go.mod h1:kwy/ufNUBkw8PsFPQnAqCvD12OpGU8h9A1cz5S7xS6g= +go.opentelemetry.io/collector/pdata/testdata v0.157.0 h1:TEee4jvYe8b0nPPKQnOnLz3LaA/XRtv3ja8J56DWIZc= +go.opentelemetry.io/collector/pdata/testdata v0.157.0/go.mod h1:ht50rAkY2bonM0eL+IvGDcAKWPNKdFE+8LjdaFjcOAA= +go.opentelemetry.io/collector/pipeline v1.63.0 h1:D97Nb1Jsgp8Ks+74jXs24kBZVd4pPdhuKe9dVogjcEo= +go.opentelemetry.io/collector/pipeline v1.63.0/go.mod h1:RD90NG3Jbk965Xaqym3JyHkuol4uZJjQVUkD9ddXJIs= +go.opentelemetry.io/collector/processor v1.63.0 h1:Aj1MLNiG9TJKOMywmojjbVFe1qtTLLMjRqmViEpPHeM= +go.opentelemetry.io/collector/processor v1.63.0/go.mod h1:dUyL11sxKBZn1XSqsiDyg76k+jZtYlRL7CkOuFWwVLI= +go.opentelemetry.io/collector/processor/processortest v0.157.0 h1:dtpyoIvbB3VLqZ+cV96EAsyCCUVX3mBFg9KMPRRyhlo= +go.opentelemetry.io/collector/processor/processortest v0.157.0/go.mod h1:gkRzdmNYfKJAmGCk/x8qDsIavVbNI0wTs+uhN7rY7B0= +go.opentelemetry.io/collector/processor/xprocessor v0.157.0 h1:+WyLGrHwcPk3TK+qt7T8CH+oADEMY4r+U5fIMTBvrAc= +go.opentelemetry.io/collector/processor/xprocessor v0.157.0/go.mod h1:DPmoWlks+CihSRjTGKvPKK6a8bl9mHk8hxthrJ+lvBI= go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.68.0 h1:cuXaPAfIoJKsYjBjPSb2nKZEmgM43zVr25l37IxhKME= go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.68.0/go.mod h1:BuzhPofpCzlDi/Q/Xjg54M4/3oWqqyDe2Zeq7A2I0QE= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.68.0 h1:CqXxU8VOmDefoh0+ztfGaymYbhdB/tT3zs79QaZTNGY= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.68.0/go.mod h1:BuhAPThV8PBHBvg8ZzZ/Ok3idOdhWIodywz2xEcRbJo= -go.opentelemetry.io/otel v1.43.0 h1:mYIM03dnh5zfN7HautFE4ieIig9amkNANT+xcVxAj9I= -go.opentelemetry.io/otel v1.43.0/go.mod h1:JuG+u74mvjvcm8vj8pI5XiHy1zDeoCS2LB1spIq7Ay0= +go.opentelemetry.io/otel v1.44.0 h1:JjwHmHpA4iZ3wBxluu2fbbE7j4kqlE8jXyAyPXH7HqU= +go.opentelemetry.io/otel v1.44.0/go.mod h1:BMgjTHL9WPRlRjL2oZCBTL4whCGtXch2H4BhOPIAyYc= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.42.0 h1:THuZiwpQZuHPul65w4WcwEnkX2QIuMT+UFoOrygtoJw= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.42.0/go.mod h1:J2pvYM5NGHofZ2/Ru6zw/TNWnEQp5crgyDeSrYpXkAw= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.42.0 h1:zWWrB1U6nqhS/k6zYB74CjRpuiitRtLLi68VcgmOEto= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.42.0/go.mod h1:2qXPNBX1OVRC0IwOnfo1ljoid+RD0QK3443EaqVlsOU= -go.opentelemetry.io/otel/metric v1.43.0 h1:d7638QeInOnuwOONPp4JAOGfbCEpYb+K6DVWvdxGzgM= -go.opentelemetry.io/otel/metric v1.43.0/go.mod h1:RDnPtIxvqlgO8GRW18W6Z/4P462ldprJtfxHxyKd2PY= -go.opentelemetry.io/otel/sdk v1.43.0 h1:pi5mE86i5rTeLXqoF/hhiBtUNcrAGHLKQdhg4h4V9Dg= -go.opentelemetry.io/otel/sdk v1.43.0/go.mod h1:P+IkVU3iWukmiit/Yf9AWvpyRDlUeBaRg6Y+C58QHzg= -go.opentelemetry.io/otel/sdk/metric v1.43.0 h1:S88dyqXjJkuBNLeMcVPRFXpRw2fuwdvfCGLEo89fDkw= -go.opentelemetry.io/otel/sdk/metric v1.43.0/go.mod h1:C/RJtwSEJ5hzTiUz5pXF1kILHStzb9zFlIEe85bhj6A= -go.opentelemetry.io/otel/trace v1.43.0 h1:BkNrHpup+4k4w+ZZ86CZoHHEkohws8AY+WTX09nk+3A= -go.opentelemetry.io/otel/trace v1.43.0/go.mod h1:/QJhyVBUUswCphDVxq+8mld+AvhXZLhe+8WVFxiFff0= +go.opentelemetry.io/otel/metric v1.44.0 h1:1w0gILTcHdr3YI+ixLyjemwrVnsMURbTZFrSYCdDdmc= +go.opentelemetry.io/otel/metric v1.44.0/go.mod h1:8O7hanEPBNgEMmybD3s2VBKcgWOCsA6tzHBPODAiquo= +go.opentelemetry.io/otel/sdk v1.44.0 h1:nHYwb9lK+fJPU/dnT6s7W7Z8itMWyqrnVfbheVYrZ58= +go.opentelemetry.io/otel/sdk v1.44.0/go.mod h1:Osuydd3Se74nqjAKxid74N5eC+jfEqfTegHRnq58oK0= +go.opentelemetry.io/otel/sdk/metric v1.44.0 h1:3LlKgI+VjbVsjNRFZJZAJ30WjXC5VkNRks6si09iEfI= +go.opentelemetry.io/otel/sdk/metric v1.44.0/go.mod h1:5B5pMARnXxKhltooO4xUuCBorl65a4EpnTalObqOigA= +go.opentelemetry.io/otel/trace v1.44.0 h1:jxF5CsGYCe74MCRx2X4g7WsY/VBKRqqpNvXlX/6gtIk= +go.opentelemetry.io/otel/trace v1.44.0/go.mod h1:oLl1jrMQAVo6v3GAggN+1VH9VIz9iUSvW53sW1Q8PIE= go.opentelemetry.io/proto/otlp v1.9.0 h1:l706jCMITVouPOqEnii2fIAuO3IVGBRPV5ICjceRb/A= go.opentelemetry.io/proto/otlp v1.9.0/go.mod h1:xE+Cx5E/eEHw+ISFkwPLwCZefwVjY+pqKg1qcK03+/4= go.opentelemetry.io/proto/slim/otlp v1.10.0 h1:iR97Vs/ZDR+y9TfuP9b1XBtdPWeC+OMslIBmhcLU7jM= @@ -575,29 +577,29 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc= -go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +go.uber.org/zap v1.28.0 h1:IZzaP1Fv73/T/pBMLk4VutPl36uNC+OSUh3JLG3FIjo= +go.uber.org/zap v1.28.0/go.mod h1:rDLpOi171uODNm/mxFcuYWxDsqWSAVkFdX4XojSKg/Q= go.yaml.in/yaml/v2 v2.4.4 h1:tuyd0P+2Ont/d6e2rl3be67goVK4R6deVxCUX5vyPaQ= go.yaml.in/yaml/v2 v2.4.4/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -go.yaml.in/yaml/v4 v4.0.0-rc.4 h1:UP4+v6fFrBIb1l934bDl//mmnoIZEDK0idg1+AIvX5U= -go.yaml.in/yaml/v4 v4.0.0-rc.4/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0= +go.yaml.in/yaml/v4 v4.0.0-rc.6 h1:1h7H1ohdUh93/FyE4YaDa1Zh64K6VVbjF4K6WUxMtH4= +go.yaml.in/yaml/v4 v4.0.0-rc.6/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= -golang.org/x/crypto v0.50.0 h1:zO47/JPrL6vsNkINmLoo/PH1gcxpls50DNogFvB5ZGI= -golang.org/x/crypto v0.50.0/go.mod h1:3muZ7vA7PBCE6xgPX7nkzzjiUq87kRItoJQM1Yo8S+Q= +golang.org/x/crypto v0.54.0 h1:YLIA59K4fiNzHzjnZt2tUJQjQtUWfWbeHBqKtk3eScw= +golang.org/x/crypto v0.54.0/go.mod h1:KWL8ny2AZdGR2cWmzeHrp2azQPGogOv+HeQaVEXC2dk= golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f h1:W3F4c+6OLc6H2lb//N1q4WpJkhzJCK5J6kUi1NTVXfM= golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f/go.mod h1:J1xhfL/vlindoeF/aINzNzt2Bket5bjo9sdOYzOsU80= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.35.0 h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM= -golang.org/x/mod v0.35.0/go.mod h1:+GwiRhIInF8wPm+4AoT6L0FA1QWAad3OMdTRx4tFYlU= +golang.org/x/mod v0.38.0 h1:MECBjubtXD7yj4HrhIUcywNaGeNVUdfVnxmPajOk4yk= +golang.org/x/mod v0.38.0/go.mod h1:V6Xz0pq8TQ3dGqVQ1FVHuelZpAL0uNhSkk9ogYP3c40= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -609,8 +611,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.13.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= -golang.org/x/net v0.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA= -golang.org/x/net v0.53.0/go.mod h1:JvMuJH7rrdiCfbeHoo3fCQU24Lf5JJwT9W3sJFulfgs= +golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE= +golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU= golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs= golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -619,8 +621,8 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4= -golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= +golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek= +golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -638,23 +640,23 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI= -golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs= +golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= -golang.org/x/term v0.42.0 h1:UiKe+zDFmJobeJ5ggPwOshJIVt6/Ft0rcfrXZDLWAWY= -golang.org/x/term v0.42.0/go.mod h1:Dq/D+snpsbazcBG5+F9Q1n2rXV8Ma+71xEjTRufARgY= +golang.org/x/term v0.45.0 h1:NwWyBmoJCbfTHpxrWoZ9C6/VxOf7ic219I8xZZFdrf0= +golang.org/x/term v0.45.0/go.mod h1:9aqxs0blBcrm/n0L9QW0aRVD+ktan8ssZromtqJC43w= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg= -golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164= +golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs= +golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY= golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U= golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -664,8 +666,8 @@ golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c= -golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI= +golang.org/x/tools v0.48.0 h1:3+hClM1aLL5mjMKm5ovokw9epgRXPuu2tILgismM6RE= +golang.org/x/tools v0.48.0/go.mod h1:08xX0orndb/F7jJxGDicx061tyd5pcMto75YMAXr6lk= golang.org/x/tools/go/expect v0.1.1-deprecated h1:jpBZDwmgPhXsKZC6WhL20P4b/wmnpsEAGHaNy0n/rJM= golang.org/x/tools/go/expect v0.1.1-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY= golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated h1:1h2MnaIAIXISqTFKdENegdpAgUXz6NrPEsbIeWaBRvM= @@ -684,12 +686,12 @@ google.golang.org/genai v1.54.0 h1:ZQCa70WMTJDI11FdqWCzGvZ5PanpcpfoO6jl/lrSnGU= google.golang.org/genai v1.54.0/go.mod h1:A3kkl0nyBjyFlNjgxIwKq70julKbIxpSxqKO5gw/gmk= google.golang.org/genproto v0.0.0-20260319201613-d00831a3d3e7 h1:XzmzkmB14QhVhgnawEVsOn6OFsnpyxNPRY9QV01dNB0= google.golang.org/genproto v0.0.0-20260319201613-d00831a3d3e7/go.mod h1:L43LFes82YgSonw6iTXTxXUX1OlULt4AQtkik4ULL/I= -google.golang.org/genproto/googleapis/api v0.0.0-20260319201613-d00831a3d3e7 h1:41r6JMbpzBMen0R/4TZeeAmGXSJC7DftGINUodzTkPI= -google.golang.org/genproto/googleapis/api v0.0.0-20260319201613-d00831a3d3e7/go.mod h1:EIQZ5bFCfRQDV4MhRle7+OgjNtZ6P1PiZBgAKuxXu/Y= +google.golang.org/genproto/googleapis/api v0.0.0-20260414002931-afd174a4e478 h1:yQugLulqltosq0B/f8l4w9VryjV+N/5gcW0jQ3N8Qec= +google.golang.org/genproto/googleapis/api v0.0.0-20260414002931-afd174a4e478/go.mod h1:C6ADNqOxbgdUUeRTU+LCHDPB9ttAMCTff6auwCVa4uc= google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478 h1:RmoJA1ujG+/lRGNfUnOMfhCy5EipVMyvUE+KNbPbTlw= google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8= -google.golang.org/grpc v1.80.0 h1:Xr6m2WmWZLETvUNvIUmeD5OAagMw3FiKmMlTdViWsHM= -google.golang.org/grpc v1.80.0/go.mod h1:ho/dLnxwi3EDJA4Zghp7k2Ec1+c2jqup0bFkw07bwF4= +google.golang.org/grpc v1.82.0 h1:vguDnZUPjE26w09A63VoxZPnvPjB5Riyc0mkXPFmAIU= +google.golang.org/grpc v1.82.0/go.mod h1:yzTZ1TB1Z3SG+LIYaI+WiE8D5+PZ3ArnrSp8zF3+/ZA= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= diff --git a/pkg/apis/fileintegrity/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/fileintegrity/v1alpha1/zz_generated.deepcopy.go index 27b98f8f6..101ffe28b 100644 --- a/pkg/apis/fileintegrity/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/fileintegrity/v1alpha1/zz_generated.deepcopy.go @@ -1,5 +1,4 @@ //go:build !ignore_autogenerated -// +build !ignore_autogenerated /* Copyright © 2019 - 2022 Red Hat Inc. diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/CHANGELOG.md b/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/CHANGELOG.md index fa477145f..ed56ac241 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/CHANGELOG.md +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/CHANGELOG.md @@ -1,5 +1,28 @@ # Release History +## 1.22.0 (2026-06-04) + +### Features Added + +* Added type `datetime.RFC7231` for date/time values in RFC 1123 format with a fixed GMT timezone. + +### Other Changes + +* Upgraded dependencies. + +## 1.21.1 (2026-04-16) + +### Bugs Fixed + +* Fixed an issue in `ResponseError.Error()` where the request URL path was being logged unescaped. +* Redact query parameters when logging errors. +* For `runtime.JoinPaths`, don't add a slash between root and paths when `paths` starts with `?` (query string). + +### Other Changes + +* Upgraded to Go 1.25.0. +* Upgraded dependencies. + ## 1.21.0 (2026-01-12) ### Features Added diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/internal/exported/response_error.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/internal/exported/response_error.go index ef0635bb2..8246b6a5b 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/internal/exported/response_error.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/internal/exported/response_error.go @@ -131,7 +131,7 @@ func (e *ResponseError) Error() string { msg := &bytes.Buffer{} if e.RawResponse != nil { if e.RawResponse.Request != nil { - fmt.Fprintf(msg, "%s %s://%s%s\n", e.RawResponse.Request.Method, e.RawResponse.Request.URL.Scheme, e.RawResponse.Request.URL.Host, e.RawResponse.Request.URL.Path) + fmt.Fprintf(msg, "%s %s://%s%s\n", e.RawResponse.Request.Method, e.RawResponse.Request.URL.Scheme, e.RawResponse.Request.URL.Host, e.RawResponse.Request.URL.EscapedPath()) } else { fmt.Fprintln(msg, "Request information not available") } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/internal/shared/constants.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/internal/shared/constants.go index 213202e33..4f7aa6434 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/internal/shared/constants.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/internal/shared/constants.go @@ -37,5 +37,5 @@ const ( Module = "azcore" // Version is the semantic version (see http://semver.org) of this module. - Version = "v1.21.0" + Version = "v1.22.0" ) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/policy_bearer_token.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/policy_bearer_token.go index 547e5a327..f204a19c4 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/policy_bearer_token.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/policy_bearer_token.go @@ -182,7 +182,7 @@ func (b *BearerTokenPolicy) handleChallenge(req *policy.Request, res *http.Respo func checkHTTPSForAuth(req *policy.Request, allowHTTP bool) error { if strings.ToLower(req.Raw().URL.Scheme) != "https" && !allowHTTP { - return errorinfo.NonRetriableError(errors.New("authenticated requests are not permitted for non TLS protected (https) endpoints")) + return errorinfo.NonRetriableError(errors.New("authorized requests are not permitted for non-TLS protected (https) endpoints")) } return nil } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/policy_http_trace.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/policy_http_trace.go index ddf9ede01..7017d5e10 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/policy_http_trace.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/policy_http_trace.go @@ -5,10 +5,8 @@ package runtime import ( "context" - "errors" "fmt" "net/http" - "net/url" "strings" "github.com/Azure/azure-sdk-for-go/sdk/azcore/internal/exported" @@ -73,14 +71,7 @@ func (h *httpTracePolicy) Do(req *policy.Request) (resp *http.Response, err erro span.SetAttributes(tracing.Attribute{Key: attrAZServiceReqID, Value: reqID}) } } else if err != nil { - var urlErr *url.Error - if errors.As(err, &urlErr) { - // calling *url.Error.Error() will include the unsanitized URL - // which we don't want. in addition, we already have the HTTP verb - // and sanitized URL in the trace so we aren't losing any info - err = urlErr.Err - } - span.SetStatus(tracing.SpanStatusError, err.Error()) + span.SetStatus(tracing.SpanStatusError, getSanitizedURLString(err.Error(), req.Raw().URL, h.allowedQP)) } span.End() }() diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/policy_logging.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/policy_logging.go index dd59fbc99..d9e6481de 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/policy_logging.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/policy_logging.go @@ -158,6 +158,27 @@ func getSanitizedURL(u url.URL, allowedQueryParams map[string]struct{}) string { return u.String() } +// getSanitizedURLString returns s with the query params of u redacted. +// if s doesn't contain u, then s is returned unchanged. +func getSanitizedURLString(s string, u *url.URL, allowedQueryParams map[string]struct{}) string { + if u.RawQuery == "" { + // the URL doesn't have any query params, so nothing to redact + return s + } + + urlIndex := strings.Index(strings.ToLower(s), strings.ToLower(u.String())) + if urlIndex < 0 { + // the URL isn't in the string, so nothing to redact + return s + } + + // replace the unsanitized URL in the error message with the sanitized version + sanitizedURL := getSanitizedURL(*u, allowedQueryParams) + s = s[:urlIndex] + sanitizedURL + s[urlIndex+len(u.String()):] + + return s +} + // writeRequestWithResponse appends a formatted HTTP request into a Buffer. If request and/or err are // not nil, then these are also written into the Buffer. func (p *logPolicy) writeRequestWithResponse(b *bytes.Buffer, req *policy.Request, resp *http.Response, err error) { @@ -171,7 +192,7 @@ func (p *logPolicy) writeRequestWithResponse(b *bytes.Buffer, req *policy.Reques } if err != nil { fmt.Fprintln(b, " --------------------------------------------------------------------------------") - fmt.Fprint(b, " ERROR:\n"+err.Error()+"\n") + fmt.Fprint(b, " ERROR:\n"+getSanitizedURLString(err.Error(), req.Raw().URL, p.allowedQP)+"\n") } } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/request.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/request.go index df7826b76..20d86496d 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/request.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/request.go @@ -90,12 +90,16 @@ func JoinPaths(root string, paths ...string) string { } if qps != "" { - p = p + "?" + qps + if strings.Contains(p, "?") { + p = p + "&" + qps + } else { + p = p + "?" + qps + } } if strings.HasSuffix(root, "/") && strings.HasPrefix(p, "/") { root = root[:len(root)-1] - } else if !strings.HasSuffix(root, "/") && !strings.HasPrefix(p, "/") { + } else if !strings.HasSuffix(root, "/") && !strings.HasPrefix(p, "/") && !strings.HasPrefix(p, "?") { p = "/" + p } return root + p diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/azidentity/CHANGELOG.md b/vendor/github.com/Azure/azure-sdk-for-go/sdk/azidentity/CHANGELOG.md index 4a6349e16..ba360a30e 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/azidentity/CHANGELOG.md +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/azidentity/CHANGELOG.md @@ -1,11 +1,61 @@ # Release History +## 1.14.0 (2026-06-15) + +### Breaking Changes + +> These changes affect only code written against a beta version such as v1.14.0-beta.3 +- Removed `WorkloadIdentityCredentialOptions.EnableAzureProxy`. + It will return in v1.15.0-beta.1 + +### Bugs Fixed + +- `AzureDeveloperCLICredential` improved reporting of error messages returned from `azd` + +### Other Changes + +- Returned `azidentity` errors include links to the troubleshooting guide when appropriate +- This module now requires a minimum Go version of 1.25 +- Upgraded dependencies + +## 1.14.0-beta.3 (2026-02-10) + +### Breaking Changes + +> These changes affect only code written against a beta version such as v1.14.0-beta.2 +- Renamed `WorkloadIdentityCredentialOptions.EnableAzureTokenProxy` to `EnableAzureProxy` + +### Other Changes + +- Removed extraneous JSON from `AzureDeveloperCLICredential` errors + +## 1.14.0-beta.2 (2025-11-10) + +### Breaking Changes + +> These changes affect only code written against a beta version such as v1.13.0-beta.1 +- `WorkloadIdentityCredential` identity binding mode is disabled by default. To enable it, set + `WorkloadIdentityCredentialOptions.EnableAzureTokenProxy` to `true` +- Removed identity binding mode support from `DefaultAzureCredential`. To use this feature, use + `WorkloadIdentityCredential` directly instead and set + `WorkloadIdentityCredentialOptions.EnableAzureTokenProxy` to `true` + +### Bugs Fixed + +- `AzureCLICredential` quoted arguments incorrectly on Windows + ## 1.13.1 (2025-11-10) ### Bugs Fixed - `AzureCLICredential` quoted arguments incorrectly on Windows +## 1.14.0-beta.1 (2025-10-07) + +### Features Added + +- Restored the `WorkloadIdentityCredential` identity binding mode support removed in v1.13.0 + ## 1.13.0 (2025-10-07) ### Features Added diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/azidentity/TROUBLESHOOTING.md b/vendor/github.com/Azure/azure-sdk-for-go/sdk/azidentity/TROUBLESHOOTING.md index 517006a42..c69664a84 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/azidentity/TROUBLESHOOTING.md +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/azidentity/TROUBLESHOOTING.md @@ -83,7 +83,7 @@ azlog.SetEvents(azidentity.EventAuthentication) | Error |Description| Mitigation | |---|---|---| -|"DefaultAzureCredential failed to acquire a token"|No credential in the `DefaultAzureCredential` chain provided a token|
client.Beta.Responses.New(ctx context.Context, params openai.BetaResponseNewParams) (\*openai.BetaResponse, error)
+- client.Beta.Responses.Get(ctx context.Context, responseID string, params openai.BetaResponseGetParams) (\*openai.BetaResponse, error)
+- client.Beta.Responses.Delete(ctx context.Context, responseID string, body openai.BetaResponseDeleteParams) error
+- client.Beta.Responses.Cancel(ctx context.Context, responseID string, body openai.BetaResponseCancelParams) (\*openai.BetaResponse, error)
+- client.Beta.Responses.Compact(ctx context.Context, params openai.BetaResponseCompactParams) (\*openai.BetaCompactedResponse, error)
+
+### InputItems
+
+Response Types:
+
+- openai.BetaResponseItemList
+
+Methods:
+
+- client.Beta.Responses.InputItems.List(ctx context.Context, responseID string, params openai.BetaResponseInputItemListParams) (\*pagination.CursorPage[openai.BetaResponseItemUnion], error)
+
+### InputTokens
+
+Response Types:
+
+- openai.BetaResponseInputTokenCountResponse
+
+Methods:
+
+- client.Beta.Responses.InputTokens.Count(ctx context.Context, params openai.BetaResponseInputTokenCountParams) (\*openai.BetaResponseInputTokenCountResponse, error)
+
## ChatKit
Response Types:
@@ -656,6 +897,421 @@ Methods:
- client.Uploads.Parts.New(ctx context.Context, uploadID string, body openai.UploadPartNewParams) (\*openai.UploadPart, error)
+# Admin
+
+## Organization
+
+### AuditLogs
+
+Response Types:
+
+- openai.AdminOrganizationAuditLogListResponse
+
+Methods:
+
+- client.Admin.Organization.AuditLogs.List(ctx context.Context, query openai.AdminOrganizationAuditLogListParams) (\*pagination.ConversationCursorPage[openai.AdminOrganizationAuditLogListResponse], error)
+
+### AdminAPIKeys
+
+Response Types:
+
+- openai.AdminAPIKey
+- openai.AdminOrganizationAdminAPIKeyNewResponse
+- openai.AdminOrganizationAdminAPIKeyDeleteResponse
+
+Methods:
+
+- client.Admin.Organization.AdminAPIKeys.New(ctx context.Context, body openai.AdminOrganizationAdminAPIKeyNewParams) (\*openai.AdminOrganizationAdminAPIKeyNewResponse, error)
+- client.Admin.Organization.AdminAPIKeys.Get(ctx context.Context, keyID string) (\*openai.AdminAPIKey, error)
+- client.Admin.Organization.AdminAPIKeys.List(ctx context.Context, query openai.AdminOrganizationAdminAPIKeyListParams) (\*pagination.CursorPage[openai.AdminAPIKey], error)
+- client.Admin.Organization.AdminAPIKeys.Delete(ctx context.Context, keyID string) (\*openai.AdminOrganizationAdminAPIKeyDeleteResponse, error)
+
+### Usage
+
+Response Types:
+
+- openai.AdminOrganizationUsageAudioSpeechesResponse
+- openai.AdminOrganizationUsageAudioTranscriptionsResponse
+- openai.AdminOrganizationUsageCodeInterpreterSessionsResponse
+- openai.AdminOrganizationUsageCompletionsResponse
+- openai.AdminOrganizationUsageCostsResponse
+- openai.AdminOrganizationUsageEmbeddingsResponse
+- openai.AdminOrganizationUsageFileSearchCallsResponse
+- openai.AdminOrganizationUsageImagesResponse
+- openai.AdminOrganizationUsageModerationsResponse
+- openai.AdminOrganizationUsageVectorStoresResponse
+- openai.AdminOrganizationUsageWebSearchCallsResponse
+
+Methods:
+
+- client.Admin.Organization.Usage.AudioSpeeches(ctx context.Context, query openai.AdminOrganizationUsageAudioSpeechesParams) (\*openai.AdminOrganizationUsageAudioSpeechesResponse, error)
+- client.Admin.Organization.Usage.AudioTranscriptions(ctx context.Context, query openai.AdminOrganizationUsageAudioTranscriptionsParams) (\*openai.AdminOrganizationUsageAudioTranscriptionsResponse, error)
+- client.Admin.Organization.Usage.CodeInterpreterSessions(ctx context.Context, query openai.AdminOrganizationUsageCodeInterpreterSessionsParams) (\*openai.AdminOrganizationUsageCodeInterpreterSessionsResponse, error)
+- client.Admin.Organization.Usage.Completions(ctx context.Context, query openai.AdminOrganizationUsageCompletionsParams) (\*openai.AdminOrganizationUsageCompletionsResponse, error)
+- client.Admin.Organization.Usage.Costs(ctx context.Context, query openai.AdminOrganizationUsageCostsParams) (\*openai.AdminOrganizationUsageCostsResponse, error)
+- client.Admin.Organization.Usage.Embeddings(ctx context.Context, query openai.AdminOrganizationUsageEmbeddingsParams) (\*openai.AdminOrganizationUsageEmbeddingsResponse, error)
+- client.Admin.Organization.Usage.FileSearchCalls(ctx context.Context, query openai.AdminOrganizationUsageFileSearchCallsParams) (\*openai.AdminOrganizationUsageFileSearchCallsResponse, error)
+- client.Admin.Organization.Usage.Images(ctx context.Context, query openai.AdminOrganizationUsageImagesParams) (\*openai.AdminOrganizationUsageImagesResponse, error)
+- client.Admin.Organization.Usage.Moderations(ctx context.Context, query openai.AdminOrganizationUsageModerationsParams) (\*openai.AdminOrganizationUsageModerationsResponse, error)
+- client.Admin.Organization.Usage.VectorStores(ctx context.Context, query openai.AdminOrganizationUsageVectorStoresParams) (\*openai.AdminOrganizationUsageVectorStoresResponse, error)
+- client.Admin.Organization.Usage.WebSearchCalls(ctx context.Context, query openai.AdminOrganizationUsageWebSearchCallsParams) (\*openai.AdminOrganizationUsageWebSearchCallsResponse, error)
+
+### Invites
+
+Response Types:
+
+- openai.Invite
+- openai.AdminOrganizationInviteDeleteResponse
+
+Methods:
+
+- client.Admin.Organization.Invites.New(ctx context.Context, body openai.AdminOrganizationInviteNewParams) (\*openai.Invite, error)
+- client.Admin.Organization.Invites.Get(ctx context.Context, inviteID string) (\*openai.Invite, error)
+- client.Admin.Organization.Invites.List(ctx context.Context, query openai.AdminOrganizationInviteListParams) (\*pagination.ConversationCursorPage[openai.Invite], error)
+- client.Admin.Organization.Invites.Delete(ctx context.Context, inviteID string) (\*openai.AdminOrganizationInviteDeleteResponse, error)
+
+### Users
+
+Response Types:
+
+- openai.OrganizationUser
+- openai.AdminOrganizationUserDeleteResponse
+
+Methods:
+
+- client.Admin.Organization.Users.Get(ctx context.Context, userID string) (\*openai.OrganizationUser, error)
+- client.Admin.Organization.Users.Update(ctx context.Context, userID string, body openai.AdminOrganizationUserUpdateParams) (\*openai.OrganizationUser, error)
+- client.Admin.Organization.Users.List(ctx context.Context, query openai.AdminOrganizationUserListParams) (\*pagination.ConversationCursorPage[openai.OrganizationUser], error)
+- client.Admin.Organization.Users.Delete(ctx context.Context, userID string) (\*openai.AdminOrganizationUserDeleteResponse, error)
+
+#### Roles
+
+Response Types:
+
+- openai.AdminOrganizationUserRoleNewResponse
+- openai.AdminOrganizationUserRoleGetResponse
+- openai.AdminOrganizationUserRoleListResponse
+- openai.AdminOrganizationUserRoleDeleteResponse
+
+Methods:
+
+- client.Admin.Organization.Users.Roles.New(ctx context.Context, userID string, body openai.AdminOrganizationUserRoleNewParams) (\*openai.AdminOrganizationUserRoleNewResponse, error)
+- client.Admin.Organization.Users.Roles.Get(ctx context.Context, userID string, roleID string) (\*openai.AdminOrganizationUserRoleGetResponse, error)
+- client.Admin.Organization.Users.Roles.List(ctx context.Context, userID string, query openai.AdminOrganizationUserRoleListParams) (\*pagination.NextCursorPage[openai.AdminOrganizationUserRoleListResponse], error)
+- client.Admin.Organization.Users.Roles.Delete(ctx context.Context, userID string, roleID string) (\*openai.AdminOrganizationUserRoleDeleteResponse, error)
+
+### Groups
+
+Response Types:
+
+- openai.Group
+- openai.AdminOrganizationGroupUpdateResponse
+- openai.AdminOrganizationGroupDeleteResponse
+
+Methods:
+
+- client.Admin.Organization.Groups.New(ctx context.Context, body openai.AdminOrganizationGroupNewParams) (\*openai.Group, error)
+- client.Admin.Organization.Groups.Get(ctx context.Context, groupID string) (\*openai.Group, error)
+- client.Admin.Organization.Groups.Update(ctx context.Context, groupID string, body openai.AdminOrganizationGroupUpdateParams) (\*openai.AdminOrganizationGroupUpdateResponse, error)
+- client.Admin.Organization.Groups.List(ctx context.Context, query openai.AdminOrganizationGroupListParams) (\*pagination.NextCursorPage[openai.Group], error)
+- client.Admin.Organization.Groups.Delete(ctx context.Context, groupID string) (\*openai.AdminOrganizationGroupDeleteResponse, error)
+
+#### Users
+
+Response Types:
+
+- openai.OrganizationGroupUser
+- openai.AdminOrganizationGroupUserNewResponse
+- openai.AdminOrganizationGroupUserGetResponse
+- openai.AdminOrganizationGroupUserDeleteResponse
+
+Methods:
+
+- client.Admin.Organization.Groups.Users.New(ctx context.Context, groupID string, body openai.AdminOrganizationGroupUserNewParams) (\*openai.AdminOrganizationGroupUserNewResponse, error)
+- client.Admin.Organization.Groups.Users.Get(ctx context.Context, groupID string, userID string) (\*openai.AdminOrganizationGroupUserGetResponse, error)
+- client.Admin.Organization.Groups.Users.List(ctx context.Context, groupID string, query openai.AdminOrganizationGroupUserListParams) (\*pagination.NextCursorPage[openai.OrganizationGroupUser], error)
+- client.Admin.Organization.Groups.Users.Delete(ctx context.Context, groupID string, userID string) (\*openai.AdminOrganizationGroupUserDeleteResponse, error)
+
+#### Roles
+
+Response Types:
+
+- openai.AdminOrganizationGroupRoleNewResponse
+- openai.AdminOrganizationGroupRoleGetResponse
+- openai.AdminOrganizationGroupRoleListResponse
+- openai.AdminOrganizationGroupRoleDeleteResponse
+
+Methods:
+
+- client.Admin.Organization.Groups.Roles.New(ctx context.Context, groupID string, body openai.AdminOrganizationGroupRoleNewParams) (\*openai.AdminOrganizationGroupRoleNewResponse, error)
+- client.Admin.Organization.Groups.Roles.Get(ctx context.Context, groupID string, roleID string) (\*openai.AdminOrganizationGroupRoleGetResponse, error)
+- client.Admin.Organization.Groups.Roles.List(ctx context.Context, groupID string, query openai.AdminOrganizationGroupRoleListParams) (\*pagination.NextCursorPage[openai.AdminOrganizationGroupRoleListResponse], error)
+- client.Admin.Organization.Groups.Roles.Delete(ctx context.Context, groupID string, roleID string) (\*openai.AdminOrganizationGroupRoleDeleteResponse, error)
+
+### Roles
+
+Response Types:
+
+- openai.Role
+- openai.AdminOrganizationRoleDeleteResponse
+
+Methods:
+
+- client.Admin.Organization.Roles.New(ctx context.Context, body openai.AdminOrganizationRoleNewParams) (\*openai.Role, error)
+- client.Admin.Organization.Roles.Get(ctx context.Context, roleID string) (\*openai.Role, error)
+- client.Admin.Organization.Roles.Update(ctx context.Context, roleID string, body openai.AdminOrganizationRoleUpdateParams) (\*openai.Role, error)
+- client.Admin.Organization.Roles.List(ctx context.Context, query openai.AdminOrganizationRoleListParams) (\*pagination.NextCursorPage[openai.Role], error)
+- client.Admin.Organization.Roles.Delete(ctx context.Context, roleID string) (\*openai.AdminOrganizationRoleDeleteResponse, error)
+
+### DataRetention
+
+Response Types:
+
+- openai.OrganizationDataRetention
+
+Methods:
+
+- client.Admin.Organization.DataRetention.Get(ctx context.Context) (\*openai.OrganizationDataRetention, error)
+- client.Admin.Organization.DataRetention.Update(ctx context.Context, body openai.AdminOrganizationDataRetentionUpdateParams) (\*openai.OrganizationDataRetention, error)
+
+### SpendAlerts
+
+Response Types:
+
+- openai.OrganizationSpendAlert
+- openai.OrganizationSpendAlertDeleted
+
+Methods:
+
+- client.Admin.Organization.SpendAlerts.New(ctx context.Context, body openai.AdminOrganizationSpendAlertNewParams) (\*openai.OrganizationSpendAlert, error)
+- client.Admin.Organization.SpendAlerts.Get(ctx context.Context, alertID string) (\*openai.OrganizationSpendAlert, error)
+- client.Admin.Organization.SpendAlerts.Update(ctx context.Context, alertID string, body openai.AdminOrganizationSpendAlertUpdateParams) (\*openai.OrganizationSpendAlert, error)
+- client.Admin.Organization.SpendAlerts.List(ctx context.Context, query openai.AdminOrganizationSpendAlertListParams) (\*pagination.ConversationCursorPage[openai.OrganizationSpendAlert], error)
+- client.Admin.Organization.SpendAlerts.Delete(ctx context.Context, alertID string) (\*openai.OrganizationSpendAlertDeleted, error)
+
+### Certificates
+
+Response Types:
+
+- openai.Certificate
+- openai.AdminOrganizationCertificateListResponse
+- openai.AdminOrganizationCertificateDeleteResponse
+- openai.AdminOrganizationCertificateActivateResponse
+- openai.AdminOrganizationCertificateDeactivateResponse
+
+Methods:
+
+- client.Admin.Organization.Certificates.New(ctx context.Context, body openai.AdminOrganizationCertificateNewParams) (\*openai.Certificate, error)
+- client.Admin.Organization.Certificates.Get(ctx context.Context, certificateID string, query openai.AdminOrganizationCertificateGetParams) (\*openai.Certificate, error)
+- client.Admin.Organization.Certificates.Update(ctx context.Context, certificateID string, body openai.AdminOrganizationCertificateUpdateParams) (\*openai.Certificate, error)
+- client.Admin.Organization.Certificates.List(ctx context.Context, query openai.AdminOrganizationCertificateListParams) (\*pagination.ConversationCursorPage[openai.AdminOrganizationCertificateListResponse], error)
+- client.Admin.Organization.Certificates.Delete(ctx context.Context, certificateID string) (\*openai.AdminOrganizationCertificateDeleteResponse, error)
+- client.Admin.Organization.Certificates.Activate(ctx context.Context, body openai.AdminOrganizationCertificateActivateParams) (\*pagination.Page[openai.AdminOrganizationCertificateActivateResponse], error)
+- client.Admin.Organization.Certificates.Deactivate(ctx context.Context, body openai.AdminOrganizationCertificateDeactivateParams) (\*pagination.Page[openai.AdminOrganizationCertificateDeactivateResponse], error)
+
+### Projects
+
+Response Types:
+
+- openai.Project
+
+Methods:
+
+- client.Admin.Organization.Projects.New(ctx context.Context, body openai.AdminOrganizationProjectNewParams) (\*openai.Project, error)
+- client.Admin.Organization.Projects.Get(ctx context.Context, projectID string) (\*openai.Project, error)
+- client.Admin.Organization.Projects.Update(ctx context.Context, projectID string, body openai.AdminOrganizationProjectUpdateParams) (\*openai.Project, error)
+- client.Admin.Organization.Projects.List(ctx context.Context, query openai.AdminOrganizationProjectListParams) (\*pagination.ConversationCursorPage[openai.Project], error)
+- client.Admin.Organization.Projects.Archive(ctx context.Context, projectID string) (\*openai.Project, error)
+
+#### Users
+
+Response Types:
+
+- openai.ProjectUser
+- openai.AdminOrganizationProjectUserDeleteResponse
+
+Methods:
+
+- client.Admin.Organization.Projects.Users.New(ctx context.Context, projectID string, body openai.AdminOrganizationProjectUserNewParams) (\*openai.ProjectUser, error)
+- client.Admin.Organization.Projects.Users.Get(ctx context.Context, projectID string, userID string) (\*openai.ProjectUser, error)
+- client.Admin.Organization.Projects.Users.Update(ctx context.Context, projectID string, userID string, body openai.AdminOrganizationProjectUserUpdateParams) (\*openai.ProjectUser, error)
+- client.Admin.Organization.Projects.Users.List(ctx context.Context, projectID string, query openai.AdminOrganizationProjectUserListParams) (\*pagination.ConversationCursorPage[openai.ProjectUser], error)
+- client.Admin.Organization.Projects.Users.Delete(ctx context.Context, projectID string, userID string) (\*openai.AdminOrganizationProjectUserDeleteResponse, error)
+
+##### Roles
+
+Response Types:
+
+- openai.AdminOrganizationProjectUserRoleNewResponse
+- openai.AdminOrganizationProjectUserRoleGetResponse
+- openai.AdminOrganizationProjectUserRoleListResponse
+- openai.AdminOrganizationProjectUserRoleDeleteResponse
+
+Methods:
+
+- client.Admin.Organization.Projects.Users.Roles.New(ctx context.Context, projectID string, userID string, body openai.AdminOrganizationProjectUserRoleNewParams) (\*openai.AdminOrganizationProjectUserRoleNewResponse, error)
+- client.Admin.Organization.Projects.Users.Roles.Get(ctx context.Context, projectID string, userID string, roleID string) (\*openai.AdminOrganizationProjectUserRoleGetResponse, error)
+- client.Admin.Organization.Projects.Users.Roles.List(ctx context.Context, projectID string, userID string, query openai.AdminOrganizationProjectUserRoleListParams) (\*pagination.NextCursorPage[openai.AdminOrganizationProjectUserRoleListResponse], error)
+- client.Admin.Organization.Projects.Users.Roles.Delete(ctx context.Context, projectID string, userID string, roleID string) (\*openai.AdminOrganizationProjectUserRoleDeleteResponse, error)
+
+#### ServiceAccounts
+
+Response Types:
+
+- openai.ProjectServiceAccount
+- openai.AdminOrganizationProjectServiceAccountNewResponse
+- openai.AdminOrganizationProjectServiceAccountDeleteResponse
+
+Methods:
+
+- client.Admin.Organization.Projects.ServiceAccounts.New(ctx context.Context, projectID string, body openai.AdminOrganizationProjectServiceAccountNewParams) (\*openai.AdminOrganizationProjectServiceAccountNewResponse, error)
+- client.Admin.Organization.Projects.ServiceAccounts.Get(ctx context.Context, projectID string, serviceAccountID string) (\*openai.ProjectServiceAccount, error)
+- client.Admin.Organization.Projects.ServiceAccounts.Update(ctx context.Context, projectID string, serviceAccountID string, body openai.AdminOrganizationProjectServiceAccountUpdateParams) (\*openai.ProjectServiceAccount, error)
+- client.Admin.Organization.Projects.ServiceAccounts.List(ctx context.Context, projectID string, query openai.AdminOrganizationProjectServiceAccountListParams) (\*pagination.ConversationCursorPage[openai.ProjectServiceAccount], error)
+- client.Admin.Organization.Projects.ServiceAccounts.Delete(ctx context.Context, projectID string, serviceAccountID string) (\*openai.AdminOrganizationProjectServiceAccountDeleteResponse, error)
+
+##### APIKeys
+
+Response Types:
+
+- openai.AdminOrganizationProjectServiceAccountAPIKeyNewResponse
+
+Methods:
+
+- client.Admin.Organization.Projects.ServiceAccounts.APIKeys.New(ctx context.Context, projectID string, serviceAccountID string, body openai.AdminOrganizationProjectServiceAccountAPIKeyNewParams) (\*openai.AdminOrganizationProjectServiceAccountAPIKeyNewResponse, error)
+
+#### APIKeys
+
+Response Types:
+
+- openai.ProjectAPIKey
+- openai.AdminOrganizationProjectAPIKeyDeleteResponse
+
+Methods:
+
+- client.Admin.Organization.Projects.APIKeys.Get(ctx context.Context, projectID string, apiKeyID string) (\*openai.ProjectAPIKey, error)
+- client.Admin.Organization.Projects.APIKeys.List(ctx context.Context, projectID string, query openai.AdminOrganizationProjectAPIKeyListParams) (\*pagination.ConversationCursorPage[openai.ProjectAPIKey], error)
+- client.Admin.Organization.Projects.APIKeys.Delete(ctx context.Context, projectID string, apiKeyID string) (\*openai.AdminOrganizationProjectAPIKeyDeleteResponse, error)
+
+#### RateLimits
+
+Response Types:
+
+- openai.ProjectRateLimit
+
+Methods:
+
+- client.Admin.Organization.Projects.RateLimits.ListRateLimits(ctx context.Context, projectID string, query openai.AdminOrganizationProjectRateLimitListRateLimitsParams) (\*pagination.ConversationCursorPage[openai.ProjectRateLimit], error)
+- client.Admin.Organization.Projects.RateLimits.UpdateRateLimit(ctx context.Context, projectID string, rateLimitID string, body openai.AdminOrganizationProjectRateLimitUpdateRateLimitParams) (\*openai.ProjectRateLimit, error)
+
+#### ModelPermissions
+
+Response Types:
+
+- openai.ProjectModelPermissions
+- openai.ProjectModelPermissionsDeleted
+
+Methods:
+
+- client.Admin.Organization.Projects.ModelPermissions.Get(ctx context.Context, projectID string) (\*openai.ProjectModelPermissions, error)
+- client.Admin.Organization.Projects.ModelPermissions.Update(ctx context.Context, projectID string, body openai.AdminOrganizationProjectModelPermissionUpdateParams) (\*openai.ProjectModelPermissions, error)
+- client.Admin.Organization.Projects.ModelPermissions.Delete(ctx context.Context, projectID string) (\*openai.ProjectModelPermissionsDeleted, error)
+
+#### HostedToolPermissions
+
+Response Types:
+
+- openai.ProjectHostedToolPermissions
+
+Methods:
+
+- client.Admin.Organization.Projects.HostedToolPermissions.Get(ctx context.Context, projectID string) (\*openai.ProjectHostedToolPermissions, error)
+- client.Admin.Organization.Projects.HostedToolPermissions.Update(ctx context.Context, projectID string, body openai.AdminOrganizationProjectHostedToolPermissionUpdateParams) (\*openai.ProjectHostedToolPermissions, error)
+
+#### Groups
+
+Response Types:
+
+- openai.ProjectGroup
+- openai.AdminOrganizationProjectGroupDeleteResponse
+
+Methods:
+
+- client.Admin.Organization.Projects.Groups.New(ctx context.Context, projectID string, body openai.AdminOrganizationProjectGroupNewParams) (\*openai.ProjectGroup, error)
+- client.Admin.Organization.Projects.Groups.Get(ctx context.Context, projectID string, groupID string, query openai.AdminOrganizationProjectGroupGetParams) (\*openai.ProjectGroup, error)
+- client.Admin.Organization.Projects.Groups.List(ctx context.Context, projectID string, query openai.AdminOrganizationProjectGroupListParams) (\*pagination.NextCursorPage[openai.ProjectGroup], error)
+- client.Admin.Organization.Projects.Groups.Delete(ctx context.Context, projectID string, groupID string) (\*openai.AdminOrganizationProjectGroupDeleteResponse, error)
+
+##### Roles
+
+Response Types:
+
+- openai.AdminOrganizationProjectGroupRoleNewResponse
+- openai.AdminOrganizationProjectGroupRoleGetResponse
+- openai.AdminOrganizationProjectGroupRoleListResponse
+- openai.AdminOrganizationProjectGroupRoleDeleteResponse
+
+Methods:
+
+- client.Admin.Organization.Projects.Groups.Roles.New(ctx context.Context, projectID string, groupID string, body openai.AdminOrganizationProjectGroupRoleNewParams) (\*openai.AdminOrganizationProjectGroupRoleNewResponse, error)
+- client.Admin.Organization.Projects.Groups.Roles.Get(ctx context.Context, projectID string, groupID string, roleID string) (\*openai.AdminOrganizationProjectGroupRoleGetResponse, error)
+- client.Admin.Organization.Projects.Groups.Roles.List(ctx context.Context, projectID string, groupID string, query openai.AdminOrganizationProjectGroupRoleListParams) (\*pagination.NextCursorPage[openai.AdminOrganizationProjectGroupRoleListResponse], error)
+- client.Admin.Organization.Projects.Groups.Roles.Delete(ctx context.Context, projectID string, groupID string, roleID string) (\*openai.AdminOrganizationProjectGroupRoleDeleteResponse, error)
+
+#### Roles
+
+Response Types:
+
+- openai.AdminOrganizationProjectRoleDeleteResponse
+
+Methods:
+
+- client.Admin.Organization.Projects.Roles.New(ctx context.Context, projectID string, body openai.AdminOrganizationProjectRoleNewParams) (\*openai.Role, error)
+- client.Admin.Organization.Projects.Roles.Get(ctx context.Context, projectID string, roleID string) (\*openai.Role, error)
+- client.Admin.Organization.Projects.Roles.Update(ctx context.Context, projectID string, roleID string, body openai.AdminOrganizationProjectRoleUpdateParams) (\*openai.Role, error)
+- client.Admin.Organization.Projects.Roles.List(ctx context.Context, projectID string, query openai.AdminOrganizationProjectRoleListParams) (\*pagination.NextCursorPage[openai.Role], error)
+- client.Admin.Organization.Projects.Roles.Delete(ctx context.Context, projectID string, roleID string) (\*openai.AdminOrganizationProjectRoleDeleteResponse, error)
+
+#### DataRetention
+
+Response Types:
+
+- openai.ProjectDataRetention
+
+Methods:
+
+- client.Admin.Organization.Projects.DataRetention.Get(ctx context.Context, projectID string) (\*openai.ProjectDataRetention, error)
+- client.Admin.Organization.Projects.DataRetention.Update(ctx context.Context, projectID string, body openai.AdminOrganizationProjectDataRetentionUpdateParams) (\*openai.ProjectDataRetention, error)
+
+#### SpendAlerts
+
+Response Types:
+
+- openai.ProjectSpendAlert
+- openai.ProjectSpendAlertDeleted
+
+Methods:
+
+- client.Admin.Organization.Projects.SpendAlerts.New(ctx context.Context, projectID string, body openai.AdminOrganizationProjectSpendAlertNewParams) (\*openai.ProjectSpendAlert, error)
+- client.Admin.Organization.Projects.SpendAlerts.Get(ctx context.Context, projectID string, alertID string) (\*openai.ProjectSpendAlert, error)
+- client.Admin.Organization.Projects.SpendAlerts.Update(ctx context.Context, projectID string, alertID string, body openai.AdminOrganizationProjectSpendAlertUpdateParams) (\*openai.ProjectSpendAlert, error)
+- client.Admin.Organization.Projects.SpendAlerts.List(ctx context.Context, projectID string, query openai.AdminOrganizationProjectSpendAlertListParams) (\*pagination.ConversationCursorPage[openai.ProjectSpendAlert], error)
+- client.Admin.Organization.Projects.SpendAlerts.Delete(ctx context.Context, projectID string, alertID string) (\*openai.ProjectSpendAlertDeleted, error)
+
+#### Certificates
+
+Response Types:
+
+- openai.AdminOrganizationProjectCertificateListResponse
+- openai.AdminOrganizationProjectCertificateActivateResponse
+- openai.AdminOrganizationProjectCertificateDeactivateResponse
+
+Methods:
+
+- client.Admin.Organization.Projects.Certificates.List(ctx context.Context, projectID string, query openai.AdminOrganizationProjectCertificateListParams) (\*pagination.ConversationCursorPage[openai.AdminOrganizationProjectCertificateListResponse], error)
+- client.Admin.Organization.Projects.Certificates.Activate(ctx context.Context, projectID string, body openai.AdminOrganizationProjectCertificateActivateParams) (\*pagination.Page[openai.AdminOrganizationProjectCertificateActivateResponse], error)
+- client.Admin.Organization.Projects.Certificates.Deactivate(ctx context.Context, projectID string, body openai.AdminOrganizationProjectCertificateDeactivateParams) (\*pagination.Page[openai.AdminOrganizationProjectCertificateDeactivateResponse], error)
+
# [Responses](responses/api.md)
# [Realtime](realtime/api.md)
diff --git a/vendor/github.com/openai/openai-go/v3/audiospeech.go b/vendor/github.com/openai/openai-go/v3/audiospeech.go
index 1318beb5c..9adce1ec5 100644
--- a/vendor/github.com/openai/openai-go/v3/audiospeech.go
+++ b/vendor/github.com/openai/openai-go/v3/audiospeech.go
@@ -38,7 +38,8 @@ func NewAudioSpeechService(opts ...option.RequestOption) (r AudioSpeechService)
//
// Returns the audio file content, or a stream of audio events.
func (r *AudioSpeechService) New(ctx context.Context, body AudioSpeechNewParams, opts ...option.RequestOption) (res *http.Response, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("Accept", "application/octet-stream")}, opts...)
path := "audio/speech"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
diff --git a/vendor/github.com/openai/openai-go/v3/audiotranscription.go b/vendor/github.com/openai/openai-go/v3/audiotranscription.go
index 15da5e18b..f3e908b6c 100644
--- a/vendor/github.com/openai/openai-go/v3/audiotranscription.go
+++ b/vendor/github.com/openai/openai-go/v3/audiotranscription.go
@@ -47,7 +47,8 @@ func NewAudioTranscriptionService(opts ...option.RequestOption) (r AudioTranscri
// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
// format, or a stream of transcript events.
func (r *AudioTranscriptionService) New(ctx context.Context, body AudioTranscriptionNewParams, opts ...option.RequestOption) (res *AudioTranscriptionNewResponseUnion, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "audio/transcriptions"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
@@ -62,7 +63,8 @@ func (r *AudioTranscriptionService) NewStreaming(ctx context.Context, body Audio
raw *http.Response
err error
)
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
body.SetExtraFields(map[string]any{
"stream": "true",
})
diff --git a/vendor/github.com/openai/openai-go/v3/audiotranslation.go b/vendor/github.com/openai/openai-go/v3/audiotranslation.go
index b5039ceef..e9053e04a 100644
--- a/vendor/github.com/openai/openai-go/v3/audiotranslation.go
+++ b/vendor/github.com/openai/openai-go/v3/audiotranslation.go
@@ -41,7 +41,8 @@ func NewAudioTranslationService(opts ...option.RequestOption) (r AudioTranslatio
// Translates audio into English.
func (r *AudioTranslationService) New(ctx context.Context, body AudioTranslationNewParams, opts ...option.RequestOption) (res *Translation, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "audio/translations"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
diff --git a/vendor/github.com/openai/openai-go/v3/auth/workloadidentity.go b/vendor/github.com/openai/openai-go/v3/auth/workloadidentity.go
index 68ef70104..3166be308 100644
--- a/vendor/github.com/openai/openai-go/v3/auth/workloadidentity.go
+++ b/vendor/github.com/openai/openai-go/v3/auth/workloadidentity.go
@@ -22,7 +22,6 @@ const (
TokenExchangeURL = "https://auth.openai.com/oauth/token"
)
-
type WorkloadIdentityAuth struct {
config WorkloadIdentity
@@ -47,7 +46,7 @@ type tokenRefreshState struct {
type tokenExchangeRequest struct {
GrantType string `json:"grant_type"`
- ClientID string `json:"client_id"`
+ ClientID string `json:"client_id,omitempty"`
SubjectToken string `json:"subject_token"`
SubjectTokenType string `json:"subject_token_type"`
IdentityProviderID string `json:"identity_provider_id"`
@@ -55,9 +54,6 @@ type tokenExchangeRequest struct {
}
func NewWorkloadIdentityAuth(config WorkloadIdentity) (*WorkloadIdentityAuth, error) {
- if config.ClientID == "" {
- return nil, fmt.Errorf("WorkloadIdentity: ClientID is required")
- }
if config.IdentityProviderID == "" {
return nil, fmt.Errorf("WorkloadIdentity: IdentityProviderID is required")
}
diff --git a/vendor/github.com/openai/openai-go/v3/batch.go b/vendor/github.com/openai/openai-go/v3/batch.go
index 0b4a8bc46..a0054c361 100644
--- a/vendor/github.com/openai/openai-go/v3/batch.go
+++ b/vendor/github.com/openai/openai-go/v3/batch.go
@@ -5,7 +5,6 @@ package openai
import (
"context"
"errors"
- "fmt"
"net/http"
"net/url"
"slices"
@@ -44,7 +43,8 @@ func NewBatchService(opts ...option.RequestOption) (r BatchService) {
// Creates and executes a batch from an uploaded file of requests
func (r *BatchService) New(ctx context.Context, body BatchNewParams, opts ...option.RequestOption) (res *Batch, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "batches"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
@@ -52,12 +52,13 @@ func (r *BatchService) New(ctx context.Context, body BatchNewParams, opts ...opt
// Retrieves a batch.
func (r *BatchService) Get(ctx context.Context, batchID string, opts ...option.RequestOption) (res *Batch, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if batchID == "" {
err = errors.New("missing required batch_id parameter")
return nil, err
}
- path := fmt.Sprintf("batches/%s", batchID)
+ path := requestconfig.FormatPath("batches/%s", batchID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
@@ -65,7 +66,8 @@ func (r *BatchService) Get(ctx context.Context, batchID string, opts ...option.R
// List your organization's batches.
func (r *BatchService) List(ctx context.Context, query BatchListParams, opts ...option.RequestOption) (res *pagination.CursorPage[Batch], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "batches"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
@@ -89,12 +91,13 @@ func (r *BatchService) ListAutoPaging(ctx context.Context, query BatchListParams
// 10 minutes, before changing to `cancelled`, where it will have partial results
// (if any) available in the output file.
func (r *BatchService) Cancel(ctx context.Context, batchID string, opts ...option.RequestOption) (res *Batch, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if batchID == "" {
err = errors.New("missing required batch_id parameter")
return nil, err
}
- path := fmt.Sprintf("batches/%s/cancel", batchID)
+ path := requestconfig.FormatPath("batches/%s/cancel", batchID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
return res, err
}
@@ -104,7 +107,7 @@ type Batch struct {
// The time frame within which the batch should be processed.
CompletionWindow string `json:"completion_window" api:"required"`
// The Unix timestamp (in seconds) for when the batch was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// The OpenAI API endpoint used by the batch.
Endpoint string `json:"endpoint" api:"required"`
// The ID of the input file for the batch.
@@ -117,24 +120,24 @@ type Batch struct {
// "expired", "cancelling", "cancelled".
Status BatchStatus `json:"status" api:"required"`
// The Unix timestamp (in seconds) for when the batch was cancelled.
- CancelledAt int64 `json:"cancelled_at"`
+ CancelledAt int64 `json:"cancelled_at" format:"unixtime"`
// The Unix timestamp (in seconds) for when the batch started cancelling.
- CancellingAt int64 `json:"cancelling_at"`
+ CancellingAt int64 `json:"cancelling_at" format:"unixtime"`
// The Unix timestamp (in seconds) for when the batch was completed.
- CompletedAt int64 `json:"completed_at"`
+ CompletedAt int64 `json:"completed_at" format:"unixtime"`
// The ID of the file containing the outputs of requests with errors.
ErrorFileID string `json:"error_file_id"`
Errors BatchErrors `json:"errors"`
// The Unix timestamp (in seconds) for when the batch expired.
- ExpiredAt int64 `json:"expired_at"`
+ ExpiredAt int64 `json:"expired_at" format:"unixtime"`
// The Unix timestamp (in seconds) for when the batch will expire.
- ExpiresAt int64 `json:"expires_at"`
+ ExpiresAt int64 `json:"expires_at" format:"unixtime"`
// The Unix timestamp (in seconds) for when the batch failed.
- FailedAt int64 `json:"failed_at"`
+ FailedAt int64 `json:"failed_at" format:"unixtime"`
// The Unix timestamp (in seconds) for when the batch started finalizing.
- FinalizingAt int64 `json:"finalizing_at"`
+ FinalizingAt int64 `json:"finalizing_at" format:"unixtime"`
// The Unix timestamp (in seconds) for when the batch started processing.
- InProgressAt int64 `json:"in_progress_at"`
+ InProgressAt int64 `json:"in_progress_at" format:"unixtime"`
// 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.
diff --git a/vendor/github.com/openai/openai-go/v3/beta.go b/vendor/github.com/openai/openai-go/v3/beta.go
index 1d240d7f7..6d38af533 100644
--- a/vendor/github.com/openai/openai-go/v3/beta.go
+++ b/vendor/github.com/openai/openai-go/v3/beta.go
@@ -13,8 +13,9 @@ import (
// automatically. You should not instantiate this service directly, and instead use
// the [NewBetaService] method instead.
type BetaService struct {
- Options []option.RequestOption
- ChatKit BetaChatKitService
+ Options []option.RequestOption
+ Responses BetaResponseService
+ ChatKit BetaChatKitService
// Build Assistants that can call models and use tools.
Assistants BetaAssistantService
// Build Assistants that can call models and use tools.
@@ -29,6 +30,7 @@ type BetaService struct {
func NewBetaService(opts ...option.RequestOption) (r BetaService) {
r = BetaService{}
r.Options = opts
+ r.Responses = NewBetaResponseService(opts...)
r.ChatKit = NewBetaChatKitService(opts...)
r.Assistants = NewBetaAssistantService(opts...)
r.Threads = NewBetaThreadService(opts...)
diff --git a/vendor/github.com/openai/openai-go/v3/betaassistant.go b/vendor/github.com/openai/openai-go/v3/betaassistant.go
index a36f36eb6..63b997cfe 100644
--- a/vendor/github.com/openai/openai-go/v3/betaassistant.go
+++ b/vendor/github.com/openai/openai-go/v3/betaassistant.go
@@ -6,7 +6,6 @@ import (
"context"
"encoding/json"
"errors"
- "fmt"
"net/http"
"net/url"
"slices"
@@ -47,7 +46,8 @@ func NewBetaAssistantService(opts ...option.RequestOption) (r BetaAssistantServi
//
// Deprecated: deprecated
func (r *BetaAssistantService) New(ctx context.Context, body BetaAssistantNewParams, opts ...option.RequestOption) (res *Assistant, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
path := "assistants"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
@@ -58,13 +58,14 @@ func (r *BetaAssistantService) New(ctx context.Context, body BetaAssistantNewPar
//
// Deprecated: deprecated
func (r *BetaAssistantService) Get(ctx context.Context, assistantID string, opts ...option.RequestOption) (res *Assistant, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if assistantID == "" {
err = errors.New("missing required assistant_id parameter")
return nil, err
}
- path := fmt.Sprintf("assistants/%s", assistantID)
+ path := requestconfig.FormatPath("assistants/%s", assistantID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
@@ -73,13 +74,14 @@ func (r *BetaAssistantService) Get(ctx context.Context, assistantID string, opts
//
// Deprecated: deprecated
func (r *BetaAssistantService) Update(ctx context.Context, assistantID string, body BetaAssistantUpdateParams, opts ...option.RequestOption) (res *Assistant, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if assistantID == "" {
err = errors.New("missing required assistant_id parameter")
return nil, err
}
- path := fmt.Sprintf("assistants/%s", assistantID)
+ path := requestconfig.FormatPath("assistants/%s", assistantID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
@@ -89,7 +91,8 @@ func (r *BetaAssistantService) Update(ctx context.Context, assistantID string, b
// Deprecated: deprecated
func (r *BetaAssistantService) List(ctx context.Context, query BetaAssistantListParams, opts ...option.RequestOption) (res *pagination.CursorPage[Assistant], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2"), option.WithResponseInto(&raw)}, opts...)
path := "assistants"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
@@ -115,13 +118,14 @@ func (r *BetaAssistantService) ListAutoPaging(ctx context.Context, query BetaAss
//
// Deprecated: deprecated
func (r *BetaAssistantService) Delete(ctx context.Context, assistantID string, opts ...option.RequestOption) (res *AssistantDeleted, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if assistantID == "" {
err = errors.New("missing required assistant_id parameter")
return nil, err
}
- path := fmt.Sprintf("assistants/%s", assistantID)
+ path := requestconfig.FormatPath("assistants/%s", assistantID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
return res, err
}
@@ -133,7 +137,7 @@ type Assistant struct {
// The identifier, which can be referenced in API endpoints.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) for when the assistant was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// The description of the assistant. The maximum length is 512 characters.
Description string `json:"description" api:"required"`
// The system instructions that the assistant uses. The maximum length is 256,000
@@ -1797,21 +1801,14 @@ type BetaAssistantNewParams 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"`
- // Constrains effort on reasoning for
- // [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
- // supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`.
- // Reducing reasoning effort can result in faster responses and fewer tokens used
- // on reasoning in a response.
+ // 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.
//
- // - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
- // reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
- // calls are supported for all reasoning values in gpt-5.1.
- // - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
- // support `none`.
- // - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
- // - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
- //
- // Any of "none", "minimal", "low", "medium", "high", "xhigh".
+ // Any of "none", "minimal", "low", "medium", "high", "xhigh", "max".
ReasoningEffort shared.ReasoningEffort `json:"reasoning_effort,omitzero"`
// A set of resources that are used by the assistant's tools. The resources are
// specific to the type of tool. For example, the `code_interpreter` tool requires
@@ -2076,21 +2073,14 @@ type BetaAssistantUpdateParams 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"`
- // Constrains effort on reasoning for
- // [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
- // supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`.
- // Reducing reasoning effort can result in faster responses and fewer tokens used
- // on reasoning in a response.
- //
- // - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
- // reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
- // calls are supported for all reasoning values in gpt-5.1.
- // - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
- // support `none`.
- // - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
- // - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
+ // 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".
+ // Any of "none", "minimal", "low", "medium", "high", "xhigh", "max".
ReasoningEffort shared.ReasoningEffort `json:"reasoning_effort,omitzero"`
// A set of resources that are used by the assistant's tools. The resources are
// specific to the type of tool. For example, the `code_interpreter` tool requires
diff --git a/vendor/github.com/openai/openai-go/v3/betachatkitsession.go b/vendor/github.com/openai/openai-go/v3/betachatkitsession.go
index 9fe1b8426..188b5e136 100644
--- a/vendor/github.com/openai/openai-go/v3/betachatkitsession.go
+++ b/vendor/github.com/openai/openai-go/v3/betachatkitsession.go
@@ -5,7 +5,6 @@ package openai
import (
"context"
"errors"
- "fmt"
"net/http"
"slices"
@@ -36,7 +35,8 @@ func NewBetaChatKitSessionService(opts ...option.RequestOption) (r BetaChatKitSe
// Create a ChatKit session.
func (r *BetaChatKitSessionService) New(ctx context.Context, body BetaChatKitSessionNewParams, opts ...option.RequestOption) (res *ChatSession, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "chatkit_beta=v1")}, opts...)
path := "chatkit/sessions"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
@@ -47,13 +47,14 @@ func (r *BetaChatKitSessionService) New(ctx context.Context, body BetaChatKitSes
//
// Cancelling prevents new requests from using the issued client secret.
func (r *BetaChatKitSessionService) Cancel(ctx context.Context, sessionID string, opts ...option.RequestOption) (res *ChatSession, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "chatkit_beta=v1")}, opts...)
if sessionID == "" {
err = errors.New("missing required session_id parameter")
return nil, err
}
- path := fmt.Sprintf("chatkit/sessions/%s/cancel", sessionID)
+ path := requestconfig.FormatPath("chatkit/sessions/%s/cancel", sessionID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
return res, err
}
diff --git a/vendor/github.com/openai/openai-go/v3/betachatkitthread.go b/vendor/github.com/openai/openai-go/v3/betachatkitthread.go
index d81ab730a..72ee9a189 100644
--- a/vendor/github.com/openai/openai-go/v3/betachatkitthread.go
+++ b/vendor/github.com/openai/openai-go/v3/betachatkitthread.go
@@ -6,7 +6,6 @@ import (
"context"
"encoding/json"
"errors"
- "fmt"
"net/http"
"net/url"
"slices"
@@ -42,13 +41,14 @@ func NewBetaChatKitThreadService(opts ...option.RequestOption) (r BetaChatKitThr
// Retrieve a ChatKit thread by its identifier.
func (r *BetaChatKitThreadService) Get(ctx context.Context, threadID string, opts ...option.RequestOption) (res *ChatKitThread, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "chatkit_beta=v1")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return nil, err
}
- path := fmt.Sprintf("chatkit/threads/%s", threadID)
+ path := requestconfig.FormatPath("chatkit/threads/%s", threadID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
@@ -56,7 +56,8 @@ func (r *BetaChatKitThreadService) Get(ctx context.Context, threadID string, opt
// List ChatKit threads with optional pagination and user filters.
func (r *BetaChatKitThreadService) List(ctx context.Context, query BetaChatKitThreadListParams, opts ...option.RequestOption) (res *pagination.ConversationCursorPage[ChatKitThread], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "chatkit_beta=v1"), option.WithResponseInto(&raw)}, opts...)
path := "chatkit/threads"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
@@ -78,13 +79,14 @@ func (r *BetaChatKitThreadService) ListAutoPaging(ctx context.Context, query Bet
// Delete a ChatKit thread along with its items and stored attachments.
func (r *BetaChatKitThreadService) Delete(ctx context.Context, threadID string, opts ...option.RequestOption) (res *BetaChatKitThreadDeleteResponse, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "chatkit_beta=v1")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return nil, err
}
- path := fmt.Sprintf("chatkit/threads/%s", threadID)
+ path := requestconfig.FormatPath("chatkit/threads/%s", threadID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
return res, err
}
@@ -92,13 +94,14 @@ func (r *BetaChatKitThreadService) Delete(ctx context.Context, threadID string,
// List items that belong to a ChatKit thread.
func (r *BetaChatKitThreadService) ListItems(ctx context.Context, threadID string, query BetaChatKitThreadListItemsParams, opts ...option.RequestOption) (res *pagination.ConversationCursorPage[ChatKitThreadItemListDataUnion], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "chatkit_beta=v1"), option.WithResponseInto(&raw)}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return nil, err
}
- path := fmt.Sprintf("chatkit/threads/%s/items", threadID)
+ path := requestconfig.FormatPath("chatkit/threads/%s/items", threadID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
return nil, err
@@ -125,7 +128,7 @@ type ChatSession struct {
// Ephemeral client secret that authenticates session requests.
ClientSecret string `json:"client_secret" api:"required"`
// Unix timestamp (in seconds) for when the session expires.
- ExpiresAt int64 `json:"expires_at" api:"required"`
+ ExpiresAt int64 `json:"expires_at" api:"required" format:"unixtime"`
// Convenience copy of the per-minute request limit.
MaxRequestsPer1Minute int64 `json:"max_requests_per_1_minute" api:"required"`
// Type discriminator that is always `chatkit.session`.
@@ -469,7 +472,7 @@ type ChatKitAttachment struct {
// Original display name for the attachment.
Name string `json:"name" api:"required"`
// Preview URL for rendering the attachment inline.
- PreviewURL string `json:"preview_url" api:"required"`
+ PreviewURL string `json:"preview_url" api:"required" format:"uri"`
// Attachment discriminator.
//
// Any of "image", "file".
@@ -683,7 +686,7 @@ type ChatKitResponseOutputTextAnnotationURLSource struct {
// Type discriminator that is always `url`.
Type constant.URL `json:"type" default:"url"`
// URL referenced by the annotation.
- URL string `json:"url" api:"required"`
+ URL string `json:"url" api:"required" format:"uri"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Type respjson.Field
@@ -704,7 +707,7 @@ type ChatKitThread struct {
// Identifier of the thread.
ID string `json:"id" api:"required"`
// Unix timestamp (in seconds) for when the thread was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Type discriminator that is always `chatkit.thread`.
Object constant.ChatKitThread `json:"object" default:"chatkit.thread"`
// Current status for the thread. Defaults to `active` for newly created threads.
@@ -872,7 +875,7 @@ type ChatKitThreadAssistantMessageItem struct {
// Ordered assistant response segments.
Content []ChatKitResponseOutputText `json:"content" api:"required"`
// Unix timestamp (in seconds) for when the item was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Type discriminator that is always `chatkit.thread_item`.
Object constant.ChatKitThreadItem `json:"object" default:"chatkit.thread_item"`
// Identifier of the parent thread.
@@ -1114,7 +1117,7 @@ type ChatKitThreadItemListDataChatKitClientToolCall struct {
// Identifier for the client tool call.
CallID string `json:"call_id" api:"required"`
// Unix timestamp (in seconds) for when the item was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Tool name that was invoked.
Name string `json:"name" api:"required"`
// Type discriminator that is always `chatkit.thread_item`.
@@ -1158,7 +1161,7 @@ type ChatKitThreadItemListDataChatKitTask struct {
// Identifier of the thread item.
ID string `json:"id" api:"required"`
// Unix timestamp (in seconds) for when the item was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Optional heading for the task. Defaults to null when not provided.
Heading string `json:"heading" api:"required"`
// Type discriminator that is always `chatkit.thread_item`.
@@ -1199,7 +1202,7 @@ type ChatKitThreadItemListDataChatKitTaskGroup struct {
// Identifier of the thread item.
ID string `json:"id" api:"required"`
// Unix timestamp (in seconds) for when the item was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Type discriminator that is always `chatkit.thread_item`.
Object constant.ChatKitThreadItem `json:"object" default:"chatkit.thread_item"`
// Tasks included in the group.
@@ -1262,7 +1265,7 @@ type ChatKitThreadUserMessageItem struct {
// Ordered content elements supplied by the user.
Content []ChatKitThreadUserMessageItemContentUnion `json:"content" api:"required"`
// Unix timestamp (in seconds) for when the item was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Inference overrides applied to the message. Defaults to null when unset.
InferenceOptions ChatKitThreadUserMessageItemInferenceOptions `json:"inference_options" api:"required"`
// Type discriminator that is always `chatkit.thread_item`.
@@ -1442,7 +1445,7 @@ type ChatKitWidgetItem struct {
// Identifier of the thread item.
ID string `json:"id" api:"required"`
// Unix timestamp (in seconds) for when the item was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Type discriminator that is always `chatkit.thread_item`.
Object constant.ChatKitThreadItem `json:"object" default:"chatkit.thread_item"`
// Identifier of the parent thread.
diff --git a/vendor/github.com/openai/openai-go/v3/betaresponse.go b/vendor/github.com/openai/openai-go/v3/betaresponse.go
new file mode 100644
index 000000000..2ae945b9e
--- /dev/null
+++ b/vendor/github.com/openai/openai-go/v3/betaresponse.go
@@ -0,0 +1,32641 @@
+// 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"
+)
diff --git a/vendor/github.com/openai/openai-go/v3/betaresponseinputitem.go b/vendor/github.com/openai/openai-go/v3/betaresponseinputitem.go
new file mode 100644
index 000000000..b9b4ba5dc
--- /dev/null
+++ b/vendor/github.com/openai/openai-go/v3/betaresponseinputitem.go
@@ -0,0 +1,142 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package openai
+
+import (
+ "context"
+ "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/requestconfig"
+ "github.com/openai/openai-go/v3/option"
+ "github.com/openai/openai-go/v3/packages/pagination"
+ "github.com/openai/openai-go/v3/packages/param"
+ "github.com/openai/openai-go/v3/packages/respjson"
+ "github.com/openai/openai-go/v3/shared/constant"
+)
+
+// BetaResponseInputItemService 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 [NewBetaResponseInputItemService] method instead.
+type BetaResponseInputItemService struct {
+ Options []option.RequestOption
+}
+
+// NewBetaResponseInputItemService 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 NewBetaResponseInputItemService(opts ...option.RequestOption) (r BetaResponseInputItemService) {
+ r = BetaResponseInputItemService{}
+ r.Options = opts
+ return
+}
+
+// Returns a list of input items for a given response.
+func (r *BetaResponseInputItemService) List(ctx context.Context, responseID string, params BetaResponseInputItemListParams, opts ...option.RequestOption) (res *pagination.CursorPage[BetaResponseItemUnion], err error) {
+ var raw *http.Response
+ 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([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
+ if responseID == "" {
+ err = errors.New("missing required response_id parameter")
+ return nil, err
+ }
+ path := requestconfig.FormatPath("responses/%s/input_items?beta=true", responseID)
+ cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...)
+ if err != nil {
+ return nil, err
+ }
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+// Returns a list of input items for a given response.
+func (r *BetaResponseInputItemService) ListAutoPaging(ctx context.Context, responseID string, params BetaResponseInputItemListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[BetaResponseItemUnion] {
+ return pagination.NewCursorPageAutoPager(r.List(ctx, responseID, params, opts...))
+}
+
+// A list of Response items.
+type BetaResponseItemList struct {
+ // A list of items used to generate this response.
+ Data []BetaResponseItemUnion `json:"data" api:"required"`
+ // The ID of the first item in the list.
+ FirstID string `json:"first_id" api:"required"`
+ // Whether there are more items available.
+ HasMore bool `json:"has_more" api:"required"`
+ // The ID of the last item in the list.
+ LastID string `json:"last_id" api:"required"`
+ // The type of object returned, must be `list`.
+ Object constant.List `json:"object" default:"list"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ Data respjson.Field
+ FirstID respjson.Field
+ HasMore respjson.Field
+ LastID respjson.Field
+ Object respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r BetaResponseItemList) RawJSON() string { return r.JSON.raw }
+func (r *BetaResponseItemList) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type BetaResponseInputItemListParams struct {
+ // An item ID to list items after, used in pagination.
+ After param.Opt[string] `query:"after,omitzero" json:"-"`
+ // A limit on the number of objects to be returned. Limit can range between 1 and
+ // 100, and the default is 20.
+ Limit param.Opt[int64] `query:"limit,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:"-"`
+ // The order to return the input items in. Default is `desc`.
+ //
+ // - `asc`: Return the input items in ascending order.
+ // - `desc`: Return the input items in descending order.
+ //
+ // Any of "asc", "desc".
+ Order BetaResponseInputItemListParamsOrder `query:"order,omitzero" json:"-"`
+ // Any of "responses_multi_agent=v1".
+ Betas []string `header:"openai-beta,omitzero" json:"-"`
+ paramObj
+}
+
+// URLQuery serializes [BetaResponseInputItemListParams]'s query parameters as
+// `url.Values`.
+func (r BetaResponseInputItemListParams) URLQuery() (v url.Values, err error) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatBrackets,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
+
+// The order to return the input items in. Default is `desc`.
+//
+// - `asc`: Return the input items in ascending order.
+// - `desc`: Return the input items in descending order.
+type BetaResponseInputItemListParamsOrder string
+
+const (
+ BetaResponseInputItemListParamsOrderAsc BetaResponseInputItemListParamsOrder = "asc"
+ BetaResponseInputItemListParamsOrderDesc BetaResponseInputItemListParamsOrder = "desc"
+)
diff --git a/vendor/github.com/openai/openai-go/v3/betaresponseinputtoken.go b/vendor/github.com/openai/openai-go/v3/betaresponseinputtoken.go
new file mode 100644
index 000000000..0460fa9f0
--- /dev/null
+++ b/vendor/github.com/openai/openai-go/v3/betaresponseinputtoken.go
@@ -0,0 +1,455 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package openai
+
+import (
+ "context"
+ "fmt"
+ "net/http"
+ "slices"
+
+ "github.com/openai/openai-go/v3/internal/apijson"
+ "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/shared/constant"
+)
+
+// BetaResponseInputTokenService 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 [NewBetaResponseInputTokenService] method instead.
+type BetaResponseInputTokenService struct {
+ Options []option.RequestOption
+}
+
+// NewBetaResponseInputTokenService 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 NewBetaResponseInputTokenService(opts ...option.RequestOption) (r BetaResponseInputTokenService) {
+ r = BetaResponseInputTokenService{}
+ r.Options = opts
+ return
+}
+
+// Returns input token counts of the request.
+//
+// Returns an object with `object` set to `response.input_tokens` and an
+// `input_tokens` count.
+func (r *BetaResponseInputTokenService) Count(ctx context.Context, params BetaResponseInputTokenCountParams, opts ...option.RequestOption) (res *BetaResponseInputTokenCountResponse, 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/input_tokens?beta=true"
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
+ return res, err
+}
+
+type BetaResponseInputTokenCountResponse struct {
+ InputTokens int64 `json:"input_tokens" api:"required"`
+ Object constant.ResponseInputTokens `json:"object" default:"response.input_tokens"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ InputTokens respjson.Field
+ Object respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r BetaResponseInputTokenCountResponse) RawJSON() string { return r.JSON.raw }
+func (r *BetaResponseInputTokenCountResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type BetaResponseInputTokenCountParams struct {
+ // 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"`
+ // 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 param.Opt[string] `json:"model,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"`
+ // 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 BetaResponseInputTokenCountParamsConversationUnion `json:"conversation,omitzero"`
+ // Text, image, or file inputs to the model, used to generate a response
+ Input BetaResponseInputTokenCountParamsInputUnion `json:"input,omitzero"`
+ // **gpt-5 and o-series models only** Configuration options for
+ // [reasoning models](https://platform.openai.com/docs/guides/reasoning).
+ Reasoning BetaResponseInputTokenCountParamsReasoning `json:"reasoning,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 BetaResponseInputTokenCountParamsText `json:"text,omitzero"`
+ // Controls which tool the model should use, if any.
+ ToolChoice BetaResponseInputTokenCountParamsToolChoiceUnion `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.
+ Tools []BetaToolUnionParam `json:"tools,omitzero"`
+ // A model-owned style preset to apply to this request. Omit this parameter to use
+ // the model's default style. Supported values may expand over time. Values must be
+ // at most 64 characters.
+ Personality BetaResponseInputTokenCountParamsPersonality `json:"personality,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 BetaResponseInputTokenCountParamsTruncation `json:"truncation,omitzero"`
+ // Any of "responses_multi_agent=v1".
+ Betas []string `header:"openai-beta,omitzero" json:"-"`
+ paramObj
+}
+
+func (r BetaResponseInputTokenCountParams) MarshalJSON() (data []byte, err error) {
+ type shadow BetaResponseInputTokenCountParams
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *BetaResponseInputTokenCountParams) 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 BetaResponseInputTokenCountParamsConversationUnion struct {
+ OfString param.Opt[string] `json:",omitzero,inline"`
+ OfConversationObject *BetaResponseConversationParam `json:",omitzero,inline"`
+ paramUnion
+}
+
+func (u BetaResponseInputTokenCountParamsConversationUnion) MarshalJSON() ([]byte, error) {
+ return param.MarshalUnion(u, u.OfString, u.OfConversationObject)
+}
+func (u *BetaResponseInputTokenCountParamsConversationUnion) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, u)
+}
+
+func (u *BetaResponseInputTokenCountParamsConversationUnion) 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 BetaResponseInputTokenCountParamsInputUnion struct {
+ OfString param.Opt[string] `json:",omitzero,inline"`
+ OfBetaResponseInputItemArray []BetaResponseInputItemUnionParam `json:",omitzero,inline"`
+ paramUnion
+}
+
+func (u BetaResponseInputTokenCountParamsInputUnion) MarshalJSON() ([]byte, error) {
+ return param.MarshalUnion(u, u.OfString, u.OfBetaResponseInputItemArray)
+}
+func (u *BetaResponseInputTokenCountParamsInputUnion) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, u)
+}
+
+func (u *BetaResponseInputTokenCountParamsInputUnion) asAny() any {
+ if !param.IsOmitted(u.OfString) {
+ return &u.OfString.Value
+ } else if !param.IsOmitted(u.OfBetaResponseInputItemArray) {
+ return &u.OfBetaResponseInputItemArray
+ }
+ return nil
+}
+
+// A model-owned style preset to apply to this request. Omit this parameter to use
+// the model's default style. Supported values may expand over time. Values must be
+// at most 64 characters.
+type BetaResponseInputTokenCountParamsPersonality string
+
+const (
+ BetaResponseInputTokenCountParamsPersonalityFriendly BetaResponseInputTokenCountParamsPersonality = "friendly"
+ BetaResponseInputTokenCountParamsPersonalityPragmatic BetaResponseInputTokenCountParamsPersonality = "pragmatic"
+)
+
+// **gpt-5 and o-series models only** Configuration options for
+// [reasoning models](https://platform.openai.com/docs/guides/reasoning).
+type BetaResponseInputTokenCountParamsReasoning 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 BetaResponseInputTokenCountParamsReasoning) MarshalJSON() (data []byte, err error) {
+ type shadow BetaResponseInputTokenCountParamsReasoning
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *BetaResponseInputTokenCountParamsReasoning) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func init() {
+ apijson.RegisterFieldValidator[BetaResponseInputTokenCountParamsReasoning](
+ "context", "auto", "current_turn", "all_turns",
+ )
+ apijson.RegisterFieldValidator[BetaResponseInputTokenCountParamsReasoning](
+ "effort", "none", "minimal", "low", "medium", "high", "xhigh", "max",
+ )
+ apijson.RegisterFieldValidator[BetaResponseInputTokenCountParamsReasoning](
+ "generate_summary", "auto", "concise", "detailed",
+ )
+ apijson.RegisterFieldValidator[BetaResponseInputTokenCountParamsReasoning](
+ "summary", "auto", "concise", "detailed",
+ )
+}
+
+// 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 BetaResponseInputTokenCountParamsText 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 string `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 BetaResponseInputTokenCountParamsText) MarshalJSON() (data []byte, err error) {
+ type shadow BetaResponseInputTokenCountParamsText
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *BetaResponseInputTokenCountParamsText) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func init() {
+ apijson.RegisterFieldValidator[BetaResponseInputTokenCountParamsText](
+ "verbosity", "low", "medium", "high",
+ )
+}
+
+// Only one field can be non-zero.
+//
+// Use [param.IsOmitted] to confirm if a field is set.
+type BetaResponseInputTokenCountParamsToolChoiceUnion 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"`
+ OfBetaResponseInputTokenCountsToolChoiceBetaSpecificProgrammaticToolCallingParam *BetaResponseInputTokenCountParamsToolChoiceBetaSpecificProgrammaticToolCallingParam `json:",omitzero,inline"`
+ OfSpecificApplyPatchToolChoice *BetaToolChoiceApplyPatchParam `json:",omitzero,inline"`
+ OfSpecificShellToolChoice *BetaToolChoiceShellParam `json:",omitzero,inline"`
+ paramUnion
+}
+
+func (u BetaResponseInputTokenCountParamsToolChoiceUnion) MarshalJSON() ([]byte, error) {
+ return param.MarshalUnion(u, u.OfToolChoiceMode,
+ u.OfAllowedTools,
+ u.OfHostedTool,
+ u.OfFunctionTool,
+ u.OfMcpTool,
+ u.OfCustomTool,
+ u.OfBetaResponseInputTokenCountsToolChoiceBetaSpecificProgrammaticToolCallingParam,
+ u.OfSpecificApplyPatchToolChoice,
+ u.OfSpecificShellToolChoice)
+}
+func (u *BetaResponseInputTokenCountParamsToolChoiceUnion) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, u)
+}
+
+func (u *BetaResponseInputTokenCountParamsToolChoiceUnion) 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.OfBetaResponseInputTokenCountsToolChoiceBetaSpecificProgrammaticToolCallingParam) {
+ return u.OfBetaResponseInputTokenCountsToolChoiceBetaSpecificProgrammaticToolCallingParam
+ } 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 BetaResponseInputTokenCountParamsToolChoiceUnion) 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 BetaResponseInputTokenCountParamsToolChoiceUnion) 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 BetaResponseInputTokenCountParamsToolChoiceUnion) 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 BetaResponseInputTokenCountParamsToolChoiceUnion) 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.OfBetaResponseInputTokenCountsToolChoiceBetaSpecificProgrammaticToolCallingParam; 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 BetaResponseInputTokenCountParamsToolChoiceUnion) 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 NewBetaResponseInputTokenCountParamsToolChoiceBetaSpecificProgrammaticToolCallingParam() BetaResponseInputTokenCountParamsToolChoiceBetaSpecificProgrammaticToolCallingParam {
+ return BetaResponseInputTokenCountParamsToolChoiceBetaSpecificProgrammaticToolCallingParam{
+ Type: "programmatic_tool_calling",
+ }
+}
+
+// This struct has a constant value, construct it with
+// [NewBetaResponseInputTokenCountParamsToolChoiceBetaSpecificProgrammaticToolCallingParam].
+type BetaResponseInputTokenCountParamsToolChoiceBetaSpecificProgrammaticToolCallingParam struct {
+ // The tool to call. Always `programmatic_tool_calling`.
+ Type constant.ProgrammaticToolCalling `json:"type" default:"programmatic_tool_calling"`
+ paramObj
+}
+
+func (r BetaResponseInputTokenCountParamsToolChoiceBetaSpecificProgrammaticToolCallingParam) MarshalJSON() (data []byte, err error) {
+ type shadow BetaResponseInputTokenCountParamsToolChoiceBetaSpecificProgrammaticToolCallingParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *BetaResponseInputTokenCountParamsToolChoiceBetaSpecificProgrammaticToolCallingParam) 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 BetaResponseInputTokenCountParamsTruncation string
+
+const (
+ BetaResponseInputTokenCountParamsTruncationAuto BetaResponseInputTokenCountParamsTruncation = "auto"
+ BetaResponseInputTokenCountParamsTruncationDisabled BetaResponseInputTokenCountParamsTruncation = "disabled"
+)
diff --git a/vendor/github.com/openai/openai-go/v3/betathread.go b/vendor/github.com/openai/openai-go/v3/betathread.go
index 524e4be02..9384998d6 100644
--- a/vendor/github.com/openai/openai-go/v3/betathread.go
+++ b/vendor/github.com/openai/openai-go/v3/betathread.go
@@ -6,7 +6,6 @@ import (
"context"
"encoding/json"
"errors"
- "fmt"
"net/http"
"slices"
@@ -57,7 +56,8 @@ func NewBetaThreadService(opts ...option.RequestOption) (r BetaThreadService) {
//
// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadService) New(ctx context.Context, body BetaThreadNewParams, opts ...option.RequestOption) (res *Thread, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
path := "threads"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
@@ -68,13 +68,14 @@ func (r *BetaThreadService) New(ctx context.Context, body BetaThreadNewParams, o
//
// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadService) Get(ctx context.Context, threadID string, opts ...option.RequestOption) (res *Thread, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return nil, err
}
- path := fmt.Sprintf("threads/%s", threadID)
+ path := requestconfig.FormatPath("threads/%s", threadID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
@@ -83,13 +84,14 @@ func (r *BetaThreadService) Get(ctx context.Context, threadID string, opts ...op
//
// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadService) Update(ctx context.Context, threadID string, body BetaThreadUpdateParams, opts ...option.RequestOption) (res *Thread, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return nil, err
}
- path := fmt.Sprintf("threads/%s", threadID)
+ path := requestconfig.FormatPath("threads/%s", threadID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
@@ -98,13 +100,14 @@ func (r *BetaThreadService) Update(ctx context.Context, threadID string, body Be
//
// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadService) Delete(ctx context.Context, threadID string, opts ...option.RequestOption) (res *ThreadDeleted, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return nil, err
}
- path := fmt.Sprintf("threads/%s", threadID)
+ path := requestconfig.FormatPath("threads/%s", threadID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
return res, err
}
@@ -113,7 +116,8 @@ func (r *BetaThreadService) Delete(ctx context.Context, threadID string, opts ..
//
// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadService) NewAndRun(ctx context.Context, body BetaThreadNewAndRunParams, opts ...option.RequestOption) (res *Run, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
path := "threads/runs"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
@@ -128,7 +132,8 @@ func (r *BetaThreadService) NewAndRunStreaming(ctx context.Context, body BetaThr
raw *http.Response
err error
)
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
opts = append(opts, option.WithJSONSet("stream", true))
path := "threads/runs"
@@ -461,7 +466,7 @@ type Thread struct {
// The identifier, which can be referenced in API endpoints.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) for when the thread was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// 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.
diff --git a/vendor/github.com/openai/openai-go/v3/betathreadmessage.go b/vendor/github.com/openai/openai-go/v3/betathreadmessage.go
index 110e709bd..69c6b19da 100644
--- a/vendor/github.com/openai/openai-go/v3/betathreadmessage.go
+++ b/vendor/github.com/openai/openai-go/v3/betathreadmessage.go
@@ -6,7 +6,6 @@ import (
"context"
"encoding/json"
"errors"
- "fmt"
"net/http"
"net/url"
"slices"
@@ -49,13 +48,14 @@ func NewBetaThreadMessageService(opts ...option.RequestOption) (r BetaThreadMess
//
// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadMessageService) New(ctx context.Context, threadID string, body BetaThreadMessageNewParams, opts ...option.RequestOption) (res *Message, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return nil, err
}
- path := fmt.Sprintf("threads/%s/messages", threadID)
+ path := requestconfig.FormatPath("threads/%s/messages", threadID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
@@ -64,7 +64,8 @@ func (r *BetaThreadMessageService) New(ctx context.Context, threadID string, bod
//
// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadMessageService) Get(ctx context.Context, threadID string, messageID string, opts ...option.RequestOption) (res *Message, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
@@ -74,7 +75,7 @@ func (r *BetaThreadMessageService) Get(ctx context.Context, threadID string, mes
err = errors.New("missing required message_id parameter")
return nil, err
}
- path := fmt.Sprintf("threads/%s/messages/%s", threadID, messageID)
+ path := requestconfig.FormatPath("threads/%s/messages/%s", threadID, messageID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
@@ -83,7 +84,8 @@ func (r *BetaThreadMessageService) Get(ctx context.Context, threadID string, mes
//
// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadMessageService) Update(ctx context.Context, threadID string, messageID string, body BetaThreadMessageUpdateParams, opts ...option.RequestOption) (res *Message, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
@@ -93,7 +95,7 @@ func (r *BetaThreadMessageService) Update(ctx context.Context, threadID string,
err = errors.New("missing required message_id parameter")
return nil, err
}
- path := fmt.Sprintf("threads/%s/messages/%s", threadID, messageID)
+ path := requestconfig.FormatPath("threads/%s/messages/%s", threadID, messageID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
@@ -103,13 +105,14 @@ func (r *BetaThreadMessageService) Update(ctx context.Context, threadID string,
// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadMessageService) List(ctx context.Context, threadID string, query BetaThreadMessageListParams, opts ...option.RequestOption) (res *pagination.CursorPage[Message], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2"), option.WithResponseInto(&raw)}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return nil, err
}
- path := fmt.Sprintf("threads/%s/messages", threadID)
+ path := requestconfig.FormatPath("threads/%s/messages", threadID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
return nil, err
@@ -133,7 +136,8 @@ func (r *BetaThreadMessageService) ListAutoPaging(ctx context.Context, threadID
//
// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadMessageService) Delete(ctx context.Context, threadID string, messageID string, opts ...option.RequestOption) (res *MessageDeleted, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
@@ -143,7 +147,7 @@ func (r *BetaThreadMessageService) Delete(ctx context.Context, threadID string,
err = errors.New("missing required message_id parameter")
return nil, err
}
- path := fmt.Sprintf("threads/%s/messages/%s", threadID, messageID)
+ path := requestconfig.FormatPath("threads/%s/messages/%s", threadID, messageID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
return res, err
}
@@ -780,7 +784,7 @@ type ImageURLDelta struct {
Detail ImageURLDeltaDetail `json:"detail"`
// The URL of the image, must be a supported image types: jpeg, jpg, png, gif,
// webp.
- URL string `json:"url"`
+ URL string `json:"url" format:"uri"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Detail respjson.Field
@@ -841,13 +845,13 @@ type Message struct {
// A list of files attached to the message, and the tools they were added to.
Attachments []MessageAttachment `json:"attachments" api:"required"`
// The Unix timestamp (in seconds) for when the message was completed.
- CompletedAt int64 `json:"completed_at" api:"required"`
+ CompletedAt int64 `json:"completed_at" api:"required" format:"unixtime"`
// The content of the message in array of text and/or images.
Content []MessageContentUnion `json:"content" api:"required"`
// The Unix timestamp (in seconds) for when the message was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// The Unix timestamp (in seconds) for when the message was marked as incomplete.
- IncompleteAt int64 `json:"incomplete_at" api:"required"`
+ IncompleteAt int64 `json:"incomplete_at" api:"required" format:"unixtime"`
// On an incomplete message, details about why the message is incomplete.
IncompleteDetails MessageIncompleteDetails `json:"incomplete_details" api:"required"`
// Set of 16 key-value pairs that can be attached to an object. This can be useful
diff --git a/vendor/github.com/openai/openai-go/v3/betathreadrun.go b/vendor/github.com/openai/openai-go/v3/betathreadrun.go
index 9f43bcb24..d986860f5 100644
--- a/vendor/github.com/openai/openai-go/v3/betathreadrun.go
+++ b/vendor/github.com/openai/openai-go/v3/betathreadrun.go
@@ -5,7 +5,6 @@ package openai
import (
"context"
"errors"
- "fmt"
"net/http"
"net/url"
"slices"
@@ -54,13 +53,14 @@ func NewBetaThreadRunService(opts ...option.RequestOption) (r BetaThreadRunServi
//
// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadRunService) New(ctx context.Context, threadID string, params BetaThreadRunNewParams, opts ...option.RequestOption) (res *Run, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return nil, err
}
- path := fmt.Sprintf("threads/%s/runs", threadID)
+ path := requestconfig.FormatPath("threads/%s/runs", threadID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
return res, err
}
@@ -73,14 +73,15 @@ func (r *BetaThreadRunService) NewStreaming(ctx context.Context, threadID string
raw *http.Response
err error
)
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
opts = append(opts, option.WithJSONSet("stream", true))
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return ssestream.NewStream[AssistantStreamEventUnion](nil, err)
}
- path := fmt.Sprintf("threads/%s/runs", threadID)
+ path := requestconfig.FormatPath("threads/%s/runs", threadID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &raw, opts...)
return ssestream.NewStreamWithSynthesizeEventData[AssistantStreamEventUnion](ssestream.NewDecoder(raw), err)
}
@@ -89,7 +90,8 @@ func (r *BetaThreadRunService) NewStreaming(ctx context.Context, threadID string
//
// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadRunService) Get(ctx context.Context, threadID string, runID string, opts ...option.RequestOption) (res *Run, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
@@ -99,7 +101,7 @@ func (r *BetaThreadRunService) Get(ctx context.Context, threadID string, runID s
err = errors.New("missing required run_id parameter")
return nil, err
}
- path := fmt.Sprintf("threads/%s/runs/%s", threadID, runID)
+ path := requestconfig.FormatPath("threads/%s/runs/%s", threadID, runID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
@@ -108,7 +110,8 @@ func (r *BetaThreadRunService) Get(ctx context.Context, threadID string, runID s
//
// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadRunService) Update(ctx context.Context, threadID string, runID string, body BetaThreadRunUpdateParams, opts ...option.RequestOption) (res *Run, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
@@ -118,7 +121,7 @@ func (r *BetaThreadRunService) Update(ctx context.Context, threadID string, runI
err = errors.New("missing required run_id parameter")
return nil, err
}
- path := fmt.Sprintf("threads/%s/runs/%s", threadID, runID)
+ path := requestconfig.FormatPath("threads/%s/runs/%s", threadID, runID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
@@ -128,13 +131,14 @@ func (r *BetaThreadRunService) Update(ctx context.Context, threadID string, runI
// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadRunService) List(ctx context.Context, threadID string, query BetaThreadRunListParams, opts ...option.RequestOption) (res *pagination.CursorPage[Run], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2"), option.WithResponseInto(&raw)}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return nil, err
}
- path := fmt.Sprintf("threads/%s/runs", threadID)
+ path := requestconfig.FormatPath("threads/%s/runs", threadID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
return nil, err
@@ -158,7 +162,8 @@ func (r *BetaThreadRunService) ListAutoPaging(ctx context.Context, threadID stri
//
// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadRunService) Cancel(ctx context.Context, threadID string, runID string, opts ...option.RequestOption) (res *Run, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
@@ -168,7 +173,7 @@ func (r *BetaThreadRunService) Cancel(ctx context.Context, threadID string, runI
err = errors.New("missing required run_id parameter")
return nil, err
}
- path := fmt.Sprintf("threads/%s/runs/%s/cancel", threadID, runID)
+ path := requestconfig.FormatPath("threads/%s/runs/%s/cancel", threadID, runID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
return res, err
}
@@ -180,7 +185,8 @@ func (r *BetaThreadRunService) Cancel(ctx context.Context, threadID string, runI
//
// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadRunService) SubmitToolOutputs(ctx context.Context, threadID string, runID string, body BetaThreadRunSubmitToolOutputsParams, opts ...option.RequestOption) (res *Run, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
@@ -190,7 +196,7 @@ func (r *BetaThreadRunService) SubmitToolOutputs(ctx context.Context, threadID s
err = errors.New("missing required run_id parameter")
return nil, err
}
- path := fmt.Sprintf("threads/%s/runs/%s/submit_tool_outputs", threadID, runID)
+ path := requestconfig.FormatPath("threads/%s/runs/%s/submit_tool_outputs", threadID, runID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
@@ -206,7 +212,8 @@ func (r *BetaThreadRunService) SubmitToolOutputsStreaming(ctx context.Context, t
raw *http.Response
err error
)
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
opts = append(opts, option.WithJSONSet("stream", true))
if threadID == "" {
@@ -217,7 +224,7 @@ func (r *BetaThreadRunService) SubmitToolOutputsStreaming(ctx context.Context, t
err = errors.New("missing required run_id parameter")
return ssestream.NewStream[AssistantStreamEventUnion](nil, err)
}
- path := fmt.Sprintf("threads/%s/runs/%s/submit_tool_outputs", threadID, runID)
+ path := requestconfig.FormatPath("threads/%s/runs/%s/submit_tool_outputs", threadID, runID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &raw, opts...)
return ssestream.NewStreamWithSynthesizeEventData[AssistantStreamEventUnion](ssestream.NewDecoder(raw), err)
}
@@ -281,15 +288,15 @@ type Run struct {
// execution of this run.
AssistantID string `json:"assistant_id" api:"required"`
// The Unix timestamp (in seconds) for when the run was cancelled.
- CancelledAt int64 `json:"cancelled_at" api:"required"`
+ CancelledAt int64 `json:"cancelled_at" api:"required" format:"unixtime"`
// The Unix timestamp (in seconds) for when the run was completed.
- CompletedAt int64 `json:"completed_at" api:"required"`
+ CompletedAt int64 `json:"completed_at" api:"required" format:"unixtime"`
// The Unix timestamp (in seconds) for when the run was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// The Unix timestamp (in seconds) for when the run will expire.
- ExpiresAt int64 `json:"expires_at" api:"required"`
+ ExpiresAt int64 `json:"expires_at" api:"required" format:"unixtime"`
// The Unix timestamp (in seconds) for when the run failed.
- FailedAt int64 `json:"failed_at" api:"required"`
+ FailedAt int64 `json:"failed_at" api:"required" format:"unixtime"`
// Details on why the run is incomplete. Will be `null` if the run is not
// incomplete.
IncompleteDetails RunIncompleteDetails `json:"incomplete_details" api:"required"`
@@ -347,7 +354,7 @@ type Run struct {
// max context length.
ResponseFormat AssistantResponseFormatOptionUnion `json:"response_format" api:"required"`
// The Unix timestamp (in seconds) for when the run was started.
- StartedAt int64 `json:"started_at" api:"required"`
+ StartedAt int64 `json:"started_at" api:"required" format:"unixtime"`
// The status of the run, which can be either `queued`, `in_progress`,
// `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`,
// `incomplete`, or `expired`.
@@ -628,21 +635,14 @@ type BetaThreadRunNewParams struct {
// model associated with the assistant. If not, the model associated with the
// assistant will be used.
Model shared.ChatModel `json:"model,omitzero"`
- // Constrains effort on reasoning for
- // [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
- // supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`.
- // Reducing reasoning effort can result in faster responses and fewer tokens used
- // on reasoning in a response.
+ // 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.
//
- // - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
- // reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
- // calls are supported for all reasoning values in gpt-5.1.
- // - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
- // support `none`.
- // - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
- // - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
- //
- // Any of "none", "minimal", "low", "medium", "high", "xhigh".
+ // Any of "none", "minimal", "low", "medium", "high", "xhigh", "max".
ReasoningEffort shared.ReasoningEffort `json:"reasoning_effort,omitzero"`
// Override the tools the assistant can use for this run. This is useful for
// modifying the behavior on a per-run basis.
diff --git a/vendor/github.com/openai/openai-go/v3/betathreadrunstep.go b/vendor/github.com/openai/openai-go/v3/betathreadrunstep.go
index d7073939e..d5e72267d 100644
--- a/vendor/github.com/openai/openai-go/v3/betathreadrunstep.go
+++ b/vendor/github.com/openai/openai-go/v3/betathreadrunstep.go
@@ -6,7 +6,6 @@ import (
"context"
"encoding/json"
"errors"
- "fmt"
"net/http"
"net/url"
"slices"
@@ -49,7 +48,8 @@ func NewBetaThreadRunStepService(opts ...option.RequestOption) (r BetaThreadRunS
//
// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadRunStepService) Get(ctx context.Context, threadID string, runID string, stepID string, query BetaThreadRunStepGetParams, opts ...option.RequestOption) (res *RunStep, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
@@ -63,7 +63,7 @@ func (r *BetaThreadRunStepService) Get(ctx context.Context, threadID string, run
err = errors.New("missing required step_id parameter")
return nil, err
}
- path := fmt.Sprintf("threads/%s/runs/%s/steps/%s", threadID, runID, stepID)
+ path := requestconfig.FormatPath("threads/%s/runs/%s/steps/%s", threadID, runID, stepID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
return res, err
}
@@ -73,7 +73,8 @@ func (r *BetaThreadRunStepService) Get(ctx context.Context, threadID string, run
// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadRunStepService) List(ctx context.Context, threadID string, runID string, query BetaThreadRunStepListParams, opts ...option.RequestOption) (res *pagination.CursorPage[RunStep], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2"), option.WithResponseInto(&raw)}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
@@ -83,7 +84,7 @@ func (r *BetaThreadRunStepService) List(ctx context.Context, threadID string, ru
err = errors.New("missing required run_id parameter")
return nil, err
}
- path := fmt.Sprintf("threads/%s/runs/%s/steps", threadID, runID)
+ path := requestconfig.FormatPath("threads/%s/runs/%s/steps", threadID, runID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
return nil, err
@@ -761,16 +762,16 @@ type RunStep struct {
// associated with the run step.
AssistantID string `json:"assistant_id" api:"required"`
// The Unix timestamp (in seconds) for when the run step was cancelled.
- CancelledAt int64 `json:"cancelled_at" api:"required"`
+ CancelledAt int64 `json:"cancelled_at" api:"required" format:"unixtime"`
// The Unix timestamp (in seconds) for when the run step completed.
- CompletedAt int64 `json:"completed_at" api:"required"`
+ CompletedAt int64 `json:"completed_at" api:"required" format:"unixtime"`
// The Unix timestamp (in seconds) for when the run step was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// The Unix timestamp (in seconds) for when the run step expired. A step is
// considered expired if the parent run is expired.
- ExpiredAt int64 `json:"expired_at" api:"required"`
+ ExpiredAt int64 `json:"expired_at" api:"required" format:"unixtime"`
// The Unix timestamp (in seconds) for when the run step failed.
- FailedAt int64 `json:"failed_at" api:"required"`
+ FailedAt int64 `json:"failed_at" api:"required" format:"unixtime"`
// The last error associated with this run step. Will be `null` if there are no
// errors.
LastError RunStepLastError `json:"last_error" api:"required"`
diff --git a/vendor/github.com/openai/openai-go/v3/chatcompletion.go b/vendor/github.com/openai/openai-go/v3/chatcompletion.go
index a465632bd..39d7d9073 100644
--- a/vendor/github.com/openai/openai-go/v3/chatcompletion.go
+++ b/vendor/github.com/openai/openai-go/v3/chatcompletion.go
@@ -6,7 +6,6 @@ import (
"context"
"encoding/json"
"errors"
- "fmt"
"net/http"
"net/url"
"slices"
@@ -70,7 +69,8 @@ func NewChatCompletionService(opts ...option.RequestOption) (r ChatCompletionSer
// Returns a chat completion object, or a streamed sequence of chat completion
// chunk objects if the request is streamed.
func (r *ChatCompletionService) New(ctx context.Context, body ChatCompletionNewParams, opts ...option.RequestOption) (res *ChatCompletion, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "chat/completions"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
@@ -101,7 +101,8 @@ func (r *ChatCompletionService) NewStreaming(ctx context.Context, body ChatCompl
raw *http.Response
err error
)
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append(opts, option.WithJSONSet("stream", true))
path := "chat/completions"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &raw, opts...)
@@ -111,12 +112,13 @@ func (r *ChatCompletionService) NewStreaming(ctx context.Context, body ChatCompl
// Get a stored chat completion. Only Chat Completions that have been created with
// the `store` parameter set to `true` will be returned.
func (r *ChatCompletionService) Get(ctx context.Context, completionID string, opts ...option.RequestOption) (res *ChatCompletion, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if completionID == "" {
err = errors.New("missing required completion_id parameter")
return nil, err
}
- path := fmt.Sprintf("chat/completions/%s", completionID)
+ path := requestconfig.FormatPath("chat/completions/%s", completionID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
@@ -125,12 +127,13 @@ func (r *ChatCompletionService) Get(ctx context.Context, completionID string, op
// with the `store` parameter set to `true` can be modified. Currently, the only
// supported modification is to update the `metadata` field.
func (r *ChatCompletionService) Update(ctx context.Context, completionID string, body ChatCompletionUpdateParams, opts ...option.RequestOption) (res *ChatCompletion, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if completionID == "" {
err = errors.New("missing required completion_id parameter")
return nil, err
}
- path := fmt.Sprintf("chat/completions/%s", completionID)
+ path := requestconfig.FormatPath("chat/completions/%s", completionID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
@@ -139,7 +142,8 @@ func (r *ChatCompletionService) Update(ctx context.Context, completionID string,
// the `store` parameter set to `true` will be returned.
func (r *ChatCompletionService) List(ctx context.Context, query ChatCompletionListParams, opts ...option.RequestOption) (res *pagination.CursorPage[ChatCompletion], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "chat/completions"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
@@ -163,12 +167,13 @@ func (r *ChatCompletionService) ListAutoPaging(ctx context.Context, query ChatCo
// Delete a stored chat completion. Only Chat Completions that have been created
// with the `store` parameter set to `true` can be deleted.
func (r *ChatCompletionService) Delete(ctx context.Context, completionID string, opts ...option.RequestOption) (res *ChatCompletionDeleted, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if completionID == "" {
err = errors.New("missing required completion_id parameter")
return nil, err
}
- path := fmt.Sprintf("chat/completions/%s", completionID)
+ path := requestconfig.FormatPath("chat/completions/%s", completionID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
return res, err
}
@@ -182,11 +187,14 @@ type ChatCompletion struct {
// than 1.
Choices []ChatCompletionChoice `json:"choices" api:"required"`
// The Unix timestamp (in seconds) of when the chat completion was created.
- Created int64 `json:"created" api:"required"`
+ Created int64 `json:"created" api:"required" format:"unixtime"`
// The model used for the chat completion.
Model string `json:"model" api:"required"`
// The object type, which is always `chat.completion`.
Object constant.ChatCompletion `json:"object" default:"chat.completion"`
+ // Moderation results for the request input and generated output, if moderated
+ // completions were requested.
+ Moderation ChatCompletionModeration `json:"moderation" 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
@@ -222,6 +230,7 @@ type ChatCompletion struct {
Created respjson.Field
Model respjson.Field
Object respjson.Field
+ Moderation respjson.Field
ServiceTier respjson.Field
SystemFingerprint respjson.Field
Usage respjson.Field
@@ -242,7 +251,8 @@ type ChatCompletionChoice struct {
// number of tokens specified in the request was reached, `content_filter` if
// content was omitted due to a flag from our content filters, `tool_calls` if the
// model called a tool, or `function_call` (deprecated) if the model called a
- // function.
+ // function. Read the [Model Spec](https://model-spec.openai.com/2025-12-18.html)
+ // for more.
//
// Any of "stop", "length", "tool_calls", "content_filter", "function_call".
FinishReason string `json:"finish_reason" api:"required"`
@@ -290,6 +300,342 @@ func (r *ChatCompletionChoiceLogprobs) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+// Moderation results for the request input and generated output, if moderated
+// completions were requested.
+type ChatCompletionModeration struct {
+ // Moderation for the request input.
+ Input ChatCompletionModerationInputUnion `json:"input" api:"required"`
+ // Moderation for the generated output.
+ Output ChatCompletionModerationOutputUnion `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 ChatCompletionModeration) RawJSON() string { return r.JSON.raw }
+func (r *ChatCompletionModeration) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// ChatCompletionModerationInputUnion contains all possible properties and values
+// from [ChatCompletionModerationInputModerationResults],
+// [ChatCompletionModerationInputError].
+//
+// Use the [ChatCompletionModerationInputUnion.AsAny] method to switch on the
+// variant.
+//
+// Use the methods beginning with 'As' to cast the union to one of its variants.
+type ChatCompletionModerationInputUnion struct {
+ // This field is from variant [ChatCompletionModerationInputModerationResults].
+ Model string `json:"model"`
+ // This field is from variant [ChatCompletionModerationInputModerationResults].
+ Results []ChatCompletionModerationInputModerationResultsResult `json:"results"`
+ // Any of "moderation_results", "error".
+ Type string `json:"type"`
+ // This field is from variant [ChatCompletionModerationInputError].
+ Code string `json:"code"`
+ // This field is from variant [ChatCompletionModerationInputError].
+ Message string `json:"message"`
+ JSON struct {
+ Model respjson.Field
+ Results respjson.Field
+ Type respjson.Field
+ Code respjson.Field
+ Message respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// anyChatCompletionModerationInput is implemented by each variant of
+// [ChatCompletionModerationInputUnion] to add type safety for the return type of
+// [ChatCompletionModerationInputUnion.AsAny]
+type anyChatCompletionModerationInput interface {
+ implChatCompletionModerationInputUnion()
+}
+
+func (ChatCompletionModerationInputModerationResults) implChatCompletionModerationInputUnion() {}
+func (ChatCompletionModerationInputError) implChatCompletionModerationInputUnion() {}
+
+// Use the following switch statement to find the correct variant
+//
+// switch variant := ChatCompletionModerationInputUnion.AsAny().(type) {
+// case openai.ChatCompletionModerationInputModerationResults:
+// case openai.ChatCompletionModerationInputError:
+// default:
+// fmt.Errorf("no variant present")
+// }
+func (u ChatCompletionModerationInputUnion) AsAny() anyChatCompletionModerationInput {
+ switch u.Type {
+ case "moderation_results":
+ return u.AsModerationResults()
+ case "error":
+ return u.AsError()
+ }
+ return nil
+}
+
+func (u ChatCompletionModerationInputUnion) AsModerationResults() (v ChatCompletionModerationInputModerationResults) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ChatCompletionModerationInputUnion) AsError() (v ChatCompletionModerationInputError) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+// Returns the unmodified JSON received from the API
+func (u ChatCompletionModerationInputUnion) RawJSON() string { return u.JSON.raw }
+
+func (r *ChatCompletionModerationInputUnion) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// Successful moderation results for the request input or generated output.
+type ChatCompletionModerationInputModerationResults struct {
+ // The moderation model used to generate the results.
+ Model string `json:"model" api:"required"`
+ // A list of moderation results.
+ Results []ChatCompletionModerationInputModerationResultsResult `json:"results" api:"required"`
+ // The object type, which is always `moderation_results`.
+ Type constant.ModerationResults `json:"type" default:"moderation_results"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ Model respjson.Field
+ Results respjson.Field
+ Type respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ChatCompletionModerationInputModerationResults) RawJSON() string { return r.JSON.raw }
+func (r *ChatCompletionModerationInputModerationResults) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// A moderation result produced for the response input or output.
+type ChatCompletionModerationInputModerationResultsResult 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 ChatCompletionModerationInputModerationResultsResult) RawJSON() string { return r.JSON.raw }
+func (r *ChatCompletionModerationInputModerationResultsResult) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// An error produced while attempting moderation.
+type ChatCompletionModerationInputError struct {
+ // The error code.
+ Code string `json:"code" api:"required"`
+ // The error message.
+ Message string `json:"message" api:"required"`
+ // The object type, which is always `error`.
+ 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 ChatCompletionModerationInputError) RawJSON() string { return r.JSON.raw }
+func (r *ChatCompletionModerationInputError) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// ChatCompletionModerationOutputUnion contains all possible properties and values
+// from [ChatCompletionModerationOutputModerationResults],
+// [ChatCompletionModerationOutputError].
+//
+// Use the [ChatCompletionModerationOutputUnion.AsAny] method to switch on the
+// variant.
+//
+// Use the methods beginning with 'As' to cast the union to one of its variants.
+type ChatCompletionModerationOutputUnion struct {
+ // This field is from variant [ChatCompletionModerationOutputModerationResults].
+ Model string `json:"model"`
+ // This field is from variant [ChatCompletionModerationOutputModerationResults].
+ Results []ChatCompletionModerationOutputModerationResultsResult `json:"results"`
+ // Any of "moderation_results", "error".
+ Type string `json:"type"`
+ // This field is from variant [ChatCompletionModerationOutputError].
+ Code string `json:"code"`
+ // This field is from variant [ChatCompletionModerationOutputError].
+ Message string `json:"message"`
+ JSON struct {
+ Model respjson.Field
+ Results respjson.Field
+ Type respjson.Field
+ Code respjson.Field
+ Message respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// anyChatCompletionModerationOutput is implemented by each variant of
+// [ChatCompletionModerationOutputUnion] to add type safety for the return type of
+// [ChatCompletionModerationOutputUnion.AsAny]
+type anyChatCompletionModerationOutput interface {
+ implChatCompletionModerationOutputUnion()
+}
+
+func (ChatCompletionModerationOutputModerationResults) implChatCompletionModerationOutputUnion() {}
+func (ChatCompletionModerationOutputError) implChatCompletionModerationOutputUnion() {}
+
+// Use the following switch statement to find the correct variant
+//
+// switch variant := ChatCompletionModerationOutputUnion.AsAny().(type) {
+// case openai.ChatCompletionModerationOutputModerationResults:
+// case openai.ChatCompletionModerationOutputError:
+// default:
+// fmt.Errorf("no variant present")
+// }
+func (u ChatCompletionModerationOutputUnion) AsAny() anyChatCompletionModerationOutput {
+ switch u.Type {
+ case "moderation_results":
+ return u.AsModerationResults()
+ case "error":
+ return u.AsError()
+ }
+ return nil
+}
+
+func (u ChatCompletionModerationOutputUnion) AsModerationResults() (v ChatCompletionModerationOutputModerationResults) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ChatCompletionModerationOutputUnion) AsError() (v ChatCompletionModerationOutputError) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+// Returns the unmodified JSON received from the API
+func (u ChatCompletionModerationOutputUnion) RawJSON() string { return u.JSON.raw }
+
+func (r *ChatCompletionModerationOutputUnion) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// Successful moderation results for the request input or generated output.
+type ChatCompletionModerationOutputModerationResults struct {
+ // The moderation model used to generate the results.
+ Model string `json:"model" api:"required"`
+ // A list of moderation results.
+ Results []ChatCompletionModerationOutputModerationResultsResult `json:"results" api:"required"`
+ // The object type, which is always `moderation_results`.
+ Type constant.ModerationResults `json:"type" default:"moderation_results"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ Model respjson.Field
+ Results respjson.Field
+ Type respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ChatCompletionModerationOutputModerationResults) RawJSON() string { return r.JSON.raw }
+func (r *ChatCompletionModerationOutputModerationResults) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// A moderation result produced for the response input or output.
+type ChatCompletionModerationOutputModerationResultsResult 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 ChatCompletionModerationOutputModerationResultsResult) RawJSON() string { return r.JSON.raw }
+func (r *ChatCompletionModerationOutputModerationResultsResult) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// An error produced while attempting moderation.
+type ChatCompletionModerationOutputError struct {
+ // The error code.
+ Code string `json:"code" api:"required"`
+ // The error message.
+ Message string `json:"message" api:"required"`
+ // The object type, which is always `error`.
+ 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 ChatCompletionModerationOutputError) RawJSON() string { return r.JSON.raw }
+func (r *ChatCompletionModerationOutputError) 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
@@ -450,6 +796,14 @@ func (u ChatCompletionAssistantMessageParamContentArrayOfContentPartUnion) GetTe
return nil
}
+// Returns a pointer to the underlying variant's property, if present.
+func (u ChatCompletionAssistantMessageParamContentArrayOfContentPartUnion) GetPromptCacheBreakpoint() *ChatCompletionContentPartTextPromptCacheBreakpointParam {
+ if vt := u.OfText; vt != nil {
+ return &vt.PromptCacheBreakpoint
+ }
+ return nil
+}
+
// Returns a pointer to the underlying variant's property, if present.
func (u ChatCompletionAssistantMessageParamContentArrayOfContentPartUnion) GetRefusal() *string {
if vt := u.OfRefusal; vt != nil {
@@ -512,7 +866,7 @@ type ChatCompletionAudio struct {
Data string `json:"data" api:"required"`
// The Unix timestamp (in seconds) for when this audio response will no longer be
// accessible on the server for use in multi-turn conversations.
- ExpiresAt int64 `json:"expires_at" api:"required"`
+ ExpiresAt int64 `json:"expires_at" api:"required" format:"unixtime"`
// Transcript of the audio generated by the model.
Transcript string `json:"transcript" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
@@ -646,11 +1000,14 @@ type ChatCompletionChunk struct {
Choices []ChatCompletionChunkChoice `json:"choices" api:"required"`
// The Unix timestamp (in seconds) of when the chat completion was created. Each
// chunk has the same timestamp.
- Created int64 `json:"created" api:"required"`
+ Created int64 `json:"created" api:"required" format:"unixtime"`
// The model to generate the completion.
Model string `json:"model" api:"required"`
// The object type, which is always `chat.completion.chunk`.
Object constant.ChatCompletionChunk `json:"object" default:"chat.completion.chunk"`
+ // Moderation results for the request input and generated output. Present on the
+ // moderation chunk when moderated completions are requested.
+ Moderation ChatCompletionChunkModeration `json:"moderation" 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
@@ -691,6 +1048,7 @@ type ChatCompletionChunk struct {
Created respjson.Field
Model respjson.Field
Object respjson.Field
+ Moderation respjson.Field
ServiceTier respjson.Field
SystemFingerprint respjson.Field
Usage respjson.Field
@@ -794,25 +1152,354 @@ type ChatCompletionChunkChoiceDeltaFunctionCall struct {
}
// Returns the unmodified JSON received from the API
-func (r ChatCompletionChunkChoiceDeltaFunctionCall) RawJSON() string { return r.JSON.raw }
-func (r *ChatCompletionChunkChoiceDeltaFunctionCall) UnmarshalJSON(data []byte) error {
+func (r ChatCompletionChunkChoiceDeltaFunctionCall) RawJSON() string { return r.JSON.raw }
+func (r *ChatCompletionChunkChoiceDeltaFunctionCall) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ChatCompletionChunkChoiceDeltaToolCall struct {
+ Index int64 `json:"index" api:"required"`
+ // The ID of the tool call.
+ ID string `json:"id"`
+ Function ChatCompletionChunkChoiceDeltaToolCallFunction `json:"function"`
+ // The type of the tool. Currently, only `function` is supported.
+ //
+ // Any of "function".
+ Type string `json:"type"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ Index respjson.Field
+ ID respjson.Field
+ Function respjson.Field
+ Type respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ChatCompletionChunkChoiceDeltaToolCall) RawJSON() string { return r.JSON.raw }
+func (r *ChatCompletionChunkChoiceDeltaToolCall) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ChatCompletionChunkChoiceDeltaToolCallFunction struct {
+ // The arguments to call the function with, as generated by the model in JSON
+ // format. Note that the model does not always generate valid JSON, and may
+ // hallucinate parameters not defined by your function schema. Validate the
+ // arguments in your code before calling your function.
+ Arguments string `json:"arguments"`
+ // The name of the function to call.
+ Name string `json:"name"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ Arguments respjson.Field
+ Name respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ChatCompletionChunkChoiceDeltaToolCallFunction) RawJSON() string { return r.JSON.raw }
+func (r *ChatCompletionChunkChoiceDeltaToolCallFunction) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// Log probability information for the choice.
+type ChatCompletionChunkChoiceLogprobs struct {
+ // A list of message content tokens with log probability information.
+ Content []ChatCompletionTokenLogprob `json:"content" api:"required"`
+ // A list of message refusal tokens with log probability information.
+ Refusal []ChatCompletionTokenLogprob `json:"refusal" api:"required"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ Content respjson.Field
+ Refusal respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ChatCompletionChunkChoiceLogprobs) RawJSON() string { return r.JSON.raw }
+func (r *ChatCompletionChunkChoiceLogprobs) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// Moderation results for the request input and generated output. Present on the
+// moderation chunk when moderated completions are requested.
+type ChatCompletionChunkModeration struct {
+ // Moderation for the request input.
+ Input ChatCompletionChunkModerationInputUnion `json:"input" api:"required"`
+ // Moderation for the generated output.
+ Output ChatCompletionChunkModerationOutputUnion `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 ChatCompletionChunkModeration) RawJSON() string { return r.JSON.raw }
+func (r *ChatCompletionChunkModeration) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// ChatCompletionChunkModerationInputUnion contains all possible properties and
+// values from [ChatCompletionChunkModerationInputModerationResults],
+// [ChatCompletionChunkModerationInputError].
+//
+// Use the [ChatCompletionChunkModerationInputUnion.AsAny] method to switch on the
+// variant.
+//
+// Use the methods beginning with 'As' to cast the union to one of its variants.
+type ChatCompletionChunkModerationInputUnion struct {
+ // This field is from variant
+ // [ChatCompletionChunkModerationInputModerationResults].
+ Model string `json:"model"`
+ // This field is from variant
+ // [ChatCompletionChunkModerationInputModerationResults].
+ Results []ChatCompletionChunkModerationInputModerationResultsResult `json:"results"`
+ // Any of "moderation_results", "error".
+ Type string `json:"type"`
+ // This field is from variant [ChatCompletionChunkModerationInputError].
+ Code string `json:"code"`
+ // This field is from variant [ChatCompletionChunkModerationInputError].
+ Message string `json:"message"`
+ JSON struct {
+ Model respjson.Field
+ Results respjson.Field
+ Type respjson.Field
+ Code respjson.Field
+ Message respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// anyChatCompletionChunkModerationInput is implemented by each variant of
+// [ChatCompletionChunkModerationInputUnion] to add type safety for the return type
+// of [ChatCompletionChunkModerationInputUnion.AsAny]
+type anyChatCompletionChunkModerationInput interface {
+ implChatCompletionChunkModerationInputUnion()
+}
+
+func (ChatCompletionChunkModerationInputModerationResults) implChatCompletionChunkModerationInputUnion() {
+}
+func (ChatCompletionChunkModerationInputError) implChatCompletionChunkModerationInputUnion() {}
+
+// Use the following switch statement to find the correct variant
+//
+// switch variant := ChatCompletionChunkModerationInputUnion.AsAny().(type) {
+// case openai.ChatCompletionChunkModerationInputModerationResults:
+// case openai.ChatCompletionChunkModerationInputError:
+// default:
+// fmt.Errorf("no variant present")
+// }
+func (u ChatCompletionChunkModerationInputUnion) AsAny() anyChatCompletionChunkModerationInput {
+ switch u.Type {
+ case "moderation_results":
+ return u.AsModerationResults()
+ case "error":
+ return u.AsError()
+ }
+ return nil
+}
+
+func (u ChatCompletionChunkModerationInputUnion) AsModerationResults() (v ChatCompletionChunkModerationInputModerationResults) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ChatCompletionChunkModerationInputUnion) AsError() (v ChatCompletionChunkModerationInputError) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+// Returns the unmodified JSON received from the API
+func (u ChatCompletionChunkModerationInputUnion) RawJSON() string { return u.JSON.raw }
+
+func (r *ChatCompletionChunkModerationInputUnion) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// Successful moderation results for the request input or generated output.
+type ChatCompletionChunkModerationInputModerationResults struct {
+ // The moderation model used to generate the results.
+ Model string `json:"model" api:"required"`
+ // A list of moderation results.
+ Results []ChatCompletionChunkModerationInputModerationResultsResult `json:"results" api:"required"`
+ // The object type, which is always `moderation_results`.
+ Type constant.ModerationResults `json:"type" default:"moderation_results"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ Model respjson.Field
+ Results respjson.Field
+ Type respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ChatCompletionChunkModerationInputModerationResults) RawJSON() string { return r.JSON.raw }
+func (r *ChatCompletionChunkModerationInputModerationResults) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// A moderation result produced for the response input or output.
+type ChatCompletionChunkModerationInputModerationResultsResult 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 ChatCompletionChunkModerationInputModerationResultsResult) RawJSON() string {
+ return r.JSON.raw
+}
+func (r *ChatCompletionChunkModerationInputModerationResultsResult) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// An error produced while attempting moderation.
+type ChatCompletionChunkModerationInputError struct {
+ // The error code.
+ Code string `json:"code" api:"required"`
+ // The error message.
+ Message string `json:"message" api:"required"`
+ // The object type, which is always `error`.
+ 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 ChatCompletionChunkModerationInputError) RawJSON() string { return r.JSON.raw }
+func (r *ChatCompletionChunkModerationInputError) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// ChatCompletionChunkModerationOutputUnion contains all possible properties and
+// values from [ChatCompletionChunkModerationOutputModerationResults],
+// [ChatCompletionChunkModerationOutputError].
+//
+// Use the [ChatCompletionChunkModerationOutputUnion.AsAny] method to switch on the
+// variant.
+//
+// Use the methods beginning with 'As' to cast the union to one of its variants.
+type ChatCompletionChunkModerationOutputUnion struct {
+ // This field is from variant
+ // [ChatCompletionChunkModerationOutputModerationResults].
+ Model string `json:"model"`
+ // This field is from variant
+ // [ChatCompletionChunkModerationOutputModerationResults].
+ Results []ChatCompletionChunkModerationOutputModerationResultsResult `json:"results"`
+ // Any of "moderation_results", "error".
+ Type string `json:"type"`
+ // This field is from variant [ChatCompletionChunkModerationOutputError].
+ Code string `json:"code"`
+ // This field is from variant [ChatCompletionChunkModerationOutputError].
+ Message string `json:"message"`
+ JSON struct {
+ Model respjson.Field
+ Results respjson.Field
+ Type respjson.Field
+ Code respjson.Field
+ Message respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// anyChatCompletionChunkModerationOutput is implemented by each variant of
+// [ChatCompletionChunkModerationOutputUnion] to add type safety for the return
+// type of [ChatCompletionChunkModerationOutputUnion.AsAny]
+type anyChatCompletionChunkModerationOutput interface {
+ implChatCompletionChunkModerationOutputUnion()
+}
+
+func (ChatCompletionChunkModerationOutputModerationResults) implChatCompletionChunkModerationOutputUnion() {
+}
+func (ChatCompletionChunkModerationOutputError) implChatCompletionChunkModerationOutputUnion() {}
+
+// Use the following switch statement to find the correct variant
+//
+// switch variant := ChatCompletionChunkModerationOutputUnion.AsAny().(type) {
+// case openai.ChatCompletionChunkModerationOutputModerationResults:
+// case openai.ChatCompletionChunkModerationOutputError:
+// default:
+// fmt.Errorf("no variant present")
+// }
+func (u ChatCompletionChunkModerationOutputUnion) AsAny() anyChatCompletionChunkModerationOutput {
+ switch u.Type {
+ case "moderation_results":
+ return u.AsModerationResults()
+ case "error":
+ return u.AsError()
+ }
+ return nil
+}
+
+func (u ChatCompletionChunkModerationOutputUnion) AsModerationResults() (v ChatCompletionChunkModerationOutputModerationResults) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ChatCompletionChunkModerationOutputUnion) AsError() (v ChatCompletionChunkModerationOutputError) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+// Returns the unmodified JSON received from the API
+func (u ChatCompletionChunkModerationOutputUnion) RawJSON() string { return u.JSON.raw }
+
+func (r *ChatCompletionChunkModerationOutputUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
-type ChatCompletionChunkChoiceDeltaToolCall struct {
- Index int64 `json:"index" api:"required"`
- // The ID of the tool call.
- ID string `json:"id"`
- Function ChatCompletionChunkChoiceDeltaToolCallFunction `json:"function"`
- // The type of the tool. Currently, only `function` is supported.
- //
- // Any of "function".
- Type string `json:"type"`
+// Successful moderation results for the request input or generated output.
+type ChatCompletionChunkModerationOutputModerationResults struct {
+ // The moderation model used to generate the results.
+ Model string `json:"model" api:"required"`
+ // A list of moderation results.
+ Results []ChatCompletionChunkModerationOutputModerationResultsResult `json:"results" api:"required"`
+ // The object type, which is always `moderation_results`.
+ Type constant.ModerationResults `json:"type" default:"moderation_results"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
- Index respjson.Field
- ID respjson.Field
- Function respjson.Field
+ Model respjson.Field
+ Results respjson.Field
Type respjson.Field
ExtraFields map[string]respjson.Field
raw string
@@ -820,52 +1507,69 @@ type ChatCompletionChunkChoiceDeltaToolCall struct {
}
// Returns the unmodified JSON received from the API
-func (r ChatCompletionChunkChoiceDeltaToolCall) RawJSON() string { return r.JSON.raw }
-func (r *ChatCompletionChunkChoiceDeltaToolCall) UnmarshalJSON(data []byte) error {
+func (r ChatCompletionChunkModerationOutputModerationResults) RawJSON() string { return r.JSON.raw }
+func (r *ChatCompletionChunkModerationOutputModerationResults) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
-type ChatCompletionChunkChoiceDeltaToolCallFunction struct {
- // The arguments to call the function with, as generated by the model in JSON
- // format. Note that the model does not always generate valid JSON, and may
- // hallucinate parameters not defined by your function schema. Validate the
- // arguments in your code before calling your function.
- Arguments string `json:"arguments"`
- // The name of the function to call.
- Name string `json:"name"`
+// A moderation result produced for the response input or output.
+type ChatCompletionChunkModerationOutputModerationResultsResult 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 {
- Arguments respjson.Field
- Name respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
+ 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 ChatCompletionChunkChoiceDeltaToolCallFunction) RawJSON() string { return r.JSON.raw }
-func (r *ChatCompletionChunkChoiceDeltaToolCallFunction) UnmarshalJSON(data []byte) error {
+func (r ChatCompletionChunkModerationOutputModerationResultsResult) RawJSON() string {
+ return r.JSON.raw
+}
+func (r *ChatCompletionChunkModerationOutputModerationResultsResult) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
-// Log probability information for the choice.
-type ChatCompletionChunkChoiceLogprobs struct {
- // A list of message content tokens with log probability information.
- Content []ChatCompletionTokenLogprob `json:"content" api:"required"`
- // A list of message refusal tokens with log probability information.
- Refusal []ChatCompletionTokenLogprob `json:"refusal" api:"required"`
+// An error produced while attempting moderation.
+type ChatCompletionChunkModerationOutputError struct {
+ // The error code.
+ Code string `json:"code" api:"required"`
+ // The error message.
+ Message string `json:"message" api:"required"`
+ // The object type, which is always `error`.
+ Type constant.Error `json:"type" default:"error"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
- Content respjson.Field
- Refusal respjson.Field
+ 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 ChatCompletionChunkChoiceLogprobs) RawJSON() string { return r.JSON.raw }
-func (r *ChatCompletionChunkChoiceLogprobs) UnmarshalJSON(data []byte) error {
+func (r ChatCompletionChunkModerationOutputError) RawJSON() string { return r.JSON.raw }
+func (r *ChatCompletionChunkModerationOutputError) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
@@ -996,6 +1700,56 @@ func (u ChatCompletionContentPartUnionParam) GetType() *string {
return nil
}
+// Returns a subunion which exports methods to access subproperties
+//
+// Or use AsAny() to get the underlying value
+func (u ChatCompletionContentPartUnionParam) GetPromptCacheBreakpoint() (res chatCompletionContentPartUnionParamPromptCacheBreakpoint) {
+ if vt := u.OfText; vt != nil {
+ res.any = &vt.PromptCacheBreakpoint
+ } else if vt := u.OfImageURL; vt != nil {
+ res.any = &vt.PromptCacheBreakpoint
+ } else if vt := u.OfInputAudio; vt != nil {
+ res.any = &vt.PromptCacheBreakpoint
+ } else if vt := u.OfFile; vt != nil {
+ res.any = &vt.PromptCacheBreakpoint
+ }
+ return
+}
+
+// Can have the runtime types
+// [*ChatCompletionContentPartTextPromptCacheBreakpointParam],
+// [*ChatCompletionContentPartImagePromptCacheBreakpointParam],
+// [*ChatCompletionContentPartInputAudioPromptCacheBreakpointParam],
+// [*ChatCompletionContentPartFilePromptCacheBreakpointParam]
+type chatCompletionContentPartUnionParamPromptCacheBreakpoint struct{ any }
+
+// Use the following switch statement to get the type of the union:
+//
+// switch u.AsAny().(type) {
+// case *openai.ChatCompletionContentPartTextPromptCacheBreakpointParam:
+// case *openai.ChatCompletionContentPartImagePromptCacheBreakpointParam:
+// case *openai.ChatCompletionContentPartInputAudioPromptCacheBreakpointParam:
+// case *openai.ChatCompletionContentPartFilePromptCacheBreakpointParam:
+// default:
+// fmt.Errorf("not present")
+// }
+func (u chatCompletionContentPartUnionParamPromptCacheBreakpoint) AsAny() any { return u.any }
+
+// Returns a pointer to the underlying variant's property, if present.
+func (u chatCompletionContentPartUnionParamPromptCacheBreakpoint) GetMode() *string {
+ switch vt := u.any.(type) {
+ case *ChatCompletionContentPartTextPromptCacheBreakpointParam:
+ return (*string)(&vt.Mode)
+ case *ChatCompletionContentPartImagePromptCacheBreakpointParam:
+ return (*string)(&vt.Mode)
+ case *ChatCompletionContentPartInputAudioPromptCacheBreakpointParam:
+ return (*string)(&vt.Mode)
+ case *ChatCompletionContentPartFilePromptCacheBreakpointParam:
+ return (*string)(&vt.Mode)
+ }
+ return nil
+}
+
func init() {
apijson.RegisterUnion[ChatCompletionContentPartUnionParam](
"type",
@@ -1012,6 +1766,10 @@ func init() {
// The properties File, Type are required.
type ChatCompletionContentPartFileParam struct {
File ChatCompletionContentPartFileFileParam `json:"file,omitzero" 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 ChatCompletionContentPartFilePromptCacheBreakpointParam `json:"prompt_cache_breakpoint,omitzero"`
// The type of the content part. Always `file`.
//
// This field can be elided, and will marshal its zero value as "file".
@@ -1046,17 +1804,48 @@ func (r *ChatCompletionContentPartFileFileParam) UnmarshalJSON(data []byte) erro
return apijson.UnmarshalRoot(data, r)
}
+func NewChatCompletionContentPartFilePromptCacheBreakpointParam() ChatCompletionContentPartFilePromptCacheBreakpointParam {
+ return ChatCompletionContentPartFilePromptCacheBreakpointParam{
+ 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
+// [NewChatCompletionContentPartFilePromptCacheBreakpointParam].
+type ChatCompletionContentPartFilePromptCacheBreakpointParam struct {
+ // The breakpoint mode. Always `explicit`.
+ Mode constant.Explicit `json:"mode" default:"explicit"`
+ paramObj
+}
+
+func (r ChatCompletionContentPartFilePromptCacheBreakpointParam) MarshalJSON() (data []byte, err error) {
+ type shadow ChatCompletionContentPartFilePromptCacheBreakpointParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ChatCompletionContentPartFilePromptCacheBreakpointParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
type ChatCompletionContentPartImage struct {
ImageURL ChatCompletionContentPartImageImageURL `json:"image_url" api:"required"`
// The type of the content part.
Type constant.ImageURL `json:"type" default:"image_url"`
+ // 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 ChatCompletionContentPartImagePromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
- ImageURL respjson.Field
- Type respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
+ ImageURL respjson.Field
+ Type respjson.Field
+ PromptCacheBreakpoint respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
} `json:"-"`
}
@@ -1099,11 +1888,35 @@ func (r *ChatCompletionContentPartImageImageURL) UnmarshalJSON(data []byte) erro
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 ChatCompletionContentPartImagePromptCacheBreakpoint 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 ChatCompletionContentPartImagePromptCacheBreakpoint) RawJSON() string { return r.JSON.raw }
+func (r *ChatCompletionContentPartImagePromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
//
// The properties ImageURL, Type are required.
type ChatCompletionContentPartImageParam struct {
ImageURL ChatCompletionContentPartImageImageURLParam `json:"image_url,omitzero" 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 ChatCompletionContentPartImagePromptCacheBreakpointParam `json:"prompt_cache_breakpoint,omitzero"`
// The type of the content part.
//
// This field can be elided, and will marshal its zero value as "image_url".
@@ -1145,11 +1958,41 @@ func init() {
)
}
+func NewChatCompletionContentPartImagePromptCacheBreakpointParam() ChatCompletionContentPartImagePromptCacheBreakpointParam {
+ return ChatCompletionContentPartImagePromptCacheBreakpointParam{
+ 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
+// [NewChatCompletionContentPartImagePromptCacheBreakpointParam].
+type ChatCompletionContentPartImagePromptCacheBreakpointParam struct {
+ // The breakpoint mode. Always `explicit`.
+ Mode constant.Explicit `json:"mode" default:"explicit"`
+ paramObj
+}
+
+func (r ChatCompletionContentPartImagePromptCacheBreakpointParam) MarshalJSON() (data []byte, err error) {
+ type shadow ChatCompletionContentPartImagePromptCacheBreakpointParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ChatCompletionContentPartImagePromptCacheBreakpointParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// Learn about [audio inputs](https://platform.openai.com/docs/guides/audio).
//
// The properties InputAudio, Type are required.
type ChatCompletionContentPartInputAudioParam struct {
InputAudio ChatCompletionContentPartInputAudioInputAudioParam `json:"input_audio,omitzero" 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 ChatCompletionContentPartInputAudioPromptCacheBreakpointParam `json:"prompt_cache_breakpoint,omitzero"`
// The type of the content part. Always `input_audio`.
//
// This field can be elided, and will marshal its zero value as "input_audio".
@@ -1190,6 +2033,32 @@ func init() {
)
}
+func NewChatCompletionContentPartInputAudioPromptCacheBreakpointParam() ChatCompletionContentPartInputAudioPromptCacheBreakpointParam {
+ return ChatCompletionContentPartInputAudioPromptCacheBreakpointParam{
+ 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
+// [NewChatCompletionContentPartInputAudioPromptCacheBreakpointParam].
+type ChatCompletionContentPartInputAudioPromptCacheBreakpointParam struct {
+ // The breakpoint mode. Always `explicit`.
+ Mode constant.Explicit `json:"mode" default:"explicit"`
+ paramObj
+}
+
+func (r ChatCompletionContentPartInputAudioPromptCacheBreakpointParam) MarshalJSON() (data []byte, err error) {
+ type shadow ChatCompletionContentPartInputAudioPromptCacheBreakpointParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ChatCompletionContentPartInputAudioPromptCacheBreakpointParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// The properties Refusal, Type are required.
type ChatCompletionContentPartRefusalParam struct {
// The refusal message generated by the model.
@@ -1216,12 +2085,17 @@ type ChatCompletionContentPartText struct {
Text string `json:"text" api:"required"`
// The type of the content part.
Type constant.Text `json:"type" default:"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 ChatCompletionContentPartTextPromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
// 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
+ Text respjson.Field
+ Type respjson.Field
+ PromptCacheBreakpoint respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
} `json:"-"`
}
@@ -1241,6 +2115,26 @@ func (r ChatCompletionContentPartText) ToParam() ChatCompletionContentPartTextPa
return param.Override[ChatCompletionContentPartTextParam](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 ChatCompletionContentPartTextPromptCacheBreakpoint 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 ChatCompletionContentPartTextPromptCacheBreakpoint) RawJSON() string { return r.JSON.raw }
+func (r *ChatCompletionContentPartTextPromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// Learn about
// [text inputs](https://platform.openai.com/docs/guides/text-generation).
//
@@ -1248,6 +2142,10 @@ func (r ChatCompletionContentPartText) ToParam() ChatCompletionContentPartTextPa
type ChatCompletionContentPartTextParam struct {
// The text content.
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 ChatCompletionContentPartTextPromptCacheBreakpointParam `json:"prompt_cache_breakpoint,omitzero"`
// The type of the content part.
//
// This field can be elided, and will marshal its zero value as "text".
@@ -1263,6 +2161,32 @@ func (r *ChatCompletionContentPartTextParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+func NewChatCompletionContentPartTextPromptCacheBreakpointParam() ChatCompletionContentPartTextPromptCacheBreakpointParam {
+ return ChatCompletionContentPartTextPromptCacheBreakpointParam{
+ 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
+// [NewChatCompletionContentPartTextPromptCacheBreakpointParam].
+type ChatCompletionContentPartTextPromptCacheBreakpointParam struct {
+ // The breakpoint mode. Always `explicit`.
+ Mode constant.Explicit `json:"mode" default:"explicit"`
+ paramObj
+}
+
+func (r ChatCompletionContentPartTextPromptCacheBreakpointParam) MarshalJSON() (data []byte, err error) {
+ type shadow ChatCompletionContentPartTextPromptCacheBreakpointParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ChatCompletionContentPartTextPromptCacheBreakpointParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// A custom tool that processes input using a specified format.
//
// The properties Custom, Type are required.
@@ -1688,7 +2612,7 @@ type ChatCompletionMessageAnnotationURLCitation struct {
// The title of the web resource.
Title string `json:"title" api:"required"`
// The URL of the web resource.
- URL string `json:"url" api:"required"`
+ URL string `json:"url" api:"required" format:"uri"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
EndIndex respjson.Field
@@ -2476,13 +3400,17 @@ type ChatCompletionStoreMessageContentPartUnion struct {
// This field is from variant [ChatCompletionContentPartText].
Text string `json:"text"`
Type string `json:"type"`
+ // This field is a union of [ChatCompletionContentPartTextPromptCacheBreakpoint],
+ // [ChatCompletionContentPartImagePromptCacheBreakpoint]
+ PromptCacheBreakpoint ChatCompletionStoreMessageContentPartUnionPromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
// This field is from variant [ChatCompletionContentPartImage].
ImageURL ChatCompletionContentPartImageImageURL `json:"image_url"`
JSON struct {
- Text respjson.Field
- Type respjson.Field
- ImageURL respjson.Field
- raw string
+ Text respjson.Field
+ Type respjson.Field
+ PromptCacheBreakpoint respjson.Field
+ ImageURL respjson.Field
+ raw string
} `json:"-"`
}
@@ -2503,6 +3431,26 @@ func (r *ChatCompletionStoreMessageContentPartUnion) UnmarshalJSON(data []byte)
return apijson.UnmarshalRoot(data, r)
}
+// ChatCompletionStoreMessageContentPartUnionPromptCacheBreakpoint is an implicit
+// subunion of [ChatCompletionStoreMessageContentPartUnion].
+// ChatCompletionStoreMessageContentPartUnionPromptCacheBreakpoint provides
+// convenient access to the sub-properties of the union.
+//
+// For type safety it is recommended to directly use a variant of the
+// [ChatCompletionStoreMessageContentPartUnion].
+type ChatCompletionStoreMessageContentPartUnionPromptCacheBreakpoint struct {
+ // This field is from variant [ChatCompletionContentPartTextPromptCacheBreakpoint].
+ Mode constant.Explicit `json:"mode"`
+ JSON struct {
+ Mode respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+func (r *ChatCompletionStoreMessageContentPartUnionPromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// Options for streaming response. Only set this when you set `stream: true`.
type ChatCompletionStreamOptionsParam struct {
// When true, stream obfuscation will be enabled. Stream obfuscation adds random
@@ -2595,8 +3543,7 @@ type ChatCompletionTokenLogprob struct {
// unlikely.
Logprob float64 `json:"logprob" api:"required"`
// List of the most likely tokens and their log probability, at this token
- // position. In rare cases, there may be fewer than the number of requested
- // `top_logprobs` returned.
+ // position. The number of entries may be fewer than the requested `top_logprobs`.
TopLogprobs []ChatCompletionTokenLogprobTopLogprob `json:"top_logprobs" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
@@ -2999,6 +3946,17 @@ type ChatCompletionNewParams struct {
// whether they appear in the text so far, increasing the model's likelihood to
// talk about new topics.
PresencePenalty param.Opt[float64] `json:"presence_penalty,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"`
// This feature is in Beta. If specified, our system will make a best effort to
// sample deterministically, such that repeated requests with the same `seed` and
// parameters should return the same result. Determinism is not guaranteed, and you
@@ -3016,8 +3974,9 @@ type ChatCompletionNewParams struct {
// 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 number of most likely tokens to
- // return at each token position, each with an associated log probability.
+ // 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.
// `logprobs` must be set to `true` if this parameter is used.
TopLogprobs param.Opt[int64] `json:"top_logprobs,omitzero"`
// An alternative to sampling with temperature, called nucleus sampling, where the
@@ -3030,17 +3989,6 @@ type ChatCompletionNewParams struct {
// [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling)
// during tool use.
ParallelToolCalls param.Opt[bool] `json:"parallel_tool_calls,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"`
// 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
@@ -3080,28 +4028,36 @@ type ChatCompletionNewParams struct {
//
// Any of "text", "audio".
Modalities []string `json:"modalities,omitzero"`
+ // Configuration for running moderation on the request input and generated output.
+ Moderation ChatCompletionNewParamsModeration `json:"moderation,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:
//
- // Any of "in-memory", "24h".
+ // - 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 ChatCompletionNewParamsPromptCacheRetention `json:"prompt_cache_retention,omitzero"`
- // Constrains effort on reasoning for
- // [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
- // supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`.
- // Reducing reasoning effort can result in faster responses and fewer tokens used
- // on reasoning in a response.
- //
- // - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
- // reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
- // calls are supported for all reasoning values in gpt-5.1.
- // - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
- // support `none`.
- // - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
- // - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
- //
- // Any of "none", "minimal", "low", "medium", "high", "xhigh".
+ // 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".
ReasoningEffort shared.ReasoningEffort `json:"reasoning_effort,omitzero"`
// Specifies the processing type used for serving the request.
//
@@ -3131,7 +4087,8 @@ type ChatCompletionNewParams struct {
StreamOptions ChatCompletionStreamOptionsParam `json:"stream_options,omitzero"`
// 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`.
+ // responses. Currently supported values are `low`, `medium`, and `high`. The
+ // default is `medium`.
//
// Any of "low", "medium", "high".
Verbosity ChatCompletionNewParamsVerbosity `json:"verbosity,omitzero"`
@@ -3157,6 +4114,16 @@ type ChatCompletionNewParams struct {
// Static predicted output content, such as the content of a text file that is
// being regenerated.
Prediction ChatCompletionPredictionContentParam `json:"prediction,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 ChatCompletionNewParamsPromptCacheOptions `json:"prompt_cache_options,omitzero"`
// An object specifying the format that the model must output.
//
// Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
@@ -3262,14 +4229,155 @@ func (r *ChatCompletionNewParamsFunction) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+// Configuration for running moderation on the request input and generated output.
+//
+// The property Model is required.
+type ChatCompletionNewParamsModeration 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 ChatCompletionNewParamsModerationPolicy `json:"policy,omitzero"`
+ paramObj
+}
+
+func (r ChatCompletionNewParamsModeration) MarshalJSON() (data []byte, err error) {
+ type shadow ChatCompletionNewParamsModeration
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ChatCompletionNewParamsModeration) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// The policy to apply to moderated response input and output.
+type ChatCompletionNewParamsModerationPolicy struct {
+ // The moderation policy for the response input.
+ Input ChatCompletionNewParamsModerationPolicyInput `json:"input,omitzero"`
+ // The moderation policy for the response output.
+ Output ChatCompletionNewParamsModerationPolicyOutput `json:"output,omitzero"`
+ paramObj
+}
+
+func (r ChatCompletionNewParamsModerationPolicy) MarshalJSON() (data []byte, err error) {
+ type shadow ChatCompletionNewParamsModerationPolicy
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ChatCompletionNewParamsModerationPolicy) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// The moderation policy for the response input.
+//
+// The property Mode is required.
+type ChatCompletionNewParamsModerationPolicyInput struct {
+ // Any of "score", "block".
+ Mode string `json:"mode,omitzero" api:"required"`
+ paramObj
+}
+
+func (r ChatCompletionNewParamsModerationPolicyInput) MarshalJSON() (data []byte, err error) {
+ type shadow ChatCompletionNewParamsModerationPolicyInput
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ChatCompletionNewParamsModerationPolicyInput) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func init() {
+ apijson.RegisterFieldValidator[ChatCompletionNewParamsModerationPolicyInput](
+ "mode", "score", "block",
+ )
+}
+
+// The moderation policy for the response output.
+//
+// The property Mode is required.
+type ChatCompletionNewParamsModerationPolicyOutput struct {
+ // Any of "score", "block".
+ Mode string `json:"mode,omitzero" api:"required"`
+ paramObj
+}
+
+func (r ChatCompletionNewParamsModerationPolicyOutput) MarshalJSON() (data []byte, err error) {
+ type shadow ChatCompletionNewParamsModerationPolicyOutput
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ChatCompletionNewParamsModerationPolicyOutput) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func init() {
+ apijson.RegisterFieldValidator[ChatCompletionNewParamsModerationPolicyOutput](
+ "mode", "score", "block",
+ )
+}
+
+// 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 ChatCompletionNewParamsPromptCacheOptions 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 ChatCompletionNewParamsPromptCacheOptions) MarshalJSON() (data []byte, err error) {
+ type shadow ChatCompletionNewParamsPromptCacheOptions
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ChatCompletionNewParamsPromptCacheOptions) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func init() {
+ apijson.RegisterFieldValidator[ChatCompletionNewParamsPromptCacheOptions](
+ "mode", "implicit", "explicit",
+ )
+ apijson.RegisterFieldValidator[ChatCompletionNewParamsPromptCacheOptions](
+ "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 ChatCompletionNewParamsPromptCacheRetention string
const (
- ChatCompletionNewParamsPromptCacheRetentionInMemory ChatCompletionNewParamsPromptCacheRetention = "in-memory"
+ ChatCompletionNewParamsPromptCacheRetentionInMemory ChatCompletionNewParamsPromptCacheRetention = "in_memory"
ChatCompletionNewParamsPromptCacheRetention24h ChatCompletionNewParamsPromptCacheRetention = "24h"
)
@@ -3383,7 +4491,8 @@ func (u *ChatCompletionNewParamsStopUnion) asAny() any {
// 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`.
+// responses. Currently supported values are `low`, `medium`, and `high`. The
+// default is `medium`.
type ChatCompletionNewParamsVerbosity string
const (
diff --git a/vendor/github.com/openai/openai-go/v3/chatcompletionmessage.go b/vendor/github.com/openai/openai-go/v3/chatcompletionmessage.go
index 169afc889..65a315b4e 100644
--- a/vendor/github.com/openai/openai-go/v3/chatcompletionmessage.go
+++ b/vendor/github.com/openai/openai-go/v3/chatcompletionmessage.go
@@ -5,7 +5,6 @@ package openai
import (
"context"
"errors"
- "fmt"
"net/http"
"net/url"
"slices"
@@ -43,13 +42,14 @@ func NewChatCompletionMessageService(opts ...option.RequestOption) (r ChatComple
// been created with the `store` parameter set to `true` will be returned.
func (r *ChatCompletionMessageService) List(ctx context.Context, completionID string, query ChatCompletionMessageListParams, opts ...option.RequestOption) (res *pagination.CursorPage[ChatCompletionStoreMessage], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
if completionID == "" {
err = errors.New("missing required completion_id parameter")
return nil, err
}
- path := fmt.Sprintf("chat/completions/%s/messages", completionID)
+ path := requestconfig.FormatPath("chat/completions/%s/messages", completionID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
return nil, err
diff --git a/vendor/github.com/openai/openai-go/v3/client.go b/vendor/github.com/openai/openai-go/v3/client.go
index 62af45c67..8982a680f 100644
--- a/vendor/github.com/openai/openai-go/v3/client.go
+++ b/vendor/github.com/openai/openai-go/v3/client.go
@@ -7,6 +7,7 @@ import (
"net/http"
"os"
"slices"
+ "strings"
"github.com/openai/openai-go/v3/conversations"
"github.com/openai/openai-go/v3/internal/requestconfig"
@@ -48,6 +49,7 @@ type Client struct {
Batches BatchService
// Use Uploads to upload large files in multiple parts.
Uploads UploadService
+ Admin AdminService
Responses responses.ResponseService
Realtime realtime.RealtimeService
// Manage conversations and conversation items.
@@ -57,17 +59,20 @@ type Client struct {
Videos VideoService
}
-// DefaultClientOptions read from the environment (OPENAI_API_KEY, OPENAI_ORG_ID,
-// OPENAI_PROJECT_ID, OPENAI_WEBHOOK_SECRET, OPENAI_BASE_URL). This should be used
-// to initialize new clients.
+// DefaultClientOptions read from the environment (OPENAI_API_KEY,
+// OPENAI_ADMIN_KEY, OPENAI_ORG_ID, OPENAI_PROJECT_ID, OPENAI_WEBHOOK_SECRET,
+// OPENAI_BASE_URL). This should be used to initialize new clients.
func DefaultClientOptions() []option.RequestOption {
- defaults := []option.RequestOption{option.WithEnvironmentProduction()}
+ defaults := defaultClientOptionsWithoutEnvironment()
if o, ok := os.LookupEnv("OPENAI_BASE_URL"); ok {
defaults = append(defaults, option.WithBaseURL(o))
}
if o, ok := os.LookupEnv("OPENAI_API_KEY"); ok {
defaults = append(defaults, option.WithAPIKey(o))
}
+ if o, ok := os.LookupEnv("OPENAI_ADMIN_KEY"); ok {
+ defaults = append(defaults, option.WithAdminAPIKey(o))
+ }
if o, ok := os.LookupEnv("OPENAI_ORG_ID"); ok {
defaults = append(defaults, option.WithOrganization(o))
}
@@ -77,16 +82,32 @@ func DefaultClientOptions() []option.RequestOption {
if o, ok := os.LookupEnv("OPENAI_WEBHOOK_SECRET"); ok {
defaults = append(defaults, option.WithWebhookSecret(o))
}
+ if o, ok := os.LookupEnv("OPENAI_CUSTOM_HEADERS"); ok {
+ for _, line := range strings.Split(o, "\n") {
+ colon := strings.Index(line, ":")
+ if colon >= 0 {
+ defaults = append(defaults, option.WithHeader(strings.TrimSpace(line[:colon]), strings.TrimSpace(line[colon+1:])))
+ }
+ }
+ }
return defaults
}
+func defaultClientOptionsWithoutEnvironment() []option.RequestOption {
+ return []option.RequestOption{option.WithHTTPClient(defaultHTTPClient()), option.WithEnvironmentProduction()}
+}
+
// NewClient generates a new client with the default option read from the
-// environment (OPENAI_API_KEY, OPENAI_ORG_ID, OPENAI_PROJECT_ID,
+// environment (OPENAI_API_KEY, OPENAI_ADMIN_KEY, OPENAI_ORG_ID, OPENAI_PROJECT_ID,
// OPENAI_WEBHOOK_SECRET, OPENAI_BASE_URL). The option passed in as arguments are
// applied after these default arguments, and all option will be passed down to the
// services and requests that this client makes.
func NewClient(opts ...option.RequestOption) (r Client) {
- opts = append(DefaultClientOptions(), opts...)
+ defaults := DefaultClientOptions()
+ if requestconfig.EnvironmentDefaultsDisabled(opts...) {
+ defaults = defaultClientOptionsWithoutEnvironment()
+ }
+ opts = append(defaults, opts...)
r = Client{Options: opts}
@@ -105,6 +126,7 @@ func NewClient(opts ...option.RequestOption) (r Client) {
r.Beta = NewBetaService(opts...)
r.Batches = NewBatchService(opts...)
r.Uploads = NewUploadService(opts...)
+ r.Admin = NewAdminService(opts...)
r.Responses = responses.NewResponseService(opts...)
r.Realtime = realtime.NewRealtimeService(opts...)
r.Conversations = conversations.NewConversationService(opts...)
@@ -147,7 +169,7 @@ func NewClient(opts ...option.RequestOption) (r Client) {
// For even greater flexibility, see [option.WithResponseInto] and
// [option.WithResponseBodyInto].
func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, opts ...option.RequestOption) error {
- opts = slices.Concat(r.Options, opts)
+ opts = slices.Concat(r.Options, []option.RequestOption{requestconfig.WithBearerAuthPreference()}, opts)
return requestconfig.ExecuteNewRequest(ctx, method, path, params, res, opts...)
}
diff --git a/vendor/github.com/openai/openai-go/v3/completion.go b/vendor/github.com/openai/openai-go/v3/completion.go
index d738745af..5a4af5cc4 100644
--- a/vendor/github.com/openai/openai-go/v3/completion.go
+++ b/vendor/github.com/openai/openai-go/v3/completion.go
@@ -43,7 +43,8 @@ func NewCompletionService(opts ...option.RequestOption) (r CompletionService) {
// Returns a completion object, or a sequence of completion objects if the request
// is streamed.
func (r *CompletionService) New(ctx context.Context, body CompletionNewParams, opts ...option.RequestOption) (res *Completion, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "completions"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
@@ -58,7 +59,8 @@ func (r *CompletionService) NewStreaming(ctx context.Context, body CompletionNew
raw *http.Response
err error
)
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append(opts, option.WithJSONSet("stream", true))
path := "completions"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &raw, opts...)
@@ -73,7 +75,7 @@ type Completion struct {
// The list of completion choices the model generated for the input prompt.
Choices []CompletionChoice `json:"choices" api:"required"`
// The Unix timestamp (in seconds) of when the completion was created.
- Created int64 `json:"created" api:"required"`
+ Created int64 `json:"created" api:"required" format:"unixtime"`
// The model used for completion.
Model string `json:"model" api:"required"`
// The object type, which is always "text_completion"
@@ -232,14 +234,17 @@ func (r *CompletionUsageCompletionTokensDetails) UnmarshalJSON(data []byte) erro
type CompletionUsagePromptTokensDetails struct {
// Audio input tokens present in the prompt.
AudioTokens int64 `json:"audio_tokens"`
+ // The unadjusted number of prompt tokens written to cache.
+ CacheWriteTokens int64 `json:"cache_write_tokens"`
// Cached tokens present in the prompt.
CachedTokens int64 `json:"cached_tokens"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
- AudioTokens respjson.Field
- CachedTokens respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
+ AudioTokens respjson.Field
+ CacheWriteTokens respjson.Field
+ CachedTokens respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
} `json:"-"`
}
diff --git a/vendor/github.com/openai/openai-go/v3/container.go b/vendor/github.com/openai/openai-go/v3/container.go
index bf109262a..09d5396de 100644
--- a/vendor/github.com/openai/openai-go/v3/container.go
+++ b/vendor/github.com/openai/openai-go/v3/container.go
@@ -5,7 +5,6 @@ package openai
import (
"context"
"errors"
- "fmt"
"net/http"
"net/url"
"slices"
@@ -43,7 +42,8 @@ func NewContainerService(opts ...option.RequestOption) (r ContainerService) {
// Create Container
func (r *ContainerService) New(ctx context.Context, body ContainerNewParams, opts ...option.RequestOption) (res *ContainerNewResponse, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "containers"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
@@ -51,12 +51,13 @@ func (r *ContainerService) New(ctx context.Context, body ContainerNewParams, opt
// Retrieve Container
func (r *ContainerService) Get(ctx context.Context, containerID string, opts ...option.RequestOption) (res *ContainerGetResponse, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if containerID == "" {
err = errors.New("missing required container_id parameter")
return nil, err
}
- path := fmt.Sprintf("containers/%s", containerID)
+ path := requestconfig.FormatPath("containers/%s", containerID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
@@ -64,7 +65,8 @@ func (r *ContainerService) Get(ctx context.Context, containerID string, opts ...
// List Containers
func (r *ContainerService) List(ctx context.Context, query ContainerListParams, opts ...option.RequestOption) (res *pagination.CursorPage[ContainerListResponse], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "containers"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
@@ -86,13 +88,14 @@ func (r *ContainerService) ListAutoPaging(ctx context.Context, query ContainerLi
// Delete Container
func (r *ContainerService) Delete(ctx context.Context, containerID string, opts ...option.RequestOption) (err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...)
if containerID == "" {
err = errors.New("missing required container_id parameter")
return err
}
- path := fmt.Sprintf("containers/%s", containerID)
+ path := requestconfig.FormatPath("containers/%s", containerID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...)
return err
}
@@ -101,7 +104,7 @@ type ContainerNewResponse struct {
// Unique identifier for the container.
ID string `json:"id" api:"required"`
// Unix timestamp (in seconds) when the container was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Name of the container.
Name string `json:"name" api:"required"`
// The type of this object.
@@ -113,7 +116,7 @@ type ContainerNewResponse struct {
// before the container expires.
ExpiresAfter ContainerNewResponseExpiresAfter `json:"expires_after"`
// Unix timestamp (in seconds) when the container was last active.
- LastActiveAt int64 `json:"last_active_at"`
+ LastActiveAt int64 `json:"last_active_at" format:"unixtime"`
// The memory limit configured for the container.
//
// Any of "1g", "4g", "16g", "64g".
@@ -204,7 +207,7 @@ type ContainerGetResponse struct {
// Unique identifier for the container.
ID string `json:"id" api:"required"`
// Unix timestamp (in seconds) when the container was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Name of the container.
Name string `json:"name" api:"required"`
// The type of this object.
@@ -216,7 +219,7 @@ type ContainerGetResponse struct {
// before the container expires.
ExpiresAfter ContainerGetResponseExpiresAfter `json:"expires_after"`
// Unix timestamp (in seconds) when the container was last active.
- LastActiveAt int64 `json:"last_active_at"`
+ LastActiveAt int64 `json:"last_active_at" format:"unixtime"`
// The memory limit configured for the container.
//
// Any of "1g", "4g", "16g", "64g".
@@ -307,7 +310,7 @@ type ContainerListResponse struct {
// Unique identifier for the container.
ID string `json:"id" api:"required"`
// Unix timestamp (in seconds) when the container was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Name of the container.
Name string `json:"name" api:"required"`
// The type of this object.
@@ -319,7 +322,7 @@ type ContainerListResponse struct {
// before the container expires.
ExpiresAfter ContainerListResponseExpiresAfter `json:"expires_after"`
// Unix timestamp (in seconds) when the container was last active.
- LastActiveAt int64 `json:"last_active_at"`
+ LastActiveAt int64 `json:"last_active_at" format:"unixtime"`
// The memory limit configured for the container.
//
// Any of "1g", "4g", "16g", "64g".
diff --git a/vendor/github.com/openai/openai-go/v3/containerfile.go b/vendor/github.com/openai/openai-go/v3/containerfile.go
index 8ecc90c01..c3bdc7dc2 100644
--- a/vendor/github.com/openai/openai-go/v3/containerfile.go
+++ b/vendor/github.com/openai/openai-go/v3/containerfile.go
@@ -6,7 +6,6 @@ import (
"bytes"
"context"
"errors"
- "fmt"
"io"
"mime/multipart"
"net/http"
@@ -50,19 +49,21 @@ func NewContainerFileService(opts ...option.RequestOption) (r ContainerFileServi
// You can send either a multipart/form-data request with the raw file content, or
// a JSON request with a file ID.
func (r *ContainerFileService) New(ctx context.Context, containerID string, body ContainerFileNewParams, opts ...option.RequestOption) (res *ContainerFileNewResponse, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if containerID == "" {
err = errors.New("missing required container_id parameter")
return nil, err
}
- path := fmt.Sprintf("containers/%s/files", containerID)
+ path := requestconfig.FormatPath("containers/%s/files", containerID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
// Retrieve Container File
func (r *ContainerFileService) Get(ctx context.Context, containerID string, fileID string, opts ...option.RequestOption) (res *ContainerFileGetResponse, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if containerID == "" {
err = errors.New("missing required container_id parameter")
return nil, err
@@ -71,7 +72,7 @@ func (r *ContainerFileService) Get(ctx context.Context, containerID string, file
err = errors.New("missing required file_id parameter")
return nil, err
}
- path := fmt.Sprintf("containers/%s/files/%s", containerID, fileID)
+ path := requestconfig.FormatPath("containers/%s/files/%s", containerID, fileID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
@@ -79,13 +80,14 @@ func (r *ContainerFileService) Get(ctx context.Context, containerID string, file
// List Container files
func (r *ContainerFileService) List(ctx context.Context, containerID string, query ContainerFileListParams, opts ...option.RequestOption) (res *pagination.CursorPage[ContainerFileListResponse], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
if containerID == "" {
err = errors.New("missing required container_id parameter")
return nil, err
}
- path := fmt.Sprintf("containers/%s/files", containerID)
+ path := requestconfig.FormatPath("containers/%s/files", containerID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
return nil, err
@@ -105,7 +107,8 @@ func (r *ContainerFileService) ListAutoPaging(ctx context.Context, containerID s
// Delete Container File
func (r *ContainerFileService) Delete(ctx context.Context, containerID string, fileID string, opts ...option.RequestOption) (err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...)
if containerID == "" {
err = errors.New("missing required container_id parameter")
@@ -115,7 +118,7 @@ func (r *ContainerFileService) Delete(ctx context.Context, containerID string, f
err = errors.New("missing required file_id parameter")
return err
}
- path := fmt.Sprintf("containers/%s/files/%s", containerID, fileID)
+ path := requestconfig.FormatPath("containers/%s/files/%s", containerID, fileID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...)
return err
}
@@ -128,7 +131,7 @@ type ContainerFileNewResponse struct {
// The container this file belongs to.
ContainerID string `json:"container_id" api:"required"`
// Unix timestamp (in seconds) when the file was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// The type of this object (`container.file`).
Object constant.ContainerFile `json:"object" default:"container.file"`
// Path of the file in the container.
@@ -163,7 +166,7 @@ type ContainerFileGetResponse struct {
// The container this file belongs to.
ContainerID string `json:"container_id" api:"required"`
// Unix timestamp (in seconds) when the file was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// The type of this object (`container.file`).
Object constant.ContainerFile `json:"object" default:"container.file"`
// Path of the file in the container.
@@ -198,7 +201,7 @@ type ContainerFileListResponse struct {
// The container this file belongs to.
ContainerID string `json:"container_id" api:"required"`
// Unix timestamp (in seconds) when the file was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// The type of this object (`container.file`).
Object constant.ContainerFile `json:"object" default:"container.file"`
// Path of the file in the container.
diff --git a/vendor/github.com/openai/openai-go/v3/containerfilecontent.go b/vendor/github.com/openai/openai-go/v3/containerfilecontent.go
index 288c1fa01..b80faa61a 100644
--- a/vendor/github.com/openai/openai-go/v3/containerfilecontent.go
+++ b/vendor/github.com/openai/openai-go/v3/containerfilecontent.go
@@ -5,7 +5,6 @@ package openai
import (
"context"
"errors"
- "fmt"
"net/http"
"slices"
@@ -34,7 +33,8 @@ func NewContainerFileContentService(opts ...option.RequestOption) (r ContainerFi
// Retrieve Container File Content
func (r *ContainerFileContentService) Get(ctx context.Context, containerID string, fileID string, opts ...option.RequestOption) (res *http.Response, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("Accept", "application/binary")}, opts...)
if containerID == "" {
err = errors.New("missing required container_id parameter")
@@ -44,7 +44,7 @@ func (r *ContainerFileContentService) Get(ctx context.Context, containerID strin
err = errors.New("missing required file_id parameter")
return nil, err
}
- path := fmt.Sprintf("containers/%s/files/%s/content", containerID, fileID)
+ path := requestconfig.FormatPath("containers/%s/files/%s/content", containerID, fileID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
diff --git a/vendor/github.com/openai/openai-go/v3/conversations/aliases.go b/vendor/github.com/openai/openai-go/v3/conversations/aliases.go
index 74c6ff9ae..2cd4c5d39 100644
--- a/vendor/github.com/openai/openai-go/v3/conversations/aliases.go
+++ b/vendor/github.com/openai/openai-go/v3/conversations/aliases.go
@@ -64,6 +64,15 @@ const AllModelsGPT5_1CodexMax = shared.AllModelsGPT5_1CodexMax
// This is an alias to an internal type.
type ChatModel = shared.ChatModel
+// Equals "gpt-5.6-sol"
+const ChatModelGPT5_6Sol = shared.ChatModelGPT5_6Sol
+
+// Equals "gpt-5.6-terra"
+const ChatModelGPT5_6Terra = shared.ChatModelGPT5_6Terra
+
+// Equals "gpt-5.6-luna"
+const ChatModelGPT5_6Luna = shared.ChatModelGPT5_6Luna
+
// Equals "gpt-5.4"
const ChatModelGPT5_4 = shared.ChatModelGPT5_4
@@ -465,6 +474,25 @@ const OAuthErrorCodeInvalidSubjectToken = shared.OAuthErrorCodeInvalidSubjectTok
// This is an alias to an internal type.
type Reasoning = shared.Reasoning
+// 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.
+//
+// This is an alias to an internal type.
+type ReasoningContext = shared.ReasoningContext
+
+// Equals "auto"
+const ReasoningContextAuto = shared.ReasoningContextAuto
+
+// Equals "current_turn"
+const ReasoningContextCurrentTurn = shared.ReasoningContextCurrentTurn
+
+// Equals "all_turns"
+const ReasoningContextAllTurns = shared.ReasoningContextAllTurns
+
// **Deprecated:** use `summary` instead.
//
// A summary of the reasoning performed by the model. This can be useful for
@@ -483,6 +511,19 @@ const ReasoningGenerateSummaryConcise = shared.ReasoningGenerateSummaryConcise
// Equals "detailed"
const ReasoningGenerateSummaryDetailed = shared.ReasoningGenerateSummaryDetailed
+// Controls the reasoning execution mode for the request.
+//
+// When returned on a response, this is the effective execution mode.
+//
+// This is an alias to an internal type.
+type ReasoningMode = shared.ReasoningMode
+
+// Equals "standard"
+const ReasoningModeStandard = shared.ReasoningModeStandard
+
+// Equals "pro"
+const ReasoningModePro = shared.ReasoningModePro
+
// 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`.
@@ -510,19 +551,12 @@ const ReasoningSummaryDetailed = shared.ReasoningSummaryDetailed
// This is an alias to an internal type.
type ReasoningParam = shared.ReasoningParam
-// Constrains effort on reasoning for
-// [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
-// supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`.
-// Reducing reasoning effort can result in faster responses and fewer tokens used
-// on reasoning in a response.
-//
-// - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
-// reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
-// calls are supported for all reasoning values in gpt-5.1.
-// - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
-// support `none`.
-// - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
-// - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
+// 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.
//
// This is an alias to an internal type.
type ReasoningEffort = shared.ReasoningEffort
@@ -545,6 +579,9 @@ const ReasoningEffortHigh = shared.ReasoningEffortHigh
// Equals "xhigh"
const ReasoningEffortXhigh = shared.ReasoningEffortXhigh
+// Equals "max"
+const ReasoningEffortMax = shared.ReasoningEffortMax
+
// 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.
diff --git a/vendor/github.com/openai/openai-go/v3/conversations/conversation.go b/vendor/github.com/openai/openai-go/v3/conversations/conversation.go
index f016e692e..74c681115 100644
--- a/vendor/github.com/openai/openai-go/v3/conversations/conversation.go
+++ b/vendor/github.com/openai/openai-go/v3/conversations/conversation.go
@@ -6,7 +6,6 @@ import (
"context"
"encoding/json"
"errors"
- "fmt"
"net/http"
"slices"
@@ -46,7 +45,8 @@ func NewConversationService(opts ...option.RequestOption) (r ConversationService
// Create a conversation.
func (r *ConversationService) New(ctx context.Context, body ConversationNewParams, opts ...option.RequestOption) (res *Conversation, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "conversations"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
@@ -54,36 +54,39 @@ func (r *ConversationService) New(ctx context.Context, body ConversationNewParam
// Get a conversation
func (r *ConversationService) Get(ctx context.Context, conversationID string, opts ...option.RequestOption) (res *Conversation, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if conversationID == "" {
err = errors.New("missing required conversation_id parameter")
return nil, err
}
- path := fmt.Sprintf("conversations/%s", conversationID)
+ path := requestconfig.FormatPath("conversations/%s", conversationID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
// Update a conversation
func (r *ConversationService) Update(ctx context.Context, conversationID string, body ConversationUpdateParams, opts ...option.RequestOption) (res *Conversation, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if conversationID == "" {
err = errors.New("missing required conversation_id parameter")
return nil, err
}
- path := fmt.Sprintf("conversations/%s", conversationID)
+ path := requestconfig.FormatPath("conversations/%s", conversationID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
// Delete a conversation. Items in the conversation will not be deleted.
func (r *ConversationService) Delete(ctx context.Context, conversationID string, opts ...option.RequestOption) (res *ConversationDeletedResource, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if conversationID == "" {
err = errors.New("missing required conversation_id parameter")
return nil, err
}
- path := fmt.Sprintf("conversations/%s", conversationID)
+ path := requestconfig.FormatPath("conversations/%s", conversationID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
return res, err
}
@@ -98,18 +101,23 @@ type ComputerScreenshotContent struct {
// 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"`
+ 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 ComputerScreenshotContentPromptCacheBreakpoint `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
- ExtraFields map[string]respjson.Field
- raw string
+ Detail respjson.Field
+ FileID respjson.Field
+ ImageURL respjson.Field
+ Type respjson.Field
+ PromptCacheBreakpoint respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
} `json:"-"`
}
@@ -130,12 +138,32 @@ const (
ComputerScreenshotContentDetailOriginal ComputerScreenshotContentDetail = "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 ComputerScreenshotContentPromptCacheBreakpoint 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 ComputerScreenshotContentPromptCacheBreakpoint) RawJSON() string { return r.JSON.raw }
+func (r *ComputerScreenshotContentPromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
type Conversation struct {
// The unique ID of the conversation.
ID string `json:"id" api:"required"`
// The time at which the conversation was created, measured in seconds since the
// Unix epoch.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// 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
@@ -240,6 +268,11 @@ type MessageContentUnion struct {
// Any of "input_text", "output_text", "text", "summary_text", "reasoning_text",
// "refusal", "input_image", "computer_screenshot", "input_file".
Type string `json:"type"`
+ // This field is a union of [responses.ResponseInputTextPromptCacheBreakpoint],
+ // [responses.ResponseInputImagePromptCacheBreakpoint],
+ // [ComputerScreenshotContentPromptCacheBreakpoint],
+ // [responses.ResponseInputFilePromptCacheBreakpoint]
+ PromptCacheBreakpoint MessageContentUnionPromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
// This field is from variant [responses.ResponseOutputText].
Annotations []responses.ResponseOutputTextAnnotationUnion `json:"annotations"`
// This field is from variant [responses.ResponseOutputText].
@@ -256,18 +289,19 @@ type MessageContentUnion struct {
// This field is from variant [responses.ResponseInputFile].
Filename string `json:"filename"`
JSON struct {
- Text respjson.Field
- Type 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
- raw string
+ 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
+ raw string
} `json:"-"`
}
@@ -373,6 +407,25 @@ func (r *MessageContentUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+// MessageContentUnionPromptCacheBreakpoint is an implicit subunion of
+// [MessageContentUnion]. MessageContentUnionPromptCacheBreakpoint provides
+// convenient access to the sub-properties of the union.
+//
+// For type safety it is recommended to directly use a variant of the
+// [MessageContentUnion].
+type MessageContentUnionPromptCacheBreakpoint struct {
+ // This field is from variant [responses.ResponseInputTextPromptCacheBreakpoint].
+ Mode constant.Explicit `json:"mode"`
+ JSON struct {
+ Mode respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+func (r *MessageContentUnionPromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// Reasoning text from the model.
type MessageContentReasoningText struct {
// The reasoning text from the model.
diff --git a/vendor/github.com/openai/openai-go/v3/conversations/item.go b/vendor/github.com/openai/openai-go/v3/conversations/item.go
index 0ce05a8dc..0c925fdca 100644
--- a/vendor/github.com/openai/openai-go/v3/conversations/item.go
+++ b/vendor/github.com/openai/openai-go/v3/conversations/item.go
@@ -6,7 +6,6 @@ import (
"context"
"encoding/json"
"errors"
- "fmt"
"net/http"
"net/url"
"slices"
@@ -45,19 +44,21 @@ func NewItemService(opts ...option.RequestOption) (r ItemService) {
// Create items in a conversation with the given ID.
func (r *ItemService) New(ctx context.Context, conversationID string, params ItemNewParams, opts ...option.RequestOption) (res *ConversationItemList, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if conversationID == "" {
err = errors.New("missing required conversation_id parameter")
return nil, err
}
- path := fmt.Sprintf("conversations/%s/items", conversationID)
+ path := requestconfig.FormatPath("conversations/%s/items", conversationID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
return res, err
}
// Get a single item from a conversation with the given IDs.
func (r *ItemService) Get(ctx context.Context, conversationID string, itemID string, query ItemGetParams, opts ...option.RequestOption) (res *ConversationItemUnion, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if conversationID == "" {
err = errors.New("missing required conversation_id parameter")
return nil, err
@@ -66,7 +67,7 @@ func (r *ItemService) Get(ctx context.Context, conversationID string, itemID str
err = errors.New("missing required item_id parameter")
return nil, err
}
- path := fmt.Sprintf("conversations/%s/items/%s", conversationID, itemID)
+ path := requestconfig.FormatPath("conversations/%s/items/%s", conversationID, itemID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
return res, err
}
@@ -74,13 +75,14 @@ func (r *ItemService) Get(ctx context.Context, conversationID string, itemID str
// List all items for a conversation with the given ID.
func (r *ItemService) List(ctx context.Context, conversationID string, query ItemListParams, opts ...option.RequestOption) (res *pagination.ConversationCursorPage[ConversationItemUnion], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
if conversationID == "" {
err = errors.New("missing required conversation_id parameter")
return nil, err
}
- path := fmt.Sprintf("conversations/%s/items", conversationID)
+ path := requestconfig.FormatPath("conversations/%s/items", conversationID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
return nil, err
@@ -100,7 +102,8 @@ func (r *ItemService) ListAutoPaging(ctx context.Context, conversationID string,
// Delete an item from a conversation with the given IDs.
func (r *ItemService) Delete(ctx context.Context, conversationID string, itemID string, opts ...option.RequestOption) (res *Conversation, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if conversationID == "" {
err = errors.New("missing required conversation_id parameter")
return nil, err
@@ -109,7 +112,7 @@ func (r *ItemService) Delete(ctx context.Context, conversationID string, itemID
err = errors.New("missing required item_id parameter")
return nil, err
}
- path := fmt.Sprintf("conversations/%s/items/%s", conversationID, itemID)
+ path := requestconfig.FormatPath("conversations/%s/items/%s", conversationID, itemID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
return res, err
}
@@ -121,9 +124,10 @@ func (r *ItemService) Delete(ctx context.Context, conversationID string, itemID
// [ConversationItemImageGenerationCall], [responses.ResponseComputerToolCall],
// [responses.ResponseComputerToolCallOutputItem],
// [responses.ResponseToolSearchCall], [responses.ResponseToolSearchOutputItem],
-// [responses.ResponseReasoningItem], [responses.ResponseCompactionItem],
-// [responses.ResponseCodeInterpreterToolCall], [ConversationItemLocalShellCall],
-// [ConversationItemLocalShellCallOutput],
+// [ConversationItemAdditionalTools], [responses.ResponseReasoningItem],
+// [ConversationItemProgram], [ConversationItemProgramOutput],
+// [responses.ResponseCompactionItem], [responses.ResponseCodeInterpreterToolCall],
+// [ConversationItemLocalShellCall], [ConversationItemLocalShellCallOutput],
// [responses.ResponseFunctionShellToolCall],
// [responses.ResponseFunctionShellToolCallOutput],
// [responses.ResponseApplyPatchToolCall],
@@ -140,16 +144,16 @@ type ConversationItemUnion struct {
// This field is a union of [[]MessageContentUnion],
// [[]responses.ResponseReasoningItemContent]
Content ConversationItemUnionContent `json:"content"`
- // This field is from variant [Message].
- Role MessageRole `json:"role"`
- Status string `json:"status"`
+ Role string `json:"role"`
+ Status string `json:"status"`
// Any of "message", "function_call", "function_call_output", "file_search_call",
// "web_search_call", "image_generation_call", "computer_call",
- // "computer_call_output", "tool_search_call", "tool_search_output", "reasoning",
- // "compaction", "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",
+ // "computer_call_output", "tool_search_call", "tool_search_output",
+ // "additional_tools", "reasoning", "program", "program_output", "compaction",
+ // "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 from variant [Message].
@@ -158,8 +162,17 @@ type ConversationItemUnion struct {
Arguments ConversationItemUnionArguments `json:"arguments"`
CallID string `json:"call_id"`
Name string `json:"name"`
- Namespace string `json:"namespace"`
- CreatedBy string `json:"created_by"`
+ // This field is a union of [responses.ResponseFunctionToolCallCallerUnion],
+ // [responses.ResponseFunctionToolCallOutputItemCallerUnion],
+ // [responses.ResponseFunctionShellToolCallCallerUnion],
+ // [responses.ResponseFunctionShellToolCallOutputCallerUnion],
+ // [responses.ResponseApplyPatchToolCallCallerUnion],
+ // [responses.ResponseApplyPatchToolCallOutputCallerUnion],
+ // [responses.ResponseCustomToolCallCallerUnion],
+ // [responses.ResponseCustomToolCallOutputCallerUnion]
+ Caller ConversationItemUnionCaller `json:"caller"`
+ Namespace string `json:"namespace"`
+ CreatedBy string `json:"created_by"`
// This field is a union of
// [responses.ResponseFunctionToolCallOutputItemOutputUnion],
// [responses.ResponseComputerToolCallOutputScreenshot], [string],
@@ -175,8 +188,7 @@ type ConversationItemUnion struct {
// [ConversationItemLocalShellCallAction],
// [responses.ResponseFunctionShellToolCallAction]
Action ConversationItemUnionAction `json:"action"`
- // This field is from variant [ConversationItemImageGenerationCall].
- Result string `json:"result"`
+ Result string `json:"result"`
// This field is from variant [responses.ResponseComputerToolCall].
PendingSafetyChecks []responses.ResponseComputerToolCallPendingSafetyCheck `json:"pending_safety_checks"`
// This field is from variant [responses.ResponseComputerToolCall].
@@ -184,14 +196,15 @@ type ConversationItemUnion struct {
// This field is from variant [responses.ResponseComputerToolCallOutputItem].
AcknowledgedSafetyChecks []responses.ResponseComputerToolCallOutputItemAcknowledgedSafetyCheck `json:"acknowledged_safety_checks"`
Execution string `json:"execution"`
- // This field is a union of [[]responses.ToolUnion],
+ // This field is a union of [[]responses.ToolUnion], [[]responses.ToolUnion],
// [[]ConversationItemMcpListToolsTool]
Tools ConversationItemUnionTools `json:"tools"`
// This field is from variant [responses.ResponseReasoningItem].
Summary []responses.ResponseReasoningItemSummary `json:"summary"`
EncryptedContent string `json:"encrypted_content"`
- // This field is from variant [responses.ResponseCodeInterpreterToolCall].
- Code string `json:"code"`
+ Code string `json:"code"`
+ // This field is from variant [ConversationItemProgram].
+ Fingerprint string `json:"fingerprint"`
// This field is from variant [responses.ResponseCodeInterpreterToolCall].
ContainerID string `json:"container_id"`
// This field is from variant [responses.ResponseCodeInterpreterToolCall].
@@ -221,6 +234,7 @@ type ConversationItemUnion struct {
Arguments respjson.Field
CallID respjson.Field
Name respjson.Field
+ Caller respjson.Field
Namespace respjson.Field
CreatedBy respjson.Field
Output respjson.Field
@@ -236,6 +250,7 @@ type ConversationItemUnion struct {
Summary respjson.Field
EncryptedContent respjson.Field
Code respjson.Field
+ Fingerprint respjson.Field
ContainerID respjson.Field
Outputs respjson.Field
Environment respjson.Field
@@ -259,6 +274,9 @@ type anyConversationItem interface {
func (Message) ImplConversationItemUnion() {}
func (ConversationItemImageGenerationCall) ImplConversationItemUnion() {}
+func (ConversationItemAdditionalTools) ImplConversationItemUnion() {}
+func (ConversationItemProgram) ImplConversationItemUnion() {}
+func (ConversationItemProgramOutput) ImplConversationItemUnion() {}
func (ConversationItemLocalShellCall) ImplConversationItemUnion() {}
func (ConversationItemLocalShellCallOutput) ImplConversationItemUnion() {}
func (ConversationItemMcpListTools) ImplConversationItemUnion() {}
@@ -279,7 +297,10 @@ func (ConversationItemMcpCall) ImplConversationItemUnion() {}
// case responses.ResponseComputerToolCallOutputItem:
// case responses.ResponseToolSearchCall:
// case responses.ResponseToolSearchOutputItem:
+// case conversations.ConversationItemAdditionalTools:
// case responses.ResponseReasoningItem:
+// case conversations.ConversationItemProgram:
+// case conversations.ConversationItemProgramOutput:
// case responses.ResponseCompactionItem:
// case responses.ResponseCodeInterpreterToolCall:
// case conversations.ConversationItemLocalShellCall:
@@ -319,8 +340,14 @@ func (u ConversationItemUnion) AsAny() anyConversationItem {
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 "code_interpreter_call":
@@ -403,11 +430,26 @@ func (u ConversationItemUnion) AsToolSearchOutput() (v responses.ResponseToolSea
return
}
+func (u ConversationItemUnion) AsAdditionalTools() (v ConversationItemAdditionalTools) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
func (u ConversationItemUnion) AsReasoning() (v responses.ResponseReasoningItem) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
+func (u ConversationItemUnion) AsProgram() (v ConversationItemProgram) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ConversationItemUnion) AsProgramOutput() (v ConversationItemProgramOutput) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
func (u ConversationItemUnion) AsCompaction() (v responses.ResponseCompactionItem) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
@@ -537,6 +579,26 @@ func (r *ConversationItemUnionArguments) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+// ConversationItemUnionCaller is an implicit subunion of [ConversationItemUnion].
+// ConversationItemUnionCaller provides convenient access to the sub-properties of
+// the union.
+//
+// For type safety it is recommended to directly use a variant of the
+// [ConversationItemUnion].
+type ConversationItemUnionCaller struct {
+ Type string `json:"type"`
+ CallerID string `json:"caller_id"`
+ JSON struct {
+ Type respjson.Field
+ CallerID respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+func (r *ConversationItemUnionCaller) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// ConversationItemUnionOutput is an implicit subunion of [ConversationItemUnion].
// ConversationItemUnionOutput provides convenient access to the sub-properties of
// the union.
@@ -585,12 +647,12 @@ func (r *ConversationItemUnionOutput) UnmarshalJSON(data []byte) error {
// For type safety it is recommended to directly use a variant of the
// [ConversationItemUnion].
type ConversationItemUnionAction struct {
- // This field is from variant [responses.ResponseFunctionWebSearchActionUnion].
- Query string `json:"query"`
- Type string `json:"type"`
+ Type string `json:"type"`
// This field is from variant [responses.ResponseFunctionWebSearchActionUnion].
Queries []string `json:"queries"`
// This field is from variant [responses.ResponseFunctionWebSearchActionUnion].
+ Query string `json:"query"`
+ // This field is from variant [responses.ResponseFunctionWebSearchActionUnion].
Sources []responses.ResponseFunctionWebSearchActionSearchSource `json:"sources"`
URL string `json:"url"`
// This field is from variant [responses.ResponseFunctionWebSearchActionUnion].
@@ -622,9 +684,9 @@ type ConversationItemUnionAction struct {
// This field is from variant [responses.ResponseFunctionShellToolCallAction].
MaxOutputLength int64 `json:"max_output_length"`
JSON struct {
- Query respjson.Field
Type respjson.Field
Queries respjson.Field
+ Query respjson.Field
Sources respjson.Field
URL respjson.Field
Pattern respjson.Field
@@ -707,6 +769,95 @@ func (r *ConversationItemImageGenerationCall) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+type ConversationItemAdditionalTools 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 []responses.ToolUnion `json:"tools" api:"required"`
+ // The type of the item. Always `additional_tools`.
+ Type constant.AdditionalTools `json:"type" default:"additional_tools"`
+ // 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
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ConversationItemAdditionalTools) RawJSON() string { return r.JSON.raw }
+func (r *ConversationItemAdditionalTools) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ConversationItemProgram 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"`
+ // 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
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ConversationItemProgram) RawJSON() string { return r.JSON.raw }
+func (r *ConversationItemProgram) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ConversationItemProgramOutput 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"`
+ // 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
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ConversationItemProgramOutput) RawJSON() string { return r.JSON.raw }
+func (r *ConversationItemProgramOutput) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// A tool call to run a command on the local shell.
type ConversationItemLocalShellCall struct {
// The unique ID of the local shell call.
diff --git a/vendor/github.com/openai/openai-go/v3/default_http_client.go b/vendor/github.com/openai/openai-go/v3/default_http_client.go
new file mode 100644
index 000000000..33259bee9
--- /dev/null
+++ b/vendor/github.com/openai/openai-go/v3/default_http_client.go
@@ -0,0 +1,30 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package openai
+
+import (
+ "net/http"
+ "time"
+)
+
+// defaultResponseHeaderTimeout bounds the time between a fully written request
+// and the server's response headers. It does not apply to the response body,
+// so long-running streams are unaffected. Without this, a server that accepts
+// the connection but never responds would hang the request indefinitely.
+const defaultResponseHeaderTimeout = 10 * time.Minute
+
+// defaultHTTPClient returns an [*http.Client] used when the caller does not
+// supply one via [option.WithHTTPClient]. When [http.DefaultTransport] is the
+// stdlib [*http.Transport], it is cloned and a [http.Transport.ResponseHeaderTimeout]
+// is set so stuck connections fail fast instead of compounding across retries.
+// If [http.DefaultTransport] has been wrapped (for example by otelhttp for
+// distributed tracing), the wrapping is preserved and the header timeout is
+// skipped.
+func defaultHTTPClient() *http.Client {
+ if t, ok := http.DefaultTransport.(*http.Transport); ok {
+ t = t.Clone()
+ t.ResponseHeaderTimeout = defaultResponseHeaderTimeout
+ return &http.Client{Transport: t}
+ }
+ return &http.Client{Transport: http.DefaultTransport}
+}
diff --git a/vendor/github.com/openai/openai-go/v3/embedding.go b/vendor/github.com/openai/openai-go/v3/embedding.go
index b88d2c335..610db8417 100644
--- a/vendor/github.com/openai/openai-go/v3/embedding.go
+++ b/vendor/github.com/openai/openai-go/v3/embedding.go
@@ -39,7 +39,8 @@ func NewEmbeddingService(opts ...option.RequestOption) (r EmbeddingService) {
// Creates an embedding vector representing the input text.
func (r *EmbeddingService) New(ctx context.Context, body EmbeddingNewParams, opts ...option.RequestOption) (res *CreateEmbeddingResponse, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "embeddings"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
diff --git a/vendor/github.com/openai/openai-go/v3/file.go b/vendor/github.com/openai/openai-go/v3/file.go
index 88dc08993..91877323e 100644
--- a/vendor/github.com/openai/openai-go/v3/file.go
+++ b/vendor/github.com/openai/openai-go/v3/file.go
@@ -6,7 +6,6 @@ import (
"bytes"
"context"
"errors"
- "fmt"
"io"
"mime/multipart"
"net/http"
@@ -48,7 +47,8 @@ func NewFileService(opts ...option.RequestOption) (r FileService) {
// Upload a file that can be used across various endpoints. Individual files can be
// up to 512 MB, and each project can store up to 2.5 TB of files in total. There
-// is no organization-wide storage limit.
+// is no organization-wide storage limit. Uploads to this endpoint are rate-limited
+// to 1,000 requests per minute per authenticated user.
//
// - The Assistants API supports files up to 2 million tokens and of specific file
// types. See the
@@ -63,11 +63,18 @@ func NewFileService(opts ...option.RequestOption) (r FileService) {
// - The Batch API only supports `.jsonl` files up to 200 MB in size. The input
// also has a specific required
// [format](https://platform.openai.com/docs/api-reference/batch/request-input).
+// - For Retrieval or `file_search` ingestion, upload files here first. If you need
+// to attach multiple uploaded files to the same vector store, use
+// [`/vector_stores/{vector_store_id}/file_batches`](https://platform.openai.com/docs/api-reference/vector-stores-file-batches/createBatch)
+// instead of attaching them one by one. Vector store attachment has separate
+// limits from file upload, including 2,000 attached files per minute per
+// organization.
//
// Please [contact us](https://help.openai.com/) if you need to increase these
// storage limits.
func (r *FileService) New(ctx context.Context, body FileNewParams, opts ...option.RequestOption) (res *FileObject, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "files"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
@@ -75,12 +82,13 @@ func (r *FileService) New(ctx context.Context, body FileNewParams, opts ...optio
// Returns information about a specific file.
func (r *FileService) Get(ctx context.Context, fileID string, opts ...option.RequestOption) (res *FileObject, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if fileID == "" {
err = errors.New("missing required file_id parameter")
return nil, err
}
- path := fmt.Sprintf("files/%s", fileID)
+ path := requestconfig.FormatPath("files/%s", fileID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
@@ -88,7 +96,8 @@ func (r *FileService) Get(ctx context.Context, fileID string, opts ...option.Req
// Returns a list of files.
func (r *FileService) List(ctx context.Context, query FileListParams, opts ...option.RequestOption) (res *pagination.CursorPage[FileObject], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "files"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
@@ -110,25 +119,27 @@ func (r *FileService) ListAutoPaging(ctx context.Context, query FileListParams,
// Delete a file and remove it from all vector stores.
func (r *FileService) Delete(ctx context.Context, fileID string, opts ...option.RequestOption) (res *FileDeleted, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if fileID == "" {
err = errors.New("missing required file_id parameter")
return nil, err
}
- path := fmt.Sprintf("files/%s", fileID)
+ path := requestconfig.FormatPath("files/%s", fileID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
return res, err
}
// Returns the contents of the specified file.
func (r *FileService) Content(ctx context.Context, fileID string, opts ...option.RequestOption) (res *http.Response, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("Accept", "application/binary")}, opts...)
if fileID == "" {
err = errors.New("missing required file_id parameter")
return nil, err
}
- path := fmt.Sprintf("files/%s/content", fileID)
+ path := requestconfig.FormatPath("files/%s/content", fileID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
@@ -160,7 +171,7 @@ type FileObject struct {
// The size of the file, in bytes.
Bytes int64 `json:"bytes" api:"required"`
// The Unix timestamp (in seconds) for when the file was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// The name of the file.
Filename string `json:"filename" api:"required"`
// The object type, which is always `file`.
@@ -180,7 +191,7 @@ type FileObject struct {
// Deprecated: deprecated
Status FileObjectStatus `json:"status" api:"required"`
// The Unix timestamp (in seconds) for when the file will expire.
- ExpiresAt int64 `json:"expires_at"`
+ ExpiresAt int64 `json:"expires_at" format:"unixtime"`
// Deprecated. For details on why a fine-tuning training file failed validation,
// see the `error` field on `fine_tuning.job`.
//
diff --git a/vendor/github.com/openai/openai-go/v3/finetuningalphagrader.go b/vendor/github.com/openai/openai-go/v3/finetuningalphagrader.go
index e09d8db22..07a159905 100644
--- a/vendor/github.com/openai/openai-go/v3/finetuningalphagrader.go
+++ b/vendor/github.com/openai/openai-go/v3/finetuningalphagrader.go
@@ -38,7 +38,8 @@ func NewFineTuningAlphaGraderService(opts ...option.RequestOption) (r FineTuning
// Run a grader.
func (r *FineTuningAlphaGraderService) Run(ctx context.Context, body FineTuningAlphaGraderRunParams, opts ...option.RequestOption) (res *FineTuningAlphaGraderRunResponse, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "fine_tuning/alpha/graders/run"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
@@ -46,7 +47,8 @@ func (r *FineTuningAlphaGraderService) Run(ctx context.Context, body FineTuningA
// Validate a grader.
func (r *FineTuningAlphaGraderService) Validate(ctx context.Context, body FineTuningAlphaGraderValidateParams, opts ...option.RequestOption) (res *FineTuningAlphaGraderValidateResponse, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "fine_tuning/alpha/graders/validate"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
diff --git a/vendor/github.com/openai/openai-go/v3/finetuningcheckpointpermission.go b/vendor/github.com/openai/openai-go/v3/finetuningcheckpointpermission.go
index 44bb8d6e2..b9e88df5a 100644
--- a/vendor/github.com/openai/openai-go/v3/finetuningcheckpointpermission.go
+++ b/vendor/github.com/openai/openai-go/v3/finetuningcheckpointpermission.go
@@ -5,7 +5,6 @@ package openai
import (
"context"
"errors"
- "fmt"
"net/http"
"net/url"
"slices"
@@ -47,13 +46,14 @@ func NewFineTuningCheckpointPermissionService(opts ...option.RequestOption) (r F
// in their organization.
func (r *FineTuningCheckpointPermissionService) New(ctx context.Context, fineTunedModelCheckpoint string, body FineTuningCheckpointPermissionNewParams, opts ...option.RequestOption) (res *pagination.Page[FineTuningCheckpointPermissionNewResponse], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
if fineTunedModelCheckpoint == "" {
err = errors.New("missing required fine_tuned_model_checkpoint parameter")
return nil, err
}
- path := fmt.Sprintf("fine_tuning/checkpoints/%s/permissions", fineTunedModelCheckpoint)
+ path := requestconfig.FormatPath("fine_tuning/checkpoints/%s/permissions", fineTunedModelCheckpoint)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, body, &res, opts...)
if err != nil {
return nil, err
@@ -82,12 +82,13 @@ func (r *FineTuningCheckpointPermissionService) NewAutoPaging(ctx context.Contex
// Deprecated: Retrieve is deprecated. Please swap to the paginated list method
// instead.
func (r *FineTuningCheckpointPermissionService) Get(ctx context.Context, fineTunedModelCheckpoint string, query FineTuningCheckpointPermissionGetParams, opts ...option.RequestOption) (res *FineTuningCheckpointPermissionGetResponse, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if fineTunedModelCheckpoint == "" {
err = errors.New("missing required fine_tuned_model_checkpoint parameter")
return nil, err
}
- path := fmt.Sprintf("fine_tuning/checkpoints/%s/permissions", fineTunedModelCheckpoint)
+ path := requestconfig.FormatPath("fine_tuning/checkpoints/%s/permissions", fineTunedModelCheckpoint)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
return res, err
}
@@ -98,13 +99,14 @@ func (r *FineTuningCheckpointPermissionService) Get(ctx context.Context, fineTun
// fine-tuned model checkpoint.
func (r *FineTuningCheckpointPermissionService) List(ctx context.Context, fineTunedModelCheckpoint string, query FineTuningCheckpointPermissionListParams, opts ...option.RequestOption) (res *pagination.ConversationCursorPage[FineTuningCheckpointPermissionListResponse], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
if fineTunedModelCheckpoint == "" {
err = errors.New("missing required fine_tuned_model_checkpoint parameter")
return nil, err
}
- path := fmt.Sprintf("fine_tuning/checkpoints/%s/permissions", fineTunedModelCheckpoint)
+ path := requestconfig.FormatPath("fine_tuning/checkpoints/%s/permissions", fineTunedModelCheckpoint)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
return nil, err
@@ -130,7 +132,8 @@ func (r *FineTuningCheckpointPermissionService) ListAutoPaging(ctx context.Conte
// Organization owners can use this endpoint to delete a permission for a
// fine-tuned model checkpoint.
func (r *FineTuningCheckpointPermissionService) Delete(ctx context.Context, fineTunedModelCheckpoint string, permissionID string, opts ...option.RequestOption) (res *FineTuningCheckpointPermissionDeleteResponse, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if fineTunedModelCheckpoint == "" {
err = errors.New("missing required fine_tuned_model_checkpoint parameter")
return nil, err
@@ -139,7 +142,7 @@ func (r *FineTuningCheckpointPermissionService) Delete(ctx context.Context, fine
err = errors.New("missing required permission_id parameter")
return nil, err
}
- path := fmt.Sprintf("fine_tuning/checkpoints/%s/permissions/%s", fineTunedModelCheckpoint, permissionID)
+ path := requestconfig.FormatPath("fine_tuning/checkpoints/%s/permissions/%s", fineTunedModelCheckpoint, permissionID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
return res, err
}
@@ -150,7 +153,7 @@ type FineTuningCheckpointPermissionNewResponse struct {
// The permission identifier, which can be referenced in the API endpoints.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) for when the permission was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// The object type, which is always "checkpoint.permission".
Object constant.CheckpointPermission `json:"object" default:"checkpoint.permission"`
// The project identifier that the permission is for.
@@ -202,7 +205,7 @@ type FineTuningCheckpointPermissionGetResponseData struct {
// The permission identifier, which can be referenced in the API endpoints.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) for when the permission was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// The object type, which is always "checkpoint.permission".
Object constant.CheckpointPermission `json:"object" default:"checkpoint.permission"`
// The project identifier that the permission is for.
@@ -230,7 +233,7 @@ type FineTuningCheckpointPermissionListResponse struct {
// The permission identifier, which can be referenced in the API endpoints.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) for when the permission was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// The object type, which is always "checkpoint.permission".
Object constant.CheckpointPermission `json:"object" default:"checkpoint.permission"`
// The project identifier that the permission is for.
diff --git a/vendor/github.com/openai/openai-go/v3/finetuningjob.go b/vendor/github.com/openai/openai-go/v3/finetuningjob.go
index df3fcb0bd..68c3bcd62 100644
--- a/vendor/github.com/openai/openai-go/v3/finetuningjob.go
+++ b/vendor/github.com/openai/openai-go/v3/finetuningjob.go
@@ -6,7 +6,6 @@ import (
"context"
"encoding/json"
"errors"
- "fmt"
"net/http"
"net/url"
"slices"
@@ -54,7 +53,8 @@ func NewFineTuningJobService(opts ...option.RequestOption) (r FineTuningJobServi
//
// [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 = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "fine_tuning/jobs"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
@@ -64,12 +64,13 @@ func (r *FineTuningJobService) New(ctx context.Context, body FineTuningJobNewPar
//
// [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 = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if fineTuningJobID == "" {
err = errors.New("missing required fine_tuning_job_id parameter")
return nil, err
}
- path := fmt.Sprintf("fine_tuning/jobs/%s", fineTuningJobID)
+ path := requestconfig.FormatPath("fine_tuning/jobs/%s", fineTuningJobID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
@@ -77,7 +78,8 @@ func (r *FineTuningJobService) Get(ctx context.Context, fineTuningJobID string,
// List your organization's fine-tuning jobs
func (r *FineTuningJobService) List(ctx context.Context, query FineTuningJobListParams, opts ...option.RequestOption) (res *pagination.CursorPage[FineTuningJob], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "fine_tuning/jobs"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
@@ -99,12 +101,13 @@ func (r *FineTuningJobService) ListAutoPaging(ctx context.Context, query FineTun
// Immediately cancel a fine-tune job.
func (r *FineTuningJobService) Cancel(ctx context.Context, fineTuningJobID string, opts ...option.RequestOption) (res *FineTuningJob, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if fineTuningJobID == "" {
err = errors.New("missing required fine_tuning_job_id parameter")
return nil, err
}
- path := fmt.Sprintf("fine_tuning/jobs/%s/cancel", fineTuningJobID)
+ path := requestconfig.FormatPath("fine_tuning/jobs/%s/cancel", fineTuningJobID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
return res, err
}
@@ -112,13 +115,14 @@ func (r *FineTuningJobService) Cancel(ctx context.Context, fineTuningJobID strin
// Get status updates for a fine-tuning job.
func (r *FineTuningJobService) ListEvents(ctx context.Context, fineTuningJobID string, query FineTuningJobListEventsParams, opts ...option.RequestOption) (res *pagination.CursorPage[FineTuningJobEvent], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
if fineTuningJobID == "" {
err = errors.New("missing required fine_tuning_job_id parameter")
return nil, err
}
- path := fmt.Sprintf("fine_tuning/jobs/%s/events", fineTuningJobID)
+ path := requestconfig.FormatPath("fine_tuning/jobs/%s/events", fineTuningJobID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
return nil, err
@@ -138,24 +142,26 @@ func (r *FineTuningJobService) ListEventsAutoPaging(ctx context.Context, fineTun
// Pause a fine-tune job.
func (r *FineTuningJobService) Pause(ctx context.Context, fineTuningJobID string, opts ...option.RequestOption) (res *FineTuningJob, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if fineTuningJobID == "" {
err = errors.New("missing required fine_tuning_job_id parameter")
return nil, err
}
- path := fmt.Sprintf("fine_tuning/jobs/%s/pause", fineTuningJobID)
+ path := requestconfig.FormatPath("fine_tuning/jobs/%s/pause", fineTuningJobID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
return res, err
}
// Resume a fine-tune job.
func (r *FineTuningJobService) Resume(ctx context.Context, fineTuningJobID string, opts ...option.RequestOption) (res *FineTuningJob, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if fineTuningJobID == "" {
err = errors.New("missing required fine_tuning_job_id parameter")
return nil, err
}
- path := fmt.Sprintf("fine_tuning/jobs/%s/resume", fineTuningJobID)
+ path := requestconfig.FormatPath("fine_tuning/jobs/%s/resume", fineTuningJobID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
return res, err
}
@@ -166,7 +172,7 @@ type FineTuningJob struct {
// The object identifier, which can be referenced in the API endpoints.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) for when the fine-tuning job was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// For fine-tuning jobs that have `failed`, this will contain more information on
// the cause of the failure.
Error FineTuningJobError `json:"error" api:"required"`
@@ -175,7 +181,7 @@ type FineTuningJob struct {
FineTunedModel string `json:"fine_tuned_model" api:"required"`
// The Unix timestamp (in seconds) for when the fine-tuning job was finished. The
// value will be null if the fine-tuning job is still running.
- FinishedAt int64 `json:"finished_at" api:"required"`
+ FinishedAt int64 `json:"finished_at" api:"required" format:"unixtime"`
// The hyperparameters used for the fine-tuning job. This value will only be
// returned when running `supervised` jobs.
Hyperparameters FineTuningJobHyperparameters `json:"hyperparameters" api:"required"`
@@ -209,7 +215,7 @@ type FineTuningJob struct {
ValidationFile string `json:"validation_file" api:"required"`
// The Unix timestamp (in seconds) for when the fine-tuning job is estimated to
// finish. The value will be null if the fine-tuning job is not running.
- EstimatedFinish int64 `json:"estimated_finish" api:"nullable"`
+ EstimatedFinish int64 `json:"estimated_finish" api:"nullable" format:"unixtime"`
// A list of integrations to enable for this fine-tuning job.
Integrations []FineTuningJobWandbIntegrationObject `json:"integrations" api:"nullable"`
// Set of 16 key-value pairs that can be attached to an object. This can be useful
@@ -465,7 +471,7 @@ type FineTuningJobEvent struct {
// The object identifier.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) for when the fine-tuning job was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// The log level of the event.
//
// Any of "info", "warn", "error".
diff --git a/vendor/github.com/openai/openai-go/v3/finetuningjobcheckpoint.go b/vendor/github.com/openai/openai-go/v3/finetuningjobcheckpoint.go
index 4f8e85650..37ee90a1b 100644
--- a/vendor/github.com/openai/openai-go/v3/finetuningjobcheckpoint.go
+++ b/vendor/github.com/openai/openai-go/v3/finetuningjobcheckpoint.go
@@ -5,7 +5,6 @@ package openai
import (
"context"
"errors"
- "fmt"
"net/http"
"net/url"
"slices"
@@ -44,13 +43,14 @@ func NewFineTuningJobCheckpointService(opts ...option.RequestOption) (r FineTuni
// List checkpoints for a fine-tuning job.
func (r *FineTuningJobCheckpointService) List(ctx context.Context, fineTuningJobID string, query FineTuningJobCheckpointListParams, opts ...option.RequestOption) (res *pagination.CursorPage[FineTuningJobCheckpoint], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
if fineTuningJobID == "" {
err = errors.New("missing required fine_tuning_job_id parameter")
return nil, err
}
- path := fmt.Sprintf("fine_tuning/jobs/%s/checkpoints", fineTuningJobID)
+ path := requestconfig.FormatPath("fine_tuning/jobs/%s/checkpoints", fineTuningJobID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
return nil, err
@@ -74,7 +74,7 @@ type FineTuningJobCheckpoint struct {
// The checkpoint identifier, which can be referenced in the API endpoints.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) for when the checkpoint was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// The name of the fine-tuned checkpoint model that is created.
FineTunedModelCheckpoint string `json:"fine_tuned_model_checkpoint" api:"required"`
// The name of the fine-tuning job that this checkpoint was created from.
diff --git a/vendor/github.com/openai/openai-go/v3/gradergradermodel.go b/vendor/github.com/openai/openai-go/v3/gradergradermodel.go
index a86b41ce3..523a9de8b 100644
--- a/vendor/github.com/openai/openai-go/v3/gradergradermodel.go
+++ b/vendor/github.com/openai/openai-go/v3/gradergradermodel.go
@@ -48,6 +48,8 @@ type GraderInputUnion struct {
OfString string `json:",inline"`
Text string `json:"text"`
Type string `json:"type"`
+ // This field is from variant [responses.ResponseInputText].
+ PromptCacheBreakpoint responses.ResponseInputTextPromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
// This field is from variant [GraderInputInputImage].
ImageURL string `json:"image_url"`
// This field is from variant [GraderInputInputImage].
@@ -55,13 +57,14 @@ type GraderInputUnion struct {
// This field is from variant [responses.ResponseInputAudio].
InputAudio responses.ResponseInputAudioInputAudio `json:"input_audio"`
JSON struct {
- OfString respjson.Field
- Text respjson.Field
- Type respjson.Field
- ImageURL respjson.Field
- Detail respjson.Field
- InputAudio respjson.Field
- raw string
+ OfString respjson.Field
+ Text respjson.Field
+ Type respjson.Field
+ PromptCacheBreakpoint respjson.Field
+ ImageURL respjson.Field
+ Detail respjson.Field
+ InputAudio respjson.Field
+ raw string
} `json:"-"`
}
@@ -121,7 +124,7 @@ func (r *GraderInputOutputText) UnmarshalJSON(data []byte) error {
// An image input block used within EvalItem content arrays.
type GraderInputInputImage struct {
// The URL of the image input.
- ImageURL string `json:"image_url" api:"required"`
+ ImageURL string `json:"image_url" api:"required" format:"uri"`
// The type of the image input. 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`, or
@@ -183,6 +186,14 @@ func (u *GraderInputUnionParam) asAny() any {
return nil
}
+// Returns a pointer to the underlying variant's property, if present.
+func (u GraderInputUnionParam) GetPromptCacheBreakpoint() *responses.ResponseInputTextPromptCacheBreakpointParam {
+ if vt := u.OfInputText; vt != nil {
+ return &vt.PromptCacheBreakpoint
+ }
+ return nil
+}
+
// Returns a pointer to the underlying variant's property, if present.
func (u GraderInputUnionParam) GetImageURL() *string {
if vt := u.OfInputImage; vt != nil {
@@ -257,7 +268,7 @@ func (r *GraderInputOutputTextParam) UnmarshalJSON(data []byte) error {
// The properties ImageURL, Type are required.
type GraderInputInputImageParam struct {
// The URL of the image input.
- ImageURL string `json:"image_url" api:"required"`
+ ImageURL string `json:"image_url" api:"required" format:"uri"`
// The detail level of the image to be sent to the model. One of `high`, `low`, or
// `auto`. Defaults to `auto`.
Detail param.Opt[string] `json:"detail,omitzero"`
@@ -370,6 +381,8 @@ type LabelModelGraderInputContentUnion struct {
OfAnArrayOfInputTextOutputTextInputImageAndInputAudio GraderInputs `json:",inline"`
Text string `json:"text"`
Type string `json:"type"`
+ // This field is from variant [responses.ResponseInputText].
+ PromptCacheBreakpoint responses.ResponseInputTextPromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
// This field is from variant [LabelModelGraderInputContentInputImage].
ImageURL string `json:"image_url"`
// This field is from variant [LabelModelGraderInputContentInputImage].
@@ -381,6 +394,7 @@ type LabelModelGraderInputContentUnion struct {
OfAnArrayOfInputTextOutputTextInputImageAndInputAudio respjson.Field
Text respjson.Field
Type respjson.Field
+ PromptCacheBreakpoint respjson.Field
ImageURL respjson.Field
Detail respjson.Field
InputAudio respjson.Field
@@ -449,7 +463,7 @@ func (r *LabelModelGraderInputContentOutputText) UnmarshalJSON(data []byte) erro
// An image input block used within EvalItem content arrays.
type LabelModelGraderInputContentInputImage struct {
// The URL of the image input.
- ImageURL string `json:"image_url" api:"required"`
+ ImageURL string `json:"image_url" api:"required" format:"uri"`
// The type of the image input. 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`, or
@@ -582,6 +596,14 @@ func (u *LabelModelGraderInputContentUnionParam) asAny() any {
return nil
}
+// Returns a pointer to the underlying variant's property, if present.
+func (u LabelModelGraderInputContentUnionParam) GetPromptCacheBreakpoint() *responses.ResponseInputTextPromptCacheBreakpointParam {
+ if vt := u.OfInputText; vt != nil {
+ return &vt.PromptCacheBreakpoint
+ }
+ return nil
+}
+
// Returns a pointer to the underlying variant's property, if present.
func (u LabelModelGraderInputContentUnionParam) GetImageURL() *string {
if vt := u.OfInputImage; vt != nil {
@@ -656,7 +678,7 @@ func (r *LabelModelGraderInputContentOutputTextParam) UnmarshalJSON(data []byte)
// The properties ImageURL, Type are required.
type LabelModelGraderInputContentInputImageParam struct {
// The URL of the image input.
- ImageURL string `json:"image_url" api:"required"`
+ ImageURL string `json:"image_url" api:"required" format:"uri"`
// The detail level of the image to be sent to the model. One of `high`, `low`, or
// `auto`. Defaults to `auto`.
Detail param.Opt[string] `json:"detail,omitzero"`
@@ -1191,6 +1213,8 @@ type ScoreModelGraderInputContentUnion struct {
OfAnArrayOfInputTextOutputTextInputImageAndInputAudio GraderInputs `json:",inline"`
Text string `json:"text"`
Type string `json:"type"`
+ // This field is from variant [responses.ResponseInputText].
+ PromptCacheBreakpoint responses.ResponseInputTextPromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
// This field is from variant [ScoreModelGraderInputContentInputImage].
ImageURL string `json:"image_url"`
// This field is from variant [ScoreModelGraderInputContentInputImage].
@@ -1202,6 +1226,7 @@ type ScoreModelGraderInputContentUnion struct {
OfAnArrayOfInputTextOutputTextInputImageAndInputAudio respjson.Field
Text respjson.Field
Type respjson.Field
+ PromptCacheBreakpoint respjson.Field
ImageURL respjson.Field
Detail respjson.Field
InputAudio respjson.Field
@@ -1270,7 +1295,7 @@ func (r *ScoreModelGraderInputContentOutputText) UnmarshalJSON(data []byte) erro
// An image input block used within EvalItem content arrays.
type ScoreModelGraderInputContentInputImage struct {
// The URL of the image input.
- ImageURL string `json:"image_url" api:"required"`
+ ImageURL string `json:"image_url" api:"required" format:"uri"`
// The type of the image input. 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`, or
@@ -1296,21 +1321,14 @@ func (r *ScoreModelGraderInputContentInputImage) UnmarshalJSON(data []byte) erro
type ScoreModelGraderSamplingParams struct {
// The maximum number of tokens the grader model may generate in its response.
MaxCompletionsTokens int64 `json:"max_completions_tokens" api:"nullable"`
- // Constrains effort on reasoning for
- // [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
- // supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`.
- // Reducing reasoning effort can result in faster responses and fewer tokens used
- // on reasoning in a response.
- //
- // - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
- // reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
- // calls are supported for all reasoning values in gpt-5.1.
- // - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
- // support `none`.
- // - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
- // - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
+ // 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".
+ // Any of "none", "minimal", "low", "medium", "high", "xhigh", "max".
ReasoningEffort shared.ReasoningEffort `json:"reasoning_effort" api:"nullable"`
// A seed value to initialize the randomness, during sampling.
Seed int64 `json:"seed" api:"nullable"`
@@ -1448,6 +1466,14 @@ func (u *ScoreModelGraderInputContentUnionParam) asAny() any {
return nil
}
+// Returns a pointer to the underlying variant's property, if present.
+func (u ScoreModelGraderInputContentUnionParam) GetPromptCacheBreakpoint() *responses.ResponseInputTextPromptCacheBreakpointParam {
+ if vt := u.OfInputText; vt != nil {
+ return &vt.PromptCacheBreakpoint
+ }
+ return nil
+}
+
// Returns a pointer to the underlying variant's property, if present.
func (u ScoreModelGraderInputContentUnionParam) GetImageURL() *string {
if vt := u.OfInputImage; vt != nil {
@@ -1522,7 +1548,7 @@ func (r *ScoreModelGraderInputContentOutputTextParam) UnmarshalJSON(data []byte)
// The properties ImageURL, Type are required.
type ScoreModelGraderInputContentInputImageParam struct {
// The URL of the image input.
- ImageURL string `json:"image_url" api:"required"`
+ ImageURL string `json:"image_url" api:"required" format:"uri"`
// The detail level of the image to be sent to the model. One of `high`, `low`, or
// `auto`. Defaults to `auto`.
Detail param.Opt[string] `json:"detail,omitzero"`
@@ -1551,21 +1577,14 @@ type ScoreModelGraderSamplingParamsParam struct {
Temperature param.Opt[float64] `json:"temperature,omitzero"`
// An alternative to temperature for nucleus sampling; 1.0 includes all tokens.
TopP param.Opt[float64] `json:"top_p,omitzero"`
- // Constrains effort on reasoning for
- // [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
- // supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`.
- // Reducing reasoning effort can result in faster responses and fewer tokens used
- // on reasoning in a response.
- //
- // - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
- // reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
- // calls are supported for all reasoning values in gpt-5.1.
- // - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
- // support `none`.
- // - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
- // - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
+ // 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".
+ // Any of "none", "minimal", "low", "medium", "high", "xhigh", "max".
ReasoningEffort shared.ReasoningEffort `json:"reasoning_effort,omitzero"`
paramObj
}
diff --git a/vendor/github.com/openai/openai-go/v3/image.go b/vendor/github.com/openai/openai-go/v3/image.go
index ec0ae828e..4c2f2d04c 100644
--- a/vendor/github.com/openai/openai-go/v3/image.go
+++ b/vendor/github.com/openai/openai-go/v3/image.go
@@ -44,7 +44,8 @@ func NewImageService(opts ...option.RequestOption) (r ImageService) {
// Creates a variation of a given image. This endpoint only supports `dall-e-2`.
func (r *ImageService) NewVariation(ctx context.Context, body ImageNewVariationParams, opts ...option.RequestOption) (res *ImagesResponse, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "images/variations"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
@@ -54,7 +55,8 @@ func (r *ImageService) NewVariation(ctx context.Context, body ImageNewVariationP
// prompt. This endpoint supports GPT Image models (`gpt-image-1.5`, `gpt-image-1`,
// `gpt-image-1-mini`, and `chatgpt-image-latest`) and `dall-e-2`.
func (r *ImageService) Edit(ctx context.Context, body ImageEditParams, opts ...option.RequestOption) (res *ImagesResponse, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "images/edits"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
@@ -68,7 +70,8 @@ func (r *ImageService) EditStreaming(ctx context.Context, body ImageEditParams,
raw *http.Response
err error
)
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
body.SetExtraFields(map[string]any{
"stream": "true",
})
@@ -80,7 +83,8 @@ func (r *ImageService) EditStreaming(ctx context.Context, body ImageEditParams,
// Creates an image given a prompt.
// [Learn more](https://platform.openai.com/docs/guides/images).
func (r *ImageService) Generate(ctx context.Context, body ImageGenerateParams, opts ...option.RequestOption) (res *ImagesResponse, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "images/generations"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
@@ -93,7 +97,8 @@ func (r *ImageService) GenerateStreaming(ctx context.Context, body ImageGenerate
raw *http.Response
err error
)
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append(opts, option.WithJSONSet("stream", true))
path := "images/generations"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &raw, opts...)
@@ -111,7 +116,7 @@ type Image struct {
// When using `dall-e-2` or `dall-e-3`, the URL of the generated image if
// `response_format` is set to `url` (default value). Unsupported for the GPT image
// models.
- URL string `json:"url"`
+ URL string `json:"url" format:"uri"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
B64JSON respjson.Field
@@ -137,7 +142,7 @@ type ImageEditCompletedEvent struct {
// Any of "transparent", "opaque", "auto".
Background ImageEditCompletedEventBackground `json:"background" api:"required"`
// The Unix timestamp when the event was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// The output format for the edited image.
//
// Any of "png", "webp", "jpeg".
@@ -272,7 +277,7 @@ type ImageEditPartialImageEvent struct {
// Any of "transparent", "opaque", "auto".
Background ImageEditPartialImageEventBackground `json:"background" api:"required"`
// The Unix timestamp when the event was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// The output format for the requested edited image.
//
// Any of "png", "webp", "jpeg".
@@ -435,7 +440,7 @@ type ImageGenCompletedEvent struct {
// Any of "transparent", "opaque", "auto".
Background ImageGenCompletedEventBackground `json:"background" api:"required"`
// The Unix timestamp when the event was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// The output format for the generated image.
//
// Any of "png", "webp", "jpeg".
@@ -570,7 +575,7 @@ type ImageGenPartialImageEvent struct {
// Any of "transparent", "opaque", "auto".
Background ImageGenPartialImageEventBackground `json:"background" api:"required"`
// The Unix timestamp when the event was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// The output format for the requested image.
//
// Any of "png", "webp", "jpeg".
@@ -727,17 +732,20 @@ func (r *ImageGenStreamEventUnion) UnmarshalJSON(data []byte) error {
type ImageModel = string
const (
- ImageModelGPTImage1_5 ImageModel = "gpt-image-1.5"
- ImageModelDallE2 ImageModel = "dall-e-2"
- ImageModelDallE3 ImageModel = "dall-e-3"
- ImageModelGPTImage1 ImageModel = "gpt-image-1"
- ImageModelGPTImage1Mini ImageModel = "gpt-image-1-mini"
+ ImageModelGPTImage1 ImageModel = "gpt-image-1"
+ ImageModelGPTImage1Mini ImageModel = "gpt-image-1-mini"
+ ImageModelGPTImage2 ImageModel = "gpt-image-2"
+ ImageModelGPTImage2_2026_04_21 ImageModel = "gpt-image-2-2026-04-21"
+ ImageModelGPTImage1_5 ImageModel = "gpt-image-1.5"
+ ImageModelChatgptImageLatest ImageModel = "chatgpt-image-latest"
+ ImageModelDallE2 ImageModel = "dall-e-2"
+ ImageModelDallE3 ImageModel = "dall-e-3"
)
// The response from the image generation endpoint.
type ImagesResponse struct {
// The Unix timestamp (in seconds) of when the image was created.
- Created int64 `json:"created" api:"required"`
+ Created int64 `json:"created" api:"required" format:"unixtime"`
// The background parameter used for the image generation. Either `transparent` or
// `opaque`.
//
@@ -957,10 +965,10 @@ const (
type ImageEditParams struct {
// The image(s) to edit. Must be a supported image file or an array of images.
//
- // For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, and
- // `gpt-image-1.5`), each image should be a `png`, `webp`, or `jpg` file less than
- // 50MB. You can provide up to 16 images. `chatgpt-image-latest` follows the same
- // input constraints as GPT image models.
+ // For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`,
+ // `gpt-image-2`, `gpt-image-2-2026-04-21`, and `chatgpt-image-latest`), each image
+ // should be a `png`, `webp`, or `jpg` file less than 50MB. You can provide up to
+ // 16 images.
//
// For `dall-e-2`, you can only provide one image, and it should be a square `png`
// file less than 4MB.
@@ -986,9 +994,14 @@ type ImageEditParams struct {
// [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
User param.Opt[string] `json:"user,omitzero"`
// Allows to set transparency for the background of the generated image(s). This
- // parameter is only supported for the GPT image models. 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.
+ // 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`.
@@ -1002,7 +1015,10 @@ type ImageEditParams struct {
//
// Any of "high", "low".
InputFidelity ImageEditParamsInputFidelity `json:"input_fidelity,omitzero"`
- // The model to use for image generation. Defaults to `gpt-image-1.5`.
+ // The model to use for image generation. One of `dall-e-2` or a GPT image model
+ // (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`,
+ // `gpt-image-2-2026-04-21`, or `chatgpt-image-latest`). Defaults to
+ // `gpt-image-1.5`.
Model ImageModel `json:"model,omitzero"`
// The format in which the generated images are returned. This parameter is only
// supported for the GPT image models. Must be one of `png`, `jpeg`, or `webp`. The
@@ -1022,11 +1038,17 @@ type ImageEditParams struct {
//
// Any of "url", "b64_json".
ResponseFormat ImageEditParamsResponseFormat `json:"response_format,omitzero"`
- // The size of the generated images. Must be one of `1024x1024`, `1536x1024`
- // (landscape), `1024x1536` (portrait), or `auto` (default value) for the GPT image
- // models, and one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`.
- //
- // Any of "256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto".
+ // 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 ImageEditParamsSize `json:"size,omitzero"`
// An additional image whose fully transparent areas (e.g. where alpha is zero)
// indicate where `image` should be edited. If there are multiple images provided,
@@ -1080,9 +1102,14 @@ func (u *ImageEditParamsImageUnion) asAny() any {
}
// Allows to set transparency for the background of the generated image(s). This
-// parameter is only supported for the GPT image models. 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.
+// 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`.
@@ -1139,9 +1166,17 @@ const (
ImageEditParamsResponseFormatB64JSON ImageEditParamsResponseFormat = "b64_json"
)
-// The size of the generated images. Must be one of `1024x1024`, `1536x1024`
-// (landscape), `1024x1536` (portrait), or `auto` (default value) for the GPT image
-// models, and one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`.
+// 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`.
type ImageEditParamsSize string
const (
@@ -1177,9 +1212,14 @@ type ImageGenerateParams struct {
// [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
User param.Opt[string] `json:"user,omitzero"`
// Allows to set transparency for the background of the generated image(s). This
- // parameter is only supported for the GPT image models. 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.
+ // 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`.
@@ -1187,8 +1227,9 @@ type ImageGenerateParams struct {
// Any of "transparent", "opaque", "auto".
Background ImageGenerateParamsBackground `json:"background,omitzero"`
// The model to use for image generation. One of `dall-e-2`, `dall-e-3`, or a GPT
- // image model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`). Defaults to
- // `dall-e-2` unless a parameter specific to the GPT image models is used.
+ // image model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`,
+ // or `gpt-image-2-2026-04-21`). Defaults to `dall-e-2` unless a parameter specific
+ // to the GPT image models is used.
Model ImageModel `json:"model,omitzero"`
// Control the content-moderation level for images generated by the GPT image
// models. Must be either `low` for less restrictive filtering or `auto` (default
@@ -1218,13 +1259,17 @@ type ImageGenerateParams struct {
//
// Any of "url", "b64_json".
ResponseFormat ImageGenerateParamsResponseFormat `json:"response_format,omitzero"`
- // The size of the generated images. Must be one of `1024x1024`, `1536x1024`
- // (landscape), `1024x1536` (portrait), or `auto` (default value) for the GPT image
- // models, one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`, and one of
- // `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3`.
- //
- // Any of "auto", "1024x1024", "1536x1024", "1024x1536", "256x256", "512x512",
- // "1792x1024", "1024x1792".
+ // 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 ImageGenerateParamsSize `json:"size,omitzero"`
// The style of the generated images. This parameter is only supported for
// `dall-e-3`. Must be one of `vivid` or `natural`. Vivid causes the model to lean
@@ -1245,9 +1290,14 @@ func (r *ImageGenerateParams) UnmarshalJSON(data []byte) error {
}
// Allows to set transparency for the background of the generated image(s). This
-// parameter is only supported for the GPT image models. 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.
+// 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`.
@@ -1308,10 +1358,17 @@ const (
ImageGenerateParamsResponseFormatB64JSON ImageGenerateParamsResponseFormat = "b64_json"
)
-// The size of the generated images. Must be one of `1024x1024`, `1536x1024`
-// (landscape), `1024x1536` (portrait), or `auto` (default value) for the GPT image
-// models, one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`, and one of
-// `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3`.
+// 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`.
type ImageGenerateParamsSize string
const (
diff --git a/vendor/github.com/openai/openai-go/v3/internal/apiform/encoder.go b/vendor/github.com/openai/openai-go/v3/internal/apiform/encoder.go
index 0a5bfc8e8..6cf398eaa 100644
--- a/vendor/github.com/openai/openai-go/v3/internal/apiform/encoder.go
+++ b/vendor/github.com/openai/openai-go/v3/internal/apiform/encoder.go
@@ -58,7 +58,7 @@ type encoderField struct {
}
type encoderEntry struct {
- reflect.Type
+ typ reflect.Type
dateFormat string
arrayFmt string
root bool
@@ -76,7 +76,7 @@ func (e *encoder) marshal(value any, writer *multipart.Writer) error {
func (e *encoder) typeEncoder(t reflect.Type) encoderFunc {
entry := encoderEntry{
- Type: t,
+ typ: t,
dateFormat: e.dateFormat,
arrayFmt: e.arrayFmt,
root: e.root,
diff --git a/vendor/github.com/openai/openai-go/v3/internal/apijson/decoder.go b/vendor/github.com/openai/openai-go/v3/internal/apijson/decoder.go
index 5da1f0a1b..055637318 100644
--- a/vendor/github.com/openai/openai-go/v3/internal/apijson/decoder.go
+++ b/vendor/github.com/openai/openai-go/v3/internal/apijson/decoder.go
@@ -80,7 +80,7 @@ type decoderField struct {
}
type decoderEntry struct {
- reflect.Type
+ typ reflect.Type
dateFormat string
root bool
}
@@ -108,7 +108,7 @@ func (d *decoderBuilder) unmarshalWithExactness(raw []byte, to any) (exactness,
func (d *decoderBuilder) typeDecoder(t reflect.Type) decoderFunc {
entry := decoderEntry{
- Type: t,
+ typ: t,
dateFormat: d.dateFormat,
root: d.root,
}
diff --git a/vendor/github.com/openai/openai-go/v3/internal/apijson/encoder.go b/vendor/github.com/openai/openai-go/v3/internal/apijson/encoder.go
index 9b7e8ee85..7c1c77341 100644
--- a/vendor/github.com/openai/openai-go/v3/internal/apijson/encoder.go
+++ b/vendor/github.com/openai/openai-go/v3/internal/apijson/encoder.go
@@ -46,7 +46,7 @@ type encoderField struct {
}
type encoderEntry struct {
- reflect.Type
+ typ reflect.Type
dateFormat string
root bool
}
@@ -63,7 +63,7 @@ func (e *encoder) marshal(value any) ([]byte, error) {
func (e *encoder) typeEncoder(t reflect.Type) encoderFunc {
entry := encoderEntry{
- Type: t,
+ typ: t,
dateFormat: e.dateFormat,
root: e.root,
}
diff --git a/vendor/github.com/openai/openai-go/v3/internal/apiquery/encoder.go b/vendor/github.com/openai/openai-go/v3/internal/apiquery/encoder.go
index 75c408a1b..1c7a6e488 100644
--- a/vendor/github.com/openai/openai-go/v3/internal/apiquery/encoder.go
+++ b/vendor/github.com/openai/openai-go/v3/internal/apiquery/encoder.go
@@ -29,7 +29,7 @@ type encoderField struct {
}
type encoderEntry struct {
- reflect.Type
+ typ reflect.Type
dateFormat string
root bool
settings QuerySettings
@@ -42,7 +42,7 @@ type Pair struct {
func (e *encoder) typeEncoder(t reflect.Type) encoderFunc {
entry := encoderEntry{
- Type: t,
+ typ: t,
dateFormat: e.dateFormat,
root: e.root,
settings: e.settings,
diff --git a/vendor/github.com/openai/openai-go/v3/internal/encoding/json/encode.go b/vendor/github.com/openai/openai-go/v3/internal/encoding/json/encode.go
index acd343ba6..d91200ce9 100644
--- a/vendor/github.com/openai/openai-go/v3/internal/encoding/json/encode.go
+++ b/vendor/github.com/openai/openai-go/v3/internal/encoding/json/encode.go
@@ -174,15 +174,21 @@ import (
// JSON cannot represent cyclic data structures and Marshal does not
// handle them. Passing cyclic structures to Marshal will result in
// an error.
-func Marshal(v any) ([]byte, error) {
+// EDIT(begin): add optimization options
+func Marshal(v any, opts ...Option) ([]byte, error) {
+ // EDIT(end): add optimization options
e := newEncodeState()
defer encodeStatePool.Put(e)
- // SHIM(begin): don't escape HTML by default
- err := e.marshal(v, encOpts{escapeHTML: shims.EscapeHTMLByDefault})
+ // EDIT(begin): don't escape HTML by default, and apply options
+ encOpts := encOpts{escapeHTML: shims.EscapeHTMLByDefault}
+ if opts != nil {
+ encOpts = encOpts.apply(opts...)
+ }
+ err := e.marshal(v, encOpts)
// ORIGINAL:
// err := e.marshal(v, encOpts{escapeHTML: true})
- // SHIM(end)
+ // EDIT(end)
if err != nil {
return nil, err
}
@@ -353,6 +359,9 @@ type encOpts struct {
// EDIT(begin): save the timefmt
timefmt string
// EDIT(end)
+ // EDIT(begin): add optimization to skip compaction
+ skipCompaction bool
+ // EDIT(end)
}
type encoderFunc func(e *encodeState, v reflect.Value, opts encOpts)
@@ -484,7 +493,7 @@ func marshalerEncoder(e *encodeState, v reflect.Value, opts encOpts) {
if err == nil {
e.Grow(len(b))
out := e.AvailableBuffer()
- out, err = appendCompact(out, b, opts.escapeHTML)
+ out, err = appendCompact(out, b, opts)
e.Buffer.Write(out)
}
if err != nil {
@@ -510,7 +519,7 @@ func addrMarshalerEncoder(e *encodeState, v reflect.Value, opts encOpts) {
if err == nil {
e.Grow(len(b))
out := e.AvailableBuffer()
- out, err = appendCompact(out, b, opts.escapeHTML)
+ out, err = appendCompact(out, b, opts)
e.Buffer.Write(out)
}
if err != nil {
diff --git a/vendor/github.com/openai/openai-go/v3/internal/encoding/json/indent.go b/vendor/github.com/openai/openai-go/v3/internal/encoding/json/indent.go
index 01bfdf65e..c9d6ca5b1 100644
--- a/vendor/github.com/openai/openai-go/v3/internal/encoding/json/indent.go
+++ b/vendor/github.com/openai/openai-go/v3/internal/encoding/json/indent.go
@@ -4,7 +4,9 @@
package json
-import "bytes"
+import (
+ "bytes"
+)
// HTMLEscape appends to dst the JSON-encoded src with <, >, &, U+2028 and U+2029
// characters inside string literals changed to \u003c, \u003e, \u0026, \u2028, \u2029
@@ -41,12 +43,21 @@ func appendHTMLEscape(dst, src []byte) []byte {
func Compact(dst *bytes.Buffer, src []byte) error {
dst.Grow(len(src))
b := dst.AvailableBuffer()
- b, err := appendCompact(b, src, false)
+ b, err := appendCompact(b, src, encOpts{})
dst.Write(b)
return err
}
-func appendCompact(dst, src []byte, escape bool) ([]byte, error) {
+func appendCompact(dst, src []byte, opts encOpts) ([]byte, error) {
+ // EDIT(begin): optimize for skipCompaction
+ if opts.skipCompaction {
+ dst = append(dst, src...)
+ return dst, nil
+ }
+
+ escape := opts.escapeHTML
+ // EDIT(end)
+
origLen := len(dst)
scan := newScanner()
defer freeScanner(scan)
diff --git a/vendor/github.com/openai/openai-go/v3/internal/encoding/json/opt.go b/vendor/github.com/openai/openai-go/v3/internal/encoding/json/opt.go
new file mode 100644
index 000000000..fd6f8d2fe
--- /dev/null
+++ b/vendor/github.com/openai/openai-go/v3/internal/encoding/json/opt.go
@@ -0,0 +1,24 @@
+// EDIT(begin): add custom options for JSON encoding
+package json
+
+type Option func(*encOpts)
+
+// Every time a sub-type of [json.Marshaler] is encountered,
+// skip a redundant and costly compaction step, trust it to self-compact.
+//
+// This is a divergence from the standard library behavior, and is only guaranteed
+// safe with SDK types.
+func WithSkipCompaction(b bool) Option {
+ return func(eos *encOpts) {
+ eos.skipCompaction = true
+ }
+}
+
+func (eos encOpts) apply(opts ...Option) encOpts {
+ for _, opt := range opts {
+ opt(&eos)
+ }
+ return eos
+}
+
+// EDIT(end)
diff --git a/vendor/github.com/openai/openai-go/v3/internal/encoding/json/stream.go b/vendor/github.com/openai/openai-go/v3/internal/encoding/json/stream.go
index e2d9470bc..652522c3a 100644
--- a/vendor/github.com/openai/openai-go/v3/internal/encoding/json/stream.go
+++ b/vendor/github.com/openai/openai-go/v3/internal/encoding/json/stream.go
@@ -6,7 +6,6 @@ package json
import (
"bytes"
- "errors"
"io"
)
@@ -253,30 +252,34 @@ func (enc *Encoder) SetEscapeHTML(on bool) {
enc.escapeHTML = on
}
-// RawMessage is a raw encoded JSON value.
-// It implements [Marshaler] and [Unmarshaler] and can
-// be used to delay JSON decoding or precompute a JSON encoding.
-type RawMessage []byte
-
-// MarshalJSON returns m as the JSON encoding of m.
-func (m RawMessage) MarshalJSON() ([]byte, error) {
- if m == nil {
- return []byte("null"), nil
- }
- return m, nil
-}
-
-// UnmarshalJSON sets *m to a copy of data.
-func (m *RawMessage) UnmarshalJSON(data []byte) error {
- if m == nil {
- return errors.New("json.RawMessage: UnmarshalJSON on nil pointer")
- }
- *m = append((*m)[0:0], data...)
- return nil
-}
-
-var _ Marshaler = (*RawMessage)(nil)
-var _ Unmarshaler = (*RawMessage)(nil)
+// EDIT(begin): remove RawMessage
+//
+// // RawMessage is a raw encoded JSON value.
+// // It implements [Marshaler] and [Unmarshaler] and can
+// // be used to delay JSON decoding or precompute a JSON encoding.
+// type RawMessage []byte
+//
+// // MarshalJSON returns m as the JSON encoding of m.
+// func (m RawMessage) MarshalJSON() ([]byte, error) {
+// if m == nil {
+// return []byte("null"), nil
+// }
+// return m, nil
+// }
+//
+// // UnmarshalJSON sets *m to a copy of data.
+// func (m *RawMessage) UnmarshalJSON(data []byte) error {
+// if m == nil {
+// return errors.New("json.RawMessage: UnmarshalJSON on nil pointer")
+// }
+// *m = append((*m)[0:0], data...)
+// return nil
+// }
+//
+// var _ Marshaler = (*RawMessage)(nil)
+// var _ Unmarshaler = (*RawMessage)(nil)
+//
+// EDIT(end)
// A Token holds a value of one of these types:
//
diff --git a/vendor/github.com/openai/openai-go/v3/internal/encoding/json/time.go b/vendor/github.com/openai/openai-go/v3/internal/encoding/json/time.go
index d4548e431..e236d6765 100644
--- a/vendor/github.com/openai/openai-go/v3/internal/encoding/json/time.go
+++ b/vendor/github.com/openai/openai-go/v3/internal/encoding/json/time.go
@@ -50,7 +50,7 @@ func timeMarshalEncoder(e *encodeState, v reflect.Value, opts encOpts) bool {
if b != nil {
e.Grow(len(b))
out := e.AvailableBuffer()
- out, _ = appendCompact(out, b, opts.escapeHTML)
+ out, _ = appendCompact(out, b, opts)
e.Buffer.Write(out)
return true
}
diff --git a/vendor/github.com/openai/openai-go/v3/internal/requestconfig/requestconfig.go b/vendor/github.com/openai/openai-go/v3/internal/requestconfig/requestconfig.go
index 153cbab65..3b8a67e87 100644
--- a/vendor/github.com/openai/openai-go/v3/internal/requestconfig/requestconfig.go
+++ b/vendor/github.com/openai/openai-go/v3/internal/requestconfig/requestconfig.go
@@ -6,6 +6,7 @@ import (
"bytes"
"context"
"encoding/json"
+ "errors"
"fmt"
"io"
"math"
@@ -16,6 +17,7 @@ import (
"runtime"
"strconv"
"strings"
+ "sync"
"time"
"github.com/openai/openai-go/v3/internal"
@@ -31,6 +33,25 @@ func getDefaultHeaders() map[string]string {
}
}
+func encodePathParam(value string) string {
+ switch value {
+ case ".":
+ return "%2E"
+ case "..":
+ return "%2E%2E"
+ }
+ return url.PathEscape(value)
+}
+
+// FormatPath escapes path parameters and inserts them into a request path.
+func FormatPath(format string, params ...string) string {
+ args := make([]any, len(params))
+ for i, param := range params {
+ args[i] = encodePathParam(param)
+ }
+ return fmt.Sprintf(format, args...)
+}
+
func getNormalizedOS() string {
switch runtime.GOOS {
case "ios":
@@ -85,6 +106,78 @@ type RequestOption interface {
type RequestOptionFunc func(*RequestConfig) error
type PreRequestOptionFunc func(*RequestConfig) error
+// requestFinalizer is an internal extension point for provider integrations
+// that must inspect the fully configured request and install middleware after
+// all client- and method-level options have been applied.
+type requestFinalizer func(*RequestConfig) error
+
+type requestFinalizerOption struct {
+ finalize func(*RequestConfig) error
+}
+
+// noRetryError marks deterministic request setup or policy failures that
+// cannot be fixed by replaying the same request. It deliberately remains an
+// internal implementation detail so public error strings and wrapping stay
+// unchanged.
+type noRetryError struct {
+ err error
+}
+
+func (e *noRetryError) Error() string { return e.err.Error() }
+func (e *noRetryError) Unwrap() error { return e.err }
+func (e *noRetryError) noRetry() {}
+
+// WithNoRetryError marks err as deterministic for the generic request retry
+// loop while preserving its message and unwrap chain. This function is
+// internal API and may change without notice.
+func WithNoRetryError(err error) error {
+ if err == nil {
+ return nil
+ }
+ return &noRetryError{err: err}
+}
+
+func (o requestFinalizerOption) Apply(cfg *RequestConfig) error {
+ cfg.finalizers = append(cfg.finalizers, o.finalize)
+ return nil
+}
+
+// WithRequestFinalizer registers an internal provider finalizer. Finalizers run
+// after every RequestOption has been applied and before request security is
+// selected. This keeps provider authentication closest to the wire, including
+// when callers add method-level middleware.
+//
+// This function is internal API and may change without notice.
+func WithRequestFinalizer(finalize func(*RequestConfig) error) RequestOption {
+ return requestFinalizerOption{finalize: finalize}
+}
+
+type environmentDefaultsDisabledOption struct{}
+
+func (environmentDefaultsDisabledOption) Apply(*RequestConfig) error {
+ return nil
+}
+
+// WithEnvironmentDefaultsDisabled marks a provider-owned client that must not
+// inherit ambient OPENAI_* configuration. The regular transport defaults still
+// apply.
+//
+// This function is internal API and may change without notice.
+func WithEnvironmentDefaultsDisabled() RequestOption {
+ return environmentDefaultsDisabledOption{}
+}
+
+// EnvironmentDefaultsDisabled reports whether opts contains the internal
+// provider marker returned by WithEnvironmentDefaultsDisabled.
+func EnvironmentDefaultsDisabled(opts ...RequestOption) bool {
+ for _, opt := range opts {
+ if _, ok := opt.(environmentDefaultsDisabledOption); ok {
+ return true
+ }
+ }
+ return false
+}
+
func (s RequestOptionFunc) Apply(r *RequestConfig) error { return s(r) }
func (s PreRequestOptionFunc) Apply(r *RequestConfig) error { return s(r) }
@@ -178,11 +271,26 @@ func NewRequestConfig(ctx context.Context, method string, u string, body any, ds
Body: reader,
}
cfg.ResponseBodyInto = dst
+ cfg.Security = Security{
+ BearerAuth: true,
+ AdminAPIKeyAuth: true,
+ }
err = cfg.Apply(opts...)
if err != nil {
return nil, err
}
+ // Provider finalizers intentionally run after every regular option so they
+ // can sign the final URL, headers, and serialized body on each attempt.
+ for _, finalizer := range cfg.finalizers {
+ if err := finalizer(&cfg); err != nil {
+ return nil, err
+ }
+ }
+
+ // This must run after `cfg.Apply(...)` above so we know which specific security scheme to add
+ ApplySecurity(cfg)
+
// This must run after `cfg.Apply(...)` above in case the request timeout gets modified. We also only
// apply our own logic for it if it's still "0" from above. If it's not, then it was deleted or modified
// by the user and we should respect that.
@@ -215,14 +323,20 @@ type RequestConfig struct {
BaseURL *url.URL
// DefaultBaseURL will be used if BaseURL is not explicitly overridden using
// WithBaseURL.
- DefaultBaseURL *url.URL
- CustomHTTPDoer HTTPDoer
- HTTPClient *http.Client
- Middlewares []middleware
- APIKey string
- Organization string
- Project string
- WebhookSecret string
+ DefaultBaseURL *url.URL
+ CustomHTTPDoer HTTPDoer
+ HTTPClient *http.Client
+ Middlewares []middleware
+ APIKey string
+ AdminAPIKey string
+ Organization string
+ Project string
+ WebhookSecret string
+ finalizers []requestFinalizer
+ authHeaderOverride bool
+ authPreference authCredentialPreference
+ // Configure which security scheme(s) should be enabled for this request
+ Security Security
// If ResponseBodyInto not nil, then we will attempt to deserialize into
// ResponseBodyInto. If Destination is a []byte, then it will return the body as
// is.
@@ -247,12 +361,17 @@ func applyMiddleware(middleware middleware, next middlewareNext) middlewareNext
}
}
-func shouldRetry(req *http.Request, res *http.Response) bool {
+func shouldRetry(req *http.Request, res *http.Response, err error) bool {
// If there is no way to recover the Body, then we shouldn't retry.
if req.Body != nil && req.GetBody == nil {
return false
}
+ var deterministic interface{ noRetry() }
+ if errors.As(err, &deterministic) {
+ return false
+ }
+
// If there is no response, that indicates that there is a connection error
// so we retry the request.
if res == nil {
@@ -364,6 +483,22 @@ func (b *bodyWithTimeout) Close() error {
return err
}
+// closeOnceReadCloser lets Execute clean up bodies when middleware returns an
+// error before reaching the transport, without double-closing bodies that a
+// transport has already closed.
+type closeOnceReadCloser struct {
+ io.ReadCloser
+ once sync.Once
+ err error
+}
+
+func (b *closeOnceReadCloser) Close() error {
+ b.once.Do(func() {
+ b.err = b.ReadCloser.Close()
+ })
+ return b.err
+}
+
func retryDelay(res *http.Response, retryCount int) time.Duration {
// If the backend tells us to wait a certain amount of time, use that value
if retryAfterDelay, ok := parseRetryAfterHeader(res); ok {
@@ -444,15 +579,21 @@ func (cfg *RequestConfig) Execute() (err error) {
}
req := cfg.Request.Clone(ctx)
+ if req.Body != nil {
+ req.Body = &closeOnceReadCloser{ReadCloser: req.Body}
+ }
if shouldSendRetryCount {
req.Header.Set("X-Stainless-Retry-Count", strconv.Itoa(retryCount))
}
res, err = handler(req)
+ if err != nil && req.Body != nil {
+ _ = req.Body.Close()
+ }
if ctx != nil && ctx.Err() != nil {
return ctx.Err()
}
- if !shouldRetry(cfg.Request, res) || retryCount >= cfg.MaxRetries {
+ if !shouldRetry(cfg.Request, res, err) || retryCount >= cfg.MaxRetries {
break
}
@@ -590,22 +731,59 @@ func (cfg *RequestConfig) Clone(ctx context.Context) *RequestConfig {
return nil
}
new := &RequestConfig{
- MaxRetries: cfg.MaxRetries,
- RequestTimeout: cfg.RequestTimeout,
- Context: ctx,
- Request: req,
- BaseURL: cfg.BaseURL,
- HTTPClient: cfg.HTTPClient,
- Middlewares: cfg.Middlewares,
- APIKey: cfg.APIKey,
- Organization: cfg.Organization,
- Project: cfg.Project,
- WebhookSecret: cfg.WebhookSecret,
+ MaxRetries: cfg.MaxRetries,
+ RequestTimeout: cfg.RequestTimeout,
+ Context: ctx,
+ Request: req,
+ BaseURL: cfg.BaseURL,
+ HTTPClient: cfg.HTTPClient,
+ Middlewares: cfg.Middlewares,
+ APIKey: cfg.APIKey,
+ AdminAPIKey: cfg.AdminAPIKey,
+ Organization: cfg.Organization,
+ Project: cfg.Project,
+ WebhookSecret: cfg.WebhookSecret,
+ finalizers: append([]requestFinalizer(nil), cfg.finalizers...),
+ authHeaderOverride: cfg.authHeaderOverride,
+ authPreference: cfg.authPreference,
}
return new
}
+func (cfg *RequestConfig) SetHeader(key, value string) {
+ cfg.Request.Header.Set(key, value)
+ if strings.EqualFold(key, "Authorization") {
+ cfg.authHeaderOverride = true
+ }
+}
+
+func (cfg *RequestConfig) AddHeader(key, value string) {
+ cfg.Request.Header.Add(key, value)
+ if strings.EqualFold(key, "Authorization") {
+ cfg.authHeaderOverride = true
+ }
+}
+
+func (cfg *RequestConfig) DelHeader(key string) {
+ cfg.Request.Header.Del(key)
+ if strings.EqualFold(key, "Authorization") {
+ cfg.authHeaderOverride = true
+ }
+}
+
+func (cfg *RequestConfig) SetAPIKey(value string) {
+ cfg.APIKey = value
+ cfg.authHeaderOverride = false
+ cfg.authPreference = authCredentialPreferenceBearer
+}
+
+func (cfg *RequestConfig) SetAdminAPIKey(value string) {
+ cfg.AdminAPIKey = value
+ cfg.authHeaderOverride = false
+ cfg.authPreference = authCredentialPreferenceAdmin
+}
+
func (cfg *RequestConfig) Apply(opts ...RequestOption) error {
for _, opt := range opts {
err := opt.Apply(cfg)
@@ -648,3 +826,81 @@ func WithDefaultBaseURL(baseURL string) RequestOption {
return nil
})
}
+
+type Security struct {
+ BearerAuth bool
+ AdminAPIKeyAuth bool
+}
+
+type authCredentialPreference int
+
+const (
+ authCredentialPreferenceNone authCredentialPreference = iota
+ authCredentialPreferenceBearer
+ authCredentialPreferenceAdmin
+)
+
+func WithSecurity(security Security) RequestOption {
+ return RequestOptionFunc(func(r *RequestConfig) error {
+ r.Security = security
+ return nil
+ })
+}
+
+// WithBearerAuthSecurity() should only be used within a method, not provided to at
+// the client-level.
+func WithBearerAuthSecurity() RequestOption {
+ return RequestOptionFunc(func(r *RequestConfig) error {
+ r.Security = Security{
+ BearerAuth: true,
+ AdminAPIKeyAuth: false,
+ }
+ return nil
+ })
+}
+
+// WithAdminAPIKeyAuthSecurity() should only be used within a method, not provided
+// to at the client-level.
+func WithAdminAPIKeyAuthSecurity() RequestOption {
+ return RequestOptionFunc(func(r *RequestConfig) error {
+ r.Security = Security{
+ BearerAuth: false,
+ AdminAPIKeyAuth: true,
+ }
+ return nil
+ })
+}
+
+// WithBearerAuthPreference() should only be used when a request supports multiple
+// auth schemes and has no endpoint-specific security preference.
+func WithBearerAuthPreference() RequestOption {
+ return RequestOptionFunc(func(r *RequestConfig) error {
+ r.authPreference = authCredentialPreferenceBearer
+ return nil
+ })
+}
+
+func ApplySecurity(r RequestConfig) {
+ if r.authHeaderOverride {
+ return
+ }
+
+ if r.authPreference == authCredentialPreferenceBearer && r.Security.BearerAuth && r.APIKey != "" {
+ r.Request.Header.Set("authorization", fmt.Sprintf("Bearer %s", r.APIKey))
+ return
+ }
+
+ if r.authPreference == authCredentialPreferenceAdmin && r.Security.AdminAPIKeyAuth && r.AdminAPIKey != "" {
+ r.Request.Header.Set("authorization", fmt.Sprintf("Bearer %s", r.AdminAPIKey))
+ return
+ }
+
+ if r.Security.AdminAPIKeyAuth && r.AdminAPIKey != "" {
+ r.Request.Header.Set("authorization", fmt.Sprintf("Bearer %s", r.AdminAPIKey))
+ return
+ }
+
+ if r.Security.BearerAuth && r.APIKey != "" {
+ r.Request.Header.Set("authorization", fmt.Sprintf("Bearer %s", r.APIKey))
+ }
+}
diff --git a/vendor/github.com/openai/openai-go/v3/internal/version.go b/vendor/github.com/openai/openai-go/v3/internal/version.go
index 1025b99f9..c612018dd 100644
--- a/vendor/github.com/openai/openai-go/v3/internal/version.go
+++ b/vendor/github.com/openai/openai-go/v3/internal/version.go
@@ -2,4 +2,4 @@
package internal
-const PackageVersion = "3.32.0" // x-release-please-version
+const PackageVersion = "3.45.0" // x-release-please-version
diff --git a/vendor/github.com/openai/openai-go/v3/model.go b/vendor/github.com/openai/openai-go/v3/model.go
index e1ab4a799..46c7a915c 100644
--- a/vendor/github.com/openai/openai-go/v3/model.go
+++ b/vendor/github.com/openai/openai-go/v3/model.go
@@ -5,7 +5,6 @@ package openai
import (
"context"
"errors"
- "fmt"
"net/http"
"slices"
@@ -41,12 +40,13 @@ func NewModelService(opts ...option.RequestOption) (r ModelService) {
// Retrieves a model instance, providing basic information about the model such as
// the owner and permissioning.
func (r *ModelService) Get(ctx context.Context, model string, opts ...option.RequestOption) (res *Model, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if model == "" {
err = errors.New("missing required model parameter")
return nil, err
}
- path := fmt.Sprintf("models/%s", model)
+ path := requestconfig.FormatPath("models/%s", model)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
@@ -55,7 +55,8 @@ func (r *ModelService) Get(ctx context.Context, model string, opts ...option.Req
// one such as the owner and availability.
func (r *ModelService) List(ctx context.Context, opts ...option.RequestOption) (res *pagination.Page[Model], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "models"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, nil, &res, opts...)
@@ -79,12 +80,13 @@ func (r *ModelService) ListAutoPaging(ctx context.Context, opts ...option.Reques
// Delete a fine-tuned model. You must have the Owner role in your organization to
// delete a model.
func (r *ModelService) Delete(ctx context.Context, model string, opts ...option.RequestOption) (res *ModelDeleted, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if model == "" {
err = errors.New("missing required model parameter")
return nil, err
}
- path := fmt.Sprintf("models/%s", model)
+ path := requestconfig.FormatPath("models/%s", model)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
return res, err
}
@@ -94,7 +96,7 @@ type Model struct {
// The model identifier, which can be referenced in the API endpoints.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) when the model was created.
- Created int64 `json:"created" api:"required"`
+ Created int64 `json:"created" api:"required" format:"unixtime"`
// The object type, which is always "model".
Object constant.Model `json:"object" default:"model"`
// The organization that owns the model.
diff --git a/vendor/github.com/openai/openai-go/v3/moderation.go b/vendor/github.com/openai/openai-go/v3/moderation.go
index b5a71dd36..a73365125 100644
--- a/vendor/github.com/openai/openai-go/v3/moderation.go
+++ b/vendor/github.com/openai/openai-go/v3/moderation.go
@@ -40,7 +40,8 @@ func NewModerationService(opts ...option.RequestOption) (r ModerationService) {
// Classifies if text and/or image inputs are potentially harmful. Learn more in
// the [moderation guide](https://platform.openai.com/docs/guides/moderation).
func (r *ModerationService) New(ctx context.Context, body ModerationNewParams, opts ...option.RequestOption) (res *ModerationNewResponse, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "moderations"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
diff --git a/vendor/github.com/openai/openai-go/v3/option/middleware.go b/vendor/github.com/openai/openai-go/v3/option/middleware.go
index 8ec9dd60b..65757596e 100644
--- a/vendor/github.com/openai/openai-go/v3/option/middleware.go
+++ b/vendor/github.com/openai/openai-go/v3/option/middleware.go
@@ -8,6 +8,17 @@ import (
"net/http/httputil"
)
+// sensitiveLogHeaders are redacted before request and response content is
+// written to the debug logger.
+var sensitiveLogHeaders = []string{
+ "authorization",
+ "api-key",
+ "x-api-key",
+ "x-amz-security-token",
+ "cookie",
+ "set-cookie",
+}
+
// WithDebugLog logs the HTTP request and response content.
// If the logger parameter is nil, it uses the default logger.
//
@@ -20,7 +31,7 @@ func WithDebugLog(logger *log.Logger) RequestOption {
logger = log.Default()
}
- if reqBytes, err := httputil.DumpRequest(req, true); err == nil {
+ if reqBytes, err := dumpRedactedRequest(req); err == nil {
logger.Printf("Request Content:\n%s\n", reqBytes)
}
@@ -29,10 +40,48 @@ func WithDebugLog(logger *log.Logger) RequestOption {
return resp, err
}
- if respBytes, err := httputil.DumpResponse(resp, true); err == nil {
+ if respBytes, err := dumpRedactedResponse(resp); err == nil {
logger.Printf("Response Content:\n%s\n", respBytes)
}
return resp, err
})
}
+
+// dumpRedactedRequest dumps req with sensitive headers replaced. The
+// original headers are restored via defer so a panic in DumpRequest cannot
+// leak the placeholder map into the live request sent downstream.
+func dumpRedactedRequest(req *http.Request) ([]byte, error) {
+ origHeaders := req.Header
+ req.Header = redactDebugHeaders(origHeaders)
+ defer func() { req.Header = origHeaders }()
+ return httputil.DumpRequest(req, true)
+}
+
+func dumpRedactedResponse(resp *http.Response) ([]byte, error) {
+ origHeaders := resp.Header
+ resp.Header = redactDebugHeaders(origHeaders)
+ defer func() { resp.Header = origHeaders }()
+ return httputil.DumpResponse(resp, true)
+}
+
+func redactDebugHeaders(headers http.Header) http.Header {
+ var redacted http.Header
+ for _, name := range sensitiveLogHeaders {
+ values := headers.Values(name)
+ if len(values) == 0 {
+ continue
+ }
+ if redacted == nil {
+ redacted = headers.Clone()
+ }
+ redacted.Del(name)
+ for range values {
+ redacted.Add(name, "***")
+ }
+ }
+ if redacted == nil {
+ return headers
+ }
+ return redacted
+}
diff --git a/vendor/github.com/openai/openai-go/v3/option/requestoption.go b/vendor/github.com/openai/openai-go/v3/option/requestoption.go
index bee4622c9..1ce529ace 100644
--- a/vendor/github.com/openai/openai-go/v3/option/requestoption.go
+++ b/vendor/github.com/openai/openai-go/v3/option/requestoption.go
@@ -112,7 +112,7 @@ func WithMaxRetries(retries int) RequestOption {
// any value if there was one already present.
func WithHeader(key, value string) RequestOption {
return requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error {
- r.Request.Header.Set(key, value)
+ r.SetHeader(key, value)
return nil
})
}
@@ -121,7 +121,7 @@ func WithHeader(key, value string) RequestOption {
// onto any existing values.
func WithHeaderAdd(key, value string) RequestOption {
return requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error {
- r.Request.Header.Add(key, value)
+ r.AddHeader(key, value)
return nil
})
}
@@ -129,7 +129,7 @@ func WithHeaderAdd(key, value string) RequestOption {
// WithHeaderDel returns a RequestOption that deletes the header value(s) associated with the given key.
func WithHeaderDel(key string) RequestOption {
return requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error {
- r.Request.Header.Del(key)
+ r.DelHeader(key)
return nil
})
}
@@ -271,8 +271,16 @@ func WithEnvironmentProduction() RequestOption {
// WithAPIKey returns a RequestOption that sets the client setting "api_key".
func WithAPIKey(value string) RequestOption {
return requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error {
- r.APIKey = value
- return r.Apply(WithHeader("authorization", fmt.Sprintf("Bearer %s", r.APIKey)))
+ r.SetAPIKey(value)
+ return nil
+ })
+}
+
+// WithAdminAPIKey returns a RequestOption that sets the client setting "admin_api_key".
+func WithAdminAPIKey(value string) RequestOption {
+ return requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error {
+ r.SetAdminAPIKey(value)
+ return nil
})
}
@@ -309,7 +317,7 @@ func WithWorkloadIdentity(config auth.WorkloadIdentity) RequestOption {
var initErr error
return requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error {
- r.APIKey = ""
+ r.SetAPIKey("")
r.Middlewares = append(r.Middlewares, func(req *http.Request, next func(*http.Request) (*http.Response, error)) (*http.Response, error) {
initOnce.Do(func() {
diff --git a/vendor/github.com/openai/openai-go/v3/packages/pagination/pagination.go b/vendor/github.com/openai/openai-go/v3/packages/pagination/pagination.go
index 302ced16c..14fc9930d 100644
--- a/vendor/github.com/openai/openai-go/v3/packages/pagination/pagination.go
+++ b/vendor/github.com/openai/openai-go/v3/packages/pagination/pagination.go
@@ -327,3 +327,109 @@ func (r *ConversationCursorPageAutoPager[T]) Err() error {
func (r *ConversationCursorPageAutoPager[T]) Index() int {
return r.run
}
+
+type NextCursorPage[T any] struct {
+ Data []T `json:"data"`
+ HasMore bool `json:"has_more"`
+ Next string `json:"next" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ Data respjson.Field
+ HasMore respjson.Field
+ Next respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+ cfg *requestconfig.RequestConfig
+ res *http.Response
+}
+
+// Returns the unmodified JSON received from the API
+func (r NextCursorPage[T]) RawJSON() string { return r.JSON.raw }
+func (r *NextCursorPage[T]) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// GetNextPage returns the next page as defined by this pagination style. When
+// there is no next page, this function will return a 'nil' for the page value, but
+// will not return an error
+func (r *NextCursorPage[T]) GetNextPage() (res *NextCursorPage[T], err error) {
+ if len(r.Data) == 0 {
+ return nil, nil
+ }
+
+ if r.JSON.HasMore.Valid() && r.HasMore == false {
+ return nil, nil
+ }
+ next := r.Next
+ if len(next) == 0 {
+ return nil, nil
+ }
+ cfg := r.cfg.Clone(r.cfg.Context)
+ err = cfg.Apply(option.WithQuery("after", next))
+ if err != nil {
+ return nil, err
+ }
+ var raw *http.Response
+ cfg.ResponseInto = &raw
+ cfg.ResponseBodyInto = &res
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *NextCursorPage[T]) SetPageConfig(cfg *requestconfig.RequestConfig, res *http.Response) {
+ if r == nil {
+ r = &NextCursorPage[T]{}
+ }
+ r.cfg = cfg
+ r.res = res
+}
+
+type NextCursorPageAutoPager[T any] struct {
+ page *NextCursorPage[T]
+ cur T
+ idx int
+ run int
+ err error
+ paramObj
+}
+
+func NewNextCursorPageAutoPager[T any](page *NextCursorPage[T], err error) *NextCursorPageAutoPager[T] {
+ return &NextCursorPageAutoPager[T]{
+ page: page,
+ err: err,
+ }
+}
+
+func (r *NextCursorPageAutoPager[T]) Next() bool {
+ if r.page == nil || len(r.page.Data) == 0 {
+ return false
+ }
+ if r.idx >= len(r.page.Data) {
+ r.idx = 0
+ r.page, r.err = r.page.GetNextPage()
+ if r.err != nil || r.page == nil || len(r.page.Data) == 0 {
+ return false
+ }
+ }
+ r.cur = r.page.Data[r.idx]
+ r.run += 1
+ r.idx += 1
+ return true
+}
+
+func (r *NextCursorPageAutoPager[T]) Current() T {
+ return r.cur
+}
+
+func (r *NextCursorPageAutoPager[T]) Err() error {
+ return r.err
+}
+
+func (r *NextCursorPageAutoPager[T]) Index() int {
+ return r.run
+}
diff --git a/vendor/github.com/openai/openai-go/v3/packages/param/encoder.go b/vendor/github.com/openai/openai-go/v3/packages/param/encoder.go
index c503c967f..f3d489260 100644
--- a/vendor/github.com/openai/openai-go/v3/packages/param/encoder.go
+++ b/vendor/github.com/openai/openai-go/v3/packages/param/encoder.go
@@ -66,7 +66,7 @@ func MarshalWithExtras[T ParamStruct, R any](f T, underlying any, extras map[str
} else if ovr, ok := f.Overrides(); ok {
return shimjson.Marshal(ovr)
} else {
- return shimjson.Marshal(underlying)
+ return shimjson.Marshal(underlying, shimjson.WithSkipCompaction(true))
}
}
@@ -96,7 +96,7 @@ func MarshalUnion[T ParamStruct](metadata T, variants ...any) ([]byte, error) {
Err: fmt.Errorf("expected union to have only one present variant, got %d", nPresent),
}
}
- return shimjson.Marshal(variants[presentIdx])
+ return shimjson.Marshal(variants[presentIdx], shimjson.WithSkipCompaction(true))
}
// typeFor is shimmed from Go 1.23 "reflect" package
diff --git a/vendor/github.com/openai/openai-go/v3/packages/ssestream/ssestream.go b/vendor/github.com/openai/openai-go/v3/packages/ssestream/ssestream.go
index 07e190ce2..773e8345d 100644
--- a/vendor/github.com/openai/openai-go/v3/packages/ssestream/ssestream.go
+++ b/vendor/github.com/openai/openai-go/v3/packages/ssestream/ssestream.go
@@ -82,6 +82,10 @@ func (s *eventStreamDecoder) Next() bool {
// Dispatch event on an empty line
if len(txt) == 0 {
+ if data.Len() == 0 {
+ event = ""
+ continue
+ }
s.evt = Event{
Type: event,
Data: data.Bytes(),
diff --git a/vendor/github.com/openai/openai-go/v3/realtime/aliases.go b/vendor/github.com/openai/openai-go/v3/realtime/aliases.go
index 98c0ca804..894b8d55f 100644
--- a/vendor/github.com/openai/openai-go/v3/realtime/aliases.go
+++ b/vendor/github.com/openai/openai-go/v3/realtime/aliases.go
@@ -64,6 +64,15 @@ const AllModelsGPT5_1CodexMax = shared.AllModelsGPT5_1CodexMax
// This is an alias to an internal type.
type ChatModel = shared.ChatModel
+// Equals "gpt-5.6-sol"
+const ChatModelGPT5_6Sol = shared.ChatModelGPT5_6Sol
+
+// Equals "gpt-5.6-terra"
+const ChatModelGPT5_6Terra = shared.ChatModelGPT5_6Terra
+
+// Equals "gpt-5.6-luna"
+const ChatModelGPT5_6Luna = shared.ChatModelGPT5_6Luna
+
// Equals "gpt-5.4"
const ChatModelGPT5_4 = shared.ChatModelGPT5_4
@@ -465,6 +474,25 @@ const OAuthErrorCodeInvalidSubjectToken = shared.OAuthErrorCodeInvalidSubjectTok
// This is an alias to an internal type.
type Reasoning = shared.Reasoning
+// 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.
+//
+// This is an alias to an internal type.
+type ReasoningContext = shared.ReasoningContext
+
+// Equals "auto"
+const ReasoningContextAuto = shared.ReasoningContextAuto
+
+// Equals "current_turn"
+const ReasoningContextCurrentTurn = shared.ReasoningContextCurrentTurn
+
+// Equals "all_turns"
+const ReasoningContextAllTurns = shared.ReasoningContextAllTurns
+
// **Deprecated:** use `summary` instead.
//
// A summary of the reasoning performed by the model. This can be useful for
@@ -483,6 +511,19 @@ const ReasoningGenerateSummaryConcise = shared.ReasoningGenerateSummaryConcise
// Equals "detailed"
const ReasoningGenerateSummaryDetailed = shared.ReasoningGenerateSummaryDetailed
+// Controls the reasoning execution mode for the request.
+//
+// When returned on a response, this is the effective execution mode.
+//
+// This is an alias to an internal type.
+type ReasoningMode = shared.ReasoningMode
+
+// Equals "standard"
+const ReasoningModeStandard = shared.ReasoningModeStandard
+
+// Equals "pro"
+const ReasoningModePro = shared.ReasoningModePro
+
// 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`.
@@ -510,19 +551,12 @@ const ReasoningSummaryDetailed = shared.ReasoningSummaryDetailed
// This is an alias to an internal type.
type ReasoningParam = shared.ReasoningParam
-// Constrains effort on reasoning for
-// [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
-// supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`.
-// Reducing reasoning effort can result in faster responses and fewer tokens used
-// on reasoning in a response.
-//
-// - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
-// reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
-// calls are supported for all reasoning values in gpt-5.1.
-// - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
-// support `none`.
-// - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
-// - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
+// 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.
//
// This is an alias to an internal type.
type ReasoningEffort = shared.ReasoningEffort
@@ -545,6 +579,9 @@ const ReasoningEffortHigh = shared.ReasoningEffortHigh
// Equals "xhigh"
const ReasoningEffortXhigh = shared.ReasoningEffortXhigh
+// Equals "max"
+const ReasoningEffortMax = shared.ReasoningEffortMax
+
// 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.
diff --git a/vendor/github.com/openai/openai-go/v3/realtime/api.md b/vendor/github.com/openai/openai-go/v3/realtime/api.md
index 61e21f5ca..693276f39 100644
--- a/vendor/github.com/openai/openai-go/v3/realtime/api.md
+++ b/vendor/github.com/openai/openai-go/v3/realtime/api.md
@@ -10,6 +10,8 @@ Params Types:
- realtime.RealtimeAudioFormatsUnionParam
- realtime.RealtimeAudioInputTurnDetectionUnionParam
- realtime.RealtimeFunctionToolParam
+- realtime.RealtimeReasoningParam
+- realtime.RealtimeReasoningEffort
- realtime.RealtimeSessionCreateRequestParam
- realtime.RealtimeToolChoiceConfigUnionParam
- realtime.RealtimeToolsConfigParam
@@ -28,6 +30,8 @@ Response Types:
- realtime.NoiseReductionType
- realtime.RealtimeAudioFormatsUnion
- realtime.RealtimeFunctionTool
+- realtime.RealtimeReasoning
+- realtime.RealtimeReasoningEffort
- realtime.RealtimeTruncationUnion
- realtime.RealtimeTruncationRetentionRatio
@@ -35,7 +39,6 @@ Response Types:
Response Types:
-- realtime.RealtimeSessionClientSecret
- realtime.RealtimeSessionCreateResponse
- realtime.RealtimeTranscriptionSessionCreateResponse
- realtime.RealtimeTranscriptionSessionTurnDetection
diff --git a/vendor/github.com/openai/openai-go/v3/realtime/call.go b/vendor/github.com/openai/openai-go/v3/realtime/call.go
index e261509be..d3f6ea88e 100644
--- a/vendor/github.com/openai/openai-go/v3/realtime/call.go
+++ b/vendor/github.com/openai/openai-go/v3/realtime/call.go
@@ -5,7 +5,6 @@ package realtime
import (
"context"
"errors"
- "fmt"
"net/http"
"slices"
@@ -38,52 +37,56 @@ func NewCallService(opts ...option.RequestOption) (r CallService) {
// Accept an incoming SIP call and configure the realtime session that will handle
// it.
func (r *CallService) Accept(ctx context.Context, callID string, body CallAcceptParams, opts ...option.RequestOption) (err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...)
if callID == "" {
err = errors.New("missing required call_id parameter")
return err
}
- path := fmt.Sprintf("realtime/calls/%s/accept", callID)
+ path := requestconfig.FormatPath("realtime/calls/%s/accept", callID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, nil, opts...)
return err
}
// End an active Realtime API call, whether it was initiated over SIP or WebRTC.
func (r *CallService) Hangup(ctx context.Context, callID string, opts ...option.RequestOption) (err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...)
if callID == "" {
err = errors.New("missing required call_id parameter")
return err
}
- path := fmt.Sprintf("realtime/calls/%s/hangup", callID)
+ path := requestconfig.FormatPath("realtime/calls/%s/hangup", callID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, nil, opts...)
return err
}
// Transfer an active SIP call to a new destination using the SIP REFER verb.
func (r *CallService) Refer(ctx context.Context, callID string, body CallReferParams, opts ...option.RequestOption) (err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...)
if callID == "" {
err = errors.New("missing required call_id parameter")
return err
}
- path := fmt.Sprintf("realtime/calls/%s/refer", callID)
+ path := requestconfig.FormatPath("realtime/calls/%s/refer", callID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, nil, opts...)
return err
}
// Decline an incoming SIP call by returning a SIP status code to the caller.
func (r *CallService) Reject(ctx context.Context, callID string, body CallRejectParams, opts ...option.RequestOption) (err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...)
if callID == "" {
err = errors.New("missing required call_id parameter")
return err
}
- path := fmt.Sprintf("realtime/calls/%s/reject", callID)
+ path := requestconfig.FormatPath("realtime/calls/%s/reject", callID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, nil, opts...)
return err
}
diff --git a/vendor/github.com/openai/openai-go/v3/realtime/clientsecret.go b/vendor/github.com/openai/openai-go/v3/realtime/clientsecret.go
index 79a9fac54..34eee0b52 100644
--- a/vendor/github.com/openai/openai-go/v3/realtime/clientsecret.go
+++ b/vendor/github.com/openai/openai-go/v3/realtime/clientsecret.go
@@ -52,45 +52,25 @@ func NewClientSecretService(opts ...option.RequestOption) (r ClientSecretService
// Returns the created client secret and the effective session object. The client
// secret is a string that looks like `ek_1234`.
func (r *ClientSecretService) New(ctx context.Context, body ClientSecretNewParams, opts ...option.RequestOption) (res *ClientSecretNewResponse, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "realtime/client_secrets"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
-// Ephemeral key returned by the API.
-type RealtimeSessionClientSecret struct {
- // Timestamp for when the token expires. Currently, all tokens expire after one
- // minute.
- ExpiresAt int64 `json:"expires_at" api:"required"`
- // Ephemeral key usable in client environments to authenticate connections to the
- // Realtime API. Use this in client-side environments rather than a standard API
- // token, which should only be used server-side.
- Value string `json:"value" api:"required"`
- // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
- JSON struct {
- ExpiresAt respjson.Field
- Value respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
- } `json:"-"`
-}
-
-// Returns the unmodified JSON received from the API
-func (r RealtimeSessionClientSecret) RawJSON() string { return r.JSON.raw }
-func (r *RealtimeSessionClientSecret) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-// A new Realtime session configuration, with an ephemeral key. Default TTL for
-// keys is one minute.
+// A Realtime session configuration object.
type RealtimeSessionCreateResponse struct {
- // Ephemeral key returned by the API.
- ClientSecret RealtimeSessionClientSecret `json:"client_secret" api:"required"`
+ // Unique identifier for the session that looks like `sess_1234567890abcdef`.
+ ID string `json:"id" api:"required"`
+ // The object type. Always `realtime.session`.
+ Object constant.RealtimeSession `json:"object" default:"realtime.session"`
// The type of session to create. Always `realtime` for the Realtime API.
Type constant.Realtime `json:"type" default:"realtime"`
// Configuration for input and output audio.
Audio RealtimeSessionCreateResponseAudio `json:"audio"`
+ // Expiration timestamp for the session, in seconds since epoch.
+ ExpiresAt int64 `json:"expires_at" format:"unixtime"`
// Additional fields to include in server outputs.
//
// `item.input_audio_transcription.logprobs`: Include logprobs for input audio
@@ -126,6 +106,8 @@ type RealtimeSessionCreateResponse struct {
// Reference to a prompt template and its variables.
// [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
Prompt responses.ResponsePrompt `json:"prompt" api:"nullable"`
+ // Configuration for reasoning-capable Realtime models such as `gpt-realtime-2`.
+ Reasoning RealtimeReasoning `json:"reasoning"`
// How the model chooses tools. Provide one of the string modes or force a specific
// function/MCP tool.
ToolChoice RealtimeSessionCreateResponseToolChoiceUnion `json:"tool_choice"`
@@ -160,15 +142,18 @@ type RealtimeSessionCreateResponse struct {
Truncation RealtimeTruncationUnion `json:"truncation"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
- ClientSecret respjson.Field
+ ID respjson.Field
+ Object respjson.Field
Type respjson.Field
Audio respjson.Field
+ ExpiresAt respjson.Field
Include respjson.Field
Instructions respjson.Field
MaxOutputTokens respjson.Field
Model respjson.Field
OutputModalities respjson.Field
Prompt respjson.Field
+ Reasoning respjson.Field
ToolChoice respjson.Field
Tools respjson.Field
Tracing respjson.Field
@@ -212,15 +197,7 @@ type RealtimeSessionCreateResponseAudioInput struct {
// detection accuracy (reducing false positives) and model performance by improving
// perception of the input audio.
NoiseReduction RealtimeSessionCreateResponseAudioInputNoiseReduction `json:"noise_reduction"`
- // Configuration for input audio transcription, defaults to off and can be set to
- // `null` to turn off once on. Input audio transcription is not native to the
- // model, since the model consumes audio directly. Transcription runs
- // asynchronously through
- // [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription)
- // and should be treated as guidance of input audio content rather than precisely
- // what the model heard. The client can optionally set the language and prompt for
- // transcription, these offer additional guidance to the transcription service.
- Transcription AudioTranscription `json:"transcription"`
+ Transcription AudioTranscription `json:"transcription"`
// Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
// set to `null` to turn off, in which case the client must manually trigger model
// response.
@@ -234,6 +211,9 @@ type RealtimeSessionCreateResponseAudioInput struct {
// trails off with "uhhm", the model will score a low probability of turn end and
// wait longer for the user to continue speaking. This can be useful for more
// natural conversations, but may have a higher latency.
+ //
+ // For `gpt-realtime-whisper` transcription sessions, turn detection must be set to
+ // `null`; VAD is not supported.
TurnDetection RealtimeSessionCreateResponseAudioInputTurnDetectionUnion `json:"turn_detection" api:"nullable"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
@@ -549,6 +529,9 @@ type RealtimeSessionCreateResponseModel string
const (
RealtimeSessionCreateResponseModelGPTRealtime RealtimeSessionCreateResponseModel = "gpt-realtime"
RealtimeSessionCreateResponseModelGPTRealtime1_5 RealtimeSessionCreateResponseModel = "gpt-realtime-1.5"
+ RealtimeSessionCreateResponseModelGPTRealtime2 RealtimeSessionCreateResponseModel = "gpt-realtime-2"
+ RealtimeSessionCreateResponseModelGPTRealtime2_1 RealtimeSessionCreateResponseModel = "gpt-realtime-2.1"
+ RealtimeSessionCreateResponseModelGPTRealtime2_1Mini RealtimeSessionCreateResponseModel = "gpt-realtime-2.1-mini"
RealtimeSessionCreateResponseModelGPTRealtime2025_08_28 RealtimeSessionCreateResponseModel = "gpt-realtime-2025-08-28"
RealtimeSessionCreateResponseModelGPT4oRealtimePreview RealtimeSessionCreateResponseModel = "gpt-4o-realtime-preview"
RealtimeSessionCreateResponseModelGPT4oRealtimePreview2024_10_01 RealtimeSessionCreateResponseModel = "gpt-4o-realtime-preview-2024-10-01"
@@ -627,6 +610,8 @@ type RealtimeSessionCreateResponseToolUnion struct {
// This field is from variant [RealtimeSessionCreateResponseToolMcpTool].
ServerLabel string `json:"server_label"`
// This field is from variant [RealtimeSessionCreateResponseToolMcpTool].
+ AllowedCallers []string `json:"allowed_callers"`
+ // This field is from variant [RealtimeSessionCreateResponseToolMcpTool].
AllowedTools RealtimeSessionCreateResponseToolMcpToolAllowedToolsUnion `json:"allowed_tools"`
// This field is from variant [RealtimeSessionCreateResponseToolMcpTool].
Authorization string `json:"authorization"`
@@ -642,12 +627,15 @@ type RealtimeSessionCreateResponseToolUnion struct {
ServerDescription string `json:"server_description"`
// This field is from variant [RealtimeSessionCreateResponseToolMcpTool].
ServerURL string `json:"server_url"`
- JSON struct {
+ // This field is from variant [RealtimeSessionCreateResponseToolMcpTool].
+ TunnelID string `json:"tunnel_id"`
+ JSON struct {
Description respjson.Field
Name respjson.Field
Parameters respjson.Field
Type respjson.Field
ServerLabel respjson.Field
+ AllowedCallers respjson.Field
AllowedTools respjson.Field
Authorization respjson.Field
ConnectorID respjson.Field
@@ -656,6 +644,7 @@ type RealtimeSessionCreateResponseToolUnion struct {
RequireApproval respjson.Field
ServerDescription respjson.Field
ServerURL respjson.Field
+ TunnelID respjson.Field
raw string
} `json:"-"`
}
@@ -685,6 +674,10 @@ type RealtimeSessionCreateResponseToolMcpTool struct {
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 RealtimeSessionCreateResponseToolMcpToolAllowedToolsUnion `json:"allowed_tools" api:"nullable"`
// An OAuth access token that can be used with a remote MCP server, either with a
@@ -692,8 +685,8 @@ type RealtimeSessionCreateResponseToolMcpTool struct {
// 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` or `connector_id` must be provided. Learn more about service
- // connectors
+ // `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:
@@ -720,13 +713,17 @@ type RealtimeSessionCreateResponseToolMcpTool struct {
RequireApproval RealtimeSessionCreateResponseToolMcpToolRequireApprovalUnion `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` or `connector_id` must be
- // provided.
- ServerURL string `json:"server_url"`
+ // 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
@@ -735,6 +732,7 @@ type RealtimeSessionCreateResponseToolMcpTool struct {
RequireApproval respjson.Field
ServerDescription respjson.Field
ServerURL respjson.Field
+ TunnelID respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
@@ -1032,7 +1030,7 @@ type RealtimeTranscriptionSessionCreateResponse struct {
// Configuration for input audio for the session.
Audio RealtimeTranscriptionSessionCreateResponseAudio `json:"audio"`
// Expiration timestamp for the session, in seconds since epoch.
- ExpiresAt int64 `json:"expires_at"`
+ ExpiresAt int64 `json:"expires_at" format:"unixtime"`
// Additional fields to include in server outputs.
//
// - `item.input_audio_transcription.logprobs`: Include logprobs for input audio
@@ -1081,12 +1079,12 @@ type RealtimeTranscriptionSessionCreateResponseAudioInput struct {
Format RealtimeAudioFormatsUnion `json:"format"`
// Configuration for input audio noise reduction.
NoiseReduction RealtimeTranscriptionSessionCreateResponseAudioInputNoiseReduction `json:"noise_reduction"`
- // Configuration of the transcription model.
- Transcription AudioTranscription `json:"transcription"`
+ Transcription AudioTranscription `json:"transcription"`
// Configuration for turn detection. Can be set to `null` to turn off. Server VAD
// means that the model will detect the start and end of speech based on audio
- // volume and respond at the end of user speech.
- TurnDetection RealtimeTranscriptionSessionTurnDetection `json:"turn_detection"`
+ // volume and respond at the end of user speech. For `gpt-realtime-whisper`, this
+ // must be `null`; VAD is not supported.
+ TurnDetection RealtimeTranscriptionSessionTurnDetection `json:"turn_detection" api:"nullable"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Format respjson.Field
@@ -1130,7 +1128,8 @@ func (r *RealtimeTranscriptionSessionCreateResponseAudioInputNoiseReduction) Unm
// Configuration for turn detection. Can be set to `null` to turn off. Server VAD
// means that the model will detect the start and end of speech based on audio
-// volume and respond at the end of user speech.
+// volume and respond at the end of user speech. For `gpt-realtime-whisper`, this
+// must be `null`; VAD is not supported.
type RealtimeTranscriptionSessionTurnDetection struct {
// Amount of audio to include before the VAD detected speech (in milliseconds).
// Defaults to 300ms.
@@ -1165,7 +1164,7 @@ func (r *RealtimeTranscriptionSessionTurnDetection) UnmarshalJSON(data []byte) e
// Response from creating a session and client secret for the Realtime API.
type ClientSecretNewResponse struct {
// Expiration timestamp for the client secret, in seconds since epoch.
- ExpiresAt int64 `json:"expires_at" api:"required"`
+ ExpiresAt int64 `json:"expires_at" api:"required" format:"unixtime"`
// The session configuration for either a realtime or transcription session.
Session ClientSecretNewResponseSessionUnion `json:"session" api:"required"`
// The generated client secret value.
@@ -1195,14 +1194,15 @@ func (r *ClientSecretNewResponse) UnmarshalJSON(data []byte) error {
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type ClientSecretNewResponseSessionUnion struct {
- // This field is from variant [RealtimeSessionCreateResponse].
- ClientSecret RealtimeSessionClientSecret `json:"client_secret"`
+ ID string `json:"id"`
+ Object string `json:"object"`
// Any of "realtime", "transcription".
Type string `json:"type"`
// This field is a union of [RealtimeSessionCreateResponseAudio],
// [RealtimeTranscriptionSessionCreateResponseAudio]
- Audio ClientSecretNewResponseSessionUnionAudio `json:"audio"`
- Include []string `json:"include"`
+ Audio ClientSecretNewResponseSessionUnionAudio `json:"audio"`
+ ExpiresAt int64 `json:"expires_at"`
+ Include []string `json:"include"`
// This field is from variant [RealtimeSessionCreateResponse].
Instructions string `json:"instructions"`
// This field is from variant [RealtimeSessionCreateResponse].
@@ -1214,6 +1214,8 @@ type ClientSecretNewResponseSessionUnion struct {
// This field is from variant [RealtimeSessionCreateResponse].
Prompt responses.ResponsePrompt `json:"prompt"`
// This field is from variant [RealtimeSessionCreateResponse].
+ Reasoning RealtimeReasoning `json:"reasoning"`
+ // This field is from variant [RealtimeSessionCreateResponse].
ToolChoice RealtimeSessionCreateResponseToolChoiceUnion `json:"tool_choice"`
// This field is from variant [RealtimeSessionCreateResponse].
Tools []RealtimeSessionCreateResponseToolUnion `json:"tools"`
@@ -1221,29 +1223,23 @@ type ClientSecretNewResponseSessionUnion struct {
Tracing RealtimeSessionCreateResponseTracingUnion `json:"tracing"`
// This field is from variant [RealtimeSessionCreateResponse].
Truncation RealtimeTruncationUnion `json:"truncation"`
- // This field is from variant [RealtimeTranscriptionSessionCreateResponse].
- ID string `json:"id"`
- // This field is from variant [RealtimeTranscriptionSessionCreateResponse].
- Object string `json:"object"`
- // This field is from variant [RealtimeTranscriptionSessionCreateResponse].
- ExpiresAt int64 `json:"expires_at"`
- JSON struct {
- ClientSecret respjson.Field
+ JSON struct {
+ ID respjson.Field
+ Object respjson.Field
Type respjson.Field
Audio respjson.Field
+ ExpiresAt respjson.Field
Include respjson.Field
Instructions respjson.Field
MaxOutputTokens respjson.Field
Model respjson.Field
OutputModalities respjson.Field
Prompt respjson.Field
+ Reasoning respjson.Field
ToolChoice respjson.Field
Tools respjson.Field
Tracing respjson.Field
Truncation respjson.Field
- ID respjson.Field
- Object respjson.Field
- ExpiresAt respjson.Field
raw string
} `json:"-"`
}
@@ -1516,6 +1512,14 @@ func (u ClientSecretNewParamsSessionUnion) GetOutputModalities() []string {
return nil
}
+// Returns a pointer to the underlying variant's property, if present.
+func (u ClientSecretNewParamsSessionUnion) GetParallelToolCalls() *bool {
+ if vt := u.OfRealtime; vt != nil && vt.ParallelToolCalls.Valid() {
+ return &vt.ParallelToolCalls.Value
+ }
+ return nil
+}
+
// Returns a pointer to the underlying variant's property, if present.
func (u ClientSecretNewParamsSessionUnion) GetPrompt() *responses.ResponsePromptParam {
if vt := u.OfRealtime; vt != nil {
@@ -1524,6 +1528,14 @@ func (u ClientSecretNewParamsSessionUnion) GetPrompt() *responses.ResponsePrompt
return nil
}
+// Returns a pointer to the underlying variant's property, if present.
+func (u ClientSecretNewParamsSessionUnion) GetReasoning() *RealtimeReasoningParam {
+ if vt := u.OfRealtime; vt != nil {
+ return &vt.Reasoning
+ }
+ return nil
+}
+
// Returns a pointer to the underlying variant's property, if present.
func (u ClientSecretNewParamsSessionUnion) GetToolChoice() *RealtimeToolChoiceConfigUnionParam {
if vt := u.OfRealtime; vt != nil {
diff --git a/vendor/github.com/openai/openai-go/v3/realtime/realtime.go b/vendor/github.com/openai/openai-go/v3/realtime/realtime.go
index b904ace3f..7f76b249d 100644
--- a/vendor/github.com/openai/openai-go/v3/realtime/realtime.go
+++ b/vendor/github.com/openai/openai-go/v3/realtime/realtime.go
@@ -37,23 +37,31 @@ func NewRealtimeService(opts ...option.RequestOption) (r RealtimeService) {
}
type AudioTranscription struct {
+ // Controls how long the model waits before emitting transcription text. Higher
+ // values can improve transcription accuracy at the cost of latency. Only supported
+ // with `gpt-realtime-whisper` in GA Realtime sessions.
+ //
+ // Any of "minimal", "low", "medium", "high", "xhigh".
+ Delay AudioTranscriptionDelay `json:"delay"`
// The language of the input audio. Supplying the input language in
// [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
// format will improve accuracy and latency.
Language string `json:"language"`
// The model to use for transcription. Current options are `whisper-1`,
// `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`,
- // `gpt-4o-transcribe`, and `gpt-4o-transcribe-diarize`. Use
- // `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.
+ // `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`.
+ // Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.
Model AudioTranscriptionModel `json:"model"`
// An optional text to guide the model's style or continue a previous audio
// segment. For `whisper-1`, the
// [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).
// For `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the
// prompt is a free text string, for example "expect words related to technology".
+ // Prompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.
Prompt string `json:"prompt"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
+ Delay respjson.Field
Language respjson.Field
Model respjson.Field
Prompt respjson.Field
@@ -77,10 +85,23 @@ func (r AudioTranscription) ToParam() AudioTranscriptionParam {
return param.Override[AudioTranscriptionParam](json.RawMessage(r.RawJSON()))
}
+// Controls how long the model waits before emitting transcription text. Higher
+// values can improve transcription accuracy at the cost of latency. Only supported
+// with `gpt-realtime-whisper` in GA Realtime sessions.
+type AudioTranscriptionDelay string
+
+const (
+ AudioTranscriptionDelayMinimal AudioTranscriptionDelay = "minimal"
+ AudioTranscriptionDelayLow AudioTranscriptionDelay = "low"
+ AudioTranscriptionDelayMedium AudioTranscriptionDelay = "medium"
+ AudioTranscriptionDelayHigh AudioTranscriptionDelay = "high"
+ AudioTranscriptionDelayXhigh AudioTranscriptionDelay = "xhigh"
+)
+
// The model to use for transcription. Current options are `whisper-1`,
// `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`,
-// `gpt-4o-transcribe`, and `gpt-4o-transcribe-diarize`. Use
-// `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.
+// `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`.
+// Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.
type AudioTranscriptionModel string
const (
@@ -89,6 +110,7 @@ const (
AudioTranscriptionModelGPT4oMiniTranscribe2025_12_15 AudioTranscriptionModel = "gpt-4o-mini-transcribe-2025-12-15"
AudioTranscriptionModelGPT4oTranscribe AudioTranscriptionModel = "gpt-4o-transcribe"
AudioTranscriptionModelGPT4oTranscribeDiarize AudioTranscriptionModel = "gpt-4o-transcribe-diarize"
+ AudioTranscriptionModelGPTRealtimeWhisper AudioTranscriptionModel = "gpt-realtime-whisper"
)
type AudioTranscriptionParam struct {
@@ -101,11 +123,18 @@ type AudioTranscriptionParam struct {
// [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).
// For `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the
// prompt is a free text string, for example "expect words related to technology".
+ // Prompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.
Prompt param.Opt[string] `json:"prompt,omitzero"`
+ // Controls how long the model waits before emitting transcription text. Higher
+ // values can improve transcription accuracy at the cost of latency. Only supported
+ // with `gpt-realtime-whisper` in GA Realtime sessions.
+ //
+ // Any of "minimal", "low", "medium", "high", "xhigh".
+ Delay AudioTranscriptionDelay `json:"delay,omitzero"`
// The model to use for transcription. Current options are `whisper-1`,
// `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`,
- // `gpt-4o-transcribe`, and `gpt-4o-transcribe-diarize`. Use
- // `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.
+ // `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`.
+ // Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.
Model AudioTranscriptionModel `json:"model,omitzero"`
paramObj
}
@@ -157,6 +186,9 @@ type RealtimeAudioConfigInputParam struct {
// trails off with "uhhm", the model will score a low probability of turn end and
// wait longer for the user to continue speaking. This can be useful for more
// natural conversations, but may have a higher latency.
+ //
+ // For `gpt-realtime-whisper` transcription sessions, turn detection must be set to
+ // `null`; VAD is not supported.
TurnDetection RealtimeAudioInputTurnDetectionUnionParam `json:"turn_detection,omitzero"`
// The format of the input audio.
Format RealtimeAudioFormatsUnionParam `json:"format,omitzero"`
@@ -851,6 +883,66 @@ func (r *RealtimeFunctionToolParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+// Configuration for reasoning-capable Realtime models such as `gpt-realtime-2`.
+type RealtimeReasoning struct {
+ // Constrains effort on reasoning for reasoning-capable Realtime models such as
+ // `gpt-realtime-2`.
+ //
+ // Any of "minimal", "low", "medium", "high", "xhigh".
+ Effort RealtimeReasoningEffort `json:"effort"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ Effort respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r RealtimeReasoning) RawJSON() string { return r.JSON.raw }
+func (r *RealtimeReasoning) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// ToParam converts this RealtimeReasoning to a RealtimeReasoningParam.
+//
+// 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
+// RealtimeReasoningParam.Overrides()
+func (r RealtimeReasoning) ToParam() RealtimeReasoningParam {
+ return param.Override[RealtimeReasoningParam](json.RawMessage(r.RawJSON()))
+}
+
+// Configuration for reasoning-capable Realtime models such as `gpt-realtime-2`.
+type RealtimeReasoningParam struct {
+ // Constrains effort on reasoning for reasoning-capable Realtime models such as
+ // `gpt-realtime-2`.
+ //
+ // Any of "minimal", "low", "medium", "high", "xhigh".
+ Effort RealtimeReasoningEffort `json:"effort,omitzero"`
+ paramObj
+}
+
+func (r RealtimeReasoningParam) MarshalJSON() (data []byte, err error) {
+ type shadow RealtimeReasoningParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *RealtimeReasoningParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// Constrains effort on reasoning for reasoning-capable Realtime models such as
+// `gpt-realtime-2`.
+type RealtimeReasoningEffort string
+
+const (
+ RealtimeReasoningEffortMinimal RealtimeReasoningEffort = "minimal"
+ RealtimeReasoningEffortLow RealtimeReasoningEffort = "low"
+ RealtimeReasoningEffortMedium RealtimeReasoningEffort = "medium"
+ RealtimeReasoningEffortHigh RealtimeReasoningEffort = "high"
+ RealtimeReasoningEffortXhigh RealtimeReasoningEffort = "xhigh"
+)
+
// Realtime session object configuration.
//
// The property Type is required.
@@ -867,6 +959,9 @@ type RealtimeSessionCreateRequestParam struct {
// is not set and are visible in the `session.created` event at the start of the
// session.
Instructions param.Opt[string] `json:"instructions,omitzero"`
+ // Whether the model may call multiple tools in parallel. Only supported by
+ // reasoning Realtime models such as `gpt-realtime-2`.
+ ParallelToolCalls param.Opt[bool] `json:"parallel_tool_calls,omitzero"`
// Reference to a prompt template and its variables.
// [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
Prompt responses.ResponsePromptParam `json:"prompt,omitzero"`
@@ -900,6 +995,8 @@ type RealtimeSessionCreateRequestParam struct {
//
// Any of "text", "audio".
OutputModalities []string `json:"output_modalities,omitzero"`
+ // Configuration for reasoning-capable Realtime models such as `gpt-realtime-2`.
+ Reasoning RealtimeReasoningParam `json:"reasoning,omitzero"`
// How the model chooses tools. Provide one of the string modes or force a specific
// function/MCP tool.
ToolChoice RealtimeToolChoiceConfigUnionParam `json:"tool_choice,omitzero"`
@@ -971,6 +1068,9 @@ type RealtimeSessionCreateRequestModel = string
const (
RealtimeSessionCreateRequestModelGPTRealtime RealtimeSessionCreateRequestModel = "gpt-realtime"
RealtimeSessionCreateRequestModelGPTRealtime1_5 RealtimeSessionCreateRequestModel = "gpt-realtime-1.5"
+ RealtimeSessionCreateRequestModelGPTRealtime2 RealtimeSessionCreateRequestModel = "gpt-realtime-2"
+ RealtimeSessionCreateRequestModelGPTRealtime2_1 RealtimeSessionCreateRequestModel = "gpt-realtime-2.1"
+ RealtimeSessionCreateRequestModelGPTRealtime2_1Mini RealtimeSessionCreateRequestModel = "gpt-realtime-2.1-mini"
RealtimeSessionCreateRequestModelGPTRealtime2025_08_28 RealtimeSessionCreateRequestModel = "gpt-realtime-2025-08-28"
RealtimeSessionCreateRequestModelGPT4oRealtimePreview RealtimeSessionCreateRequestModel = "gpt-4o-realtime-preview"
RealtimeSessionCreateRequestModelGPT4oRealtimePreview2024_10_01 RealtimeSessionCreateRequestModel = "gpt-4o-realtime-preview-2024-10-01"
@@ -1121,6 +1221,14 @@ func (u RealtimeToolsConfigUnionParam) GetServerLabel() *string {
return nil
}
+// Returns a pointer to the underlying variant's property, if present.
+func (u RealtimeToolsConfigUnionParam) GetAllowedCallers() []string {
+ if vt := u.OfMcp; vt != nil {
+ return vt.AllowedCallers
+ }
+ return nil
+}
+
// Returns a pointer to the underlying variant's property, if present.
func (u RealtimeToolsConfigUnionParam) GetAllowedTools() *RealtimeToolsConfigUnionMcpAllowedToolsParam {
if vt := u.OfMcp; vt != nil {
@@ -1185,6 +1293,14 @@ func (u RealtimeToolsConfigUnionParam) GetServerURL() *string {
return nil
}
+// Returns a pointer to the underlying variant's property, if present.
+func (u RealtimeToolsConfigUnionParam) 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 RealtimeToolsConfigUnionParam) GetType() *string {
if vt := u.OfFunction; vt != nil {
@@ -1219,9 +1335,16 @@ type RealtimeToolsConfigUnionMcpParam struct {
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` or `connector_id` must be
- // provided.
- ServerURL param.Opt[string] `json:"server_url,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 RealtimeToolsConfigUnionMcpAllowedToolsParam `json:"allowed_tools,omitzero"`
// Optional HTTP headers to send to the MCP server. Use for authentication or other
@@ -1230,8 +1353,8 @@ type RealtimeToolsConfigUnionMcpParam struct {
// Specify which of the MCP server's tools require approval.
RequireApproval RealtimeToolsConfigUnionMcpRequireApprovalParam `json:"require_approval,omitzero"`
// Identifier for service connectors, like those available in ChatGPT. One of
- // `server_url` or `connector_id` must be provided. Learn more about service
- // connectors
+ // `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:
@@ -1490,6 +1613,9 @@ type RealtimeTranscriptionSessionAudioInputParam struct {
// trails off with "uhhm", the model will score a low probability of turn end and
// wait longer for the user to continue speaking. This can be useful for more
// natural conversations, but may have a higher latency.
+ //
+ // For `gpt-realtime-whisper` transcription sessions, turn detection must be set to
+ // `null`; VAD is not supported.
TurnDetection RealtimeTranscriptionSessionAudioInputTurnDetectionUnionParam `json:"turn_detection,omitzero"`
// The PCM audio format. Only a 24kHz sample rate is supported.
Format RealtimeAudioFormatsUnionParam `json:"format,omitzero"`
diff --git a/vendor/github.com/openai/openai-go/v3/responses/aliases.go b/vendor/github.com/openai/openai-go/v3/responses/aliases.go
index eae852236..4f70078e0 100644
--- a/vendor/github.com/openai/openai-go/v3/responses/aliases.go
+++ b/vendor/github.com/openai/openai-go/v3/responses/aliases.go
@@ -64,6 +64,15 @@ const AllModelsGPT5_1CodexMax = shared.AllModelsGPT5_1CodexMax
// This is an alias to an internal type.
type ChatModel = shared.ChatModel
+// Equals "gpt-5.6-sol"
+const ChatModelGPT5_6Sol = shared.ChatModelGPT5_6Sol
+
+// Equals "gpt-5.6-terra"
+const ChatModelGPT5_6Terra = shared.ChatModelGPT5_6Terra
+
+// Equals "gpt-5.6-luna"
+const ChatModelGPT5_6Luna = shared.ChatModelGPT5_6Luna
+
// Equals "gpt-5.4"
const ChatModelGPT5_4 = shared.ChatModelGPT5_4
@@ -465,6 +474,25 @@ const OAuthErrorCodeInvalidSubjectToken = shared.OAuthErrorCodeInvalidSubjectTok
// This is an alias to an internal type.
type Reasoning = shared.Reasoning
+// 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.
+//
+// This is an alias to an internal type.
+type ReasoningContext = shared.ReasoningContext
+
+// Equals "auto"
+const ReasoningContextAuto = shared.ReasoningContextAuto
+
+// Equals "current_turn"
+const ReasoningContextCurrentTurn = shared.ReasoningContextCurrentTurn
+
+// Equals "all_turns"
+const ReasoningContextAllTurns = shared.ReasoningContextAllTurns
+
// **Deprecated:** use `summary` instead.
//
// A summary of the reasoning performed by the model. This can be useful for
@@ -483,6 +511,19 @@ const ReasoningGenerateSummaryConcise = shared.ReasoningGenerateSummaryConcise
// Equals "detailed"
const ReasoningGenerateSummaryDetailed = shared.ReasoningGenerateSummaryDetailed
+// Controls the reasoning execution mode for the request.
+//
+// When returned on a response, this is the effective execution mode.
+//
+// This is an alias to an internal type.
+type ReasoningMode = shared.ReasoningMode
+
+// Equals "standard"
+const ReasoningModeStandard = shared.ReasoningModeStandard
+
+// Equals "pro"
+const ReasoningModePro = shared.ReasoningModePro
+
// 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`.
@@ -510,19 +551,12 @@ const ReasoningSummaryDetailed = shared.ReasoningSummaryDetailed
// This is an alias to an internal type.
type ReasoningParam = shared.ReasoningParam
-// Constrains effort on reasoning for
-// [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
-// supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`.
-// Reducing reasoning effort can result in faster responses and fewer tokens used
-// on reasoning in a response.
-//
-// - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
-// reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
-// calls are supported for all reasoning values in gpt-5.1.
-// - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
-// support `none`.
-// - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
-// - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
+// 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.
//
// This is an alias to an internal type.
type ReasoningEffort = shared.ReasoningEffort
@@ -545,6 +579,9 @@ const ReasoningEffortHigh = shared.ReasoningEffortHigh
// Equals "xhigh"
const ReasoningEffortXhigh = shared.ReasoningEffortXhigh
+// Equals "max"
+const ReasoningEffortMax = shared.ReasoningEffortMax
+
// 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.
diff --git a/vendor/github.com/openai/openai-go/v3/responses/inputitem.go b/vendor/github.com/openai/openai-go/v3/responses/inputitem.go
index 3926a30f4..d8f803e39 100644
--- a/vendor/github.com/openai/openai-go/v3/responses/inputitem.go
+++ b/vendor/github.com/openai/openai-go/v3/responses/inputitem.go
@@ -5,7 +5,6 @@ package responses
import (
"context"
"errors"
- "fmt"
"net/http"
"net/url"
"slices"
@@ -42,13 +41,14 @@ func NewInputItemService(opts ...option.RequestOption) (r InputItemService) {
// Returns a list of input items for a given response.
func (r *InputItemService) List(ctx context.Context, responseID string, query InputItemListParams, opts ...option.RequestOption) (res *pagination.CursorPage[ResponseItemUnion], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
if responseID == "" {
err = errors.New("missing required response_id parameter")
return nil, err
}
- path := fmt.Sprintf("responses/%s/input_items", responseID)
+ path := requestconfig.FormatPath("responses/%s/input_items", responseID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
return nil, err
diff --git a/vendor/github.com/openai/openai-go/v3/responses/inputtoken.go b/vendor/github.com/openai/openai-go/v3/responses/inputtoken.go
index 7d86241d9..7dee27214 100644
--- a/vendor/github.com/openai/openai-go/v3/responses/inputtoken.go
+++ b/vendor/github.com/openai/openai-go/v3/responses/inputtoken.go
@@ -40,7 +40,8 @@ func NewInputTokenService(opts ...option.RequestOption) (r InputTokenService) {
// Returns an object with `object` set to `response.input_tokens` and an
// `input_tokens` count.
func (r *InputTokenService) Count(ctx context.Context, body InputTokenCountParams, opts ...option.RequestOption) (res *InputTokenCountResponse, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "responses/input_tokens"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
@@ -101,6 +102,10 @@ type InputTokenCountParams struct {
// 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.
Tools []ToolUnionParam `json:"tools,omitzero"`
+ // A model-owned style preset to apply to this request. Omit this parameter to use
+ // the model's default style. Supported values may expand over time. Values must be
+ // at most 64 characters.
+ Personality InputTokenCountParamsPersonality `json:"personality,omitzero"`
// **gpt-5 and o-series models only** Configuration options for
// [reasoning models](https://platform.openai.com/docs/guides/reasoning).
Reasoning shared.ReasoningParam `json:"reasoning,omitzero"`
@@ -173,6 +178,16 @@ func (u *InputTokenCountParamsInputUnion) asAny() any {
return nil
}
+// A model-owned style preset to apply to this request. Omit this parameter to use
+// the model's default style. Supported values may expand over time. Values must be
+// at most 64 characters.
+type InputTokenCountParamsPersonality string
+
+const (
+ InputTokenCountParamsPersonalityFriendly InputTokenCountParamsPersonality = "friendly"
+ InputTokenCountParamsPersonalityPragmatic InputTokenCountParamsPersonality = "pragmatic"
+)
+
// Configuration options for a text response from the model. Can be plain text or
// structured JSON data. Learn more:
//
@@ -181,7 +196,8 @@ func (u *InputTokenCountParamsInputUnion) asAny() any {
type InputTokenCountParamsText 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`.
+ // responses. Currently supported values are `low`, `medium`, and `high`. The
+ // default is `medium`.
//
// Any of "low", "medium", "high".
Verbosity string `json:"verbosity,omitzero"`
@@ -221,14 +237,15 @@ func init() {
// Use [param.IsOmitted] to confirm if a field is set.
type InputTokenCountParamsToolChoiceUnion struct {
// Check if union is this variant with !param.IsOmitted(union.OfToolChoiceMode)
- OfToolChoiceMode param.Opt[ToolChoiceOptions] `json:",omitzero,inline"`
- OfAllowedTools *ToolChoiceAllowedParam `json:",omitzero,inline"`
- OfHostedTool *ToolChoiceTypesParam `json:",omitzero,inline"`
- OfFunctionTool *ToolChoiceFunctionParam `json:",omitzero,inline"`
- OfMcpTool *ToolChoiceMcpParam `json:",omitzero,inline"`
- OfCustomTool *ToolChoiceCustomParam `json:",omitzero,inline"`
- OfSpecificApplyPatchToolChoice *ToolChoiceApplyPatchParam `json:",omitzero,inline"`
- OfSpecificShellToolChoice *ToolChoiceShellParam `json:",omitzero,inline"`
+ OfToolChoiceMode param.Opt[ToolChoiceOptions] `json:",omitzero,inline"`
+ OfAllowedTools *ToolChoiceAllowedParam `json:",omitzero,inline"`
+ OfHostedTool *ToolChoiceTypesParam `json:",omitzero,inline"`
+ OfFunctionTool *ToolChoiceFunctionParam `json:",omitzero,inline"`
+ OfMcpTool *ToolChoiceMcpParam `json:",omitzero,inline"`
+ OfCustomTool *ToolChoiceCustomParam `json:",omitzero,inline"`
+ OfInputTokenCountsToolChoiceSpecificProgrammaticToolCallingParam *InputTokenCountParamsToolChoiceSpecificProgrammaticToolCallingParam `json:",omitzero,inline"`
+ OfSpecificApplyPatchToolChoice *ToolChoiceApplyPatchParam `json:",omitzero,inline"`
+ OfSpecificShellToolChoice *ToolChoiceShellParam `json:",omitzero,inline"`
paramUnion
}
@@ -239,6 +256,7 @@ func (u InputTokenCountParamsToolChoiceUnion) MarshalJSON() ([]byte, error) {
u.OfFunctionTool,
u.OfMcpTool,
u.OfCustomTool,
+ u.OfInputTokenCountsToolChoiceSpecificProgrammaticToolCallingParam,
u.OfSpecificApplyPatchToolChoice,
u.OfSpecificShellToolChoice)
}
@@ -259,6 +277,8 @@ func (u *InputTokenCountParamsToolChoiceUnion) asAny() any {
return u.OfMcpTool
} else if !param.IsOmitted(u.OfCustomTool) {
return u.OfCustomTool
+ } else if !param.IsOmitted(u.OfInputTokenCountsToolChoiceSpecificProgrammaticToolCallingParam) {
+ return u.OfInputTokenCountsToolChoiceSpecificProgrammaticToolCallingParam
} else if !param.IsOmitted(u.OfSpecificApplyPatchToolChoice) {
return u.OfSpecificApplyPatchToolChoice
} else if !param.IsOmitted(u.OfSpecificShellToolChoice) {
@@ -303,6 +323,8 @@ func (u InputTokenCountParamsToolChoiceUnion) GetType() *string {
return (*string)(&vt.Type)
} else if vt := u.OfCustomTool; vt != nil {
return (*string)(&vt.Type)
+ } else if vt := u.OfInputTokenCountsToolChoiceSpecificProgrammaticToolCallingParam; vt != nil {
+ return (*string)(&vt.Type)
} else if vt := u.OfSpecificApplyPatchToolChoice; vt != nil {
return (*string)(&vt.Type)
} else if vt := u.OfSpecificShellToolChoice; vt != nil {
@@ -323,6 +345,28 @@ func (u InputTokenCountParamsToolChoiceUnion) GetName() *string {
return nil
}
+func NewInputTokenCountParamsToolChoiceSpecificProgrammaticToolCallingParam() InputTokenCountParamsToolChoiceSpecificProgrammaticToolCallingParam {
+ return InputTokenCountParamsToolChoiceSpecificProgrammaticToolCallingParam{
+ Type: "programmatic_tool_calling",
+ }
+}
+
+// This struct has a constant value, construct it with
+// [NewInputTokenCountParamsToolChoiceSpecificProgrammaticToolCallingParam].
+type InputTokenCountParamsToolChoiceSpecificProgrammaticToolCallingParam struct {
+ // The tool to call. Always `programmatic_tool_calling`.
+ Type constant.ProgrammaticToolCalling `json:"type" default:"programmatic_tool_calling"`
+ paramObj
+}
+
+func (r InputTokenCountParamsToolChoiceSpecificProgrammaticToolCallingParam) MarshalJSON() (data []byte, err error) {
+ type shadow InputTokenCountParamsToolChoiceSpecificProgrammaticToolCallingParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *InputTokenCountParamsToolChoiceSpecificProgrammaticToolCallingParam) 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
diff --git a/vendor/github.com/openai/openai-go/v3/responses/response.go b/vendor/github.com/openai/openai-go/v3/responses/response.go
index 9982dbf9b..726f952ee 100644
--- a/vendor/github.com/openai/openai-go/v3/responses/response.go
+++ b/vendor/github.com/openai/openai-go/v3/responses/response.go
@@ -6,7 +6,6 @@ import (
"context"
"encoding/json"
"errors"
- "fmt"
"net/http"
"net/url"
"slices"
@@ -59,7 +58,8 @@ func NewResponseService(opts ...option.RequestOption) (r ResponseService) {
// [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 *ResponseService) New(ctx context.Context, body ResponseNewParams, opts ...option.RequestOption) (res *Response, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "responses"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
@@ -81,7 +81,8 @@ func (r *ResponseService) NewStreaming(ctx context.Context, body ResponseNewPara
raw *http.Response
err error
)
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append(opts, option.WithJSONSet("stream", true))
path := "responses"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &raw, opts...)
@@ -90,12 +91,13 @@ func (r *ResponseService) NewStreaming(ctx context.Context, body ResponseNewPara
// Retrieves a model response with the given ID.
func (r *ResponseService) Get(ctx context.Context, responseID string, query ResponseGetParams, opts ...option.RequestOption) (res *Response, err error) {
- opts = slices.Concat(r.Options, opts)
+ 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 := fmt.Sprintf("responses/%s", responseID)
+ path := requestconfig.FormatPath("responses/%s", responseID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
return res, err
}
@@ -106,26 +108,28 @@ func (r *ResponseService) GetStreaming(ctx context.Context, responseID string, q
raw *http.Response
err error
)
- opts = slices.Concat(r.Options, opts)
+ 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[ResponseStreamEventUnion](nil, err)
}
- path := fmt.Sprintf("responses/%s", responseID)
+ path := requestconfig.FormatPath("responses/%s", responseID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &raw, opts...)
return ssestream.NewStream[ResponseStreamEventUnion](ssestream.NewDecoder(raw), err)
}
// Deletes a model response with the given ID.
func (r *ResponseService) Delete(ctx context.Context, responseID string, opts ...option.RequestOption) (err error) {
- opts = slices.Concat(r.Options, opts)
+ 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 := fmt.Sprintf("responses/%s", responseID)
+ path := requestconfig.FormatPath("responses/%s", responseID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...)
return err
}
@@ -134,12 +138,13 @@ func (r *ResponseService) Delete(ctx context.Context, responseID string, opts ..
// `background` parameter set to `true` can be cancelled.
// [Learn more](https://platform.openai.com/docs/guides/background).
func (r *ResponseService) Cancel(ctx context.Context, responseID string, opts ...option.RequestOption) (res *Response, err error) {
- opts = slices.Concat(r.Options, opts)
+ 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 := fmt.Sprintf("responses/%s/cancel", responseID)
+ path := requestconfig.FormatPath("responses/%s/cancel", responseID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
return res, err
}
@@ -151,7 +156,8 @@ func (r *ResponseService) Cancel(ctx context.Context, responseID string, opts ..
// For ZDR-compatible compaction details, see
// [Compaction (advanced)](https://platform.openai.com/docs/guides/conversation-state#compaction-advanced).
func (r *ResponseService) Compact(ctx context.Context, body ResponseCompactParams, opts ...option.RequestOption) (res *CompactedResponse, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "responses/compact"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
@@ -161,11 +167,16 @@ func (r *ResponseService) Compact(ctx context.Context, body ResponseCompactParam
type ApplyPatchTool 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
- ExtraFields map[string]respjson.Field
- raw string
+ Type respjson.Field
+ AllowedCallers respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
} `json:"-"`
}
@@ -184,17 +195,17 @@ func (r ApplyPatchTool) ToParam() ApplyPatchToolParam {
return param.Override[ApplyPatchToolParam](json.RawMessage(r.RawJSON()))
}
-func NewApplyPatchToolParam() ApplyPatchToolParam {
- return ApplyPatchToolParam{
- Type: "apply_patch",
- }
-}
-
// Allows the assistant to create, delete, or update files using unified diffs.
//
-// This struct has a constant value, construct it with [NewApplyPatchToolParam].
+// The property Type is required.
type ApplyPatchToolParam 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
}
@@ -211,7 +222,7 @@ type CompactedResponse 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"`
+ 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,
@@ -1847,6 +1858,10 @@ type CustomTool struct {
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.
@@ -1855,13 +1870,14 @@ type CustomTool struct {
Format shared.CustomToolInputFormatUnion `json:"format"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
- Name respjson.Field
- Type respjson.Field
- DeferLoading respjson.Field
- Description respjson.Field
- Format respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
+ 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:"-"`
}
@@ -1891,6 +1907,10 @@ type CustomToolParam struct {
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 shared.CustomToolInputFormatUnionParam `json:"format,omitzero"`
// The type of the custom tool. Always `custom`.
@@ -2361,14 +2381,19 @@ func (r *FileSearchToolRankingOptionsHybridSearchParam) UnmarshalJSON(data []byt
// A tool that allows the model to execute shell commands.
type FunctionShellTool struct {
// The type of the shell tool. Always `shell`.
- Type constant.Shell `json:"type" default:"shell"`
- Environment FunctionShellToolEnvironmentUnion `json:"environment" api:"nullable"`
+ Type constant.Shell `json:"type" default:"shell"`
+ // The tool invocation context(s).
+ //
+ // Any of "direct", "programmatic".
+ AllowedCallers []string `json:"allowed_callers" api:"nullable"`
+ Environment FunctionShellToolEnvironmentUnion `json:"environment" api:"nullable"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
- Type respjson.Field
- Environment respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
+ Type respjson.Field
+ AllowedCallers respjson.Field
+ Environment respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
} `json:"-"`
}
@@ -2503,7 +2528,11 @@ func (r *FunctionShellToolEnvironmentUnionSkills) UnmarshalJSON(data []byte) err
//
// The property Type is required.
type FunctionShellToolParam struct {
- Environment FunctionShellToolEnvironmentUnionParam `json:"environment,omitzero"`
+ // The tool invocation context(s).
+ //
+ // Any of "direct", "programmatic".
+ AllowedCallers []string `json:"allowed_callers,omitzero"`
+ Environment FunctionShellToolEnvironmentUnionParam `json:"environment,omitzero"`
// The type of the shell tool. Always `shell`.
//
// This field can be elided, and will marshal its zero value as "shell".
@@ -2634,25 +2663,34 @@ type FunctionTool struct {
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 to enforce strict parameter validation. Default `true`.
+ // 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
- DeferLoading respjson.Field
- Description respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
+ 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:"-"`
}
@@ -2677,7 +2715,7 @@ func (r FunctionTool) ToParam() FunctionToolParam {
//
// The properties Name, Parameters, Strict, Type are required.
type FunctionToolParam struct {
- // Whether to enforce strict parameter validation. Default `true`.
+ // 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"`
@@ -2688,6 +2726,13 @@ type FunctionToolParam struct {
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".
@@ -2963,9 +3008,12 @@ func (r NamespaceTool) ToParam() NamespaceToolParam {
type NamespaceToolToolUnion struct {
Name string `json:"name"`
// Any of "function", "custom".
- Type string `json:"type"`
- DeferLoading bool `json:"defer_loading"`
- Description string `json:"description"`
+ Type string `json:"type"`
+ AllowedCallers []string `json:"allowed_callers"`
+ DeferLoading bool `json:"defer_loading"`
+ Description string `json:"description"`
+ // This field is from variant [NamespaceToolToolFunction].
+ OutputSchema map[string]any `json:"output_schema"`
// This field is from variant [NamespaceToolToolFunction].
Parameters any `json:"parameters"`
// This field is from variant [NamespaceToolToolFunction].
@@ -2973,14 +3021,16 @@ type NamespaceToolToolUnion struct {
// This field is from variant [CustomTool].
Format shared.CustomToolInputFormatUnion `json:"format"`
JSON struct {
- Name respjson.Field
- Type respjson.Field
- DeferLoading respjson.Field
- Description respjson.Field
- Parameters respjson.Field
- Strict respjson.Field
- Format respjson.Field
- raw string
+ 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:"-"`
}
@@ -3031,21 +3081,33 @@ func (r *NamespaceToolToolUnion) UnmarshalJSON(data []byte) error {
type NamespaceToolToolFunction 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"`
- Parameters any `json:"parameters" api:"nullable"`
- Strict bool `json:"strict" 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
- DeferLoading respjson.Field
- Description respjson.Field
- Parameters respjson.Field
- Strict respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
+ 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:"-"`
}
@@ -3105,6 +3167,14 @@ func (u *NamespaceToolToolUnionParam) asAny() any {
return nil
}
+// Returns a pointer to the underlying variant's property, if present.
+func (u NamespaceToolToolUnionParam) 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 NamespaceToolToolUnionParam) GetParameters() *any {
if vt := u.OfFunction; vt != nil {
@@ -3169,6 +3239,17 @@ func (u NamespaceToolToolUnionParam) GetDescription() *string {
return nil
}
+// Returns a pointer to the underlying variant's AllowedCallers property, if
+// present.
+func (u NamespaceToolToolUnionParam) 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[NamespaceToolToolUnionParam](
"type",
@@ -3181,10 +3262,20 @@ func init() {
type NamespaceToolToolFunctionParam struct {
Name string `json:"name" api:"required"`
Description param.Opt[string] `json:"description,omitzero"`
- Strict param.Opt[bool] `json:"strict,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"`
- Parameters any `json:"parameters,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
@@ -3202,7 +3293,7 @@ type Response 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"`
+ CreatedAt float64 `json:"created_at" api:"required" format:"unixtime"`
// An error object returned when the model fails to generate a Response.
Error ResponseError `json:"error" api:"required"`
// Details about why the response is incomplete.
@@ -3278,7 +3369,7 @@ type Response struct {
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"`
+ 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 ResponseConversation `json:"conversation" api:"nullable"`
@@ -3291,6 +3382,9 @@ type Response struct {
// 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 ResponseModeration `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).
@@ -3302,13 +3396,31 @@ type Response struct {
// 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"`
+ 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 ResponsePromptCacheOptions `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".
//
- // Any of "in-memory", "24h".
+ // Deprecated: deprecated
PromptCacheRetention ResponsePromptCacheRetention `json:"prompt_cache_retention" api:"nullable"`
// **gpt-5 and o-series models only**
//
@@ -3321,7 +3433,7 @@ type Response struct {
// 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"`
+ 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
@@ -3353,8 +3465,9 @@ type Response struct {
// - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
// - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
Text ResponseTextConfig `json:"text"`
- // An integer between 0 and 20 specifying the number of most likely tokens to
- // return at each token position, each with an associated log probability.
+ // 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.
//
@@ -3398,9 +3511,11 @@ type Response struct {
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
@@ -3494,6 +3609,7 @@ func (r *ResponseInstructionsUnion) UnmarshalJSON(data []byte) error {
// ResponseToolChoiceUnion contains all possible properties and values from
// [ToolChoiceOptions], [ToolChoiceAllowed], [ToolChoiceTypes],
// [ToolChoiceFunction], [ToolChoiceMcp], [ToolChoiceCustom],
+// [ResponseToolChoiceSpecificProgrammaticToolCallingParam],
// [ToolChoiceApplyPatch], [ToolChoiceShell].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
@@ -3553,6 +3669,11 @@ func (u ResponseToolChoiceUnion) AsCustomTool() (v ToolChoiceCustom) {
return
}
+func (u ResponseToolChoiceUnion) AsResponseToolChoiceSpecificProgrammaticToolCallingParam() (v ResponseToolChoiceSpecificProgrammaticToolCallingParam) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
func (u ResponseToolChoiceUnion) AsSpecificApplyPatchToolChoice() (v ToolChoiceApplyPatch) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
@@ -3570,6 +3691,23 @@ func (r *ResponseToolChoiceUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+type ResponseToolChoiceSpecificProgrammaticToolCallingParam 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 ResponseToolChoiceSpecificProgrammaticToolCallingParam) RawJSON() string { return r.JSON.raw }
+func (r *ResponseToolChoiceSpecificProgrammaticToolCallingParam) 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 ResponseConversation struct {
@@ -3589,14 +3727,355 @@ func (r *ResponseConversation) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+// Moderation results for the response input and output, if moderated completions
+// were requested.
+type ResponseModeration struct {
+ // Moderation for the response input.
+ Input ResponseModerationInputUnion `json:"input" api:"required"`
+ // Moderation for the response output.
+ Output ResponseModerationOutputUnion `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 ResponseModeration) RawJSON() string { return r.JSON.raw }
+func (r *ResponseModeration) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// ResponseModerationInputUnion contains all possible properties and values from
+// [ResponseModerationInputModerationResult], [ResponseModerationInputError].
+//
+// Use the [ResponseModerationInputUnion.AsAny] method to switch on the variant.
+//
+// Use the methods beginning with 'As' to cast the union to one of its variants.
+type ResponseModerationInputUnion struct {
+ // This field is from variant [ResponseModerationInputModerationResult].
+ Categories map[string]bool `json:"categories"`
+ // This field is from variant [ResponseModerationInputModerationResult].
+ CategoryAppliedInputTypes map[string][]string `json:"category_applied_input_types"`
+ // This field is from variant [ResponseModerationInputModerationResult].
+ CategoryScores map[string]float64 `json:"category_scores"`
+ // This field is from variant [ResponseModerationInputModerationResult].
+ Flagged bool `json:"flagged"`
+ // This field is from variant [ResponseModerationInputModerationResult].
+ Model string `json:"model"`
+ // Any of "moderation_result", "error".
+ Type string `json:"type"`
+ // This field is from variant [ResponseModerationInputError].
+ Code string `json:"code"`
+ // This field is from variant [ResponseModerationInputError].
+ 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:"-"`
+}
+
+// anyResponseModerationInput is implemented by each variant of
+// [ResponseModerationInputUnion] to add type safety for the return type of
+// [ResponseModerationInputUnion.AsAny]
+type anyResponseModerationInput interface {
+ implResponseModerationInputUnion()
+}
+
+func (ResponseModerationInputModerationResult) implResponseModerationInputUnion() {}
+func (ResponseModerationInputError) implResponseModerationInputUnion() {}
+
+// Use the following switch statement to find the correct variant
+//
+// switch variant := ResponseModerationInputUnion.AsAny().(type) {
+// case responses.ResponseModerationInputModerationResult:
+// case responses.ResponseModerationInputError:
+// default:
+// fmt.Errorf("no variant present")
+// }
+func (u ResponseModerationInputUnion) AsAny() anyResponseModerationInput {
+ switch u.Type {
+ case "moderation_result":
+ return u.AsModerationResult()
+ case "error":
+ return u.AsError()
+ }
+ return nil
+}
+
+func (u ResponseModerationInputUnion) AsModerationResult() (v ResponseModerationInputModerationResult) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseModerationInputUnion) AsError() (v ResponseModerationInputError) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+// Returns the unmodified JSON received from the API
+func (u ResponseModerationInputUnion) RawJSON() string { return u.JSON.raw }
+
+func (r *ResponseModerationInputUnion) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// A moderation result produced for the response input or output.
+type ResponseModerationInputModerationResult 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 ResponseModerationInputModerationResult) RawJSON() string { return r.JSON.raw }
+func (r *ResponseModerationInputModerationResult) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// An error produced while attempting moderation for the response input or output.
+type ResponseModerationInputError 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 ResponseModerationInputError) RawJSON() string { return r.JSON.raw }
+func (r *ResponseModerationInputError) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// ResponseModerationOutputUnion contains all possible properties and values from
+// [ResponseModerationOutputModerationResult], [ResponseModerationOutputError].
+//
+// Use the [ResponseModerationOutputUnion.AsAny] method to switch on the variant.
+//
+// Use the methods beginning with 'As' to cast the union to one of its variants.
+type ResponseModerationOutputUnion struct {
+ // This field is from variant [ResponseModerationOutputModerationResult].
+ Categories map[string]bool `json:"categories"`
+ // This field is from variant [ResponseModerationOutputModerationResult].
+ CategoryAppliedInputTypes map[string][]string `json:"category_applied_input_types"`
+ // This field is from variant [ResponseModerationOutputModerationResult].
+ CategoryScores map[string]float64 `json:"category_scores"`
+ // This field is from variant [ResponseModerationOutputModerationResult].
+ Flagged bool `json:"flagged"`
+ // This field is from variant [ResponseModerationOutputModerationResult].
+ Model string `json:"model"`
+ // Any of "moderation_result", "error".
+ Type string `json:"type"`
+ // This field is from variant [ResponseModerationOutputError].
+ Code string `json:"code"`
+ // This field is from variant [ResponseModerationOutputError].
+ 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:"-"`
+}
+
+// anyResponseModerationOutput is implemented by each variant of
+// [ResponseModerationOutputUnion] to add type safety for the return type of
+// [ResponseModerationOutputUnion.AsAny]
+type anyResponseModerationOutput interface {
+ implResponseModerationOutputUnion()
+}
+
+func (ResponseModerationOutputModerationResult) implResponseModerationOutputUnion() {}
+func (ResponseModerationOutputError) implResponseModerationOutputUnion() {}
+
+// Use the following switch statement to find the correct variant
+//
+// switch variant := ResponseModerationOutputUnion.AsAny().(type) {
+// case responses.ResponseModerationOutputModerationResult:
+// case responses.ResponseModerationOutputError:
+// default:
+// fmt.Errorf("no variant present")
+// }
+func (u ResponseModerationOutputUnion) AsAny() anyResponseModerationOutput {
+ switch u.Type {
+ case "moderation_result":
+ return u.AsModerationResult()
+ case "error":
+ return u.AsError()
+ }
+ return nil
+}
+
+func (u ResponseModerationOutputUnion) AsModerationResult() (v ResponseModerationOutputModerationResult) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseModerationOutputUnion) AsError() (v ResponseModerationOutputError) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+// Returns the unmodified JSON received from the API
+func (u ResponseModerationOutputUnion) RawJSON() string { return u.JSON.raw }
+
+func (r *ResponseModerationOutputUnion) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// A moderation result produced for the response input or output.
+type ResponseModerationOutputModerationResult 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 ResponseModerationOutputModerationResult) RawJSON() string { return r.JSON.raw }
+func (r *ResponseModerationOutputModerationResult) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// An error produced while attempting moderation for the response input or output.
+type ResponseModerationOutputError 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 ResponseModerationOutputError) RawJSON() string { return r.JSON.raw }
+func (r *ResponseModerationOutputError) 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 ResponsePromptCacheOptions 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 ResponsePromptCacheOptions) RawJSON() string { return r.JSON.raw }
+func (r *ResponsePromptCacheOptions) 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 ResponsePromptCacheRetention string
const (
- ResponsePromptCacheRetentionInMemory ResponsePromptCacheRetention = "in-memory"
+ ResponsePromptCacheRetentionInMemory ResponsePromptCacheRetention = "in_memory"
ResponsePromptCacheRetention24h ResponsePromptCacheRetention = "24h"
)
@@ -3656,6 +4135,8 @@ type ResponseApplyPatchToolCall struct {
Status ResponseApplyPatchToolCallStatus `json:"status" api:"required"`
// The type of the item. Always `apply_patch_call`.
Type constant.ApplyPatchCall `json:"type" default:"apply_patch_call"`
+ // The execution context that produced this tool call.
+ Caller ResponseApplyPatchToolCallCallerUnion `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].
@@ -3665,6 +4146,7 @@ type ResponseApplyPatchToolCall struct {
Operation respjson.Field
Status respjson.Field
Type respjson.Field
+ Caller respjson.Field
CreatedBy respjson.Field
ExtraFields map[string]respjson.Field
raw string
@@ -3832,19 +4314,121 @@ const (
ResponseApplyPatchToolCallStatusCompleted ResponseApplyPatchToolCallStatus = "completed"
)
-// The output emitted by an apply patch tool call.
-type ResponseApplyPatchToolCallOutput 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".
+// ResponseApplyPatchToolCallCallerUnion contains all possible properties and
+// values from [ResponseApplyPatchToolCallCallerDirect],
+// [ResponseApplyPatchToolCallCallerProgram].
+//
+// Use the [ResponseApplyPatchToolCallCallerUnion.AsAny] method to switch on the
+// variant.
+//
+// Use the methods beginning with 'As' to cast the union to one of its variants.
+type ResponseApplyPatchToolCallCallerUnion struct {
+ // Any of "direct", "program".
+ Type string `json:"type"`
+ // This field is from variant [ResponseApplyPatchToolCallCallerProgram].
+ CallerID string `json:"caller_id"`
+ JSON struct {
+ Type respjson.Field
+ CallerID respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// anyResponseApplyPatchToolCallCaller is implemented by each variant of
+// [ResponseApplyPatchToolCallCallerUnion] to add type safety for the return type
+// of [ResponseApplyPatchToolCallCallerUnion.AsAny]
+type anyResponseApplyPatchToolCallCaller interface {
+ implResponseApplyPatchToolCallCallerUnion()
+}
+
+func (ResponseApplyPatchToolCallCallerDirect) implResponseApplyPatchToolCallCallerUnion() {}
+func (ResponseApplyPatchToolCallCallerProgram) implResponseApplyPatchToolCallCallerUnion() {}
+
+// Use the following switch statement to find the correct variant
+//
+// switch variant := ResponseApplyPatchToolCallCallerUnion.AsAny().(type) {
+// case responses.ResponseApplyPatchToolCallCallerDirect:
+// case responses.ResponseApplyPatchToolCallCallerProgram:
+// default:
+// fmt.Errorf("no variant present")
+// }
+func (u ResponseApplyPatchToolCallCallerUnion) AsAny() anyResponseApplyPatchToolCallCaller {
+ switch u.Type {
+ case "direct":
+ return u.AsDirect()
+ case "program":
+ return u.AsProgram()
+ }
+ return nil
+}
+
+func (u ResponseApplyPatchToolCallCallerUnion) AsDirect() (v ResponseApplyPatchToolCallCallerDirect) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseApplyPatchToolCallCallerUnion) AsProgram() (v ResponseApplyPatchToolCallCallerProgram) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+// Returns the unmodified JSON received from the API
+func (u ResponseApplyPatchToolCallCallerUnion) RawJSON() string { return u.JSON.raw }
+
+func (r *ResponseApplyPatchToolCallCallerUnion) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseApplyPatchToolCallCallerDirect 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 ResponseApplyPatchToolCallCallerDirect) RawJSON() string { return r.JSON.raw }
+func (r *ResponseApplyPatchToolCallCallerDirect) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseApplyPatchToolCallCallerProgram 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 ResponseApplyPatchToolCallCallerProgram) RawJSON() string { return r.JSON.raw }
+func (r *ResponseApplyPatchToolCallCallerProgram) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// The output emitted by an apply patch tool call.
+type ResponseApplyPatchToolCallOutput 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 ResponseApplyPatchToolCallOutputStatus `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 execution context that produced this tool call.
+ Caller ResponseApplyPatchToolCallOutputCallerUnion `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.
@@ -3855,6 +4439,7 @@ type ResponseApplyPatchToolCallOutput struct {
CallID respjson.Field
Status respjson.Field
Type respjson.Field
+ Caller respjson.Field
CreatedBy respjson.Field
Output respjson.Field
ExtraFields map[string]respjson.Field
@@ -3878,6 +4463,108 @@ const (
ResponseApplyPatchToolCallOutputStatusFailed ResponseApplyPatchToolCallOutputStatus = "failed"
)
+// ResponseApplyPatchToolCallOutputCallerUnion contains all possible properties and
+// values from [ResponseApplyPatchToolCallOutputCallerDirect],
+// [ResponseApplyPatchToolCallOutputCallerProgram].
+//
+// Use the [ResponseApplyPatchToolCallOutputCallerUnion.AsAny] method to switch on
+// the variant.
+//
+// Use the methods beginning with 'As' to cast the union to one of its variants.
+type ResponseApplyPatchToolCallOutputCallerUnion struct {
+ // Any of "direct", "program".
+ Type string `json:"type"`
+ // This field is from variant [ResponseApplyPatchToolCallOutputCallerProgram].
+ CallerID string `json:"caller_id"`
+ JSON struct {
+ Type respjson.Field
+ CallerID respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// anyResponseApplyPatchToolCallOutputCaller is implemented by each variant of
+// [ResponseApplyPatchToolCallOutputCallerUnion] to add type safety for the return
+// type of [ResponseApplyPatchToolCallOutputCallerUnion.AsAny]
+type anyResponseApplyPatchToolCallOutputCaller interface {
+ implResponseApplyPatchToolCallOutputCallerUnion()
+}
+
+func (ResponseApplyPatchToolCallOutputCallerDirect) implResponseApplyPatchToolCallOutputCallerUnion() {
+}
+func (ResponseApplyPatchToolCallOutputCallerProgram) implResponseApplyPatchToolCallOutputCallerUnion() {
+}
+
+// Use the following switch statement to find the correct variant
+//
+// switch variant := ResponseApplyPatchToolCallOutputCallerUnion.AsAny().(type) {
+// case responses.ResponseApplyPatchToolCallOutputCallerDirect:
+// case responses.ResponseApplyPatchToolCallOutputCallerProgram:
+// default:
+// fmt.Errorf("no variant present")
+// }
+func (u ResponseApplyPatchToolCallOutputCallerUnion) AsAny() anyResponseApplyPatchToolCallOutputCaller {
+ switch u.Type {
+ case "direct":
+ return u.AsDirect()
+ case "program":
+ return u.AsProgram()
+ }
+ return nil
+}
+
+func (u ResponseApplyPatchToolCallOutputCallerUnion) AsDirect() (v ResponseApplyPatchToolCallOutputCallerDirect) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseApplyPatchToolCallOutputCallerUnion) AsProgram() (v ResponseApplyPatchToolCallOutputCallerProgram) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+// Returns the unmodified JSON received from the API
+func (u ResponseApplyPatchToolCallOutputCallerUnion) RawJSON() string { return u.JSON.raw }
+
+func (r *ResponseApplyPatchToolCallOutputCallerUnion) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseApplyPatchToolCallOutputCallerDirect 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 ResponseApplyPatchToolCallOutputCallerDirect) RawJSON() string { return r.JSON.raw }
+func (r *ResponseApplyPatchToolCallOutputCallerDirect) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseApplyPatchToolCallOutputCallerProgram 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 ResponseApplyPatchToolCallOutputCallerProgram) RawJSON() string { return r.JSON.raw }
+func (r *ResponseApplyPatchToolCallOutputCallerProgram) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// Emitted when there is a partial audio response.
type ResponseAudioDeltaEvent struct {
// A chunk of Base64 encoded response audio bytes.
@@ -4256,7 +4943,7 @@ type ResponseCodeInterpreterToolCallOutputImage 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"`
+ URL string `json:"url" api:"required" format:"uri"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Type respjson.Field
@@ -4403,7 +5090,7 @@ func (r *ResponseCodeInterpreterToolCallOutputLogsParam) UnmarshalJSON(data []by
// The properties Type, URL are required.
type ResponseCodeInterpreterToolCallOutputImageParam struct {
// The URL of the image output from the code interpreter.
- URL string `json:"url" api:"required"`
+ 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".
@@ -5632,7 +6319,7 @@ type ResponseComputerToolCallOutputScreenshot struct {
// 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"`
+ ImageURL string `json:"image_url" format:"uri"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Type respjson.Field
@@ -5666,7 +6353,7 @@ type ResponseComputerToolCallOutputScreenshotParam 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"`
+ 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`.
//
@@ -6029,6 +6716,8 @@ type ResponseCustomToolCall struct {
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 execution context that produced this tool call.
+ Caller ResponseCustomToolCallCallerUnion `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].
@@ -6038,6 +6727,7 @@ type ResponseCustomToolCall struct {
Name respjson.Field
Type respjson.Field
ID respjson.Field
+ Caller respjson.Field
Namespace respjson.Field
ExtraFields map[string]respjson.Field
raw string
@@ -6061,6 +6751,106 @@ func (r ResponseCustomToolCall) ToParam() ResponseCustomToolCallParam {
return param.Override[ResponseCustomToolCallParam](json.RawMessage(r.RawJSON()))
}
+// ResponseCustomToolCallCallerUnion contains all possible properties and values
+// from [ResponseCustomToolCallCallerDirect],
+// [ResponseCustomToolCallCallerProgram].
+//
+// Use the [ResponseCustomToolCallCallerUnion.AsAny] method to switch on the
+// variant.
+//
+// Use the methods beginning with 'As' to cast the union to one of its variants.
+type ResponseCustomToolCallCallerUnion struct {
+ // Any of "direct", "program".
+ Type string `json:"type"`
+ // This field is from variant [ResponseCustomToolCallCallerProgram].
+ CallerID string `json:"caller_id"`
+ JSON struct {
+ Type respjson.Field
+ CallerID respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// anyResponseCustomToolCallCaller is implemented by each variant of
+// [ResponseCustomToolCallCallerUnion] to add type safety for the return type of
+// [ResponseCustomToolCallCallerUnion.AsAny]
+type anyResponseCustomToolCallCaller interface {
+ implResponseCustomToolCallCallerUnion()
+}
+
+func (ResponseCustomToolCallCallerDirect) implResponseCustomToolCallCallerUnion() {}
+func (ResponseCustomToolCallCallerProgram) implResponseCustomToolCallCallerUnion() {}
+
+// Use the following switch statement to find the correct variant
+//
+// switch variant := ResponseCustomToolCallCallerUnion.AsAny().(type) {
+// case responses.ResponseCustomToolCallCallerDirect:
+// case responses.ResponseCustomToolCallCallerProgram:
+// default:
+// fmt.Errorf("no variant present")
+// }
+func (u ResponseCustomToolCallCallerUnion) AsAny() anyResponseCustomToolCallCaller {
+ switch u.Type {
+ case "direct":
+ return u.AsDirect()
+ case "program":
+ return u.AsProgram()
+ }
+ return nil
+}
+
+func (u ResponseCustomToolCallCallerUnion) AsDirect() (v ResponseCustomToolCallCallerDirect) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseCustomToolCallCallerUnion) AsProgram() (v ResponseCustomToolCallCallerProgram) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+// Returns the unmodified JSON received from the API
+func (u ResponseCustomToolCallCallerUnion) RawJSON() string { return u.JSON.raw }
+
+func (r *ResponseCustomToolCallCallerUnion) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseCustomToolCallCallerDirect 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 ResponseCustomToolCallCallerDirect) RawJSON() string { return r.JSON.raw }
+func (r *ResponseCustomToolCallCallerDirect) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseCustomToolCallCallerProgram 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 ResponseCustomToolCallCallerProgram) RawJSON() string { return r.JSON.raw }
+func (r *ResponseCustomToolCallCallerProgram) 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.
@@ -6075,6 +6865,8 @@ type ResponseCustomToolCallParam struct {
ID param.Opt[string] `json:"id,omitzero"`
// The namespace of the custom tool being called.
Namespace param.Opt[string] `json:"namespace,omitzero"`
+ // The execution context that produced this tool call.
+ Caller ResponseCustomToolCallCallerUnionParam `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".
@@ -6090,6 +6882,95 @@ func (r *ResponseCustomToolCallParam) 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 ResponseCustomToolCallCallerUnionParam struct {
+ OfDirect *ResponseCustomToolCallCallerDirectParam `json:",omitzero,inline"`
+ OfProgram *ResponseCustomToolCallCallerProgramParam `json:",omitzero,inline"`
+ paramUnion
+}
+
+func (u ResponseCustomToolCallCallerUnionParam) MarshalJSON() ([]byte, error) {
+ return param.MarshalUnion(u, u.OfDirect, u.OfProgram)
+}
+func (u *ResponseCustomToolCallCallerUnionParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, u)
+}
+
+func (u *ResponseCustomToolCallCallerUnionParam) 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 ResponseCustomToolCallCallerUnionParam) 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 ResponseCustomToolCallCallerUnionParam) 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[ResponseCustomToolCallCallerUnionParam](
+ "type",
+ apijson.Discriminator[ResponseCustomToolCallCallerDirectParam]("direct"),
+ apijson.Discriminator[ResponseCustomToolCallCallerProgramParam]("program"),
+ )
+}
+
+func NewResponseCustomToolCallCallerDirectParam() ResponseCustomToolCallCallerDirectParam {
+ return ResponseCustomToolCallCallerDirectParam{
+ Type: "direct",
+ }
+}
+
+// This struct has a constant value, construct it with
+// [NewResponseCustomToolCallCallerDirectParam].
+type ResponseCustomToolCallCallerDirectParam struct {
+ Type constant.Direct `json:"type" default:"direct"`
+ paramObj
+}
+
+func (r ResponseCustomToolCallCallerDirectParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseCustomToolCallCallerDirectParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseCustomToolCallCallerDirectParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// The properties CallerID, Type are required.
+type ResponseCustomToolCallCallerProgramParam 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 ResponseCustomToolCallCallerProgramParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseCustomToolCallCallerProgramParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseCustomToolCallCallerProgramParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// Event representing a delta (partial update) to the input of a custom tool call.
type ResponseCustomToolCallInputDeltaEvent struct {
// The incremental input data (delta) for the custom tool call.
@@ -6189,12 +7070,15 @@ type ResponseCustomToolCallOutput struct {
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 execution context that produced this tool call.
+ Caller ResponseCustomToolCallOutputCallerUnion `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
+ Caller respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
@@ -6269,9 +7153,13 @@ type ResponseCustomToolCallOutputOutputOutputContentListItemUnion struct {
// This field is from variant [ResponseInputText].
Text string `json:"text"`
// Any of "input_text", "input_image", "input_file".
- Type string `json:"type"`
- Detail string `json:"detail"`
- FileID string `json:"file_id"`
+ Type string `json:"type"`
+ // This field is a union of [ResponseInputTextPromptCacheBreakpoint],
+ // [ResponseInputImagePromptCacheBreakpoint],
+ // [ResponseInputFilePromptCacheBreakpoint]
+ PromptCacheBreakpoint ResponseCustomToolCallOutputOutputOutputContentListItemUnionPromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
+ Detail string `json:"detail"`
+ FileID string `json:"file_id"`
// This field is from variant [ResponseInputImage].
ImageURL string `json:"image_url"`
// This field is from variant [ResponseInputFile].
@@ -6281,15 +7169,16 @@ type ResponseCustomToolCallOutputOutputOutputContentListItemUnion struct {
// This field is from variant [ResponseInputFile].
Filename string `json:"filename"`
JSON struct {
- Text respjson.Field
- Type respjson.Field
- Detail respjson.Field
- FileID respjson.Field
- ImageURL respjson.Field
- FileData respjson.Field
- FileURL respjson.Field
- Filename respjson.Field
- raw string
+ 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:"-"`
}
@@ -6350,6 +7239,129 @@ func (r *ResponseCustomToolCallOutputOutputOutputContentListItemUnion) Unmarshal
return apijson.UnmarshalRoot(data, r)
}
+// ResponseCustomToolCallOutputOutputOutputContentListItemUnionPromptCacheBreakpoint
+// is an implicit subunion of
+// [ResponseCustomToolCallOutputOutputOutputContentListItemUnion].
+// ResponseCustomToolCallOutputOutputOutputContentListItemUnionPromptCacheBreakpoint
+// provides convenient access to the sub-properties of the union.
+//
+// For type safety it is recommended to directly use a variant of the
+// [ResponseCustomToolCallOutputOutputOutputContentListItemUnion].
+type ResponseCustomToolCallOutputOutputOutputContentListItemUnionPromptCacheBreakpoint struct {
+ // This field is from variant [ResponseInputTextPromptCacheBreakpoint].
+ Mode constant.Explicit `json:"mode"`
+ JSON struct {
+ Mode respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+func (r *ResponseCustomToolCallOutputOutputOutputContentListItemUnionPromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// ResponseCustomToolCallOutputCallerUnion contains all possible properties and
+// values from [ResponseCustomToolCallOutputCallerDirect],
+// [ResponseCustomToolCallOutputCallerProgram].
+//
+// Use the [ResponseCustomToolCallOutputCallerUnion.AsAny] method to switch on the
+// variant.
+//
+// Use the methods beginning with 'As' to cast the union to one of its variants.
+type ResponseCustomToolCallOutputCallerUnion struct {
+ // Any of "direct", "program".
+ Type string `json:"type"`
+ // This field is from variant [ResponseCustomToolCallOutputCallerProgram].
+ CallerID string `json:"caller_id"`
+ JSON struct {
+ Type respjson.Field
+ CallerID respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// anyResponseCustomToolCallOutputCaller is implemented by each variant of
+// [ResponseCustomToolCallOutputCallerUnion] to add type safety for the return type
+// of [ResponseCustomToolCallOutputCallerUnion.AsAny]
+type anyResponseCustomToolCallOutputCaller interface {
+ implResponseCustomToolCallOutputCallerUnion()
+}
+
+func (ResponseCustomToolCallOutputCallerDirect) implResponseCustomToolCallOutputCallerUnion() {}
+func (ResponseCustomToolCallOutputCallerProgram) implResponseCustomToolCallOutputCallerUnion() {}
+
+// Use the following switch statement to find the correct variant
+//
+// switch variant := ResponseCustomToolCallOutputCallerUnion.AsAny().(type) {
+// case responses.ResponseCustomToolCallOutputCallerDirect:
+// case responses.ResponseCustomToolCallOutputCallerProgram:
+// default:
+// fmt.Errorf("no variant present")
+// }
+func (u ResponseCustomToolCallOutputCallerUnion) AsAny() anyResponseCustomToolCallOutputCaller {
+ switch u.Type {
+ case "direct":
+ return u.AsDirect()
+ case "program":
+ return u.AsProgram()
+ }
+ return nil
+}
+
+func (u ResponseCustomToolCallOutputCallerUnion) AsDirect() (v ResponseCustomToolCallOutputCallerDirect) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseCustomToolCallOutputCallerUnion) AsProgram() (v ResponseCustomToolCallOutputCallerProgram) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+// Returns the unmodified JSON received from the API
+func (u ResponseCustomToolCallOutputCallerUnion) RawJSON() string { return u.JSON.raw }
+
+func (r *ResponseCustomToolCallOutputCallerUnion) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseCustomToolCallOutputCallerDirect 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 ResponseCustomToolCallOutputCallerDirect) RawJSON() string { return r.JSON.raw }
+func (r *ResponseCustomToolCallOutputCallerDirect) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseCustomToolCallOutputCallerProgram 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 ResponseCustomToolCallOutputCallerProgram) RawJSON() string { return r.JSON.raw }
+func (r *ResponseCustomToolCallOutputCallerProgram) 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.
@@ -6361,6 +7373,8 @@ type ResponseCustomToolCallOutputParam struct {
Output ResponseCustomToolCallOutputOutputUnionParam `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 execution context that produced this tool call.
+ Caller ResponseCustomToolCallOutputCallerUnionParam `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
@@ -6502,6 +7516,51 @@ func (u ResponseCustomToolCallOutputOutputOutputContentListItemUnionParam) GetFi
return nil
}
+// Returns a subunion which exports methods to access subproperties
+//
+// Or use AsAny() to get the underlying value
+func (u ResponseCustomToolCallOutputOutputOutputContentListItemUnionParam) GetPromptCacheBreakpoint() (res responseCustomToolCallOutputOutputOutputContentListItemUnionParamPromptCacheBreakpoint) {
+ 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 [*ResponseInputTextPromptCacheBreakpointParam],
+// [*ResponseInputImagePromptCacheBreakpointParam],
+// [*ResponseInputFilePromptCacheBreakpointParam]
+type responseCustomToolCallOutputOutputOutputContentListItemUnionParamPromptCacheBreakpoint struct{ any }
+
+// Use the following switch statement to get the type of the union:
+//
+// switch u.AsAny().(type) {
+// case *responses.ResponseInputTextPromptCacheBreakpointParam:
+// case *responses.ResponseInputImagePromptCacheBreakpointParam:
+// case *responses.ResponseInputFilePromptCacheBreakpointParam:
+// default:
+// fmt.Errorf("not present")
+// }
+func (u responseCustomToolCallOutputOutputOutputContentListItemUnionParamPromptCacheBreakpoint) AsAny() any {
+ return u.any
+}
+
+// Returns a pointer to the underlying variant's property, if present.
+func (u responseCustomToolCallOutputOutputOutputContentListItemUnionParamPromptCacheBreakpoint) GetMode() *string {
+ switch vt := u.any.(type) {
+ case *ResponseInputTextPromptCacheBreakpointParam:
+ return (*string)(&vt.Mode)
+ case *ResponseInputImagePromptCacheBreakpointParam:
+ return (*string)(&vt.Mode)
+ case *ResponseInputFilePromptCacheBreakpointParam:
+ return (*string)(&vt.Mode)
+ }
+ return nil
+}
+
func init() {
apijson.RegisterUnion[ResponseCustomToolCallOutputOutputOutputContentListItemUnionParam](
"type",
@@ -6511,6 +7570,98 @@ func init() {
)
}
+// Only one field can be non-zero.
+//
+// Use [param.IsOmitted] to confirm if a field is set.
+type ResponseCustomToolCallOutputCallerUnionParam struct {
+ OfDirect *ResponseCustomToolCallOutputCallerDirectParam `json:",omitzero,inline"`
+ OfProgram *ResponseCustomToolCallOutputCallerProgramParam `json:",omitzero,inline"`
+ paramUnion
+}
+
+func (u ResponseCustomToolCallOutputCallerUnionParam) MarshalJSON() ([]byte, error) {
+ return param.MarshalUnion(u, u.OfDirect, u.OfProgram)
+}
+func (u *ResponseCustomToolCallOutputCallerUnionParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, u)
+}
+
+func (u *ResponseCustomToolCallOutputCallerUnionParam) 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 ResponseCustomToolCallOutputCallerUnionParam) 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 ResponseCustomToolCallOutputCallerUnionParam) 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[ResponseCustomToolCallOutputCallerUnionParam](
+ "type",
+ apijson.Discriminator[ResponseCustomToolCallOutputCallerDirectParam]("direct"),
+ apijson.Discriminator[ResponseCustomToolCallOutputCallerProgramParam]("program"),
+ )
+}
+
+func NewResponseCustomToolCallOutputCallerDirectParam() ResponseCustomToolCallOutputCallerDirectParam {
+ return ResponseCustomToolCallOutputCallerDirectParam{
+ Type: "direct",
+ }
+}
+
+// This struct has a constant value, construct it with
+// [NewResponseCustomToolCallOutputCallerDirectParam].
+type ResponseCustomToolCallOutputCallerDirectParam struct {
+ // The caller type. Always `direct`.
+ Type constant.Direct `json:"type" default:"direct"`
+ paramObj
+}
+
+func (r ResponseCustomToolCallOutputCallerDirectParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseCustomToolCallOutputCallerDirectParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseCustomToolCallOutputCallerDirectParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// The properties CallerID, Type are required.
+type ResponseCustomToolCallOutputCallerProgramParam 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 ResponseCustomToolCallOutputCallerProgramParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseCustomToolCallOutputCallerProgramParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseCustomToolCallOutputCallerProgramParam) 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 ResponseCustomToolCallOutputItem struct {
// The unique ID of the custom tool call output item.
@@ -6544,11 +7695,12 @@ type ResponseError struct {
// The error code for the response.
//
// Any of "server_error", "rate_limit_exceeded", "invalid_prompt",
- // "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".
+ // "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 ResponseErrorCode `json:"code" api:"required"`
// A human-readable description of the error.
Message string `json:"message" api:"required"`
@@ -6574,6 +7726,8 @@ const (
ResponseErrorCodeServerError ResponseErrorCode = "server_error"
ResponseErrorCodeRateLimitExceeded ResponseErrorCode = "rate_limit_exceeded"
ResponseErrorCodeInvalidPrompt ResponseErrorCode = "invalid_prompt"
+ ResponseErrorCodeDataResidencyMismatch ResponseErrorCode = "data_residency_mismatch"
+ ResponseErrorCodeBioPolicy ResponseErrorCode = "bio_policy"
ResponseErrorCodeVectorStoreTimeout ResponseErrorCode = "vector_store_timeout"
ResponseErrorCodeInvalidImage ResponseErrorCode = "invalid_image"
ResponseErrorCodeInvalidImageFormat ResponseErrorCode = "invalid_image_format"
@@ -7285,9 +8439,13 @@ type ResponseFunctionCallOutputItemUnion struct {
// This field is from variant [ResponseInputTextContent].
Text string `json:"text"`
// Any of "input_text", "input_image", "input_file".
- Type string `json:"type"`
- Detail string `json:"detail"`
- FileID string `json:"file_id"`
+ Type string `json:"type"`
+ // This field is a union of [ResponseInputTextContentPromptCacheBreakpoint],
+ // [ResponseInputImageContentPromptCacheBreakpoint],
+ // [ResponseInputFileContentPromptCacheBreakpoint]
+ PromptCacheBreakpoint ResponseFunctionCallOutputItemUnionPromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
+ Detail string `json:"detail"`
+ FileID string `json:"file_id"`
// This field is from variant [ResponseInputImageContent].
ImageURL string `json:"image_url"`
// This field is from variant [ResponseInputFileContent].
@@ -7297,15 +8455,16 @@ type ResponseFunctionCallOutputItemUnion struct {
// This field is from variant [ResponseInputFileContent].
Filename string `json:"filename"`
JSON struct {
- Text respjson.Field
- Type respjson.Field
- Detail respjson.Field
- FileID respjson.Field
- ImageURL respjson.Field
- FileData respjson.Field
- FileURL respjson.Field
- Filename respjson.Field
- raw string
+ 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:"-"`
}
@@ -7363,6 +8522,26 @@ func (r *ResponseFunctionCallOutputItemUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+// ResponseFunctionCallOutputItemUnionPromptCacheBreakpoint is an implicit subunion
+// of [ResponseFunctionCallOutputItemUnion].
+// ResponseFunctionCallOutputItemUnionPromptCacheBreakpoint provides convenient
+// access to the sub-properties of the union.
+//
+// For type safety it is recommended to directly use a variant of the
+// [ResponseFunctionCallOutputItemUnion].
+type ResponseFunctionCallOutputItemUnionPromptCacheBreakpoint struct {
+ // This field is from variant [ResponseInputTextContentPromptCacheBreakpoint].
+ Mode constant.Explicit `json:"mode"`
+ JSON struct {
+ Mode respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+func (r *ResponseFunctionCallOutputItemUnionPromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// ToParam converts this ResponseFunctionCallOutputItemUnion to a
// ResponseFunctionCallOutputItemUnionParam.
//
@@ -7479,6 +8658,50 @@ func (u ResponseFunctionCallOutputItemUnionParam) GetFileID() *string {
return nil
}
+// Returns a subunion which exports methods to access subproperties
+//
+// Or use AsAny() to get the underlying value
+func (u ResponseFunctionCallOutputItemUnionParam) GetPromptCacheBreakpoint() (res responseFunctionCallOutputItemUnionParamPromptCacheBreakpoint) {
+ 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
+// [*ResponseInputTextContentPromptCacheBreakpointParam],
+// [*ResponseInputImageContentPromptCacheBreakpointParam],
+// [*ResponseInputFileContentPromptCacheBreakpointParam]
+type responseFunctionCallOutputItemUnionParamPromptCacheBreakpoint struct{ any }
+
+// Use the following switch statement to get the type of the union:
+//
+// switch u.AsAny().(type) {
+// case *responses.ResponseInputTextContentPromptCacheBreakpointParam:
+// case *responses.ResponseInputImageContentPromptCacheBreakpointParam:
+// case *responses.ResponseInputFileContentPromptCacheBreakpointParam:
+// default:
+// fmt.Errorf("not present")
+// }
+func (u responseFunctionCallOutputItemUnionParamPromptCacheBreakpoint) AsAny() any { return u.any }
+
+// Returns a pointer to the underlying variant's property, if present.
+func (u responseFunctionCallOutputItemUnionParamPromptCacheBreakpoint) GetMode() *string {
+ switch vt := u.any.(type) {
+ case *ResponseInputTextContentPromptCacheBreakpointParam:
+ return (*string)(&vt.Mode)
+ case *ResponseInputImageContentPromptCacheBreakpointParam:
+ return (*string)(&vt.Mode)
+ case *ResponseInputFileContentPromptCacheBreakpointParam:
+ return (*string)(&vt.Mode)
+ }
+ return nil
+}
+
func init() {
apijson.RegisterUnion[ResponseFunctionCallOutputItemUnionParam](
"type",
@@ -7768,6 +8991,8 @@ type ResponseFunctionShellToolCall struct {
Status ResponseFunctionShellToolCallStatus `json:"status" api:"required"`
// The type of the item. Always `shell_call`.
Type constant.ShellCall `json:"type" default:"shell_call"`
+ // The execution context that produced this tool call.
+ Caller ResponseFunctionShellToolCallCallerUnion `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].
@@ -7778,6 +9003,7 @@ type ResponseFunctionShellToolCall struct {
Environment respjson.Field
Status respjson.Field
Type respjson.Field
+ Caller respjson.Field
CreatedBy respjson.Field
ExtraFields map[string]respjson.Field
raw string
@@ -7889,64 +9115,167 @@ const (
ResponseFunctionShellToolCallStatusIncomplete ResponseFunctionShellToolCallStatus = "incomplete"
)
-// The output of a shell tool call that was emitted.
-type ResponseFunctionShellToolCallOutput 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 []ResponseFunctionShellToolCallOutputOutput `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 ResponseFunctionShellToolCallOutputStatus `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 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
- CreatedBy respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
+// ResponseFunctionShellToolCallCallerUnion contains all possible properties and
+// values from [ResponseFunctionShellToolCallCallerDirect],
+// [ResponseFunctionShellToolCallCallerProgram].
+//
+// Use the [ResponseFunctionShellToolCallCallerUnion.AsAny] method to switch on the
+// variant.
+//
+// Use the methods beginning with 'As' to cast the union to one of its variants.
+type ResponseFunctionShellToolCallCallerUnion struct {
+ // Any of "direct", "program".
+ Type string `json:"type"`
+ // This field is from variant [ResponseFunctionShellToolCallCallerProgram].
+ CallerID string `json:"caller_id"`
+ JSON struct {
+ Type respjson.Field
+ CallerID respjson.Field
+ raw string
} `json:"-"`
}
-// Returns the unmodified JSON received from the API
-func (r ResponseFunctionShellToolCallOutput) RawJSON() string { return r.JSON.raw }
-func (r *ResponseFunctionShellToolCallOutput) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
+// anyResponseFunctionShellToolCallCaller is implemented by each variant of
+// [ResponseFunctionShellToolCallCallerUnion] to add type safety for the return
+// type of [ResponseFunctionShellToolCallCallerUnion.AsAny]
+type anyResponseFunctionShellToolCallCaller interface {
+ implResponseFunctionShellToolCallCallerUnion()
}
-func (ResponseFunctionShellToolCallOutput) ImplConversationItemUnion() {}
+func (ResponseFunctionShellToolCallCallerDirect) implResponseFunctionShellToolCallCallerUnion() {}
+func (ResponseFunctionShellToolCallCallerProgram) implResponseFunctionShellToolCallCallerUnion() {}
-// The content of a shell tool call output that was emitted.
-type ResponseFunctionShellToolCallOutputOutput struct {
- // Represents either an exit outcome (with an exit code) or a timeout outcome for a
- // shell call output chunk.
- Outcome ResponseFunctionShellToolCallOutputOutputOutcomeUnion `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
+// Use the following switch statement to find the correct variant
+//
+// switch variant := ResponseFunctionShellToolCallCallerUnion.AsAny().(type) {
+// case responses.ResponseFunctionShellToolCallCallerDirect:
+// case responses.ResponseFunctionShellToolCallCallerProgram:
+// default:
+// fmt.Errorf("no variant present")
+// }
+func (u ResponseFunctionShellToolCallCallerUnion) AsAny() anyResponseFunctionShellToolCallCaller {
+ switch u.Type {
+ case "direct":
+ return u.AsDirect()
+ case "program":
+ return u.AsProgram()
+ }
+ return nil
+}
+
+func (u ResponseFunctionShellToolCallCallerUnion) AsDirect() (v ResponseFunctionShellToolCallCallerDirect) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseFunctionShellToolCallCallerUnion) AsProgram() (v ResponseFunctionShellToolCallCallerProgram) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+// Returns the unmodified JSON received from the API
+func (u ResponseFunctionShellToolCallCallerUnion) RawJSON() string { return u.JSON.raw }
+
+func (r *ResponseFunctionShellToolCallCallerUnion) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseFunctionShellToolCallCallerDirect 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 ResponseFunctionShellToolCallCallerDirect) RawJSON() string { return r.JSON.raw }
+func (r *ResponseFunctionShellToolCallCallerDirect) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseFunctionShellToolCallCallerProgram 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 ResponseFunctionShellToolCallCallerProgram) RawJSON() string { return r.JSON.raw }
+func (r *ResponseFunctionShellToolCallCallerProgram) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// The output of a shell tool call that was emitted.
+type ResponseFunctionShellToolCallOutput 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 []ResponseFunctionShellToolCallOutputOutput `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 ResponseFunctionShellToolCallOutputStatus `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 execution context that produced this tool call.
+ Caller ResponseFunctionShellToolCallOutputCallerUnion `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
+ Caller respjson.Field
+ CreatedBy respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseFunctionShellToolCallOutput) RawJSON() string { return r.JSON.raw }
+func (r *ResponseFunctionShellToolCallOutput) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (ResponseFunctionShellToolCallOutput) ImplConversationItemUnion() {}
+
+// The content of a shell tool call output that was emitted.
+type ResponseFunctionShellToolCallOutputOutput struct {
+ // Represents either an exit outcome (with an exit code) or a timeout outcome for a
+ // shell call output chunk.
+ Outcome ResponseFunctionShellToolCallOutputOutputOutcomeUnion `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
@@ -8079,6 +9408,108 @@ const (
ResponseFunctionShellToolCallOutputStatusIncomplete ResponseFunctionShellToolCallOutputStatus = "incomplete"
)
+// ResponseFunctionShellToolCallOutputCallerUnion contains all possible properties
+// and values from [ResponseFunctionShellToolCallOutputCallerDirect],
+// [ResponseFunctionShellToolCallOutputCallerProgram].
+//
+// Use the [ResponseFunctionShellToolCallOutputCallerUnion.AsAny] method to switch
+// on the variant.
+//
+// Use the methods beginning with 'As' to cast the union to one of its variants.
+type ResponseFunctionShellToolCallOutputCallerUnion struct {
+ // Any of "direct", "program".
+ Type string `json:"type"`
+ // This field is from variant [ResponseFunctionShellToolCallOutputCallerProgram].
+ CallerID string `json:"caller_id"`
+ JSON struct {
+ Type respjson.Field
+ CallerID respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// anyResponseFunctionShellToolCallOutputCaller is implemented by each variant of
+// [ResponseFunctionShellToolCallOutputCallerUnion] to add type safety for the
+// return type of [ResponseFunctionShellToolCallOutputCallerUnion.AsAny]
+type anyResponseFunctionShellToolCallOutputCaller interface {
+ implResponseFunctionShellToolCallOutputCallerUnion()
+}
+
+func (ResponseFunctionShellToolCallOutputCallerDirect) implResponseFunctionShellToolCallOutputCallerUnion() {
+}
+func (ResponseFunctionShellToolCallOutputCallerProgram) implResponseFunctionShellToolCallOutputCallerUnion() {
+}
+
+// Use the following switch statement to find the correct variant
+//
+// switch variant := ResponseFunctionShellToolCallOutputCallerUnion.AsAny().(type) {
+// case responses.ResponseFunctionShellToolCallOutputCallerDirect:
+// case responses.ResponseFunctionShellToolCallOutputCallerProgram:
+// default:
+// fmt.Errorf("no variant present")
+// }
+func (u ResponseFunctionShellToolCallOutputCallerUnion) AsAny() anyResponseFunctionShellToolCallOutputCaller {
+ switch u.Type {
+ case "direct":
+ return u.AsDirect()
+ case "program":
+ return u.AsProgram()
+ }
+ return nil
+}
+
+func (u ResponseFunctionShellToolCallOutputCallerUnion) AsDirect() (v ResponseFunctionShellToolCallOutputCallerDirect) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseFunctionShellToolCallOutputCallerUnion) AsProgram() (v ResponseFunctionShellToolCallOutputCallerProgram) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+// Returns the unmodified JSON received from the API
+func (u ResponseFunctionShellToolCallOutputCallerUnion) RawJSON() string { return u.JSON.raw }
+
+func (r *ResponseFunctionShellToolCallOutputCallerUnion) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseFunctionShellToolCallOutputCallerDirect 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 ResponseFunctionShellToolCallOutputCallerDirect) RawJSON() string { return r.JSON.raw }
+func (r *ResponseFunctionShellToolCallOutputCallerDirect) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseFunctionShellToolCallOutputCallerProgram 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 ResponseFunctionShellToolCallOutputCallerProgram) RawJSON() string { return r.JSON.raw }
+func (r *ResponseFunctionShellToolCallOutputCallerProgram) 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.
@@ -8093,6 +9524,8 @@ type ResponseFunctionToolCall struct {
Type constant.FunctionCall `json:"type" default:"function_call"`
// The unique ID of the function tool call.
ID string `json:"id"`
+ // The execution context that produced this tool call.
+ Caller ResponseFunctionToolCallCallerUnion `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`.
@@ -8107,6 +9540,7 @@ type ResponseFunctionToolCall struct {
Name respjson.Field
Type respjson.Field
ID respjson.Field
+ Caller respjson.Field
Namespace respjson.Field
Status respjson.Field
ExtraFields map[string]respjson.Field
@@ -8130,6 +9564,106 @@ func (r ResponseFunctionToolCall) ToParam() ResponseFunctionToolCallParam {
return param.Override[ResponseFunctionToolCallParam](json.RawMessage(r.RawJSON()))
}
+// ResponseFunctionToolCallCallerUnion contains all possible properties and values
+// from [ResponseFunctionToolCallCallerDirect],
+// [ResponseFunctionToolCallCallerProgram].
+//
+// Use the [ResponseFunctionToolCallCallerUnion.AsAny] method to switch on the
+// variant.
+//
+// Use the methods beginning with 'As' to cast the union to one of its variants.
+type ResponseFunctionToolCallCallerUnion struct {
+ // Any of "direct", "program".
+ Type string `json:"type"`
+ // This field is from variant [ResponseFunctionToolCallCallerProgram].
+ CallerID string `json:"caller_id"`
+ JSON struct {
+ Type respjson.Field
+ CallerID respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// anyResponseFunctionToolCallCaller is implemented by each variant of
+// [ResponseFunctionToolCallCallerUnion] to add type safety for the return type of
+// [ResponseFunctionToolCallCallerUnion.AsAny]
+type anyResponseFunctionToolCallCaller interface {
+ implResponseFunctionToolCallCallerUnion()
+}
+
+func (ResponseFunctionToolCallCallerDirect) implResponseFunctionToolCallCallerUnion() {}
+func (ResponseFunctionToolCallCallerProgram) implResponseFunctionToolCallCallerUnion() {}
+
+// Use the following switch statement to find the correct variant
+//
+// switch variant := ResponseFunctionToolCallCallerUnion.AsAny().(type) {
+// case responses.ResponseFunctionToolCallCallerDirect:
+// case responses.ResponseFunctionToolCallCallerProgram:
+// default:
+// fmt.Errorf("no variant present")
+// }
+func (u ResponseFunctionToolCallCallerUnion) AsAny() anyResponseFunctionToolCallCaller {
+ switch u.Type {
+ case "direct":
+ return u.AsDirect()
+ case "program":
+ return u.AsProgram()
+ }
+ return nil
+}
+
+func (u ResponseFunctionToolCallCallerUnion) AsDirect() (v ResponseFunctionToolCallCallerDirect) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseFunctionToolCallCallerUnion) AsProgram() (v ResponseFunctionToolCallCallerProgram) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+// Returns the unmodified JSON received from the API
+func (u ResponseFunctionToolCallCallerUnion) RawJSON() string { return u.JSON.raw }
+
+func (r *ResponseFunctionToolCallCallerUnion) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseFunctionToolCallCallerDirect 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 ResponseFunctionToolCallCallerDirect) RawJSON() string { return r.JSON.raw }
+func (r *ResponseFunctionToolCallCallerDirect) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseFunctionToolCallCallerProgram 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 ResponseFunctionToolCallCallerProgram) RawJSON() string { return r.JSON.raw }
+func (r *ResponseFunctionToolCallCallerProgram) 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 ResponseFunctionToolCallStatus string
@@ -8156,6 +9690,8 @@ type ResponseFunctionToolCallParam struct {
ID param.Opt[string] `json:"id,omitzero"`
// The namespace of the function to run.
Namespace param.Opt[string] `json:"namespace,omitzero"`
+ // The execution context that produced this tool call.
+ Caller ResponseFunctionToolCallCallerUnionParam `json:"caller,omitzero"`
// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
// Populated when items are returned via API.
//
@@ -8176,6 +9712,95 @@ func (r *ResponseFunctionToolCallParam) 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 ResponseFunctionToolCallCallerUnionParam struct {
+ OfDirect *ResponseFunctionToolCallCallerDirectParam `json:",omitzero,inline"`
+ OfProgram *ResponseFunctionToolCallCallerProgramParam `json:",omitzero,inline"`
+ paramUnion
+}
+
+func (u ResponseFunctionToolCallCallerUnionParam) MarshalJSON() ([]byte, error) {
+ return param.MarshalUnion(u, u.OfDirect, u.OfProgram)
+}
+func (u *ResponseFunctionToolCallCallerUnionParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, u)
+}
+
+func (u *ResponseFunctionToolCallCallerUnionParam) 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 ResponseFunctionToolCallCallerUnionParam) 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 ResponseFunctionToolCallCallerUnionParam) 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[ResponseFunctionToolCallCallerUnionParam](
+ "type",
+ apijson.Discriminator[ResponseFunctionToolCallCallerDirectParam]("direct"),
+ apijson.Discriminator[ResponseFunctionToolCallCallerProgramParam]("program"),
+ )
+}
+
+func NewResponseFunctionToolCallCallerDirectParam() ResponseFunctionToolCallCallerDirectParam {
+ return ResponseFunctionToolCallCallerDirectParam{
+ Type: "direct",
+ }
+}
+
+// This struct has a constant value, construct it with
+// [NewResponseFunctionToolCallCallerDirectParam].
+type ResponseFunctionToolCallCallerDirectParam struct {
+ Type constant.Direct `json:"type" default:"direct"`
+ paramObj
+}
+
+func (r ResponseFunctionToolCallCallerDirectParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseFunctionToolCallCallerDirectParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseFunctionToolCallCallerDirectParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// The properties CallerID, Type are required.
+type ResponseFunctionToolCallCallerProgramParam 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 ResponseFunctionToolCallCallerProgramParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseFunctionToolCallCallerProgramParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseFunctionToolCallCallerProgramParam) 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.
@@ -8223,6 +9848,8 @@ type ResponseFunctionToolCallOutputItem struct {
Status ResponseFunctionToolCallOutputItemStatus `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 execution context that produced this tool call.
+ Caller ResponseFunctionToolCallOutputItemCallerUnion `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].
@@ -8232,6 +9859,7 @@ type ResponseFunctionToolCallOutputItem struct {
Output respjson.Field
Status respjson.Field
Type respjson.Field
+ Caller respjson.Field
CreatedBy respjson.Field
ExtraFields map[string]respjson.Field
raw string
@@ -8298,9 +9926,13 @@ type ResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion struct {
// This field is from variant [ResponseInputText].
Text string `json:"text"`
// Any of "input_text", "input_image", "input_file".
- Type string `json:"type"`
- Detail string `json:"detail"`
- FileID string `json:"file_id"`
+ Type string `json:"type"`
+ // This field is a union of [ResponseInputTextPromptCacheBreakpoint],
+ // [ResponseInputImagePromptCacheBreakpoint],
+ // [ResponseInputFilePromptCacheBreakpoint]
+ PromptCacheBreakpoint ResponseFunctionToolCallOutputItemOutputOutputContentListItemUnionPromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
+ Detail string `json:"detail"`
+ FileID string `json:"file_id"`
// This field is from variant [ResponseInputImage].
ImageURL string `json:"image_url"`
// This field is from variant [ResponseInputFile].
@@ -8310,15 +9942,16 @@ type ResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion struct {
// This field is from variant [ResponseInputFile].
Filename string `json:"filename"`
JSON struct {
- Text respjson.Field
- Type respjson.Field
- Detail respjson.Field
- FileID respjson.Field
- ImageURL respjson.Field
- FileData respjson.Field
- FileURL respjson.Field
- Filename respjson.Field
- raw string
+ 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:"-"`
}
@@ -8380,6 +10013,27 @@ func (r *ResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion) Unm
return apijson.UnmarshalRoot(data, r)
}
+// ResponseFunctionToolCallOutputItemOutputOutputContentListItemUnionPromptCacheBreakpoint
+// is an implicit subunion of
+// [ResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion].
+// ResponseFunctionToolCallOutputItemOutputOutputContentListItemUnionPromptCacheBreakpoint
+// provides convenient access to the sub-properties of the union.
+//
+// For type safety it is recommended to directly use a variant of the
+// [ResponseFunctionToolCallOutputItemOutputOutputContentListItemUnion].
+type ResponseFunctionToolCallOutputItemOutputOutputContentListItemUnionPromptCacheBreakpoint struct {
+ // This field is from variant [ResponseInputTextPromptCacheBreakpoint].
+ Mode constant.Explicit `json:"mode"`
+ JSON struct {
+ Mode respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+func (r *ResponseFunctionToolCallOutputItemOutputOutputContentListItemUnionPromptCacheBreakpoint) 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 ResponseFunctionToolCallOutputItemStatus string
@@ -8390,6 +10044,110 @@ const (
ResponseFunctionToolCallOutputItemStatusIncomplete ResponseFunctionToolCallOutputItemStatus = "incomplete"
)
+// ResponseFunctionToolCallOutputItemCallerUnion contains all possible properties
+// and values from [ResponseFunctionToolCallOutputItemCallerDirect],
+// [ResponseFunctionToolCallOutputItemCallerProgram].
+//
+// Use the [ResponseFunctionToolCallOutputItemCallerUnion.AsAny] method to switch
+// on the variant.
+//
+// Use the methods beginning with 'As' to cast the union to one of its variants.
+type ResponseFunctionToolCallOutputItemCallerUnion struct {
+ // Any of "direct", "program".
+ Type string `json:"type"`
+ // This field is from variant [ResponseFunctionToolCallOutputItemCallerProgram].
+ CallerID string `json:"caller_id"`
+ JSON struct {
+ Type respjson.Field
+ CallerID respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// anyResponseFunctionToolCallOutputItemCaller is implemented by each variant of
+// [ResponseFunctionToolCallOutputItemCallerUnion] to add type safety for the
+// return type of [ResponseFunctionToolCallOutputItemCallerUnion.AsAny]
+type anyResponseFunctionToolCallOutputItemCaller interface {
+ implResponseFunctionToolCallOutputItemCallerUnion()
+}
+
+func (ResponseFunctionToolCallOutputItemCallerDirect) implResponseFunctionToolCallOutputItemCallerUnion() {
+}
+func (ResponseFunctionToolCallOutputItemCallerProgram) implResponseFunctionToolCallOutputItemCallerUnion() {
+}
+
+// Use the following switch statement to find the correct variant
+//
+// switch variant := ResponseFunctionToolCallOutputItemCallerUnion.AsAny().(type) {
+// case responses.ResponseFunctionToolCallOutputItemCallerDirect:
+// case responses.ResponseFunctionToolCallOutputItemCallerProgram:
+// default:
+// fmt.Errorf("no variant present")
+// }
+func (u ResponseFunctionToolCallOutputItemCallerUnion) AsAny() anyResponseFunctionToolCallOutputItemCaller {
+ switch u.Type {
+ case "direct":
+ return u.AsDirect()
+ case "program":
+ return u.AsProgram()
+ }
+ return nil
+}
+
+func (u ResponseFunctionToolCallOutputItemCallerUnion) AsDirect() (v ResponseFunctionToolCallOutputItemCallerDirect) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseFunctionToolCallOutputItemCallerUnion) AsProgram() (v ResponseFunctionToolCallOutputItemCallerProgram) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+// Returns the unmodified JSON received from the API
+func (u ResponseFunctionToolCallOutputItemCallerUnion) RawJSON() string { return u.JSON.raw }
+
+func (r *ResponseFunctionToolCallOutputItemCallerUnion) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseFunctionToolCallOutputItemCallerDirect 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 ResponseFunctionToolCallOutputItemCallerDirect) RawJSON() string { return r.JSON.raw }
+func (r *ResponseFunctionToolCallOutputItemCallerDirect) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseFunctionToolCallOutputItemCallerProgram 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 ResponseFunctionToolCallOutputItemCallerProgram) RawJSON() string { return r.JSON.raw }
+func (r *ResponseFunctionToolCallOutputItemCallerProgram) 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.
@@ -8444,21 +10202,21 @@ func (r ResponseFunctionWebSearch) ToParam() ResponseFunctionWebSearchParam {
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type ResponseFunctionWebSearchActionUnion struct {
- // This field is from variant [ResponseFunctionWebSearchActionSearch].
- Query string `json:"query"`
// Any of "search", "open_page", "find_in_page".
Type string `json:"type"`
// This field is from variant [ResponseFunctionWebSearchActionSearch].
Queries []string `json:"queries"`
// This field is from variant [ResponseFunctionWebSearchActionSearch].
+ Query string `json:"query"`
+ // This field is from variant [ResponseFunctionWebSearchActionSearch].
Sources []ResponseFunctionWebSearchActionSearchSource `json:"sources"`
URL string `json:"url"`
// This field is from variant [ResponseFunctionWebSearchActionFind].
Pattern string `json:"pattern"`
JSON struct {
- Query respjson.Field
Type respjson.Field
Queries respjson.Field
+ Query respjson.Field
Sources respjson.Field
URL respjson.Field
Pattern respjson.Field
@@ -8522,19 +10280,21 @@ func (r *ResponseFunctionWebSearchActionUnion) UnmarshalJSON(data []byte) error
// Action type "search" - Performs a web search query.
type ResponseFunctionWebSearchActionSearch struct {
- // [DEPRECATED] The search query.
- Query string `json:"query" api:"required"`
// 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 []ResponseFunctionWebSearchActionSearchSource `json:"sources"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
- Query respjson.Field
Type respjson.Field
Queries respjson.Field
+ Query respjson.Field
Sources respjson.Field
ExtraFields map[string]respjson.Field
raw string
@@ -8552,7 +10312,7 @@ type ResponseFunctionWebSearchActionSearchSource 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"`
+ URL string `json:"url" api:"required" format:"uri"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Type respjson.Field
@@ -8682,17 +10442,17 @@ func (u *ResponseFunctionWebSearchActionUnionParam) asAny() any {
}
// Returns a pointer to the underlying variant's property, if present.
-func (u ResponseFunctionWebSearchActionUnionParam) GetQuery() *string {
+func (u ResponseFunctionWebSearchActionUnionParam) GetQueries() []string {
if vt := u.OfSearch; vt != nil {
- return &vt.Query
+ return vt.Queries
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
-func (u ResponseFunctionWebSearchActionUnionParam) GetQueries() []string {
- if vt := u.OfSearch; vt != nil {
- return vt.Queries
+func (u ResponseFunctionWebSearchActionUnionParam) GetQuery() *string {
+ if vt := u.OfSearch; vt != nil && vt.Query.Valid() {
+ return &vt.Query.Value
}
return nil
}
@@ -8746,10 +10506,12 @@ func init() {
// Action type "search" - Performs a web search query.
//
-// The properties Query, Type are required.
+// The property Type is required.
type ResponseFunctionWebSearchActionSearchParam struct {
- // [DEPRECATED] The search query.
- Query string `json:"query" api:"required"`
+ // 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.
@@ -8774,7 +10536,7 @@ func (r *ResponseFunctionWebSearchActionSearchParam) UnmarshalJSON(data []byte)
// The properties Type, URL are required.
type ResponseFunctionWebSearchActionSearchSourceParam struct {
// The URL of the source.
- URL string `json:"url" api:"required"`
+ 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".
@@ -8978,6 +10740,8 @@ func (r *ResponseInProgressEvent) UnmarshalJSON(data []byte) error {
// 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
@@ -9138,9 +10902,13 @@ type ResponseInputContentUnion struct {
// This field is from variant [ResponseInputText].
Text string `json:"text"`
// Any of "input_text", "input_image", "input_file".
- Type string `json:"type"`
- Detail string `json:"detail"`
- FileID string `json:"file_id"`
+ Type string `json:"type"`
+ // This field is a union of [ResponseInputTextPromptCacheBreakpoint],
+ // [ResponseInputImagePromptCacheBreakpoint],
+ // [ResponseInputFilePromptCacheBreakpoint]
+ PromptCacheBreakpoint ResponseInputContentUnionPromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
+ Detail string `json:"detail"`
+ FileID string `json:"file_id"`
// This field is from variant [ResponseInputImage].
ImageURL string `json:"image_url"`
// This field is from variant [ResponseInputFile].
@@ -9150,15 +10918,16 @@ type ResponseInputContentUnion struct {
// This field is from variant [ResponseInputFile].
Filename string `json:"filename"`
JSON struct {
- Text respjson.Field
- Type respjson.Field
- Detail respjson.Field
- FileID respjson.Field
- ImageURL respjson.Field
- FileData respjson.Field
- FileURL respjson.Field
- Filename respjson.Field
- raw string
+ 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:"-"`
}
@@ -9216,6 +10985,25 @@ func (r *ResponseInputContentUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+// ResponseInputContentUnionPromptCacheBreakpoint is an implicit subunion of
+// [ResponseInputContentUnion]. ResponseInputContentUnionPromptCacheBreakpoint
+// provides convenient access to the sub-properties of the union.
+//
+// For type safety it is recommended to directly use a variant of the
+// [ResponseInputContentUnion].
+type ResponseInputContentUnionPromptCacheBreakpoint struct {
+ // This field is from variant [ResponseInputTextPromptCacheBreakpoint].
+ Mode constant.Explicit `json:"mode"`
+ JSON struct {
+ Mode respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+func (r *ResponseInputContentUnionPromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// ToParam converts this ResponseInputContentUnion to a
// ResponseInputContentUnionParam.
//
@@ -9338,6 +11126,49 @@ func (u ResponseInputContentUnionParam) GetFileID() *string {
return nil
}
+// Returns a subunion which exports methods to access subproperties
+//
+// Or use AsAny() to get the underlying value
+func (u ResponseInputContentUnionParam) GetPromptCacheBreakpoint() (res responseInputContentUnionParamPromptCacheBreakpoint) {
+ 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 [*ResponseInputTextPromptCacheBreakpointParam],
+// [*ResponseInputImagePromptCacheBreakpointParam],
+// [*ResponseInputFilePromptCacheBreakpointParam]
+type responseInputContentUnionParamPromptCacheBreakpoint struct{ any }
+
+// Use the following switch statement to get the type of the union:
+//
+// switch u.AsAny().(type) {
+// case *responses.ResponseInputTextPromptCacheBreakpointParam:
+// case *responses.ResponseInputImagePromptCacheBreakpointParam:
+// case *responses.ResponseInputFilePromptCacheBreakpointParam:
+// default:
+// fmt.Errorf("not present")
+// }
+func (u responseInputContentUnionParamPromptCacheBreakpoint) AsAny() any { return u.any }
+
+// Returns a pointer to the underlying variant's property, if present.
+func (u responseInputContentUnionParamPromptCacheBreakpoint) GetMode() *string {
+ switch vt := u.any.(type) {
+ case *ResponseInputTextPromptCacheBreakpointParam:
+ return (*string)(&vt.Mode)
+ case *ResponseInputImagePromptCacheBreakpointParam:
+ return (*string)(&vt.Mode)
+ case *ResponseInputFilePromptCacheBreakpointParam:
+ return (*string)(&vt.Mode)
+ }
+ return nil
+}
+
func init() {
apijson.RegisterUnion[ResponseInputContentUnionParam](
"type",
@@ -9351,30 +11182,37 @@ func init() {
type ResponseInputFile 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 `low` for the default
- // rendering behavior, or `high` to render the file at higher quality. Defaults to
- // `low`.
+ // 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 "low", "high".
+ // Any of "auto", "low", "high".
Detail ResponseInputFileDetail `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"`
+ 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 ResponseInputFilePromptCacheBreakpoint `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
- ExtraFields map[string]respjson.Field
- raw string
+ 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:"-"`
}
@@ -9395,16 +11233,39 @@ func (r ResponseInputFile) ToParam() ResponseInputFileParam {
return param.Override[ResponseInputFileParam](json.RawMessage(r.RawJSON()))
}
-// The detail level of the file to be sent to the model. Use `low` for the default
-// rendering behavior, or `high` to render the file at higher quality. Defaults to
-// `low`.
+// 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 ResponseInputFileDetail string
const (
+ ResponseInputFileDetailAuto ResponseInputFileDetail = "auto"
ResponseInputFileDetailLow ResponseInputFileDetail = "low"
ResponseInputFileDetailHigh ResponseInputFileDetail = "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 ResponseInputFilePromptCacheBreakpoint 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 ResponseInputFilePromptCacheBreakpoint) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputFilePromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// A file input to the model.
//
// The property Type is required.
@@ -9414,15 +11275,21 @@ type ResponseInputFileParam struct {
// 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"`
+ 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 `low` for the default
- // rendering behavior, or `high` to render the file at higher quality. Defaults to
- // `low`.
+ // 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 "low", "high".
+ // Any of "auto", "low", "high".
Detail ResponseInputFileDetail `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 ResponseInputFilePromptCacheBreakpointParam `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".
@@ -9438,34 +11305,67 @@ func (r *ResponseInputFileParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+func NewResponseInputFilePromptCacheBreakpointParam() ResponseInputFilePromptCacheBreakpointParam {
+ return ResponseInputFilePromptCacheBreakpointParam{
+ 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
+// [NewResponseInputFilePromptCacheBreakpointParam].
+type ResponseInputFilePromptCacheBreakpointParam struct {
+ // The breakpoint mode. Always `explicit`.
+ Mode constant.Explicit `json:"mode" default:"explicit"`
+ paramObj
+}
+
+func (r ResponseInputFilePromptCacheBreakpointParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseInputFilePromptCacheBreakpointParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseInputFilePromptCacheBreakpointParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// A file input to the model.
type ResponseInputFileContent 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 `low` for the default
- // rendering behavior, or `high` to render the file at higher quality. Defaults to
- // `low`.
+ // 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 "low", "high".
+ // Any of "auto", "low", "high".
Detail ResponseInputFileContentDetail `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"`
+ 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 ResponseInputFileContentPromptCacheBreakpoint `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
- ExtraFields map[string]respjson.Field
- raw string
+ 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:"-"`
}
@@ -9485,16 +11385,39 @@ func (r ResponseInputFileContent) ToParam() ResponseInputFileContentParam {
return param.Override[ResponseInputFileContentParam](json.RawMessage(r.RawJSON()))
}
-// The detail level of the file to be sent to the model. Use `low` for the default
-// rendering behavior, or `high` to render the file at higher quality. Defaults to
-// `low`.
+// 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 ResponseInputFileContentDetail string
const (
+ ResponseInputFileContentDetailAuto ResponseInputFileContentDetail = "auto"
ResponseInputFileContentDetailLow ResponseInputFileContentDetail = "low"
ResponseInputFileContentDetailHigh ResponseInputFileContentDetail = "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 ResponseInputFileContentPromptCacheBreakpoint 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 ResponseInputFileContentPromptCacheBreakpoint) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputFileContentPromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// A file input to the model.
//
// The property Type is required.
@@ -9504,14 +11427,20 @@ type ResponseInputFileContentParam struct {
// 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"`
+ 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 `low` for the default
- // rendering behavior, or `high` to render the file at higher quality. Defaults to
- // `low`.
- //
- // Any of "low", "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.
+ PromptCacheBreakpoint ResponseInputFileContentPromptCacheBreakpointParam `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 ResponseInputFileContentDetail `json:"detail,omitzero"`
// The type of the input item. Always `input_file`.
//
@@ -9528,6 +11457,32 @@ func (r *ResponseInputFileContentParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+func NewResponseInputFileContentPromptCacheBreakpointParam() ResponseInputFileContentPromptCacheBreakpointParam {
+ return ResponseInputFileContentPromptCacheBreakpointParam{
+ 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
+// [NewResponseInputFileContentPromptCacheBreakpointParam].
+type ResponseInputFileContentPromptCacheBreakpointParam struct {
+ // The breakpoint mode. Always `explicit`.
+ Mode constant.Explicit `json:"mode" default:"explicit"`
+ paramObj
+}
+
+func (r ResponseInputFileContentPromptCacheBreakpointParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseInputFileContentPromptCacheBreakpointParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseInputFileContentPromptCacheBreakpointParam) 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 ResponseInputImage struct {
@@ -9540,17 +11495,22 @@ type ResponseInputImage struct {
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"`
- // 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
- ExtraFields map[string]respjson.Field
- raw string
+ // 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 ResponseInputImagePromptCacheBreakpoint `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:"-"`
}
@@ -9582,6 +11542,26 @@ const (
ResponseInputImageDetailOriginal ResponseInputImageDetail = "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 ResponseInputImagePromptCacheBreakpoint 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 ResponseInputImagePromptCacheBreakpoint) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputImagePromptCacheBreakpoint) 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).
//
@@ -9596,7 +11576,11 @@ type ResponseInputImageParam struct {
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"`
+ 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 ResponseInputImagePromptCacheBreakpointParam `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".
@@ -9612,6 +11596,32 @@ func (r *ResponseInputImageParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+func NewResponseInputImagePromptCacheBreakpointParam() ResponseInputImagePromptCacheBreakpointParam {
+ return ResponseInputImagePromptCacheBreakpointParam{
+ 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
+// [NewResponseInputImagePromptCacheBreakpointParam].
+type ResponseInputImagePromptCacheBreakpointParam struct {
+ // The breakpoint mode. Always `explicit`.
+ Mode constant.Explicit `json:"mode" default:"explicit"`
+ paramObj
+}
+
+func (r ResponseInputImagePromptCacheBreakpointParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseInputImagePromptCacheBreakpointParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseInputImagePromptCacheBreakpointParam) 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 ResponseInputImageContent struct {
@@ -9626,15 +11636,20 @@ type ResponseInputImageContent struct {
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"`
+ 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 ResponseInputImageContentPromptCacheBreakpoint `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
- ExtraFields map[string]respjson.Field
- raw string
+ Type respjson.Field
+ Detail respjson.Field
+ FileID respjson.Field
+ ImageURL respjson.Field
+ PromptCacheBreakpoint respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
} `json:"-"`
}
@@ -9665,6 +11680,26 @@ const (
ResponseInputImageContentDetailOriginal ResponseInputImageContentDetail = "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 ResponseInputImageContentPromptCacheBreakpoint 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 ResponseInputImageContentPromptCacheBreakpoint) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputImageContentPromptCacheBreakpoint) 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)
//
@@ -9674,12 +11709,16 @@ type ResponseInputImageContentParam struct {
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"`
+ 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 ResponseInputImageContentDetail `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 ResponseInputImageContentPromptCacheBreakpointParam `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".
@@ -9695,21 +11734,49 @@ func (r *ResponseInputImageContentParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+func NewResponseInputImageContentPromptCacheBreakpointParam() ResponseInputImageContentPromptCacheBreakpointParam {
+ return ResponseInputImageContentPromptCacheBreakpointParam{
+ 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
+// [NewResponseInputImageContentPromptCacheBreakpointParam].
+type ResponseInputImageContentPromptCacheBreakpointParam struct {
+ // The breakpoint mode. Always `explicit`.
+ Mode constant.Explicit `json:"mode" default:"explicit"`
+ paramObj
+}
+
+func (r ResponseInputImageContentPromptCacheBreakpointParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseInputImageContentPromptCacheBreakpointParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseInputImageContentPromptCacheBreakpointParam) 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],
// [ResponseInputItemToolSearchCall], [ResponseToolSearchOutputItemParamResp],
-// [ResponseReasoningItem], [ResponseCompactionItemParamResp],
-// [ResponseInputItemImageGenerationCall], [ResponseCodeInterpreterToolCall],
-// [ResponseInputItemLocalShellCall], [ResponseInputItemLocalShellCallOutput],
-// [ResponseInputItemShellCall], [ResponseInputItemShellCallOutput],
-// [ResponseInputItemApplyPatchCall], [ResponseInputItemApplyPatchCallOutput],
-// [ResponseInputItemMcpListTools], [ResponseInputItemMcpApprovalRequest],
-// [ResponseInputItemMcpApprovalResponse], [ResponseInputItemMcpCall],
-// [ResponseCustomToolCallOutput], [ResponseCustomToolCall],
-// [ResponseInputItemItemReference].
+// [ResponseInputItemAdditionalTools], [ResponseReasoningItem],
+// [ResponseCompactionItemParamResp], [ResponseInputItemImageGenerationCall],
+// [ResponseCodeInterpreterToolCall], [ResponseInputItemLocalShellCall],
+// [ResponseInputItemLocalShellCallOutput], [ResponseInputItemShellCall],
+// [ResponseInputItemShellCallOutput], [ResponseInputItemApplyPatchCall],
+// [ResponseInputItemApplyPatchCallOutput], [ResponseInputItemMcpListTools],
+// [ResponseInputItemMcpApprovalRequest], [ResponseInputItemMcpApprovalResponse],
+// [ResponseInputItemMcpCall], [ResponseCustomToolCallOutput],
+// [ResponseCustomToolCall], [ResponseInputItemCompactionTrigger],
+// [ResponseInputItemItemReference], [ResponseInputItemProgram],
+// [ResponseInputItemProgramOutput].
//
// Use the [ResponseInputItemUnion.AsAny] method to switch on the variant.
//
@@ -9723,12 +11790,14 @@ type ResponseInputItemUnion struct {
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", "tool_search_call", "tool_search_output", "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", "item_reference".
+ // "function_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"`
Status string `json:"status"`
ID string `json:"id"`
@@ -9755,17 +11824,24 @@ type ResponseInputItemUnion struct {
// This field is a union of [string], [any], [string], [string]
Arguments ResponseInputItemUnionArguments `json:"arguments"`
Name string `json:"name"`
- Namespace string `json:"namespace"`
- Execution string `json:"execution"`
- // This field is a union of [[]ToolUnion], [[]ResponseInputItemMcpListToolsTool]
+ // This field is a union of [ResponseFunctionToolCallCallerUnion],
+ // [ResponseInputItemFunctionCallOutputCallerUnion],
+ // [ResponseInputItemShellCallCallerUnion],
+ // [ResponseInputItemShellCallOutputCallerUnion],
+ // [ResponseInputItemApplyPatchCallCallerUnion],
+ // [ResponseInputItemApplyPatchCallOutputCallerUnion],
+ // [ResponseCustomToolCallOutputCallerUnion], [ResponseCustomToolCallCallerUnion]
+ Caller ResponseInputItemUnionCaller `json:"caller"`
+ Namespace string `json:"namespace"`
+ Execution string `json:"execution"`
+ // This field is a union of [[]ToolUnion], [[]ToolUnion],
+ // [[]ResponseInputItemMcpListToolsTool]
Tools ResponseInputItemUnionTools `json:"tools"`
// This field is from variant [ResponseReasoningItem].
Summary []ResponseReasoningItemSummary `json:"summary"`
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"`
+ Result string `json:"result"`
+ Code string `json:"code"`
// This field is from variant [ResponseCodeInterpreterToolCall].
ContainerID string `json:"container_id"`
// This field is from variant [ResponseCodeInterpreterToolCall].
@@ -9785,7 +11861,9 @@ type ResponseInputItemUnion struct {
Reason string `json:"reason"`
// This field is from variant [ResponseCustomToolCall].
Input string `json:"input"`
- JSON struct {
+ // This field is from variant [ResponseInputItemProgram].
+ Fingerprint string `json:"fingerprint"`
+ JSON struct {
Content respjson.Field
Role respjson.Field
Phase respjson.Field
@@ -9802,6 +11880,7 @@ type ResponseInputItemUnion struct {
AcknowledgedSafetyChecks respjson.Field
Arguments respjson.Field
Name respjson.Field
+ Caller respjson.Field
Namespace respjson.Field
Execution respjson.Field
Tools respjson.Field
@@ -9820,6 +11899,7 @@ type ResponseInputItemUnion struct {
Approve respjson.Field
Reason respjson.Field
Input respjson.Field
+ Fingerprint respjson.Field
raw string
} `json:"-"`
}
@@ -9841,6 +11921,7 @@ func (ResponseFunctionToolCall) implResponseInputItemUnion() {}
func (ResponseInputItemFunctionCallOutput) implResponseInputItemUnion() {}
func (ResponseInputItemToolSearchCall) implResponseInputItemUnion() {}
func (ResponseToolSearchOutputItemParamResp) implResponseInputItemUnion() {}
+func (ResponseInputItemAdditionalTools) implResponseInputItemUnion() {}
func (ResponseReasoningItem) implResponseInputItemUnion() {}
func (ResponseCompactionItemParamResp) implResponseInputItemUnion() {}
func (ResponseInputItemImageGenerationCall) implResponseInputItemUnion() {}
@@ -9857,7 +11938,10 @@ func (ResponseInputItemMcpApprovalResponse) implResponseInputItemUnion() {}
func (ResponseInputItemMcpCall) implResponseInputItemUnion() {}
func (ResponseCustomToolCallOutput) implResponseInputItemUnion() {}
func (ResponseCustomToolCall) implResponseInputItemUnion() {}
+func (ResponseInputItemCompactionTrigger) implResponseInputItemUnion() {}
func (ResponseInputItemItemReference) implResponseInputItemUnion() {}
+func (ResponseInputItemProgram) implResponseInputItemUnion() {}
+func (ResponseInputItemProgramOutput) implResponseInputItemUnion() {}
// Use the following switch statement to find the correct variant
//
@@ -9873,6 +11957,7 @@ func (ResponseInputItemItemReference) implResponseInputItemUnion() {}
// case responses.ResponseInputItemFunctionCallOutput:
// case responses.ResponseInputItemToolSearchCall:
// case responses.ResponseToolSearchOutputItemParamResp:
+// case responses.ResponseInputItemAdditionalTools:
// case responses.ResponseReasoningItem:
// case responses.ResponseCompactionItemParamResp:
// case responses.ResponseInputItemImageGenerationCall:
@@ -9889,7 +11974,10 @@ func (ResponseInputItemItemReference) implResponseInputItemUnion() {}
// case responses.ResponseInputItemMcpCall:
// case responses.ResponseCustomToolCallOutput:
// case responses.ResponseCustomToolCall:
+// case responses.ResponseInputItemCompactionTrigger:
// case responses.ResponseInputItemItemReference:
+// case responses.ResponseInputItemProgram:
+// case responses.ResponseInputItemProgramOutput:
// default:
// fmt.Errorf("no variant present")
// }
@@ -9913,6 +12001,8 @@ func (u ResponseInputItemUnion) AsAny() anyResponseInputItem {
return u.AsToolSearchCall()
case "tool_search_output":
return u.AsToolSearchOutput()
+ case "additional_tools":
+ return u.AsAdditionalTools()
case "reasoning":
return u.AsReasoning()
case "compaction":
@@ -9945,8 +12035,14 @@ func (u ResponseInputItemUnion) AsAny() anyResponseInputItem {
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
}
@@ -10006,6 +12102,11 @@ func (u ResponseInputItemUnion) AsToolSearchOutput() (v ResponseToolSearchOutput
return
}
+func (u ResponseInputItemUnion) AsAdditionalTools() (v ResponseInputItemAdditionalTools) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
func (u ResponseInputItemUnion) AsReasoning() (v ResponseReasoningItem) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
@@ -10086,11 +12187,26 @@ func (u ResponseInputItemUnion) AsCustomToolCall() (v ResponseCustomToolCall) {
return
}
+func (u ResponseInputItemUnion) AsCompactionTrigger() (v ResponseInputItemCompactionTrigger) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
func (u ResponseInputItemUnion) AsItemReference() (v ResponseInputItemItemReference) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
+func (u ResponseInputItemUnion) AsProgram() (v ResponseInputItemProgram) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInputItemUnion) AsProgramOutput() (v ResponseInputItemProgramOutput) {
+ 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 }
@@ -10155,10 +12271,10 @@ type ResponseInputItemUnionAction struct {
// This field is from variant [ResponseComputerToolCallActionUnion].
Text string `json:"text"`
// This field is from variant [ResponseFunctionWebSearchActionUnion].
- Query string `json:"query"`
- // This field is from variant [ResponseFunctionWebSearchActionUnion].
Queries []string `json:"queries"`
// This field is from variant [ResponseFunctionWebSearchActionUnion].
+ Query string `json:"query"`
+ // This field is from variant [ResponseFunctionWebSearchActionUnion].
Sources []ResponseFunctionWebSearchActionSearchSource `json:"sources"`
URL string `json:"url"`
// This field is from variant [ResponseFunctionWebSearchActionUnion].
@@ -10186,8 +12302,8 @@ type ResponseInputItemUnionAction struct {
ScrollX respjson.Field
ScrollY respjson.Field
Text respjson.Field
- Query respjson.Field
Queries respjson.Field
+ Query respjson.Field
Sources respjson.Field
URL respjson.Field
Pattern respjson.Field
@@ -10276,6 +12392,26 @@ func (r *ResponseInputItemUnionArguments) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+// ResponseInputItemUnionCaller is an implicit subunion of
+// [ResponseInputItemUnion]. ResponseInputItemUnionCaller 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 ResponseInputItemUnionCaller struct {
+ Type string `json:"type"`
+ CallerID string `json:"caller_id"`
+ JSON struct {
+ Type respjson.Field
+ CallerID respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+func (r *ResponseInputItemUnionCaller) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// ResponseInputItemUnionTools is an implicit subunion of [ResponseInputItemUnion].
// ResponseInputItemUnionTools provides convenient access to the sub-properties of
// the union.
@@ -10422,6 +12558,8 @@ type ResponseInputItemFunctionCallOutput struct {
// The unique ID of the function tool call output. Populated when this item is
// returned via API.
ID string `json:"id" api:"nullable"`
+ // The execution context that produced this tool call.
+ Caller ResponseInputItemFunctionCallOutputCallerUnion `json:"caller" api:"nullable"`
// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
// Populated when items are returned via API.
//
@@ -10433,6 +12571,7 @@ type ResponseInputItemFunctionCallOutput struct {
Output respjson.Field
Type respjson.Field
ID respjson.Field
+ Caller respjson.Field
Status respjson.Field
ExtraFields map[string]respjson.Field
raw string
@@ -10482,6 +12621,110 @@ func (r *ResponseInputItemFunctionCallOutputOutputUnion) UnmarshalJSON(data []by
return apijson.UnmarshalRoot(data, r)
}
+// ResponseInputItemFunctionCallOutputCallerUnion contains all possible properties
+// and values from [ResponseInputItemFunctionCallOutputCallerDirect],
+// [ResponseInputItemFunctionCallOutputCallerProgram].
+//
+// Use the [ResponseInputItemFunctionCallOutputCallerUnion.AsAny] method to switch
+// on the variant.
+//
+// Use the methods beginning with 'As' to cast the union to one of its variants.
+type ResponseInputItemFunctionCallOutputCallerUnion struct {
+ // Any of "direct", "program".
+ Type string `json:"type"`
+ // This field is from variant [ResponseInputItemFunctionCallOutputCallerProgram].
+ CallerID string `json:"caller_id"`
+ JSON struct {
+ Type respjson.Field
+ CallerID respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// anyResponseInputItemFunctionCallOutputCaller is implemented by each variant of
+// [ResponseInputItemFunctionCallOutputCallerUnion] to add type safety for the
+// return type of [ResponseInputItemFunctionCallOutputCallerUnion.AsAny]
+type anyResponseInputItemFunctionCallOutputCaller interface {
+ implResponseInputItemFunctionCallOutputCallerUnion()
+}
+
+func (ResponseInputItemFunctionCallOutputCallerDirect) implResponseInputItemFunctionCallOutputCallerUnion() {
+}
+func (ResponseInputItemFunctionCallOutputCallerProgram) implResponseInputItemFunctionCallOutputCallerUnion() {
+}
+
+// Use the following switch statement to find the correct variant
+//
+// switch variant := ResponseInputItemFunctionCallOutputCallerUnion.AsAny().(type) {
+// case responses.ResponseInputItemFunctionCallOutputCallerDirect:
+// case responses.ResponseInputItemFunctionCallOutputCallerProgram:
+// default:
+// fmt.Errorf("no variant present")
+// }
+func (u ResponseInputItemFunctionCallOutputCallerUnion) AsAny() anyResponseInputItemFunctionCallOutputCaller {
+ switch u.Type {
+ case "direct":
+ return u.AsDirect()
+ case "program":
+ return u.AsProgram()
+ }
+ return nil
+}
+
+func (u ResponseInputItemFunctionCallOutputCallerUnion) AsDirect() (v ResponseInputItemFunctionCallOutputCallerDirect) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInputItemFunctionCallOutputCallerUnion) AsProgram() (v ResponseInputItemFunctionCallOutputCallerProgram) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+// Returns the unmodified JSON received from the API
+func (u ResponseInputItemFunctionCallOutputCallerUnion) RawJSON() string { return u.JSON.raw }
+
+func (r *ResponseInputItemFunctionCallOutputCallerUnion) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseInputItemFunctionCallOutputCallerDirect 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 ResponseInputItemFunctionCallOutputCallerDirect) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemFunctionCallOutputCallerDirect) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseInputItemFunctionCallOutputCallerProgram 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 ResponseInputItemFunctionCallOutputCallerProgram) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemFunctionCallOutputCallerProgram) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
type ResponseInputItemToolSearchCall struct {
// The arguments supplied to the tool search call.
Arguments any `json:"arguments" api:"required"`
@@ -10518,6 +12761,32 @@ func (r *ResponseInputItemToolSearchCall) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+type ResponseInputItemAdditionalTools 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 []ToolUnion `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"`
+ // 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
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseInputItemAdditionalTools) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemAdditionalTools) 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.
@@ -10652,6 +12921,8 @@ type ResponseInputItemShellCall struct {
// The unique ID of the shell tool call. Populated when this item is returned via
// API.
ID string `json:"id" api:"nullable"`
+ // The execution context that produced this tool call.
+ Caller ResponseInputItemShellCallCallerUnion `json:"caller" api:"nullable"`
// The environment to execute the shell commands in.
Environment ResponseInputItemShellCallEnvironmentUnion `json:"environment" api:"nullable"`
// The status of the shell call. One of `in_progress`, `completed`, or
@@ -10661,45 +12932,148 @@ type ResponseInputItemShellCall struct {
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
+ Action respjson.Field
+ CallID respjson.Field
+ Type respjson.Field
+ ID 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 ResponseInputItemShellCall) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemShellCall) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// The shell commands and limits that describe how to run the tool call.
+type ResponseInputItemShellCallAction 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 ResponseInputItemShellCallAction) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemShellCallAction) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// ResponseInputItemShellCallCallerUnion contains all possible properties and
+// values from [ResponseInputItemShellCallCallerDirect],
+// [ResponseInputItemShellCallCallerProgram].
+//
+// Use the [ResponseInputItemShellCallCallerUnion.AsAny] method to switch on the
+// variant.
+//
+// Use the methods beginning with 'As' to cast the union to one of its variants.
+type ResponseInputItemShellCallCallerUnion struct {
+ // Any of "direct", "program".
+ Type string `json:"type"`
+ // This field is from variant [ResponseInputItemShellCallCallerProgram].
+ CallerID string `json:"caller_id"`
+ JSON struct {
+ Type respjson.Field
+ CallerID respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// anyResponseInputItemShellCallCaller is implemented by each variant of
+// [ResponseInputItemShellCallCallerUnion] to add type safety for the return type
+// of [ResponseInputItemShellCallCallerUnion.AsAny]
+type anyResponseInputItemShellCallCaller interface {
+ implResponseInputItemShellCallCallerUnion()
+}
+
+func (ResponseInputItemShellCallCallerDirect) implResponseInputItemShellCallCallerUnion() {}
+func (ResponseInputItemShellCallCallerProgram) implResponseInputItemShellCallCallerUnion() {}
+
+// Use the following switch statement to find the correct variant
+//
+// switch variant := ResponseInputItemShellCallCallerUnion.AsAny().(type) {
+// case responses.ResponseInputItemShellCallCallerDirect:
+// case responses.ResponseInputItemShellCallCallerProgram:
+// default:
+// fmt.Errorf("no variant present")
+// }
+func (u ResponseInputItemShellCallCallerUnion) AsAny() anyResponseInputItemShellCallCaller {
+ switch u.Type {
+ case "direct":
+ return u.AsDirect()
+ case "program":
+ return u.AsProgram()
+ }
+ return nil
+}
+
+func (u ResponseInputItemShellCallCallerUnion) AsDirect() (v ResponseInputItemShellCallCallerDirect) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInputItemShellCallCallerUnion) AsProgram() (v ResponseInputItemShellCallCallerProgram) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+// Returns the unmodified JSON received from the API
+func (u ResponseInputItemShellCallCallerUnion) RawJSON() string { return u.JSON.raw }
+
+func (r *ResponseInputItemShellCallCallerUnion) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseInputItemShellCallCallerDirect 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
- ID 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 ResponseInputItemShellCall) RawJSON() string { return r.JSON.raw }
-func (r *ResponseInputItemShellCall) UnmarshalJSON(data []byte) error {
+func (r ResponseInputItemShellCallCallerDirect) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemShellCallCallerDirect) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
-// The shell commands and limits that describe how to run the tool call.
-type ResponseInputItemShellCallAction 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"`
+type ResponseInputItemShellCallCallerProgram 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 {
- Commands respjson.Field
- MaxOutputLength respjson.Field
- TimeoutMs respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
+ CallerID respjson.Field
+ Type respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
-func (r ResponseInputItemShellCallAction) RawJSON() string { return r.JSON.raw }
-func (r *ResponseInputItemShellCallAction) UnmarshalJSON(data []byte) error {
+func (r ResponseInputItemShellCallCallerProgram) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemShellCallCallerProgram) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
@@ -10782,6 +13156,8 @@ type ResponseInputItemShellCallOutput struct {
// The unique ID of the shell tool call output. Populated when this item is
// returned via API.
ID string `json:"id" api:"nullable"`
+ // The execution context that produced this tool call.
+ Caller ResponseInputItemShellCallOutputCallerUnion `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"`
@@ -10795,6 +13171,7 @@ type ResponseInputItemShellCallOutput struct {
Output respjson.Field
Type respjson.Field
ID respjson.Field
+ Caller respjson.Field
MaxOutputLength respjson.Field
Status respjson.Field
ExtraFields map[string]respjson.Field
@@ -10808,6 +13185,110 @@ func (r *ResponseInputItemShellCallOutput) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+// ResponseInputItemShellCallOutputCallerUnion contains all possible properties and
+// values from [ResponseInputItemShellCallOutputCallerDirect],
+// [ResponseInputItemShellCallOutputCallerProgram].
+//
+// Use the [ResponseInputItemShellCallOutputCallerUnion.AsAny] method to switch on
+// the variant.
+//
+// Use the methods beginning with 'As' to cast the union to one of its variants.
+type ResponseInputItemShellCallOutputCallerUnion struct {
+ // Any of "direct", "program".
+ Type string `json:"type"`
+ // This field is from variant [ResponseInputItemShellCallOutputCallerProgram].
+ CallerID string `json:"caller_id"`
+ JSON struct {
+ Type respjson.Field
+ CallerID respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// anyResponseInputItemShellCallOutputCaller is implemented by each variant of
+// [ResponseInputItemShellCallOutputCallerUnion] to add type safety for the return
+// type of [ResponseInputItemShellCallOutputCallerUnion.AsAny]
+type anyResponseInputItemShellCallOutputCaller interface {
+ implResponseInputItemShellCallOutputCallerUnion()
+}
+
+func (ResponseInputItemShellCallOutputCallerDirect) implResponseInputItemShellCallOutputCallerUnion() {
+}
+func (ResponseInputItemShellCallOutputCallerProgram) implResponseInputItemShellCallOutputCallerUnion() {
+}
+
+// Use the following switch statement to find the correct variant
+//
+// switch variant := ResponseInputItemShellCallOutputCallerUnion.AsAny().(type) {
+// case responses.ResponseInputItemShellCallOutputCallerDirect:
+// case responses.ResponseInputItemShellCallOutputCallerProgram:
+// default:
+// fmt.Errorf("no variant present")
+// }
+func (u ResponseInputItemShellCallOutputCallerUnion) AsAny() anyResponseInputItemShellCallOutputCaller {
+ switch u.Type {
+ case "direct":
+ return u.AsDirect()
+ case "program":
+ return u.AsProgram()
+ }
+ return nil
+}
+
+func (u ResponseInputItemShellCallOutputCallerUnion) AsDirect() (v ResponseInputItemShellCallOutputCallerDirect) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInputItemShellCallOutputCallerUnion) AsProgram() (v ResponseInputItemShellCallOutputCallerProgram) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+// Returns the unmodified JSON received from the API
+func (u ResponseInputItemShellCallOutputCallerUnion) RawJSON() string { return u.JSON.raw }
+
+func (r *ResponseInputItemShellCallOutputCallerUnion) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseInputItemShellCallOutputCallerDirect 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 ResponseInputItemShellCallOutputCallerDirect) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemShellCallOutputCallerDirect) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseInputItemShellCallOutputCallerProgram 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 ResponseInputItemShellCallOutputCallerProgram) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemShellCallOutputCallerProgram) 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 ResponseInputItemApplyPatchCall struct {
@@ -10825,6 +13306,8 @@ type ResponseInputItemApplyPatchCall struct {
// The unique ID of the apply patch tool call. Populated when this item is returned
// via API.
ID string `json:"id" api:"nullable"`
+ // The execution context that produced this tool call.
+ Caller ResponseInputItemApplyPatchCallCallerUnion `json:"caller" api:"nullable"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
CallID respjson.Field
@@ -10832,6 +13315,7 @@ type ResponseInputItemApplyPatchCall struct {
Status respjson.Field
Type respjson.Field
ID respjson.Field
+ Caller respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
@@ -10962,23 +13446,247 @@ type ResponseInputItemApplyPatchCallOperationDeleteFile struct {
}
// Returns the unmodified JSON received from the API
-func (r ResponseInputItemApplyPatchCallOperationDeleteFile) RawJSON() string { return r.JSON.raw }
-func (r *ResponseInputItemApplyPatchCallOperationDeleteFile) UnmarshalJSON(data []byte) error {
+func (r ResponseInputItemApplyPatchCallOperationDeleteFile) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemApplyPatchCallOperationDeleteFile) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// Instruction for updating an existing file via the apply_patch tool.
+type ResponseInputItemApplyPatchCallOperationUpdateFile 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 ResponseInputItemApplyPatchCallOperationUpdateFile) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemApplyPatchCallOperationUpdateFile) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// ResponseInputItemApplyPatchCallCallerUnion contains all possible properties and
+// values from [ResponseInputItemApplyPatchCallCallerDirect],
+// [ResponseInputItemApplyPatchCallCallerProgram].
+//
+// Use the [ResponseInputItemApplyPatchCallCallerUnion.AsAny] method to switch on
+// the variant.
+//
+// Use the methods beginning with 'As' to cast the union to one of its variants.
+type ResponseInputItemApplyPatchCallCallerUnion struct {
+ // Any of "direct", "program".
+ Type string `json:"type"`
+ // This field is from variant [ResponseInputItemApplyPatchCallCallerProgram].
+ CallerID string `json:"caller_id"`
+ JSON struct {
+ Type respjson.Field
+ CallerID respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// anyResponseInputItemApplyPatchCallCaller is implemented by each variant of
+// [ResponseInputItemApplyPatchCallCallerUnion] to add type safety for the return
+// type of [ResponseInputItemApplyPatchCallCallerUnion.AsAny]
+type anyResponseInputItemApplyPatchCallCaller interface {
+ implResponseInputItemApplyPatchCallCallerUnion()
+}
+
+func (ResponseInputItemApplyPatchCallCallerDirect) implResponseInputItemApplyPatchCallCallerUnion() {}
+func (ResponseInputItemApplyPatchCallCallerProgram) implResponseInputItemApplyPatchCallCallerUnion() {
+}
+
+// Use the following switch statement to find the correct variant
+//
+// switch variant := ResponseInputItemApplyPatchCallCallerUnion.AsAny().(type) {
+// case responses.ResponseInputItemApplyPatchCallCallerDirect:
+// case responses.ResponseInputItemApplyPatchCallCallerProgram:
+// default:
+// fmt.Errorf("no variant present")
+// }
+func (u ResponseInputItemApplyPatchCallCallerUnion) AsAny() anyResponseInputItemApplyPatchCallCaller {
+ switch u.Type {
+ case "direct":
+ return u.AsDirect()
+ case "program":
+ return u.AsProgram()
+ }
+ return nil
+}
+
+func (u ResponseInputItemApplyPatchCallCallerUnion) AsDirect() (v ResponseInputItemApplyPatchCallCallerDirect) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInputItemApplyPatchCallCallerUnion) AsProgram() (v ResponseInputItemApplyPatchCallCallerProgram) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+// Returns the unmodified JSON received from the API
+func (u ResponseInputItemApplyPatchCallCallerUnion) RawJSON() string { return u.JSON.raw }
+
+func (r *ResponseInputItemApplyPatchCallCallerUnion) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseInputItemApplyPatchCallCallerDirect 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 ResponseInputItemApplyPatchCallCallerDirect) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemApplyPatchCallCallerDirect) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseInputItemApplyPatchCallCallerProgram 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 ResponseInputItemApplyPatchCallCallerProgram) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemApplyPatchCallCallerProgram) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// The streamed output emitted by an apply patch tool call.
+type ResponseInputItemApplyPatchCallOutput 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 execution context that produced this tool call.
+ Caller ResponseInputItemApplyPatchCallOutputCallerUnion `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
+ Caller respjson.Field
+ Output respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseInputItemApplyPatchCallOutput) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemApplyPatchCallOutput) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// ResponseInputItemApplyPatchCallOutputCallerUnion contains all possible
+// properties and values from [ResponseInputItemApplyPatchCallOutputCallerDirect],
+// [ResponseInputItemApplyPatchCallOutputCallerProgram].
+//
+// Use the [ResponseInputItemApplyPatchCallOutputCallerUnion.AsAny] method to
+// switch on the variant.
+//
+// Use the methods beginning with 'As' to cast the union to one of its variants.
+type ResponseInputItemApplyPatchCallOutputCallerUnion struct {
+ // Any of "direct", "program".
+ Type string `json:"type"`
+ // This field is from variant [ResponseInputItemApplyPatchCallOutputCallerProgram].
+ CallerID string `json:"caller_id"`
+ JSON struct {
+ Type respjson.Field
+ CallerID respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// anyResponseInputItemApplyPatchCallOutputCaller is implemented by each variant of
+// [ResponseInputItemApplyPatchCallOutputCallerUnion] to add type safety for the
+// return type of [ResponseInputItemApplyPatchCallOutputCallerUnion.AsAny]
+type anyResponseInputItemApplyPatchCallOutputCaller interface {
+ implResponseInputItemApplyPatchCallOutputCallerUnion()
+}
+
+func (ResponseInputItemApplyPatchCallOutputCallerDirect) implResponseInputItemApplyPatchCallOutputCallerUnion() {
+}
+func (ResponseInputItemApplyPatchCallOutputCallerProgram) implResponseInputItemApplyPatchCallOutputCallerUnion() {
+}
+
+// Use the following switch statement to find the correct variant
+//
+// switch variant := ResponseInputItemApplyPatchCallOutputCallerUnion.AsAny().(type) {
+// case responses.ResponseInputItemApplyPatchCallOutputCallerDirect:
+// case responses.ResponseInputItemApplyPatchCallOutputCallerProgram:
+// default:
+// fmt.Errorf("no variant present")
+// }
+func (u ResponseInputItemApplyPatchCallOutputCallerUnion) AsAny() anyResponseInputItemApplyPatchCallOutputCaller {
+ switch u.Type {
+ case "direct":
+ return u.AsDirect()
+ case "program":
+ return u.AsProgram()
+ }
+ return nil
+}
+
+func (u ResponseInputItemApplyPatchCallOutputCallerUnion) AsDirect() (v ResponseInputItemApplyPatchCallOutputCallerDirect) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInputItemApplyPatchCallOutputCallerUnion) AsProgram() (v ResponseInputItemApplyPatchCallOutputCallerProgram) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+// Returns the unmodified JSON received from the API
+func (u ResponseInputItemApplyPatchCallOutputCallerUnion) RawJSON() string { return u.JSON.raw }
+
+func (r *ResponseInputItemApplyPatchCallOutputCallerUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
-// Instruction for updating an existing file via the apply_patch tool.
-type ResponseInputItemApplyPatchCallOperationUpdateFile 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"`
+type ResponseInputItemApplyPatchCallOutputCallerDirect 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 {
- Diff respjson.Field
- Path respjson.Field
Type respjson.Field
ExtraFields map[string]respjson.Field
raw string
@@ -10986,42 +13694,28 @@ type ResponseInputItemApplyPatchCallOperationUpdateFile struct {
}
// Returns the unmodified JSON received from the API
-func (r ResponseInputItemApplyPatchCallOperationUpdateFile) RawJSON() string { return r.JSON.raw }
-func (r *ResponseInputItemApplyPatchCallOperationUpdateFile) UnmarshalJSON(data []byte) error {
+func (r ResponseInputItemApplyPatchCallOutputCallerDirect) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemApplyPatchCallOutputCallerDirect) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
-// The streamed output emitted by an apply patch tool call.
-type ResponseInputItemApplyPatchCallOutput 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"`
- // Optional human-readable log text from the apply patch tool (e.g., patch results
- // or errors).
- Output string `json:"output" api:"nullable"`
+type ResponseInputItemApplyPatchCallOutputCallerProgram 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 {
- CallID respjson.Field
- Status respjson.Field
+ CallerID respjson.Field
Type respjson.Field
- ID respjson.Field
- Output respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
-func (r ResponseInputItemApplyPatchCallOutput) RawJSON() string { return r.JSON.raw }
-func (r *ResponseInputItemApplyPatchCallOutput) UnmarshalJSON(data []byte) error {
+func (r ResponseInputItemApplyPatchCallOutputCallerProgram) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemApplyPatchCallOutputCallerProgram) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
@@ -11189,6 +13883,24 @@ func (r *ResponseInputItemMcpCall) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+// Compacts the current context. Must be the final input item.
+type ResponseInputItemCompactionTrigger struct {
+ // The type of the item. Always `compaction_trigger`.
+ Type constant.CompactionTrigger `json:"type" default:"compaction_trigger"`
+ // 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 ResponseInputItemCompactionTrigger) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemCompactionTrigger) 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.
@@ -11212,6 +13924,66 @@ func (r *ResponseInputItemItemReference) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+type ResponseInputItemProgram 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"`
+ // 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
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseInputItemProgram) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemProgram) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseInputItemProgramOutput 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"`
+ // 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
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseInputItemProgramOutput) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputItemProgramOutput) 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) {
@@ -11303,6 +14075,12 @@ func ResponseInputItemParamOfToolSearchOutput(tools []ToolUnionParam) ResponseIn
return ResponseInputItemUnionParam{OfToolSearchOutput: &toolSearchOutput}
}
+func ResponseInputItemParamOfAdditionalTools(tools []ToolUnionParam) ResponseInputItemUnionParam {
+ var additionalTools ResponseInputItemAdditionalToolsParam
+ additionalTools.Tools = tools
+ return ResponseInputItemUnionParam{OfAdditionalTools: &additionalTools}
+}
+
func ResponseInputItemParamOfReasoning(id string, summary []ResponseReasoningItemSummaryParam) ResponseInputItemUnionParam {
var reasoning ResponseReasoningItemParam
reasoning.ID = id
@@ -11427,6 +14205,7 @@ type ResponseInputItemUnionParam struct {
OfFunctionCallOutput *ResponseInputItemFunctionCallOutputParam `json:",omitzero,inline"`
OfToolSearchCall *ResponseInputItemToolSearchCallParam `json:",omitzero,inline"`
OfToolSearchOutput *ResponseToolSearchOutputItemParam `json:",omitzero,inline"`
+ OfAdditionalTools *ResponseInputItemAdditionalToolsParam `json:",omitzero,inline"`
OfReasoning *ResponseReasoningItemParam `json:",omitzero,inline"`
OfCompaction *ResponseCompactionItemParam `json:",omitzero,inline"`
OfImageGenerationCall *ResponseInputItemImageGenerationCallParam `json:",omitzero,inline"`
@@ -11443,7 +14222,10 @@ type ResponseInputItemUnionParam struct {
OfMcpCall *ResponseInputItemMcpCallParam `json:",omitzero,inline"`
OfCustomToolCallOutput *ResponseCustomToolCallOutputParam `json:",omitzero,inline"`
OfCustomToolCall *ResponseCustomToolCallParam `json:",omitzero,inline"`
+ OfCompactionTrigger *ResponseInputItemCompactionTriggerParam `json:",omitzero,inline"`
OfItemReference *ResponseInputItemItemReferenceParam `json:",omitzero,inline"`
+ OfProgram *ResponseInputItemProgramParam `json:",omitzero,inline"`
+ OfProgramOutput *ResponseInputItemProgramOutputParam `json:",omitzero,inline"`
paramUnion
}
@@ -11459,6 +14241,7 @@ func (u ResponseInputItemUnionParam) MarshalJSON() ([]byte, error) {
u.OfFunctionCallOutput,
u.OfToolSearchCall,
u.OfToolSearchOutput,
+ u.OfAdditionalTools,
u.OfReasoning,
u.OfCompaction,
u.OfImageGenerationCall,
@@ -11475,7 +14258,10 @@ func (u ResponseInputItemUnionParam) MarshalJSON() ([]byte, error) {
u.OfMcpCall,
u.OfCustomToolCallOutput,
u.OfCustomToolCall,
- u.OfItemReference)
+ u.OfCompactionTrigger,
+ u.OfItemReference,
+ u.OfProgram,
+ u.OfProgramOutput)
}
func (u *ResponseInputItemUnionParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, u)
@@ -11504,6 +14290,8 @@ func (u *ResponseInputItemUnionParam) asAny() any {
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) {
@@ -11536,8 +14324,14 @@ func (u *ResponseInputItemUnionParam) asAny() any {
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
}
@@ -11590,22 +14384,6 @@ func (u ResponseInputItemUnionParam) GetSummary() []ResponseReasoningItemSummary
return nil
}
-// Returns a pointer to the underlying variant's property, if present.
-func (u ResponseInputItemUnionParam) GetResult() *string {
- if vt := u.OfImageGenerationCall; vt != nil && vt.Result.Valid() {
- return &vt.Result.Value
- }
- return nil
-}
-
-// Returns a pointer to the underlying variant's property, if present.
-func (u ResponseInputItemUnionParam) GetCode() *string {
- if vt := u.OfCodeInterpreterCall; vt != nil && vt.Code.Valid() {
- return &vt.Code.Value
- }
- return nil
-}
-
// Returns a pointer to the underlying variant's property, if present.
func (u ResponseInputItemUnionParam) GetContainerID() *string {
if vt := u.OfCodeInterpreterCall; vt != nil {
@@ -11670,6 +14448,14 @@ func (u ResponseInputItemUnionParam) GetInput() *string {
return nil
}
+// Returns a pointer to the underlying variant's property, if present.
+func (u ResponseInputItemUnionParam) 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 ResponseInputItemUnionParam) GetRole() *string {
if vt := u.OfMessage; vt != nil {
@@ -11678,6 +14464,8 @@ func (u ResponseInputItemUnionParam) GetRole() *string {
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
}
@@ -11716,6 +14504,8 @@ func (u ResponseInputItemUnionParam) GetType() *string {
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 {
@@ -11748,8 +14538,14 @@ func (u ResponseInputItemUnionParam) GetType() *string {
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
}
@@ -11796,6 +14592,8 @@ func (u ResponseInputItemUnionParam) GetStatus() *string {
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
}
@@ -11820,6 +14618,8 @@ func (u ResponseInputItemUnionParam) GetID() *string {
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() {
@@ -11854,6 +14654,10 @@ func (u ResponseInputItemUnionParam) GetID() *string {
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
}
@@ -11886,6 +14690,10 @@ func (u ResponseInputItemUnionParam) GetCallID() *string {
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
}
@@ -11934,6 +14742,26 @@ func (u ResponseInputItemUnionParam) GetEncryptedContent() *string {
return nil
}
+// Returns a pointer to the underlying variant's property, if present.
+func (u ResponseInputItemUnionParam) 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 ResponseInputItemUnionParam) 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 ResponseInputItemUnionParam) GetServerLabel() *string {
if vt := u.OfMcpListTools; vt != nil {
@@ -12099,19 +14927,19 @@ func (u responseInputItemUnionParamAction) GetText() *string {
}
// Returns a pointer to the underlying variant's property, if present.
-func (u responseInputItemUnionParamAction) GetQuery() *string {
+func (u responseInputItemUnionParamAction) GetQueries() []string {
switch vt := u.any.(type) {
case *ResponseFunctionWebSearchActionUnionParam:
- return vt.GetQuery()
+ return vt.GetQueries()
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
-func (u responseInputItemUnionParamAction) GetQueries() []string {
+func (u responseInputItemUnionParamAction) GetQuery() *string {
switch vt := u.any.(type) {
case *ResponseFunctionWebSearchActionUnionParam:
- return vt.GetQueries()
+ return vt.GetQuery()
}
return nil
}
@@ -12318,12 +15146,126 @@ type responseInputItemUnionParamArguments struct{ any }
// }
func (u responseInputItemUnionParamArguments) AsAny() any { return u.any }
+// Returns a subunion which exports methods to access subproperties
+//
+// Or use AsAny() to get the underlying value
+func (u ResponseInputItemUnionParam) GetCaller() (res responseInputItemUnionParamCaller) {
+ 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 [*ResponseFunctionToolCallCallerDirectParam],
+// [*ResponseFunctionToolCallCallerProgramParam],
+// [*ResponseInputItemFunctionCallOutputCallerDirectParam],
+// [*ResponseInputItemFunctionCallOutputCallerProgramParam],
+// [*ResponseInputItemShellCallCallerDirectParam],
+// [*ResponseInputItemShellCallCallerProgramParam],
+// [*ResponseInputItemShellCallOutputCallerDirectParam],
+// [*ResponseInputItemShellCallOutputCallerProgramParam],
+// [*ResponseInputItemApplyPatchCallCallerDirectParam],
+// [*ResponseInputItemApplyPatchCallCallerProgramParam],
+// [*ResponseInputItemApplyPatchCallOutputCallerDirectParam],
+// [*ResponseInputItemApplyPatchCallOutputCallerProgramParam],
+// [*ResponseCustomToolCallOutputCallerDirectParam],
+// [*ResponseCustomToolCallOutputCallerProgramParam],
+// [*ResponseCustomToolCallCallerDirectParam],
+// [*ResponseCustomToolCallCallerProgramParam]
+type responseInputItemUnionParamCaller struct{ any }
+
+// Use the following switch statement to get the type of the union:
+//
+// switch u.AsAny().(type) {
+// case *responses.ResponseFunctionToolCallCallerDirectParam:
+// case *responses.ResponseFunctionToolCallCallerProgramParam:
+// case *responses.ResponseInputItemFunctionCallOutputCallerDirectParam:
+// case *responses.ResponseInputItemFunctionCallOutputCallerProgramParam:
+// case *responses.ResponseInputItemShellCallCallerDirectParam:
+// case *responses.ResponseInputItemShellCallCallerProgramParam:
+// case *responses.ResponseInputItemShellCallOutputCallerDirectParam:
+// case *responses.ResponseInputItemShellCallOutputCallerProgramParam:
+// case *responses.ResponseInputItemApplyPatchCallCallerDirectParam:
+// case *responses.ResponseInputItemApplyPatchCallCallerProgramParam:
+// case *responses.ResponseInputItemApplyPatchCallOutputCallerDirectParam:
+// case *responses.ResponseInputItemApplyPatchCallOutputCallerProgramParam:
+// case *responses.ResponseCustomToolCallOutputCallerDirectParam:
+// case *responses.ResponseCustomToolCallOutputCallerProgramParam:
+// case *responses.ResponseCustomToolCallCallerDirectParam:
+// case *responses.ResponseCustomToolCallCallerProgramParam:
+// default:
+// fmt.Errorf("not present")
+// }
+func (u responseInputItemUnionParamCaller) AsAny() any { return u.any }
+
+// Returns a pointer to the underlying variant's property, if present.
+func (u responseInputItemUnionParamCaller) GetType() *string {
+ switch vt := u.any.(type) {
+ case *ResponseFunctionToolCallCallerUnionParam:
+ return vt.GetType()
+ case *ResponseInputItemFunctionCallOutputCallerUnionParam:
+ return vt.GetType()
+ case *ResponseInputItemShellCallCallerUnionParam:
+ return vt.GetType()
+ case *ResponseInputItemShellCallOutputCallerUnionParam:
+ return vt.GetType()
+ case *ResponseInputItemApplyPatchCallCallerUnionParam:
+ return vt.GetType()
+ case *ResponseInputItemApplyPatchCallOutputCallerUnionParam:
+ return vt.GetType()
+ case *ResponseCustomToolCallOutputCallerUnionParam:
+ return vt.GetType()
+ case *ResponseCustomToolCallCallerUnionParam:
+ return vt.GetType()
+ }
+ return nil
+}
+
+// Returns a pointer to the underlying variant's property, if present.
+func (u responseInputItemUnionParamCaller) GetCallerID() *string {
+ switch vt := u.any.(type) {
+ case *ResponseFunctionToolCallCallerUnionParam:
+ return vt.GetCallerID()
+ case *ResponseInputItemFunctionCallOutputCallerUnionParam:
+ return vt.GetCallerID()
+ case *ResponseInputItemShellCallCallerUnionParam:
+ return vt.GetCallerID()
+ case *ResponseInputItemShellCallOutputCallerUnionParam:
+ return vt.GetCallerID()
+ case *ResponseInputItemApplyPatchCallCallerUnionParam:
+ return vt.GetCallerID()
+ case *ResponseInputItemApplyPatchCallOutputCallerUnionParam:
+ return vt.GetCallerID()
+ case *ResponseCustomToolCallOutputCallerUnionParam:
+ return vt.GetCallerID()
+ case *ResponseCustomToolCallCallerUnionParam:
+ return vt.GetCallerID()
+ }
+ return nil
+}
+
// Returns a subunion which exports methods to access subproperties
//
// Or use AsAny() to get the underlying value
func (u ResponseInputItemUnionParam) GetTools() (res responseInputItemUnionParamTools) {
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
}
@@ -12358,6 +15300,7 @@ func init() {
apijson.Discriminator[ResponseInputItemFunctionCallOutputParam]("function_call_output"),
apijson.Discriminator[ResponseInputItemToolSearchCallParam]("tool_search_call"),
apijson.Discriminator[ResponseToolSearchOutputItemParam]("tool_search_output"),
+ apijson.Discriminator[ResponseInputItemAdditionalToolsParam]("additional_tools"),
apijson.Discriminator[ResponseReasoningItemParam]("reasoning"),
apijson.Discriminator[ResponseCompactionItemParam]("compaction"),
apijson.Discriminator[ResponseInputItemImageGenerationCallParam]("image_generation_call"),
@@ -12374,7 +15317,10 @@ func init() {
apijson.Discriminator[ResponseInputItemMcpCallParam]("mcp_call"),
apijson.Discriminator[ResponseCustomToolCallOutputParam]("custom_tool_call_output"),
apijson.Discriminator[ResponseCustomToolCallParam]("custom_tool_call"),
+ apijson.Discriminator[ResponseInputItemCompactionTriggerParam]("compaction_trigger"),
apijson.Discriminator[ResponseInputItemItemReferenceParam]("item_reference"),
+ apijson.Discriminator[ResponseInputItemProgramParam]("program"),
+ apijson.Discriminator[ResponseInputItemProgramOutputParam]("program_output"),
)
}
@@ -12495,6 +15441,8 @@ type ResponseInputItemFunctionCallOutputParam struct {
// 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 execution context that produced this tool call.
+ Caller ResponseInputItemFunctionCallOutputCallerUnionParam `json:"caller,omitzero"`
// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
// Populated when items are returned via API.
//
@@ -12547,6 +15495,98 @@ func (u *ResponseInputItemFunctionCallOutputOutputUnionParam) asAny() any {
return nil
}
+// Only one field can be non-zero.
+//
+// Use [param.IsOmitted] to confirm if a field is set.
+type ResponseInputItemFunctionCallOutputCallerUnionParam struct {
+ OfDirect *ResponseInputItemFunctionCallOutputCallerDirectParam `json:",omitzero,inline"`
+ OfProgram *ResponseInputItemFunctionCallOutputCallerProgramParam `json:",omitzero,inline"`
+ paramUnion
+}
+
+func (u ResponseInputItemFunctionCallOutputCallerUnionParam) MarshalJSON() ([]byte, error) {
+ return param.MarshalUnion(u, u.OfDirect, u.OfProgram)
+}
+func (u *ResponseInputItemFunctionCallOutputCallerUnionParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, u)
+}
+
+func (u *ResponseInputItemFunctionCallOutputCallerUnionParam) 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 ResponseInputItemFunctionCallOutputCallerUnionParam) 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 ResponseInputItemFunctionCallOutputCallerUnionParam) 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[ResponseInputItemFunctionCallOutputCallerUnionParam](
+ "type",
+ apijson.Discriminator[ResponseInputItemFunctionCallOutputCallerDirectParam]("direct"),
+ apijson.Discriminator[ResponseInputItemFunctionCallOutputCallerProgramParam]("program"),
+ )
+}
+
+func NewResponseInputItemFunctionCallOutputCallerDirectParam() ResponseInputItemFunctionCallOutputCallerDirectParam {
+ return ResponseInputItemFunctionCallOutputCallerDirectParam{
+ Type: "direct",
+ }
+}
+
+// This struct has a constant value, construct it with
+// [NewResponseInputItemFunctionCallOutputCallerDirectParam].
+type ResponseInputItemFunctionCallOutputCallerDirectParam struct {
+ // The caller type. Always `direct`.
+ Type constant.Direct `json:"type" default:"direct"`
+ paramObj
+}
+
+func (r ResponseInputItemFunctionCallOutputCallerDirectParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseInputItemFunctionCallOutputCallerDirectParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseInputItemFunctionCallOutputCallerDirectParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// The properties CallerID, Type are required.
+type ResponseInputItemFunctionCallOutputCallerProgramParam 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 ResponseInputItemFunctionCallOutputCallerProgramParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseInputItemFunctionCallOutputCallerProgramParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseInputItemFunctionCallOutputCallerProgramParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// The properties Arguments, Type are required.
type ResponseInputItemToolSearchCallParam struct {
// The arguments supplied to the tool search call.
@@ -12587,6 +15627,31 @@ func init() {
)
}
+// The properties Role, Tools, Type are required.
+type ResponseInputItemAdditionalToolsParam struct {
+ // A list of additional tools made available at this item.
+ Tools []ToolUnionParam `json:"tools,omitzero" api:"required"`
+ // The unique ID of this additional tools item.
+ ID param.Opt[string] `json:"id,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 ResponseInputItemAdditionalToolsParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseInputItemAdditionalToolsParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseInputItemAdditionalToolsParam) 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.
@@ -12730,6 +15795,8 @@ type ResponseInputItemShellCallParam struct {
// The unique ID of the shell tool call. Populated when this item is returned via
// API.
ID param.Opt[string] `json:"id,omitzero"`
+ // The execution context that produced this tool call.
+ Caller ResponseInputItemShellCallCallerUnionParam `json:"caller,omitzero"`
// The environment to execute the shell commands in.
Environment ResponseInputItemShellCallEnvironmentUnionParam `json:"environment,omitzero"`
// The status of the shell call. One of `in_progress`, `completed`, or
@@ -12780,6 +15847,98 @@ func (r *ResponseInputItemShellCallActionParam) 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 ResponseInputItemShellCallCallerUnionParam struct {
+ OfDirect *ResponseInputItemShellCallCallerDirectParam `json:",omitzero,inline"`
+ OfProgram *ResponseInputItemShellCallCallerProgramParam `json:",omitzero,inline"`
+ paramUnion
+}
+
+func (u ResponseInputItemShellCallCallerUnionParam) MarshalJSON() ([]byte, error) {
+ return param.MarshalUnion(u, u.OfDirect, u.OfProgram)
+}
+func (u *ResponseInputItemShellCallCallerUnionParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, u)
+}
+
+func (u *ResponseInputItemShellCallCallerUnionParam) 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 ResponseInputItemShellCallCallerUnionParam) 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 ResponseInputItemShellCallCallerUnionParam) 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[ResponseInputItemShellCallCallerUnionParam](
+ "type",
+ apijson.Discriminator[ResponseInputItemShellCallCallerDirectParam]("direct"),
+ apijson.Discriminator[ResponseInputItemShellCallCallerProgramParam]("program"),
+ )
+}
+
+func NewResponseInputItemShellCallCallerDirectParam() ResponseInputItemShellCallCallerDirectParam {
+ return ResponseInputItemShellCallCallerDirectParam{
+ Type: "direct",
+ }
+}
+
+// This struct has a constant value, construct it with
+// [NewResponseInputItemShellCallCallerDirectParam].
+type ResponseInputItemShellCallCallerDirectParam struct {
+ // The caller type. Always `direct`.
+ Type constant.Direct `json:"type" default:"direct"`
+ paramObj
+}
+
+func (r ResponseInputItemShellCallCallerDirectParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseInputItemShellCallCallerDirectParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseInputItemShellCallCallerDirectParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// The properties CallerID, Type are required.
+type ResponseInputItemShellCallCallerProgramParam 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 ResponseInputItemShellCallCallerProgramParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseInputItemShellCallCallerProgramParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseInputItemShellCallCallerProgramParam) 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.
@@ -12854,6 +16013,8 @@ type ResponseInputItemShellCallOutputParam struct {
// 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 execution context that produced this tool call.
+ Caller ResponseInputItemShellCallOutputCallerUnionParam `json:"caller,omitzero"`
// The status of the shell call output.
//
// Any of "in_progress", "completed", "incomplete".
@@ -12880,6 +16041,98 @@ func init() {
)
}
+// Only one field can be non-zero.
+//
+// Use [param.IsOmitted] to confirm if a field is set.
+type ResponseInputItemShellCallOutputCallerUnionParam struct {
+ OfDirect *ResponseInputItemShellCallOutputCallerDirectParam `json:",omitzero,inline"`
+ OfProgram *ResponseInputItemShellCallOutputCallerProgramParam `json:",omitzero,inline"`
+ paramUnion
+}
+
+func (u ResponseInputItemShellCallOutputCallerUnionParam) MarshalJSON() ([]byte, error) {
+ return param.MarshalUnion(u, u.OfDirect, u.OfProgram)
+}
+func (u *ResponseInputItemShellCallOutputCallerUnionParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, u)
+}
+
+func (u *ResponseInputItemShellCallOutputCallerUnionParam) 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 ResponseInputItemShellCallOutputCallerUnionParam) 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 ResponseInputItemShellCallOutputCallerUnionParam) 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[ResponseInputItemShellCallOutputCallerUnionParam](
+ "type",
+ apijson.Discriminator[ResponseInputItemShellCallOutputCallerDirectParam]("direct"),
+ apijson.Discriminator[ResponseInputItemShellCallOutputCallerProgramParam]("program"),
+ )
+}
+
+func NewResponseInputItemShellCallOutputCallerDirectParam() ResponseInputItemShellCallOutputCallerDirectParam {
+ return ResponseInputItemShellCallOutputCallerDirectParam{
+ Type: "direct",
+ }
+}
+
+// This struct has a constant value, construct it with
+// [NewResponseInputItemShellCallOutputCallerDirectParam].
+type ResponseInputItemShellCallOutputCallerDirectParam struct {
+ // The caller type. Always `direct`.
+ Type constant.Direct `json:"type" default:"direct"`
+ paramObj
+}
+
+func (r ResponseInputItemShellCallOutputCallerDirectParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseInputItemShellCallOutputCallerDirectParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseInputItemShellCallOutputCallerDirectParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// The properties CallerID, Type are required.
+type ResponseInputItemShellCallOutputCallerProgramParam 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 ResponseInputItemShellCallOutputCallerProgramParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseInputItemShellCallOutputCallerProgramParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseInputItemShellCallOutputCallerProgramParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// A tool call representing a request to create, delete, or update files using diff
// patches.
//
@@ -12897,6 +16150,8 @@ type ResponseInputItemApplyPatchCallParam struct {
// 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 execution context that produced this tool call.
+ Caller ResponseInputItemApplyPatchCallCallerUnionParam `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".
@@ -13056,6 +16311,98 @@ func (r *ResponseInputItemApplyPatchCallOperationUpdateFileParam) UnmarshalJSON(
return apijson.UnmarshalRoot(data, r)
}
+// Only one field can be non-zero.
+//
+// Use [param.IsOmitted] to confirm if a field is set.
+type ResponseInputItemApplyPatchCallCallerUnionParam struct {
+ OfDirect *ResponseInputItemApplyPatchCallCallerDirectParam `json:",omitzero,inline"`
+ OfProgram *ResponseInputItemApplyPatchCallCallerProgramParam `json:",omitzero,inline"`
+ paramUnion
+}
+
+func (u ResponseInputItemApplyPatchCallCallerUnionParam) MarshalJSON() ([]byte, error) {
+ return param.MarshalUnion(u, u.OfDirect, u.OfProgram)
+}
+func (u *ResponseInputItemApplyPatchCallCallerUnionParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, u)
+}
+
+func (u *ResponseInputItemApplyPatchCallCallerUnionParam) 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 ResponseInputItemApplyPatchCallCallerUnionParam) 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 ResponseInputItemApplyPatchCallCallerUnionParam) 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[ResponseInputItemApplyPatchCallCallerUnionParam](
+ "type",
+ apijson.Discriminator[ResponseInputItemApplyPatchCallCallerDirectParam]("direct"),
+ apijson.Discriminator[ResponseInputItemApplyPatchCallCallerProgramParam]("program"),
+ )
+}
+
+func NewResponseInputItemApplyPatchCallCallerDirectParam() ResponseInputItemApplyPatchCallCallerDirectParam {
+ return ResponseInputItemApplyPatchCallCallerDirectParam{
+ Type: "direct",
+ }
+}
+
+// This struct has a constant value, construct it with
+// [NewResponseInputItemApplyPatchCallCallerDirectParam].
+type ResponseInputItemApplyPatchCallCallerDirectParam struct {
+ // The caller type. Always `direct`.
+ Type constant.Direct `json:"type" default:"direct"`
+ paramObj
+}
+
+func (r ResponseInputItemApplyPatchCallCallerDirectParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseInputItemApplyPatchCallCallerDirectParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseInputItemApplyPatchCallCallerDirectParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// The properties CallerID, Type are required.
+type ResponseInputItemApplyPatchCallCallerProgramParam 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 ResponseInputItemApplyPatchCallCallerProgramParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseInputItemApplyPatchCallCallerProgramParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseInputItemApplyPatchCallCallerProgramParam) 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.
@@ -13072,6 +16419,8 @@ type ResponseInputItemApplyPatchCallOutputParam struct {
// Optional human-readable log text from the apply patch tool (e.g., patch results
// or errors).
Output param.Opt[string] `json:"output,omitzero"`
+ // The execution context that produced this tool call.
+ Caller ResponseInputItemApplyPatchCallOutputCallerUnionParam `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
@@ -13094,6 +16443,98 @@ func init() {
)
}
+// Only one field can be non-zero.
+//
+// Use [param.IsOmitted] to confirm if a field is set.
+type ResponseInputItemApplyPatchCallOutputCallerUnionParam struct {
+ OfDirect *ResponseInputItemApplyPatchCallOutputCallerDirectParam `json:",omitzero,inline"`
+ OfProgram *ResponseInputItemApplyPatchCallOutputCallerProgramParam `json:",omitzero,inline"`
+ paramUnion
+}
+
+func (u ResponseInputItemApplyPatchCallOutputCallerUnionParam) MarshalJSON() ([]byte, error) {
+ return param.MarshalUnion(u, u.OfDirect, u.OfProgram)
+}
+func (u *ResponseInputItemApplyPatchCallOutputCallerUnionParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, u)
+}
+
+func (u *ResponseInputItemApplyPatchCallOutputCallerUnionParam) 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 ResponseInputItemApplyPatchCallOutputCallerUnionParam) 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 ResponseInputItemApplyPatchCallOutputCallerUnionParam) 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[ResponseInputItemApplyPatchCallOutputCallerUnionParam](
+ "type",
+ apijson.Discriminator[ResponseInputItemApplyPatchCallOutputCallerDirectParam]("direct"),
+ apijson.Discriminator[ResponseInputItemApplyPatchCallOutputCallerProgramParam]("program"),
+ )
+}
+
+func NewResponseInputItemApplyPatchCallOutputCallerDirectParam() ResponseInputItemApplyPatchCallOutputCallerDirectParam {
+ return ResponseInputItemApplyPatchCallOutputCallerDirectParam{
+ Type: "direct",
+ }
+}
+
+// This struct has a constant value, construct it with
+// [NewResponseInputItemApplyPatchCallOutputCallerDirectParam].
+type ResponseInputItemApplyPatchCallOutputCallerDirectParam struct {
+ // The caller type. Always `direct`.
+ Type constant.Direct `json:"type" default:"direct"`
+ paramObj
+}
+
+func (r ResponseInputItemApplyPatchCallOutputCallerDirectParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseInputItemApplyPatchCallOutputCallerDirectParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseInputItemApplyPatchCallOutputCallerDirectParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// The properties CallerID, Type are required.
+type ResponseInputItemApplyPatchCallOutputCallerProgramParam 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 ResponseInputItemApplyPatchCallOutputCallerProgramParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseInputItemApplyPatchCallOutputCallerProgramParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseInputItemApplyPatchCallOutputCallerProgramParam) 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.
@@ -13246,30 +16687,112 @@ func init() {
)
}
+func NewResponseInputItemCompactionTriggerParam() ResponseInputItemCompactionTriggerParam {
+ return ResponseInputItemCompactionTriggerParam{
+ Type: "compaction_trigger",
+ }
+}
+
+// Compacts the current context. Must be the final input item.
+//
+// This struct has a constant value, construct it with
+// [NewResponseInputItemCompactionTriggerParam].
+type ResponseInputItemCompactionTriggerParam struct {
+ // The type of the item. Always `compaction_trigger`.
+ Type constant.CompactionTrigger `json:"type" default:"compaction_trigger"`
+ paramObj
+}
+
+func (r ResponseInputItemCompactionTriggerParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseInputItemCompactionTriggerParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseInputItemCompactionTriggerParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// An internal identifier for an item to reference.
//
// The property ID is required.
type ResponseInputItemItemReferenceParam struct {
// The ID of the item to reference.
ID string `json:"id" api:"required"`
- // The type of item to reference. Always `item_reference`.
+ // The type of item to reference. Always `item_reference`.
+ //
+ // Any of "item_reference".
+ Type string `json:"type,omitzero"`
+ paramObj
+}
+
+func (r ResponseInputItemItemReferenceParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseInputItemItemReferenceParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseInputItemItemReferenceParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func init() {
+ apijson.RegisterFieldValidator[ResponseInputItemItemReferenceParam](
+ "type", "item_reference",
+ )
+}
+
+// The properties ID, CallID, Code, Fingerprint, Type are required.
+type ResponseInputItemProgramParam 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`.
+ //
+ // This field can be elided, and will marshal its zero value as "program".
+ Type constant.Program `json:"type" default:"program"`
+ paramObj
+}
+
+func (r ResponseInputItemProgramParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseInputItemProgramParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseInputItemProgramParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// The properties ID, CallID, Result, Status, Type are required.
+type ResponseInputItemProgramOutputParam 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 "item_reference".
- Type string `json:"type,omitzero"`
+ // Any of "completed", "incomplete".
+ Status string `json:"status,omitzero" api:"required"`
+ // 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 ResponseInputItemItemReferenceParam) MarshalJSON() (data []byte, err error) {
- type shadow ResponseInputItemItemReferenceParam
+func (r ResponseInputItemProgramOutputParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseInputItemProgramOutputParam
return param.MarshalObject(r, (*shadow)(&r))
}
-func (r *ResponseInputItemItemReferenceParam) UnmarshalJSON(data []byte) error {
+func (r *ResponseInputItemProgramOutputParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
func init() {
- apijson.RegisterFieldValidator[ResponseInputItemItemReferenceParam](
- "type", "item_reference",
+ apijson.RegisterFieldValidator[ResponseInputItemProgramOutputParam](
+ "status", "completed", "incomplete",
)
}
@@ -13337,12 +16860,17 @@ type ResponseInputText struct {
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 ResponseInputTextPromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
// 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
+ Text respjson.Field
+ Type respjson.Field
+ PromptCacheBreakpoint respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
} `json:"-"`
}
@@ -13363,12 +16891,36 @@ func (r ResponseInputText) ToParam() ResponseInputTextParam {
return param.Override[ResponseInputTextParam](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 ResponseInputTextPromptCacheBreakpoint 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 ResponseInputTextPromptCacheBreakpoint) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputTextPromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// A text input to the model.
//
// The properties Text, Type are required.
type ResponseInputTextParam 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 ResponseInputTextPromptCacheBreakpointParam `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".
@@ -13384,18 +16936,49 @@ func (r *ResponseInputTextParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+func NewResponseInputTextPromptCacheBreakpointParam() ResponseInputTextPromptCacheBreakpointParam {
+ return ResponseInputTextPromptCacheBreakpointParam{
+ 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
+// [NewResponseInputTextPromptCacheBreakpointParam].
+type ResponseInputTextPromptCacheBreakpointParam struct {
+ // The breakpoint mode. Always `explicit`.
+ Mode constant.Explicit `json:"mode" default:"explicit"`
+ paramObj
+}
+
+func (r ResponseInputTextPromptCacheBreakpointParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseInputTextPromptCacheBreakpointParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseInputTextPromptCacheBreakpointParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// A text input to the model.
type ResponseInputTextContent 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 ResponseInputTextContentPromptCacheBreakpoint `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
- ExtraFields map[string]respjson.Field
- raw string
+ Text respjson.Field
+ Type respjson.Field
+ PromptCacheBreakpoint respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
} `json:"-"`
}
@@ -13415,12 +16998,36 @@ func (r ResponseInputTextContent) ToParam() ResponseInputTextContentParam {
return param.Override[ResponseInputTextContentParam](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 ResponseInputTextContentPromptCacheBreakpoint 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 ResponseInputTextContentPromptCacheBreakpoint) RawJSON() string { return r.JSON.raw }
+func (r *ResponseInputTextContentPromptCacheBreakpoint) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// A text input to the model.
//
// The properties Text, Type are required.
type ResponseInputTextContentParam 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 ResponseInputTextContentPromptCacheBreakpointParam `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".
@@ -13436,13 +17043,40 @@ func (r *ResponseInputTextContentParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+func NewResponseInputTextContentPromptCacheBreakpointParam() ResponseInputTextContentPromptCacheBreakpointParam {
+ return ResponseInputTextContentPromptCacheBreakpointParam{
+ 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
+// [NewResponseInputTextContentPromptCacheBreakpointParam].
+type ResponseInputTextContentPromptCacheBreakpointParam struct {
+ // The breakpoint mode. Always `explicit`.
+ Mode constant.Explicit `json:"mode" default:"explicit"`
+ paramObj
+}
+
+func (r ResponseInputTextContentPromptCacheBreakpointParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseInputTextContentPromptCacheBreakpointParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseInputTextContentPromptCacheBreakpointParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// ResponseItemUnion contains all possible properties and values from
// [ResponseInputMessageItem], [ResponseOutputMessage],
// [ResponseFileSearchToolCall], [ResponseComputerToolCall],
// [ResponseComputerToolCallOutputItem], [ResponseFunctionWebSearch],
// [ResponseFunctionToolCallItem], [ResponseFunctionToolCallOutputItem],
// [ResponseToolSearchCall], [ResponseToolSearchOutputItem],
-// [ResponseReasoningItem], [ResponseCompactionItem],
+// [ResponseItemAdditionalTools], [ResponseReasoningItem], [ResponseItemProgram],
+// [ResponseItemProgramOutput], [ResponseCompactionItem],
// [ResponseItemImageGenerationCall], [ResponseCodeInterpreterToolCall],
// [ResponseItemLocalShellCall], [ResponseItemLocalShellCallOutput],
// [ResponseFunctionShellToolCall], [ResponseFunctionShellToolCallOutput],
@@ -13462,12 +17096,13 @@ type ResponseItemUnion struct {
Role string `json:"role"`
// Any of "message", "message", "file_search_call", "computer_call",
// "computer_call_output", "web_search_call", "function_call",
- // "function_call_output", "tool_search_call", "tool_search_output", "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", "custom_tool_call_output".
+ // "function_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"`
Status string `json:"status"`
// This field is from variant [ResponseOutputMessage].
@@ -13496,17 +17131,26 @@ type ResponseItemUnion struct {
// This field is a union of [string], [any], [string], [string]
Arguments ResponseItemUnionArguments `json:"arguments"`
Name string `json:"name"`
- Namespace string `json:"namespace"`
- Execution string `json:"execution"`
- // This field is a union of [[]ToolUnion], [[]ResponseItemMcpListToolsTool]
+ // This field is a union of [ResponseFunctionToolCallCallerUnion],
+ // [ResponseFunctionToolCallOutputItemCallerUnion],
+ // [ResponseFunctionShellToolCallCallerUnion],
+ // [ResponseFunctionShellToolCallOutputCallerUnion],
+ // [ResponseApplyPatchToolCallCallerUnion],
+ // [ResponseApplyPatchToolCallOutputCallerUnion],
+ // [ResponseCustomToolCallCallerUnion], [ResponseCustomToolCallOutputCallerUnion]
+ Caller ResponseItemUnionCaller `json:"caller"`
+ Namespace string `json:"namespace"`
+ Execution string `json:"execution"`
+ // This field is a union of [[]ToolUnion], [[]ToolUnion],
+ // [[]ResponseItemMcpListToolsTool]
Tools ResponseItemUnionTools `json:"tools"`
// This field is from variant [ResponseReasoningItem].
Summary []ResponseReasoningItemSummary `json:"summary"`
EncryptedContent string `json:"encrypted_content"`
- // This field is from variant [ResponseItemImageGenerationCall].
- Result string `json:"result"`
- // This field is from variant [ResponseCodeInterpreterToolCall].
- Code string `json:"code"`
+ Code string `json:"code"`
+ // This field is from variant [ResponseItemProgram].
+ Fingerprint string `json:"fingerprint"`
+ Result string `json:"result"`
// This field is from variant [ResponseCodeInterpreterToolCall].
ContainerID string `json:"container_id"`
// This field is from variant [ResponseCodeInterpreterToolCall].
@@ -13544,13 +17188,15 @@ type ResponseItemUnion struct {
CreatedBy respjson.Field
Arguments respjson.Field
Name respjson.Field
+ Caller respjson.Field
Namespace respjson.Field
Execution respjson.Field
Tools respjson.Field
Summary respjson.Field
EncryptedContent respjson.Field
- Result respjson.Field
Code respjson.Field
+ Fingerprint respjson.Field
+ Result respjson.Field
ContainerID respjson.Field
Outputs respjson.Field
Environment respjson.Field
@@ -13582,7 +17228,10 @@ func (ResponseFunctionToolCallItem) implResponseItemUnion() {}
func (ResponseFunctionToolCallOutputItem) implResponseItemUnion() {}
func (ResponseToolSearchCall) implResponseItemUnion() {}
func (ResponseToolSearchOutputItem) implResponseItemUnion() {}
+func (ResponseItemAdditionalTools) implResponseItemUnion() {}
func (ResponseReasoningItem) implResponseItemUnion() {}
+func (ResponseItemProgram) implResponseItemUnion() {}
+func (ResponseItemProgramOutput) implResponseItemUnion() {}
func (ResponseCompactionItem) implResponseItemUnion() {}
func (ResponseItemImageGenerationCall) implResponseItemUnion() {}
func (ResponseCodeInterpreterToolCall) implResponseItemUnion() {}
@@ -13612,7 +17261,10 @@ func (ResponseCustomToolCallOutputItem) implResponseItemUnion() {}
// case responses.ResponseFunctionToolCallOutputItem:
// case responses.ResponseToolSearchCall:
// case responses.ResponseToolSearchOutputItem:
+// case responses.ResponseItemAdditionalTools:
// case responses.ResponseReasoningItem:
+// case responses.ResponseItemProgram:
+// case responses.ResponseItemProgramOutput:
// case responses.ResponseCompactionItem:
// case responses.ResponseItemImageGenerationCall:
// case responses.ResponseCodeInterpreterToolCall:
@@ -13651,8 +17303,14 @@ func (u ResponseItemUnion) AsAny() anyResponseItem {
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":
@@ -13737,11 +17395,26 @@ func (u ResponseItemUnion) AsToolSearchOutput() (v ResponseToolSearchOutputItem)
return
}
+func (u ResponseItemUnion) AsAdditionalTools() (v ResponseItemAdditionalTools) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
func (u ResponseItemUnion) AsReasoning() (v ResponseReasoningItem) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
+func (u ResponseItemUnion) AsProgram() (v ResponseItemProgram) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseItemUnion) AsProgramOutput() (v ResponseItemProgramOutput) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
func (u ResponseItemUnion) AsCompaction() (v ResponseCompactionItem) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
@@ -13878,10 +17551,10 @@ type ResponseItemUnionAction struct {
// This field is from variant [ResponseComputerToolCallActionUnion].
Text string `json:"text"`
// This field is from variant [ResponseFunctionWebSearchActionUnion].
- Query string `json:"query"`
- // This field is from variant [ResponseFunctionWebSearchActionUnion].
Queries []string `json:"queries"`
// This field is from variant [ResponseFunctionWebSearchActionUnion].
+ Query string `json:"query"`
+ // This field is from variant [ResponseFunctionWebSearchActionUnion].
Sources []ResponseFunctionWebSearchActionSearchSource `json:"sources"`
URL string `json:"url"`
// This field is from variant [ResponseFunctionWebSearchActionUnion].
@@ -13909,8 +17582,8 @@ type ResponseItemUnionAction struct {
ScrollX respjson.Field
ScrollY respjson.Field
Text respjson.Field
- Query respjson.Field
Queries respjson.Field
+ Query respjson.Field
Sources respjson.Field
URL respjson.Field
Pattern respjson.Field
@@ -13995,6 +17668,26 @@ func (r *ResponseItemUnionArguments) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+// ResponseItemUnionCaller is an implicit subunion of [ResponseItemUnion].
+// ResponseItemUnionCaller provides convenient access to the sub-properties of the
+// union.
+//
+// For type safety it is recommended to directly use a variant of the
+// [ResponseItemUnion].
+type ResponseItemUnionCaller struct {
+ Type string `json:"type"`
+ CallerID string `json:"caller_id"`
+ JSON struct {
+ Type respjson.Field
+ CallerID respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+func (r *ResponseItemUnionCaller) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// ResponseItemUnionTools is an implicit subunion of [ResponseItemUnion].
// ResponseItemUnionTools provides convenient access to the sub-properties of the
// union.
@@ -14021,6 +17714,95 @@ func (r *ResponseItemUnionTools) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+type ResponseItemAdditionalTools 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 []ToolUnion `json:"tools" api:"required"`
+ // The type of the item. Always `additional_tools`.
+ Type constant.AdditionalTools `json:"type" default:"additional_tools"`
+ // 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
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseItemAdditionalTools) RawJSON() string { return r.JSON.raw }
+func (r *ResponseItemAdditionalTools) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseItemProgram 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"`
+ // 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
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseItemProgram) RawJSON() string { return r.JSON.raw }
+func (r *ResponseItemProgram) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseItemProgramOutput 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"`
+ // 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
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseItemProgramOutput) RawJSON() string { return r.JSON.raw }
+func (r *ResponseItemProgramOutput) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// An image generation request made by the model.
type ResponseItemImageGenerationCall struct {
// The unique ID of the image generation call.
@@ -14556,15 +18338,16 @@ func (r *ResponseMcpListToolsInProgressEvent) UnmarshalJSON(data []byte) error {
// [ResponseFunctionToolCall], [ResponseFunctionToolCallOutputItem],
// [ResponseFunctionWebSearch], [ResponseComputerToolCall],
// [ResponseComputerToolCallOutputItem], [ResponseReasoningItem],
+// [ResponseOutputItemProgram], [ResponseOutputItemProgramOutput],
// [ResponseToolSearchCall], [ResponseToolSearchOutputItem],
-// [ResponseCompactionItem], [ResponseOutputItemImageGenerationCall],
-// [ResponseCodeInterpreterToolCall], [ResponseOutputItemLocalShellCall],
-// [ResponseOutputItemLocalShellCallOutput], [ResponseFunctionShellToolCall],
-// [ResponseFunctionShellToolCallOutput], [ResponseApplyPatchToolCall],
-// [ResponseApplyPatchToolCallOutput], [ResponseOutputItemMcpCall],
-// [ResponseOutputItemMcpListTools], [ResponseOutputItemMcpApprovalRequest],
-// [ResponseOutputItemMcpApprovalResponse], [ResponseCustomToolCall],
-// [ResponseCustomToolCallOutputItem].
+// [ResponseOutputItemAdditionalTools], [ResponseCompactionItem],
+// [ResponseOutputItemImageGenerationCall], [ResponseCodeInterpreterToolCall],
+// [ResponseOutputItemLocalShellCall], [ResponseOutputItemLocalShellCallOutput],
+// [ResponseFunctionShellToolCall], [ResponseFunctionShellToolCallOutput],
+// [ResponseApplyPatchToolCall], [ResponseApplyPatchToolCallOutput],
+// [ResponseOutputItemMcpCall], [ResponseOutputItemMcpListTools],
+// [ResponseOutputItemMcpApprovalRequest], [ResponseOutputItemMcpApprovalResponse],
+// [ResponseCustomToolCall], [ResponseCustomToolCallOutputItem].
//
// Use the [ResponseOutputItemUnion.AsAny] method to switch on the variant.
//
@@ -14572,12 +18355,12 @@ func (r *ResponseMcpListToolsInProgressEvent) UnmarshalJSON(data []byte) error {
type ResponseOutputItemUnion struct {
ID string `json:"id"`
Content []ResponseOutputMessageContentUnion `json:"content"`
- // This field is from variant [ResponseOutputMessage].
- Role constant.Assistant `json:"role"`
- Status string `json:"status"`
+ Role string `json:"role"`
+ Status string `json:"status"`
// Any of "message", "file_search_call", "function_call", "function_call_output",
// "web_search_call", "computer_call", "computer_call_output", "reasoning",
- // "tool_search_call", "tool_search_output", "compaction", "image_generation_call",
+ // "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",
@@ -14593,7 +18376,15 @@ type ResponseOutputItemUnion struct {
Arguments ResponseOutputItemUnionArguments `json:"arguments"`
CallID string `json:"call_id"`
Name string `json:"name"`
- Namespace string `json:"namespace"`
+ // This field is a union of [ResponseFunctionToolCallCallerUnion],
+ // [ResponseFunctionToolCallOutputItemCallerUnion],
+ // [ResponseFunctionShellToolCallCallerUnion],
+ // [ResponseFunctionShellToolCallOutputCallerUnion],
+ // [ResponseApplyPatchToolCallCallerUnion],
+ // [ResponseApplyPatchToolCallOutputCallerUnion],
+ // [ResponseCustomToolCallCallerUnion], [ResponseCustomToolCallOutputCallerUnion]
+ Caller ResponseOutputItemUnionCaller `json:"caller"`
+ Namespace string `json:"namespace"`
// This field is a union of [ResponseFunctionToolCallOutputItemOutputUnion],
// [ResponseComputerToolCallOutputScreenshot], [string],
// [[]ResponseFunctionShellToolCallOutputOutput], [string], [string],
@@ -14613,13 +18404,14 @@ type ResponseOutputItemUnion struct {
// This field is from variant [ResponseReasoningItem].
Summary []ResponseReasoningItemSummary `json:"summary"`
EncryptedContent string `json:"encrypted_content"`
- Execution string `json:"execution"`
- // This field is a union of [[]ToolUnion], [[]ResponseOutputItemMcpListToolsTool]
+ Code string `json:"code"`
+ // This field is from variant [ResponseOutputItemProgram].
+ Fingerprint string `json:"fingerprint"`
+ Result string `json:"result"`
+ Execution string `json:"execution"`
+ // This field is a union of [[]ToolUnion], [[]ToolUnion],
+ // [[]ResponseOutputItemMcpListToolsTool]
Tools ResponseOutputItemUnionTools `json:"tools"`
- // This field is from variant [ResponseOutputItemImageGenerationCall].
- 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"`
// This field is from variant [ResponseCodeInterpreterToolCall].
@@ -14651,6 +18443,7 @@ type ResponseOutputItemUnion struct {
Arguments respjson.Field
CallID respjson.Field
Name respjson.Field
+ Caller respjson.Field
Namespace respjson.Field
Output respjson.Field
CreatedBy respjson.Field
@@ -14660,10 +18453,11 @@ type ResponseOutputItemUnion struct {
AcknowledgedSafetyChecks respjson.Field
Summary respjson.Field
EncryptedContent respjson.Field
+ Code respjson.Field
+ Fingerprint respjson.Field
+ Result respjson.Field
Execution respjson.Field
Tools respjson.Field
- Result respjson.Field
- Code respjson.Field
ContainerID respjson.Field
Outputs respjson.Field
Environment respjson.Field
@@ -14694,8 +18488,11 @@ func (ResponseFunctionWebSearch) implResponseOutputItemUnion() {}
func (ResponseComputerToolCall) implResponseOutputItemUnion() {}
func (ResponseComputerToolCallOutputItem) implResponseOutputItemUnion() {}
func (ResponseReasoningItem) implResponseOutputItemUnion() {}
+func (ResponseOutputItemProgram) implResponseOutputItemUnion() {}
+func (ResponseOutputItemProgramOutput) implResponseOutputItemUnion() {}
func (ResponseToolSearchCall) implResponseOutputItemUnion() {}
func (ResponseToolSearchOutputItem) implResponseOutputItemUnion() {}
+func (ResponseOutputItemAdditionalTools) implResponseOutputItemUnion() {}
func (ResponseCompactionItem) implResponseOutputItemUnion() {}
func (ResponseOutputItemImageGenerationCall) implResponseOutputItemUnion() {}
func (ResponseCodeInterpreterToolCall) implResponseOutputItemUnion() {}
@@ -14723,8 +18520,11 @@ func (ResponseCustomToolCallOutputItem) implResponseOutputItemUnion() {}
// case responses.ResponseComputerToolCall:
// case responses.ResponseComputerToolCallOutputItem:
// case responses.ResponseReasoningItem:
+// case responses.ResponseOutputItemProgram:
+// case responses.ResponseOutputItemProgramOutput:
// case responses.ResponseToolSearchCall:
// case responses.ResponseToolSearchOutputItem:
+// case responses.ResponseOutputItemAdditionalTools:
// case responses.ResponseCompactionItem:
// case responses.ResponseOutputItemImageGenerationCall:
// case responses.ResponseCodeInterpreterToolCall:
@@ -14761,10 +18561,16 @@ func (u ResponseOutputItemUnion) AsAny() anyResponseOutputItem {
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":
@@ -14839,6 +18645,16 @@ func (u ResponseOutputItemUnion) AsReasoning() (v ResponseReasoningItem) {
return
}
+func (u ResponseOutputItemUnion) AsProgram() (v ResponseOutputItemProgram) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseOutputItemUnion) AsProgramOutput() (v ResponseOutputItemProgramOutput) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
func (u ResponseOutputItemUnion) AsToolSearchCall() (v ResponseToolSearchCall) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
@@ -14849,6 +18665,11 @@ func (u ResponseOutputItemUnion) AsToolSearchOutput() (v ResponseToolSearchOutpu
return
}
+func (u ResponseOutputItemUnion) AsAdditionalTools() (v ResponseOutputItemAdditionalTools) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
func (u ResponseOutputItemUnion) AsCompaction() (v ResponseCompactionItem) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
@@ -14956,6 +18777,26 @@ func (r *ResponseOutputItemUnionArguments) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+// ResponseOutputItemUnionCaller is an implicit subunion of
+// [ResponseOutputItemUnion]. ResponseOutputItemUnionCaller provides convenient
+// access to the sub-properties of the union.
+//
+// For type safety it is recommended to directly use a variant of the
+// [ResponseOutputItemUnion].
+type ResponseOutputItemUnionCaller struct {
+ Type string `json:"type"`
+ CallerID string `json:"caller_id"`
+ JSON struct {
+ Type respjson.Field
+ CallerID respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+func (r *ResponseOutputItemUnionCaller) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// ResponseOutputItemUnionOutput is an implicit subunion of
// [ResponseOutputItemUnion]. ResponseOutputItemUnionOutput provides convenient
// access to the sub-properties of the union.
@@ -15004,12 +18845,12 @@ func (r *ResponseOutputItemUnionOutput) UnmarshalJSON(data []byte) error {
// For type safety it is recommended to directly use a variant of the
// [ResponseOutputItemUnion].
type ResponseOutputItemUnionAction struct {
- // This field is from variant [ResponseFunctionWebSearchActionUnion].
- Query string `json:"query"`
- Type string `json:"type"`
+ Type string `json:"type"`
// This field is from variant [ResponseFunctionWebSearchActionUnion].
Queries []string `json:"queries"`
// This field is from variant [ResponseFunctionWebSearchActionUnion].
+ Query string `json:"query"`
+ // This field is from variant [ResponseFunctionWebSearchActionUnion].
Sources []ResponseFunctionWebSearchActionSearchSource `json:"sources"`
URL string `json:"url"`
// This field is from variant [ResponseFunctionWebSearchActionUnion].
@@ -15041,9 +18882,9 @@ type ResponseOutputItemUnionAction struct {
// This field is from variant [ResponseFunctionShellToolCallAction].
MaxOutputLength int64 `json:"max_output_length"`
JSON struct {
- Query respjson.Field
Type respjson.Field
Queries respjson.Field
+ Query respjson.Field
Sources respjson.Field
URL respjson.Field
Pattern respjson.Field
@@ -15092,7 +18933,96 @@ type ResponseOutputItemUnionTools struct {
} `json:"-"`
}
-func (r *ResponseOutputItemUnionTools) UnmarshalJSON(data []byte) error {
+func (r *ResponseOutputItemUnionTools) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseOutputItemProgram 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"`
+ // 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
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseOutputItemProgram) RawJSON() string { return r.JSON.raw }
+func (r *ResponseOutputItemProgram) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseOutputItemProgramOutput 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"`
+ // 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
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseOutputItemProgramOutput) RawJSON() string { return r.JSON.raw }
+func (r *ResponseOutputItemProgramOutput) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type ResponseOutputItemAdditionalTools 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 []ToolUnion `json:"tools" api:"required"`
+ // The type of the item. Always `additional_tools`.
+ Type constant.AdditionalTools `json:"type" default:"additional_tools"`
+ // 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
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseOutputItemAdditionalTools) RawJSON() string { return r.JSON.raw }
+func (r *ResponseOutputItemAdditionalTools) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
@@ -15924,7 +19854,7 @@ type ResponseOutputTextAnnotationURLCitation struct {
// 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"`
+ URL string `json:"url" api:"required" format:"uri"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
EndIndex respjson.Field
@@ -16235,7 +20165,7 @@ type ResponseOutputTextAnnotationURLCitationParam struct {
// The title of the web resource.
Title string `json:"title" api:"required"`
// The URL of the web resource.
- URL string `json:"url" api:"required"`
+ 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".
@@ -16425,10 +20355,14 @@ 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"`
- Detail string `json:"detail"`
- FileID string `json:"file_id"`
+ Text string `json:"text"`
+ Type string `json:"type"`
+ // This field is a union of [ResponseInputTextPromptCacheBreakpoint],
+ // [ResponseInputImagePromptCacheBreakpoint],
+ // [ResponseInputFilePromptCacheBreakpoint]
+ PromptCacheBreakpoint ResponsePromptVariableUnionPromptCacheBreakpoint `json:"prompt_cache_breakpoint"`
+ Detail string `json:"detail"`
+ FileID string `json:"file_id"`
// This field is from variant [ResponseInputImage].
ImageURL string `json:"image_url"`
// This field is from variant [ResponseInputFile].
@@ -16438,16 +20372,17 @@ type ResponsePromptVariableUnion struct {
// 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
- FileURL respjson.Field
- Filename respjson.Field
- raw string
+ 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:"-"`
}
@@ -16478,6 +20413,25 @@ func (r *ResponsePromptVariableUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+// ResponsePromptVariableUnionPromptCacheBreakpoint is an implicit subunion of
+// [ResponsePromptVariableUnion]. ResponsePromptVariableUnionPromptCacheBreakpoint
+// provides convenient access to the sub-properties of the union.
+//
+// For type safety it is recommended to directly use a variant of the
+// [ResponsePromptVariableUnion].
+type ResponsePromptVariableUnionPromptCacheBreakpoint struct {
+ // This field is from variant [ResponseInputTextPromptCacheBreakpoint].
+ Mode constant.Explicit `json:"mode"`
+ JSON struct {
+ Mode respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+func (r *ResponsePromptVariableUnionPromptCacheBreakpoint) 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).
//
@@ -16605,6 +20559,49 @@ func (u ResponsePromptVariableUnionParam) GetFileID() *string {
return nil
}
+// Returns a subunion which exports methods to access subproperties
+//
+// Or use AsAny() to get the underlying value
+func (u ResponsePromptVariableUnionParam) GetPromptCacheBreakpoint() (res responsePromptVariableUnionParamPromptCacheBreakpoint) {
+ 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 [*ResponseInputTextPromptCacheBreakpointParam],
+// [*ResponseInputImagePromptCacheBreakpointParam],
+// [*ResponseInputFilePromptCacheBreakpointParam]
+type responsePromptVariableUnionParamPromptCacheBreakpoint struct{ any }
+
+// Use the following switch statement to get the type of the union:
+//
+// switch u.AsAny().(type) {
+// case *responses.ResponseInputTextPromptCacheBreakpointParam:
+// case *responses.ResponseInputImagePromptCacheBreakpointParam:
+// case *responses.ResponseInputFilePromptCacheBreakpointParam:
+// default:
+// fmt.Errorf("not present")
+// }
+func (u responsePromptVariableUnionParamPromptCacheBreakpoint) AsAny() any { return u.any }
+
+// Returns a pointer to the underlying variant's property, if present.
+func (u responsePromptVariableUnionParamPromptCacheBreakpoint) GetMode() *string {
+ switch vt := u.any.(type) {
+ case *ResponseInputTextPromptCacheBreakpointParam:
+ return (*string)(&vt.Mode)
+ case *ResponseInputImagePromptCacheBreakpointParam:
+ return (*string)(&vt.Mode)
+ case *ResponseInputFilePromptCacheBreakpointParam:
+ return (*string)(&vt.Mode)
+ }
+ return nil
+}
+
// Emitted when a response is queued and waiting to be processed.
type ResponseQueuedEvent struct {
// The full response object that is queued.
@@ -16642,8 +20639,9 @@ type ResponseReasoningItem struct {
Type constant.Reasoning `json:"type" default:"reasoning"`
// Reasoning text content.
Content []ResponseReasoningItemContent `json:"content"`
- // The encrypted content of the reasoning item - populated when a response is
- // generated with `reasoning.encrypted_content` in the `include` parameter.
+ // 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.
@@ -16743,8 +20741,9 @@ type ResponseReasoningItemParam struct {
ID string `json:"id" api:"required"`
// Reasoning summary content.
Summary []ResponseReasoningItemSummaryParam `json:"summary,omitzero" api:"required"`
- // The encrypted content of the reasoning item - populated when a response is
- // generated with `reasoning.encrypted_content` in the `include` parameter.
+ // 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"`
// Reasoning text content.
Content []ResponseReasoningItemContentParam `json:"content,omitzero"`
@@ -16878,6 +20877,11 @@ type ResponseReasoningSummaryPartDoneEvent struct {
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 completion status of the summary part. Omitted when the part completed
+ // normally and set to `incomplete` when generation was interrupted.
+ //
+ // Any of "incomplete".
+ Status ResponseReasoningSummaryPartDoneEventStatus `json:"status"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ItemID respjson.Field
@@ -16886,6 +20890,7 @@ type ResponseReasoningSummaryPartDoneEvent struct {
SequenceNumber respjson.Field
SummaryIndex respjson.Field
Type respjson.Field
+ Status respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
@@ -16918,6 +20923,14 @@ func (r *ResponseReasoningSummaryPartDoneEventPart) UnmarshalJSON(data []byte) e
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 ResponseReasoningSummaryPartDoneEventStatus string
+
+const (
+ ResponseReasoningSummaryPartDoneEventStatusIncomplete ResponseReasoningSummaryPartDoneEventStatus = "incomplete"
+)
+
// Emitted when a delta is added to a reasoning summary text.
type ResponseReasoningSummaryTextDeltaEvent struct {
// The text delta that was added to the summary.
@@ -17220,7 +21233,9 @@ type ResponseStreamEventUnion struct {
// This field is from variant [ResponseOutputItemAddedEvent].
Item ResponseOutputItemUnion `json:"item"`
SummaryIndex int64 `json:"summary_index"`
- Text string `json:"text"`
+ // This field is from variant [ResponseReasoningSummaryPartDoneEvent].
+ Status ResponseReasoningSummaryPartDoneEventStatus `json:"status"`
+ Text string `json:"text"`
// This field is from variant [ResponseRefusalDoneEvent].
Refusal string `json:"refusal"`
// This field is a union of [[]ResponseTextDeltaEventLogprob],
@@ -17252,6 +21267,7 @@ type ResponseStreamEventUnion struct {
Name respjson.Field
Item respjson.Field
SummaryIndex respjson.Field
+ Status respjson.Field
Text respjson.Field
Refusal respjson.Field
Logprobs respjson.Field
@@ -17849,7 +21865,8 @@ type ResponseTextConfig struct {
Format ResponseFormatTextConfigUnion `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`.
+ // responses. Currently supported values are `low`, `medium`, and `high`. The
+ // default is `medium`.
//
// Any of "low", "medium", "high".
Verbosity ResponseTextConfigVerbosity `json:"verbosity" api:"nullable"`
@@ -17879,7 +21896,8 @@ func (r ResponseTextConfig) ToParam() ResponseTextConfigParam {
// 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`.
+// responses. Currently supported values are `low`, `medium`, and `high`. The
+// default is `medium`.
type ResponseTextConfigVerbosity string
const (
@@ -17896,7 +21914,8 @@ const (
type ResponseTextConfigParam 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`.
+ // responses. Currently supported values are `low`, `medium`, and `high`. The
+ // default is `medium`.
//
// Any of "low", "medium", "high".
Verbosity ResponseTextConfigVerbosity `json:"verbosity,omitzero"`
@@ -17969,7 +21988,7 @@ type ResponseTextDeltaEventLogprob struct {
Token string `json:"token" api:"required"`
// The log probability of this token.
Logprob float64 `json:"logprob" api:"required"`
- // The log probability of the top 20 most likely tokens.
+ // The log probabilities of up to 20 of the most likely tokens.
TopLogprobs []ResponseTextDeltaEventLogprobTopLogprob `json:"top_logprobs"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
@@ -18051,7 +22070,7 @@ type ResponseTextDoneEventLogprob struct {
Token string `json:"token" api:"required"`
// The log probability of this token.
Logprob float64 `json:"logprob" api:"required"`
- // The log probability of the top 20 most likely tokens.
+ // The log probabilities of up to 20 of the most likely tokens.
TopLogprobs []ResponseTextDoneEventLogprobTopLogprob `json:"top_logprobs"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
@@ -18333,14 +22352,17 @@ func (r *ResponseUsage) UnmarshalJSON(data []byte) error {
// A detailed breakdown of the input tokens.
type ResponseUsageInputTokensDetails 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 {
- CachedTokens respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
+ CacheWriteTokens respjson.Field
+ CachedTokens respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
} `json:"-"`
}
@@ -18504,9 +22526,9 @@ func (r *SkillReferenceParam) UnmarshalJSON(data []byte) error {
// ToolUnion contains all possible properties and values from [FunctionTool],
// [FileSearchTool], [ComputerTool], [ComputerUsePreviewTool], [WebSearchTool],
-// [ToolMcp], [ToolCodeInterpreter], [ToolImageGeneration], [ToolLocalShell],
-// [FunctionShellTool], [CustomTool], [NamespaceTool], [ToolSearchTool],
-// [WebSearchPreviewTool], [ApplyPatchTool].
+// [ToolMcp], [ToolCodeInterpreter], [ToolProgrammaticToolCalling],
+// [ToolImageGeneration], [ToolLocalShell], [FunctionShellTool], [CustomTool],
+// [NamespaceTool], [ToolSearchTool], [WebSearchPreviewTool], [ApplyPatchTool].
//
// Use the [ToolUnion.AsAny] method to switch on the variant.
//
@@ -18517,11 +22539,15 @@ type ToolUnion struct {
// This field is from variant [FunctionTool].
Strict bool `json:"strict"`
// Any of "function", "file_search", "computer", "computer_use_preview", nil,
- // "mcp", "code_interpreter", "image_generation", "local_shell", "shell", "custom",
- // "namespace", "tool_search", nil, "apply_patch".
- Type string `json:"type"`
- DeferLoading bool `json:"defer_loading"`
- Description string `json:"description"`
+ // "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 [FunctionTool].
+ OutputSchema map[string]any `json:"output_schema"`
// This field is from variant [FileSearchTool].
VectorStoreIDs []string `json:"vector_store_ids"`
// This field is a union of [FileSearchToolFiltersUnion], [WebSearchToolFilters]
@@ -18557,6 +22583,8 @@ type ToolUnion struct {
ServerDescription string `json:"server_description"`
// This field is from variant [ToolMcp].
ServerURL string `json:"server_url"`
+ // This field is from variant [ToolMcp].
+ TunnelID string `json:"tunnel_id"`
// This field is from variant [ToolCodeInterpreter].
Container ToolCodeInterpreterContainerUnion `json:"container"`
// This field is from variant [ToolImageGeneration].
@@ -18594,8 +22622,10 @@ type ToolUnion struct {
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
@@ -18613,6 +22643,7 @@ type ToolUnion struct {
RequireApproval respjson.Field
ServerDescription respjson.Field
ServerURL respjson.Field
+ TunnelID respjson.Field
Container respjson.Field
Action respjson.Field
Background respjson.Field
@@ -18668,6 +22699,11 @@ func (u ToolUnion) AsCodeInterpreter() (v ToolCodeInterpreter) {
return
}
+func (u ToolUnion) AsProgrammaticToolCalling() (v ToolProgrammaticToolCalling) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
func (u ToolUnion) AsImageGeneration() (v ToolImageGeneration) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
@@ -18850,6 +22886,10 @@ type ToolMcp struct {
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 ToolMcpAllowedToolsUnion `json:"allowed_tools" api:"nullable"`
// An OAuth access token that can be used with a remote MCP server, either with a
@@ -18857,8 +22897,8 @@ type ToolMcp struct {
// 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` or `connector_id` must be provided. Learn more about service
- // connectors
+ // `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:
@@ -18885,13 +22925,17 @@ type ToolMcp struct {
RequireApproval ToolMcpRequireApprovalUnion `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` or `connector_id` must be
- // provided.
- ServerURL string `json:"server_url"`
+ // 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
@@ -18900,6 +22944,7 @@ type ToolMcp struct {
RequireApproval respjson.Field
ServerDescription respjson.Field
ServerURL respjson.Field
+ TunnelID respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
@@ -19101,12 +23146,17 @@ type ToolCodeInterpreter struct {
Container ToolCodeInterpreterContainerUnion `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
- ExtraFields map[string]respjson.Field
- raw string
+ Container respjson.Field
+ Type respjson.Field
+ AllowedCallers respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
} `json:"-"`
}
@@ -19270,6 +23320,23 @@ func (r *ToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnion)
return apijson.UnmarshalRoot(data, r)
}
+type ToolProgrammaticToolCalling 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 ToolProgrammaticToolCalling) RawJSON() string { return r.JSON.raw }
+func (r *ToolProgrammaticToolCalling) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// A tool that generates images using the GPT image models.
type ToolImageGeneration struct {
// The type of the image generation tool. Always `image_generation`.
@@ -19278,8 +23345,18 @@ type ToolImageGeneration struct {
//
// Any of "generate", "edit", "auto".
Action string `json:"action"`
- // Background type for the generated image. One of `transparent`, `opaque`, or
- // `auto`. Default: `auto`.
+ // 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"`
@@ -19314,10 +23391,17 @@ type ToolImageGeneration struct {
//
// Any of "low", "medium", "high", "auto".
Quality string `json:"quality"`
- // The size of the generated image. One of `1024x1024`, `1024x1536`, `1536x1024`,
- // or `auto`. Default: `auto`.
- //
- // Any of "1024x1024", "1024x1536", "1536x1024", "auto".
+ // 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 {
@@ -19455,21 +23539,22 @@ func ToolParamOfWebSearchPreview(type_ WebSearchPreviewToolType) ToolUnionParam
//
// Use [param.IsOmitted] to confirm if a field is set.
type ToolUnionParam struct {
- OfFunction *FunctionToolParam `json:",omitzero,inline"`
- OfFileSearch *FileSearchToolParam `json:",omitzero,inline"`
- OfComputer *ComputerToolParam `json:",omitzero,inline"`
- OfComputerUsePreview *ComputerUsePreviewToolParam `json:",omitzero,inline"`
- OfWebSearch *WebSearchToolParam `json:",omitzero,inline"`
- OfMcp *ToolMcpParam `json:",omitzero,inline"`
- OfCodeInterpreter *ToolCodeInterpreterParam `json:",omitzero,inline"`
- OfImageGeneration *ToolImageGenerationParam `json:",omitzero,inline"`
- OfLocalShell *ToolLocalShellParam `json:",omitzero,inline"`
- OfShell *FunctionShellToolParam `json:",omitzero,inline"`
- OfCustom *CustomToolParam `json:",omitzero,inline"`
- OfNamespace *NamespaceToolParam `json:",omitzero,inline"`
- OfToolSearch *ToolSearchToolParam `json:",omitzero,inline"`
- OfWebSearchPreview *WebSearchPreviewToolParam `json:",omitzero,inline"`
- OfApplyPatch *ApplyPatchToolParam `json:",omitzero,inline"`
+ OfFunction *FunctionToolParam `json:",omitzero,inline"`
+ OfFileSearch *FileSearchToolParam `json:",omitzero,inline"`
+ OfComputer *ComputerToolParam `json:",omitzero,inline"`
+ OfComputerUsePreview *ComputerUsePreviewToolParam `json:",omitzero,inline"`
+ OfWebSearch *WebSearchToolParam `json:",omitzero,inline"`
+ OfMcp *ToolMcpParam `json:",omitzero,inline"`
+ OfCodeInterpreter *ToolCodeInterpreterParam `json:",omitzero,inline"`
+ OfProgrammaticToolCalling *ToolProgrammaticToolCallingParam `json:",omitzero,inline"`
+ OfImageGeneration *ToolImageGenerationParam `json:",omitzero,inline"`
+ OfLocalShell *ToolLocalShellParam `json:",omitzero,inline"`
+ OfShell *FunctionShellToolParam `json:",omitzero,inline"`
+ OfCustom *CustomToolParam `json:",omitzero,inline"`
+ OfNamespace *NamespaceToolParam `json:",omitzero,inline"`
+ OfToolSearch *ToolSearchToolParam `json:",omitzero,inline"`
+ OfWebSearchPreview *WebSearchPreviewToolParam `json:",omitzero,inline"`
+ OfApplyPatch *ApplyPatchToolParam `json:",omitzero,inline"`
paramUnion
}
@@ -19481,6 +23566,7 @@ func (u ToolUnionParam) MarshalJSON() ([]byte, error) {
u.OfWebSearch,
u.OfMcp,
u.OfCodeInterpreter,
+ u.OfProgrammaticToolCalling,
u.OfImageGeneration,
u.OfLocalShell,
u.OfShell,
@@ -19509,6 +23595,8 @@ func (u *ToolUnionParam) asAny() any {
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) {
@@ -19537,6 +23625,14 @@ func (u ToolUnionParam) GetStrict() *bool {
return nil
}
+// Returns a pointer to the underlying variant's property, if present.
+func (u ToolUnionParam) 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 ToolUnionParam) GetVectorStoreIDs() []string {
if vt := u.OfFileSearch; vt != nil {
@@ -19641,6 +23737,14 @@ func (u ToolUnionParam) GetServerURL() *string {
return nil
}
+// Returns a pointer to the underlying variant's property, if present.
+func (u ToolUnionParam) 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 ToolUnionParam) GetContainer() *ToolCodeInterpreterContainerUnionParam {
if vt := u.OfCodeInterpreter; vt != nil {
@@ -19797,6 +23901,8 @@ func (u ToolUnionParam) GetType() *string {
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 {
@@ -19878,6 +23984,25 @@ type toolUnionParamParameters struct{ any }
// }
func (u toolUnionParamParameters) AsAny() any { return u.any }
+// Returns a pointer to the underlying variant's AllowedCallers property, if
+// present.
+func (u ToolUnionParam) 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
@@ -20140,6 +24265,7 @@ func init() {
apijson.Discriminator[WebSearchToolParam]("web_search_2025_08_26"),
apijson.Discriminator[ToolMcpParam]("mcp"),
apijson.Discriminator[ToolCodeInterpreterParam]("code_interpreter"),
+ apijson.Discriminator[ToolProgrammaticToolCallingParam]("programmatic_tool_calling"),
apijson.Discriminator[ToolImageGenerationParam]("image_generation"),
apijson.Discriminator[ToolLocalShellParam]("local_shell"),
apijson.Discriminator[FunctionShellToolParam]("shell"),
@@ -20168,9 +24294,16 @@ type ToolMcpParam struct {
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` or `connector_id` must be
- // provided.
- ServerURL param.Opt[string] `json:"server_url,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 ToolMcpAllowedToolsUnionParam `json:"allowed_tools,omitzero"`
// Optional HTTP headers to send to the MCP server. Use for authentication or other
@@ -20179,8 +24312,8 @@ type ToolMcpParam struct {
// Specify which of the MCP server's tools require approval.
RequireApproval ToolMcpRequireApprovalUnionParam `json:"require_approval,omitzero"`
// Identifier for service connectors, like those available in ChatGPT. One of
- // `server_url` or `connector_id` must be provided. Learn more about service
- // connectors
+ // `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:
@@ -20357,6 +24490,10 @@ type ToolCodeInterpreterParam struct {
// specifies uploaded file IDs to make available to your code, along with an
// optional `memory_limit` setting.
Container ToolCodeInterpreterContainerUnionParam `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".
@@ -20490,6 +24627,28 @@ func init() {
)
}
+func NewToolProgrammaticToolCallingParam() ToolProgrammaticToolCallingParam {
+ return ToolProgrammaticToolCallingParam{
+ Type: "programmatic_tool_calling",
+ }
+}
+
+// This struct has a constant value, construct it with
+// [NewToolProgrammaticToolCallingParam].
+type ToolProgrammaticToolCallingParam struct {
+ // The type of the tool. Always `programmatic_tool_calling`.
+ Type constant.ProgrammaticToolCalling `json:"type" default:"programmatic_tool_calling"`
+ paramObj
+}
+
+func (r ToolProgrammaticToolCallingParam) MarshalJSON() (data []byte, err error) {
+ type shadow ToolProgrammaticToolCallingParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ToolProgrammaticToolCallingParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// A tool that generates images using the GPT image models.
//
// The property Type is required.
@@ -20510,8 +24669,18 @@ type ToolImageGenerationParam struct {
//
// Any of "generate", "edit", "auto".
Action string `json:"action,omitzero"`
- // Background type for the generated image. One of `transparent`, `opaque`, or
- // `auto`. Default: `auto`.
+ // 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"`
@@ -20534,10 +24703,17 @@ type ToolImageGenerationParam struct {
//
// Any of "low", "medium", "high", "auto".
Quality string `json:"quality,omitzero"`
- // The size of the generated image. One of `1024x1024`, `1024x1536`, `1536x1024`,
- // or `auto`. Default: `auto`.
- //
- // Any of "1024x1024", "1024x1536", "1536x1024", "auto".
+ // 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`.
//
@@ -20573,9 +24749,6 @@ func init() {
apijson.RegisterFieldValidator[ToolImageGenerationParam](
"quality", "low", "medium", "high", "auto",
)
- apijson.RegisterFieldValidator[ToolImageGenerationParam](
- "size", "1024x1024", "1024x1536", "1536x1024", "auto",
- )
}
// Optional mask for inpainting. Contains `image_url` (string, optional) and
@@ -21553,6 +25726,17 @@ type ResponseNewParams struct {
// [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
@@ -21560,8 +25744,9 @@ type ResponseNewParams struct {
// 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 number of most likely tokens to
- // return at each token position, each with an associated log probability.
+ // 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
@@ -21569,17 +25754,6 @@ type ResponseNewParams struct {
//
// We generally recommend altering this or `temperature` but not both.
TopP param.Opt[float64] `json:"top_p,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"`
// 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
@@ -21619,15 +25793,30 @@ 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"`
+ // Configuration for running moderation on the input and output of this response.
+ Moderation ResponseNewParamsModeration `json:"moderation,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"`
+ // 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:
//
- // Any of "in-memory", "24h".
+ // - 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 ResponseNewParamsPromptCacheRetention `json:"prompt_cache_retention,omitzero"`
// Specifies the processing type used for serving the request.
//
@@ -21676,6 +25865,16 @@ type ResponseNewParams struct {
// [model guide](https://platform.openai.com/docs/models) to browse and compare
// available models.
Model shared.ResponsesModel `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 ResponseNewParamsPromptCacheOptions `json:"prompt_cache_options,omitzero"`
// **gpt-5 and o-series models only**
//
// Configuration options for
@@ -21789,14 +25988,155 @@ func (u *ResponseNewParamsInputUnion) asAny() any {
return nil
}
+// Configuration for running moderation on the input and output of this response.
+//
+// The property Model is required.
+type ResponseNewParamsModeration 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 ResponseNewParamsModerationPolicy `json:"policy,omitzero"`
+ paramObj
+}
+
+func (r ResponseNewParamsModeration) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseNewParamsModeration
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseNewParamsModeration) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// The policy to apply to moderated response input and output.
+type ResponseNewParamsModerationPolicy struct {
+ // The moderation policy for the response input.
+ Input ResponseNewParamsModerationPolicyInput `json:"input,omitzero"`
+ // The moderation policy for the response output.
+ Output ResponseNewParamsModerationPolicyOutput `json:"output,omitzero"`
+ paramObj
+}
+
+func (r ResponseNewParamsModerationPolicy) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseNewParamsModerationPolicy
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseNewParamsModerationPolicy) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// The moderation policy for the response input.
+//
+// The property Mode is required.
+type ResponseNewParamsModerationPolicyInput struct {
+ // Any of "score", "block".
+ Mode string `json:"mode,omitzero" api:"required"`
+ paramObj
+}
+
+func (r ResponseNewParamsModerationPolicyInput) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseNewParamsModerationPolicyInput
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseNewParamsModerationPolicyInput) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func init() {
+ apijson.RegisterFieldValidator[ResponseNewParamsModerationPolicyInput](
+ "mode", "score", "block",
+ )
+}
+
+// The moderation policy for the response output.
+//
+// The property Mode is required.
+type ResponseNewParamsModerationPolicyOutput struct {
+ // Any of "score", "block".
+ Mode string `json:"mode,omitzero" api:"required"`
+ paramObj
+}
+
+func (r ResponseNewParamsModerationPolicyOutput) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseNewParamsModerationPolicyOutput
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseNewParamsModerationPolicyOutput) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func init() {
+ apijson.RegisterFieldValidator[ResponseNewParamsModerationPolicyOutput](
+ "mode", "score", "block",
+ )
+}
+
+// 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 ResponseNewParamsPromptCacheOptions 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 ResponseNewParamsPromptCacheOptions) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseNewParamsPromptCacheOptions
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseNewParamsPromptCacheOptions) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func init() {
+ apijson.RegisterFieldValidator[ResponseNewParamsPromptCacheOptions](
+ "mode", "implicit", "explicit",
+ )
+ apijson.RegisterFieldValidator[ResponseNewParamsPromptCacheOptions](
+ "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 ResponseNewParamsPromptCacheRetention string
const (
- ResponseNewParamsPromptCacheRetentionInMemory ResponseNewParamsPromptCacheRetention = "in-memory"
+ ResponseNewParamsPromptCacheRetentionInMemory ResponseNewParamsPromptCacheRetention = "in_memory"
ResponseNewParamsPromptCacheRetention24h ResponseNewParamsPromptCacheRetention = "24h"
)
@@ -21851,14 +26191,15 @@ func (r *ResponseNewParamsStreamOptions) UnmarshalJSON(data []byte) error {
// Use [param.IsOmitted] to confirm if a field is set.
type ResponseNewParamsToolChoiceUnion struct {
// Check if union is this variant with !param.IsOmitted(union.OfToolChoiceMode)
- OfToolChoiceMode param.Opt[ToolChoiceOptions] `json:",omitzero,inline"`
- OfAllowedTools *ToolChoiceAllowedParam `json:",omitzero,inline"`
- OfHostedTool *ToolChoiceTypesParam `json:",omitzero,inline"`
- OfFunctionTool *ToolChoiceFunctionParam `json:",omitzero,inline"`
- OfMcpTool *ToolChoiceMcpParam `json:",omitzero,inline"`
- OfCustomTool *ToolChoiceCustomParam `json:",omitzero,inline"`
- OfSpecificApplyPatchToolChoice *ToolChoiceApplyPatchParam `json:",omitzero,inline"`
- OfSpecificShellToolChoice *ToolChoiceShellParam `json:",omitzero,inline"`
+ OfToolChoiceMode param.Opt[ToolChoiceOptions] `json:",omitzero,inline"`
+ OfAllowedTools *ToolChoiceAllowedParam `json:",omitzero,inline"`
+ OfHostedTool *ToolChoiceTypesParam `json:",omitzero,inline"`
+ OfFunctionTool *ToolChoiceFunctionParam `json:",omitzero,inline"`
+ OfMcpTool *ToolChoiceMcpParam `json:",omitzero,inline"`
+ OfCustomTool *ToolChoiceCustomParam `json:",omitzero,inline"`
+ OfResponseNewsToolChoiceSpecificProgrammaticToolCallingParam *ResponseNewParamsToolChoiceSpecificProgrammaticToolCallingParam `json:",omitzero,inline"`
+ OfSpecificApplyPatchToolChoice *ToolChoiceApplyPatchParam `json:",omitzero,inline"`
+ OfSpecificShellToolChoice *ToolChoiceShellParam `json:",omitzero,inline"`
paramUnion
}
@@ -21869,6 +26210,7 @@ func (u ResponseNewParamsToolChoiceUnion) MarshalJSON() ([]byte, error) {
u.OfFunctionTool,
u.OfMcpTool,
u.OfCustomTool,
+ u.OfResponseNewsToolChoiceSpecificProgrammaticToolCallingParam,
u.OfSpecificApplyPatchToolChoice,
u.OfSpecificShellToolChoice)
}
@@ -21889,6 +26231,8 @@ func (u *ResponseNewParamsToolChoiceUnion) asAny() any {
return u.OfMcpTool
} else if !param.IsOmitted(u.OfCustomTool) {
return u.OfCustomTool
+ } else if !param.IsOmitted(u.OfResponseNewsToolChoiceSpecificProgrammaticToolCallingParam) {
+ return u.OfResponseNewsToolChoiceSpecificProgrammaticToolCallingParam
} else if !param.IsOmitted(u.OfSpecificApplyPatchToolChoice) {
return u.OfSpecificApplyPatchToolChoice
} else if !param.IsOmitted(u.OfSpecificShellToolChoice) {
@@ -21933,6 +26277,8 @@ func (u ResponseNewParamsToolChoiceUnion) GetType() *string {
return (*string)(&vt.Type)
} else if vt := u.OfCustomTool; vt != nil {
return (*string)(&vt.Type)
+ } else if vt := u.OfResponseNewsToolChoiceSpecificProgrammaticToolCallingParam; vt != nil {
+ return (*string)(&vt.Type)
} else if vt := u.OfSpecificApplyPatchToolChoice; vt != nil {
return (*string)(&vt.Type)
} else if vt := u.OfSpecificShellToolChoice; vt != nil {
@@ -21953,6 +26299,28 @@ func (u ResponseNewParamsToolChoiceUnion) GetName() *string {
return nil
}
+func NewResponseNewParamsToolChoiceSpecificProgrammaticToolCallingParam() ResponseNewParamsToolChoiceSpecificProgrammaticToolCallingParam {
+ return ResponseNewParamsToolChoiceSpecificProgrammaticToolCallingParam{
+ Type: "programmatic_tool_calling",
+ }
+}
+
+// This struct has a constant value, construct it with
+// [NewResponseNewParamsToolChoiceSpecificProgrammaticToolCallingParam].
+type ResponseNewParamsToolChoiceSpecificProgrammaticToolCallingParam struct {
+ // The tool to call. Always `programmatic_tool_calling`.
+ Type constant.ProgrammaticToolCalling `json:"type" default:"programmatic_tool_calling"`
+ paramObj
+}
+
+func (r ResponseNewParamsToolChoiceSpecificProgrammaticToolCallingParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseNewParamsToolChoiceSpecificProgrammaticToolCallingParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseNewParamsToolChoiceSpecificProgrammaticToolCallingParam) 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,
@@ -22012,10 +26380,24 @@ type ResponseCompactParams struct {
PromptCacheKey param.Opt[string] `json:"prompt_cache_key,omitzero"`
// Text, image, or file inputs to the model, used to generate a response
Input ResponseCompactParamsInputUnion `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 ResponseCompactParamsPromptCacheOptions `json:"prompt_cache_options,omitzero"`
// How long to retain a prompt cache entry created by this request.
//
// Any of "in_memory", "24h".
PromptCacheRetention ResponseCompactParamsPromptCacheRetention `json:"prompt_cache_retention,omitzero"`
+ // The service tier to use for this request.
+ //
+ // Any of "auto", "default", "flex", "priority".
+ ServiceTier ResponseCompactParamsServiceTier `json:"service_tier,omitzero"`
paramObj
}
@@ -22035,6 +26417,9 @@ func (r *ResponseCompactParams) UnmarshalJSON(data []byte) error {
type ResponseCompactParamsModel string
const (
+ ResponseCompactParamsModelGPT5_6Sol ResponseCompactParamsModel = "gpt-5.6-sol"
+ ResponseCompactParamsModelGPT5_6Terra ResponseCompactParamsModel = "gpt-5.6-terra"
+ ResponseCompactParamsModelGPT5_6Luna ResponseCompactParamsModel = "gpt-5.6-luna"
ResponseCompactParamsModelGPT5_4 ResponseCompactParamsModel = "gpt-5.4"
ResponseCompactParamsModelGPT5_4Mini ResponseCompactParamsModel = "gpt-5.4-mini"
ResponseCompactParamsModelGPT5_4Nano ResponseCompactParamsModel = "gpt-5.4-nano"
@@ -22154,6 +26539,51 @@ func (u *ResponseCompactParamsInputUnion) asAny() any {
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 ResponseCompactParamsPromptCacheOptions 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 ResponseCompactParamsPromptCacheOptions) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseCompactParamsPromptCacheOptions
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseCompactParamsPromptCacheOptions) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func init() {
+ apijson.RegisterFieldValidator[ResponseCompactParamsPromptCacheOptions](
+ "mode", "implicit", "explicit",
+ )
+ apijson.RegisterFieldValidator[ResponseCompactParamsPromptCacheOptions](
+ "ttl", "30m",
+ )
+}
+
// How long to retain a prompt cache entry created by this request.
type ResponseCompactParamsPromptCacheRetention string
@@ -22161,3 +26591,13 @@ const (
ResponseCompactParamsPromptCacheRetentionInMemory ResponseCompactParamsPromptCacheRetention = "in_memory"
ResponseCompactParamsPromptCacheRetention24h ResponseCompactParamsPromptCacheRetention = "24h"
)
+
+// The service tier to use for this request.
+type ResponseCompactParamsServiceTier string
+
+const (
+ ResponseCompactParamsServiceTierAuto ResponseCompactParamsServiceTier = "auto"
+ ResponseCompactParamsServiceTierDefault ResponseCompactParamsServiceTier = "default"
+ ResponseCompactParamsServiceTierFlex ResponseCompactParamsServiceTier = "flex"
+ ResponseCompactParamsServiceTierPriority ResponseCompactParamsServiceTier = "priority"
+)
diff --git a/vendor/github.com/openai/openai-go/v3/shared/constant/constants.go b/vendor/github.com/openai/openai-go/v3/shared/constant/constants.go
index 7ab9b729b..d8e76b205 100644
--- a/vendor/github.com/openai/openai-go/v3/shared/constant/constants.go
+++ b/vendor/github.com/openai/openai-go/v3/shared/constant/constants.go
@@ -19,6 +19,8 @@ func ValueOf[T Constant[T]]() T {
}
type Active string // Always "active"
+type AdditionalTools string // Always "additional_tools"
+type AgentMessage string // Always "agent_message"
type AllowedTools string // Always "allowed_tools"
type Allowlist string // Always "allowlist"
type ApplicationZip string // Always "application/zip"
@@ -35,6 +37,8 @@ type BatchCancelled string // Always "batch.ca
type BatchCompleted string // Always "batch.completed"
type BatchExpired string // Always "batch.expired"
type BatchFailed string // Always "batch.failed"
+type Bucket string // Always "bucket"
+type CertificateDeleted string // Always "certificate.deleted"
type ChatCompletion string // Always "chat.completion"
type ChatCompletionChunk string // Always "chat.completion.chunk"
type ChatCompletionDeleted string // Always "chat.completion.deleted"
@@ -54,6 +58,7 @@ type Closed string // Always "closed"
type CodeInterpreter string // Always "code_interpreter"
type CodeInterpreterCall string // Always "code_interpreter_call"
type Compaction string // Always "compaction"
+type CompactionTrigger string // Always "compaction_trigger"
type Computer string // Always "computer"
type ComputerCallOutput string // Always "computer_call_output"
type ComputerScreenshot string // Always "computer_screenshot"
@@ -87,17 +92,21 @@ type CustomToolCall string // Always "custom_t
type CustomToolCallOutput string // Always "custom_tool_call_output"
type DeleteFile string // Always "delete_file"
type Developer string // Always "developer"
+type Direct string // Always "direct"
type Disabled string // Always "disabled"
type DoubleClick string // Always "double_click"
type Drag string // Always "drag"
type Duration string // Always "duration"
+type Email string // Always "email"
type Embedding string // Always "embedding"
+type EncryptedContent string // Always "encrypted_content"
type Error string // Always "error"
type EvalRunCanceled string // Always "eval.run.canceled"
type EvalRunFailed string // Always "eval.run.failed"
type EvalRunSucceeded string // Always "eval.run.succeeded"
type Exec string // Always "exec"
type Exit string // Always "exit"
+type Explicit string // Always "explicit"
type File string // Always "file"
type FileCitation string // Always "file_citation"
type FilePath string // Always "file_path"
@@ -114,6 +123,11 @@ type Function string // Always "function
type FunctionCall string // Always "function_call"
type FunctionCallOutput string // Always "function_call_output"
type Grammar string // Always "grammar"
+type Group string // Always "group"
+type GroupDeleted string // Always "group.deleted"
+type GroupRole string // Always "group.role"
+type GroupUser string // Always "group.user"
+type GroupUserDeleted string // Always "group.user.deleted"
type HTTPError string // Always "http_error"
type Image string // Always "image"
type ImageEditCompleted string // Always "image_edit.completed"
@@ -162,10 +176,48 @@ type McpListToolsInProgress string // Always "mcp_list
type Message string // Always "message"
type MessageCreation string // Always "message_creation"
type Model string // Always "model"
+type ModerationResult string // Always "moderation_result"
+type ModerationResults string // Always "moderation_results"
type Move string // Always "move"
type Multi string // Always "multi"
+type MultiAgentCall string // Always "multi_agent_call"
+type MultiAgentCallOutput string // Always "multi_agent_call_output"
type Namespace string // Always "namespace"
type OpenPage string // Always "open_page"
+type OrganizationAdminAPIKey string // Always "organization.admin_api_key"
+type OrganizationAdminAPIKeyDeleted string // Always "organization.admin_api_key.deleted"
+type OrganizationCertificate string // Always "organization.certificate"
+type OrganizationCertificateActivation string // Always "organization.certificate.activation"
+type OrganizationCertificateDeactivation string // Always "organization.certificate.deactivation"
+type OrganizationCostsResult string // Always "organization.costs.result"
+type OrganizationDataRetention string // Always "organization.data_retention"
+type OrganizationInvite string // Always "organization.invite"
+type OrganizationInviteDeleted string // Always "organization.invite.deleted"
+type OrganizationProject string // Always "organization.project"
+type OrganizationProjectAPIKey string // Always "organization.project.api_key"
+type OrganizationProjectAPIKeyDeleted string // Always "organization.project.api_key.deleted"
+type OrganizationProjectCertificate string // Always "organization.project.certificate"
+type OrganizationProjectCertificateActivation string // Always "organization.project.certificate.activation"
+type OrganizationProjectCertificateDeactivation string // Always "organization.project.certificate.deactivation"
+type OrganizationProjectServiceAccount string // Always "organization.project.service_account"
+type OrganizationProjectServiceAccountAPIKey string // Always "organization.project.service_account.api_key"
+type OrganizationProjectServiceAccountDeleted string // Always "organization.project.service_account.deleted"
+type OrganizationProjectUser string // Always "organization.project.user"
+type OrganizationProjectUserDeleted string // Always "organization.project.user.deleted"
+type OrganizationSpendAlert string // Always "organization.spend_alert"
+type OrganizationSpendAlertDeleted string // Always "organization.spend_alert.deleted"
+type OrganizationUsageAudioSpeechesResult string // Always "organization.usage.audio_speeches.result"
+type OrganizationUsageAudioTranscriptionsResult string // Always "organization.usage.audio_transcriptions.result"
+type OrganizationUsageCodeInterpreterSessionsResult string // Always "organization.usage.code_interpreter_sessions.result"
+type OrganizationUsageCompletionsResult string // Always "organization.usage.completions.result"
+type OrganizationUsageEmbeddingsResult string // Always "organization.usage.embeddings.result"
+type OrganizationUsageFileSearchesResult string // Always "organization.usage.file_searches.result"
+type OrganizationUsageImagesResult string // Always "organization.usage.images.result"
+type OrganizationUsageModerationsResult string // Always "organization.usage.moderations.result"
+type OrganizationUsageVectorStoresResult string // Always "organization.usage.vector_stores.result"
+type OrganizationUsageWebSearchesResult string // Always "organization.usage.web_searches.result"
+type OrganizationUser string // Always "organization.user"
+type OrganizationUserDeleted string // Always "organization.user.deleted"
type Other string // Always "other"
type OutputAudio string // Always "output_audio"
type OutputAudioBufferClear string // Always "output_audio_buffer.clear"
@@ -173,12 +225,25 @@ type OutputAudioBufferCleared string // Always "output_a
type OutputAudioBufferStarted string // Always "output_audio_buffer.started"
type OutputAudioBufferStopped string // Always "output_audio_buffer.stopped"
type OutputText string // Always "output_text"
+type Page string // Always "page"
+type Program string // Always "program"
+type ProgramOutput string // Always "program_output"
+type ProgrammaticToolCalling string // Always "programmatic_tool_calling"
+type ProjectDataRetention string // Always "project.data_retention"
+type ProjectGroup string // Always "project.group"
+type ProjectGroupDeleted string // Always "project.group.deleted"
+type ProjectModelPermissions string // Always "project.model_permissions"
+type ProjectModelPermissionsDeleted string // Always "project.model_permissions.deleted"
+type ProjectRateLimit string // Always "project.rate_limit"
+type ProjectSpendAlert string // Always "project.spend_alert"
+type ProjectSpendAlertDeleted string // Always "project.spend_alert.deleted"
type ProtocolError string // Always "protocol_error"
type Python string // Always "python"
type QuotedText string // Always "quoted_text"
type RateLimitsUpdated string // Always "rate_limits.updated"
type Realtime string // Always "realtime"
type RealtimeCallIncoming string // Always "realtime.call.incoming"
+type RealtimeSession string // Always "realtime.session"
type Reasoning string // Always "reasoning"
type ReasoningText string // Always "reasoning_text"
type Refusal string // Always "refusal"
@@ -215,6 +280,9 @@ type ResponseImageGenerationCallInProgress string // Always "response
type ResponseImageGenerationCallPartialImage string // Always "response.image_generation_call.partial_image"
type ResponseInProgress string // Always "response.in_progress"
type ResponseIncomplete string // Always "response.incomplete"
+type ResponseInject string // Always "response.inject"
+type ResponseInjectCreated string // Always "response.inject.created"
+type ResponseInjectFailed string // Always "response.inject.failed"
type ResponseInputTokens string // Always "response.input_tokens"
type ResponseMcpCallArgumentsDelta string // Always "response.mcp_call_arguments.delta"
type ResponseMcpCallArgumentsDone string // Always "response.mcp_call_arguments.done"
@@ -246,13 +314,21 @@ type ResponseWebSearchCallCompleted string // Always "response
type ResponseWebSearchCallInProgress string // Always "response.web_search_call.in_progress"
type ResponseWebSearchCallSearching string // Always "response.web_search_call.searching"
type RetentionRatio string // Always "retention_ratio"
+type Role string // Always "role"
+type RoleDeleted string // Always "role.deleted"
type ScoreModel string // Always "score_model"
type Screenshot string // Always "screenshot"
type Scroll string // Always "scroll"
type Search string // Always "search"
type SemanticVad string // Always "semantic_vad"
type ServerVad string // Always "server_vad"
+type SessionClose string // Always "session.close"
+type SessionClosed string // Always "session.closed"
type SessionCreated string // Always "session.created"
+type SessionInputAudioBufferAppend string // Always "session.input_audio_buffer.append"
+type SessionInputTranscriptDelta string // Always "session.input_transcript.delta"
+type SessionOutputAudioDelta string // Always "session.output_audio.delta"
+type SessionOutputTranscriptDelta string // Always "session.output_transcript.delta"
type SessionUpdate string // Always "session.update"
type SessionUpdated string // Always "session.updated"
type Shell string // Always "shell"
@@ -315,6 +391,7 @@ type TranscriptTextSegment string // Always "transcri
type Transcription string // Always "transcription"
type TranscriptionSessionUpdate string // Always "transcription_session.update"
type TranscriptionSessionUpdated string // Always "transcription_session.updated"
+type Translation string // Always "translation"
type Type string // Always "type"
type UpdateFile string // Always "update_file"
type Upload string // Always "upload"
@@ -322,6 +399,7 @@ type UploadPart string // Always "upload.p
type URL string // Always "url"
type URLCitation string // Always "url_citation"
type User string // Always "user"
+type UserRole string // Always "user.role"
type VectorStore string // Always "vector_store"
type VectorStoreDeleted string // Always "vector_store.deleted"
type VectorStoreFile string // Always "vector_store.file"
@@ -336,6 +414,8 @@ type Wandb string // Always "wandb"
type WebSearchCall string // Always "web_search_call"
func (c Active) Default() Active { return "active" }
+func (c AdditionalTools) Default() AdditionalTools { return "additional_tools" }
+func (c AgentMessage) Default() AgentMessage { return "agent_message" }
func (c AllowedTools) Default() AllowedTools { return "allowed_tools" }
func (c Allowlist) Default() Allowlist { return "allowlist" }
func (c ApplicationZip) Default() ApplicationZip { return "application/zip" }
@@ -352,6 +432,8 @@ func (c BatchCancelled) Default() BatchCancelled { return "batch.c
func (c BatchCompleted) Default() BatchCompleted { return "batch.completed" }
func (c BatchExpired) Default() BatchExpired { return "batch.expired" }
func (c BatchFailed) Default() BatchFailed { return "batch.failed" }
+func (c Bucket) Default() Bucket { return "bucket" }
+func (c CertificateDeleted) Default() CertificateDeleted { return "certificate.deleted" }
func (c ChatCompletion) Default() ChatCompletion { return "chat.completion" }
func (c ChatCompletionChunk) Default() ChatCompletionChunk { return "chat.completion.chunk" }
func (c ChatCompletionDeleted) Default() ChatCompletionDeleted { return "chat.completion.deleted" }
@@ -373,6 +455,7 @@ func (c Closed) Default() Closed { return "close
func (c CodeInterpreter) Default() CodeInterpreter { return "code_interpreter" }
func (c CodeInterpreterCall) Default() CodeInterpreterCall { return "code_interpreter_call" }
func (c Compaction) Default() Compaction { return "compaction" }
+func (c CompactionTrigger) Default() CompactionTrigger { return "compaction_trigger" }
func (c Computer) Default() Computer { return "computer" }
func (c ComputerCallOutput) Default() ComputerCallOutput { return "computer_call_output" }
func (c ComputerScreenshot) Default() ComputerScreenshot { return "computer_screenshot" }
@@ -426,17 +509,21 @@ func (c CustomToolCall) Default() CustomToolCall { return "custo
func (c CustomToolCallOutput) Default() CustomToolCallOutput { return "custom_tool_call_output" }
func (c DeleteFile) Default() DeleteFile { return "delete_file" }
func (c Developer) Default() Developer { return "developer" }
+func (c Direct) Default() Direct { return "direct" }
func (c Disabled) Default() Disabled { return "disabled" }
func (c DoubleClick) Default() DoubleClick { return "double_click" }
func (c Drag) Default() Drag { return "drag" }
func (c Duration) Default() Duration { return "duration" }
+func (c Email) Default() Email { return "email" }
func (c Embedding) Default() Embedding { return "embedding" }
+func (c EncryptedContent) Default() EncryptedContent { return "encrypted_content" }
func (c Error) Default() Error { return "error" }
func (c EvalRunCanceled) Default() EvalRunCanceled { return "eval.run.canceled" }
func (c EvalRunFailed) Default() EvalRunFailed { return "eval.run.failed" }
func (c EvalRunSucceeded) Default() EvalRunSucceeded { return "eval.run.succeeded" }
func (c Exec) Default() Exec { return "exec" }
func (c Exit) Default() Exit { return "exit" }
+func (c Explicit) Default() Explicit { return "explicit" }
func (c File) Default() File { return "file" }
func (c FileCitation) Default() FileCitation { return "file_citation" }
func (c FilePath) Default() FilePath { return "file_path" }
@@ -455,6 +542,11 @@ func (c Function) Default() Function { return "funct
func (c FunctionCall) Default() FunctionCall { return "function_call" }
func (c FunctionCallOutput) Default() FunctionCallOutput { return "function_call_output" }
func (c Grammar) Default() Grammar { return "grammar" }
+func (c Group) Default() Group { return "group" }
+func (c GroupDeleted) Default() GroupDeleted { return "group.deleted" }
+func (c GroupRole) Default() GroupRole { return "group.role" }
+func (c GroupUser) Default() GroupUser { return "group.user" }
+func (c GroupUserDeleted) Default() GroupUserDeleted { return "group.user.deleted" }
func (c HTTPError) Default() HTTPError { return "http_error" }
func (c Image) Default() Image { return "image" }
func (c ImageEditCompleted) Default() ImageEditCompleted { return "image_edit.completed" }
@@ -519,10 +611,106 @@ func (c McpListToolsInProgress) Default() McpListToolsInProgress { return "mcp_l
func (c Message) Default() Message { return "message" }
func (c MessageCreation) Default() MessageCreation { return "message_creation" }
func (c Model) Default() Model { return "model" }
+func (c ModerationResult) Default() ModerationResult { return "moderation_result" }
+func (c ModerationResults) Default() ModerationResults { return "moderation_results" }
func (c Move) Default() Move { return "move" }
func (c Multi) Default() Multi { return "multi" }
+func (c MultiAgentCall) Default() MultiAgentCall { return "multi_agent_call" }
+func (c MultiAgentCallOutput) Default() MultiAgentCallOutput { return "multi_agent_call_output" }
func (c Namespace) Default() Namespace { return "namespace" }
func (c OpenPage) Default() OpenPage { return "open_page" }
+func (c OrganizationAdminAPIKey) Default() OrganizationAdminAPIKey {
+ return "organization.admin_api_key"
+}
+func (c OrganizationAdminAPIKeyDeleted) Default() OrganizationAdminAPIKeyDeleted {
+ return "organization.admin_api_key.deleted"
+}
+func (c OrganizationCertificate) Default() OrganizationCertificate { return "organization.certificate" }
+func (c OrganizationCertificateActivation) Default() OrganizationCertificateActivation {
+ return "organization.certificate.activation"
+}
+func (c OrganizationCertificateDeactivation) Default() OrganizationCertificateDeactivation {
+ return "organization.certificate.deactivation"
+}
+func (c OrganizationCostsResult) Default() OrganizationCostsResult {
+ return "organization.costs.result"
+}
+func (c OrganizationDataRetention) Default() OrganizationDataRetention {
+ return "organization.data_retention"
+}
+func (c OrganizationInvite) Default() OrganizationInvite { return "organization.invite" }
+func (c OrganizationInviteDeleted) Default() OrganizationInviteDeleted {
+ return "organization.invite.deleted"
+}
+func (c OrganizationProject) Default() OrganizationProject { return "organization.project" }
+func (c OrganizationProjectAPIKey) Default() OrganizationProjectAPIKey {
+ return "organization.project.api_key"
+}
+func (c OrganizationProjectAPIKeyDeleted) Default() OrganizationProjectAPIKeyDeleted {
+ return "organization.project.api_key.deleted"
+}
+func (c OrganizationProjectCertificate) Default() OrganizationProjectCertificate {
+ return "organization.project.certificate"
+}
+func (c OrganizationProjectCertificateActivation) Default() OrganizationProjectCertificateActivation {
+ return "organization.project.certificate.activation"
+}
+func (c OrganizationProjectCertificateDeactivation) Default() OrganizationProjectCertificateDeactivation {
+ return "organization.project.certificate.deactivation"
+}
+func (c OrganizationProjectServiceAccount) Default() OrganizationProjectServiceAccount {
+ return "organization.project.service_account"
+}
+func (c OrganizationProjectServiceAccountAPIKey) Default() OrganizationProjectServiceAccountAPIKey {
+ return "organization.project.service_account.api_key"
+}
+func (c OrganizationProjectServiceAccountDeleted) Default() OrganizationProjectServiceAccountDeleted {
+ return "organization.project.service_account.deleted"
+}
+func (c OrganizationProjectUser) Default() OrganizationProjectUser {
+ return "organization.project.user"
+}
+func (c OrganizationProjectUserDeleted) Default() OrganizationProjectUserDeleted {
+ return "organization.project.user.deleted"
+}
+func (c OrganizationSpendAlert) Default() OrganizationSpendAlert { return "organization.spend_alert" }
+func (c OrganizationSpendAlertDeleted) Default() OrganizationSpendAlertDeleted {
+ return "organization.spend_alert.deleted"
+}
+func (c OrganizationUsageAudioSpeechesResult) Default() OrganizationUsageAudioSpeechesResult {
+ return "organization.usage.audio_speeches.result"
+}
+func (c OrganizationUsageAudioTranscriptionsResult) Default() OrganizationUsageAudioTranscriptionsResult {
+ return "organization.usage.audio_transcriptions.result"
+}
+func (c OrganizationUsageCodeInterpreterSessionsResult) Default() OrganizationUsageCodeInterpreterSessionsResult {
+ return "organization.usage.code_interpreter_sessions.result"
+}
+func (c OrganizationUsageCompletionsResult) Default() OrganizationUsageCompletionsResult {
+ return "organization.usage.completions.result"
+}
+func (c OrganizationUsageEmbeddingsResult) Default() OrganizationUsageEmbeddingsResult {
+ return "organization.usage.embeddings.result"
+}
+func (c OrganizationUsageFileSearchesResult) Default() OrganizationUsageFileSearchesResult {
+ return "organization.usage.file_searches.result"
+}
+func (c OrganizationUsageImagesResult) Default() OrganizationUsageImagesResult {
+ return "organization.usage.images.result"
+}
+func (c OrganizationUsageModerationsResult) Default() OrganizationUsageModerationsResult {
+ return "organization.usage.moderations.result"
+}
+func (c OrganizationUsageVectorStoresResult) Default() OrganizationUsageVectorStoresResult {
+ return "organization.usage.vector_stores.result"
+}
+func (c OrganizationUsageWebSearchesResult) Default() OrganizationUsageWebSearchesResult {
+ return "organization.usage.web_searches.result"
+}
+func (c OrganizationUser) Default() OrganizationUser { return "organization.user" }
+func (c OrganizationUserDeleted) Default() OrganizationUserDeleted {
+ return "organization.user.deleted"
+}
func (c Other) Default() Other { return "other" }
func (c OutputAudio) Default() OutputAudio { return "output_audio" }
func (c OutputAudioBufferClear) Default() OutputAudioBufferClear { return "output_audio_buffer.clear" }
@@ -535,13 +723,34 @@ func (c OutputAudioBufferStarted) Default() OutputAudioBufferStarted {
func (c OutputAudioBufferStopped) Default() OutputAudioBufferStopped {
return "output_audio_buffer.stopped"
}
-func (c OutputText) Default() OutputText { return "output_text" }
+func (c OutputText) Default() OutputText { return "output_text" }
+func (c Page) Default() Page { return "page" }
+func (c Program) Default() Program { return "program" }
+func (c ProgramOutput) Default() ProgramOutput { return "program_output" }
+func (c ProgrammaticToolCalling) Default() ProgrammaticToolCalling {
+ return "programmatic_tool_calling"
+}
+func (c ProjectDataRetention) Default() ProjectDataRetention { return "project.data_retention" }
+func (c ProjectGroup) Default() ProjectGroup { return "project.group" }
+func (c ProjectGroupDeleted) Default() ProjectGroupDeleted { return "project.group.deleted" }
+func (c ProjectModelPermissions) Default() ProjectModelPermissions {
+ return "project.model_permissions"
+}
+func (c ProjectModelPermissionsDeleted) Default() ProjectModelPermissionsDeleted {
+ return "project.model_permissions.deleted"
+}
+func (c ProjectRateLimit) Default() ProjectRateLimit { return "project.rate_limit" }
+func (c ProjectSpendAlert) Default() ProjectSpendAlert { return "project.spend_alert" }
+func (c ProjectSpendAlertDeleted) Default() ProjectSpendAlertDeleted {
+ return "project.spend_alert.deleted"
+}
func (c ProtocolError) Default() ProtocolError { return "protocol_error" }
func (c Python) Default() Python { return "python" }
func (c QuotedText) Default() QuotedText { return "quoted_text" }
func (c RateLimitsUpdated) Default() RateLimitsUpdated { return "rate_limits.updated" }
func (c Realtime) Default() Realtime { return "realtime" }
func (c RealtimeCallIncoming) Default() RealtimeCallIncoming { return "realtime.call.incoming" }
+func (c RealtimeSession) Default() RealtimeSession { return "realtime.session" }
func (c Reasoning) Default() Reasoning { return "reasoning" }
func (c ReasoningText) Default() ReasoningText { return "reasoning_text" }
func (c Refusal) Default() Refusal { return "refusal" }
@@ -616,9 +825,12 @@ func (c ResponseImageGenerationCallInProgress) Default() ResponseImageGeneration
func (c ResponseImageGenerationCallPartialImage) Default() ResponseImageGenerationCallPartialImage {
return "response.image_generation_call.partial_image"
}
-func (c ResponseInProgress) Default() ResponseInProgress { return "response.in_progress" }
-func (c ResponseIncomplete) Default() ResponseIncomplete { return "response.incomplete" }
-func (c ResponseInputTokens) Default() ResponseInputTokens { return "response.input_tokens" }
+func (c ResponseInProgress) Default() ResponseInProgress { return "response.in_progress" }
+func (c ResponseIncomplete) Default() ResponseIncomplete { return "response.incomplete" }
+func (c ResponseInject) Default() ResponseInject { return "response.inject" }
+func (c ResponseInjectCreated) Default() ResponseInjectCreated { return "response.inject.created" }
+func (c ResponseInjectFailed) Default() ResponseInjectFailed { return "response.inject.failed" }
+func (c ResponseInputTokens) Default() ResponseInputTokens { return "response.input_tokens" }
func (c ResponseMcpCallArgumentsDelta) Default() ResponseMcpCallArgumentsDelta {
return "response.mcp_call_arguments.delta"
}
@@ -694,14 +906,30 @@ func (c ResponseWebSearchCallInProgress) Default() ResponseWebSearchCallInProgre
func (c ResponseWebSearchCallSearching) Default() ResponseWebSearchCallSearching {
return "response.web_search_call.searching"
}
-func (c RetentionRatio) Default() RetentionRatio { return "retention_ratio" }
-func (c ScoreModel) Default() ScoreModel { return "score_model" }
-func (c Screenshot) Default() Screenshot { return "screenshot" }
-func (c Scroll) Default() Scroll { return "scroll" }
-func (c Search) Default() Search { return "search" }
-func (c SemanticVad) Default() SemanticVad { return "semantic_vad" }
-func (c ServerVad) Default() ServerVad { return "server_vad" }
-func (c SessionCreated) Default() SessionCreated { return "session.created" }
+func (c RetentionRatio) Default() RetentionRatio { return "retention_ratio" }
+func (c Role) Default() Role { return "role" }
+func (c RoleDeleted) Default() RoleDeleted { return "role.deleted" }
+func (c ScoreModel) Default() ScoreModel { return "score_model" }
+func (c Screenshot) Default() Screenshot { return "screenshot" }
+func (c Scroll) Default() Scroll { return "scroll" }
+func (c Search) Default() Search { return "search" }
+func (c SemanticVad) Default() SemanticVad { return "semantic_vad" }
+func (c ServerVad) Default() ServerVad { return "server_vad" }
+func (c SessionClose) Default() SessionClose { return "session.close" }
+func (c SessionClosed) Default() SessionClosed { return "session.closed" }
+func (c SessionCreated) Default() SessionCreated { return "session.created" }
+func (c SessionInputAudioBufferAppend) Default() SessionInputAudioBufferAppend {
+ return "session.input_audio_buffer.append"
+}
+func (c SessionInputTranscriptDelta) Default() SessionInputTranscriptDelta {
+ return "session.input_transcript.delta"
+}
+func (c SessionOutputAudioDelta) Default() SessionOutputAudioDelta {
+ return "session.output_audio.delta"
+}
+func (c SessionOutputTranscriptDelta) Default() SessionOutputTranscriptDelta {
+ return "session.output_transcript.delta"
+}
func (c SessionUpdate) Default() SessionUpdate { return "session.update" }
func (c SessionUpdated) Default() SessionUpdated { return "session.updated" }
func (c Shell) Default() Shell { return "shell" }
@@ -776,6 +1004,7 @@ func (c TranscriptionSessionUpdate) Default() TranscriptionSessionUpdate {
func (c TranscriptionSessionUpdated) Default() TranscriptionSessionUpdated {
return "transcription_session.updated"
}
+func (c Translation) Default() Translation { return "translation" }
func (c Type) Default() Type { return "type" }
func (c UpdateFile) Default() UpdateFile { return "update_file" }
func (c Upload) Default() Upload { return "upload" }
@@ -783,6 +1012,7 @@ func (c UploadPart) Default() UploadPart { return "upload.part"
func (c URL) Default() URL { return "url" }
func (c URLCitation) Default() URLCitation { return "url_citation" }
func (c User) Default() User { return "user" }
+func (c UserRole) Default() UserRole { return "user.role" }
func (c VectorStore) Default() VectorStore { return "vector_store" }
func (c VectorStoreDeleted) Default() VectorStoreDeleted { return "vector_store.deleted" }
func (c VectorStoreFile) Default() VectorStoreFile { return "vector_store.file" }
@@ -801,6 +1031,8 @@ func (c Wandb) Default() Wandb { return "wandb" }
func (c WebSearchCall) Default() WebSearchCall { return "web_search_call" }
func (c Active) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c AdditionalTools) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c AgentMessage) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c AllowedTools) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c Allowlist) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c ApplicationZip) MarshalJSON() ([]byte, error) { return marshalString(c) }
@@ -817,6 +1049,8 @@ func (c BatchCancelled) MarshalJSON() ([]byte, error) { return marshalS
func (c BatchCompleted) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c BatchExpired) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c BatchFailed) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Bucket) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c CertificateDeleted) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c ChatCompletion) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c ChatCompletionChunk) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c ChatCompletionDeleted) MarshalJSON() ([]byte, error) { return marshalString(c) }
@@ -836,6 +1070,7 @@ func (c Closed) MarshalJSON() ([]byte, error) { return marshalS
func (c CodeInterpreter) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c CodeInterpreterCall) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c Compaction) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c CompactionTrigger) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c Computer) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c ComputerCallOutput) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c ComputerScreenshot) MarshalJSON() ([]byte, error) { return marshalString(c) }
@@ -866,96 +1101,155 @@ func (c ConversationItemInputAudioTranscriptionFailed) MarshalJSON() ([]byte, er
func (c ConversationItemInputAudioTranscriptionSegment) MarshalJSON() ([]byte, error) {
return marshalString(c)
}
-func (c ConversationItemRetrieve) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c ConversationItemRetrieved) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c ConversationItemTruncate) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c ConversationItemTruncated) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c CreateFile) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c CreatedAt) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c Custom) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c CustomToolCall) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c CustomToolCallOutput) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c DeleteFile) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c Developer) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c Disabled) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c DoubleClick) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c Drag) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c Duration) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c Embedding) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c Error) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c EvalRunCanceled) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c EvalRunFailed) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c EvalRunSucceeded) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c Exec) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c Exit) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c File) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c FileCitation) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c FilePath) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c FileSearch) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c FileSearchCall) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c FindInPage) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c FineTuningJob) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c FineTuningJobCancelled) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c FineTuningJobCheckpoint) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c FineTuningJobEvent) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c FineTuningJobFailed) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c FineTuningJobSucceeded) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c Function) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c FunctionCall) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c FunctionCallOutput) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c Grammar) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c HTTPError) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c Image) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c ImageEditCompleted) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c ImageEditPartialImage) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c ImageFile) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c ImageGeneration) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c ImageGenerationCall) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c ImageGenerationCompleted) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c ImageGenerationPartialImage) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c ImageURL) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c Inf) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c Inline) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c InputAudio) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c InputAudioBufferAppend) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c InputAudioBufferClear) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c InputAudioBufferCleared) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c InputAudioBufferCommit) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c InputAudioBufferCommitted) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c InputAudioBufferDtmfEventReceived) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c InputAudioBufferSpeechStarted) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c InputAudioBufferSpeechStopped) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c InputAudioBufferTimeoutTriggered) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c InputFile) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c InputImage) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c InputText) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c JSONObject) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c JSONSchema) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c Keypress) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c LabelModel) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c LastActiveAt) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c List) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c Local) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c LocalShell) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c LocalShellCall) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c LocalShellCallOutput) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c Locked) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c Logs) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c Mcp) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c McpApprovalRequest) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c McpApprovalResponse) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c McpCall) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c McpListTools) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c McpListToolsCompleted) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c McpListToolsFailed) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c McpListToolsInProgress) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c Message) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c MessageCreation) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c Model) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c Move) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c Multi) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c Namespace) MarshalJSON() ([]byte, error) { return marshalString(c) }
-func (c OpenPage) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ConversationItemRetrieve) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ConversationItemRetrieved) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ConversationItemTruncate) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ConversationItemTruncated) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c CreateFile) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c CreatedAt) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Custom) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c CustomToolCall) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c CustomToolCallOutput) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c DeleteFile) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Developer) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Direct) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Disabled) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c DoubleClick) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Drag) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Duration) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Email) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Embedding) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c EncryptedContent) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Error) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c EvalRunCanceled) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c EvalRunFailed) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c EvalRunSucceeded) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Exec) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Exit) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Explicit) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c File) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c FileCitation) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c FilePath) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c FileSearch) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c FileSearchCall) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c FindInPage) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c FineTuningJob) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c FineTuningJobCancelled) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c FineTuningJobCheckpoint) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c FineTuningJobEvent) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c FineTuningJobFailed) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c FineTuningJobSucceeded) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Function) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c FunctionCall) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c FunctionCallOutput) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Grammar) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Group) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c GroupDeleted) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c GroupRole) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c GroupUser) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c GroupUserDeleted) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c HTTPError) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Image) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ImageEditCompleted) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ImageEditPartialImage) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ImageFile) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ImageGeneration) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ImageGenerationCall) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ImageGenerationCompleted) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ImageGenerationPartialImage) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ImageURL) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Inf) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Inline) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c InputAudio) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c InputAudioBufferAppend) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c InputAudioBufferClear) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c InputAudioBufferCleared) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c InputAudioBufferCommit) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c InputAudioBufferCommitted) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c InputAudioBufferDtmfEventReceived) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c InputAudioBufferSpeechStarted) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c InputAudioBufferSpeechStopped) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c InputAudioBufferTimeoutTriggered) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c InputFile) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c InputImage) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c InputText) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c JSONObject) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c JSONSchema) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Keypress) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c LabelModel) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c LastActiveAt) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c List) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Local) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c LocalShell) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c LocalShellCall) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c LocalShellCallOutput) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Locked) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Logs) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Mcp) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c McpApprovalRequest) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c McpApprovalResponse) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c McpCall) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c McpListTools) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c McpListToolsCompleted) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c McpListToolsFailed) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c McpListToolsInProgress) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Message) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c MessageCreation) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Model) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ModerationResult) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ModerationResults) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Move) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Multi) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c MultiAgentCall) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c MultiAgentCallOutput) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Namespace) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OpenPage) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationAdminAPIKey) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationAdminAPIKeyDeleted) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationCertificate) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationCertificateActivation) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationCertificateDeactivation) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationCostsResult) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationDataRetention) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationInvite) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationInviteDeleted) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationProject) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationProjectAPIKey) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationProjectAPIKeyDeleted) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationProjectCertificate) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationProjectCertificateActivation) MarshalJSON() ([]byte, error) {
+ return marshalString(c)
+}
+func (c OrganizationProjectCertificateDeactivation) MarshalJSON() ([]byte, error) {
+ return marshalString(c)
+}
+func (c OrganizationProjectServiceAccount) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationProjectServiceAccountAPIKey) MarshalJSON() ([]byte, error) {
+ return marshalString(c)
+}
+func (c OrganizationProjectServiceAccountDeleted) MarshalJSON() ([]byte, error) {
+ return marshalString(c)
+}
+func (c OrganizationProjectUser) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationProjectUserDeleted) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationSpendAlert) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationSpendAlertDeleted) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationUsageAudioSpeechesResult) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationUsageAudioTranscriptionsResult) MarshalJSON() ([]byte, error) {
+ return marshalString(c)
+}
+func (c OrganizationUsageCodeInterpreterSessionsResult) MarshalJSON() ([]byte, error) {
+ return marshalString(c)
+}
+func (c OrganizationUsageCompletionsResult) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationUsageEmbeddingsResult) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationUsageFileSearchesResult) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationUsageImagesResult) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationUsageModerationsResult) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationUsageVectorStoresResult) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationUsageWebSearchesResult) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationUser) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c OrganizationUserDeleted) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c Other) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c OutputAudio) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c OutputAudioBufferClear) MarshalJSON() ([]byte, error) { return marshalString(c) }
@@ -963,12 +1257,25 @@ func (c OutputAudioBufferCleared) MarshalJSON() ([]byte, error) { r
func (c OutputAudioBufferStarted) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c OutputAudioBufferStopped) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c OutputText) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Page) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Program) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ProgramOutput) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ProgrammaticToolCalling) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ProjectDataRetention) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ProjectGroup) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ProjectGroupDeleted) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ProjectModelPermissions) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ProjectModelPermissionsDeleted) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ProjectRateLimit) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ProjectSpendAlert) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ProjectSpendAlertDeleted) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c ProtocolError) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c Python) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c QuotedText) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c RateLimitsUpdated) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c Realtime) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c RealtimeCallIncoming) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c RealtimeSession) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c Reasoning) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c ReasoningText) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c Refusal) MarshalJSON() ([]byte, error) { return marshalString(c) }
@@ -1009,6 +1316,9 @@ func (c ResponseImageGenerationCallPartialImage) MarshalJSON() ([]byte, error) {
}
func (c ResponseInProgress) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c ResponseIncomplete) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ResponseInject) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ResponseInjectCreated) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c ResponseInjectFailed) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c ResponseInputTokens) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c ResponseMcpCallArgumentsDelta) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c ResponseMcpCallArgumentsDone) MarshalJSON() ([]byte, error) { return marshalString(c) }
@@ -1040,13 +1350,21 @@ func (c ResponseWebSearchCallCompleted) MarshalJSON() ([]byte, error) { retu
func (c ResponseWebSearchCallInProgress) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c ResponseWebSearchCallSearching) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c RetentionRatio) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Role) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c RoleDeleted) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c ScoreModel) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c Screenshot) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c Scroll) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c Search) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c SemanticVad) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c ServerVad) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c SessionClose) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c SessionClosed) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c SessionCreated) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c SessionInputAudioBufferAppend) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c SessionInputTranscriptDelta) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c SessionOutputAudioDelta) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c SessionOutputTranscriptDelta) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c SessionUpdate) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c SessionUpdated) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c Shell) MarshalJSON() ([]byte, error) { return marshalString(c) }
@@ -1109,6 +1427,7 @@ func (c TranscriptTextSegment) MarshalJSON() ([]byte, error) { retu
func (c Transcription) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c TranscriptionSessionUpdate) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c TranscriptionSessionUpdated) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c Translation) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c Type) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c UpdateFile) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c Upload) MarshalJSON() ([]byte, error) { return marshalString(c) }
@@ -1116,6 +1435,7 @@ func (c UploadPart) MarshalJSON() ([]byte, error) { retu
func (c URL) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c URLCitation) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c User) MarshalJSON() ([]byte, error) { return marshalString(c) }
+func (c UserRole) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c VectorStore) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c VectorStoreDeleted) MarshalJSON() ([]byte, error) { return marshalString(c) }
func (c VectorStoreFile) MarshalJSON() ([]byte, error) { return marshalString(c) }
diff --git a/vendor/github.com/openai/openai-go/v3/shared/shared.go b/vendor/github.com/openai/openai-go/v3/shared/shared.go
index a45ce9146..4f457cffb 100644
--- a/vendor/github.com/openai/openai-go/v3/shared/shared.go
+++ b/vendor/github.com/openai/openai-go/v3/shared/shared.go
@@ -42,6 +42,9 @@ type ResponsesModel = string
// aliased to make [param.APIObject] private when embedding
const (
+ ChatModelGPT5_6Sol ChatModel = "gpt-5.6-sol"
+ ChatModelGPT5_6Terra ChatModel = "gpt-5.6-terra"
+ ChatModelGPT5_6Luna ChatModel = "gpt-5.6-luna"
ChatModelGPT5_4 ChatModel = "gpt-5.4"
ChatModelGPT5_4Mini ChatModel = "gpt-5.4-mini"
ChatModelGPT5_4Nano ChatModel = "gpt-5.4-nano"
@@ -796,21 +799,23 @@ const (
// Configuration options for
// [reasoning models](https://platform.openai.com/docs/guides/reasoning).
type Reasoning struct {
- // Constrains effort on reasoning for
- // [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
- // supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`.
- // Reducing reasoning effort can result in faster responses and fewer tokens used
- // on reasoning in a response.
+ // 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`.
//
- // - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
- // reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
- // calls are supported for all reasoning values in gpt-5.1.
- // - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
- // support `none`.
- // - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
- // - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
+ // When returned on a response, this is the effective reasoning context mode used
+ // for the response.
//
- // Any of "none", "minimal", "low", "medium", "high", "xhigh".
+ // Any of "auto", "current_turn", "all_turns".
+ Context ReasoningContext `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 ReasoningEffort `json:"effort" api:"nullable"`
// **Deprecated:** use `summary` instead.
//
@@ -822,6 +827,10 @@ type Reasoning struct {
//
// Deprecated: deprecated
GenerateSummary ReasoningGenerateSummary `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 ReasoningMode `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`.
@@ -833,8 +842,10 @@ type Reasoning struct {
Summary ReasoningSummary `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
@@ -856,6 +867,20 @@ func (r Reasoning) ToParam() ReasoningParam {
return param.Override[ReasoningParam](json.RawMessage(r.RawJSON()))
}
+// 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.
+type ReasoningContext string
+
+const (
+ ReasoningContextAuto ReasoningContext = "auto"
+ ReasoningContextCurrentTurn ReasoningContext = "current_turn"
+ ReasoningContextAllTurns ReasoningContext = "all_turns"
+)
+
// **Deprecated:** use `summary` instead.
//
// A summary of the reasoning performed by the model. This can be useful for
@@ -869,6 +894,16 @@ const (
ReasoningGenerateSummaryDetailed ReasoningGenerateSummary = "detailed"
)
+// Controls the reasoning execution mode for the request.
+//
+// When returned on a response, this is the effective execution mode.
+type ReasoningMode string
+
+const (
+ ReasoningModeStandard ReasoningMode = "standard"
+ ReasoningModePro ReasoningMode = "pro"
+)
+
// 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`.
@@ -888,21 +923,23 @@ const (
// Configuration options for
// [reasoning models](https://platform.openai.com/docs/guides/reasoning).
type ReasoningParam struct {
- // Constrains effort on reasoning for
- // [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
- // supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`.
- // Reducing reasoning effort can result in faster responses and fewer tokens used
- // on reasoning in a response.
+ // 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`.
//
- // - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
- // reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
- // calls are supported for all reasoning values in gpt-5.1.
- // - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
- // support `none`.
- // - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
- // - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
+ // When returned on a response, this is the effective reasoning context mode used
+ // for the response.
//
- // Any of "none", "minimal", "low", "medium", "high", "xhigh".
+ // Any of "auto", "current_turn", "all_turns".
+ Context ReasoningContext `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 ReasoningEffort `json:"effort,omitzero"`
// **Deprecated:** use `summary` instead.
//
@@ -923,6 +960,10 @@ type ReasoningParam struct {
//
// Any of "auto", "concise", "detailed".
Summary ReasoningSummary `json:"summary,omitzero"`
+ // Controls the reasoning execution mode for the request.
+ //
+ // When returned on a response, this is the effective execution mode.
+ Mode ReasoningMode `json:"mode,omitzero"`
paramObj
}
@@ -934,19 +975,12 @@ func (r *ReasoningParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
-// Constrains effort on reasoning for
-// [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
-// supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`.
-// Reducing reasoning effort can result in faster responses and fewer tokens used
-// on reasoning in a response.
-//
-// - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
-// reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
-// calls are supported for all reasoning values in gpt-5.1.
-// - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
-// support `none`.
-// - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
-// - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
+// 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.
type ReasoningEffort string
const (
@@ -956,6 +990,7 @@ const (
ReasoningEffortMedium ReasoningEffort = "medium"
ReasoningEffortHigh ReasoningEffort = "high"
ReasoningEffortXhigh ReasoningEffort = "xhigh"
+ ReasoningEffortMax ReasoningEffort = "max"
)
// JSON object response format. An older method of generating JSON responses. Using
diff --git a/vendor/github.com/openai/openai-go/v3/skill.go b/vendor/github.com/openai/openai-go/v3/skill.go
index bdae55ba2..baf89b42a 100644
--- a/vendor/github.com/openai/openai-go/v3/skill.go
+++ b/vendor/github.com/openai/openai-go/v3/skill.go
@@ -6,7 +6,6 @@ import (
"bytes"
"context"
"errors"
- "fmt"
"io"
"mime/multipart"
"net/http"
@@ -49,7 +48,8 @@ func NewSkillService(opts ...option.RequestOption) (r SkillService) {
// Create a new skill.
func (r *SkillService) New(ctx context.Context, body SkillNewParams, opts ...option.RequestOption) (res *Skill, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "skills"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
@@ -57,24 +57,26 @@ func (r *SkillService) New(ctx context.Context, body SkillNewParams, opts ...opt
// Get a skill by its ID.
func (r *SkillService) Get(ctx context.Context, skillID string, opts ...option.RequestOption) (res *Skill, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if skillID == "" {
err = errors.New("missing required skill_id parameter")
return nil, err
}
- path := fmt.Sprintf("skills/%s", skillID)
+ path := requestconfig.FormatPath("skills/%s", skillID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
// Update the default version pointer for a skill.
func (r *SkillService) Update(ctx context.Context, skillID string, body SkillUpdateParams, opts ...option.RequestOption) (res *Skill, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if skillID == "" {
err = errors.New("missing required skill_id parameter")
return nil, err
}
- path := fmt.Sprintf("skills/%s", skillID)
+ path := requestconfig.FormatPath("skills/%s", skillID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
@@ -82,7 +84,8 @@ func (r *SkillService) Update(ctx context.Context, skillID string, body SkillUpd
// List all skills for the current project.
func (r *SkillService) List(ctx context.Context, query SkillListParams, opts ...option.RequestOption) (res *pagination.CursorPage[Skill], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "skills"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
@@ -104,12 +107,13 @@ func (r *SkillService) ListAutoPaging(ctx context.Context, query SkillListParams
// Delete a skill by its ID.
func (r *SkillService) Delete(ctx context.Context, skillID string, opts ...option.RequestOption) (res *DeletedSkill, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if skillID == "" {
err = errors.New("missing required skill_id parameter")
return nil, err
}
- path := fmt.Sprintf("skills/%s", skillID)
+ path := requestconfig.FormatPath("skills/%s", skillID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
return res, err
}
@@ -138,7 +142,7 @@ type Skill struct {
// Unique identifier for the skill.
ID string `json:"id" api:"required"`
// Unix timestamp (seconds) for when the skill was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Default version for the skill.
DefaultVersion string `json:"default_version" api:"required"`
// Description of the skill.
diff --git a/vendor/github.com/openai/openai-go/v3/skillcontent.go b/vendor/github.com/openai/openai-go/v3/skillcontent.go
index 16ec3339c..1bdbd2ef0 100644
--- a/vendor/github.com/openai/openai-go/v3/skillcontent.go
+++ b/vendor/github.com/openai/openai-go/v3/skillcontent.go
@@ -5,7 +5,6 @@ package openai
import (
"context"
"errors"
- "fmt"
"net/http"
"slices"
@@ -34,13 +33,14 @@ func NewSkillContentService(opts ...option.RequestOption) (r SkillContentService
// Download a skill zip bundle by its ID.
func (r *SkillContentService) Get(ctx context.Context, skillID string, opts ...option.RequestOption) (res *http.Response, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("Accept", "application/binary")}, opts...)
if skillID == "" {
err = errors.New("missing required skill_id parameter")
return nil, err
}
- path := fmt.Sprintf("skills/%s/content", skillID)
+ path := requestconfig.FormatPath("skills/%s/content", skillID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
diff --git a/vendor/github.com/openai/openai-go/v3/skillversion.go b/vendor/github.com/openai/openai-go/v3/skillversion.go
index c1ab5fb16..5c4ea6860 100644
--- a/vendor/github.com/openai/openai-go/v3/skillversion.go
+++ b/vendor/github.com/openai/openai-go/v3/skillversion.go
@@ -6,7 +6,6 @@ import (
"bytes"
"context"
"errors"
- "fmt"
"io"
"mime/multipart"
"net/http"
@@ -47,19 +46,21 @@ func NewSkillVersionService(opts ...option.RequestOption) (r SkillVersionService
// Create a new immutable skill version.
func (r *SkillVersionService) New(ctx context.Context, skillID string, body SkillVersionNewParams, opts ...option.RequestOption) (res *SkillVersion, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if skillID == "" {
err = errors.New("missing required skill_id parameter")
return nil, err
}
- path := fmt.Sprintf("skills/%s/versions", skillID)
+ path := requestconfig.FormatPath("skills/%s/versions", skillID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
// Get a specific skill version.
func (r *SkillVersionService) Get(ctx context.Context, skillID string, version string, opts ...option.RequestOption) (res *SkillVersion, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if skillID == "" {
err = errors.New("missing required skill_id parameter")
return nil, err
@@ -68,7 +69,7 @@ func (r *SkillVersionService) Get(ctx context.Context, skillID string, version s
err = errors.New("missing required version parameter")
return nil, err
}
- path := fmt.Sprintf("skills/%s/versions/%s", skillID, version)
+ path := requestconfig.FormatPath("skills/%s/versions/%s", skillID, version)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
@@ -76,13 +77,14 @@ func (r *SkillVersionService) Get(ctx context.Context, skillID string, version s
// List skill versions for a skill.
func (r *SkillVersionService) List(ctx context.Context, skillID string, query SkillVersionListParams, opts ...option.RequestOption) (res *pagination.CursorPage[SkillVersion], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
if skillID == "" {
err = errors.New("missing required skill_id parameter")
return nil, err
}
- path := fmt.Sprintf("skills/%s/versions", skillID)
+ path := requestconfig.FormatPath("skills/%s/versions", skillID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
return nil, err
@@ -102,7 +104,8 @@ func (r *SkillVersionService) ListAutoPaging(ctx context.Context, skillID string
// Delete a skill version.
func (r *SkillVersionService) Delete(ctx context.Context, skillID string, version string, opts ...option.RequestOption) (res *DeletedSkillVersion, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if skillID == "" {
err = errors.New("missing required skill_id parameter")
return nil, err
@@ -111,7 +114,7 @@ func (r *SkillVersionService) Delete(ctx context.Context, skillID string, versio
err = errors.New("missing required version parameter")
return nil, err
}
- path := fmt.Sprintf("skills/%s/versions/%s", skillID, version)
+ path := requestconfig.FormatPath("skills/%s/versions/%s", skillID, version)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
return res, err
}
@@ -143,7 +146,7 @@ type SkillVersion struct {
// Unique identifier for the skill version.
ID string `json:"id" api:"required"`
// Unix timestamp (seconds) for when the version was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Description of the skill version.
Description string `json:"description" api:"required"`
// Name of the skill version.
diff --git a/vendor/github.com/openai/openai-go/v3/skillversioncontent.go b/vendor/github.com/openai/openai-go/v3/skillversioncontent.go
index 56d1be7a1..e6a399c04 100644
--- a/vendor/github.com/openai/openai-go/v3/skillversioncontent.go
+++ b/vendor/github.com/openai/openai-go/v3/skillversioncontent.go
@@ -5,7 +5,6 @@ package openai
import (
"context"
"errors"
- "fmt"
"net/http"
"slices"
@@ -34,7 +33,8 @@ func NewSkillVersionContentService(opts ...option.RequestOption) (r SkillVersion
// Download a skill version zip bundle.
func (r *SkillVersionContentService) Get(ctx context.Context, skillID string, version string, opts ...option.RequestOption) (res *http.Response, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("Accept", "application/binary")}, opts...)
if skillID == "" {
err = errors.New("missing required skill_id parameter")
@@ -44,7 +44,7 @@ func (r *SkillVersionContentService) Get(ctx context.Context, skillID string, ve
err = errors.New("missing required version parameter")
return nil, err
}
- path := fmt.Sprintf("skills/%s/versions/%s/content", skillID, version)
+ path := requestconfig.FormatPath("skills/%s/versions/%s/content", skillID, version)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
diff --git a/vendor/github.com/openai/openai-go/v3/upload.go b/vendor/github.com/openai/openai-go/v3/upload.go
index dcb7a6606..6120d3912 100644
--- a/vendor/github.com/openai/openai-go/v3/upload.go
+++ b/vendor/github.com/openai/openai-go/v3/upload.go
@@ -5,7 +5,6 @@ package openai
import (
"context"
"errors"
- "fmt"
"net/http"
"slices"
@@ -63,7 +62,8 @@ func NewUploadService(opts ...option.RequestOption) (r UploadService) {
//
// Returns the Upload object with status `pending`.
func (r *UploadService) New(ctx context.Context, body UploadNewParams, opts ...option.RequestOption) (res *Upload, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "uploads"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
@@ -73,12 +73,13 @@ func (r *UploadService) New(ctx context.Context, body UploadNewParams, opts ...o
//
// Returns the Upload object with status `cancelled`.
func (r *UploadService) Cancel(ctx context.Context, uploadID string, opts ...option.RequestOption) (res *Upload, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if uploadID == "" {
err = errors.New("missing required upload_id parameter")
return nil, err
}
- path := fmt.Sprintf("uploads/%s/cancel", uploadID)
+ path := requestconfig.FormatPath("uploads/%s/cancel", uploadID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
return res, err
}
@@ -99,12 +100,13 @@ func (r *UploadService) Cancel(ctx context.Context, uploadID string, opts ...opt
// including an additional `file` property containing the created usable File
// object.
func (r *UploadService) Complete(ctx context.Context, uploadID string, body UploadCompleteParams, opts ...option.RequestOption) (res *Upload, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if uploadID == "" {
err = errors.New("missing required upload_id parameter")
return nil, err
}
- path := fmt.Sprintf("uploads/%s/complete", uploadID)
+ path := requestconfig.FormatPath("uploads/%s/complete", uploadID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
@@ -116,9 +118,9 @@ type Upload struct {
// The intended number of bytes to be uploaded.
Bytes int64 `json:"bytes" api:"required"`
// The Unix timestamp (in seconds) for when the Upload was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// The Unix timestamp (in seconds) for when the Upload will expire.
- ExpiresAt int64 `json:"expires_at" api:"required"`
+ ExpiresAt int64 `json:"expires_at" api:"required" format:"unixtime"`
// The name of the file to be uploaded.
Filename string `json:"filename" api:"required"`
// The object type, which is always "upload".
diff --git a/vendor/github.com/openai/openai-go/v3/uploadpart.go b/vendor/github.com/openai/openai-go/v3/uploadpart.go
index 86a3eca41..4c1369762 100644
--- a/vendor/github.com/openai/openai-go/v3/uploadpart.go
+++ b/vendor/github.com/openai/openai-go/v3/uploadpart.go
@@ -6,7 +6,6 @@ import (
"bytes"
"context"
"errors"
- "fmt"
"io"
"mime/multipart"
"net/http"
@@ -53,12 +52,13 @@ func NewUploadPartService(opts ...option.RequestOption) (r UploadPartService) {
// order of the Parts when you
// [complete the Upload](https://platform.openai.com/docs/api-reference/uploads/complete).
func (r *UploadPartService) New(ctx context.Context, uploadID string, body UploadPartNewParams, opts ...option.RequestOption) (res *UploadPart, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if uploadID == "" {
err = errors.New("missing required upload_id parameter")
return nil, err
}
- path := fmt.Sprintf("uploads/%s/parts", uploadID)
+ path := requestconfig.FormatPath("uploads/%s/parts", uploadID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
@@ -68,7 +68,7 @@ type UploadPart struct {
// The upload Part unique identifier, which can be referenced in API endpoints.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) for when the Part was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// The object type, which is always `upload.part`.
Object constant.UploadPart `json:"object" default:"upload.part"`
// The ID of the Upload object that this Part was added to.
diff --git a/vendor/github.com/openai/openai-go/v3/vectorstore.go b/vendor/github.com/openai/openai-go/v3/vectorstore.go
index 78646c12a..6c356b2b3 100644
--- a/vendor/github.com/openai/openai-go/v3/vectorstore.go
+++ b/vendor/github.com/openai/openai-go/v3/vectorstore.go
@@ -6,7 +6,6 @@ import (
"context"
"encoding/json"
"errors"
- "fmt"
"net/http"
"net/url"
"slices"
@@ -47,7 +46,8 @@ func NewVectorStoreService(opts ...option.RequestOption) (r VectorStoreService)
// Create a vector store.
func (r *VectorStoreService) New(ctx context.Context, body VectorStoreNewParams, opts ...option.RequestOption) (res *VectorStore, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
path := "vector_stores"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
@@ -56,26 +56,28 @@ func (r *VectorStoreService) New(ctx context.Context, body VectorStoreNewParams,
// Retrieves a vector store.
func (r *VectorStoreService) Get(ctx context.Context, vectorStoreID string, opts ...option.RequestOption) (res *VectorStore, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if vectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
return nil, err
}
- path := fmt.Sprintf("vector_stores/%s", vectorStoreID)
+ path := requestconfig.FormatPath("vector_stores/%s", vectorStoreID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
// Modifies a vector store.
func (r *VectorStoreService) Update(ctx context.Context, vectorStoreID string, body VectorStoreUpdateParams, opts ...option.RequestOption) (res *VectorStore, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if vectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
return nil, err
}
- path := fmt.Sprintf("vector_stores/%s", vectorStoreID)
+ path := requestconfig.FormatPath("vector_stores/%s", vectorStoreID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
@@ -83,7 +85,8 @@ func (r *VectorStoreService) Update(ctx context.Context, vectorStoreID string, b
// Returns a list of vector stores.
func (r *VectorStoreService) List(ctx context.Context, query VectorStoreListParams, opts ...option.RequestOption) (res *pagination.CursorPage[VectorStore], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2"), option.WithResponseInto(&raw)}, opts...)
path := "vector_stores"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
@@ -105,13 +108,14 @@ func (r *VectorStoreService) ListAutoPaging(ctx context.Context, query VectorSto
// Delete a vector store.
func (r *VectorStoreService) Delete(ctx context.Context, vectorStoreID string, opts ...option.RequestOption) (res *VectorStoreDeleted, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if vectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
return nil, err
}
- path := fmt.Sprintf("vector_stores/%s", vectorStoreID)
+ path := requestconfig.FormatPath("vector_stores/%s", vectorStoreID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
return res, err
}
@@ -120,13 +124,14 @@ func (r *VectorStoreService) Delete(ctx context.Context, vectorStoreID string, o
// filter.
func (r *VectorStoreService) Search(ctx context.Context, vectorStoreID string, body VectorStoreSearchParams, opts ...option.RequestOption) (res *pagination.Page[VectorStoreSearchResponse], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2"), option.WithResponseInto(&raw)}, opts...)
if vectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
return nil, err
}
- path := fmt.Sprintf("vector_stores/%s/search", vectorStoreID)
+ path := requestconfig.FormatPath("vector_stores/%s/search", vectorStoreID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, body, &res, opts...)
if err != nil {
return nil, err
@@ -408,10 +413,10 @@ type VectorStore struct {
// The identifier, which can be referenced in API endpoints.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) for when the vector store was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
FileCounts VectorStoreFileCounts `json:"file_counts" api:"required"`
// The Unix timestamp (in seconds) for when the vector store was last active.
- LastActiveAt int64 `json:"last_active_at" api:"required"`
+ LastActiveAt int64 `json:"last_active_at" api:"required" format:"unixtime"`
// 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.
@@ -434,7 +439,7 @@ type VectorStore struct {
// The expiration policy for a vector store.
ExpiresAfter VectorStoreExpiresAfter `json:"expires_after"`
// The Unix timestamp (in seconds) for when the vector store will expire.
- ExpiresAt int64 `json:"expires_at" api:"nullable"`
+ ExpiresAt int64 `json:"expires_at" api:"nullable" format:"unixtime"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
diff --git a/vendor/github.com/openai/openai-go/v3/vectorstorefile.go b/vendor/github.com/openai/openai-go/v3/vectorstorefile.go
index 1c7389090..17d002452 100644
--- a/vendor/github.com/openai/openai-go/v3/vectorstorefile.go
+++ b/vendor/github.com/openai/openai-go/v3/vectorstorefile.go
@@ -6,7 +6,6 @@ import (
"context"
"encoding/json"
"errors"
- "fmt"
"net/http"
"net/url"
"slices"
@@ -44,13 +43,14 @@ func NewVectorStoreFileService(opts ...option.RequestOption) (r VectorStoreFileS
// [File](https://platform.openai.com/docs/api-reference/files) to a
// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object).
func (r *VectorStoreFileService) New(ctx context.Context, vectorStoreID string, body VectorStoreFileNewParams, opts ...option.RequestOption) (res *VectorStoreFile, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if vectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
return nil, err
}
- path := fmt.Sprintf("vector_stores/%s/files", vectorStoreID)
+ path := requestconfig.FormatPath("vector_stores/%s/files", vectorStoreID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
@@ -96,7 +96,8 @@ func (r *VectorStoreFileService) UploadAndPoll(ctx context.Context, vectorStoreI
// Retrieves a vector store file.
func (r *VectorStoreFileService) Get(ctx context.Context, vectorStoreID string, fileID string, opts ...option.RequestOption) (res *VectorStoreFile, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if vectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
@@ -106,14 +107,15 @@ func (r *VectorStoreFileService) Get(ctx context.Context, vectorStoreID string,
err = errors.New("missing required file_id parameter")
return nil, err
}
- path := fmt.Sprintf("vector_stores/%s/files/%s", vectorStoreID, fileID)
+ path := requestconfig.FormatPath("vector_stores/%s/files/%s", vectorStoreID, fileID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
// Update attributes on a vector store file.
func (r *VectorStoreFileService) Update(ctx context.Context, vectorStoreID string, fileID string, body VectorStoreFileUpdateParams, opts ...option.RequestOption) (res *VectorStoreFile, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if vectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
@@ -123,7 +125,7 @@ func (r *VectorStoreFileService) Update(ctx context.Context, vectorStoreID strin
err = errors.New("missing required file_id parameter")
return nil, err
}
- path := fmt.Sprintf("vector_stores/%s/files/%s", vectorStoreID, fileID)
+ path := requestconfig.FormatPath("vector_stores/%s/files/%s", vectorStoreID, fileID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
@@ -131,13 +133,14 @@ func (r *VectorStoreFileService) Update(ctx context.Context, vectorStoreID strin
// Returns a list of vector store files.
func (r *VectorStoreFileService) List(ctx context.Context, vectorStoreID string, query VectorStoreFileListParams, opts ...option.RequestOption) (res *pagination.CursorPage[VectorStoreFile], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2"), option.WithResponseInto(&raw)}, opts...)
if vectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
return nil, err
}
- path := fmt.Sprintf("vector_stores/%s/files", vectorStoreID)
+ path := requestconfig.FormatPath("vector_stores/%s/files", vectorStoreID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
return nil, err
@@ -160,7 +163,8 @@ func (r *VectorStoreFileService) ListAutoPaging(ctx context.Context, vectorStore
// [delete file](https://platform.openai.com/docs/api-reference/files/delete)
// endpoint.
func (r *VectorStoreFileService) Delete(ctx context.Context, vectorStoreID string, fileID string, opts ...option.RequestOption) (res *VectorStoreFileDeleted, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if vectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
@@ -170,7 +174,7 @@ func (r *VectorStoreFileService) Delete(ctx context.Context, vectorStoreID strin
err = errors.New("missing required file_id parameter")
return nil, err
}
- path := fmt.Sprintf("vector_stores/%s/files/%s", vectorStoreID, fileID)
+ path := requestconfig.FormatPath("vector_stores/%s/files/%s", vectorStoreID, fileID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
return res, err
}
@@ -178,7 +182,8 @@ func (r *VectorStoreFileService) Delete(ctx context.Context, vectorStoreID strin
// Retrieve the parsed contents of a vector store file.
func (r *VectorStoreFileService) Content(ctx context.Context, vectorStoreID string, fileID string, opts ...option.RequestOption) (res *pagination.Page[VectorStoreFileContentResponse], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2"), option.WithResponseInto(&raw)}, opts...)
if vectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
@@ -188,7 +193,7 @@ func (r *VectorStoreFileService) Content(ctx context.Context, vectorStoreID stri
err = errors.New("missing required file_id parameter")
return nil, err
}
- path := fmt.Sprintf("vector_stores/%s/files/%s/content", vectorStoreID, fileID)
+ path := requestconfig.FormatPath("vector_stores/%s/files/%s/content", vectorStoreID, fileID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, nil, &res, opts...)
if err != nil {
return nil, err
@@ -211,7 +216,7 @@ type VectorStoreFile struct {
// The identifier, which can be referenced in API endpoints.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) for when the vector store file was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// The last error associated with this vector store file. Will be `null` if there
// are no errors.
LastError VectorStoreFileLastError `json:"last_error" api:"required"`
diff --git a/vendor/github.com/openai/openai-go/v3/vectorstorefilebatch.go b/vendor/github.com/openai/openai-go/v3/vectorstorefilebatch.go
index 6828de9ae..874d669d6 100644
--- a/vendor/github.com/openai/openai-go/v3/vectorstorefilebatch.go
+++ b/vendor/github.com/openai/openai-go/v3/vectorstorefilebatch.go
@@ -5,7 +5,6 @@ package openai
import (
"context"
"errors"
- "fmt"
"net/http"
"net/url"
"slices"
@@ -42,13 +41,14 @@ func NewVectorStoreFileBatchService(opts ...option.RequestOption) (r VectorStore
// Create a vector store file batch.
func (r *VectorStoreFileBatchService) New(ctx context.Context, vectorStoreID string, body VectorStoreFileBatchNewParams, opts ...option.RequestOption) (res *VectorStoreFileBatch, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if vectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
return nil, err
}
- path := fmt.Sprintf("vector_stores/%s/file_batches", vectorStoreID)
+ path := requestconfig.FormatPath("vector_stores/%s/file_batches", vectorStoreID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
@@ -114,7 +114,8 @@ func (r *VectorStoreFileBatchService) UploadAndPoll(ctx context.Context, vectorS
// Retrieves a vector store file batch.
func (r *VectorStoreFileBatchService) Get(ctx context.Context, vectorStoreID string, batchID string, opts ...option.RequestOption) (res *VectorStoreFileBatch, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if vectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
@@ -124,7 +125,7 @@ func (r *VectorStoreFileBatchService) Get(ctx context.Context, vectorStoreID str
err = errors.New("missing required batch_id parameter")
return nil, err
}
- path := fmt.Sprintf("vector_stores/%s/file_batches/%s", vectorStoreID, batchID)
+ path := requestconfig.FormatPath("vector_stores/%s/file_batches/%s", vectorStoreID, batchID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
@@ -132,7 +133,8 @@ func (r *VectorStoreFileBatchService) Get(ctx context.Context, vectorStoreID str
// Cancel a vector store file batch. This attempts to cancel the processing of
// files in this batch as soon as possible.
func (r *VectorStoreFileBatchService) Cancel(ctx context.Context, vectorStoreID string, batchID string, opts ...option.RequestOption) (res *VectorStoreFileBatch, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if vectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
@@ -142,7 +144,7 @@ func (r *VectorStoreFileBatchService) Cancel(ctx context.Context, vectorStoreID
err = errors.New("missing required batch_id parameter")
return nil, err
}
- path := fmt.Sprintf("vector_stores/%s/file_batches/%s/cancel", vectorStoreID, batchID)
+ path := requestconfig.FormatPath("vector_stores/%s/file_batches/%s/cancel", vectorStoreID, batchID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
return res, err
}
@@ -150,7 +152,8 @@ func (r *VectorStoreFileBatchService) Cancel(ctx context.Context, vectorStoreID
// Returns a list of vector store files in a batch.
func (r *VectorStoreFileBatchService) ListFiles(ctx context.Context, vectorStoreID string, batchID string, query VectorStoreFileBatchListFilesParams, opts ...option.RequestOption) (res *pagination.CursorPage[VectorStoreFile], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2"), option.WithResponseInto(&raw)}, opts...)
if vectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
@@ -160,7 +163,7 @@ func (r *VectorStoreFileBatchService) ListFiles(ctx context.Context, vectorStore
err = errors.New("missing required batch_id parameter")
return nil, err
}
- path := fmt.Sprintf("vector_stores/%s/file_batches/%s/files", vectorStoreID, batchID)
+ path := requestconfig.FormatPath("vector_stores/%s/file_batches/%s/files", vectorStoreID, batchID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
return nil, err
@@ -184,7 +187,7 @@ type VectorStoreFileBatch struct {
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) for when the vector store files batch was
// created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
FileCounts VectorStoreFileBatchFileCounts `json:"file_counts" api:"required"`
// The object type, which is always `vector_store.file_batch`.
Object constant.VectorStoreFilesBatch `json:"object" default:"vector_store.files_batch"`
diff --git a/vendor/github.com/openai/openai-go/v3/video.go b/vendor/github.com/openai/openai-go/v3/video.go
index a1b4345b7..7a0df6000 100644
--- a/vendor/github.com/openai/openai-go/v3/video.go
+++ b/vendor/github.com/openai/openai-go/v3/video.go
@@ -6,7 +6,6 @@ import (
"bytes"
"context"
"errors"
- "fmt"
"io"
"mime/multipart"
"net/http"
@@ -45,7 +44,8 @@ func NewVideoService(opts ...option.RequestOption) (r VideoService) {
// Create a new video generation job from a prompt and optional reference assets.
func (r *VideoService) New(ctx context.Context, body VideoNewParams, opts ...option.RequestOption) (res *Video, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "videos"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
@@ -65,12 +65,13 @@ func (r *VideoService) NewAndPoll(ctx context.Context, body VideoNewParams, poll
// Fetch the latest metadata for a generated video.
func (r *VideoService) Get(ctx context.Context, videoID string, opts ...option.RequestOption) (res *Video, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if videoID == "" {
err = errors.New("missing required video_id parameter")
return nil, err
}
- path := fmt.Sprintf("videos/%s", videoID)
+ path := requestconfig.FormatPath("videos/%s", videoID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
@@ -78,7 +79,8 @@ func (r *VideoService) Get(ctx context.Context, videoID string, opts ...option.R
// List recently generated videos for the current project.
func (r *VideoService) List(ctx context.Context, query VideoListParams, opts ...option.RequestOption) (res *pagination.ConversationCursorPage[Video], err error) {
var raw *http.Response
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "videos"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
@@ -100,19 +102,21 @@ func (r *VideoService) ListAutoPaging(ctx context.Context, query VideoListParams
// Permanently delete a completed or failed video and its stored assets.
func (r *VideoService) Delete(ctx context.Context, videoID string, opts ...option.RequestOption) (res *VideoDeleteResponse, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if videoID == "" {
err = errors.New("missing required video_id parameter")
return nil, err
}
- path := fmt.Sprintf("videos/%s", videoID)
+ path := requestconfig.FormatPath("videos/%s", videoID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
return res, err
}
// Create a character from an uploaded video.
func (r *VideoService) NewCharacter(ctx context.Context, body VideoNewCharacterParams, opts ...option.RequestOption) (res *VideoNewCharacterResponse, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "videos/characters"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
@@ -122,13 +126,14 @@ func (r *VideoService) NewCharacter(ctx context.Context, body VideoNewCharacterP
//
// Streams the rendered video content for the specified video job.
func (r *VideoService) DownloadContent(ctx context.Context, videoID string, query VideoDownloadContentParams, opts ...option.RequestOption) (res *http.Response, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("Accept", "application/binary")}, opts...)
if videoID == "" {
err = errors.New("missing required video_id parameter")
return nil, err
}
- path := fmt.Sprintf("videos/%s/content", videoID)
+ path := requestconfig.FormatPath("videos/%s/content", videoID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
return res, err
}
@@ -136,7 +141,8 @@ func (r *VideoService) DownloadContent(ctx context.Context, videoID string, quer
// Create a new video generation job by editing a source video or existing
// generated video.
func (r *VideoService) Edit(ctx context.Context, body VideoEditParams, opts ...option.RequestOption) (res *Video, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "videos/edits"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
@@ -144,7 +150,8 @@ func (r *VideoService) Edit(ctx context.Context, body VideoEditParams, opts ...o
// Create an extension of a completed video.
func (r *VideoService) Extend(ctx context.Context, body VideoExtendParams, opts ...option.RequestOption) (res *Video, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
path := "videos/extensions"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
@@ -152,24 +159,26 @@ func (r *VideoService) Extend(ctx context.Context, body VideoExtendParams, opts
// Fetch a character.
func (r *VideoService) GetCharacter(ctx context.Context, characterID string, opts ...option.RequestOption) (res *VideoGetCharacterResponse, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if characterID == "" {
err = errors.New("missing required character_id parameter")
return nil, err
}
- path := fmt.Sprintf("videos/characters/%s", characterID)
+ path := requestconfig.FormatPath("videos/characters/%s", characterID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
// Create a remix of a completed video using a refreshed prompt.
func (r *VideoService) Remix(ctx context.Context, videoID string, body VideoRemixParams, opts ...option.RequestOption) (res *Video, err error) {
- opts = slices.Concat(r.Options, opts)
+ var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}
+ opts = slices.Concat(preClientOpts, r.Options, opts)
if videoID == "" {
err = errors.New("missing required video_id parameter")
return nil, err
}
- path := fmt.Sprintf("videos/%s/remix", videoID)
+ path := requestconfig.FormatPath("videos/%s/remix", videoID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
@@ -177,7 +186,7 @@ func (r *VideoService) Remix(ctx context.Context, videoID string, body VideoRemi
type ImageInputReferenceParam struct {
FileID param.Opt[string] `json:"file_id,omitzero"`
// A fully qualified URL or base64-encoded data URL.
- ImageURL param.Opt[string] `json:"image_url,omitzero"`
+ ImageURL param.Opt[string] `json:"image_url,omitzero" format:"uri"`
paramObj
}
@@ -194,13 +203,13 @@ type Video struct {
// Unique identifier for the video job.
ID string `json:"id" api:"required"`
// Unix timestamp (seconds) for when the job completed, if finished.
- CompletedAt int64 `json:"completed_at" api:"required"`
+ CompletedAt int64 `json:"completed_at" api:"required" format:"unixtime"`
// Unix timestamp (seconds) for when the job was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Error payload that explains why generation failed, if applicable.
Error VideoCreateError `json:"error" api:"required"`
// Unix timestamp (seconds) for when the downloadable assets expire, if set.
- ExpiresAt int64 `json:"expires_at" api:"required"`
+ ExpiresAt int64 `json:"expires_at" api:"required" format:"unixtime"`
// The video generation model that produced the job.
Model VideoModel `json:"model" api:"required"`
// The object type, which is always `video`.
@@ -334,7 +343,7 @@ type VideoNewCharacterResponse struct {
// Identifier for the character creation cameo.
ID string `json:"id" api:"required"`
// Unix timestamp (in seconds) when the character was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Display name for the character.
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
@@ -357,7 +366,7 @@ type VideoGetCharacterResponse struct {
// Identifier for the character creation cameo.
ID string `json:"id" api:"required"`
// Unix timestamp (in seconds) when the character was created.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Display name for the character.
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
@@ -572,7 +581,7 @@ func (u *VideoEditParamsVideoUnion) asAny() any {
return nil
}
-// Reference to the completed video.
+// Reference to the completed video to edit.
//
// The property ID is required.
type VideoEditParamsVideoVideoReferenceInputParam struct {
diff --git a/vendor/github.com/openai/openai-go/v3/webhooks/aliases.go b/vendor/github.com/openai/openai-go/v3/webhooks/aliases.go
index 037b8545c..5bf4ccba6 100644
--- a/vendor/github.com/openai/openai-go/v3/webhooks/aliases.go
+++ b/vendor/github.com/openai/openai-go/v3/webhooks/aliases.go
@@ -64,6 +64,15 @@ const AllModelsGPT5_1CodexMax = shared.AllModelsGPT5_1CodexMax
// This is an alias to an internal type.
type ChatModel = shared.ChatModel
+// Equals "gpt-5.6-sol"
+const ChatModelGPT5_6Sol = shared.ChatModelGPT5_6Sol
+
+// Equals "gpt-5.6-terra"
+const ChatModelGPT5_6Terra = shared.ChatModelGPT5_6Terra
+
+// Equals "gpt-5.6-luna"
+const ChatModelGPT5_6Luna = shared.ChatModelGPT5_6Luna
+
// Equals "gpt-5.4"
const ChatModelGPT5_4 = shared.ChatModelGPT5_4
@@ -465,6 +474,25 @@ const OAuthErrorCodeInvalidSubjectToken = shared.OAuthErrorCodeInvalidSubjectTok
// This is an alias to an internal type.
type Reasoning = shared.Reasoning
+// 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.
+//
+// This is an alias to an internal type.
+type ReasoningContext = shared.ReasoningContext
+
+// Equals "auto"
+const ReasoningContextAuto = shared.ReasoningContextAuto
+
+// Equals "current_turn"
+const ReasoningContextCurrentTurn = shared.ReasoningContextCurrentTurn
+
+// Equals "all_turns"
+const ReasoningContextAllTurns = shared.ReasoningContextAllTurns
+
// **Deprecated:** use `summary` instead.
//
// A summary of the reasoning performed by the model. This can be useful for
@@ -483,6 +511,19 @@ const ReasoningGenerateSummaryConcise = shared.ReasoningGenerateSummaryConcise
// Equals "detailed"
const ReasoningGenerateSummaryDetailed = shared.ReasoningGenerateSummaryDetailed
+// Controls the reasoning execution mode for the request.
+//
+// When returned on a response, this is the effective execution mode.
+//
+// This is an alias to an internal type.
+type ReasoningMode = shared.ReasoningMode
+
+// Equals "standard"
+const ReasoningModeStandard = shared.ReasoningModeStandard
+
+// Equals "pro"
+const ReasoningModePro = shared.ReasoningModePro
+
// 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`.
@@ -510,19 +551,12 @@ const ReasoningSummaryDetailed = shared.ReasoningSummaryDetailed
// This is an alias to an internal type.
type ReasoningParam = shared.ReasoningParam
-// Constrains effort on reasoning for
-// [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
-// supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`.
-// Reducing reasoning effort can result in faster responses and fewer tokens used
-// on reasoning in a response.
-//
-// - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
-// reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
-// calls are supported for all reasoning values in gpt-5.1.
-// - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
-// support `none`.
-// - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
-// - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
+// 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.
//
// This is an alias to an internal type.
type ReasoningEffort = shared.ReasoningEffort
@@ -545,6 +579,9 @@ const ReasoningEffortHigh = shared.ReasoningEffortHigh
// Equals "xhigh"
const ReasoningEffortXhigh = shared.ReasoningEffortXhigh
+// Equals "max"
+const ReasoningEffortMax = shared.ReasoningEffortMax
+
// 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.
diff --git a/vendor/github.com/openai/openai-go/v3/webhooks/webhook.go b/vendor/github.com/openai/openai-go/v3/webhooks/webhook.go
index 7bde9cbcb..0a0c48764 100644
--- a/vendor/github.com/openai/openai-go/v3/webhooks/webhook.go
+++ b/vendor/github.com/openai/openai-go/v3/webhooks/webhook.go
@@ -202,7 +202,7 @@ type BatchCancelledWebhookEvent struct {
// The unique ID of the event.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) of when the batch API request was cancelled.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Event data payload.
Data BatchCancelledWebhookEventData `json:"data" api:"required"`
// The type of the event. Always `batch.cancelled`.
@@ -259,7 +259,7 @@ type BatchCompletedWebhookEvent struct {
// The unique ID of the event.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) of when the batch API request was completed.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Event data payload.
Data BatchCompletedWebhookEventData `json:"data" api:"required"`
// The type of the event. Always `batch.completed`.
@@ -316,7 +316,7 @@ type BatchExpiredWebhookEvent struct {
// The unique ID of the event.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) of when the batch API request expired.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Event data payload.
Data BatchExpiredWebhookEventData `json:"data" api:"required"`
// The type of the event. Always `batch.expired`.
@@ -373,7 +373,7 @@ type BatchFailedWebhookEvent struct {
// The unique ID of the event.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) of when the batch API request failed.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Event data payload.
Data BatchFailedWebhookEventData `json:"data" api:"required"`
// The type of the event. Always `batch.failed`.
@@ -430,7 +430,7 @@ type EvalRunCanceledWebhookEvent struct {
// The unique ID of the event.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) of when the eval run was canceled.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Event data payload.
Data EvalRunCanceledWebhookEventData `json:"data" api:"required"`
// The type of the event. Always `eval.run.canceled`.
@@ -487,7 +487,7 @@ type EvalRunFailedWebhookEvent struct {
// The unique ID of the event.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) of when the eval run failed.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Event data payload.
Data EvalRunFailedWebhookEventData `json:"data" api:"required"`
// The type of the event. Always `eval.run.failed`.
@@ -544,7 +544,7 @@ type EvalRunSucceededWebhookEvent struct {
// The unique ID of the event.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) of when the eval run succeeded.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Event data payload.
Data EvalRunSucceededWebhookEventData `json:"data" api:"required"`
// The type of the event. Always `eval.run.succeeded`.
@@ -601,7 +601,7 @@ type FineTuningJobCancelledWebhookEvent struct {
// The unique ID of the event.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) of when the fine-tuning job was cancelled.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Event data payload.
Data FineTuningJobCancelledWebhookEventData `json:"data" api:"required"`
// The type of the event. Always `fine_tuning.job.cancelled`.
@@ -658,7 +658,7 @@ type FineTuningJobFailedWebhookEvent struct {
// The unique ID of the event.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) of when the fine-tuning job failed.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Event data payload.
Data FineTuningJobFailedWebhookEventData `json:"data" api:"required"`
// The type of the event. Always `fine_tuning.job.failed`.
@@ -715,7 +715,7 @@ type FineTuningJobSucceededWebhookEvent struct {
// The unique ID of the event.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) of when the fine-tuning job succeeded.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Event data payload.
Data FineTuningJobSucceededWebhookEventData `json:"data" api:"required"`
// The type of the event. Always `fine_tuning.job.succeeded`.
@@ -772,7 +772,7 @@ type RealtimeCallIncomingWebhookEvent struct {
// The unique ID of the event.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) of when the model response was completed.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Event data payload.
Data RealtimeCallIncomingWebhookEventData `json:"data" api:"required"`
// The type of the event. Always `realtime.call.incoming`.
@@ -853,7 +853,7 @@ type ResponseCancelledWebhookEvent struct {
// The unique ID of the event.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) of when the model response was cancelled.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Event data payload.
Data ResponseCancelledWebhookEventData `json:"data" api:"required"`
// The type of the event. Always `response.cancelled`.
@@ -910,7 +910,7 @@ type ResponseCompletedWebhookEvent struct {
// The unique ID of the event.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) of when the model response was completed.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Event data payload.
Data ResponseCompletedWebhookEventData `json:"data" api:"required"`
// The type of the event. Always `response.completed`.
@@ -967,7 +967,7 @@ type ResponseFailedWebhookEvent struct {
// The unique ID of the event.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) of when the model response failed.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Event data payload.
Data ResponseFailedWebhookEventData `json:"data" api:"required"`
// The type of the event. Always `response.failed`.
@@ -1024,7 +1024,7 @@ type ResponseIncompleteWebhookEvent struct {
// The unique ID of the event.
ID string `json:"id" api:"required"`
// The Unix timestamp (in seconds) of when the model response was interrupted.
- CreatedAt int64 `json:"created_at" api:"required"`
+ CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Event data payload.
Data ResponseIncompleteWebhookEventData `json:"data" api:"required"`
// The type of the event. Always `response.incomplete`.
diff --git a/vendor/github.com/pb33f/libopenapi-validator/README.md b/vendor/github.com/pb33f/libopenapi-validator/README.md
index f2c200504..cf758339f 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/README.md
+++ b/vendor/github.com/pb33f/libopenapi-validator/README.md
@@ -9,7 +9,9 @@
[](https://discord.gg/x7VACVuEGP)
[](https://pkg.go.dev/github.com/pb33f/libopenapi-validator)
-A validation module for [libopenapi](https://github.com/pb33f/libopenapi).
+A validation module for [libopenapi](https://github.com/pb33f/libopenapi).
+
+Document validation is explicitly covered for OpenAPI 3.0, 3.1, and 3.2.
`libopenapi-validator` will validate the following elements against an OpenAPI 3+ specification
@@ -18,7 +20,24 @@ A validation module for [libopenapi](https://github.com/pb33f/libopenapi).
- *libopenapi.Document* - Validates the OpenAPI document against the OpenAPI specification
- *base.Schema* - Validates a schema against a JSON or YAML blob / unmarshalled object
-👉👉 [Check out the full documentation](https://pb33f.io/libopenapi/validation/) 👈👈
+👉👉 [Check out the full documentation](https://pb33f.io/libopenapi/validation/) 👈👈
+
+## Runtime validation features
+
+The validator now includes a standalone OpenAPI router, authentication callbacks with route context and replayable bodies, immutable custom body codecs, opt-in request defaults, `Parameter.content` decoding, validation policy switches, and explicit OpenAPI 3.2 document validation.
+
+Existing behavior remains the default. Strict server matching, non-JSON codecs, request mutation, and new rejection policies are opt-in:
+
+```go
+v := validator.NewValidatorFromV3Model(&model.Model,
+ config.WithStrictServerMatching(),
+ config.WithStandardBodyDecoders(),
+ config.WithRejectUnsupportedBodyContent(),
+ config.WithRequestDefaults(),
+)
+```
+
+Use `router.NewRouter` for routing without validation, `WithBodyDecoder` and `WithBodyEncoder` for proprietary formats, and `WithAuthenticationFunc` for application-owned security checks. See the [complete validation guide](https://pb33f.io/libopenapi/validation/) for defaults, options, and examples.
---
diff --git a/vendor/github.com/pb33f/libopenapi-validator/cache/cache.go b/vendor/github.com/pb33f/libopenapi-validator/cache/cache.go
index 7cbdd4934..ef09fdb31 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/cache/cache.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/cache/cache.go
@@ -1,4 +1,4 @@
-// Copyright 2025 Princess B33f Heavy Industries / Dave Shanley
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
// SPDX-License-Identifier: MIT
package cache
@@ -18,6 +18,18 @@ type SchemaCacheEntry struct {
RenderedJSON []byte
CompiledSchema *jsonschema.Schema
RenderedNode *yaml.Node
+ ResourceNodes map[string]*yaml.Node
+}
+
+// SchemaResourceCacheEntry holds one rendered document-level JSON Schema resource.
+// Resource entries are shared by many compiled schema entry points from the same parsed document.
+// RenderedNode may point at source YAML for generic validation; consumers must treat it as read-only.
+type SchemaResourceCacheEntry struct {
+ RenderedInline []byte
+ ReferenceSchema string
+ RenderedJSON []byte
+ RenderedNode *yaml.Node
+ SourceRootNode *yaml.Node // Keeps pointer-identity cache keys live for the cache entry lifetime.
}
// SchemaCache defines the interface for schema caching implementations.
@@ -27,3 +39,12 @@ type SchemaCache interface {
Store(key uint64, value *SchemaCacheEntry)
Range(f func(key uint64, value *SchemaCacheEntry) bool)
}
+
+// SchemaResourceCache caches rendered document resources by parsed document identity.
+// Entries are immutable once stored; implementations must be safe for concurrent use.
+type SchemaResourceCache interface {
+ Load(key string) (*SchemaResourceCacheEntry, bool)
+ Store(key string, value *SchemaResourceCacheEntry)
+ Range(f func(key string, value *SchemaResourceCacheEntry) bool)
+ Release()
+}
diff --git a/vendor/github.com/pb33f/libopenapi-validator/cache/default_cache.go b/vendor/github.com/pb33f/libopenapi-validator/cache/default_cache.go
index c27211c7e..6b6b45b46 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/cache/default_cache.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/cache/default_cache.go
@@ -1,3 +1,6 @@
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
+// SPDX-License-Identifier: MIT
+
package cache
import "sync"
@@ -7,13 +10,42 @@ type DefaultCache struct {
m *sync.Map
}
-var _ SchemaCache = &DefaultCache{}
+// DefaultSchemaResourceCache is the default thread-safe cache for rendered document resources.
+type DefaultSchemaResourceCache struct {
+ m *sync.Map
+}
+
+var (
+ _ SchemaCache = &DefaultCache{}
+ _ SchemaResourceCache = &DefaultSchemaResourceCache{}
+)
// NewDefaultCache creates a new DefaultCache with an initialized sync.Map.
func NewDefaultCache() *DefaultCache {
return &DefaultCache{m: &sync.Map{}}
}
+// NewDefaultSchemaResourceCache creates a default cache for rendered document resources.
+func NewDefaultSchemaResourceCache() *DefaultSchemaResourceCache {
+ return &DefaultSchemaResourceCache{m: &sync.Map{}}
+}
+
+// Release clears all cached schema entries.
+func (c *DefaultCache) Release() {
+ if c == nil || c.m == nil {
+ return
+ }
+ c.m.Clear()
+}
+
+// Release clears all cached rendered document resources.
+func (c *DefaultSchemaResourceCache) Release() {
+ if c == nil || c.m == nil {
+ return
+ }
+ c.m.Clear()
+}
+
// Load retrieves a schema from the cache.
func (c *DefaultCache) Load(key uint64) (*SchemaCacheEntry, bool) {
if c == nil || c.m == nil {
@@ -52,3 +84,42 @@ func (c *DefaultCache) Range(f func(key uint64, value *SchemaCacheEntry) bool) {
return f(key, val)
})
}
+
+// Load retrieves a rendered document resource from the cache.
+func (c *DefaultSchemaResourceCache) Load(key string) (*SchemaResourceCacheEntry, bool) {
+ if c == nil || c.m == nil {
+ return nil, false
+ }
+ val, ok := c.m.Load(key)
+ if !ok {
+ return nil, false
+ }
+ resourceCache, ok := val.(*SchemaResourceCacheEntry)
+ return resourceCache, ok
+}
+
+// Store saves a rendered document resource to the cache.
+func (c *DefaultSchemaResourceCache) Store(key string, value *SchemaResourceCacheEntry) {
+ if c == nil || c.m == nil {
+ return
+ }
+ c.m.Store(key, value)
+}
+
+// Range calls f for each rendered document resource cache entry.
+func (c *DefaultSchemaResourceCache) Range(f func(key string, value *SchemaResourceCacheEntry) bool) {
+ if c == nil || c.m == nil {
+ return
+ }
+ c.m.Range(func(k, v interface{}) bool {
+ key, ok := k.(string)
+ if !ok {
+ return true
+ }
+ val, ok := v.(*SchemaResourceCacheEntry)
+ if !ok {
+ return true
+ }
+ return f(key, val)
+ })
+}
diff --git a/vendor/github.com/pb33f/libopenapi-validator/config/config.go b/vendor/github.com/pb33f/libopenapi-validator/config/config.go
index f67ec0f00..806774f3b 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/config/config.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/config/config.go
@@ -1,12 +1,22 @@
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
+// SPDX-License-Identifier: MIT
+
package config
import (
+ "context"
"log/slog"
+ "net/http"
+ "github.com/pb33f/libopenapi/datamodel/high/base"
"github.com/santhosh-tekuri/jsonschema/v6"
+ v3 "github.com/pb33f/libopenapi/datamodel/high/v3"
+
"github.com/pb33f/libopenapi-validator/cache"
+ "github.com/pb33f/libopenapi-validator/content"
"github.com/pb33f/libopenapi-validator/radix"
+ "github.com/pb33f/libopenapi-validator/router"
)
// RegexCache can be set to enable compiled regex caching.
@@ -18,24 +28,77 @@ type RegexCache interface {
Store(key, value any) // Set a compiled regex to the cache
}
+// AuthenticationFunc validates one security scheme for an HTTP request.
+// Return nil when the scheme is satisfied; return an error to fail the current
+// security requirement. Each invocation receives a fresh replayable body reader.
+type AuthenticationFunc func(context.Context, *AuthenticationInput) error
+
+// AuthenticationInput contains the request and OpenAPI security scheme details passed to an AuthenticationFunc.
+type AuthenticationInput struct {
+ Request *http.Request // Request is the request being authenticated.
+ SecuritySchemeName string // SecuritySchemeName is the component key from the requirement.
+ SecurityScheme *v3.SecurityScheme // SecurityScheme is the resolved OpenAPI scheme.
+ Scopes []string // Scopes contains the scopes required by this requirement.
+ Path string // Path is the matched OpenAPI path template.
+ PathItem *v3.PathItem // PathItem is the matched OpenAPI path item.
+ Operation *v3.Operation // Operation is the matched OpenAPI operation.
+ PathParams map[string]string // PathParams contains decoded operation path parameters.
+ Server *v3.Server // Server is the effective matched server, if explicit.
+ ServerParams map[string]string // ServerParams contains decoded server variables.
+}
+
+// ContentParameterDecoder decodes an OpenAPI Parameter.content value and may select a schema.
+type ContentParameterDecoder func(context.Context, *ContentParameterInput) (value any, schema *base.Schema, err error)
+
+// ContentParameterInput contains raw parameter values and matched route context.
+type ContentParameterInput struct {
+ Parameter *v3.Parameter // Parameter is the OpenAPI parameter being decoded.
+ RawValues []string // RawValues contains all query values or the single non-query value.
+ MediaType string // MediaType is the declared Parameter.content media type.
+ DefaultSchema *base.Schema // DefaultSchema is the schema declared by the selected media type.
+ Request *http.Request // Request is the request being validated.
+ PathParams map[string]string // PathParams contains decoded operation path parameters.
+ ServerVariables map[string]string // ServerVariables contains decoded server variables.
+}
+
// ValidationOptions A container for validation configuration.
//
// Generally fluent With... style functions are used to establish the desired behavior.
type ValidationOptions struct {
- RegexEngine jsonschema.RegexpEngine
- RegexCache RegexCache // Enable compiled regex caching
- FormatAssertions bool
- ContentAssertions bool
- SecurityValidation bool
+ RegexEngine jsonschema.RegexpEngine
+ RegexCache RegexCache // Enable compiled regex caching
+ FormatAssertions bool
+ ContentAssertions bool
+ SecurityValidation bool
+ AuthenticationFunc AuthenticationFunc
+ // ContentParameterDecoder replaces built-in Parameter.content decoding when non-nil.
+ ContentParameterDecoder ContentParameterDecoder
+ // ValidateContentParameters enables built-in JSON decoding for path, header, and cookie Parameter.content values.
+ // Existing query Parameter.content behavior remains enabled independently.
+ ValidateContentParameters bool
OpenAPIMode bool // Enable OpenAPI-specific vocabulary validation
AllowScalarCoercion bool // Enable string->boolean/number coercion
Formats map[string]func(v any) error
- SchemaCache cache.SchemaCache // Optional cache for compiled schemas
- PathTree radix.PathLookup // O(k) path lookup via radix tree (built automatically)
- pathTreeDisabled bool // Internal: true if radix tree auto-build was disabled via DisablePathTree
- Logger *slog.Logger // Logger for debug/error output (nil = silent)
- AllowXMLBodyValidation bool // Allows to convert XML to JSON for validating a request/response body.
- AllowURLEncodedBodyValidation bool // Allows to convert URL Encoded to JSON for validating a request/response body.
+ SchemaCache cache.SchemaCache // Optional cache for compiled schemas
+ SchemaResourceCache cache.SchemaResourceCache // Optional cache for rendered document-level schema resources
+ PathTree radix.PathLookup // O(k) path lookup via radix tree (built automatically)
+ Router router.Router // Shared immutable request router, when constructed by the high-level validator.
+ pathTreeDisabled bool // Internal: true if radix tree auto-build was disabled via DisablePathTree
+ Logger *slog.Logger // Logger for debug/error output (nil = silent)
+ AllowXMLBodyValidation bool // Allows to convert XML to JSON for validating a request/response body.
+ AllowURLEncodedBodyValidation bool // Allows to convert URL Encoded to JSON for validating a request/response body.
+ BodyRegistry *content.Registry // BodyRegistry is the frozen per-validator body codec registry.
+ RejectUnsupportedBodyContent bool // RejectUnsupportedBodyContent rejects declared media types without a decoder.
+ RejectUndeclaredRequestBody bool // RejectUndeclaredRequestBody rejects bodies on operations without requestBody.
+ ValidateRequestQuery bool // ValidateRequestQuery controls high-level query validation.
+ ValidateRequestBody bool // ValidateRequestBody controls high-level request-body validation.
+ ValidateResponseBody bool // ValidateResponseBody controls high-level response-body validation.
+ ValidateResponseStatus bool // ValidateResponseStatus rejects undocumented response status codes.
+ RequestDefaults bool // RequestDefaults stages and atomically applies request defaults.
+ StrictServerMatching bool // StrictServerMatching matches scheme, host, port, base path, and server variables.
+ bodyDecoders []content.Registration
+ bodyEncoders []content.EncoderRegistration
+ borrowedState bool
// strict mode options - detect undeclared properties even when additionalProperties: true
StrictMode bool // Enable strict property validation
@@ -53,11 +116,24 @@ type Option func(*ValidationOptions)
func NewValidationOptions(opts ...Option) *ValidationOptions {
// create the set of default values
o := &ValidationOptions{
- FormatAssertions: false,
- ContentAssertions: false,
- SecurityValidation: true,
- OpenAPIMode: true, // Enable OpenAPI vocabulary by default
- SchemaCache: cache.NewDefaultCache(), // Enable caching by default
+ FormatAssertions: false,
+ ContentAssertions: false,
+ SecurityValidation: true,
+ OpenAPIMode: true, // Enable OpenAPI vocabulary by default
+ ValidateRequestQuery: true,
+ ValidateRequestBody: true,
+ ValidateResponseBody: true,
+ ValidateResponseStatus: true,
+ SchemaCache: cache.NewDefaultCache(), // Enable compiled schema caching by default
+ SchemaResourceCache: cache.NewDefaultSchemaResourceCache(), // Enable rendered resource caching by default
+ bodyDecoders: []content.Registration{
+ {MediaType: "application/json", Decoder: content.JSONDecoder()},
+ {MediaType: "application/*+json", Decoder: content.JSONDecoder()},
+ },
+ bodyEncoders: []content.EncoderRegistration{
+ {MediaType: "application/json", Encoder: content.JSONEncoder()},
+ {MediaType: "application/*+json", Encoder: content.JSONEncoder()},
+ },
}
for _, opt := range opts {
@@ -65,27 +141,88 @@ func NewValidationOptions(opts ...Option) *ValidationOptions {
opt(o)
}
}
+ if o.BodyRegistry == nil {
+ o.BodyRegistry = content.NewRegistry(o.bodyDecoders, o.bodyEncoders)
+ }
+ o.bodyDecoders = nil
+ o.bodyEncoders = nil
return o
}
+// Release clears cached validation state and drops references that can keep
+// parsed documents, rendered schemas, path trees, or user-provided callbacks alive.
+func (o *ValidationOptions) Release() {
+ if o == nil {
+ return
+ }
+ if !o.borrowedState {
+ releaseIfSupported(o.SchemaCache)
+ releaseIfSupported(o.SchemaResourceCache)
+ releaseIfSupported(o.PathTree)
+ }
+
+ o.RegexEngine = nil
+ o.RegexCache = nil
+ o.AuthenticationFunc = nil
+ o.ContentParameterDecoder = nil
+ o.ValidateContentParameters = false
+ o.Formats = nil
+ o.SchemaCache = nil
+ o.SchemaResourceCache = nil
+ o.PathTree = nil
+ o.Router = nil
+ o.Logger = nil
+ o.StrictIgnorePaths = nil
+ o.StrictIgnoredHeaders = nil
+ o.BodyRegistry = nil
+ o.bodyDecoders = nil
+ o.bodyEncoders = nil
+ o.borrowedState = false
+}
+
+type releaser interface {
+ Release()
+}
+
+func releaseIfSupported(value any) {
+ if r, ok := value.(releaser); ok {
+ r.Release()
+ }
+}
+
// WithExistingOpts returns an Option that will copy the values from the supplied ValidationOptions instance
func WithExistingOpts(options *ValidationOptions) Option {
return func(o *ValidationOptions) {
if options != nil {
+ o.borrowedState = true
o.RegexEngine = options.RegexEngine
o.RegexCache = options.RegexCache
o.FormatAssertions = options.FormatAssertions
o.ContentAssertions = options.ContentAssertions
o.SecurityValidation = options.SecurityValidation
+ o.AuthenticationFunc = options.AuthenticationFunc
+ o.ContentParameterDecoder = options.ContentParameterDecoder
+ o.ValidateContentParameters = options.ValidateContentParameters
o.OpenAPIMode = options.OpenAPIMode
o.AllowScalarCoercion = options.AllowScalarCoercion
o.Formats = options.Formats
o.SchemaCache = options.SchemaCache
+ o.SchemaResourceCache = options.SchemaResourceCache
o.PathTree = options.PathTree
+ o.Router = options.Router
o.pathTreeDisabled = options.pathTreeDisabled
o.Logger = options.Logger
o.AllowXMLBodyValidation = options.AllowXMLBodyValidation
o.AllowURLEncodedBodyValidation = options.AllowURLEncodedBodyValidation
+ o.BodyRegistry = options.BodyRegistry
+ o.RejectUnsupportedBodyContent = options.RejectUnsupportedBodyContent
+ o.RejectUndeclaredRequestBody = options.RejectUndeclaredRequestBody
+ o.ValidateRequestQuery = options.ValidateRequestQuery
+ o.ValidateRequestBody = options.ValidateRequestBody
+ o.ValidateResponseBody = options.ValidateResponseBody
+ o.ValidateResponseStatus = options.ValidateResponseStatus
+ o.RequestDefaults = options.RequestDefaults
+ o.StrictServerMatching = options.StrictServerMatching
o.StrictMode = options.StrictMode
o.StrictIgnorePaths = options.StrictIgnorePaths
o.StrictIgnoredHeaders = options.StrictIgnoredHeaders
@@ -140,6 +277,28 @@ func WithoutSecurityValidation() Option {
}
}
+// WithAuthenticationFunc sets a custom function for validating security requirements.
+// When set, the function is authoritative for all security scheme types, including oauth2 and openIdConnect.
+func WithAuthenticationFunc(fn AuthenticationFunc) Option {
+ return func(o *ValidationOptions) {
+ o.AuthenticationFunc = fn
+ }
+}
+
+// WithContentParameterDecoder enables Parameter.content validation with a custom per-validator decoder.
+func WithContentParameterDecoder(decoder ContentParameterDecoder) Option {
+ return func(o *ValidationOptions) {
+ o.ContentParameterDecoder = decoder
+ o.ValidateContentParameters = decoder != nil
+ }
+}
+
+// WithContentParameterValidation enables built-in JSON Parameter.content validation for path, header, and cookie parameters.
+// Existing query Parameter.content behavior remains enabled independently for compatibility.
+func WithContentParameterValidation() Option {
+ return func(o *ValidationOptions) { o.ValidateContentParameters = true }
+}
+
// WithCustomFormat adds custom formats and their validators that checks for custom 'format' assertions
// When you add different validators with the same name, they will be overridden,
// and only the last registration will take effect.
@@ -179,6 +338,10 @@ func WithScalarCoercion() Option {
func WithXmlBodyValidation() Option {
return func(o *ValidationOptions) {
o.AllowXMLBodyValidation = true
+ o.bodyDecoders = append(o.bodyDecoders,
+ content.Registration{MediaType: "application/xml", Decoder: content.XMLCompatibilityDecoder()},
+ content.Registration{MediaType: "text/xml", Decoder: content.XMLCompatibilityDecoder()},
+ )
}
}
@@ -187,9 +350,89 @@ func WithXmlBodyValidation() Option {
func WithURLEncodedBodyValidation() Option {
return func(o *ValidationOptions) {
o.AllowURLEncodedBodyValidation = true
+ o.bodyDecoders = append(o.bodyDecoders, content.Registration{
+ MediaType: "application/x-www-form-urlencoded", Decoder: content.FormCompatibilityDecoder(),
+ })
+ }
+}
+
+// WithBodyDecoder registers a per-validator body decoder. Later exact registrations win.
+func WithBodyDecoder(mediaType string, decoder content.Decoder) Option {
+ return func(o *ValidationOptions) {
+ o.BodyRegistry = nil
+ o.bodyDecoders = append(o.bodyDecoders, content.Registration{MediaType: mediaType, Decoder: decoder})
}
}
+// WithBodyEncoder registers a per-validator body encoder. Later exact registrations win.
+func WithBodyEncoder(mediaType string, encoder content.Encoder) Option {
+ return func(o *ValidationOptions) {
+ o.BodyRegistry = nil
+ o.bodyEncoders = append(o.bodyEncoders, content.EncoderRegistration{MediaType: mediaType, Encoder: encoder})
+ }
+}
+
+// WithStandardBodyDecoders enables YAML, generic XML, URL-encoded forms,
+// multipart forms, plain text, CSV, and binary codecs. ZIP remains separately
+// opt-in through WithZipBodyDecoder.
+func WithStandardBodyDecoders() Option {
+ return func(o *ValidationOptions) {
+ o.BodyRegistry = nil
+ o.bodyDecoders = append(o.bodyDecoders, content.StandardDecoderRegistrations()...)
+ }
+}
+
+// WithZipBodyDecoder enables ZIP validation bounded by limits.
+func WithZipBodyDecoder(limits content.ZipLimits) Option {
+ return func(o *ValidationOptions) {
+ o.BodyRegistry = nil
+ o.bodyDecoders = append(o.bodyDecoders, content.Registration{
+ MediaType: "application/zip", Decoder: content.ZIPDecoder(limits),
+ })
+ }
+}
+
+// WithRejectUnsupportedBodyContent rejects declared body media types without a decoder.
+func WithRejectUnsupportedBodyContent() Option {
+ return func(o *ValidationOptions) { o.RejectUnsupportedBodyContent = true }
+}
+
+// WithRejectUndeclaredRequestBody rejects non-empty bodies on operations without requestBody.
+func WithRejectUndeclaredRequestBody() Option {
+ return func(o *ValidationOptions) { o.RejectUndeclaredRequestBody = true }
+}
+
+// WithoutRequestQueryParameterValidation excludes query validation from high-level request validation.
+func WithoutRequestQueryParameterValidation() Option {
+ return func(o *ValidationOptions) { o.ValidateRequestQuery = false }
+}
+
+// WithoutRequestBodyValidation excludes all request-body policy, defaults, decoding, and validation.
+func WithoutRequestBodyValidation() Option {
+ return func(o *ValidationOptions) { o.ValidateRequestBody = false }
+}
+
+// WithoutResponseBodyValidation excludes response content and schema checks while retaining status and headers.
+func WithoutResponseBodyValidation() Option {
+ return func(o *ValidationOptions) { o.ValidateResponseBody = false }
+}
+
+// WithoutResponseStatusValidation allows undocumented response status codes.
+func WithoutResponseStatusValidation() Option {
+ return func(o *ValidationOptions) { o.ValidateResponseStatus = false }
+}
+
+// WithRequestDefaults stages query, header, cookie, and request-body defaults
+// and commits them atomically after successful decoding, encoding, and validation.
+func WithRequestDefaults() Option {
+ return func(o *ValidationOptions) { o.RequestDefaults = true }
+}
+
+// WithStrictServerMatching enables standalone-router server semantics in high-level validation.
+func WithStrictServerMatching() Option {
+ return func(o *ValidationOptions) { o.StrictServerMatching = true }
+}
+
// WithSchemaCache sets a custom cache implementation or disables caching if nil.
// Pass nil to disable schema caching and skip cache warming during validator initialization.
// The default cache is a thread-safe sync.Map wrapper.
@@ -199,6 +442,15 @@ func WithSchemaCache(schemaCache cache.SchemaCache) Option {
}
}
+// WithSchemaResourceCache sets a cache for rendered document-level schema resources.
+// Pass nil to disable resource reuse when compiling referenced schemas.
+// Cached entries retain source YAML nodes, so long-lived shared caches should be bounded or scoped deliberately.
+func WithSchemaResourceCache(schemaResourceCache cache.SchemaResourceCache) Option {
+ return func(o *ValidationOptions) {
+ o.SchemaResourceCache = schemaResourceCache
+ }
+}
+
// WithPathTree sets a custom radix tree for path matching.
// The default is built automatically from the OpenAPI specification.
func WithPathTree(pathTree radix.PathLookup) Option {
diff --git a/vendor/github.com/pb33f/libopenapi-validator/content/content.go b/vendor/github.com/pb33f/libopenapi-validator/content/content.go
new file mode 100644
index 000000000..e657f48e6
--- /dev/null
+++ b/vendor/github.com/pb33f/libopenapi-validator/content/content.go
@@ -0,0 +1,714 @@
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
+// SPDX-License-Identifier: MIT
+
+// Package content provides immutable per-validator HTTP body codec registries.
+//
+// Decoders convert request and response bodies into the JSON-compatible values
+// consumed by schema validation. Encoders are used only when opt-in request
+// default application rewrites a body. Registry lookup precedence is exact
+// media type, structured suffix, type wildcard, then global wildcard.
+package content
+
+import (
+ "archive/zip"
+ "bytes"
+ "context"
+ "encoding/csv"
+ "encoding/json"
+ "encoding/xml"
+ "errors"
+ "fmt"
+ "io"
+ "mime"
+ "mime/multipart"
+ "net/http"
+ "net/url"
+ "strconv"
+ "strings"
+ "time"
+
+ "github.com/pb33f/libopenapi/datamodel/high/base"
+ "go.yaml.in/yaml/v4"
+
+ v3 "github.com/pb33f/libopenapi/datamodel/high/v3"
+)
+
+// Direction identifies whether a codec is processing request or response data.
+type Direction uint8
+
+const (
+ // Request identifies request-body processing.
+ Request Direction = iota
+ // Response identifies response-body processing.
+ Response
+)
+
+// DecodeInput contains the complete body-decoding context supplied by a validator.
+type DecodeInput struct {
+ Context context.Context // Context is the request context.
+ Body io.Reader // Body is a fresh reader over the immutable body snapshot.
+ Header http.Header // Header contains the request or response headers.
+ // MediaType is the normalized media type without parameters.
+ MediaType string
+ // Parameters contains parsed media-type parameters such as charset or boundary.
+ Parameters map[string]string
+ Schema *base.Schema // Schema is the OpenAPI media-type schema.
+ // Encoding contains OpenAPI per-property encoding metadata when available.
+ Encoding interface{ GetOrZero(string) *v3.Encoding }
+ Direction Direction // Direction identifies request or response processing.
+}
+
+// EncodeInput contains the complete body-encoding context.
+type EncodeInput struct {
+ Context context.Context // Context is the request context.
+ Value any // Value is the canonical decoded value to encode.
+ Header http.Header // Header contains the staged request headers.
+ MediaType string // MediaType is the normalized media type.
+ Schema *base.Schema // Schema is the OpenAPI media-type schema.
+ // Encoding contains OpenAPI per-property encoding metadata when available.
+ Encoding interface{ GetOrZero(string) *v3.Encoding }
+ Direction Direction // Direction identifies request or response processing.
+}
+
+// FailureContext retains HTTP and OpenAPI objects associated with a decoding or rewrite failure.
+type FailureContext struct {
+ Request *http.Request // Request is the request being validated.
+ Response *http.Response // Response is populated for response failures.
+ Operation *v3.Operation // Operation is the matched OpenAPI operation.
+ MediaType *v3.MediaType // MediaType is the selected OpenAPI media-type definition.
+ Schema *base.Schema // Schema is the selected body schema.
+}
+
+// Decoder converts an HTTP entity into a JSON-compatible validation value.
+type Decoder interface {
+ // Decode returns a JSON-compatible validation value.
+ Decode(*DecodeInput) (any, error)
+}
+
+// DecoderFunc adapts a function to Decoder.
+type DecoderFunc func(*DecodeInput) (any, error)
+
+// Decode calls f with input.
+func (f DecoderFunc) Decode(input *DecodeInput) (any, error) { return f(input) }
+
+// Encoder converts a validation value back into an HTTP entity.
+type Encoder interface {
+ // Encode serializes a canonical validation value into an HTTP body.
+ Encode(*EncodeInput) ([]byte, error)
+}
+
+// EncoderFunc adapts a function to Encoder.
+type EncoderFunc func(*EncodeInput) ([]byte, error)
+
+// Encode calls f with input.
+func (f EncoderFunc) Encode(input *EncodeInput) ([]byte, error) { return f(input) }
+
+// Registration associates a normalized media-range with a decoder.
+type Registration struct {
+ MediaType string // MediaType is an exact type or wildcard media range.
+ Decoder Decoder // Decoder handles values selected by MediaType.
+}
+
+// EncoderRegistration associates a normalized media-range with an encoder.
+type EncoderRegistration struct {
+ MediaType string // MediaType is an exact type or wildcard media range.
+ Encoder Encoder // Encoder handles values selected by MediaType.
+}
+
+// Registry is an immutable, concurrency-safe, lock-free codec lookup table.
+// Construct registries with NewRegistry and derive replacements with WithDecoder.
+type Registry struct {
+ decoders map[string]Decoder
+ encoders map[string]Encoder
+}
+
+// CompatibilityDecoder marks a decoder placeholder that is replaced by a schema-aware validator adapter.
+type CompatibilityDecoder interface {
+ Decoder
+ // CompatibilityKind identifies the legacy adapter that must replace this marker.
+ CompatibilityKind() string
+}
+
+type compatibilityDecoder string
+
+func (d compatibilityDecoder) Decode(*DecodeInput) (any, error) {
+ return nil, fmt.Errorf("%s compatibility decoder was not initialized", d)
+}
+
+func (d compatibilityDecoder) CompatibilityKind() string { return string(d) }
+
+// XMLCompatibilityDecoder returns the marker used by the legacy XML validation option.
+func XMLCompatibilityDecoder() Decoder { return compatibilityDecoder("xml") }
+
+// FormCompatibilityDecoder returns the marker used by the legacy form validation option.
+func FormCompatibilityDecoder() Decoder { return compatibilityDecoder("form") }
+
+// Precompute returns a new immutable registry with resolved exact dispatch entries for declared media types.
+func (r *Registry) Precompute(mediaTypes []string) *Registry {
+ if r == nil {
+ return nil
+ }
+ resolved := &Registry{decoders: make(map[string]Decoder, len(r.decoders)+len(mediaTypes)), encoders: make(map[string]Encoder, len(r.encoders)+len(mediaTypes))}
+ for mediaType, decoder := range r.decoders {
+ resolved.decoders[mediaType] = decoder
+ }
+ for mediaType, encoder := range r.encoders {
+ resolved.encoders[mediaType] = encoder
+ }
+ for _, declared := range mediaTypes {
+ normalized, _ := NormalizeMediaType(declared)
+ if normalized == "" {
+ continue
+ }
+ if _, exists := resolved.decoders[normalized]; !exists {
+ if decoder, _, _ := r.Decoder(normalized); decoder != nil {
+ resolved.decoders[normalized] = decoder
+ }
+ }
+ if _, exists := resolved.encoders[normalized]; !exists {
+ if encoder, _, _ := r.Encoder(normalized); encoder != nil {
+ resolved.encoders[normalized] = encoder
+ }
+ }
+ }
+ return resolved
+}
+
+// ExactDecoder returns only an exact normalized registration without wildcard resolution.
+func (r *Registry) ExactDecoder(mediaType string) Decoder {
+ if r == nil {
+ return nil
+ }
+ normalized, _ := NormalizeMediaType(mediaType)
+ return r.decoders[normalized]
+}
+
+// WithDecoder returns a new immutable registry with one exact decoder replaced.
+func (r *Registry) WithDecoder(mediaType string, decoder Decoder) *Registry {
+ if r == nil {
+ return NewRegistry([]Registration{{MediaType: mediaType, Decoder: decoder}}, nil)
+ }
+ resolved := r.Precompute(nil)
+ key := normalizeRange(mediaType)
+ if key != "" && decoder != nil {
+ resolved.decoders[key] = decoder
+ }
+ return resolved
+}
+
+// NewRegistry freezes codec registrations. Later duplicate exact registrations win.
+func NewRegistry(decoders []Registration, encoders []EncoderRegistration) *Registry {
+ r := &Registry{decoders: make(map[string]Decoder, len(decoders)), encoders: make(map[string]Encoder, len(encoders))}
+ for _, registration := range decoders {
+ if key := normalizeRange(registration.MediaType); key != "" && registration.Decoder != nil {
+ r.decoders[key] = registration.Decoder
+ }
+ }
+ for _, registration := range encoders {
+ if key := normalizeRange(registration.MediaType); key != "" && registration.Encoder != nil {
+ r.encoders[key] = registration.Encoder
+ }
+ }
+ return r
+}
+
+// Decoder resolves exact, structured-suffix, type-wildcard, then global-wildcard matches.
+func (r *Registry) Decoder(mediaType string) (Decoder, string, map[string]string) {
+ if r == nil {
+ return nil, "", nil
+ }
+ if decoder := r.decoders[mediaType]; decoder != nil {
+ return decoder, mediaType, nil
+ }
+ normalized, params := NormalizeMediaType(mediaType)
+ if normalized == "" {
+ return nil, "", params
+ }
+ if decoder := r.decoders[normalized]; decoder != nil {
+ return decoder, normalized, params
+ }
+ parts := strings.SplitN(normalized, "/", 2)
+ if len(parts) != 2 {
+ return nil, normalized, params
+ }
+ if plus := strings.LastIndexByte(parts[1], '+'); plus >= 0 {
+ if decoder := r.decoders[parts[0]+"/*"+parts[1][plus:]]; decoder != nil {
+ return decoder, normalized, params
+ }
+ }
+ if decoder := r.decoders[parts[0]+"/*"]; decoder != nil {
+ return decoder, normalized, params
+ }
+ return r.decoders["*/*"], normalized, params
+}
+
+// Encoder resolves an encoder with the same precedence as Decoder.
+func (r *Registry) Encoder(mediaType string) (Encoder, string, map[string]string) {
+ if r == nil {
+ return nil, "", nil
+ }
+ normalized, params := NormalizeMediaType(mediaType)
+ if encoder := r.encoders[normalized]; encoder != nil {
+ return encoder, normalized, params
+ }
+ parts := strings.SplitN(normalized, "/", 2)
+ if len(parts) == 2 {
+ if plus := strings.LastIndexByte(parts[1], '+'); plus >= 0 {
+ if encoder := r.encoders[parts[0]+"/*"+parts[1][plus:]]; encoder != nil {
+ return encoder, normalized, params
+ }
+ }
+ if encoder := r.encoders[parts[0]+"/*"]; encoder != nil {
+ return encoder, normalized, params
+ }
+ }
+ return r.encoders["*/*"], normalized, params
+}
+
+// NormalizeMediaType parses a media type and lowercases its lookup key.
+func NormalizeMediaType(value string) (string, map[string]string) {
+ mediaType, params, err := mime.ParseMediaType(value)
+ if err != nil && mediaType == "" {
+ return "", params
+ }
+ return strings.ToLower(mediaType), params
+}
+
+func normalizeRange(value string) string {
+ value = strings.TrimSpace(strings.ToLower(value))
+ if strings.Contains(value, ";") {
+ value, _ = NormalizeMediaType(value)
+ }
+ if strings.Count(value, "/") != 1 {
+ return ""
+ }
+ return value
+}
+
+// DecodingError retains codec context while exposing the decoder failure.
+type DecodingError struct {
+ MediaType string // MediaType is the normalized type selected for decoding.
+ Direction Direction // Direction identifies request or response decoding.
+ Err error // Err is the underlying decoder or canonicalization error.
+}
+
+// Error describes the media type, direction, and underlying decoder failure.
+func (e *DecodingError) Error() string {
+ if e == nil || e.Err == nil {
+ return "body decoding failed"
+ }
+ return fmt.Sprintf("decode %s body as %s: %v", directionName(e.Direction), e.MediaType, e.Err)
+}
+
+// Unwrap exposes the underlying decoder or canonicalization failure.
+func (e *DecodingError) Unwrap() error {
+ if e == nil {
+ return nil
+ }
+ return e.Err
+}
+
+func directionName(direction Direction) string {
+ if direction == Response {
+ return "response"
+ }
+ return "request"
+}
+
+// Canonicalize recursively converts decoded values to the JSON validation data model.
+// It rejects maps with non-string keys and values outside the documented primitive,
+// []any, map[string]any, []byte, json.Number, and time.Time set.
+func Canonicalize(value any) (any, error) {
+ switch typed := value.(type) {
+ case map[string]any:
+ result := make(map[string]any, len(typed))
+ for key, child := range typed {
+ canonical, err := Canonicalize(child)
+ if err != nil {
+ return nil, err
+ }
+ result[key] = canonical
+ }
+ return result, nil
+ case map[any]any:
+ result := make(map[string]any, len(typed))
+ for key, child := range typed {
+ stringKey, ok := key.(string)
+ if !ok {
+ return nil, fmt.Errorf("mapping key %v is not a string", key)
+ }
+ canonical, err := Canonicalize(child)
+ if err != nil {
+ return nil, err
+ }
+ result[stringKey] = canonical
+ }
+ return result, nil
+ case []any:
+ result := make([]any, len(typed))
+ for i, child := range typed {
+ canonical, err := Canonicalize(child)
+ if err != nil {
+ return nil, err
+ }
+ result[i] = canonical
+ }
+ return result, nil
+ case int:
+ return float64(typed), nil
+ case int8:
+ return float64(typed), nil
+ case int16:
+ return float64(typed), nil
+ case int32:
+ return float64(typed), nil
+ case int64:
+ return float64(typed), nil
+ case uint:
+ return float64(typed), nil
+ case uint8:
+ return float64(typed), nil
+ case uint16:
+ return float64(typed), nil
+ case uint32:
+ return float64(typed), nil
+ case uint64:
+ return float64(typed), nil
+ case float32:
+ return float64(typed), nil
+ case json.Number:
+ return typed.Float64()
+ case time.Time:
+ return typed.Format(time.RFC3339Nano), nil
+ case nil, string, bool, float64, []byte:
+ return value, nil
+ default:
+ return nil, fmt.Errorf("decoded value of type %T is not JSON-compatible", value)
+ }
+}
+
+// JSONDecoder returns the compatibility JSON decoder.
+func JSONDecoder() Decoder {
+ return DecoderFunc(func(input *DecodeInput) (any, error) {
+ var value any
+ if input == nil || input.Body == nil {
+ return nil, nil
+ }
+ decoder := json.NewDecoder(input.Body)
+ if err := decoder.Decode(&value); err != nil {
+ if errors.Is(err, io.EOF) {
+ return nil, nil
+ }
+ return nil, err
+ }
+ if _, err := decoder.Token(); !errors.Is(err, io.EOF) {
+ if err == nil {
+ return nil, errors.New("JSON body contains multiple values")
+ }
+ return nil, err
+ }
+ return value, nil
+ })
+}
+
+// JSONEncoder returns the standard JSON encoder.
+func JSONEncoder() Encoder {
+ return EncoderFunc(func(input *EncodeInput) ([]byte, error) {
+ if input == nil {
+ return nil, nil
+ }
+ return json.Marshal(input.Value)
+ })
+}
+
+// YAMLDecoder returns a YAML decoder with JSON-compatible canonicalization.
+func YAMLDecoder() Decoder {
+ return DecoderFunc(func(input *DecodeInput) (any, error) {
+ var value any
+ if input == nil || input.Body == nil {
+ return nil, nil
+ }
+ if err := yaml.NewDecoder(input.Body).Decode(&value); err != nil {
+ return nil, err
+ }
+ return Canonicalize(value)
+ })
+}
+
+// TextDecoder returns a decoder that preserves the body as a string.
+func TextDecoder() Decoder { return stringDecoder(false) }
+
+// CSVDecoder validates CSV syntax and preserves the original body as a string.
+func CSVDecoder() Decoder { return stringDecoder(true) }
+
+// BinaryDecoder returns a decoder for string/binary schemas.
+func BinaryDecoder() Decoder { return stringDecoder(false) }
+
+func stringDecoder(validateCSV bool) Decoder {
+ return DecoderFunc(func(input *DecodeInput) (any, error) {
+ if input == nil || input.Body == nil {
+ return "", nil
+ }
+ body, err := io.ReadAll(input.Body)
+ if err != nil {
+ return nil, err
+ }
+ if validateCSV {
+ if _, err = csv.NewReader(bytes.NewReader(body)).ReadAll(); err != nil {
+ return nil, err
+ }
+ }
+ return string(body), nil
+ })
+}
+
+// FormDecoder returns a URL-encoded form decoder.
+func FormDecoder() Decoder {
+ return DecoderFunc(func(input *DecodeInput) (any, error) {
+ if input == nil || input.Body == nil {
+ return map[string]any{}, nil
+ }
+ body, err := io.ReadAll(input.Body)
+ if err != nil {
+ return nil, err
+ }
+ values, err := url.ParseQuery(string(body))
+ if err != nil {
+ return nil, err
+ }
+ result := make(map[string]any, len(values))
+ for key, value := range values {
+ if len(value) == 1 {
+ result[key] = coerceString(value[0], propertySchema(input.Schema, key))
+ } else {
+ items := make([]any, len(value))
+ property := propertySchema(input.Schema, key)
+ for i, item := range value {
+ items[i] = coerceString(item, arrayItemSchema(property))
+ }
+ result[key] = items
+ }
+ }
+ return result, nil
+ })
+}
+
+// MultipartDecoder returns a form-data decoder using the boundary parameter.
+func MultipartDecoder() Decoder {
+ return DecoderFunc(func(input *DecodeInput) (any, error) {
+ if input == nil || input.Body == nil {
+ return map[string]any{}, nil
+ }
+ boundary := ""
+ if input.Parameters != nil {
+ boundary = input.Parameters["boundary"]
+ }
+ if boundary == "" {
+ return nil, errors.New("multipart boundary is missing")
+ }
+ reader := multipart.NewReader(input.Body, boundary)
+ values := make(map[string]any)
+ for {
+ part, err := reader.NextPart()
+ if errors.Is(err, io.EOF) {
+ break
+ }
+ if err != nil {
+ return nil, err
+ }
+ body, err := io.ReadAll(part)
+ _ = part.Close()
+ if err != nil {
+ return nil, err
+ }
+ name := part.FormName()
+ property := propertySchema(input.Schema, name)
+ decodedBody := coerceString(string(body), arrayItemSchema(property))
+ if previous, exists := values[name]; exists {
+ switch prior := previous.(type) {
+ case []any:
+ values[name] = append(prior, coerceString(string(body), arrayItemSchema(property)))
+ default:
+ values[name] = []any{prior, coerceString(string(body), arrayItemSchema(property))}
+ }
+ } else {
+ if isArraySchema(property) {
+ values[name] = []any{decodedBody}
+ } else {
+ values[name] = decodedBody
+ }
+ }
+ }
+ return values, nil
+ })
+}
+
+type xmlNode struct {
+ XMLName xml.Name
+ Text string `xml:",chardata"`
+ Nodes []xmlNode `xml:",any"`
+}
+
+// XMLDecoder returns a generic XML object decoder.
+func XMLDecoder() Decoder {
+ return DecoderFunc(func(input *DecodeInput) (any, error) {
+ if input == nil || input.Body == nil {
+ return nil, nil
+ }
+ var root xmlNode
+ if err := xml.NewDecoder(input.Body).Decode(&root); err != nil {
+ return nil, err
+ }
+ return xmlValue(root, input.Schema), nil
+ })
+}
+
+func xmlValue(node xmlNode, schema *base.Schema) any {
+ if len(node.Nodes) == 0 {
+ return coerceString(strings.TrimSpace(node.Text), schema)
+ }
+ result := make(map[string]any)
+ for _, child := range node.Nodes {
+ property := propertySchema(schema, child.XMLName.Local)
+ value := xmlValue(child, arrayItemSchema(property))
+ if previous, exists := result[child.XMLName.Local]; exists {
+ switch prior := previous.(type) {
+ case []any:
+ result[child.XMLName.Local] = append(prior, value)
+ default:
+ result[child.XMLName.Local] = []any{prior, value}
+ }
+ } else {
+ if isArraySchema(property) {
+ result[child.XMLName.Local] = []any{value}
+ } else {
+ result[child.XMLName.Local] = value
+ }
+ }
+ }
+ return result
+}
+
+func propertySchema(schema *base.Schema, name string) *base.Schema {
+ if schema == nil || schema.Properties == nil {
+ return nil
+ }
+ proxy := schema.Properties.GetOrZero(name)
+ if proxy == nil {
+ return nil
+ }
+ return proxy.Schema()
+}
+
+func arrayItemSchema(schema *base.Schema) *base.Schema {
+ if schema == nil || schema.Items == nil || !schema.Items.IsA() || schema.Items.A == nil {
+ return schema
+ }
+ return schema.Items.A.Schema()
+}
+
+func isArraySchema(schema *base.Schema) bool {
+ if schema == nil {
+ return false
+ }
+ for _, kind := range schema.Type {
+ if kind == "array" {
+ return true
+ }
+ }
+ return false
+}
+
+func coerceString(value string, schema *base.Schema) any {
+ if schema == nil || len(schema.Type) == 0 {
+ return value
+ }
+ return ParseScalar(value, schema.Type[0])
+}
+
+// ZipLimits bounds archive processing.
+type ZipLimits struct {
+ CompressedSize int64 // CompressedSize is the maximum archive size in bytes.
+ ExpandedSize int64 // ExpandedSize is the maximum total uncompressed size in bytes.
+ Entries int // Entries is the maximum number of archive entries.
+ ExpansionRatio float64 // ExpansionRatio is the maximum expanded-to-compressed size ratio.
+}
+
+// Validate requires finite positive archive limits.
+func (l ZipLimits) Validate() error {
+ if l.CompressedSize <= 0 || l.ExpandedSize <= 0 || l.Entries <= 0 || l.ExpansionRatio <= 0 {
+ return errors.New("all ZIP limits must be positive")
+ }
+ return nil
+}
+
+// ZIPDecoder returns a decoder that validates archive metadata against limits and
+// returns the original archive bytes as a string for schema validation. It does not
+// extract archive entries. All limits must be positive.
+func ZIPDecoder(limits ZipLimits) Decoder {
+ return DecoderFunc(func(input *DecodeInput) (any, error) {
+ if err := limits.Validate(); err != nil {
+ return nil, err
+ }
+ body, err := io.ReadAll(io.LimitReader(input.Body, limits.CompressedSize+1))
+ if err != nil {
+ return nil, err
+ }
+ if int64(len(body)) > limits.CompressedSize {
+ return nil, errors.New("ZIP compressed-size limit exceeded")
+ }
+ archive, err := zip.NewReader(bytes.NewReader(body), int64(len(body)))
+ if err != nil {
+ return nil, err
+ }
+ if len(archive.File) > limits.Entries {
+ return nil, errors.New("ZIP entry-count limit exceeded")
+ }
+ var expanded uint64
+ for _, file := range archive.File {
+ expanded += file.UncompressedSize64
+ if expanded > uint64(limits.ExpandedSize) {
+ return nil, errors.New("ZIP expanded-size limit exceeded")
+ }
+ }
+ compressed := len(body)
+ if float64(expanded)/float64(compressed) > limits.ExpansionRatio {
+ return nil, errors.New("ZIP expansion-ratio limit exceeded")
+ }
+ return string(body), nil
+ })
+}
+
+// StandardDecoderRegistrations returns non-archive built-in codecs.
+func StandardDecoderRegistrations() []Registration {
+ return []Registration{
+ {"application/json", JSONDecoder()},
+ {"application/*+json", JSONDecoder()},
+ {"application/yaml", YAMLDecoder()},
+ {"application/x-yaml", YAMLDecoder()},
+ {"text/yaml", YAMLDecoder()},
+ {"application/xml", XMLDecoder()},
+ {"text/xml", XMLDecoder()},
+ {"application/x-www-form-urlencoded", FormDecoder()},
+ {"multipart/form-data", MultipartDecoder()},
+ {"text/csv", CSVDecoder()},
+ {"text/plain", TextDecoder()},
+ {"text/*", TextDecoder()},
+ {"application/octet-stream", BinaryDecoder()},
+ }
+}
+
+// ParseScalar converts a string to a JSON-compatible primitive when requested by custom codecs.
+func ParseScalar(value, kind string) any {
+ switch kind {
+ case "integer", "number":
+ if number, err := strconv.ParseFloat(value, 64); err == nil {
+ return number
+ }
+ case "boolean":
+ if boolean, err := strconv.ParseBool(value); err == nil {
+ return boolean
+ }
+ }
+ return value
+}
diff --git a/vendor/github.com/pb33f/libopenapi-validator/errors/parameter_errors.go b/vendor/github.com/pb33f/libopenapi-validator/errors/parameter_errors.go
index 6667b76dc..48ee25a80 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/errors/parameter_errors.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/errors/parameter_errors.go
@@ -87,6 +87,47 @@ func InvalidDeepObject(param *v3.Parameter, qp *helpers.QueryParam) *ValidationE
}
}
+func deepObjectPathForError(qp *helpers.QueryParam) string {
+ if qp == nil {
+ return ""
+ }
+ if len(qp.PropertyPath) > 0 {
+ return strings.Join(qp.PropertyPath, ".")
+ }
+ return qp.Property
+}
+
+func deepObjectBracketPathForError(qp *helpers.QueryParam) string {
+ if qp == nil {
+ return ""
+ }
+ if len(qp.PropertyPath) > 0 {
+ return strings.Join(qp.PropertyPath, "][")
+ }
+ return qp.Property
+}
+
+func InvalidDeepObjectPathConflict(param *v3.Parameter, prefixParam, nestedParam *helpers.QueryParam) *ValidationError {
+ specLine, specCol := paramStyleLineCol(param)
+ prefixPath := deepObjectPathForError(prefixParam)
+ nestedPath := deepObjectPathForError(nestedParam)
+ return &ValidationError{
+ ValidationType: helpers.ParameterValidation,
+ ValidationSubType: helpers.ParameterValidationQuery,
+ Message: fmt.Sprintf("Query parameter '%s' is not a valid deepObject", param.Name),
+ Reason: fmt.Sprintf("The query parameter '%s' has the 'deepObject' style defined, "+
+ "but the property path '%s' is also used as a nested object prefix for '%s'",
+ param.Name, prefixPath, nestedPath),
+ SpecLine: specLine,
+ SpecCol: specCol,
+ ParameterName: param.Name,
+ Context: param,
+ HowToFix: fmt.Sprintf(HowToFixParamInvalidDeepObjectPathConflict,
+ param.Name, deepObjectBracketPathForError(prefixParam),
+ param.Name, deepObjectBracketPathForError(nestedParam)),
+ }
+}
+
func QueryParameterMissing(param *v3.Parameter, pathTemplate string, operation string, renderedSchema string) *ValidationError {
keywordLocation := helpers.ConstructParameterJSONPointer(pathTemplate, operation, param.Name, "required")
specLine, specCol := paramRequiredLineCol(param)
diff --git a/vendor/github.com/pb33f/libopenapi-validator/errors/parameters_howtofix.go b/vendor/github.com/pb33f/libopenapi-validator/errors/parameters_howtofix.go
index b884700f0..143197eda 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/errors/parameters_howtofix.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/errors/parameters_howtofix.go
@@ -24,18 +24,19 @@ const (
"they should be separated by pipes '|'. For example: '%s'"
HowToFixParamInvalidDeepObjectMultipleValues string = "There can only be a single value per property name, " +
"deepObject parameters should contain the property key in square brackets next to the parameter name. For example: '%s'"
- HowToFixInvalidJSON string = "The JSON submitted is invalid, please check the syntax"
- HowToFixInvalidUrlEncoded string = "Ensure URL Encoded submitted is well-formed and matches schema structure"
- HowToFixDecodingError string = "The object can't be decoded, so make sure it's being encoded correctly according to the spec."
- HowToFixInvalidContentType string = "The content type is invalid, Use one of the %d supported types for this operation: %s"
- HowToFixInvalidResponseCode string = "The service is responding with a code that is not defined in the spec, fix the service or add the code to the specification"
- HowToFixInvalidEncoding string = "Ensure the correct encoding has been used on the object"
- HowToFixMissingValue string = "Ensure the value has been set"
- HowToFixPath string = "Check the path is correct, and check that the correct HTTP method has been used (e.g. GET, POST, PUT, DELETE)"
- HowToFixPathMethod string = "Add the missing operation to the contract for the path"
- HowToFixInvalidMaxItems string = "Reduce the number of items in the array to %d or less"
- HowToFixInvalidMinItems string = "Increase the number of items in the array to %d or more"
- HowToFixMissingHeader string = "Make sure the service responding sets the required headers with this response code"
- HowToFixInvalidRenderedSchema string = "Check the request schema for circular references or invalid structures"
- HowToFixInvalidJsonSchema string = "Check the request schema for invalid JSON Schema syntax, complex regex patterns, or unsupported schema constructs"
+ HowToFixParamInvalidDeepObjectPathConflict string = "Use either '%s[%s]' or nested properties like '%s[%s]', not both"
+ HowToFixInvalidJSON string = "The JSON submitted is invalid, please check the syntax"
+ HowToFixInvalidUrlEncoded string = "Ensure URL Encoded submitted is well-formed and matches schema structure"
+ HowToFixDecodingError string = "The object can't be decoded, so make sure it's being encoded correctly according to the spec."
+ HowToFixInvalidContentType string = "The content type is invalid, Use one of the %d supported types for this operation: %s"
+ HowToFixInvalidResponseCode string = "The service is responding with a code that is not defined in the spec, fix the service or add the code to the specification"
+ HowToFixInvalidEncoding string = "Ensure the correct encoding has been used on the object"
+ HowToFixMissingValue string = "Ensure the value has been set"
+ HowToFixPath string = "Check the path is correct, and check that the correct HTTP method has been used (e.g. GET, POST, PUT, DELETE)"
+ HowToFixPathMethod string = "Add the missing operation to the contract for the path"
+ HowToFixInvalidMaxItems string = "Reduce the number of items in the array to %d or less"
+ HowToFixInvalidMinItems string = "Increase the number of items in the array to %d or more"
+ HowToFixMissingHeader string = "Make sure the service responding sets the required headers with this response code"
+ HowToFixInvalidRenderedSchema string = "Check the request schema for circular references or invalid structures"
+ HowToFixInvalidJsonSchema string = "Check the request schema for invalid JSON Schema syntax, complex regex patterns, or unsupported schema constructs"
)
diff --git a/vendor/github.com/pb33f/libopenapi-validator/helpers/parameter_utilities.go b/vendor/github.com/pb33f/libopenapi-validator/helpers/parameter_utilities.go
index 3ca3e1c64..e38a98296 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/helpers/parameter_utilities.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/helpers/parameter_utilities.go
@@ -19,9 +19,10 @@ import (
// it's used for complex query types that need to be parsed and tracked differently depending
// on the encoding styles used.
type QueryParam struct {
- Key string
- Values []string
- Property string
+ Key string
+ Values []string
+ Property string
+ PropertyPath []string
}
// ExtractParamsForOperation will extract the parameters for the operation based on the request method.
@@ -203,21 +204,214 @@ func getPropertySchema(objectSchema *base.Schema, propertyName string) *base.Sch
return proxy.Schema()
}
+func getAdditionalPropertiesSchema(objectSchema *base.Schema) *base.Schema {
+ if objectSchema == nil || objectSchema.AdditionalProperties == nil || !objectSchema.AdditionalProperties.IsA() ||
+ objectSchema.AdditionalProperties.A == nil {
+ return nil
+ }
+ return objectSchema.AdditionalProperties.A.Schema()
+}
+
+func getSchemaForObjectProperty(objectSchema *base.Schema, propertyName string) *base.Schema {
+ if propSchema := getPropertySchema(objectSchema, propertyName); propSchema != nil {
+ return propSchema
+ }
+ return getAdditionalPropertiesSchema(objectSchema)
+}
+
+// ParseDeepObjectKey splits a query-string key using qs-style deepObject bracket notation.
+// It returns ok=false for non-deepObject keys or malformed bracket paths.
+func ParseDeepObjectKey(key string) (baseName string, propertyPath []string, ok bool) {
+ open := strings.IndexRune(key, '[')
+ if open <= 0 {
+ return "", nil, false
+ }
+ baseName = key[:open]
+ rest := key[open:]
+ for len(rest) > 0 {
+ if rest[0] != '[' {
+ return "", nil, false
+ }
+ close := strings.IndexRune(rest, ']')
+ if close <= 1 {
+ return "", nil, false
+ }
+ propertyPath = append(propertyPath, rest[1:close])
+ rest = rest[close+1:]
+ }
+ return baseName, propertyPath, len(propertyPath) > 0
+}
+
// castWithSchema casts a string value consulting the schema for the property's declared type.
-// If the schema says the property is a string, the value is returned as-is (no numeric/bool guessing).
+// If the schema says the property, or array property item, is a string, the value is returned
+// as-is (no numeric/bool guessing).
// For other declared types, it falls back to cast() which produces correct results for integer,
// number, and boolean values. The explicit string check prevents the most common miscast: numeric-
// looking strings like "10" being converted to int64 when the schema declares type: string.
func castWithSchema(v string, objectSchema *base.Schema, propertyName string) any {
- propSchema := getPropertySchema(objectSchema, propertyName)
+ propSchema := schemaForPropertyPath(objectSchema, []string{propertyName})
+ if schemaPreservesStringValue(propSchema) {
+ return v
+ }
+ if propSchema == nil && schemaPreservesStringValue(objectSchema) {
+ return v
+ }
+ return cast(v)
+}
+
+func queryParamPropertyPath(v *QueryParam) []string {
+ if len(v.PropertyPath) > 0 {
+ return v.PropertyPath
+ }
+ return []string{v.Property}
+}
+
+func queryParamDeepObjectPath(v *QueryParam) []string {
+ if v == nil {
+ return nil
+ }
+ if len(v.PropertyPath) > 0 {
+ return v.PropertyPath
+ }
+ if v.Property != "" {
+ return []string{v.Property}
+ }
+ return nil
+}
+
+func schemaForPropertyPath(objectSchema *base.Schema, propertyPath []string) *base.Schema {
+ current := objectSchema
+ for _, propertyName := range propertyPath {
+ current = getSchemaForObjectProperty(current, propertyName)
+ if current == nil {
+ return nil
+ }
+ }
+ return current
+}
+
+func schemaTypeIncludes(sch *base.Schema, schemaType string) bool {
+ return sch != nil && slices.Contains(sch.Type, schemaType)
+}
+
+func schemaArrayItems(sch *base.Schema) *base.Schema {
+ if sch == nil || sch.Items == nil || !sch.Items.IsA() || sch.Items.A == nil {
+ return nil
+ }
+ return sch.Items.A.Schema()
+}
+
+func schemaPreservesStringValue(sch *base.Schema) bool {
+ if schemaTypeIncludes(sch, String) {
+ return true
+ }
+ return schemaTypeIncludes(sch, Array) && schemaTypeIncludes(schemaArrayItems(sch), String)
+}
+
+// DeepObjectAllowsMultipleValues reports whether repeated values are allowed for a deepObject
+// property. It preserves existing top-level array/additionalProperties behavior and adds support
+// for nested properties declared as arrays.
+func DeepObjectAllowsMultipleValues(objectSchema *base.Schema, qp *QueryParam) bool {
+ if objectSchema == nil {
+ return false
+ }
+ if schemaTypeIncludes(objectSchema, Array) {
+ return true
+ }
+ propertyPath := queryParamPropertyPath(qp)
+ if schemaTypeIncludes(schemaForPropertyPath(objectSchema, propertyPath), Array) {
+ return true
+ }
+ return schemaTypeIncludes(getAdditionalPropertiesSchema(objectSchema), Array)
+}
+
+func schemaForCastingPath(objectSchema *base.Schema, propertyPath []string) *base.Schema {
+ propSchema := schemaForPropertyPath(objectSchema, propertyPath)
if propSchema != nil {
- for _, t := range propSchema.Type {
- if t == String {
- return v
+ return propSchema
+ }
+ if schemaTypeIncludes(objectSchema, Array) {
+ return objectSchema
+ }
+ return nil
+}
+
+func castWithSchemaPath(v string, objectSchema *base.Schema, propertyPath []string) any {
+ if schemaPreservesStringValue(schemaForCastingPath(objectSchema, propertyPath)) {
+ return v
+ }
+ if len(propertyPath) == 1 {
+ return castWithSchema(v, objectSchema, propertyPath[0])
+ }
+ return cast(v)
+}
+
+func deepObjectPathHasPrefix(prefix, path []string) bool {
+ if len(prefix) >= len(path) {
+ return false
+ }
+ for i := range prefix {
+ if prefix[i] != path[i] {
+ return false
+ }
+ }
+ return true
+}
+
+// DeepObjectPathConflict reports whether any deepObject property path is also used
+// as a prefix for a nested path, such as obj[nested] and obj[nested][child].
+func DeepObjectPathConflict(values []*QueryParam) (prefixParam, nestedParam *QueryParam, ok bool) {
+ for i := range values {
+ leftPath := queryParamDeepObjectPath(values[i])
+ if len(leftPath) == 0 {
+ continue
+ }
+ for j := i + 1; j < len(values); j++ {
+ rightPath := queryParamDeepObjectPath(values[j])
+ if len(rightPath) == 0 || slices.Equal(leftPath, rightPath) {
+ continue
+ }
+ if deepObjectPathHasPrefix(leftPath, rightPath) {
+ return values[i], values[j], true
+ }
+ if deepObjectPathHasPrefix(rightPath, leftPath) {
+ return values[j], values[i], true
}
}
}
- return cast(v)
+ return nil, nil, false
+}
+
+func setNestedDeepObjectValue(target map[string]interface{}, propertyPath []string, value any) bool {
+ if len(propertyPath) == 0 {
+ target[""] = value
+ return true
+ }
+ current := target
+ for _, propertyName := range propertyPath[:len(propertyPath)-1] {
+ next, ok := current[propertyName].(map[string]interface{})
+ if !ok {
+ if existing, exists := current[propertyName]; exists {
+ current[propertyName] = []interface{}{existing, value}
+ return false
+ }
+ next = make(map[string]interface{})
+ current[propertyName] = next
+ }
+ current = next
+ }
+
+ propertyName := propertyPath[len(propertyPath)-1]
+ if existing, exists := current[propertyName]; exists {
+ if _, existingIsMap := existing.(map[string]interface{}); existingIsMap {
+ if _, valueIsMap := value.(map[string]interface{}); !valueIsMap {
+ current[propertyName] = []interface{}{existing, value}
+ return false
+ }
+ }
+ }
+ current[propertyName] = value
+ return true
}
// constructKVFromDelimited is the shared implementation for constructing key=value maps
@@ -258,56 +452,26 @@ func constructParamMapFromDelimitedEncoding(values []*QueryParam, delimiter stri
func ConstructParamMapFromDeepObjectEncoding(values []*QueryParam, sch *base.Schema) map[string]interface{} {
decoded := make(map[string]interface{})
for _, v := range values {
+ propertyPath := queryParamPropertyPath(v)
castForProp := func(val string) any {
- return castWithSchema(val, sch, v.Property)
+ return castWithSchemaPath(val, sch, propertyPath)
}
- if decoded[v.Key] == nil {
- props := make(map[string]interface{})
- rawValues := make([]interface{}, len(v.Values))
- for i := range v.Values {
- rawValues[i] = castForProp(v.Values[i])
- }
- // check if the schema for the param is an array
- if sch != nil && slices.Contains(sch.Type, Array) {
- props[v.Property] = rawValues
- }
- // check if schema has additional properties defined as an array
- if sch != nil && sch.AdditionalProperties != nil &&
- sch.AdditionalProperties.IsA() {
- s := sch.AdditionalProperties.A.Schema()
- if s != nil &&
- slices.Contains(s.Type, Array) {
- props[v.Property] = rawValues
- }
- }
-
- if len(props) == 0 {
- props[v.Property] = castForProp(v.Values[0])
- }
+ props, ok := decoded[v.Key].(map[string]interface{})
+ if !ok {
+ props = make(map[string]interface{})
decoded[v.Key] = props
- } else {
- added := false
- rawValues := make([]interface{}, len(v.Values))
- for i := range v.Values {
- rawValues[i] = castForProp(v.Values[i])
- }
- // check if the schema for the param is an array
- if sch != nil && slices.Contains(sch.Type, Array) {
- decoded[v.Key].(map[string]interface{})[v.Property] = rawValues
- added = true
- }
- // check if schema has additional properties defined as an array
- if sch != nil && sch.AdditionalProperties != nil &&
- sch.AdditionalProperties.IsA() &&
- slices.Contains(sch.AdditionalProperties.A.Schema().Type, Array) {
- decoded[v.Key].(map[string]interface{})[v.Property] = rawValues
- added = true
- }
- if !added {
- decoded[v.Key].(map[string]interface{})[v.Property] = castForProp(v.Values[0])
- }
}
+
+ rawValues := make([]interface{}, len(v.Values))
+ for i := range v.Values {
+ rawValues[i] = castForProp(v.Values[i])
+ }
+ if DeepObjectAllowsMultipleValues(sch, v) {
+ setNestedDeepObjectValue(props, propertyPath, rawValues)
+ continue
+ }
+ setNestedDeepObjectValue(props, propertyPath, castForProp(v.Values[0]))
}
return decoded
}
diff --git a/vendor/github.com/pb33f/libopenapi-validator/helpers/path_finder.go b/vendor/github.com/pb33f/libopenapi-validator/helpers/path_finder.go
index 370dd6343..29155790c 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/helpers/path_finder.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/helpers/path_finder.go
@@ -27,7 +27,7 @@ func ExtractJSONPathFromValidationError(e *jsonschema.ValidationError) string {
for _, seg := range e.InstanceLocation {
switch {
case isNumeric(seg):
- b.WriteString(fmt.Sprintf("[%s]", seg))
+ fmt.Fprintf(&b, "[%s]", seg)
case isSimpleIdentifier(seg):
b.WriteByte('.')
@@ -129,7 +129,7 @@ func ExtractJSONPathFromInstanceLocation(instanceLocation []string) string {
for _, seg := range instanceLocation {
switch {
case isNumeric(seg):
- b.WriteString(fmt.Sprintf("[%s]", seg))
+ fmt.Fprintf(&b, "[%s]", seg)
case isSimpleIdentifier(seg):
b.WriteByte('.')
diff --git a/vendor/github.com/pb33f/libopenapi-validator/helpers/schema_compiler.go b/vendor/github.com/pb33f/libopenapi-validator/helpers/schema_compiler.go
index 7b6fbccf8..4c52889bb 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/helpers/schema_compiler.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/helpers/schema_compiler.go
@@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
+ "sort"
"github.com/santhosh-tekuri/jsonschema/v6"
@@ -58,29 +59,8 @@ func NewCompiledSchemaWithVersion(name string, jsonSchema []byte, options *confi
compiler := NewCompilerWithOptions(options)
compiler.UseLoader(NewCompilerLoader())
- // register OpenAPI vocabulary with appropriate version and coercion settings
- if options != nil && options.OpenAPIMode {
- var vocabVersion openapi_vocabulary.VersionType
- if version >= 3.15 { // use 3.15 to avoid floating point precision issues (3.2+)
- vocabVersion = openapi_vocabulary.Version32
- } else if version >= 3.05 { // use 3.05 to avoid floating point precision issues (3.1)
- vocabVersion = openapi_vocabulary.Version31
- } else {
- vocabVersion = openapi_vocabulary.Version30
- }
-
- vocab := openapi_vocabulary.NewOpenAPIVocabularyWithCoercion(vocabVersion, options.AllowScalarCoercion)
- compiler.RegisterVocabulary(vocab)
- compiler.AssertVocabs()
-
- if version < 3.05 {
- jsonSchema = transformOpenAPI30Schema(jsonSchema)
- }
-
- if options.AllowScalarCoercion {
- jsonSchema = transformSchemaForCoercion(jsonSchema)
- }
- }
+ configureOpenAPICompiler(compiler, options, version)
+ jsonSchema = prepareSchemaForVersion(jsonSchema, options, version)
decodedSchema, err := jsonschema.UnmarshalJSON(bytes.NewReader(jsonSchema))
if err != nil {
@@ -99,6 +79,79 @@ func NewCompiledSchemaWithVersion(name string, jsonSchema []byte, options *confi
return jsch, nil
}
+// NewCompiledSchemaResourcesWithVersion compiles a schema from named JSON Schema resources.
+// The name argument may include a fragment pointing at the schema inside one of the resources.
+func NewCompiledSchemaResourcesWithVersion(
+ name string,
+ resources map[string][]byte,
+ options *config.ValidationOptions,
+ version float32,
+) (*jsonschema.Schema, error) {
+ compiler := NewCompilerWithOptions(options)
+ compiler.UseLoader(NewCompilerLoader())
+ configureOpenAPICompiler(compiler, options, version)
+
+ resourceNames := make([]string, 0, len(resources))
+ for resourceName := range resources {
+ resourceNames = append(resourceNames, resourceName)
+ }
+ sort.Strings(resourceNames)
+
+ for _, resourceName := range resourceNames {
+ preparedSchema := prepareSchemaForVersion(resources[resourceName], options, version)
+ decodedSchema, err := jsonschema.UnmarshalJSON(bytes.NewReader(preparedSchema))
+ if err != nil {
+ return nil, fmt.Errorf("failed to unmarshal JSON schema resource %q: %w", resourceName, err)
+ }
+
+ if err = compiler.AddResource(resourceName, decodedSchema); err != nil {
+ return nil, fmt.Errorf("failed to add resource %q to schema compiler: %w", resourceName, err)
+ }
+ }
+
+ jsch, err := compiler.Compile(name)
+ if err != nil {
+ return nil, fmt.Errorf("JSON schema compile failed: %s", err.Error())
+ }
+
+ return jsch, nil
+}
+
+func configureOpenAPICompiler(compiler *jsonschema.Compiler, options *config.ValidationOptions, version float32) {
+ if options == nil || !options.OpenAPIMode {
+ return
+ }
+
+ var vocabVersion openapi_vocabulary.VersionType
+ if version >= 3.15 { // use 3.15 to avoid floating point precision issues (3.2+)
+ vocabVersion = openapi_vocabulary.Version32
+ } else if version >= 3.05 { // use 3.05 to avoid floating point precision issues (3.1)
+ vocabVersion = openapi_vocabulary.Version31
+ } else {
+ vocabVersion = openapi_vocabulary.Version30
+ }
+
+ vocab := openapi_vocabulary.NewOpenAPIVocabularyWithCoercion(vocabVersion, options.AllowScalarCoercion)
+ compiler.RegisterVocabulary(vocab)
+ compiler.AssertVocabs()
+}
+
+func prepareSchemaForVersion(jsonSchema []byte, options *config.ValidationOptions, version float32) []byte {
+ if options == nil || !options.OpenAPIMode {
+ return jsonSchema
+ }
+
+ if version < 3.05 {
+ jsonSchema = transformOpenAPI30Schema(jsonSchema)
+ }
+
+ if options.AllowScalarCoercion {
+ jsonSchema = transformSchemaForCoercion(jsonSchema)
+ }
+
+ return jsonSchema
+}
+
// transformOpenAPI30Schema transforms OpenAPI 3.0 schemas to JSON Schema 2020-12 compatible format.
// Handles OAS 3.0-specific keywords:
// - nullable: true → type array with "null"
@@ -111,11 +164,8 @@ func transformOpenAPI30Schema(jsonSchema []byte) []byte {
transformed := transformOAS30Keywords(schema)
- result, err := json.Marshal(transformed)
- if err != nil {
- return jsonSchema
- }
-
+ // json.Unmarshal only produces JSON-marshalable values here.
+ result, _ := json.Marshal(transformed)
return result
}
@@ -273,11 +323,8 @@ func transformSchemaForCoercion(jsonSchema []byte) []byte {
transformed := transformCoercionInSchema(schema)
- result, err := json.Marshal(transformed)
- if err != nil {
- return jsonSchema
- }
-
+ // json.Unmarshal only produces JSON-marshalable values here.
+ result, _ := json.Marshal(transformed)
return result
}
diff --git a/vendor/github.com/pb33f/libopenapi-validator/helpers/schema_output.go b/vendor/github.com/pb33f/libopenapi-validator/helpers/schema_output.go
new file mode 100644
index 000000000..811e1d5b1
--- /dev/null
+++ b/vendor/github.com/pb33f/libopenapi-validator/helpers/schema_output.go
@@ -0,0 +1,37 @@
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
+// SPDX-License-Identifier: MIT
+
+package helpers
+
+import "github.com/santhosh-tekuri/jsonschema/v6"
+
+// FlattenSchemaOutputErrors returns every output unit that carries an actual validation error.
+func FlattenSchemaOutputErrors(output *jsonschema.OutputUnit) []jsonschema.OutputUnit {
+ if output == nil {
+ return nil
+ }
+
+ flattened := make([]jsonschema.OutputUnit, 0, countSchemaOutputErrors(*output))
+ collectSchemaOutputErrors(*output, &flattened)
+ return flattened
+}
+
+func countSchemaOutputErrors(output jsonschema.OutputUnit) int {
+ count := 0
+ if output.Error != nil {
+ count++
+ }
+ for _, child := range output.Errors {
+ count += countSchemaOutputErrors(child)
+ }
+ return count
+}
+
+func collectSchemaOutputErrors(output jsonschema.OutputUnit, flattened *[]jsonschema.OutputUnit) {
+ if output.Error != nil {
+ *flattened = append(*flattened, output)
+ }
+ for _, child := range output.Errors {
+ collectSchemaOutputErrors(child, flattened)
+ }
+}
diff --git a/vendor/github.com/pb33f/libopenapi-validator/internal/bodycodec/compatibility.go b/vendor/github.com/pb33f/libopenapi-validator/internal/bodycodec/compatibility.go
new file mode 100644
index 000000000..4f0bc31df
--- /dev/null
+++ b/vendor/github.com/pb33f/libopenapi-validator/internal/bodycodec/compatibility.go
@@ -0,0 +1,103 @@
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
+// SPDX-License-Identifier: MIT
+
+// Package bodycodec adapts legacy schema-aware body transforms to content decoders.
+package bodycodec
+
+import (
+ "encoding/json"
+ "fmt"
+ "io"
+
+ v3 "github.com/pb33f/libopenapi/datamodel/high/v3"
+ "github.com/pb33f/libopenapi/orderedmap"
+
+ "github.com/pb33f/libopenapi-validator/config"
+ "github.com/pb33f/libopenapi-validator/content"
+ validatorerrors "github.com/pb33f/libopenapi-validator/errors"
+ "github.com/pb33f/libopenapi-validator/schema_validation"
+)
+
+// ValidationErrors carries the original structured transform errors through the decoder contract.
+type ValidationErrors struct {
+ Errors []*validatorerrors.ValidationError // Errors contains the original structured transform failures.
+}
+
+// Error returns the first structured transform error.
+func (e *ValidationErrors) Error() string {
+ if e == nil || len(e.Errors) == 0 {
+ return "body transform failed"
+ }
+ return e.Errors[0].Error()
+}
+
+// Apply replaces compatibility markers with schema-aware immutable decoder adapters.
+func Apply(options *config.ValidationOptions) {
+ if options == nil || options.BodyRegistry == nil {
+ return
+ }
+ for _, registration := range []struct {
+ mediaType string
+ kind string
+ decoder content.Decoder
+ }{
+ {"application/xml", "xml", xmlDecoder{}},
+ {"text/xml", "xml", xmlDecoder{}},
+ {"application/x-www-form-urlencoded", "form", formDecoder{}},
+ } {
+ marker, ok := options.BodyRegistry.ExactDecoder(registration.mediaType).(content.CompatibilityDecoder)
+ if ok && marker.CompatibilityKind() == registration.kind {
+ options.BodyRegistry = options.BodyRegistry.WithDecoder(registration.mediaType, registration.decoder)
+ }
+ }
+}
+
+type xmlDecoder struct{}
+
+func (xmlDecoder) Decode(input *content.DecodeInput) (any, error) {
+ body, err := readBody(input)
+ if err != nil {
+ return nil, err
+ }
+ value, validationErrors := schema_validation.TransformXMLToSchemaJSON(string(body), input.Schema)
+ if len(validationErrors) > 0 {
+ return nil, &ValidationErrors{Errors: validationErrors}
+ }
+ if _, err = json.Marshal(value); err != nil {
+ return nil, &ValidationErrors{Errors: []*validatorerrors.ValidationError{
+ validatorerrors.InvalidXMLParsing(err.Error(), string(body)),
+ }}
+ }
+ return value, nil
+}
+
+type formDecoder struct{}
+
+func (formDecoder) Decode(input *content.DecodeInput) (any, error) {
+ body, err := readBody(input)
+ if err != nil {
+ return nil, err
+ }
+ encoding, _ := input.Encoding.(*orderedmap.Map[string, *v3.Encoding])
+ value, validationErrors := schema_validation.TransformURLEncodedToSchemaJSON(string(body), input.Schema, encoding)
+ if len(validationErrors) > 0 {
+ return nil, &ValidationErrors{Errors: validationErrors}
+ }
+ if _, err = json.Marshal(value); err != nil {
+ return nil, &ValidationErrors{Errors: []*validatorerrors.ValidationError{
+ validatorerrors.InvalidURLEncodedParsing(err.Error(), string(body)),
+ }}
+ }
+ return value, nil
+}
+
+func readBody(input *content.DecodeInput) ([]byte, error) {
+ if input == nil || input.Body == nil {
+ return nil, nil
+ }
+ body, err := io.ReadAll(input.Body)
+ if err != nil {
+ return nil, fmt.Errorf("read body: %w", err)
+ }
+ return body, nil
+}
diff --git a/vendor/github.com/pb33f/libopenapi-validator/internal/requeststate/body.go b/vendor/github.com/pb33f/libopenapi-validator/internal/requeststate/body.go
new file mode 100644
index 000000000..6d34ed1e3
--- /dev/null
+++ b/vendor/github.com/pb33f/libopenapi-validator/internal/requeststate/body.go
@@ -0,0 +1,143 @@
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
+// SPDX-License-Identifier: MIT
+
+// Package requeststate owns replayable request-body snapshots shared by validation stages.
+package requeststate
+
+import (
+ "bytes"
+ "errors"
+ "io"
+ "net/http"
+ "reflect"
+)
+
+type replayableBody interface {
+ io.ReaderAt
+ Size() int64
+}
+
+type snapshotBody struct {
+ *bytes.Reader
+ bytes []byte
+}
+
+func (b *snapshotBody) Close() error { return nil }
+
+// Snapshot reads a request body once and installs replay support while leaving it readable.
+func Snapshot(request *http.Request) ([]byte, error) {
+ if request == nil {
+ return nil, nil
+ }
+ if request.Body == nil {
+ if request.GetBody == nil {
+ return nil, nil
+ }
+ replay, err := request.GetBody()
+ if err != nil {
+ return nil, err
+ }
+ if replay == nil {
+ return nil, nil
+ }
+ body, readErr := io.ReadAll(replay)
+ _ = replay.Close()
+ if readErr != nil {
+ return nil, readErr
+ }
+ Install(request, body)
+ return body, nil
+ }
+ if request.Body == http.NoBody {
+ return nil, nil
+ }
+ if snapshot, ok := request.Body.(*snapshotBody); ok {
+ return append([]byte(nil), snapshot.bytes...), nil
+ }
+ var prior []byte
+ if replayable, ok := underlyingReader(request.Body).(replayableBody); ok && replayable.Size() > 0 {
+ var err error
+ prior, err = io.ReadAll(io.NewSectionReader(replayable, 0, replayable.Size()))
+ if err != nil {
+ prior = nil
+ }
+ }
+ body, err := io.ReadAll(request.Body)
+ _ = request.Body.Close()
+ if err != nil {
+ return nil, err
+ }
+ if len(body) == 0 && len(prior) > 0 && request.GetBody != nil {
+ replay, replayErr := request.GetBody()
+ if replayErr == nil && replay != nil {
+ replayed, readErr := io.ReadAll(replay)
+ _ = replay.Close()
+ if readErr == nil && bytes.Equal(replayed, prior) {
+ body = replayed
+ }
+ }
+ }
+ Install(request, body)
+ return body, nil
+}
+
+func underlyingReader(body io.ReadCloser) io.Reader {
+ value := reflect.ValueOf(body)
+ if value.Kind() == reflect.Pointer {
+ if value.IsNil() {
+ return nil
+ }
+ value = value.Elem()
+ }
+ if value.Kind() == reflect.Struct {
+ field := value.FieldByName("Reader")
+ if field.IsValid() && field.CanInterface() {
+ if reader, ok := field.Interface().(io.Reader); ok {
+ return reader
+ }
+ }
+ }
+ return body
+}
+
+// Install replaces a request body with an immutable replayable snapshot.
+func Install(request *http.Request, body []byte) {
+ if request == nil {
+ return
+ }
+ snapshot := append([]byte(nil), body...)
+ request.Body = &snapshotBody{Reader: bytes.NewReader(snapshot), bytes: snapshot}
+ request.ContentLength = int64(len(snapshot))
+ request.GetBody = func() (io.ReadCloser, error) {
+ return &snapshotBody{Reader: bytes.NewReader(snapshot), bytes: snapshot}, nil
+ }
+}
+
+// WithFreshBody gives a callback an independent reader and restores a fresh reader afterward.
+func WithFreshBody(request *http.Request, callback func() error) error {
+ if request == nil || request.Body == nil || request.Body == http.NoBody {
+ return callback()
+ }
+ if request.GetBody == nil {
+ if _, err := Snapshot(request); err != nil {
+ return err
+ }
+ }
+ getBody := request.GetBody
+ body, err := getBody()
+ if err != nil {
+ return err
+ }
+ request.Body = body
+ callbackErr := callback()
+ if request.Body != nil {
+ _ = request.Body.Close()
+ }
+ restored, restoreErr := getBody()
+ request.GetBody = getBody
+ if restoreErr != nil {
+ return errors.Join(callbackErr, restoreErr)
+ }
+ request.Body = restored
+ return callbackErr
+}
diff --git a/vendor/github.com/pb33f/libopenapi-validator/internal/requeststate/route.go b/vendor/github.com/pb33f/libopenapi-validator/internal/requeststate/route.go
new file mode 100644
index 000000000..e46f25fde
--- /dev/null
+++ b/vendor/github.com/pb33f/libopenapi-validator/internal/requeststate/route.go
@@ -0,0 +1,39 @@
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
+// SPDX-License-Identifier: MIT
+
+package requeststate
+
+import (
+ "context"
+ "net/http"
+
+ "github.com/pb33f/libopenapi-validator/router"
+)
+
+type routeContextKey struct{}
+
+// Route returns the route scoped to the current high-level validation call.
+func Route(request *http.Request) *router.Route {
+ if request == nil {
+ return nil
+ }
+ route, _ := request.Context().Value(routeContextKey{}).(*router.Route)
+ return route
+}
+
+// AttachRoute scopes a resolved route to a request and returns an idempotent restoration function.
+func AttachRoute(request *http.Request, route *router.Route) func() {
+ if request == nil || route == nil {
+ return func() {}
+ }
+ original := request.Context()
+ *request = *request.WithContext(context.WithValue(original, routeContextKey{}, route))
+ restored := false
+ return func() {
+ if restored {
+ return
+ }
+ restored = true
+ *request = *request.WithContext(original)
+ }
+}
diff --git a/vendor/github.com/pb33f/libopenapi-validator/parameters/content_parameter.go b/vendor/github.com/pb33f/libopenapi-validator/parameters/content_parameter.go
new file mode 100644
index 000000000..6133fc5e4
--- /dev/null
+++ b/vendor/github.com/pb33f/libopenapi-validator/parameters/content_parameter.go
@@ -0,0 +1,167 @@
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
+// SPDX-License-Identifier: MIT
+
+package parameters
+
+import (
+ "encoding/json"
+ "fmt"
+ "net/http"
+ "net/url"
+ "strings"
+
+ "github.com/pb33f/libopenapi/datamodel/high/base"
+ "github.com/pb33f/libopenapi/orderedmap"
+
+ v3 "github.com/pb33f/libopenapi/datamodel/high/v3"
+
+ "github.com/pb33f/libopenapi-validator/config"
+ "github.com/pb33f/libopenapi-validator/errors"
+ "github.com/pb33f/libopenapi-validator/helpers"
+ "github.com/pb33f/libopenapi-validator/internal/requeststate"
+)
+
+func (v *paramValidator) validateContentParameters(request *http.Request, pathItem *v3.PathItem, pathValue, location string) []*errors.ValidationError {
+ if v.options == nil || (location == helpers.Query && v.options.ContentParameterDecoder == nil) ||
+ (location != helpers.Query && !v.options.ValidateContentParameters) {
+ return nil
+ }
+ params := helpers.ExtractParamsForOperation(request, pathItem)
+ var validationErrors []*errors.ValidationError
+ var pathParams, serverParams map[string]string
+ routeResolved := false
+ for _, parameter := range params {
+ if parameter == nil || parameter.In != location || parameter.Schema != nil || parameter.Content == nil || orderedmap.Len(parameter.Content) == 0 {
+ continue
+ }
+ if v.options.ContentParameterDecoder != nil && !routeResolved {
+ pathParams, serverParams = v.routeParameters(request)
+ routeResolved = true
+ }
+ raw := rawParameterValues(request, parameter, pathValue, pathParams)
+ if len(raw) == 0 {
+ if parameter.Required != nil && *parameter.Required {
+ validationErrors = append(validationErrors, contentParameterError(parameter, location, "required parameter is missing"))
+ }
+ continue
+ }
+ entry := orderedmap.First(parameter.Content)
+ mediaType := entry.Key()
+ media := entry.Value()
+ var schema *base.Schema
+ if media != nil && media.Schema != nil {
+ schema = media.Schema.Schema()
+ }
+ input := &config.ContentParameterInput{
+ Parameter: parameter, RawValues: raw, MediaType: mediaType, DefaultSchema: schema,
+ Request: request, PathParams: pathParams, ServerVariables: serverParams,
+ }
+ var value any
+ var decodeErr error
+ if v.options.ContentParameterDecoder != nil {
+ value, schema, decodeErr = v.options.ContentParameterDecoder(request.Context(), input)
+ } else if strings.EqualFold(mediaType, helpers.JSONContentType) || strings.HasSuffix(strings.ToLower(mediaType), "+json") {
+ decodeErr = json.Unmarshal([]byte(raw[0]), &value)
+ } else {
+ decodeErr = fmt.Errorf("no content-parameter decoder is registered for %s", mediaType)
+ }
+ if decodeErr != nil {
+ validationErrors = append(validationErrors, contentParameterError(parameter, location, decodeErr.Error()))
+ continue
+ }
+ if schema == nil || schema.GoLow() == nil {
+ validationErrors = append(validationErrors, contentParameterError(parameter, location, "decoded parameter schema has no low-level render identity"))
+ continue
+ }
+ validationErrors = append(validationErrors, ValidateSingleParameterSchema(
+ schema, value, parameterLocationLabel(location)+" parameter", "The "+location+" parameter", parameter.Name,
+ helpers.ParameterValidation, parameterSubtype(location), v.options, pathValue, strings.ToLower(request.Method),
+ )...)
+ }
+ errors.PopulateValidationErrors(validationErrors, request, pathValue)
+ return validationErrors
+}
+
+func parameterLocationLabel(location string) string {
+ if location == "" {
+ return ""
+ }
+ return strings.ToUpper(location[:1]) + location[1:]
+}
+
+func (v *paramValidator) routeParameters(request *http.Request) (map[string]string, map[string]string) {
+ if route := requeststate.Route(request); route != nil {
+ return route.PathParams, route.ServerParams
+ }
+ if v.options != nil && v.options.Router != nil {
+ if route, err := v.options.Router.FindRoute(request); err == nil && route != nil {
+ return route.PathParams, route.ServerParams
+ }
+ }
+ return nil, nil
+}
+
+func rawParameterValues(request *http.Request, parameter *v3.Parameter, pathValue string, routeParams map[string]string) []string {
+ switch parameter.In {
+ case helpers.Query:
+ return request.URL.Query()[parameter.Name]
+ case helpers.Header:
+ return request.Header.Values(parameter.Name)
+ case helpers.Cookie:
+ if cookie, err := request.Cookie(parameter.Name); err == nil {
+ return []string{cookie.Value}
+ }
+ case helpers.Path:
+ if value, ok := routeParams[parameter.Name]; ok {
+ return []string{value}
+ }
+ return pathParameterValues(request.URL.EscapedPath(), pathValue, parameter.Name)
+ }
+ return nil
+}
+
+func pathParameterValues(requestPath, template, target string) []string {
+ expression, err := helpers.GetRegexForPath(template)
+ if err != nil {
+ return nil
+ }
+ matches := expression.FindStringSubmatch(requestPath)
+ indices, err := helpers.BraceIndices(template)
+ if err != nil || len(matches) != len(indices)/2+1 {
+ return nil
+ }
+ for i := 0; i < len(indices); i += 2 {
+ name := template[indices[i]+1 : indices[i+1]-1]
+ name = strings.TrimSuffix(strings.TrimLeft(strings.SplitN(name, ":", 2)[0], ".;"), "*")
+ if name == target {
+ value, err := url.PathUnescape(matches[i/2+1])
+ if err != nil {
+ value = matches[i/2+1]
+ }
+ return []string{value}
+ }
+ }
+ return nil
+}
+
+func contentParameterError(parameter *v3.Parameter, location, reason string) *errors.ValidationError {
+ return &errors.ValidationError{
+ ValidationType: helpers.ParameterValidation, ValidationSubType: parameterSubtype(location),
+ ParameterName: parameter.Name, Message: fmt.Sprintf("%s parameter '%s' could not be decoded", location, parameter.Name),
+ Reason: reason, HowToFix: errors.HowToFixDecodingError, Context: parameter,
+ }
+}
+
+func parameterSubtype(location string) string {
+ switch location {
+ case helpers.Query:
+ return helpers.ParameterValidationQuery
+ case helpers.Header:
+ return helpers.ParameterValidationHeader
+ case helpers.Cookie:
+ return helpers.ParameterValidationCookie
+ case helpers.Path:
+ return helpers.ParameterValidationPath
+ }
+ return helpers.ParameterValidation
+}
diff --git a/vendor/github.com/pb33f/libopenapi-validator/parameters/cookie_parameters.go b/vendor/github.com/pb33f/libopenapi-validator/parameters/cookie_parameters.go
index 46d7a2abb..add208c29 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/parameters/cookie_parameters.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/parameters/cookie_parameters.go
@@ -1,10 +1,9 @@
-// Copyright 2023-2025 Princess Beef Heavy Industries, LLC / Dave Shanley
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
// SPDX-License-Identifier: MIT
package parameters
import (
- "encoding/json"
"fmt"
"net/http"
"strconv"
@@ -44,7 +43,7 @@ func (v *paramValidator) ValidateCookieParamsWithPathItem(request *http.Request,
}
// extract params for the operation
params := helpers.ExtractParamsForOperation(request, pathItem)
- var validationErrors []*errors.ValidationError
+ validationErrors := v.validateContentParameters(request, pathItem, pathValue, helpers.Cookie)
operation := strings.ToLower(request.Method)
// build a map of cookies from the request for efficient lookup
@@ -54,7 +53,7 @@ func (v *paramValidator) ValidateCookieParamsWithPathItem(request *http.Request,
}
for _, p := range params {
- if p.In == helpers.Cookie {
+ if p.In == helpers.Cookie && p.Schema != nil {
// look up the cookie by name (cookies are case-sensitive)
cookie, found := cookieMap[p.Name]
if !found {
@@ -70,13 +69,8 @@ func (v *paramValidator) ValidateCookieParamsWithPathItem(request *http.Request,
sch = p.Schema.Schema()
}
- // Render schema once for ReferenceSchema field in errors
- var renderedSchema string
- if sch != nil {
- rendered, _ := sch.RenderInline()
- schemaBytes, _ := json.Marshal(rendered)
- renderedSchema = string(schemaBytes)
- }
+ // Get rendered schema for ReferenceSchema field in errors (uses cache if available)
+ renderedSchema := GetRenderedSchema(sch, v.options)
pType := sch.Type
diff --git a/vendor/github.com/pb33f/libopenapi-validator/parameters/header_parameters.go b/vendor/github.com/pb33f/libopenapi-validator/parameters/header_parameters.go
index a924f754b..9dea41da2 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/parameters/header_parameters.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/parameters/header_parameters.go
@@ -1,10 +1,9 @@
-// Copyright 2023 Princess B33f Heavy Industries / Dave Shanley
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
// SPDX-License-Identifier: MIT
package parameters
import (
- "encoding/json"
"fmt"
"net/http"
"strconv"
@@ -46,13 +45,16 @@ func (v *paramValidator) ValidateHeaderParamsWithPathItem(request *http.Request,
// extract params for the operation
params := helpers.ExtractParamsForOperation(request, pathItem)
- var validationErrors []*errors.ValidationError
+ validationErrors := v.validateContentParameters(request, pathItem, pathValue, helpers.Header)
seenHeaders := make(map[string]bool)
operation := strings.ToLower(request.Method)
for _, p := range params {
if p.In == helpers.Header {
seenHeaders[strings.ToLower(p.Name)] = true
+ if p.Schema == nil {
+ continue
+ }
if param := request.Header.Get(p.Name); param != "" {
var sch *base.Schema
@@ -60,13 +62,8 @@ func (v *paramValidator) ValidateHeaderParamsWithPathItem(request *http.Request,
sch = p.Schema.Schema()
}
- // Render schema once for ReferenceSchema field in errors
- var renderedSchema string
- if sch != nil {
- rendered, _ := sch.RenderInline()
- schemaBytes, _ := json.Marshal(rendered)
- renderedSchema = string(schemaBytes)
- }
+ // Get rendered schema for ReferenceSchema field in errors (uses cache if available)
+ renderedSchema := GetRenderedSchema(sch, v.options)
pType := sch.Type
@@ -204,15 +201,10 @@ func (v *paramValidator) ValidateHeaderParamsWithPathItem(request *http.Request,
}
} else {
if p.Required != nil && *p.Required {
- // Render schema for missing required parameter
+ // Get rendered schema for missing required parameter (uses cache if available)
var renderedSchema string
if p.Schema != nil {
- sch := p.Schema.Schema()
- if sch != nil {
- rendered, _ := sch.RenderInline()
- schemaBytes, _ := json.Marshal(rendered)
- renderedSchema = string(schemaBytes)
- }
+ renderedSchema = GetRenderedSchema(p.Schema.Schema(), v.options)
}
validationErrors = append(validationErrors, errors.HeaderParameterMissing(p, pathValue, operation, renderedSchema))
}
diff --git a/vendor/github.com/pb33f/libopenapi-validator/parameters/parameters.go b/vendor/github.com/pb33f/libopenapi-validator/parameters/parameters.go
index 2fa168a14..db57cfa3c 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/parameters/parameters.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/parameters/parameters.go
@@ -1,4 +1,4 @@
-// Copyright 2023 Princess B33f Heavy Industries / Dave Shanley
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
// SPDX-License-Identifier: MIT
package parameters
@@ -64,6 +64,9 @@ type ParameterValidator interface {
// ValidateSecurityWithPathItem validates the security requirements for the operation. It returns a boolean stating true
// if validation passed (false for failed), and a slice of errors if validation failed.
ValidateSecurityWithPathItem(request *http.Request, pathItem *v3.PathItem, pathValue string) (bool, []*errors.ValidationError)
+
+ // Release clears validator-owned options and drops the OpenAPI document reference.
+ Release()
}
// NewParameterValidator will create a new ParameterValidator from an OpenAPI 3+ document
@@ -77,3 +80,14 @@ type paramValidator struct {
options *config.ValidationOptions
document *v3.Document
}
+
+func (p *paramValidator) Release() {
+ if p == nil {
+ return
+ }
+ if p.options != nil {
+ p.options.Release()
+ p.options = nil
+ }
+ p.document = nil
+}
diff --git a/vendor/github.com/pb33f/libopenapi-validator/parameters/path_parameters.go b/vendor/github.com/pb33f/libopenapi-validator/parameters/path_parameters.go
index bf7005cd6..e295badb2 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/parameters/path_parameters.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/parameters/path_parameters.go
@@ -1,10 +1,9 @@
-// Copyright 2023 Princess B33f Heavy Industries / Dave Shanley
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
// SPDX-License-Identifier: MIT
package parameters
import (
- "encoding/json"
"fmt"
"net/http"
"net/url"
@@ -52,9 +51,9 @@ func (v *paramValidator) ValidatePathParamsWithPathItem(request *http.Request, p
// extract params for the operation
params := helpers.ExtractParamsForOperation(request, pathItem)
- var validationErrors []*errors.ValidationError
+ validationErrors := v.validateContentParameters(request, pathItem, pathValue, helpers.Path)
for _, p := range params {
- if p.In == helpers.Path {
+ if p.In == helpers.Path && p.Schema != nil {
// var paramTemplate string
for x := range pathSegments {
if pathSegments[x] == "" { // skip empty segments
@@ -142,13 +141,8 @@ func (v *paramValidator) ValidatePathParamsWithPathItem(request *http.Request, p
// extract the schema from the parameter
sch := p.Schema.Schema()
- // Render schema once for ReferenceSchema field in errors
- var renderedSchema string
- if sch != nil {
- rendered, _ := sch.RenderInline()
- schemaBytes, _ := json.Marshal(rendered)
- renderedSchema = string(schemaBytes)
- }
+ // Get rendered schema for ReferenceSchema field in errors (uses cache if available)
+ renderedSchema := GetRenderedSchema(sch, v.options)
// check enum (if present)
enumCheck := func(decodedValue string) {
@@ -309,13 +303,8 @@ func (v *paramValidator) ValidatePathParamsWithPathItem(request *http.Request, p
if sch.Items != nil && sch.Items.IsA() {
iSch := sch.Items.A.Schema()
- // Render items schema once for ReferenceSchema field in array errors
- var renderedItemsSchema string
- if iSch != nil {
- rendered, _ := iSch.RenderInline()
- schemaBytes, _ := json.Marshal(rendered)
- renderedItemsSchema = string(schemaBytes)
- }
+ // Get rendered items schema for ReferenceSchema field in errors (uses cache if available)
+ renderedItemsSchema := GetRenderedSchema(iSch, v.options)
for n := range iSch.Type {
// determine how to explode the array
diff --git a/vendor/github.com/pb33f/libopenapi-validator/parameters/query_parameters.go b/vendor/github.com/pb33f/libopenapi-validator/parameters/query_parameters.go
index 40074d436..1c8086e4f 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/parameters/query_parameters.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/parameters/query_parameters.go
@@ -1,4 +1,4 @@
-// Copyright 2023-2025 Princess Beef Heavy Industries, LLC / Dave Shanley
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
// SPDX-License-Identifier: MIT
package parameters
@@ -51,7 +51,7 @@ func (v *paramValidator) ValidateQueryParamsWithPathItem(request *http.Request,
// extract params for the operation
params := helpers.ExtractParamsForOperation(request, pathItem)
queryParams := make(map[string][]*helpers.QueryParam)
- var validationErrors []*errors.ValidationError
+ validationErrors := v.validateContentParameters(request, pathItem, pathValue, helpers.Query)
// build a set of spec parameter names for exact matching
specParamNames := make(map[string]bool)
@@ -69,14 +69,13 @@ func (v *paramValidator) ValidateQueryParamsWithPathItem(request *http.Request,
Key: qKey,
Values: qVal,
})
- } else if strings.IndexRune(qKey, '[') > 0 && strings.IndexRune(qKey, ']') > 0 {
+ } else if stripped, propertyPath, ok := helpers.ParseDeepObjectKey(qKey); ok {
// check if the param is encoded as a property / deepObject
- stripped := qKey[:strings.IndexRune(qKey, '[')]
- value := qKey[strings.IndexRune(qKey, '[')+1 : strings.IndexRune(qKey, ']')]
queryParams[stripped] = append(queryParams[stripped], &helpers.QueryParam{
- Key: stripped,
- Values: qVal,
- Property: value,
+ Key: stripped,
+ Values: qVal,
+ Property: propertyPath[0],
+ PropertyPath: propertyPath,
})
} else {
queryParams[qKey] = append(queryParams[qKey], &helpers.QueryParam{
@@ -92,7 +91,7 @@ func (v *paramValidator) ValidateQueryParamsWithPathItem(request *http.Request,
// look through the params for the query key
doneLooking:
for p := range params {
- if params[p].In == helpers.Query {
+ if params[p].In == helpers.Query && (params[p].Schema != nil || (params[p].Content != nil && v.options.ContentParameterDecoder == nil)) {
contentWrapped := false
var contentType string
@@ -121,13 +120,8 @@ doneLooking:
}
}
- // Render schema once for ReferenceSchema field in errors
- var renderedSchema string
- if sch != nil {
- rendered, _ := sch.RenderInline()
- schemaBytes, _ := json.Marshal(rendered)
- renderedSchema = string(schemaBytes)
- }
+ // Get rendered schema for ReferenceSchema field in errors (uses cache if available)
+ renderedSchema := GetRenderedSchema(sch, v.options)
pType := sch.Type
@@ -263,12 +257,8 @@ doneLooking:
break
}
}
- var renderedSchema string
- if sch != nil {
- rendered, _ := sch.RenderInline()
- schemaBytes, _ := json.Marshal(rendered)
- renderedSchema = string(schemaBytes)
- }
+ // Get rendered schema for ReferenceSchema field in errors (uses cache if available)
+ renderedSchema := GetRenderedSchema(sch, v.options)
validationErrors = append(validationErrors, errors.QueryParameterMissing(params[p], pathValue, operation, renderedSchema))
}
}
diff --git a/vendor/github.com/pb33f/libopenapi-validator/parameters/validate_parameter.go b/vendor/github.com/pb33f/libopenapi-validator/parameters/validate_parameter.go
index 1b7de9caf..816f71aff 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/parameters/validate_parameter.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/parameters/validate_parameter.go
@@ -1,4 +1,4 @@
-// Copyright 2023 Princess B33f Heavy Industries / Dave Shanley
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
// SPDX-License-Identifier: MIT
package parameters
@@ -11,7 +11,6 @@ import (
"strings"
"github.com/pb33f/libopenapi/datamodel/high/base"
- "github.com/pb33f/libopenapi/utils"
"github.com/santhosh-tekuri/jsonschema/v6"
"golang.org/x/text/language"
"golang.org/x/text/message"
@@ -21,8 +20,11 @@ import (
"github.com/pb33f/libopenapi-validator/config"
"github.com/pb33f/libopenapi-validator/errors"
"github.com/pb33f/libopenapi-validator/helpers"
+ "github.com/pb33f/libopenapi-validator/schema_validation"
)
+const parameterSchemaVersion = 3.1
+
func ValidateSingleParameterSchema(
schema *base.Schema,
rawObject any,
@@ -35,15 +37,10 @@ func ValidateSingleParameterSchema(
pathTemplate string,
operation string,
) (validationErrors []*errors.ValidationError) {
- // Get the JSON Schema for the parameter definition.
- jsonSchema, err := buildJsonRender(schema)
- if err != nil {
- return validationErrors
- }
-
- // Attempt to compile the JSON Schema
- jsch, err := helpers.NewCompiledSchema(name, jsonSchema, o)
- if err != nil {
+ jsch, referenceSchema, validationErrors := compileParameterValidationSchema(
+ schema, o, entity, reasonEntity, name, validationType, subValType,
+ )
+ if jsch == nil || len(validationErrors) > 0 {
return validationErrors
}
@@ -51,24 +48,34 @@ func ValidateSingleParameterSchema(
scErrs := jsch.Validate(rawObject)
var werras *jsonschema.ValidationError
if stdError.As(scErrs, &werras) {
- validationErrors = formatJsonSchemaValidationError(schema, werras, entity, reasonEntity, name, validationType, subValType, pathTemplate, operation)
+ validationErrors = formatJsonSchemaValidationError(
+ schema, werras, entity, reasonEntity, name,
+ validationType, subValType, pathTemplate, operation, referenceSchema,
+ )
}
return validationErrors
}
-// buildJsonRender build a JSON render of the schema.
-func buildJsonRender(schema *base.Schema) ([]byte, error) {
+// GetRenderedSchema returns a YAML string representation of the schema for error messages.
+// It first checks the schema cache for a pre-rendered version, falling back to fresh rendering.
+// This avoids expensive re-rendering on each validation when the cache is available.
+func GetRenderedSchema(schema *base.Schema, opts *config.ValidationOptions) string {
if schema == nil {
- // Sanity Check
- return nil, stdError.New("buildJSONRender nil pointer")
+ return ""
}
- renderedSchema, err := schema.Render()
- if err != nil {
- return nil, err
+ // Try cache lookup first
+ if opts != nil && opts.SchemaCache != nil && schema.GoLow() != nil {
+ hash := schema.GoLow().Hash()
+ if cached, ok := opts.SchemaCache.Load(hash); ok && cached != nil && len(cached.RenderedInline) > 0 {
+ return string(cached.RenderedInline)
+ }
}
- return utils.ConvertYAMLtoJSON(renderedSchema)
+ // Cache miss - render fresh as YAML using validation mode
+ renderCtx := base.NewInlineRenderContextForValidation()
+ rendered, _ := schema.RenderInlineWithContext(renderCtx)
+ return string(rendered)
}
// ValidateParameterSchema will validate a parameter against a raw object, or a blob of json/yaml.
@@ -94,13 +101,14 @@ func ValidateParameterSchema(
validationOptions *config.ValidationOptions,
) []*errors.ValidationError {
var validationErrors []*errors.ValidationError
+ jsch, referenceSchema, validationErrors := compileParameterValidationSchema(
+ schema, validationOptions, entity, reasonEntity, name, validationType, subValType,
+ )
+ if jsch == nil || len(validationErrors) > 0 {
+ return validationErrors
+ }
- // 1. build a JSON render of the schema.
- renderCtx := base.NewInlineRenderContextForValidation()
- renderedSchema, _ := schema.RenderInlineWithContext(renderCtx)
- jsonSchema, _ := utils.ConvertYAMLtoJSON(renderedSchema)
-
- // 2. decode the object into a json blob.
+ // 3. decode the object into a json blob.
var decodedObj interface{}
rawIsMap := false
validEncoding := false
@@ -125,24 +133,6 @@ func ValidateParameterSchema(
}
validEncoding = true
}
- // 3. create a new json schema compiler and add the schema to it
- jsch, err := helpers.NewCompiledSchema(name, jsonSchema, validationOptions)
- if err != nil {
- // schema compilation failed, return validation error instead of panicking
- validationErrors = append(validationErrors, &errors.ValidationError{
- ValidationType: validationType,
- ValidationSubType: subValType,
- Message: fmt.Sprintf("%s '%s' failed schema compilation", entity, name),
- Reason: fmt.Sprintf("%s '%s' schema compilation failed: %s",
- reasonEntity, name, err.Error()),
- SpecLine: 1,
- SpecCol: 0,
- ParameterName: name,
- HowToFix: "check the parameter schema for invalid JSON Schema syntax, complex regex patterns, or unsupported schema constructs",
- Context: string(jsonSchema),
- })
- return validationErrors
- }
// 4. validate the object against the schema
var scErrs error
@@ -185,7 +175,10 @@ func ValidateParameterSchema(
}
var werras *jsonschema.ValidationError
if stdError.As(scErrs, &werras) {
- validationErrors = formatJsonSchemaValidationError(schema, werras, entity, reasonEntity, name, validationType, subValType, "", "")
+ validationErrors = formatJsonSchemaValidationError(
+ schema, werras, entity, reasonEntity, name,
+ validationType, subValType, "", "", referenceSchema,
+ )
}
// if there are no validationErrors, check that the supplied value is even JSON
@@ -209,9 +202,90 @@ func ValidateParameterSchema(
return validationErrors
}
-func formatJsonSchemaValidationError(schema *base.Schema, scErrs *jsonschema.ValidationError, entity string, reasonEntity string, name string, validationType string, subValType string, pathTemplate string, operation string) (validationErrors []*errors.ValidationError) {
+func compileParameterValidationSchema(
+ schema *base.Schema,
+ validationOptions *config.ValidationOptions,
+ entity string,
+ reasonEntity string,
+ name string,
+ validationType string,
+ subValType string,
+) (*jsonschema.Schema, string, []*errors.ValidationError) {
+ if validationOptions != nil && validationOptions.SchemaCache != nil && schema != nil && schema.GoLow() != nil {
+ hash := schema_validation.SchemaCacheKey(
+ schema.GoLow().Hash(),
+ parameterSchemaVersion,
+ schema_validation.SchemaValidationPurposeGeneric,
+ )
+ if cached, ok := validationOptions.SchemaCache.Load(hash); ok && cached != nil && cached.CompiledSchema != nil {
+ return cached.CompiledSchema, cached.ReferenceSchema, nil
+ }
+ }
+
+ compiled, err := schema_validation.CompileSchemaForValidation(
+ schema,
+ schema_validation.SchemaValidationPurposeGeneric,
+ validationOptions,
+ parameterSchemaVersion,
+ )
+ if err != nil {
+ return nil, "", []*errors.ValidationError{
+ parameterSchemaCompilationError(schema, err, entity, reasonEntity, name, validationType, subValType),
+ }
+ }
+ if compiled == nil || compiled.CompiledSchema == nil {
+ return nil, "", nil
+ }
+
+ if validationOptions != nil && validationOptions.SchemaCache != nil && schema != nil && schema.GoLow() != nil {
+ hash := schema_validation.SchemaCacheKey(
+ schema.GoLow().Hash(),
+ parameterSchemaVersion,
+ schema_validation.SchemaValidationPurposeGeneric,
+ )
+ validationOptions.SchemaCache.Store(hash, compiled.ToCacheEntry(schema))
+ }
+
+ return compiled.CompiledSchema, compiled.ReferenceSchema, nil
+}
+
+func parameterSchemaCompilationError(
+ schema *base.Schema,
+ err error,
+ entity string,
+ reasonEntity string,
+ name string,
+ validationType string,
+ subValType string,
+) *errors.ValidationError {
+ return &errors.ValidationError{
+ ValidationType: validationType,
+ ValidationSubType: subValType,
+ Message: fmt.Sprintf("%s '%s' failed schema compilation", entity, name),
+ Reason: fmt.Sprintf("%s '%s' schema compilation failed: %s",
+ reasonEntity, name, err.Error()),
+ SpecLine: 1,
+ SpecCol: 0,
+ ParameterName: name,
+ HowToFix: "check the parameter schema for invalid JSON Schema syntax, complex regex patterns, or unsupported schema constructs",
+ Context: schema,
+ }
+}
+
+func formatJsonSchemaValidationError(
+ schema *base.Schema,
+ scErrs *jsonschema.ValidationError,
+ entity string,
+ reasonEntity string,
+ name string,
+ validationType string,
+ subValType string,
+ pathTemplate string,
+ operation string,
+ referenceSchema string,
+) (validationErrors []*errors.ValidationError) {
// flatten the validationErrors
- schFlatErrs := scErrs.BasicOutput().Errors
+ schFlatErrs := helpers.FlattenSchemaOutputErrors(scErrs.DetailedOutput())
var schemaValidationErrors []*errors.SchemaValidationFailure
for q := range schFlatErrs {
er := schFlatErrs[q]
@@ -237,12 +311,13 @@ func formatJsonSchemaValidationError(schema *base.Schema, scErrs *jsonschema.Val
KeywordLocation: keywordLocation,
OriginalJsonSchemaError: scErrs,
}
- if schema != nil {
+ if referenceSchema != "" {
+ fail.ReferenceSchema = referenceSchema
+ } else if schema != nil {
renderCtx := base.NewInlineRenderContextForValidation()
rendered, err := schema.RenderInlineWithContext(renderCtx)
if err == nil && rendered != nil {
- renderedBytes, _ := json.Marshal(rendered)
- fail.ReferenceSchema = string(renderedBytes)
+ fail.ReferenceSchema = string(rendered)
}
}
schemaValidationErrors = append(schemaValidationErrors, fail)
diff --git a/vendor/github.com/pb33f/libopenapi-validator/parameters/validate_security.go b/vendor/github.com/pb33f/libopenapi-validator/parameters/validate_security.go
index de4f5b6ab..3d36f07a9 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/parameters/validate_security.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/parameters/validate_security.go
@@ -9,11 +9,14 @@ import (
"strings"
"github.com/pb33f/libopenapi/datamodel/high/base"
- v3 "github.com/pb33f/libopenapi/datamodel/high/v3"
"github.com/pb33f/libopenapi/orderedmap"
+ v3 "github.com/pb33f/libopenapi/datamodel/high/v3"
+
+ "github.com/pb33f/libopenapi-validator/config"
"github.com/pb33f/libopenapi-validator/errors"
"github.com/pb33f/libopenapi-validator/helpers"
+ "github.com/pb33f/libopenapi-validator/internal/requeststate"
"github.com/pb33f/libopenapi-validator/paths"
)
@@ -84,7 +87,7 @@ func (v *paramValidator) ValidateSecurityWithPathItem(request *http.Request, pat
}
secScheme := v.document.Components.SecuritySchemes.GetOrZero(secName)
- schemeValid, schemeErrors := v.validateSecurityScheme(secScheme, sec, request, pathValue)
+ schemeValid, schemeErrors := v.validateSecurityScheme(secName, secScheme, pair.Value(), sec, request, pathValue, pathItem)
if !schemeValid {
requirementSatisfied = false
requirementErrors = append(requirementErrors, schemeErrors...)
@@ -103,11 +106,18 @@ func (v *paramValidator) ValidateSecurityWithPathItem(request *http.Request, pat
// validateSecurityScheme checks if a single security scheme is satisfied by the request.
func (v *paramValidator) validateSecurityScheme(
+ secName string,
secScheme *v3.SecurityScheme,
+ scopes []string,
sec *base.SecurityRequirement,
request *http.Request,
pathValue string,
+ pathItem *v3.PathItem,
) (bool, []*errors.ValidationError) {
+ if v.options.AuthenticationFunc != nil {
+ return v.validateAuthenticationFunc(secName, secScheme, scopes, sec, request, pathValue, pathItem)
+ }
+
switch strings.ToLower(secScheme.Type) {
case "http":
return v.validateHTTPSecurityScheme(secScheme, sec, request, pathValue)
@@ -118,6 +128,63 @@ func (v *paramValidator) validateSecurityScheme(
return true, nil
}
+func (v *paramValidator) validateAuthenticationFunc(
+ secName string,
+ secScheme *v3.SecurityScheme,
+ scopes []string,
+ sec *base.SecurityRequirement,
+ request *http.Request,
+ pathValue string,
+ pathItem *v3.PathItem,
+) (bool, []*errors.ValidationError) {
+ input := &config.AuthenticationInput{
+ Request: request,
+ SecuritySchemeName: secName,
+ SecurityScheme: secScheme,
+ Scopes: scopes,
+ Path: pathValue,
+ PathItem: pathItem,
+ }
+ input.Operation = helpers.ExtractOperation(request, input.PathItem)
+ if route := requeststate.Route(request); route != nil {
+ input.Path = route.Path
+ input.PathItem = route.PathItem
+ input.Operation = route.Operation
+ input.PathParams = route.PathParams
+ input.Server = route.Server
+ input.ServerParams = route.ServerParams
+ } else if v.options.Router != nil {
+ if route, err := v.options.Router.FindRoute(request); err == nil && route != nil {
+ input.Path = route.Path
+ input.PathItem = route.PathItem
+ input.Operation = route.Operation
+ input.PathParams = route.PathParams
+ input.Server = route.Server
+ input.ServerParams = route.ServerParams
+ }
+ }
+ authErr := requeststate.WithFreshBody(request, func() error {
+ return v.options.AuthenticationFunc(request.Context(), input)
+ })
+ if authErr == nil {
+ return true, nil
+ }
+
+ validationErrors := []*errors.ValidationError{
+ {
+ Message: fmt.Sprintf("Authentication failed for security scheme '%s'", secName),
+ Reason: authErr.Error(),
+ ValidationType: helpers.SecurityValidation,
+ ValidationSubType: secScheme.Type,
+ SpecLine: sec.GoLow().Requirements.ValueNode.Line,
+ SpecCol: sec.GoLow().Requirements.ValueNode.Column,
+ HowToFix: fmt.Sprintf("Provide valid credentials for security scheme '%s'", secName),
+ },
+ }
+ errors.PopulateValidationErrors(validationErrors, request, pathValue)
+ return false, validationErrors
+}
+
func (v *paramValidator) validateHTTPSecurityScheme(
secScheme *v3.SecurityScheme,
sec *base.SecurityRequirement,
diff --git a/vendor/github.com/pb33f/libopenapi-validator/parameters/validation_functions.go b/vendor/github.com/pb33f/libopenapi-validator/parameters/validation_functions.go
index f931588fa..069277ad7 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/parameters/validation_functions.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/parameters/validation_functions.go
@@ -6,7 +6,6 @@ package parameters
import (
"encoding/json"
"fmt"
- "slices"
"strconv"
"strings"
@@ -119,12 +118,8 @@ func ValidateQueryArray(
var validationErrors []*errors.ValidationError
itemsSchema := sch.Items.A.Schema()
- var renderedItemsSchema string
- if itemsSchema != nil {
- rendered, _ := itemsSchema.RenderInline()
- schemaBytes, _ := json.Marshal(rendered)
- renderedItemsSchema = string(schemaBytes)
- }
+ // Get rendered items schema for ReferenceSchema field in errors (uses cache if available)
+ renderedItemsSchema := GetRenderedSchema(itemsSchema, validationOptions)
// check for an exploded bit on the schema.
// if it's exploded, then we need to check each item in the array
@@ -253,26 +248,19 @@ func ValidateQueryArray(
// ValidateQueryParamStyle will validate a query parameter by style
func ValidateQueryParamStyle(param *v3.Parameter, as []*helpers.QueryParam) []*errors.ValidationError {
var validationErrors []*errors.ValidationError
+ if param.Style == helpers.DeepObject {
+ if prefixParam, nestedParam, ok := helpers.DeepObjectPathConflict(as); ok {
+ return []*errors.ValidationError{errors.InvalidDeepObjectPathConflict(param, prefixParam, nestedParam)}
+ }
+ }
stopValidation:
for _, qp := range as {
for i := range qp.Values {
switch param.Style {
case helpers.DeepObject:
// check if the object has additional properties defined that treat this as an array
- if param.Schema != nil {
- pSchema := param.Schema.Schema()
- if slices.Contains(pSchema.Type, helpers.Array) {
- continue
- }
- if pSchema.AdditionalProperties != nil && pSchema.AdditionalProperties.IsA() {
- addPropSchema := pSchema.AdditionalProperties.A.Schema()
- if len(addPropSchema.Type) > 0 {
- if slices.Contains(addPropSchema.Type, helpers.Array) {
- // an array can have more than one value.
- continue
- }
- }
- }
+ if param.Schema != nil && helpers.DeepObjectAllowsMultipleValues(param.Schema.Schema(), qp) {
+ continue
}
if len(qp.Values) > 1 {
validationErrors = append(validationErrors, errors.InvalidDeepObject(param, qp))
diff --git a/vendor/github.com/pb33f/libopenapi-validator/paths/paths.go b/vendor/github.com/pb33f/libopenapi-validator/paths/paths.go
index ccddf9159..e15ae59fe 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/paths/paths.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/paths/paths.go
@@ -1,9 +1,10 @@
-// Copyright 2023 Princess B33f Heavy Industries / Dave Shanley
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
// SPDX-License-Identifier: MIT
package paths
import (
+ stderrors "errors"
"fmt"
"net/http"
"net/url"
@@ -11,13 +12,13 @@ import (
"regexp"
"strings"
- "github.com/pb33f/libopenapi/orderedmap"
-
v3 "github.com/pb33f/libopenapi/datamodel/high/v3"
+ "github.com/pb33f/libopenapi/orderedmap"
"github.com/pb33f/libopenapi-validator/config"
"github.com/pb33f/libopenapi-validator/errors"
"github.com/pb33f/libopenapi-validator/helpers"
+ "github.com/pb33f/libopenapi-validator/router"
)
// FindPath will find the path in the document that matches the request path. If a successful match was found, then
@@ -33,6 +34,13 @@ import (
// Path matching follows the OpenAPI specification: literal (concrete) paths take precedence over
// parameterized paths, regardless of definition order in the specification.
func FindPath(request *http.Request, document *v3.Document, options *config.ValidationOptions) (*v3.PathItem, []*errors.ValidationError, string) {
+ if options != nil && options.Router != nil {
+ route, validationErrors := ResolveRoute(request, document, options)
+ if route == nil {
+ return nil, validationErrors, ""
+ }
+ return route.PathItem, validationErrors, route.Path
+ }
stripped := StripRequestPath(request, document)
// Fast path: try radix tree first (O(k) where k = path depth)
@@ -117,6 +125,41 @@ func FindPath(request *http.Request, document *v3.Document, options *config.Vali
return bestOverall.pathItem, missingOperationError(request, bestOverall.path), bestOverall.path
}
+// ResolveRoute returns the complete route used by high-level validation.
+// It preserves existing ValidationError shapes while exposing the router's server,
+// operation, path-parameter, and server-variable context to internal callers.
+func ResolveRoute(request *http.Request, document *v3.Document, options *config.ValidationOptions) (*router.Route, []*errors.ValidationError) {
+ if options == nil || options.Router == nil {
+ pathItem, validationErrors, path := FindPath(request, document, options)
+ if pathItem == nil {
+ return nil, validationErrors
+ }
+ return &router.Route{
+ Document: document, Path: path, PathItem: pathItem, Method: request.Method,
+ Operation: helpers.ExtractOperation(request, pathItem),
+ }, validationErrors
+ }
+ route, err := options.Router.FindRoute(request)
+ if err == nil && route != nil {
+ return route, nil
+ }
+ if stderrors.Is(err, router.ErrMethodNotAllowed) && route != nil {
+ return route, missingOperationError(request, route.Path)
+ }
+ validationErrors := []*errors.ValidationError{{
+ ValidationType: helpers.PathValidation,
+ ValidationSubType: helpers.ValidationMissing,
+ Message: fmt.Sprintf("%s Path '%s' not found", request.Method, request.URL.Path),
+ Reason: fmt.Sprintf("The %s request contains a path of '%s' however that path, or the %s method for that path does not exist in the specification",
+ request.Method, request.URL.Path, request.Method),
+ SpecLine: -1,
+ SpecCol: -1,
+ HowToFix: errors.HowToFixPath,
+ }}
+ errors.PopulateValidationErrors(validationErrors, request, "")
+ return nil, validationErrors
+}
+
// normalizePathForMatching removes the fragment from a path template unless
// the request path itself contains a fragment.
func normalizePathForMatching(path, requestPath string) string {
@@ -163,7 +206,7 @@ func StripRequestPath(request *http.Request, document *v3.Document) string {
if request.URL.Fragment != "" {
stripped = fmt.Sprintf("%s#%s", stripped, request.URL.Fragment)
}
- if len(stripped) > 0 && !strings.HasPrefix(stripped, "/") {
+ if !strings.HasPrefix(stripped, "/") {
stripped = "/" + stripped
}
return stripped
diff --git a/vendor/github.com/pb33f/libopenapi-validator/radix/path_tree.go b/vendor/github.com/pb33f/libopenapi-validator/radix/path_tree.go
index ae7c634bb..4fcbbf2fe 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/radix/path_tree.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/radix/path_tree.go
@@ -1,4 +1,4 @@
-// Copyright 2026 Princess B33f Heavy Industries / Dave Shanley
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
// SPDX-License-Identifier: MIT
package radix
@@ -42,22 +42,48 @@ func NewPathTree() *PathTree {
// Insert adds a path and its PathItem to the tree.
// Path should be in OpenAPI format, e.g., "/users/{id}/posts"
func (t *PathTree) Insert(path string, pathItem *v3.PathItem) {
+ if t == nil {
+ return
+ }
+ if t.tree == nil {
+ t.tree = New[*v3.PathItem]()
+ }
t.tree.Insert(path, pathItem)
}
// Lookup finds the PathItem for a given request path.
// Returns the PathItem, the matched path template, and whether a match was found.
func (t *PathTree) Lookup(urlPath string) (*v3.PathItem, string, bool) {
+ if t == nil || t.tree == nil {
+ return nil, "", false
+ }
return t.tree.Lookup(urlPath)
}
// Size returns the number of paths stored in the tree.
func (t *PathTree) Size() int {
+ if t == nil || t.tree == nil {
+ return 0
+ }
return t.tree.Size()
}
+// Release clears all path entries and drops the backing tree.
+func (t *PathTree) Release() {
+ if t == nil {
+ return
+ }
+ if t.tree != nil {
+ t.tree.Release()
+ t.tree = nil
+ }
+}
+
// Walk calls the given function for each path in the tree.
func (t *PathTree) Walk(fn func(path string, pathItem *v3.PathItem) bool) {
+ if t == nil || t.tree == nil {
+ return
+ }
t.tree.Walk(fn)
}
diff --git a/vendor/github.com/pb33f/libopenapi-validator/radix/tree.go b/vendor/github.com/pb33f/libopenapi-validator/radix/tree.go
index 8383ad4ef..1a7c7598f 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/radix/tree.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/radix/tree.go
@@ -1,4 +1,4 @@
-// Copyright 2026 Princess B33f Heavy Industries / Dave Shanley
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
// SPDX-License-Identifier: MIT
// Package radix provides a radix tree (prefix tree) implementation optimized for
@@ -64,6 +64,9 @@ func New[T any]() *Tree[T] {
//
// Returns true if a new path was inserted, false if an existing path was updated.
func (t *Tree[T]) Insert(path string, value T) bool {
+ if t == nil {
+ return false
+ }
if t.root == nil {
t.root = &node[T]{children: make(map[string]*node[T])}
}
@@ -116,7 +119,7 @@ func (t *Tree[T]) Insert(path string, value T) bool {
// For example, "/users/admin" will match "/users/admin" before "/users/{id}".
func (t *Tree[T]) Lookup(urlPath string) (value T, matchedPath string, found bool) {
var zero T
- if t.root == nil {
+ if t == nil || t.root == nil {
return zero, "", false
}
@@ -158,20 +161,35 @@ func (t *Tree[T]) lookupRecursive(n *node[T], segments []string, depth int) *lea
// Size returns the number of paths stored in the tree.
func (t *Tree[T]) Size() int {
+ if t == nil {
+ return 0
+ }
return t.size
}
// Clear removes all entries from the tree.
func (t *Tree[T]) Clear() {
+ if t == nil {
+ return
+ }
t.root = &node[T]{children: make(map[string]*node[T])}
t.size = 0
}
+// Release clears the tree and drops the root node so retained values can be garbage-collected.
+func (t *Tree[T]) Release() {
+ if t == nil {
+ return
+ }
+ t.root = nil
+ t.size = 0
+}
+
// Walk calls the given function for each path in the tree.
// The function receives the path template and its associated value.
// If the function returns false, iteration stops.
func (t *Tree[T]) Walk(fn func(path string, value T) bool) {
- if t.root == nil {
+ if t == nil || t.root == nil {
return
}
t.walkRecursive(t.root, fn)
diff --git a/vendor/github.com/pb33f/libopenapi-validator/request_defaults.go b/vendor/github.com/pb33f/libopenapi-validator/request_defaults.go
new file mode 100644
index 000000000..6e9979e5a
--- /dev/null
+++ b/vendor/github.com/pb33f/libopenapi-validator/request_defaults.go
@@ -0,0 +1,331 @@
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
+// SPDX-License-Identifier: MIT
+
+package validator
+
+import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "net/http"
+ "net/url"
+ "strings"
+
+ "github.com/pb33f/libopenapi/datamodel/high/base"
+ "go.yaml.in/yaml/v4"
+
+ v3 "github.com/pb33f/libopenapi/datamodel/high/v3"
+
+ "github.com/pb33f/libopenapi-validator/content"
+ "github.com/pb33f/libopenapi-validator/errors"
+ "github.com/pb33f/libopenapi-validator/helpers"
+ "github.com/pb33f/libopenapi-validator/internal/requeststate"
+)
+
+type requestValidation func(*http.Request, *v3.PathItem, string) (bool, []*errors.ValidationError)
+
+func (v *validator) validateWithRequestDefaults(request *http.Request, pathItem *v3.PathItem, pathValue string, validate requestValidation) (bool, []*errors.ValidationError) {
+ staged, preparationErrors := v.stageRequestDefaults(request, pathItem)
+ if len(preparationErrors) > 0 {
+ return false, preparationErrors
+ }
+ valid, validationErrors := validate(staged, pathItem, pathValue)
+ if !valid {
+ return false, validationErrors
+ }
+ request.URL = staged.URL
+ request.Header = staged.Header
+ request.Body = staged.Body
+ request.GetBody = staged.GetBody
+ request.ContentLength = staged.ContentLength
+ return true, nil
+}
+
+func (v *validator) stageRequestDefaults(request *http.Request, pathItem *v3.PathItem) (*http.Request, []*errors.ValidationError) {
+ if request == nil {
+ return request, []*errors.ValidationError{{
+ ValidationType: helpers.RequestBodyValidation, ValidationSubType: helpers.Schema,
+ Message: "request is nil", Reason: "request defaults require a request",
+ }}
+ }
+ staged := new(http.Request)
+ *staged = *request
+ if request.URL != nil {
+ clonedURL := new(url.URL)
+ *clonedURL = *request.URL
+ staged.URL = clonedURL
+ }
+ staged.Header = request.Header.Clone()
+ if staged.Header == nil {
+ staged.Header = make(http.Header)
+ }
+ body, err := requeststate.Snapshot(request)
+ if err != nil {
+ return nil, []*errors.ValidationError{requestDefaultError("request body could not be staged", err)}
+ }
+ requeststate.Install(staged, body)
+
+ operation := helpers.ExtractOperation(staged, pathItem)
+ if operation == nil {
+ return staged, nil
+ }
+ for _, parameter := range helpers.ExtractParamsForOperation(staged, pathItem) {
+ if parameter == nil {
+ continue
+ }
+ var schema *base.Schema
+ contentWrapped := false
+ if parameter.Schema != nil {
+ schema = parameter.Schema.Schema()
+ } else if parameter.Content != nil && parameter.Content.First() != nil {
+ mediaType := parameter.Content.First().Value()
+ if mediaType != nil && mediaType.Schema != nil {
+ schema = mediaType.Schema.Schema()
+ contentWrapped = true
+ }
+ }
+ if schema == nil || schema.Default == nil {
+ continue
+ }
+ if !parameterNeedsDefault(staged, parameter, v.options.ValidateRequestQuery) {
+ continue
+ }
+ value, decodeErr := defaultValue(schema.Default)
+ if decodeErr != nil {
+ return nil, []*errors.ValidationError{requestDefaultError("parameter default could not be decoded", decodeErr)}
+ }
+ if !contentWrapped && containsObjectDefault(value) {
+ return nil, []*errors.ValidationError{requestDefaultError(
+ "parameter default uses unsupported object serialization",
+ fmt.Errorf("parameter %q must use Parameter.content or a scalar/array default", parameter.Name),
+ )}
+ }
+ serialized := serializeDefault(value, ",")
+ if contentWrapped {
+ serialized = serializeContentDefault(value)
+ }
+ switch parameter.In {
+ case helpers.Query:
+ query := staged.URL.Query()
+ if contentWrapped {
+ query.Set(parameter.Name, serialized)
+ } else {
+ writeQueryDefault(query, parameter, value)
+ }
+ staged.URL.RawQuery = query.Encode()
+ case helpers.Header:
+ staged.Header.Set(parameter.Name, serialized)
+ case helpers.Cookie:
+ staged.AddCookie(&http.Cookie{Name: parameter.Name, Value: serialized})
+ }
+ }
+
+ if !v.options.ValidateRequestBody || operation.RequestBody == nil || len(body) == 0 {
+ return staged, nil
+ }
+ contentType, _ := content.NormalizeMediaType(staged.Header.Get(helpers.ContentTypeHeader))
+ mediaType := requestMediaType(operation, contentType)
+ if mediaType == nil || mediaType.Schema == nil {
+ return staged, nil
+ }
+ decoder, normalized, parameters := v.options.BodyRegistry.Decoder(contentType)
+ if decoder == nil {
+ return nil, []*errors.ValidationError{requestDefaultError("request body defaults require a decoder", fmt.Errorf("no decoder for %s", contentType))}
+ }
+ schema := mediaType.Schema.Schema()
+ decoded, decodeErr := decoder.Decode(&content.DecodeInput{
+ Context: staged.Context(), Body: bytes.NewReader(body), Header: staged.Header,
+ MediaType: normalized, Parameters: parameters, Schema: schema, Encoding: mediaType.Encoding, Direction: content.Request,
+ })
+ if decodeErr != nil {
+ return nil, []*errors.ValidationError{requestDefaultError("request body could not be decoded for defaults", decodeErr)}
+ }
+ decoded, decodeErr = content.Canonicalize(decoded)
+ if decodeErr != nil {
+ return nil, []*errors.ValidationError{requestDefaultError("request body could not be canonicalized for defaults", decodeErr)}
+ }
+ changed, applyErr := applySchemaDefaults(decoded, schema)
+ if applyErr != nil {
+ return nil, []*errors.ValidationError{requestDefaultError("request body defaults could not be applied", applyErr)}
+ }
+ if !changed {
+ return staged, nil
+ }
+ encoder, _, _ := v.options.BodyRegistry.Encoder(contentType)
+ if encoder == nil {
+ return nil, []*errors.ValidationError{requestDefaultError("request body defaults require an encoder", fmt.Errorf("no encoder for %s", contentType))}
+ }
+ rewritten, encodeErr := encoder.Encode(&content.EncodeInput{
+ Context: staged.Context(), Value: decoded, Header: staged.Header, MediaType: contentType,
+ Schema: schema, Encoding: mediaType.Encoding, Direction: content.Request,
+ })
+ if encodeErr != nil {
+ return nil, []*errors.ValidationError{requestDefaultError("request body defaults could not be encoded", encodeErr)}
+ }
+ requeststate.Install(staged, rewritten)
+ return staged, nil
+}
+
+func parameterNeedsDefault(request *http.Request, parameter *v3.Parameter, validateQuery bool) bool {
+ if request == nil || parameter == nil {
+ return false
+ }
+ switch parameter.In {
+ case helpers.Query:
+ return validateQuery && request.URL != nil && !request.URL.Query().Has(parameter.Name)
+ case helpers.Header:
+ return !headerExists(request.Header, parameter.Name)
+ case helpers.Cookie:
+ _, err := request.Cookie(parameter.Name)
+ return err != nil
+ }
+ return false
+}
+
+func headerExists(header http.Header, name string) bool {
+ for key := range header {
+ if strings.EqualFold(key, name) {
+ return true
+ }
+ }
+ return false
+}
+
+func containsObjectDefault(value any) bool {
+ switch typed := value.(type) {
+ case map[string]any:
+ return true
+ case []any:
+ for _, item := range typed {
+ if containsObjectDefault(item) {
+ return true
+ }
+ }
+ }
+ return false
+}
+
+func serializeContentDefault(value any) string {
+ encoded, _ := json.Marshal(value) // defaultValue already proves JSON encodability.
+ return string(encoded)
+}
+
+func requestDefaultError(message string, err error) *errors.ValidationError {
+ return &errors.ValidationError{
+ ValidationType: helpers.RequestBodyValidation, ValidationSubType: helpers.Schema,
+ Message: message, Reason: err.Error(), HowToFix: "fix the default, decoder, encoder, or request value before enabling request defaults",
+ }
+}
+
+func defaultValue(node *yaml.Node) (any, error) {
+ var value any
+ if err := node.Decode(&value); err != nil {
+ return nil, err
+ }
+ canonical, err := content.Canonicalize(value)
+ if err != nil {
+ return nil, err
+ }
+ return canonical, nil
+}
+
+func writeQueryDefault(query url.Values, parameter *v3.Parameter, value any) {
+ if values, ok := value.([]any); ok {
+ if parameter.IsExploded() {
+ for _, item := range values {
+ query.Add(parameter.Name, fmt.Sprint(item))
+ }
+ return
+ }
+ query.Set(parameter.Name, serializeDefault(value, ","))
+ return
+ }
+ query.Set(parameter.Name, fmt.Sprint(value))
+}
+
+func serializeDefault(value any, separator string) string {
+ if values, ok := value.([]any); ok {
+ parts := make([]string, len(values))
+ for i, item := range values {
+ parts[i] = fmt.Sprint(item)
+ }
+ return strings.Join(parts, separator)
+ }
+ return fmt.Sprint(value)
+}
+
+func requestMediaType(operation *v3.Operation, mediaType string) *v3.MediaType {
+ if operation == nil || operation.RequestBody == nil || operation.RequestBody.Content == nil {
+ return nil
+ }
+ if exact := operation.RequestBody.Content.GetOrZero(mediaType); exact != nil {
+ return exact
+ }
+ parts := strings.SplitN(mediaType, "/", 2)
+ if len(parts) != 2 {
+ return nil
+ }
+ for pair := operation.RequestBody.Content.First(); pair != nil; pair = pair.Next() {
+ declared := strings.SplitN(strings.ToLower(pair.Key()), "/", 2)
+ if len(declared) == 2 && (declared[0] == "*" || declared[0] == parts[0]) && (declared[1] == "*" || declared[1] == parts[1]) {
+ return pair.Value()
+ }
+ }
+ return nil
+}
+
+func applySchemaDefaults(value any, schema *base.Schema) (bool, error) {
+ if schema == nil {
+ return false, nil
+ }
+ changed := false
+ for _, allOf := range schema.AllOf {
+ if allOf == nil {
+ continue
+ }
+ applied, err := applySchemaDefaults(value, allOf.Schema())
+ if err != nil {
+ return false, err
+ }
+ changed = changed || applied
+ }
+ if object, ok := value.(map[string]any); ok && schema.Properties != nil {
+ for pair := schema.Properties.First(); pair != nil; pair = pair.Next() {
+ if pair.Value() == nil {
+ continue
+ }
+ property := pair.Value().Schema()
+ if property == nil || (property.ReadOnly != nil && *property.ReadOnly) {
+ continue
+ }
+ current, exists := object[pair.Key()]
+ if !exists && property.Default != nil {
+ defaulted, err := defaultValue(property.Default)
+ if err != nil {
+ return false, err
+ }
+ object[pair.Key()] = defaulted
+ changed = true
+ continue
+ }
+ if exists && current != nil {
+ applied, err := applySchemaDefaults(current, property)
+ if err != nil {
+ return false, err
+ }
+ changed = changed || applied
+ }
+ }
+ }
+ if array, ok := value.([]any); ok && schema.Items != nil && schema.Items.IsA() {
+ itemSchema := schema.Items.A.Schema()
+ for _, item := range array {
+ applied, err := applySchemaDefaults(item, itemSchema)
+ if err != nil {
+ return false, err
+ }
+ changed = changed || applied
+ }
+ }
+ return changed, nil
+}
diff --git a/vendor/github.com/pb33f/libopenapi-validator/requests/request_body.go b/vendor/github.com/pb33f/libopenapi-validator/requests/request_body.go
index 164689087..6aed18a86 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/requests/request_body.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/requests/request_body.go
@@ -1,4 +1,4 @@
-// Copyright 2023 Princess B33f Heavy Industries / Dave Shanley
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
// SPDX-License-Identifier: MIT
package requests
@@ -10,6 +10,7 @@ import (
"github.com/pb33f/libopenapi-validator/config"
"github.com/pb33f/libopenapi-validator/errors"
+ "github.com/pb33f/libopenapi-validator/internal/bodycodec"
)
// RequestBodyValidator is an interface that defines the methods for validating request bodies for Operations.
@@ -26,11 +27,15 @@ type RequestBodyValidator interface {
// request body is valid, false if it is not. The second return value will be a slice of ValidationError pointers if
// the body is not valid.
ValidateRequestBodyWithPathItem(request *http.Request, pathItem *v3.PathItem, pathValue string) (bool, []*errors.ValidationError)
+
+ // Release clears validator-owned options and drops the OpenAPI document reference.
+ Release()
}
// NewRequestBodyValidator will create a new RequestBodyValidator from an OpenAPI 3+ document
func NewRequestBodyValidator(document *v3.Document, opts ...config.Option) RequestBodyValidator {
options := config.NewValidationOptions(opts...)
+ bodycodec.Apply(options)
return &requestBodyValidator{options: options, document: document}
}
@@ -39,3 +44,14 @@ type requestBodyValidator struct {
options *config.ValidationOptions
document *v3.Document
}
+
+func (r *requestBodyValidator) Release() {
+ if r == nil {
+ return
+ }
+ if r.options != nil {
+ r.options.Release()
+ r.options = nil
+ }
+ r.document = nil
+}
diff --git a/vendor/github.com/pb33f/libopenapi-validator/requests/validate_body.go b/vendor/github.com/pb33f/libopenapi-validator/requests/validate_body.go
index 92ae3440b..22010aba8 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/requests/validate_body.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/requests/validate_body.go
@@ -1,21 +1,23 @@
-// Copyright 2023 Princess B33f Heavy Industries / Dave Shanley
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
// SPDX-License-Identifier: MIT
package requests
import (
"bytes"
- "encoding/json"
+ stderrors "errors"
"fmt"
- "io"
"net/http"
"strings"
v3 "github.com/pb33f/libopenapi/datamodel/high/v3"
"github.com/pb33f/libopenapi-validator/config"
+ "github.com/pb33f/libopenapi-validator/content"
"github.com/pb33f/libopenapi-validator/errors"
"github.com/pb33f/libopenapi-validator/helpers"
+ "github.com/pb33f/libopenapi-validator/internal/bodycodec"
+ "github.com/pb33f/libopenapi-validator/internal/requeststate"
"github.com/pb33f/libopenapi-validator/paths"
"github.com/pb33f/libopenapi-validator/schema_validation"
)
@@ -47,6 +49,22 @@ func (v *requestBodyValidator) ValidateRequestBodyWithPathItem(request *http.Req
return false, []*errors.ValidationError{errors.OperationNotFound(pathItem, request, request.Method, pathValue)}
}
if operation.RequestBody == nil {
+ if v.options.RejectUndeclaredRequestBody {
+ body, err := requeststate.Snapshot(request)
+ if err != nil {
+ return false, []*errors.ValidationError{{
+ ValidationType: helpers.RequestBodyValidation, ValidationSubType: helpers.Schema,
+ Message: "request body could not be inspected", Reason: err.Error(), Context: operation,
+ }}
+ }
+ if len(body) > 0 {
+ return false, []*errors.ValidationError{{
+ ValidationType: helpers.RequestBodyValidation, ValidationSubType: helpers.Schema,
+ Message: fmt.Sprintf("%s request body for '%s' is not declared", request.Method, request.URL.Path),
+ Reason: "the matched operation does not declare a requestBody", Context: operation,
+ }}
+ }
+ }
return true, nil
}
@@ -79,51 +97,61 @@ func (v *requestBodyValidator) ValidateRequestBodyWithPathItem(request *http.Req
schema := mediaType.Schema.Schema()
isJson := strings.Contains(strings.ToLower(contentType), helpers.JSONType)
-
- // we currently only support JSON, XML and URLEncoded validation for request bodies
- if !isJson {
- isXml := schema_validation.IsXMLContentType(contentType)
- isUrlEncoded := schema_validation.IsURLEncodedContentType(contentType)
-
- xmlValid := isXml && v.options.AllowXMLBodyValidation
- urlEncodedValid := isUrlEncoded && v.options.AllowURLEncodedBodyValidation
-
- if !xmlValid && !urlEncodedValid {
+ isXml := schema_validation.IsXMLContentType(contentType)
+ isUrlEncoded := schema_validation.IsURLEncodedContentType(contentType)
+ decoder, normalized, parameters := v.options.BodyRegistry.Decoder(contentType)
+ if decoder == nil && isJson {
+ decoder = content.JSONDecoder()
+ }
+ if decoder == nil {
+ if !v.options.RejectUnsupportedBodyContent {
return true, nil
}
+ return false, []*errors.ValidationError{{
+ ValidationType: helpers.RequestBodyValidation, ValidationSubType: helpers.Schema,
+ Message: fmt.Sprintf("%s request body for '%s' has no registered decoder", request.Method, request.URL.Path),
+ Reason: fmt.Sprintf("no body decoder is registered for %s", contentType),
+ Context: &content.FailureContext{Request: request, Operation: operation, MediaType: mediaType, Schema: schema},
+ }}
+ }
+ requestBody, readErr := requeststate.Snapshot(request)
+ if readErr != nil {
+ return false, []*errors.ValidationError{{
+ ValidationType: helpers.RequestBodyValidation, ValidationSubType: helpers.Schema,
+ Message: "request body could not be read", Reason: readErr.Error(), Context: schema,
+ }}
+ }
+ var decodedValue any
+ var decodeErr error
+ decoded := false
- if request != nil && request.Body != nil {
- requestBody, _ := io.ReadAll(request.Body)
- _ = request.Body.Close()
-
- stringedBody := string(requestBody)
- var jsonBody any
- var prevalidationErrors []*errors.ValidationError
-
- switch {
- case xmlValid:
- jsonBody, prevalidationErrors = schema_validation.TransformXMLToSchemaJSON(stringedBody, schema)
- case urlEncodedValid:
- jsonBody, prevalidationErrors = schema_validation.TransformURLEncodedToSchemaJSON(stringedBody, schema, mediaType.Encoding)
- }
-
- if len(prevalidationErrors) > 0 {
- return false, prevalidationErrors
- }
-
- transformedBytes, err := json.Marshal(jsonBody)
- if err != nil {
- switch {
- case isXml:
- return false, []*errors.ValidationError{errors.InvalidXMLParsing(err.Error(), stringedBody)}
- case isUrlEncoded:
- return false, []*errors.ValidationError{errors.InvalidURLEncodedParsing(err.Error(), stringedBody)}
- }
- }
-
- request.Body = io.NopCloser(bytes.NewBuffer(transformedBytes))
+ decodedValue, decodeErr = decoder.Decode(&content.DecodeInput{
+ Context: request.Context(), Body: bytes.NewReader(requestBody), Header: request.Header,
+ MediaType: normalized, Parameters: parameters, Schema: schema, Encoding: mediaType.Encoding, Direction: content.Request,
+ })
+ if decodeErr == nil {
+ decodedValue, decodeErr = content.Canonicalize(decodedValue)
+ }
+ if decodeErr != nil {
+ var transformErrors *bodycodec.ValidationErrors
+ if stderrors.As(decodeErr, &transformErrors) {
+ return false, transformErrors.Errors
+ }
+ structured := &content.DecodingError{MediaType: normalized, Direction: content.Request, Err: decodeErr}
+ if isXml {
+ return false, []*errors.ValidationError{errors.InvalidXMLParsing(structured.Error(), string(requestBody))}
}
+ if isUrlEncoded {
+ return false, []*errors.ValidationError{errors.InvalidURLEncodedParsing(structured.Error(), string(requestBody))}
+ }
+ return false, []*errors.ValidationError{{
+ ValidationType: helpers.RequestBodyValidation, ValidationSubType: helpers.Schema,
+ Message: fmt.Sprintf("%s request body for '%s' could not be decoded", request.Method, request.URL.Path),
+ Reason: "The request body cannot be decoded: " + structured.Error(),
+ Context: &content.FailureContext{Request: request, Operation: operation, MediaType: mediaType, Schema: schema},
+ }}
}
+ decoded = true
validationSucceeded, validationErrors := ValidateRequestSchema(&ValidateRequestSchemaInput{
Request: request,
@@ -131,6 +159,9 @@ func (v *requestBodyValidator) ValidateRequestBodyWithPathItem(request *http.Req
Version: helpers.VersionToFloat(v.document.Version),
Options: []config.Option{config.WithExistingOpts(v.options)},
BodyRequired: required,
+ DecodedValue: decodedValue,
+ RawBody: requestBody,
+ ValueDecoded: decoded,
})
errors.PopulateValidationErrors(validationErrors, request, pathValue)
diff --git a/vendor/github.com/pb33f/libopenapi-validator/requests/validate_request.go b/vendor/github.com/pb33f/libopenapi-validator/requests/validate_request.go
index 251b8d1e1..e760f852f 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/requests/validate_request.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/requests/validate_request.go
@@ -4,26 +4,24 @@
package requests
import (
- "bytes"
"encoding/json"
+ "errors"
"fmt"
- "io"
"net/http"
"reflect"
"regexp"
"strconv"
"github.com/pb33f/libopenapi/datamodel/high/base"
- "github.com/pb33f/libopenapi/utils"
"github.com/santhosh-tekuri/jsonschema/v6"
"go.yaml.in/yaml/v4"
"golang.org/x/text/language"
"golang.org/x/text/message"
- "github.com/pb33f/libopenapi-validator/cache"
"github.com/pb33f/libopenapi-validator/config"
- "github.com/pb33f/libopenapi-validator/errors"
+ liberrors "github.com/pb33f/libopenapi-validator/errors"
"github.com/pb33f/libopenapi-validator/helpers"
+ "github.com/pb33f/libopenapi-validator/internal/requeststate"
"github.com/pb33f/libopenapi-validator/schema_validation"
"github.com/pb33f/libopenapi-validator/strict"
)
@@ -37,28 +35,41 @@ type ValidateRequestSchemaInput struct {
Version float32 // Required: OpenAPI version (3.0 or 3.1)
Options []config.Option // Optional: Functional options (defaults applied if empty/nil)
BodyRequired bool // Optional: Whether the request body is required (default false)
+ DecodedValue any // Optional: A value produced by a registered body decoder
+ RawBody []byte // Optional: Original bytes used for diagnostics with DecodedValue
+ ValueDecoded bool // Distinguishes an explicitly decoded nil from the legacy JSON path
+}
+
+func setRequestBody(request *http.Request, body []byte) {
+ requeststate.Install(request, body)
+}
+
+func readAndResetRequestBody(request *http.Request) []byte {
+ body, _ := requeststate.Snapshot(request)
+ return body
}
// ValidateRequestSchema will validate a http.Request pointer against a schema.
// If validation fails, it will return a list of validation errors as the second return value.
// The schema will be stored and reused from cache if available, otherwise it will be compiled on each call.
-func ValidateRequestSchema(input *ValidateRequestSchemaInput) (bool, []*errors.ValidationError) {
+func ValidateRequestSchema(input *ValidateRequestSchemaInput) (bool, []*liberrors.ValidationError) {
validationOptions := config.NewValidationOptions(input.Options...)
- var validationErrors []*errors.ValidationError
+ var validationErrors []*liberrors.ValidationError
var renderedSchema, jsonSchema []byte
var referenceSchema string
var compiledSchema *jsonschema.Schema
var cachedNode *yaml.Node
+ var resourceNodes map[string]*yaml.Node
if input.Schema == nil {
- return false, []*errors.ValidationError{{
+ return false, []*liberrors.ValidationError{{
ValidationType: helpers.RequestBodyValidation,
ValidationSubType: helpers.Schema,
Message: "schema is nil",
Reason: "The schema to validate against is nil",
}}
} else if input.Schema.GoLow() == nil {
- return false, []*errors.ValidationError{{
+ return false, []*liberrors.ValidationError{{
ValidationType: helpers.RequestBodyValidation,
ValidationSubType: helpers.Schema,
Message: "schema cannot be rendered",
@@ -67,57 +78,31 @@ func ValidateRequestSchema(input *ValidateRequestSchemaInput) (bool, []*errors.V
}
if validationOptions.SchemaCache != nil {
- hash := input.Schema.GoLow().Hash()
+ hash := schema_validation.SchemaCacheKey(
+ input.Schema.GoLow().Hash(),
+ input.Version,
+ schema_validation.SchemaValidationPurposeRequestBody,
+ )
if cached, ok := validationOptions.SchemaCache.Load(hash); ok && cached != nil && cached.CompiledSchema != nil {
renderedSchema = cached.RenderedInline
referenceSchema = cached.ReferenceSchema
jsonSchema = cached.RenderedJSON
compiledSchema = cached.CompiledSchema
cachedNode = cached.RenderedNode
+ resourceNodes = cached.ResourceNodes
}
}
// Cache miss or no cache - render and compile
if compiledSchema == nil {
- renderCtx := base.NewInlineRenderContextForValidation()
- var renderErr error
- renderedSchema, renderErr = input.Schema.RenderInlineWithContext(renderCtx)
- referenceSchema = string(renderedSchema)
-
- // If rendering failed (e.g., circular reference), return the render error
- if renderErr != nil {
- violation := &errors.SchemaValidationFailure{
- Reason: renderErr.Error(),
- ReferenceSchema: referenceSchema,
- }
- validationErrors = append(validationErrors, &errors.ValidationError{
- ValidationType: helpers.RequestBodyValidation,
- ValidationSubType: helpers.Schema,
- Message: fmt.Sprintf("%s request body for '%s' failed schema rendering",
- input.Request.Method, input.Request.URL.Path),
- Reason: fmt.Sprintf("The request schema failed to render: %s",
- renderErr.Error()),
- SpecLine: 1,
- SpecCol: 0,
- SchemaValidationErrors: []*errors.SchemaValidationFailure{violation},
- HowToFix: errors.HowToFixInvalidRenderedSchema,
- Context: referenceSchema,
- })
- return false, validationErrors
- }
-
- jsonSchema, _ = utils.ConvertYAMLtoJSON(renderedSchema)
-
- var err error
- schemaName := fmt.Sprintf("%x", input.Schema.GoLow().Hash())
- compiledSchema, err = helpers.NewCompiledSchemaWithVersion(
- schemaName,
- jsonSchema,
+ compiled, err := schema_validation.CompileSchemaForValidation(
+ input.Schema,
+ schema_validation.SchemaValidationPurposeRequestBody,
validationOptions,
input.Version,
)
if err != nil {
- validationErrors = append(validationErrors, &errors.ValidationError{
+ validationErrors = append(validationErrors, &liberrors.ValidationError{
ValidationType: helpers.RequestBodyValidation,
ValidationSubType: helpers.Schema,
Message: fmt.Sprintf("%s request body for '%s' failed schema compilation",
@@ -130,39 +115,37 @@ func ValidateRequestSchema(input *ValidateRequestSchemaInput) (bool, []*errors.V
})
return false, validationErrors
}
+ renderedSchema = compiled.RenderedInline
+ referenceSchema = compiled.ReferenceSchema
+ jsonSchema = compiled.RenderedJSON
+ cachedNode = compiled.RenderedNode
+ resourceNodes = compiled.ResourceNodes
+ compiledSchema = compiled.CompiledSchema
if validationOptions.SchemaCache != nil {
- hash := input.Schema.GoLow().Hash()
- validationOptions.SchemaCache.Store(hash, &cache.SchemaCacheEntry{
- Schema: input.Schema,
- RenderedInline: renderedSchema,
- ReferenceSchema: referenceSchema,
- RenderedJSON: jsonSchema,
- CompiledSchema: compiledSchema,
- })
+ hash := schema_validation.SchemaCacheKey(
+ input.Schema.GoLow().Hash(),
+ input.Version,
+ schema_validation.SchemaValidationPurposeRequestBody,
+ )
+ validationOptions.SchemaCache.Store(hash, compiled.ToCacheEntry(input.Schema))
}
}
request := input.Request
schema := input.Schema
- var requestBody []byte
- if request != nil && request.Body != nil {
- requestBody, _ = io.ReadAll(request.Body)
-
- // close the request body, so it can be re-read later by another player in the chain
- _ = request.Body.Close()
- request.Body = io.NopCloser(bytes.NewBuffer(requestBody))
-
+ requestBody := input.RawBody
+ decodedObj := input.DecodedValue
+ if !input.ValueDecoded {
+ requestBody = readAndResetRequestBody(request)
}
- var decodedObj interface{}
-
- if len(requestBody) > 0 {
+ if !input.ValueDecoded && len(requestBody) > 0 {
err := json.Unmarshal(requestBody, &decodedObj)
if err != nil {
// cannot decode the request body, so it's not valid
- validationErrors = append(validationErrors, &errors.ValidationError{
+ validationErrors = append(validationErrors, &liberrors.ValidationError{
ValidationType: helpers.RequestBodyValidation,
ValidationSubType: helpers.Schema,
Message: fmt.Sprintf("%s request body for '%s' failed to validate schema",
@@ -170,7 +153,7 @@ func ValidateRequestSchema(input *ValidateRequestSchemaInput) (bool, []*errors.V
Reason: fmt.Sprintf("The request body cannot be decoded: %s", err.Error()),
SpecLine: 1,
SpecCol: 0,
- HowToFix: errors.HowToFixInvalidSchema,
+ HowToFix: liberrors.HowToFixInvalidSchema,
Context: schema,
})
return false, validationErrors
@@ -198,7 +181,7 @@ func ValidateRequestSchema(input *ValidateRequestSchemaInput) (bool, []*errors.V
}
}
- validationErrors = append(validationErrors, &errors.ValidationError{
+ validationErrors = append(validationErrors, &liberrors.ValidationError{
ValidationType: helpers.RequestBodyValidation,
ValidationSubType: helpers.Schema,
Message: fmt.Sprintf("%s request body is empty for '%s'",
@@ -206,7 +189,7 @@ func ValidateRequestSchema(input *ValidateRequestSchemaInput) (bool, []*errors.V
Reason: "The request body is empty but there is a schema defined",
SpecLine: line,
SpecCol: col,
- HowToFix: errors.HowToFixInvalidSchema,
+ HowToFix: liberrors.HowToFixInvalidSchema,
Context: schema,
})
return false, validationErrors
@@ -215,80 +198,81 @@ func ValidateRequestSchema(input *ValidateRequestSchemaInput) (bool, []*errors.V
// validate the object against the schema
scErrs := compiledSchema.Validate(decodedObj)
if scErrs != nil {
+ var jk *jsonschema.ValidationError
+ var schemaValidationErrors []*liberrors.SchemaValidationFailure
- jk := scErrs.(*jsonschema.ValidationError)
-
- // flatten the validationErrors
- schFlatErrs := jk.BasicOutput().Errors
- var schemaValidationErrors []*errors.SchemaValidationFailure
+ if errors.As(scErrs, &jk) {
+ // flatten the validationErrors
+ schFlatErrs := helpers.FlattenSchemaOutputErrors(jk.DetailedOutput())
- // Use cached node if available, otherwise parse
- renderedNode := cachedNode
- if renderedNode == nil {
- renderedNode = new(yaml.Node)
- _ = yaml.Unmarshal(renderedSchema, renderedNode)
- }
- for q := range schFlatErrs {
- er := schFlatErrs[q]
+ renderedNode, resourceNodes := schema_validation.DiagnosticLocationNodes(renderedSchema, cachedNode, resourceNodes)
+ for q := range schFlatErrs {
+ er := schFlatErrs[q]
- errMsg := er.Error.Kind.LocalizedString(message.NewPrinter(language.Tag{}))
-
- if er.KeywordLocation == "" || helpers.IgnoreRegex.MatchString(errMsg) {
- continue // ignore this error, it's useless tbh, utter noise.
- }
- if er.Error != nil {
+ errMsg := er.Error.Kind.LocalizedString(message.NewPrinter(language.Tag{}))
- // locate the violated property in the schema
- var located *yaml.Node
- if len(renderedNode.Content) > 0 {
- located = schema_validation.LocateSchemaPropertyNodeByJSONPath(renderedNode.Content[0], er.KeywordLocation)
+ if er.KeywordLocation == "" || helpers.IgnoreRegex.MatchString(errMsg) {
+ continue // ignore this error, it's useless tbh, utter noise.
}
-
- // extract the element specified by the instance
- val := instanceLocationRegex.FindStringSubmatch(er.InstanceLocation)
- var referenceObject string
-
- if len(val) > 0 {
- referenceIndex, _ := strconv.Atoi(val[1])
- if reflect.ValueOf(decodedObj).Type().Kind() == reflect.Slice {
- found := decodedObj.([]any)[referenceIndex]
- recoded, _ := json.MarshalIndent(found, "", " ")
- referenceObject = string(recoded)
+ if er.Error != nil {
+
+ // locate the violated property in the schema
+ var located *yaml.Node
+ if renderedNode != nil {
+ located = schema_validation.LocateSchemaPropertyNodeByJSONPathWithResources(
+ renderedNode,
+ resourceNodes,
+ er.KeywordLocation,
+ er.AbsoluteKeywordLocation,
+ )
}
- }
- if referenceObject == "" {
- referenceObject = string(requestBody)
- }
- errMsg := er.Error.Kind.LocalizedString(message.NewPrinter(language.Tag{}))
+ // extract the element specified by the instance
+ val := instanceLocationRegex.FindStringSubmatch(er.InstanceLocation)
+ var referenceObject string
- violation := &errors.SchemaValidationFailure{
- Reason: errMsg,
- FieldName: helpers.ExtractFieldNameFromStringLocation(er.InstanceLocation),
- FieldPath: helpers.ExtractJSONPathFromStringLocation(er.InstanceLocation),
- InstancePath: helpers.ConvertStringLocationToPathSegments(er.InstanceLocation),
- KeywordLocation: er.KeywordLocation,
- ReferenceSchema: referenceSchema,
- ReferenceObject: referenceObject,
- OriginalJsonSchemaError: jk,
- }
- // if we have a location within the schema, add it to the error
- if located != nil {
-
- line := located.Line
- // if the located node is a map or an array, then the actual human interpretable
- // line on which the violation occurred is the line of the key, not the value.
- if located.Kind == yaml.MappingNode || located.Kind == yaml.SequenceNode {
- if line > 0 {
- line--
+ if len(val) > 0 {
+ referenceIndex, _ := strconv.Atoi(val[1])
+ if reflect.ValueOf(decodedObj).Type().Kind() == reflect.Slice {
+ found := decodedObj.([]any)[referenceIndex]
+ recoded, _ := json.MarshalIndent(found, "", " ")
+ referenceObject = string(recoded)
}
}
+ if referenceObject == "" {
+ referenceObject = string(requestBody)
+ }
- // location of the violation within the rendered schema.
- violation.Line = line
- violation.Column = located.Column
+ errMsg := er.Error.Kind.LocalizedString(message.NewPrinter(language.Tag{}))
+
+ violation := &liberrors.SchemaValidationFailure{
+ Reason: errMsg,
+ FieldName: helpers.ExtractFieldNameFromStringLocation(er.InstanceLocation),
+ FieldPath: helpers.ExtractJSONPathFromStringLocation(er.InstanceLocation),
+ InstancePath: helpers.ConvertStringLocationToPathSegments(er.InstanceLocation),
+ KeywordLocation: er.KeywordLocation,
+ ReferenceSchema: referenceSchema,
+ ReferenceObject: referenceObject,
+ OriginalJsonSchemaError: jk,
+ }
+ // if we have a location within the schema, add it to the error
+ if located != nil {
+
+ line := located.Line
+ // if the located node is a map or an array, then the actual human interpretable
+ // line on which the violation occurred is the line of the key, not the value.
+ if located.Kind == yaml.MappingNode || located.Kind == yaml.SequenceNode {
+ if line > 0 {
+ line--
+ }
+ }
+
+ // location of the violation within the rendered schema.
+ violation.Line = line
+ violation.Column = located.Column
+ }
+ schemaValidationErrors = append(schemaValidationErrors, violation)
}
- schemaValidationErrors = append(schemaValidationErrors, violation)
}
}
@@ -300,7 +284,7 @@ func ValidateRequestSchema(input *ValidateRequestSchemaInput) (bool, []*errors.V
}
// add the error to the list
- validationErrors = append(validationErrors, &errors.ValidationError{
+ validationErrors = append(validationErrors, &liberrors.ValidationError{
ValidationType: helpers.RequestBodyValidation,
ValidationSubType: helpers.Schema,
Message: fmt.Sprintf("%s request body for '%s' failed to validate schema",
@@ -310,7 +294,7 @@ func ValidateRequestSchema(input *ValidateRequestSchemaInput) (bool, []*errors.V
SpecLine: line,
SpecCol: col,
SchemaValidationErrors: schemaValidationErrors,
- HowToFix: errors.HowToFixInvalidSchema,
+ HowToFix: liberrors.HowToFixInvalidSchema,
Context: schema,
})
}
@@ -335,14 +319,14 @@ func ValidateRequestSchema(input *ValidateRequestSchemaInput) (bool, []*errors.V
switch undeclared.Type {
case strict.TypeReadOnlyProperty:
validationErrors = append(validationErrors,
- errors.ReadOnlyPropertyError(
+ liberrors.ReadOnlyPropertyError(
undeclared.Path, undeclared.Name, undeclared.Value,
request.URL.Path, request.Method,
undeclared.SpecLine, undeclared.SpecCol,
))
default:
validationErrors = append(validationErrors,
- errors.UndeclaredPropertyError(
+ liberrors.UndeclaredPropertyError(
undeclared.Path,
undeclared.Name,
undeclared.Value,
diff --git a/vendor/github.com/pb33f/libopenapi-validator/responses/response_body.go b/vendor/github.com/pb33f/libopenapi-validator/responses/response_body.go
index 62bac3f64..1efd97405 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/responses/response_body.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/responses/response_body.go
@@ -1,4 +1,4 @@
-// Copyright 2023 Princess B33f Heavy Industries / Dave Shanley
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
// SPDX-License-Identifier: MIT
package responses
@@ -10,6 +10,7 @@ import (
"github.com/pb33f/libopenapi-validator/config"
"github.com/pb33f/libopenapi-validator/errors"
+ "github.com/pb33f/libopenapi-validator/internal/bodycodec"
)
// ResponseBodyValidator is an interface that defines the methods for validating response bodies for Operations.
@@ -26,11 +27,15 @@ type ResponseBodyValidator interface {
// locate the operation in the specification, the response is used to ensure the response code, media type and the
// schema of the response body are valid.
ValidateResponseBodyWithPathItem(request *http.Request, response *http.Response, pathItem *v3.PathItem, pathFound string) (bool, []*errors.ValidationError)
+
+ // Release clears validator-owned options and drops the OpenAPI document reference.
+ Release()
}
// NewResponseBodyValidator will create a new ResponseBodyValidator from an OpenAPI 3+ document
func NewResponseBodyValidator(document *v3.Document, opts ...config.Option) ResponseBodyValidator {
options := config.NewValidationOptions(opts...)
+ bodycodec.Apply(options)
return &responseBodyValidator{options: options, document: document}
}
@@ -39,3 +44,14 @@ type responseBodyValidator struct {
options *config.ValidationOptions
document *v3.Document
}
+
+func (r *responseBodyValidator) Release() {
+ if r == nil {
+ return
+ }
+ if r.options != nil {
+ r.options.Release()
+ r.options = nil
+ }
+ r.document = nil
+}
diff --git a/vendor/github.com/pb33f/libopenapi-validator/responses/validate_body.go b/vendor/github.com/pb33f/libopenapi-validator/responses/validate_body.go
index 82d779685..06c7c7a9b 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/responses/validate_body.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/responses/validate_body.go
@@ -5,7 +5,7 @@ package responses
import (
"bytes"
- "encoding/json"
+ stderrors "errors"
"fmt"
"io"
"net/http"
@@ -17,10 +17,11 @@ import (
v3 "github.com/pb33f/libopenapi/datamodel/high/v3"
"github.com/pb33f/libopenapi-validator/config"
+ "github.com/pb33f/libopenapi-validator/content"
"github.com/pb33f/libopenapi-validator/errors"
"github.com/pb33f/libopenapi-validator/helpers"
+ "github.com/pb33f/libopenapi-validator/internal/bodycodec"
"github.com/pb33f/libopenapi-validator/paths"
- "github.com/pb33f/libopenapi-validator/schema_validation"
)
func (v *responseBodyValidator) ValidateResponseBody(
@@ -77,11 +78,11 @@ func (v *responseBodyValidator) ValidateResponseBodyWithPathItem(request *http.R
}
if foundResponse != nil {
- if foundResponse.Content != nil { // only validate if we have content types.
+ if v.options.ValidateResponseBody && foundResponse.Content != nil { // only validate if we have content types.
// check content type has been defined in the contract
if mediaType, ok := foundResponse.Content.Get(mediaTypeSting); ok {
validationErrors = append(validationErrors,
- v.checkResponseSchema(request, response, mediaTypeSting, mediaType)...)
+ v.checkResponseSchema(request, response, contentType, mediaType, operation)...)
} else {
// check that the operation *actually* returns a body. (i.e. a 204 response)
if foundResponse.Content != nil && orderedmap.Len(foundResponse.Content) > 0 {
@@ -95,10 +96,12 @@ func (v *responseBodyValidator) ValidateResponseBodyWithPathItem(request *http.R
// no code match, check for default response
if operation.Responses.Default != nil && operation.Responses.Default.Content != nil {
// check content type has been defined in the contract
- if mediaType, ok := operation.Responses.Default.Content.Get(mediaTypeSting); ok {
+ if !v.options.ValidateResponseBody {
+ foundResponse = operation.Responses.Default
+ } else if mediaType, ok := operation.Responses.Default.Content.Get(mediaTypeSting); ok {
foundResponse = operation.Responses.Default
validationErrors = append(validationErrors,
- v.checkResponseSchema(request, response, contentType, mediaType)...)
+ v.checkResponseSchema(request, response, contentType, mediaType, operation)...)
} else {
// check that the operation *actually* returns a body. (i.e. a 204 response)
if operation.Responses.Default.Content != nil && orderedmap.Len(operation.Responses.Default.Content) > 0 {
@@ -107,7 +110,7 @@ func (v *responseBodyValidator) ValidateResponseBodyWithPathItem(request *http.R
errors.ResponseContentTypeNotFound(operation, request, response, codeStr, true))
}
}
- } else {
+ } else if v.options.ValidateResponseStatus {
// TODO: add support for '2XX' and '3XX' responses in the contract
// no default, no code match, nothing!
validationErrors = append(validationErrors,
@@ -137,6 +140,7 @@ func (v *responseBodyValidator) checkResponseSchema(
response *http.Response,
contentType string,
mediaType *v3.MediaType,
+ operation *v3.Operation,
) []*errors.ValidationError {
var validationErrors []*errors.ValidationError
@@ -144,64 +148,89 @@ func (v *responseBodyValidator) checkResponseSchema(
return validationErrors
}
- // currently, we can only validate JSON, XML and URL Encoded based responses, so check for the presence
- // of 'json' (what ever it may be) and for XML/URLEncoded content type so we can perform a schema check on it.
- // anything other than JSON XML, or URL Encoded will be ignored.
-
- isXml := schema_validation.IsXMLContentType(contentType)
- isUrlEncoded := schema_validation.IsURLEncodedContentType(contentType)
isJson := strings.Contains(strings.ToLower(contentType), helpers.JSONType)
- xmlValid := isXml && v.options.AllowXMLBodyValidation
- urlEncodedValid := isUrlEncoded && v.options.AllowURLEncodedBodyValidation
-
- if !isJson && !xmlValid && !urlEncodedValid {
- return validationErrors
- }
-
schema := mediaType.Schema.Schema()
+ decoder, normalized, parameters := v.options.BodyRegistry.Decoder(contentType)
+ if decoder == nil && isJson {
+ decoder = content.JSONDecoder()
+ }
+ if decoder == nil {
+ if !v.options.RejectUnsupportedBodyContent {
+ return validationErrors
+ }
+ return []*errors.ValidationError{{
+ ValidationType: helpers.ResponseBodyValidation, ValidationSubType: helpers.Schema,
+ Message: fmt.Sprintf("%d response body has no registered decoder", response.StatusCode),
+ Reason: fmt.Sprintf("no body decoder is registered for %s", contentType),
+ Context: &content.FailureContext{Request: request, Response: response, Operation: operation, MediaType: mediaType, Schema: schema},
+ }}
+ }
+ if response == nil || response.Body == nil || response.Body == http.NoBody {
+ validationResponse := response
+ if response != nil && response.Body == nil {
+ copyResponse := *response
+ copyResponse.Body = http.NoBody
+ validationResponse = ©Response
+ }
+ _, bodyErrors := ValidateResponseSchema(&ValidateResponseSchemaInput{
+ Request: request, Response: validationResponse, Schema: schema,
+ Version: helpers.VersionToFloat(v.document.Version), Options: []config.Option{config.WithExistingOpts(v.options)},
+ })
+ return bodyErrors
+ }
+ responseBody, readErr := io.ReadAll(response.Body)
+ _ = response.Body.Close()
+ response.Body = io.NopCloser(bytes.NewReader(responseBody))
+ if readErr != nil {
+ return []*errors.ValidationError{{
+ ValidationType: helpers.ResponseBodyValidation, ValidationSubType: helpers.Schema,
+ Message: "response body could not be read", Reason: "The response body cannot be decoded: " + readErr.Error(), Context: schema,
+ }}
+ }
- if !isJson {
- if response != nil && response.Body != http.NoBody {
- responseBody, _ := io.ReadAll(response.Body)
- _ = response.Body.Close()
-
- stringedBody := string(responseBody)
- var jsonBody any
- var prevalidationErrors []*errors.ValidationError
-
- switch {
- case xmlValid:
- jsonBody, prevalidationErrors = schema_validation.TransformXMLToSchemaJSON(stringedBody, schema)
- case urlEncodedValid:
- jsonBody, prevalidationErrors = schema_validation.TransformURLEncodedToSchemaJSON(stringedBody, schema, mediaType.Encoding)
- }
-
- if len(prevalidationErrors) > 0 {
- return prevalidationErrors
- }
-
- transformedBytes, err := json.Marshal(jsonBody)
- if err != nil {
- switch {
- case isXml:
- return []*errors.ValidationError{errors.InvalidXMLParsing(err.Error(), stringedBody)}
- case isUrlEncoded:
- return []*errors.ValidationError{errors.InvalidURLEncodedParsing(err.Error(), stringedBody)}
- }
- }
-
- response.Body = io.NopCloser(bytes.NewBuffer(transformedBytes))
+ var decodedValue any
+ decoded := false
+ var decodeErr error
+ decodedValue, decodeErr = decoder.Decode(&content.DecodeInput{
+ Context: request.Context(), Body: bytes.NewReader(responseBody), Header: response.Header,
+ MediaType: normalized, Parameters: parameters, Schema: schema, Encoding: mediaType.Encoding, Direction: content.Response,
+ })
+ if decodeErr == nil {
+ decodedValue, decodeErr = content.Canonicalize(decodedValue)
+ }
+ if decodeErr != nil {
+ var transformErrors *bodycodec.ValidationErrors
+ if stderrors.As(decodeErr, &transformErrors) {
+ return transformErrors.Errors
+ }
+ structured := &content.DecodingError{MediaType: normalized, Direction: content.Response, Err: decodeErr}
+ if isJson {
+ return []*errors.ValidationError{{
+ ValidationType: helpers.ResponseBodyValidation, ValidationSubType: helpers.Schema,
+ Message: fmt.Sprintf("%s response body for '%s' failed to validate schema", request.Method, request.URL.Path),
+ Reason: "The response body cannot be decoded: " + structured.Error(),
+ Context: &content.FailureContext{Request: request, Response: response, Operation: operation, MediaType: mediaType, Schema: schema},
+ }}
}
+ return []*errors.ValidationError{{
+ ValidationType: helpers.ResponseBodyValidation, ValidationSubType: helpers.Schema,
+ Message: fmt.Sprintf("%d response body could not be decoded", response.StatusCode), Reason: structured.Error(),
+ Context: &content.FailureContext{Request: request, Response: response, Operation: operation, MediaType: mediaType, Schema: schema},
+ }}
}
+ decoded = true
// Validate response schema
valid, vErrs := ValidateResponseSchema(&ValidateResponseSchemaInput{
- Request: request,
- Response: response,
- Schema: schema,
- Version: helpers.VersionToFloat(v.document.Version),
- Options: []config.Option{config.WithExistingOpts(v.options)},
+ Request: request,
+ Response: response,
+ Schema: schema,
+ Version: helpers.VersionToFloat(v.document.Version),
+ Options: []config.Option{config.WithExistingOpts(v.options)},
+ DecodedValue: decodedValue,
+ RawBody: responseBody,
+ ValueDecoded: decoded,
})
if !valid {
diff --git a/vendor/github.com/pb33f/libopenapi-validator/responses/validate_response.go b/vendor/github.com/pb33f/libopenapi-validator/responses/validate_response.go
index f750dc9f0..e307b8630 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/responses/validate_response.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/responses/validate_response.go
@@ -6,6 +6,7 @@ package responses
import (
"bytes"
"encoding/json"
+ "errors"
"fmt"
"io"
"net/http"
@@ -14,15 +15,13 @@ import (
"strconv"
"github.com/pb33f/libopenapi/datamodel/high/base"
- "github.com/pb33f/libopenapi/utils"
"github.com/santhosh-tekuri/jsonschema/v6"
"go.yaml.in/yaml/v4"
"golang.org/x/text/language"
"golang.org/x/text/message"
- "github.com/pb33f/libopenapi-validator/cache"
"github.com/pb33f/libopenapi-validator/config"
- "github.com/pb33f/libopenapi-validator/errors"
+ liberrors "github.com/pb33f/libopenapi-validator/errors"
"github.com/pb33f/libopenapi-validator/helpers"
"github.com/pb33f/libopenapi-validator/schema_validation"
"github.com/pb33f/libopenapi-validator/strict"
@@ -32,11 +31,14 @@ var instanceLocationRegex = regexp.MustCompile(`^/(\d+)`)
// ValidateResponseSchemaInput contains parameters for response schema validation.
type ValidateResponseSchemaInput struct {
- Request *http.Request // Required: The HTTP request (for context)
- Response *http.Response // Required: The HTTP response to validate
- Schema *base.Schema // Required: The OpenAPI schema to validate against
- Version float32 // Required: OpenAPI version (3.0 or 3.1)
- Options []config.Option // Optional: Functional options (defaults applied if empty/nil)
+ Request *http.Request // Required: The HTTP request (for context)
+ Response *http.Response // Required: The HTTP response to validate
+ Schema *base.Schema // Required: The OpenAPI schema to validate against
+ Version float32 // Required: OpenAPI version (3.0 or 3.1)
+ Options []config.Option // Optional: Functional options (defaults applied if empty/nil)
+ DecodedValue any // Optional: A value produced by a registered body decoder
+ RawBody []byte // Optional: Original bytes used for diagnostics with DecodedValue
+ ValueDecoded bool // Distinguishes an explicitly decoded nil from the legacy JSON path
}
// ValidateResponseSchema will validate the response body for a http.Response pointer. The request is used to
@@ -45,23 +47,24 @@ type ValidateResponseSchemaInput struct {
//
// This function is used by the ValidateResponseBody function, but can be used independently.
// The schema will be compiled from cache if available, otherwise it will be compiled and cached.
-func ValidateResponseSchema(input *ValidateResponseSchemaInput) (bool, []*errors.ValidationError) {
+func ValidateResponseSchema(input *ValidateResponseSchemaInput) (bool, []*liberrors.ValidationError) {
validationOptions := config.NewValidationOptions(input.Options...)
- var validationErrors []*errors.ValidationError
- var renderedSchema, jsonSchema []byte
+ var validationErrors []*liberrors.ValidationError
+ var renderedSchema []byte
var referenceSchema string
var compiledSchema *jsonschema.Schema
var cachedNode *yaml.Node
+ var resourceNodes map[string]*yaml.Node
if input.Schema == nil {
- return false, []*errors.ValidationError{{
+ return false, []*liberrors.ValidationError{{
ValidationType: helpers.ResponseBodyValidation,
ValidationSubType: helpers.Schema,
Message: "schema is nil",
Reason: "The schema to validate against is nil",
}}
} else if input.Schema.GoLow() == nil {
- return false, []*errors.ValidationError{{
+ return false, []*liberrors.ValidationError{{
ValidationType: helpers.ResponseBodyValidation,
ValidationSubType: helpers.Schema,
Message: "schema cannot be rendered",
@@ -70,56 +73,30 @@ func ValidateResponseSchema(input *ValidateResponseSchemaInput) (bool, []*errors
}
if validationOptions.SchemaCache != nil {
- hash := input.Schema.GoLow().Hash()
+ hash := schema_validation.SchemaCacheKey(
+ input.Schema.GoLow().Hash(),
+ input.Version,
+ schema_validation.SchemaValidationPurposeResponseBody,
+ )
if cached, ok := validationOptions.SchemaCache.Load(hash); ok && cached != nil && cached.CompiledSchema != nil {
renderedSchema = cached.RenderedInline
referenceSchema = cached.ReferenceSchema
compiledSchema = cached.CompiledSchema
cachedNode = cached.RenderedNode
+ resourceNodes = cached.ResourceNodes
}
}
// Cache miss or no cache - render and compile
if compiledSchema == nil {
- renderCtx := base.NewInlineRenderContextForValidation()
- var renderErr error
- renderedSchema, renderErr = input.Schema.RenderInlineWithContext(renderCtx)
- referenceSchema = string(renderedSchema)
-
- // If rendering failed (e.g., circular reference), return the render error
- if renderErr != nil {
- violation := &errors.SchemaValidationFailure{
- Reason: renderErr.Error(),
- ReferenceSchema: referenceSchema,
- }
- validationErrors = append(validationErrors, &errors.ValidationError{
- ValidationType: helpers.ResponseBodyValidation,
- ValidationSubType: helpers.Schema,
- Message: fmt.Sprintf("%d response body for '%s' failed schema rendering",
- input.Response.StatusCode, input.Request.URL.Path),
- Reason: fmt.Sprintf("The response schema for status code '%d' failed to render: %s",
- input.Response.StatusCode, renderErr.Error()),
- SpecLine: 1,
- SpecCol: 0,
- SchemaValidationErrors: []*errors.SchemaValidationFailure{violation},
- HowToFix: "check the response schema for circular references or invalid structures",
- Context: referenceSchema,
- })
- return false, validationErrors
- }
-
- jsonSchema, _ = utils.ConvertYAMLtoJSON(renderedSchema)
-
- var err error
- schemaName := fmt.Sprintf("%x", input.Schema.GoLow().Hash())
- compiledSchema, err = helpers.NewCompiledSchemaWithVersion(
- schemaName,
- jsonSchema,
+ compiled, err := schema_validation.CompileSchemaForValidation(
+ input.Schema,
+ schema_validation.SchemaValidationPurposeResponseBody,
validationOptions,
input.Version,
)
if err != nil {
- validationErrors = append(validationErrors, &errors.ValidationError{
+ validationErrors = append(validationErrors, &liberrors.ValidationError{
ValidationType: helpers.ResponseBodyValidation,
ValidationSubType: helpers.Schema,
Message: fmt.Sprintf("%d response body for '%s' failed schema compilation",
@@ -133,16 +110,19 @@ func ValidateResponseSchema(input *ValidateResponseSchemaInput) (bool, []*errors
})
return false, validationErrors
}
+ renderedSchema = compiled.RenderedInline
+ referenceSchema = compiled.ReferenceSchema
+ cachedNode = compiled.RenderedNode
+ resourceNodes = compiled.ResourceNodes
+ compiledSchema = compiled.CompiledSchema
if validationOptions.SchemaCache != nil {
- hash := input.Schema.GoLow().Hash()
- validationOptions.SchemaCache.Store(hash, &cache.SchemaCacheEntry{
- Schema: input.Schema,
- RenderedInline: renderedSchema,
- ReferenceSchema: referenceSchema,
- RenderedJSON: jsonSchema,
- CompiledSchema: compiledSchema,
- })
+ hash := schema_validation.SchemaCacheKey(
+ input.Schema.GoLow().Hash(),
+ input.Version,
+ schema_validation.SchemaValidationPurposeResponseBody,
+ )
+ validationOptions.SchemaCache.Store(hash, compiled.ToCacheEntry(input.Schema))
}
}
@@ -157,7 +137,7 @@ func ValidateResponseSchema(input *ValidateResponseSchemaInput) (bool, []*errors
return len(validationErrors) == 0, validationErrors
}
// cannot decode the response body, so it's not valid
- validationErrors = append(validationErrors, &errors.ValidationError{
+ validationErrors = append(validationErrors, &liberrors.ValidationError{
ValidationType: "response",
ValidationSubType: "object",
Message: fmt.Sprintf("%s response object is missing for '%s'",
@@ -171,38 +151,44 @@ func ValidateResponseSchema(input *ValidateResponseSchemaInput) (bool, []*errors
return false, validationErrors
}
- responseBody, ioErr := io.ReadAll(response.Body)
- if ioErr != nil {
- // cannot decode the response body, so it's not valid
- validationErrors = append(validationErrors, &errors.ValidationError{
- ValidationType: helpers.ResponseBodyValidation,
- ValidationSubType: helpers.Schema,
- Message: fmt.Sprintf("%s response body for '%s' cannot be read, it's empty or malformed",
- request.Method, request.URL.Path),
- Reason: fmt.Sprintf("The response body cannot be decoded: %s", ioErr.Error()),
- SpecLine: 1,
- SpecCol: 0,
- HowToFix: "ensure body is not empty",
- Context: schema,
- })
- return false, validationErrors
+ responseBody := input.RawBody
+ if !input.ValueDecoded {
+ var ioErr error
+ responseBody, ioErr = io.ReadAll(response.Body)
+ if ioErr != nil {
+ // cannot decode the response body, so it's not valid
+ validationErrors = append(validationErrors, &liberrors.ValidationError{
+ ValidationType: helpers.ResponseBodyValidation,
+ ValidationSubType: helpers.Schema,
+ Message: fmt.Sprintf("%s response body for '%s' cannot be read, it's empty or malformed",
+ request.Method, request.URL.Path),
+ Reason: fmt.Sprintf("The response body cannot be decoded: %s", ioErr.Error()),
+ SpecLine: 1,
+ SpecCol: 0,
+ HowToFix: "ensure body is not empty",
+ Context: schema,
+ })
+ return false, validationErrors
+ }
}
// close the request body, so it can be re-read later by another player in the chain
- _ = response.Body.Close()
- response.Body = io.NopCloser(bytes.NewBuffer(responseBody))
+ if !input.ValueDecoded {
+ _ = response.Body.Close()
+ response.Body = io.NopCloser(bytes.NewBuffer(responseBody))
+ }
- var decodedObj interface{}
+ decodedObj := input.DecodedValue
if len(responseBody) > 0 {
// Per RFC7231, a response to a HEAD request MUST NOT include a message body.
if request != nil && request.Method == http.MethodHead {
- violation := &errors.SchemaValidationFailure{
+ violation := &liberrors.SchemaValidationFailure{
Reason: "HEAD responses must not include a message body",
ReferenceObject: string(responseBody),
ReferenceSchema: referenceSchema,
}
- validationErrors = append(validationErrors, &errors.ValidationError{
+ validationErrors = append(validationErrors, &liberrors.ValidationError{
ValidationType: helpers.ResponseBodyValidation,
ValidationSubType: helpers.Schema,
Message: fmt.Sprintf("%s response for '%s' must not include a body",
@@ -210,16 +196,19 @@ func ValidateResponseSchema(input *ValidateResponseSchemaInput) (bool, []*errors
Reason: "The response to a HEAD request must not contain a body",
SpecLine: 1,
SpecCol: 0,
- SchemaValidationErrors: []*errors.SchemaValidationFailure{violation},
+ SchemaValidationErrors: []*liberrors.SchemaValidationFailure{violation},
HowToFix: "ensure no response body is present for HEAD requests",
Context: referenceSchema,
})
return false, validationErrors
}
- err := json.Unmarshal(responseBody, &decodedObj)
+ var err error
+ if !input.ValueDecoded {
+ err = json.Unmarshal(responseBody, &decodedObj)
+ }
if err != nil {
// cannot decode the response body, so it's not valid
- validationErrors = append(validationErrors, &errors.ValidationError{
+ validationErrors = append(validationErrors, &liberrors.ValidationError{
ValidationType: helpers.ResponseBodyValidation,
ValidationSubType: helpers.Schema,
Message: fmt.Sprintf("%s response body for '%s' failed to validate schema",
@@ -227,7 +216,7 @@ func ValidateResponseSchema(input *ValidateResponseSchemaInput) (bool, []*errors
Reason: fmt.Sprintf("The response body cannot be decoded: %s", err.Error()),
SpecLine: 1,
SpecCol: 0,
- HowToFix: errors.HowToFixInvalidSchema,
+ HowToFix: liberrors.HowToFixInvalidSchema,
Context: schema,
})
return false, validationErrors
@@ -242,75 +231,82 @@ func ValidateResponseSchema(input *ValidateResponseSchemaInput) (bool, []*errors
// validate the object against the schema
scErrs := compiledSchema.Validate(decodedObj)
if scErrs != nil {
- jk := scErrs.(*jsonschema.ValidationError)
+ var jk *jsonschema.ValidationError
+ var schemaValidationErrors []*liberrors.SchemaValidationFailure
- // flatten the validationErrors
- schFlatErrs := jk.BasicOutput().Errors
- var schemaValidationErrors []*errors.SchemaValidationFailure
+ if errors.As(scErrs, &jk) {
+ // flatten the validationErrors
+ schFlatErrs := helpers.FlattenSchemaOutputErrors(jk.DetailedOutput())
- renderedNode := cachedNode
- if renderedNode == nil {
- renderedNode = new(yaml.Node)
- _ = yaml.Unmarshal(renderedSchema, renderedNode)
- }
+ renderedNode := cachedNode
+ if renderedNode == nil {
+ renderedNode = new(yaml.Node)
+ _ = yaml.Unmarshal(renderedSchema, renderedNode)
+ }
- for q := range schFlatErrs {
- er := schFlatErrs[q]
+ for q := range schFlatErrs {
+ er := schFlatErrs[q]
- errMsg := er.Error.Kind.LocalizedString(message.NewPrinter(language.Tag{}))
- if er.KeywordLocation == "" || helpers.IgnoreRegex.MatchString(errMsg) {
- continue // ignore this error, it's useless tbh, utter noise.
- }
- if er.Error != nil {
- // locate the violated property in the schema
- var located *yaml.Node
- if len(renderedNode.Content) > 0 {
- located = schema_validation.LocateSchemaPropertyNodeByJSONPath(renderedNode.Content[0], er.KeywordLocation)
+ errMsg := er.Error.Kind.LocalizedString(message.NewPrinter(language.Tag{}))
+ if er.KeywordLocation == "" || helpers.IgnoreRegex.MatchString(errMsg) {
+ continue // ignore this error, it's useless tbh, utter noise.
}
+ if er.Error != nil {
+ // locate the violated property in the schema
+ var located *yaml.Node
+ if renderedNode != nil {
+ located = schema_validation.LocateSchemaPropertyNodeByJSONPathWithResources(
+ renderedNode,
+ resourceNodes,
+ er.KeywordLocation,
+ er.AbsoluteKeywordLocation,
+ )
+ }
- // extract the element specified by the instance
- val := instanceLocationRegex.FindStringSubmatch(er.InstanceLocation)
- var referenceObject string
+ // extract the element specified by the instance
+ val := instanceLocationRegex.FindStringSubmatch(er.InstanceLocation)
+ var referenceObject string
- if len(val) > 0 {
- referenceIndex, _ := strconv.Atoi(val[1])
- if reflect.ValueOf(decodedObj).Type().Kind() == reflect.Slice {
- found := decodedObj.([]any)[referenceIndex]
- recoded, _ := json.MarshalIndent(found, "", " ")
- referenceObject = string(recoded)
+ if len(val) > 0 {
+ referenceIndex, _ := strconv.Atoi(val[1])
+ if reflect.ValueOf(decodedObj).Type().Kind() == reflect.Slice {
+ found := decodedObj.([]any)[referenceIndex]
+ recoded, _ := json.MarshalIndent(found, "", " ")
+ referenceObject = string(recoded)
+ }
+ }
+ if referenceObject == "" {
+ referenceObject = string(responseBody)
}
- }
- if referenceObject == "" {
- referenceObject = string(responseBody)
- }
- violation := &errors.SchemaValidationFailure{
- Reason: errMsg,
- FieldName: helpers.ExtractFieldNameFromStringLocation(er.InstanceLocation),
- FieldPath: helpers.ExtractJSONPathFromStringLocation(er.InstanceLocation),
- InstancePath: helpers.ConvertStringLocationToPathSegments(er.InstanceLocation),
- KeywordLocation: er.KeywordLocation,
- ReferenceSchema: referenceSchema,
- ReferenceObject: referenceObject,
- OriginalJsonSchemaError: jk,
- }
- // if we have a location within the schema, add it to the error
- if located != nil {
-
- line := located.Line
- // if the located node is a map or an array, then the actual human interpretable
- // line on which the violation occurred is the line of the key, not the value.
- if located.Kind == yaml.MappingNode || located.Kind == yaml.SequenceNode {
- if line > 0 {
- line--
- }
+ violation := &liberrors.SchemaValidationFailure{
+ Reason: errMsg,
+ FieldName: helpers.ExtractFieldNameFromStringLocation(er.InstanceLocation),
+ FieldPath: helpers.ExtractJSONPathFromStringLocation(er.InstanceLocation),
+ InstancePath: helpers.ConvertStringLocationToPathSegments(er.InstanceLocation),
+ KeywordLocation: er.KeywordLocation,
+ ReferenceSchema: referenceSchema,
+ ReferenceObject: referenceObject,
+ OriginalJsonSchemaError: jk,
}
+ // if we have a location within the schema, add it to the error
+ if located != nil {
+
+ line := located.Line
+ // if the located node is a map or an array, then the actual human interpretable
+ // line on which the violation occurred is the line of the key, not the value.
+ if located.Kind == yaml.MappingNode || located.Kind == yaml.SequenceNode {
+ if line > 0 {
+ line--
+ }
+ }
- // location of the violation within the rendered schema.
- violation.Line = line
- violation.Column = located.Column
+ // location of the violation within the rendered schema.
+ violation.Line = line
+ violation.Column = located.Column
+ }
+ schemaValidationErrors = append(schemaValidationErrors, violation)
}
- schemaValidationErrors = append(schemaValidationErrors, violation)
}
}
@@ -322,7 +318,7 @@ func ValidateResponseSchema(input *ValidateResponseSchemaInput) (bool, []*errors
}
// add the error to the list
- validationErrors = append(validationErrors, &errors.ValidationError{
+ validationErrors = append(validationErrors, &liberrors.ValidationError{
ValidationType: helpers.ResponseBodyValidation,
ValidationSubType: helpers.Schema,
Message: fmt.Sprintf("%d response body for '%s' failed to validate schema",
@@ -332,7 +328,7 @@ func ValidateResponseSchema(input *ValidateResponseSchemaInput) (bool, []*errors
SpecLine: line,
SpecCol: col,
SchemaValidationErrors: schemaValidationErrors,
- HowToFix: errors.HowToFixInvalidSchema,
+ HowToFix: liberrors.HowToFixInvalidSchema,
Context: schema,
})
}
@@ -357,14 +353,14 @@ func ValidateResponseSchema(input *ValidateResponseSchemaInput) (bool, []*errors
switch undeclared.Type {
case strict.TypeWriteOnlyProperty:
validationErrors = append(validationErrors,
- errors.WriteOnlyPropertyError(
+ liberrors.WriteOnlyPropertyError(
undeclared.Path, undeclared.Name, undeclared.Value,
request.URL.Path, request.Method,
undeclared.SpecLine, undeclared.SpecCol,
))
default:
validationErrors = append(validationErrors,
- errors.UndeclaredPropertyError(
+ liberrors.UndeclaredPropertyError(
undeclared.Path,
undeclared.Name,
undeclared.Value,
diff --git a/vendor/github.com/pb33f/libopenapi-validator/router/router.go b/vendor/github.com/pb33f/libopenapi-validator/router/router.go
new file mode 100644
index 000000000..89d07ef0b
--- /dev/null
+++ b/vendor/github.com/pb33f/libopenapi-validator/router/router.go
@@ -0,0 +1,538 @@
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
+// SPDX-License-Identifier: MIT
+
+// Package router matches HTTP requests to OpenAPI operations without running validation.
+//
+// A Router returns the effective server, path template, path item, operation,
+// decoded server variables, and raw and decoded path parameters. Standalone
+// routers enforce OpenAPI server precedence by default; WithPathOnlyMatching
+// provides the validator's backward-compatible path-only behavior.
+package router
+
+import (
+ "errors"
+ "fmt"
+ "net/http"
+ "net/url"
+ "regexp"
+ "sort"
+ "strings"
+ "sync"
+
+ "github.com/pb33f/libopenapi/orderedmap"
+
+ v3 "github.com/pb33f/libopenapi/datamodel/high/v3"
+
+ "github.com/pb33f/libopenapi-validator/radix"
+)
+
+var (
+ // ErrPathNotFound identifies requests that do not match an effective server and path.
+ ErrPathNotFound = errors.New("openapi path not found")
+ // ErrMethodNotAllowed identifies requests whose path exists but method does not.
+ // FindRoute returns a partial Route alongside this error.
+ ErrMethodNotAllowed = errors.New("openapi operation not found")
+)
+
+// RegexCache stores compiled path expressions. config.RegexCache satisfies this contract.
+// Values stored by the router are *regexp.Regexp instances.
+type RegexCache interface {
+ // Load returns a previously cached value for key.
+ Load(key any) (value any, ok bool)
+ // Store associates value with key.
+ Store(key, value any)
+}
+
+// PathLookup performs fast standard-template lookup. radix.PathLookup satisfies this contract.
+type PathLookup interface {
+ // Lookup returns the matched path item, its OpenAPI path template, and whether a match was found.
+ Lookup(string) (*v3.PathItem, string, bool)
+}
+
+// Router locates an OpenAPI route for a request.
+type Router interface {
+ // FindRoute returns the route selected for a request.
+ //
+ // A method mismatch returns a non-nil partial Route and an error matching
+ // ErrMethodNotAllowed. A server or path mismatch returns a nil Route and an
+ // error matching ErrPathNotFound.
+ FindRoute(*http.Request) (*Route, error)
+ // Release drops document and router-owned lookup references. Injected lookups
+ // and regex caches are borrowed and are never released by the router.
+ Release()
+}
+
+// Route describes the OpenAPI operation selected for a request.
+type Route struct {
+ Document *v3.Document // Document is the OpenAPI document used for matching.
+ Server *v3.Server // Server is the matched server, or nil for the implicit relative server.
+ Path string // Path is the matched OpenAPI path template.
+ PathItem *v3.PathItem // PathItem is the matched OpenAPI path item.
+ Method string // Method is the request method, including additional methods.
+ Operation *v3.Operation // Operation is nil on a method mismatch.
+ // RawPathParams contains escaped parameter values exactly as matched in the URL path.
+ RawPathParams map[string]string
+ // PathParams contains URL-decoded operation path parameter values.
+ PathParams map[string]string
+ // ServerParams contains URL-decoded server variable values.
+ ServerParams map[string]string
+}
+
+// RouteError retains partial match context while supporting errors.Is.
+type RouteError struct {
+ Kind error // Kind is ErrPathNotFound or ErrMethodNotAllowed.
+ Route *Route // Route is populated for method mismatches and nil for path misses.
+}
+
+// Error returns the stable error message for the route failure kind.
+func (e *RouteError) Error() string {
+ if e == nil || e.Kind == nil {
+ return "openapi route error"
+ }
+ return e.Kind.Error()
+}
+
+// Unwrap exposes the stable route error kind.
+func (e *RouteError) Unwrap() error {
+ if e == nil {
+ return nil
+ }
+ return e.Kind
+}
+
+type options struct {
+ lookup PathLookup
+ regexCache RegexCache
+ pathOnly bool
+}
+
+// Option configures Router construction.
+type Option func(*options)
+
+// WithPathLookup borrows a path lookup. The router never releases it.
+func WithPathLookup(lookup PathLookup) Option {
+ return func(o *options) { o.lookup = lookup }
+}
+
+// WithRegexCache borrows a compiled-regex cache. The router never releases it.
+func WithRegexCache(cache RegexCache) Option {
+ return func(o *options) { o.regexCache = cache }
+}
+
+// WithPathOnlyMatching preserves validator-compatible document base-path matching.
+func WithPathOnlyMatching() Option {
+ return func(o *options) { o.pathOnly = true }
+}
+
+type routeFinder struct {
+ mu sync.RWMutex
+ document *v3.Document
+ lookup PathLookup
+ ownedLookup *radix.PathTree
+ regexCache RegexCache
+ pathOnly bool
+ servers []*v3.Server
+ paths map[string]*compiledPath
+ serverMatch map[*v3.Server]*compiledServer
+}
+
+type compiledPath struct {
+ expression *regexp.Regexp
+ names []string
+}
+
+// NewRouter creates an immutable, concurrency-safe router.
+// Strict OpenAPI server matching is enabled unless WithPathOnlyMatching is supplied.
+func NewRouter(document *v3.Document, opts ...Option) Router {
+ o := &options{}
+ for _, opt := range opts {
+ if opt != nil {
+ opt(o)
+ }
+ }
+ r := &routeFinder{document: document, lookup: o.lookup, regexCache: o.regexCache, pathOnly: o.pathOnly}
+ if r.lookup == nil {
+ r.ownedLookup = radix.BuildPathTree(document)
+ r.lookup = r.ownedLookup
+ }
+ if !r.pathOnly {
+ r.servers = collectServers(document)
+ }
+ r.paths = compileDocumentPaths(document, r.regexCache)
+ r.serverMatch = compileDocumentServers(r.servers)
+ return r
+}
+
+func (r *routeFinder) FindRoute(request *http.Request) (*Route, error) {
+ if r == nil {
+ return nil, &RouteError{Kind: ErrPathNotFound}
+ }
+ r.mu.RLock()
+ defer r.mu.RUnlock()
+ if request == nil || request.URL == nil || r.document == nil || r.document.Paths == nil || r.document.Paths.PathItems == nil {
+ return nil, &RouteError{Kind: ErrPathNotFound}
+ }
+
+ if r.pathOnly {
+ return r.find(request, compatibilityPath(request, r.document), compatibilityServer(request, r.document), nil)
+ }
+
+ if len(r.servers) == 0 {
+ return r.find(request, request.URL.EscapedPath(), nil, nil)
+ }
+
+ var partial *Route
+ for _, server := range r.servers {
+ path, params, ok := matchCompiledServer(request, server, r.serverMatch[server])
+ if !ok {
+ continue
+ }
+ route, err := r.find(request, path, server, params)
+ if route == nil {
+ continue
+ }
+ if !serverIsEffective(server, route.Operation, route.PathItem, r.document) {
+ continue
+ }
+ if err == nil {
+ return route, nil
+ }
+ partial = route
+ }
+ implicit, implicitErr := r.find(request, request.URL.EscapedPath(), nil, nil)
+ if implicit != nil && usesImplicitServer(implicit.Operation, implicit.PathItem, r.document) {
+ if implicitErr == nil {
+ return implicit, nil
+ }
+ if partial == nil {
+ partial = implicit
+ }
+ }
+ if partial != nil {
+ return partial, &RouteError{Kind: ErrMethodNotAllowed, Route: partial}
+ }
+ return nil, &RouteError{Kind: ErrPathNotFound}
+}
+
+func usesImplicitServer(operation *v3.Operation, item *v3.PathItem, document *v3.Document) bool {
+ return (operation == nil || len(operation.Servers) == 0) &&
+ (item == nil || len(item.Servers) == 0) &&
+ (document == nil || len(document.Servers) == 0)
+}
+
+func (r *routeFinder) find(request *http.Request, requestPath string, server *v3.Server, serverParams map[string]string) (*Route, error) {
+ if requestPath == "" {
+ requestPath = "/"
+ }
+ pathItem, path, found := r.lookup.Lookup(requestPath)
+ if found && !simpleRadixTemplate(path) {
+ compiled := r.compiledPath(path, requestPath)
+ found = compiled != nil && compiled.expression.MatchString(requestPath)
+ }
+ if found && (!r.pathOnly && !sameTrailingSlash(path, requestPath)) {
+ found = false
+ }
+ if !found {
+ pathItem, path = r.regexLookup(requestPath, request.Method)
+ found = pathItem != nil
+ }
+ if !found {
+ return nil, &RouteError{Kind: ErrPathNotFound}
+ }
+
+ operation := operationForMethod(pathItem, request.Method)
+ raw, decoded := r.extractPathParams(path, requestPath)
+ route := &Route{
+ Document: r.document,
+ Server: server,
+ Path: path,
+ PathItem: pathItem,
+ Method: request.Method,
+ Operation: operation,
+ RawPathParams: raw,
+ PathParams: decoded,
+ ServerParams: serverParams,
+ }
+ if operation == nil {
+ return route, &RouteError{Kind: ErrMethodNotAllowed, Route: route}
+ }
+ return route, nil
+}
+
+type candidate struct {
+ path string
+ item *v3.PathItem
+ score int
+ hasMethod bool
+}
+
+func (r *routeFinder) regexLookup(requestPath, method string) (*v3.PathItem, string) {
+ candidates := make([]candidate, 0)
+ for pair := orderedmap.First(r.document.Paths.PathItems); pair != nil; pair = pair.Next() {
+ compiled := r.compiledPath(pair.Key(), requestPath)
+ if compiled != nil && compiled.expression.MatchString(requestPath) {
+ candidates = append(candidates, candidate{pair.Key(), pair.Value(), specificity(pair.Key()), operationForMethod(pair.Value(), method) != nil})
+ }
+ }
+ if len(candidates) == 0 {
+ return nil, ""
+ }
+ sort.SliceStable(candidates, func(i, j int) bool {
+ if candidates[i].hasMethod != candidates[j].hasMethod {
+ return candidates[i].hasMethod
+ }
+ if candidates[i].score != candidates[j].score {
+ return candidates[i].score > candidates[j].score
+ }
+ return candidates[i].path < candidates[j].path
+ })
+ return candidates[0].item, candidates[0].path
+}
+
+func (r *routeFinder) Release() {
+ if r == nil {
+ return
+ }
+ r.mu.Lock()
+ defer r.mu.Unlock()
+ if r.ownedLookup != nil {
+ r.ownedLookup.Release()
+ }
+ r.document = nil
+ r.lookup = nil
+ r.ownedLookup = nil
+ r.regexCache = nil
+ r.servers = nil
+ r.paths = nil
+ r.serverMatch = nil
+}
+
+func operationForMethod(item *v3.PathItem, method string) *v3.Operation {
+ if item == nil {
+ return nil
+ }
+ switch method {
+ case http.MethodGet:
+ return item.Get
+ case http.MethodPut:
+ return item.Put
+ case http.MethodPost:
+ return item.Post
+ case http.MethodDelete:
+ return item.Delete
+ case http.MethodOptions:
+ return item.Options
+ case http.MethodHead:
+ if item.Head != nil {
+ return item.Head
+ }
+ return item.Get
+ case http.MethodPatch:
+ return item.Patch
+ case http.MethodTrace:
+ return item.Trace
+ case "QUERY":
+ return item.Query
+ }
+ if item.AdditionalOperations != nil {
+ for pair := orderedmap.First(item.AdditionalOperations); pair != nil; pair = pair.Next() {
+ if strings.EqualFold(pair.Key(), method) {
+ return pair.Value()
+ }
+ }
+ }
+ return nil
+}
+
+func sameTrailingSlash(template, requestPath string) bool {
+ return strings.HasSuffix(template, "/") == strings.HasSuffix(requestPath, "/")
+}
+
+func simpleRadixTemplate(path string) bool {
+ for _, segment := range strings.Split(strings.Trim(path, "/"), "/") {
+ if !strings.ContainsAny(segment, "{}") {
+ continue
+ }
+ if len(segment) < 3 || segment[0] != '{' || segment[len(segment)-1] != '}' || strings.ContainsAny(segment[1:len(segment)-1], ":.*;") {
+ return false
+ }
+ }
+ return true
+}
+
+func normalizeFragment(path, requestPath string) string {
+ if !strings.Contains(requestPath, "#") {
+ if i := strings.IndexByte(path, '#'); i >= 0 {
+ return path[:i]
+ }
+ }
+ return path
+}
+
+func specificity(path string) int {
+ score := 0
+ for _, segment := range strings.Split(path, "/") {
+ if segment == "" {
+ continue
+ }
+ if strings.Contains(segment, "{") && strings.Contains(segment, "}") {
+ score++
+ } else {
+ score += 1000
+ }
+ }
+ return score
+}
+
+func compileDocumentPaths(document *v3.Document, cache RegexCache) map[string]*compiledPath {
+ compiled := make(map[string]*compiledPath)
+ if document == nil || document.Paths == nil || document.Paths.PathItems == nil {
+ return compiled
+ }
+ for pair := orderedmap.First(document.Paths.PathItems); pair != nil; pair = pair.Next() {
+ for _, path := range []string{pair.Key(), normalizeFragment(pair.Key(), "")} {
+ if _, exists := compiled[path]; exists {
+ continue
+ }
+ if cache != nil {
+ if value, ok := cache.Load(path); ok {
+ if expression, valid := value.(*regexp.Regexp); valid {
+ if names, err := templateNames(path); err == nil {
+ compiled[path] = &compiledPath{expression: expression, names: names}
+ continue
+ }
+ }
+ }
+ }
+ expression, names, err := compileTemplate(path, "[^/]*")
+ if err == nil {
+ compiled[path] = &compiledPath{expression: expression, names: names}
+ if cache != nil {
+ cache.Store(path, expression)
+ }
+ }
+ }
+ }
+ return compiled
+}
+
+func templateNames(template string) ([]string, error) {
+ indices, err := braceIndices(template)
+ if err != nil {
+ return nil, err
+ }
+ names := make([]string, 0, len(indices)/2)
+ for i := 0; i < len(indices); i += 2 {
+ parts := strings.SplitN(template[indices[i]+1:indices[i+1]-1], ":", 2)
+ name := strings.TrimSuffix(strings.TrimLeft(parts[0], ".;"), "*")
+ if name == "" {
+ return nil, fmt.Errorf("invalid route parameter in %q", template)
+ }
+ names = append(names, name)
+ }
+ return names, nil
+}
+
+func (r *routeFinder) compiledPath(path, requestPath string) *compiledPath {
+ if r == nil {
+ return nil
+ }
+ normalized := normalizeFragment(path, requestPath)
+ if compiled := r.paths[normalized]; compiled != nil {
+ return compiled
+ }
+ expression, names, err := compileTemplate(normalized, "[^/]*")
+ if err != nil {
+ return nil
+ }
+ return &compiledPath{expression: expression, names: names}
+}
+
+func compileTemplate(template, defaultPattern string) (*regexp.Regexp, []string, error) {
+ indices, err := braceIndices(template)
+ if err != nil {
+ return nil, nil, err
+ }
+ var pattern strings.Builder
+ pattern.WriteByte('^')
+ names := make([]string, 0, len(indices)/2)
+ end := 0
+ for i := 0; i < len(indices); i += 2 {
+ pattern.WriteString(regexp.QuoteMeta(template[end:indices[i]]))
+ end = indices[i+1]
+ parts := strings.SplitN(template[indices[i]+1:end-1], ":", 2)
+ name := strings.TrimSuffix(strings.TrimLeft(parts[0], ".;"), "*")
+ match := defaultPattern
+ if len(parts) == 2 {
+ match = parts[1]
+ }
+ if name == "" || match == "" {
+ return nil, nil, fmt.Errorf("invalid route parameter in %q", template)
+ }
+ names = append(names, name)
+ pattern.WriteByte('(')
+ pattern.WriteString(match)
+ pattern.WriteByte(')')
+ }
+ pattern.WriteString(regexp.QuoteMeta(template[end:]))
+ pattern.WriteByte('$')
+ expression, err := regexp.Compile(pattern.String())
+ if err != nil {
+ return nil, nil, err
+ }
+ if expression.NumSubexp() != len(names) {
+ return nil, nil, fmt.Errorf("route %s contains capturing groups", template)
+ }
+ return expression, names, nil
+}
+
+func braceIndices(value string) ([]int, error) {
+ level, start := 0, 0
+ var indices []int
+ for i := 0; i < len(value); i++ {
+ switch value[i] {
+ case '{':
+ level++
+ if level == 1 {
+ start = i
+ }
+ case '}':
+ level--
+ if level == 0 {
+ indices = append(indices, start, i+1)
+ } else if level < 0 {
+ return nil, fmt.Errorf("unbalanced braces in %q", value)
+ }
+ }
+ }
+ if level != 0 {
+ return nil, fmt.Errorf("unbalanced braces in %q", value)
+ }
+ return indices, nil
+}
+
+func (r *routeFinder) extractPathParams(template, requestPath string) (map[string]string, map[string]string) {
+ compiled := r.compiledPath(template, requestPath)
+ if compiled == nil || len(compiled.names) == 0 {
+ return nil, nil
+ }
+ matches := compiled.expression.FindStringSubmatch(requestPath)
+ if len(matches) != len(compiled.names)+1 {
+ return nil, nil
+ }
+ raw := make(map[string]string, len(compiled.names))
+ decoded := make(map[string]string, len(compiled.names))
+ for i, name := range compiled.names {
+ raw[name] = matches[i+1]
+ decoded[name] = decodePathValue(matches[i+1])
+ }
+ return raw, decoded
+}
+
+func decodePathValue(value string) string {
+ decoded, err := url.PathUnescape(value)
+ if err != nil {
+ return value
+ }
+ return decoded
+}
diff --git a/vendor/github.com/pb33f/libopenapi-validator/router/server.go b/vendor/github.com/pb33f/libopenapi-validator/router/server.go
new file mode 100644
index 000000000..aaed2451f
--- /dev/null
+++ b/vendor/github.com/pb33f/libopenapi-validator/router/server.go
@@ -0,0 +1,233 @@
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
+// SPDX-License-Identifier: MIT
+
+package router
+
+import (
+ "net/http"
+ "net/url"
+ "regexp"
+ "strings"
+
+ "github.com/pb33f/libopenapi/orderedmap"
+
+ v3 "github.com/pb33f/libopenapi/datamodel/high/v3"
+)
+
+type compiledServer struct {
+ expression *regexp.Regexp
+ names []string
+ absolute bool
+}
+
+func compileDocumentServers(servers []*v3.Server) map[*v3.Server]*compiledServer {
+ compiled := make(map[*v3.Server]*compiledServer, len(servers))
+ for _, server := range servers {
+ template, absolute := normalizeServerTemplate(server)
+ expression, names, err := compileServerTemplate(template)
+ if err == nil {
+ compiled[server] = &compiledServer{expression: expression, names: names, absolute: absolute}
+ }
+ }
+ return compiled
+}
+
+func collectServers(document *v3.Document) []*v3.Server {
+ if document == nil {
+ return nil
+ }
+ seen := make(map[*v3.Server]struct{})
+ var servers []*v3.Server
+ add := func(values []*v3.Server) {
+ for _, server := range values {
+ if server == nil {
+ continue
+ }
+ if _, ok := seen[server]; !ok {
+ seen[server] = struct{}{}
+ servers = append(servers, server)
+ }
+ }
+ }
+ add(document.Servers)
+ if document.Paths != nil && document.Paths.PathItems != nil {
+ for pair := orderedmap.First(document.Paths.PathItems); pair != nil; pair = pair.Next() {
+ item := pair.Value()
+ add(item.Servers)
+ for operation := item.GetOperations().First(); operation != nil; operation = operation.Next() {
+ add(operation.Value().Servers)
+ }
+ }
+ }
+ return servers
+}
+
+func serverIsEffective(server *v3.Server, operation *v3.Operation, item *v3.PathItem, document *v3.Document) bool {
+ var effective []*v3.Server
+ if operation != nil && len(operation.Servers) > 0 {
+ effective = operation.Servers
+ } else if item != nil && len(item.Servers) > 0 {
+ effective = item.Servers
+ } else if document != nil {
+ effective = document.Servers
+ }
+ for _, candidate := range effective {
+ if candidate == server {
+ return true
+ }
+ }
+ return false
+}
+
+func matchServer(request *http.Request, server *v3.Server) (string, map[string]string, bool) {
+ if request == nil || request.URL == nil || server == nil {
+ return "", nil, false
+ }
+ template, absolute := normalizeServerTemplate(server)
+ expression, names, err := compileServerTemplate(template)
+ if err != nil {
+ return "", nil, false
+ }
+ return matchCompiledServer(request, server, &compiledServer{expression: expression, names: names, absolute: absolute})
+}
+
+func normalizeServerTemplate(server *v3.Server) (string, bool) {
+ template := server.URL
+ if template == "" {
+ template = "/"
+ }
+ absolute := strings.Contains(template, "://")
+ if !absolute && !strings.HasPrefix(template, "/") {
+ template = "/" + template
+ }
+ template = strings.TrimSuffix(template, "/")
+ if template == "" {
+ template = "/"
+ }
+ return template, absolute
+}
+
+func matchCompiledServer(request *http.Request, server *v3.Server, compiled *compiledServer) (string, map[string]string, bool) {
+ if request == nil || request.URL == nil || server == nil || compiled == nil {
+ return "", nil, false
+ }
+ target := request.URL.EscapedPath()
+ if compiled.absolute {
+ scheme := request.URL.Scheme
+ if scheme == "" {
+ if request.TLS != nil {
+ scheme = "https"
+ } else {
+ scheme = "http"
+ }
+ }
+ host := request.URL.Host
+ if host == "" {
+ host = request.Host
+ }
+ target = scheme + "://" + host + target
+ }
+
+ matches := compiled.expression.FindStringSubmatch(target)
+ if matches == nil {
+ return "", nil, false
+ }
+ params := make(map[string]string, len(compiled.names))
+ for i, name := range compiled.names {
+ value := decodePathValue(matches[i+1])
+ if variable := serverVariable(server, name); variable != nil && len(variable.Enum) > 0 && !contains(variable.Enum, value) {
+ return "", nil, false
+ }
+ params[name] = value
+ }
+ rest := matches[len(matches)-1]
+ if rest == "" {
+ rest = "/"
+ }
+ return rest, params, true
+}
+
+func compileServerTemplate(template string) (*regexp.Regexp, []string, error) {
+ if template == "/" {
+ expression, err := regexp.Compile(`^(/.*|/)$`)
+ return expression, nil, err
+ }
+ indices, err := braceIndices(template)
+ if err != nil {
+ return nil, nil, err
+ }
+ var pattern strings.Builder
+ pattern.WriteByte('^')
+ names := make([]string, 0, len(indices)/2)
+ end := 0
+ for i := 0; i < len(indices); i += 2 {
+ pattern.WriteString(regexp.QuoteMeta(template[end:indices[i]]))
+ end = indices[i+1]
+ name := template[indices[i]+1 : end-1]
+ if name == "" {
+ return nil, nil, &url.Error{Op: "parse", URL: template, Err: url.InvalidHostError("empty server variable")}
+ }
+ names = append(names, name)
+ pattern.WriteString("([^/?#]+)")
+ }
+ pattern.WriteString(regexp.QuoteMeta(template[end:]))
+ pattern.WriteString("(/.*|$)")
+ expression, err := regexp.Compile(pattern.String())
+ return expression, names, err
+}
+
+func serverVariable(server *v3.Server, name string) *v3.ServerVariable {
+ if server == nil || server.Variables == nil {
+ return nil
+ }
+ return server.Variables.GetOrZero(name)
+}
+
+func contains(values []string, target string) bool {
+ for _, value := range values {
+ if value == target {
+ return true
+ }
+ }
+ return false
+}
+
+func compatibilityPath(request *http.Request, document *v3.Document) string {
+ path := request.URL.EscapedPath()
+ if document != nil {
+ for _, server := range document.Servers {
+ if server == nil {
+ continue
+ }
+ parsed, err := url.Parse(server.URL)
+ if err == nil && parsed.Path != "" && strings.HasPrefix(path, parsed.Path) {
+ path = strings.TrimPrefix(path, parsed.Path)
+ break
+ }
+ }
+ }
+ if request.URL.Fragment != "" {
+ path += "#" + request.URL.Fragment
+ }
+ if !strings.HasPrefix(path, "/") {
+ path = "/" + path
+ }
+ return path
+}
+
+func compatibilityServer(request *http.Request, document *v3.Document) *v3.Server {
+ if request == nil || request.URL == nil || document == nil {
+ return nil
+ }
+ path := request.URL.EscapedPath()
+ for _, server := range document.Servers {
+ if server == nil {
+ continue
+ }
+ parsed, err := url.Parse(server.URL)
+ if err == nil && parsed.Path != "" && strings.HasPrefix(path, parsed.Path) {
+ return server
+ }
+ }
+ return nil
+}
diff --git a/vendor/github.com/pb33f/libopenapi-validator/schema_validation/directional_schema.go b/vendor/github.com/pb33f/libopenapi-validator/schema_validation/directional_schema.go
new file mode 100644
index 000000000..126051633
--- /dev/null
+++ b/vendor/github.com/pb33f/libopenapi-validator/schema_validation/directional_schema.go
@@ -0,0 +1,236 @@
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
+// SPDX-License-Identifier: MIT
+
+package schema_validation
+
+import (
+ "encoding/json"
+ "fmt"
+ "math"
+
+ "github.com/pb33f/libopenapi/datamodel/high/base"
+ "github.com/pb33f/libopenapi/utils"
+ "go.yaml.in/yaml/v4"
+)
+
+// SchemaValidationPurpose identifies the context in which a schema is compiled.
+// Request and response bodies need distinct cache entries because readOnly and
+// writeOnly annotations change required-property semantics by direction.
+type SchemaValidationPurpose uint64
+
+const (
+ SchemaValidationPurposeGeneric SchemaValidationPurpose = iota
+ SchemaValidationPurposeRequestBody
+ SchemaValidationPurposeResponseBody
+)
+
+const schemaCachePurposeSalt uint64 = 0x9e3779b97f4a7c15
+
+// RenderedValidationSchema contains a rendered schema and its JSON equivalent.
+type RenderedValidationSchema struct {
+ RenderedInline []byte
+ ReferenceSchema string
+ RenderedJSON []byte
+ RenderedNode *yaml.Node
+}
+
+// SchemaCacheKey returns a cache key for a schema compiled in a validation context.
+func SchemaCacheKey(schemaHash uint64, version float32, purpose SchemaValidationPurpose) uint64 {
+ if purpose == SchemaValidationPurposeGeneric {
+ return schemaHash
+ }
+ versionBits := uint64(math.Float32bits(version))
+ return schemaHash ^ (versionBits << 32) ^ versionBits ^ (uint64(purpose) * schemaCachePurposeSalt)
+}
+
+// RenderSchemaForValidation renders schema for the supplied validation purpose.
+// For request bodies it removes readOnly properties from required lists, and for
+// response bodies it removes writeOnly properties from required lists.
+func RenderSchemaForValidation(schema *base.Schema, purpose SchemaValidationPurpose) (*RenderedValidationSchema, error) {
+ if schema == nil {
+ return nil, nil
+ }
+
+ renderCtx := base.NewInlineRenderContextForValidation()
+ nodeIface, err := schema.MarshalYAMLInlineWithContext(renderCtx)
+ renderedNode, _ := nodeIface.(*yaml.Node)
+ if err != nil {
+ renderedInline, _ := yaml.Marshal(renderedNode)
+ return &RenderedValidationSchema{
+ RenderedInline: renderedInline,
+ ReferenceSchema: string(renderedInline),
+ RenderedNode: renderedNode,
+ }, err
+ }
+
+ return renderSchemaNodeForValidation(renderedNode, purpose)
+}
+
+func renderSchemaBytesForValidation(renderedInline []byte, purpose SchemaValidationPurpose) (*RenderedValidationSchema, error) {
+ renderedNode := new(yaml.Node)
+ if err := yaml.Unmarshal(renderedInline, renderedNode); err != nil {
+ return nil, fmt.Errorf("schema render decode failed: %w", err)
+ }
+
+ return renderSchemaNodeForValidation(renderedNode, purpose)
+}
+
+func renderSchemaNodeForValidation(renderedNode *yaml.Node, purpose SchemaValidationPurpose) (*RenderedValidationSchema, error) {
+ pruneDirectionalRequired(schemaRootNode(renderedNode), purpose)
+
+ renderedInline, _ := yaml.Marshal(renderedNode)
+ renderedJSON := renderSchemaNodeJSON(renderedNode, renderedInline)
+
+ return &RenderedValidationSchema{
+ RenderedInline: renderedInline,
+ ReferenceSchema: string(renderedInline),
+ RenderedJSON: renderedJSON,
+ RenderedNode: renderedNode,
+ }, nil
+}
+
+func renderSchemaNodeJSON(renderedNode *yaml.Node, renderedInline []byte) []byte {
+ var jsonValue any
+ if rootNode := schemaRootNode(renderedNode); rootNode != nil {
+ if err := rootNode.Decode(&jsonValue); err == nil {
+ renderedJSON, _ := json.Marshal(jsonValue)
+ return renderedJSON
+ }
+ }
+ renderedJSON, _ := utils.ConvertYAMLtoJSON(renderedInline)
+ return renderedJSON
+}
+
+func schemaRootNode(node *yaml.Node) *yaml.Node {
+ if node == nil {
+ return nil
+ }
+ if node.Kind == yaml.DocumentNode && len(node.Content) > 0 {
+ return node.Content[0]
+ }
+ return node
+}
+
+func pruneDirectionalRequired(schemaNode *yaml.Node, purpose SchemaValidationPurpose) {
+ if schemaNode == nil || schemaNode.Kind != yaml.MappingNode {
+ return
+ }
+
+ pruneRequiredAtSchema(schemaNode, purpose)
+
+ for _, key := range []string{"properties", "patternProperties", "$defs", "definitions", "dependentSchemas"} {
+ if childMap := mappingValue(schemaNode, key); childMap != nil && childMap.Kind == yaml.MappingNode {
+ for i := 1; i < len(childMap.Content); i += 2 {
+ pruneDirectionalRequired(childMap.Content[i], purpose)
+ }
+ }
+ }
+
+ for _, key := range []string{"items", "contains", "additionalProperties", "unevaluatedProperties", "propertyNames", "not", "if", "then", "else"} {
+ pruneDirectionalRequired(mappingValue(schemaNode, key), purpose)
+ }
+
+ for _, key := range []string{"prefixItems", "allOf", "anyOf", "oneOf"} {
+ if childSeq := mappingValue(schemaNode, key); childSeq != nil && childSeq.Kind == yaml.SequenceNode {
+ for _, item := range childSeq.Content {
+ pruneDirectionalRequired(item, purpose)
+ }
+ }
+ }
+}
+
+func pruneRequiredAtSchema(schemaNode *yaml.Node, purpose SchemaValidationPurpose) {
+ if purpose != SchemaValidationPurposeRequestBody && purpose != SchemaValidationPurposeResponseBody {
+ return
+ }
+
+ requiredIndex, requiredNode := mappingPair(schemaNode, "required")
+ if requiredNode == nil || requiredNode.Kind != yaml.SequenceNode {
+ return
+ }
+ propertiesNode := mappingValue(schemaNode, "properties")
+ if propertiesNode == nil || propertiesNode.Kind != yaml.MappingNode {
+ return
+ }
+
+ prunedRequired := make([]*yaml.Node, 0, len(requiredNode.Content))
+ for _, item := range requiredNode.Content {
+ if item == nil || item.Kind != yaml.ScalarNode {
+ prunedRequired = append(prunedRequired, item)
+ continue
+ }
+ propertySchema := mappingValue(propertiesNode, item.Value)
+ if propertySchemaHasDirectionalAnnotation(propertySchema, purpose) {
+ continue
+ }
+ prunedRequired = append(prunedRequired, item)
+ }
+
+ if len(prunedRequired) == 0 {
+ removeMappingPair(schemaNode, requiredIndex)
+ return
+ }
+ requiredNode.Content = prunedRequired
+}
+
+func propertySchemaHasDirectionalAnnotation(schemaNode *yaml.Node, purpose SchemaValidationPurpose) bool {
+ if schemaNode == nil || schemaNode.Kind != yaml.MappingNode {
+ return false
+ }
+
+ switch purpose {
+ case SchemaValidationPurposeRequestBody:
+ if boolMappingValue(schemaNode, "readOnly") {
+ return true
+ }
+ case SchemaValidationPurposeResponseBody:
+ if boolMappingValue(schemaNode, "writeOnly") {
+ return true
+ }
+ }
+
+ for _, key := range []string{"allOf", "anyOf", "oneOf"} {
+ if childSeq := mappingValue(schemaNode, key); childSeq != nil && childSeq.Kind == yaml.SequenceNode {
+ for _, item := range childSeq.Content {
+ if propertySchemaHasDirectionalAnnotation(item, purpose) {
+ return true
+ }
+ }
+ }
+ }
+
+ return false
+}
+
+func mappingPair(node *yaml.Node, key string) (int, *yaml.Node) {
+ if node == nil || node.Kind != yaml.MappingNode {
+ return -1, nil
+ }
+ for i := 0; i+1 < len(node.Content); i += 2 {
+ keyNode := node.Content[i]
+ if keyNode != nil && keyNode.Value == key {
+ return i, node.Content[i+1]
+ }
+ }
+ return -1, nil
+}
+
+func mappingValue(node *yaml.Node, key string) *yaml.Node {
+ _, value := mappingPair(node, key)
+ return value
+}
+
+func boolMappingValue(node *yaml.Node, key string) bool {
+ value := mappingValue(node, key)
+ if value == nil || value.Kind != yaml.ScalarNode {
+ return false
+ }
+ return (value.Tag == "!!bool" || value.Tag == "") && value.Value == "true"
+}
+
+func removeMappingPair(node *yaml.Node, keyIndex int) {
+ if node == nil || keyIndex < 0 || keyIndex+1 >= len(node.Content) {
+ return
+ }
+ node.Content = append(node.Content[:keyIndex], node.Content[keyIndex+2:]...)
+}
diff --git a/vendor/github.com/pb33f/libopenapi-validator/schema_validation/locate_schema_property.go b/vendor/github.com/pb33f/libopenapi-validator/schema_validation/locate_schema_property.go
index a84ce3776..9d70bd1e1 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/schema_validation/locate_schema_property.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/schema_validation/locate_schema_property.go
@@ -1,9 +1,12 @@
-// Copyright 2023 Princess B33f Heavy Industries / Dave Shanley
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
// SPDX-License-Identifier: MIT
package schema_validation
import (
+ "net/url"
+ "strings"
+
"github.com/pb33f/jsonpath/pkg/jsonpath"
"github.com/pb33f/jsonpath/pkg/jsonpath/config"
"github.com/pb33f/libopenapi/utils"
@@ -13,20 +16,110 @@ import (
// LocateSchemaPropertyNodeByJSONPath will locate a schema property node by a JSONPath. It converts something like
// #/components/schemas/MySchema/properties/MyProperty to something like $.components.schemas.MySchema.properties.MyProperty
func LocateSchemaPropertyNodeByJSONPath(doc *yaml.Node, JSONPath string) *yaml.Node {
+ JSONPath = normalizeKeywordLocation(JSONPath)
+ _, path := utils.ConvertComponentIdIntoFriendlyPathSearch(JSONPath)
+ return locateSchemaPropertyNode(doc, path)
+}
+
+// LocateSchemaPropertyNodeByJSONPathFallback locates a schema node using a primary and fallback keyword location.
+func LocateSchemaPropertyNodeByJSONPathFallback(doc *yaml.Node, primaryLocation, fallbackLocation string) *yaml.Node {
+ return LocateSchemaPropertyNodeByJSONPathWithResources(doc, nil, primaryLocation, fallbackLocation)
+}
+
+// LocateSchemaPropertyNodeByJSONPathWithResources locates a schema node, selecting external resource nodes when available.
+func LocateSchemaPropertyNodeByJSONPathWithResources(
+ doc *yaml.Node,
+ resourceNodes map[string]*yaml.Node,
+ primaryLocation, fallbackLocation string,
+) *yaml.Node {
+ located := locateSchemaPropertyNodeByKeywordLocation(doc, resourceNodes, primaryLocation)
+ if located != nil || fallbackLocation == "" {
+ return located
+ }
+ return locateSchemaPropertyNodeByKeywordLocation(doc, resourceNodes, fallbackLocation)
+}
+
+func normalizeKeywordLocation(location string) string {
+ _, pointer := splitKeywordLocation(location)
+ return pointer
+}
+
+func locateSchemaPropertyNodeByKeywordLocation(
+ doc *yaml.Node,
+ resourceNodes map[string]*yaml.Node,
+ location string,
+) *yaml.Node {
+ resourceName, pointer := splitKeywordLocation(location)
+ sourceNode := doc
+ if resourceNodes != nil {
+ if resourceName != "" {
+ if resourceNode := lookupResourceNode(resourceNodes, resourceName); resourceNode != nil {
+ sourceNode = resourceNode
+ }
+ } else if strings.HasPrefix(location, "#") {
+ if resourceNode := resourceNodes[""]; resourceNode != nil {
+ sourceNode = resourceNode
+ }
+ }
+ }
+ return LocateSchemaPropertyNodeByJSONPath(rootContentNode(sourceNode), pointer)
+}
+
+func lookupResourceNode(resourceNodes map[string]*yaml.Node, resourceName string) *yaml.Node {
+ if resourceNode := resourceNodes[resourceName]; resourceNode != nil {
+ return resourceNode
+ }
+ if !strings.HasPrefix(resourceName, "file:") {
+ return resourceNodes[canonicalResourceName(resourceName)]
+ }
+
+ parsedURL, err := url.Parse(resourceName)
+ if err != nil || parsedURL.Scheme != "file" || parsedURL.Path == "" {
+ return nil
+ }
+
+ if resourceNode := resourceNodes[parsedURL.String()]; resourceNode != nil {
+ return resourceNode
+ }
+ filePath, _ := url.PathUnescape(parsedURL.Path)
+ if resourceNode := resourceNodes[filePath]; resourceNode != nil {
+ return resourceNode
+ }
+ return resourceNodes[canonicalResourceName(filePath)]
+}
+
+func splitKeywordLocation(location string) (string, string) {
+ if location == "" || strings.HasPrefix(location, "#") || strings.HasPrefix(location, "/") {
+ return "", location
+ }
+
+ hashIndex := strings.Index(location, "#")
+ if hashIndex < 0 {
+ return "", location
+ }
+ return location[:hashIndex], location[hashIndex:]
+}
+
+func rootContentNode(node *yaml.Node) *yaml.Node {
+ if node != nil && node.Kind == yaml.DocumentNode && len(node.Content) > 0 {
+ return node.Content[0]
+ }
+ return node
+}
+
+func locateSchemaPropertyNode(doc *yaml.Node, path string) *yaml.Node {
+ if path == "" {
+ return nil
+ }
var locatedNode *yaml.Node
doneChan := make(chan bool)
locatedNodeChan := make(chan *yaml.Node)
go func() {
defer func() {
if err := recover(); err != nil {
- // can't search path, too crazy.
doneChan <- true
}
}()
- _, path := utils.ConvertComponentIdIntoFriendlyPathSearch(JSONPath)
- if path == "" {
- doneChan <- true
- }
jsonPath, _ := jsonpath.NewPath(path, config.WithLazyContextTracking())
locatedNodes := jsonPath.Query(doc)
if len(locatedNodes) > 0 {
diff --git a/vendor/github.com/pb33f/libopenapi-validator/schema_validation/schema_resources.go b/vendor/github.com/pb33f/libopenapi-validator/schema_validation/schema_resources.go
new file mode 100644
index 000000000..c881b7f15
--- /dev/null
+++ b/vendor/github.com/pb33f/libopenapi-validator/schema_validation/schema_resources.go
@@ -0,0 +1,747 @@
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
+// SPDX-License-Identifier: MIT
+
+package schema_validation
+
+import (
+ "fmt"
+ "net/url"
+ "path/filepath"
+ "strconv"
+ "strings"
+
+ "github.com/pb33f/libopenapi/datamodel/high/base"
+ "github.com/pb33f/libopenapi/index"
+ "github.com/pb33f/libopenapi/utils"
+ "github.com/santhosh-tekuri/jsonschema/v6"
+ "go.yaml.in/yaml/v4"
+
+ "github.com/pb33f/libopenapi-validator/cache"
+ "github.com/pb33f/libopenapi-validator/config"
+ "github.com/pb33f/libopenapi-validator/helpers"
+)
+
+const syntheticSchemaResourceBase = "https://libopenapi-validator.local/schema/"
+
+// renderSchemaWithRefs keeps fallback rendering testable without depending on libopenapi internals failing.
+var renderSchemaWithRefs = func(schema *base.Schema) ([]byte, error) {
+ return schema.Render()
+}
+
+var renderSchemaForValidation = RenderSchemaForValidation
+
+// CompiledValidationSchema contains a schema compiled for validation plus the rendered schema context.
+type CompiledValidationSchema struct {
+ RenderedInline []byte
+ ReferenceSchema string
+ RenderedJSON []byte
+ RenderedNode *yaml.Node
+ ResourceNodes map[string]*yaml.Node
+ CompiledSchema *jsonschema.Schema
+}
+
+// schemaDocumentResourceSet is the in-memory set of JSON Schema resources passed to jsonschema.
+type schemaDocumentResourceSet struct {
+ resources map[string][]byte
+ resourceNodes map[string]*yaml.Node
+ entryName string
+ entryNode *yaml.Node
+}
+
+// schemaResourceBuildState tracks resource identity and recursion guards while walking reachable refs.
+type schemaResourceBuildState struct {
+ resourceNames map[*index.SpecIndex]string
+ seenRefs map[string]struct{}
+ seenNodes map[*yaml.Node]struct{}
+}
+
+// CompileSchemaForValidation compiles a schema for validation while preserving reachable references.
+func CompileSchemaForValidation(
+ schema *base.Schema,
+ purpose SchemaValidationPurpose,
+ options *config.ValidationOptions,
+ version float32,
+) (*CompiledValidationSchema, error) {
+ if schema == nil {
+ return nil, nil
+ }
+
+ rendered, err := renderRootSchemaForValidation(schema, purpose)
+ if err != nil {
+ return nil, err
+ }
+
+ if purpose == SchemaValidationPurposeGeneric && singleSchemaCompilePreferred(rendered) {
+ return compileSingleValidationSchema(schema, rendered, options, version)
+ }
+
+ var resourceCache cache.SchemaResourceCache
+ if options != nil {
+ resourceCache = options.SchemaResourceCache
+ }
+
+ resourceSet, err := buildSchemaDocumentResources(schema, purpose, resourceCache)
+ if err != nil {
+ return nil, err
+ }
+
+ if resourceSet == nil || len(resourceSet.resources) == 0 || resourceSet.entryName == "" {
+ return compileSingleValidationSchema(schema, rendered, options, version)
+ }
+
+ compiled, compileErr := helpers.NewCompiledSchemaResourcesWithVersion(
+ resourceSet.entryName,
+ resourceSet.resources,
+ options,
+ version,
+ )
+ if compileErr != nil {
+ return nil, compileErr
+ }
+
+ return &CompiledValidationSchema{
+ RenderedInline: rendered.RenderedInline,
+ ReferenceSchema: rendered.ReferenceSchema,
+ RenderedJSON: rendered.RenderedJSON,
+ RenderedNode: resourceSet.entryNode,
+ ResourceNodes: resourceSet.resourceNodes,
+ CompiledSchema: compiled,
+ }, nil
+}
+
+// ToCacheEntry converts a compiled validation schema into the shared schema cache shape.
+func (c *CompiledValidationSchema) ToCacheEntry(schema *base.Schema) *cache.SchemaCacheEntry {
+ if c == nil {
+ return nil
+ }
+ return &cache.SchemaCacheEntry{
+ Schema: schema,
+ RenderedInline: c.RenderedInline,
+ ReferenceSchema: c.ReferenceSchema,
+ RenderedJSON: c.RenderedJSON,
+ CompiledSchema: c.CompiledSchema,
+ RenderedNode: c.RenderedNode,
+ ResourceNodes: c.ResourceNodes,
+ }
+}
+
+// compileSingleValidationSchema compiles one rendered schema document without building a resource graph.
+//
+// This keeps the no-ref path close to the legacy behavior and avoids the extra
+// resource rendering work needed only when reachable refs must stay addressable.
+func compileSingleValidationSchema(
+ schema *base.Schema,
+ rendered *RenderedValidationSchema,
+ options *config.ValidationOptions,
+ version float32,
+) (*CompiledValidationSchema, error) {
+ schemaName := "schema"
+ if schema != nil && schema.GoLow() != nil {
+ schemaName = fmt.Sprintf("%x", schema.GoLow().Hash())
+ }
+ compiled, compileErr := helpers.NewCompiledSchemaWithVersion(
+ schemaName,
+ rendered.RenderedJSON,
+ options,
+ version,
+ )
+ if compileErr != nil {
+ return nil, compileErr
+ }
+ return &CompiledValidationSchema{
+ RenderedInline: rendered.RenderedInline,
+ ReferenceSchema: rendered.ReferenceSchema,
+ RenderedJSON: rendered.RenderedJSON,
+ RenderedNode: rendered.RenderedNode,
+ ResourceNodes: sourceNodesForRenderedSchema(schemaName, rendered.RenderedNode),
+ CompiledSchema: compiled,
+ }, nil
+}
+
+// sourceNodesForRenderedSchema builds the source-node lookup for the single-resource compiler path.
+//
+// The same rendered node is indexed by both the empty resource name and the
+// compiler resource name because jsonschema diagnostics can identify the entry
+// schema either way depending on the reported location shape.
+func sourceNodesForRenderedSchema(resourceName string, renderedNode *yaml.Node) map[string]*yaml.Node {
+ if renderedNode == nil {
+ return nil
+ }
+
+ resourceNodes := map[string]*yaml.Node{
+ "": renderedNode,
+ }
+ if resourceName != "" {
+ resourceNodes[resourceName] = renderedNode
+ }
+ return resourceNodes
+}
+
+// renderRootSchemaForValidation renders the entry schema in the best form available for validation.
+//
+// The normal renderer is preferred because it applies request/response pruning
+// consistently. If inline rendering cannot resolve a circular graph, this falls
+// back to rendering the schema node with refs intact so the resource compiler can
+// preserve those refs.
+func renderRootSchemaForValidation(schema *base.Schema, purpose SchemaValidationPurpose) (*RenderedValidationSchema, error) {
+ if schema == nil {
+ return nil, nil
+ }
+ if schema.GoLow() == nil || schema.GoLow().GetRootNode() == nil {
+ return nil, fmt.Errorf("schema does not have low-level information and cannot be rendered")
+ }
+
+ rendered, err := renderSchemaForValidation(schema, purpose)
+ if err == nil {
+ return rendered, nil
+ }
+
+ renderedInline, err := renderSchemaWithRefs(schema)
+ if err != nil {
+ return nil, err
+ }
+
+ return renderSchemaBytesForValidation(renderedInline, purpose)
+}
+
+// singleSchemaCompilePreferred reports whether the rendered schema is already self-contained.
+//
+// Source schemas can contain refs that the inline renderer resolves cheaply. The
+// document-resource compiler is needed only when refs survive rendering, usually
+// because the schema graph is circular or otherwise must stay addressable.
+func singleSchemaCompilePreferred(rendered *RenderedValidationSchema) bool {
+ return rendered != nil && !renderedSchemaHasReachableRefs(rendered)
+}
+
+func renderedSchemaHasReachableRefs(rendered *RenderedValidationSchema) bool {
+ if rendered == nil {
+ return false
+ }
+ if rendered.RenderedNode != nil {
+ return hasSchemaRefValue(rendered.RenderedNode)
+ }
+ if len(rendered.RenderedInline) == 0 {
+ return false
+ }
+
+ var renderedNode yaml.Node
+ if err := yaml.Unmarshal(rendered.RenderedInline, &renderedNode); err != nil {
+ // Invalid YAML should fall back to the resource compiler, which returns the real compile error.
+ return true
+ }
+ return hasSchemaRefValue(&renderedNode)
+}
+
+// schemaHasReachableRefs checks whether the entry schema tree contains refs that jsonschema must resolve.
+func schemaHasReachableRefs(schema *base.Schema) bool {
+ if schema == nil || schema.GoLow() == nil {
+ return false
+ }
+ return hasSchemaRefValue(schema.GoLow().GetRootNode())
+}
+
+// renderYAMLNodeForValidation renders a YAML node to the YAML and JSON forms used by jsonschema.
+//
+// Request and response validation prune directional "required" markers, so they
+// clone before mutating. Generic validation does not prune, which keeps the
+// whole-document resource path allocation-light for ordinary document schemas.
+// Generic rendered nodes may be cached, so downstream diagnostic code must keep
+// treating them as read-only.
+func renderYAMLNodeForValidation(node *yaml.Node, purpose SchemaValidationPurpose) (*RenderedValidationSchema, error) {
+ if node == nil {
+ return nil, nil
+ }
+
+ renderedNode := node
+ if purpose != SchemaValidationPurposeGeneric {
+ renderedNode = cloneYAMLNode(node)
+ pruneDirectionalRequiredEverywhere(renderedNode, purpose)
+ }
+
+ renderedInline, err := yaml.Marshal(renderedNode)
+ if err != nil {
+ return nil, fmt.Errorf("schema render encode failed: %w", err)
+ }
+
+ renderedJSON, err := utils.ConvertYAMLtoJSON(renderedInline)
+ if err != nil {
+ return nil, fmt.Errorf("schema render JSON conversion failed: %w", err)
+ }
+
+ return &RenderedValidationSchema{
+ RenderedInline: renderedInline,
+ ReferenceSchema: string(renderedInline),
+ RenderedJSON: renderedJSON,
+ RenderedNode: renderedNode,
+ }, nil
+}
+
+// buildSchemaDocumentResources builds the resource graph needed for a schema with reachable refs.
+//
+// The root OpenAPI document is registered as a resource, then only documents
+// reachable from schema-keyword refs are added. The entry name points at the
+// specific schema node inside the root resource, not necessarily the document root.
+func buildSchemaDocumentResources(
+ schema *base.Schema,
+ purpose SchemaValidationPurpose,
+ resourceCache cache.SchemaResourceCache,
+) (*schemaDocumentResourceSet, error) {
+ if schema == nil || schema.GoLow() == nil {
+ return nil, nil
+ }
+
+ schemaIndex := schema.GoLow().GetIndex()
+ if schemaIndex == nil || schemaIndex.GetRootNode() == nil {
+ return nil, nil
+ }
+ if !schemaHasReachableRefs(schema) {
+ return nil, nil
+ }
+
+ schemaPointer, ok := jsonPointerForNode(schemaIndex.GetRootNode(), schema.GoLow().GetRootNode())
+ if !ok {
+ return nil, fmt.Errorf("schema node was not found in its root document")
+ }
+
+ state := &schemaResourceBuildState{
+ resourceNames: make(map[*index.SpecIndex]string),
+ seenRefs: make(map[string]struct{}),
+ seenNodes: make(map[*yaml.Node]struct{}),
+ }
+ rootResourceName := resourceNameForIndex(schemaIndex, schema.GoLow().Hash())
+ state.resourceNames[schemaIndex] = rootResourceName
+ resourceSet := &schemaDocumentResourceSet{
+ resources: make(map[string][]byte),
+ resourceNodes: make(map[string]*yaml.Node),
+ }
+ rootRendered, err := addSchemaDocumentResource(
+ resourceSet.resources,
+ resourceSet.resourceNodes,
+ rootResourceName,
+ schemaIndex.GetRootNode(),
+ purpose,
+ resourceCache,
+ )
+ if err != nil {
+ return nil, err
+ }
+
+ if err := addReachableSchemaResources(
+ resourceSet,
+ state,
+ schemaIndex,
+ schema.GoLow().GetRootNode(),
+ purpose,
+ resourceCache,
+ ); err != nil {
+ return nil, err
+ }
+
+ resourceSet.entryName = rootResourceName + "#" + schemaPointer
+ if rootRendered != nil {
+ resourceSet.entryNode = rootRendered.RenderedNode
+ }
+ return resourceSet, nil
+}
+
+// addReachableSchemaResources recursively adds resources referenced by schema-keyword refs.
+//
+// seenNodes prevents circular schema graphs from recursing forever, while
+// seenRefs prevents repeatedly visiting the same resolved definition through
+// different local paths.
+func addReachableSchemaResources(
+ resourceSet *schemaDocumentResourceSet,
+ state *schemaResourceBuildState,
+ currentIndex *index.SpecIndex,
+ node *yaml.Node,
+ purpose SchemaValidationPurpose,
+ resourceCache cache.SchemaResourceCache,
+) error {
+ if resourceSet == nil || state == nil || currentIndex == nil || node == nil {
+ return nil
+ }
+ if _, seen := state.seenNodes[node]; seen {
+ return nil
+ }
+ state.seenNodes[node] = struct{}{}
+
+ for _, refValue := range collectSchemaRefValues(node) {
+ foundRef, foundIndex := currentIndex.SearchIndexForReference(refValue)
+ if foundRef == nil {
+ continue
+ }
+ foundIndex = schemaResourceIndex(foundRef, foundIndex)
+ if foundIndex != nil && foundIndex.GetRootNode() != nil {
+ resourceName := ensureSchemaResourceName(state, foundIndex, uint64(len(resourceSet.resources)+1))
+ refKey := resourceName + "|" + foundRef.FullDefinition
+ if _, seen := state.seenRefs[refKey]; seen {
+ continue
+ }
+ state.seenRefs[refKey] = struct{}{}
+
+ if _, exists := resourceSet.resources[resourceName]; !exists {
+ if _, err := addSchemaDocumentResource(
+ resourceSet.resources,
+ resourceSet.resourceNodes,
+ resourceName,
+ foundIndex.GetRootNode(),
+ purpose,
+ resourceCache,
+ ); err != nil {
+ return err
+ }
+ }
+
+ if err := addReachableSchemaResources(resourceSet, state, foundIndex, foundRef.Node, purpose, resourceCache); err != nil {
+ return err
+ }
+ }
+ }
+ return nil
+}
+
+func schemaResourceIndex(foundRef *index.Reference, foundIndex *index.SpecIndex) *index.SpecIndex {
+ if foundIndex != nil {
+ return foundIndex
+ }
+ if foundRef == nil {
+ return nil
+ }
+ return foundRef.Index
+}
+
+// ensureSchemaResourceName returns the stable compiler resource name for a parsed document.
+func ensureSchemaResourceName(state *schemaResourceBuildState, schemaIndex *index.SpecIndex, fallback uint64) string {
+ if state == nil || schemaIndex == nil {
+ return ""
+ }
+ if resourceName, exists := state.resourceNames[schemaIndex]; exists {
+ return resourceName
+ }
+ resourceName := resourceNameForIndex(schemaIndex, fallback)
+ state.resourceNames[schemaIndex] = resourceName
+ return resourceName
+}
+
+// addSchemaDocumentResource renders and registers a document-level JSON Schema resource.
+func addSchemaDocumentResource(
+ resources map[string][]byte,
+ resourceNodes map[string]*yaml.Node,
+ resourceName string,
+ rootNode *yaml.Node,
+ purpose SchemaValidationPurpose,
+ resourceCache cache.SchemaResourceCache,
+) (*RenderedValidationSchema, error) {
+ if resourceName == "" || rootNode == nil {
+ return nil, nil
+ }
+ cacheKey := schemaResourceCacheKey(rootNode, purpose)
+ if resourceCache != nil && cacheKey != "" {
+ if cached, ok := resourceCache.Load(cacheKey); ok && cached != nil {
+ rendered := renderedSchemaFromResourceCache(cached)
+ registerSchemaDocumentResource(resources, resourceNodes, resourceName, rendered)
+ return rendered, nil
+ }
+ }
+
+ rendered, err := renderYAMLNodeForValidation(rootNode, purpose)
+ if err != nil {
+ return nil, fmt.Errorf("schema resource %q render failed: %w", resourceName, err)
+ }
+ if resourceCache != nil && cacheKey != "" {
+ resourceCache.Store(cacheKey, resourceCacheEntryFromRenderedSchema(rendered, rootNode))
+ }
+ registerSchemaDocumentResource(resources, resourceNodes, resourceName, rendered)
+ return rendered, nil
+}
+
+func registerSchemaDocumentResource(
+ resources map[string][]byte,
+ resourceNodes map[string]*yaml.Node,
+ resourceName string,
+ rendered *RenderedValidationSchema,
+) {
+ if rendered == nil {
+ return
+ }
+ if resources != nil {
+ resources[resourceName] = rendered.RenderedJSON
+ }
+ if resourceNodes != nil {
+ resourceNodes[resourceName] = rendered.RenderedNode
+ }
+}
+
+func schemaResourceCacheKey(rootNode *yaml.Node, purpose SchemaValidationPurpose) string {
+ if rootNode == nil {
+ return ""
+ }
+ // Cache entries retain rootNode, so this parsed-document identity key cannot
+ // be reused by another document while the entry remains cached.
+ return fmt.Sprintf("%p:%d", rootNode, purpose)
+}
+
+func resourceCacheEntryFromRenderedSchema(rendered *RenderedValidationSchema, sourceRootNode *yaml.Node) *cache.SchemaResourceCacheEntry {
+ if rendered == nil {
+ return nil
+ }
+ return &cache.SchemaResourceCacheEntry{
+ RenderedInline: rendered.RenderedInline,
+ ReferenceSchema: rendered.ReferenceSchema,
+ RenderedJSON: rendered.RenderedJSON,
+ RenderedNode: rendered.RenderedNode,
+ SourceRootNode: sourceRootNode,
+ }
+}
+
+func renderedSchemaFromResourceCache(cached *cache.SchemaResourceCacheEntry) *RenderedValidationSchema {
+ if cached == nil {
+ return nil
+ }
+ return &RenderedValidationSchema{
+ RenderedInline: cached.RenderedInline,
+ ReferenceSchema: cached.ReferenceSchema,
+ RenderedJSON: cached.RenderedJSON,
+ RenderedNode: cached.RenderedNode,
+ }
+}
+
+// resourceNameForIndex returns the canonical resource URI for an indexed document.
+//
+// File-backed specs use a canonical file URI so jsonschema absolute keyword
+// locations line up with source-node lookup. Memory-only specs get deterministic
+// synthetic HTTPS names scoped to this validator package.
+func resourceNameForIndex(schemaIndex *index.SpecIndex, fallback uint64) string {
+ if schemaIndex != nil && schemaIndex.GetSpecAbsolutePath() != "" {
+ return canonicalResourceName(schemaIndex.GetSpecAbsolutePath())
+ }
+ return syntheticSchemaResourceBase + strconv.FormatUint(fallback, 16) + ".json"
+}
+
+// canonicalResourceName normalizes resource names into the URI form used by jsonschema diagnostics.
+func canonicalResourceName(resourceName string) string {
+ if resourceName == "" {
+ return ""
+ }
+ parsed, err := url.Parse(resourceName)
+ if err == nil && parsed.Scheme != "" {
+ return parsed.String()
+ }
+ absPath := resourceName
+ if !filepath.IsAbs(absPath) {
+ if resolved, err := filepath.Abs(absPath); err == nil {
+ absPath = resolved
+ }
+ }
+ return (&url.URL{Scheme: "file", Path: filepath.ToSlash(absPath)}).String()
+}
+
+// collectSchemaRefValues returns refs from schema-keyword positions in a YAML tree.
+func collectSchemaRefValues(node *yaml.Node) []string {
+ var refs []string
+ collectSchemaRefValuesInto(node, "", &refs)
+ return refs
+}
+
+func hasSchemaRefValue(node *yaml.Node) bool {
+ return hasSchemaRefValueIn(node, "")
+}
+
+func hasSchemaRefValueIn(node *yaml.Node, parentKey string) bool {
+ if node == nil {
+ return false
+ }
+
+ switch node.Kind {
+ case yaml.DocumentNode:
+ for _, child := range node.Content {
+ if hasSchemaRefValueIn(child, parentKey) {
+ return true
+ }
+ }
+ case yaml.MappingNode:
+ for i := 0; i+1 < len(node.Content); i += 2 {
+ keyNode := node.Content[i]
+ valueNode := node.Content[i+1]
+ key := ""
+ if keyNode != nil {
+ key = keyNode.Value
+ }
+ if isSchemaRefPair(key, parentKey, valueNode) {
+ return true
+ }
+ if hasSchemaRefValueIn(valueNode, key) {
+ return true
+ }
+ }
+ case yaml.SequenceNode:
+ for _, child := range node.Content {
+ if hasSchemaRefValueIn(child, parentKey) {
+ return true
+ }
+ }
+ }
+
+ return false
+}
+
+// collectSchemaRefValuesInto walks a YAML tree and records only real schema $ref keywords.
+//
+// OpenAPI schema maps can legally contain schema names or property names called
+// "$ref"; those names are not references and must not pull unrelated resources
+// into the compiler graph.
+func collectSchemaRefValuesInto(node *yaml.Node, parentKey string, refs *[]string) {
+ if node == nil {
+ return
+ }
+
+ switch node.Kind {
+ case yaml.DocumentNode:
+ for _, child := range node.Content {
+ collectSchemaRefValuesInto(child, parentKey, refs)
+ }
+ case yaml.MappingNode:
+ for i := 0; i+1 < len(node.Content); i += 2 {
+ keyNode := node.Content[i]
+ valueNode := node.Content[i+1]
+ key := ""
+ if keyNode != nil {
+ key = keyNode.Value
+ }
+ if isSchemaRefPair(key, parentKey, valueNode) {
+ *refs = append(*refs, valueNode.Value)
+ continue
+ }
+ collectSchemaRefValuesInto(valueNode, key, refs)
+ }
+ case yaml.SequenceNode:
+ for _, child := range node.Content {
+ collectSchemaRefValuesInto(child, parentKey, refs)
+ }
+ }
+}
+
+// isSchemaNameMap reports whether a mapping value is keyed by user-defined schema names.
+func isSchemaNameMap(parentKey string) bool {
+ switch parentKey {
+ case "properties", "patternProperties", "$defs", "definitions", "dependentSchemas":
+ return true
+ default:
+ return false
+ }
+}
+
+func isSchemaRefPair(key, parentKey string, valueNode *yaml.Node) bool {
+ return key == "$ref" && !isSchemaNameMap(parentKey) &&
+ valueNode != nil && valueNode.Kind == yaml.ScalarNode
+}
+
+// cloneYAMLNode deep-copies a YAML node tree before validation-specific pruning mutates it.
+func cloneYAMLNode(node *yaml.Node) *yaml.Node {
+ if node == nil {
+ return nil
+ }
+
+ cloned := *node
+ if len(node.Content) > 0 {
+ cloned.Content = make([]*yaml.Node, len(node.Content))
+ for i, child := range node.Content {
+ cloned.Content[i] = cloneYAMLNode(child)
+ }
+ }
+ return &cloned
+}
+
+// pruneDirectionalRequiredEverywhere removes request-only or response-only required markers recursively.
+func pruneDirectionalRequiredEverywhere(node *yaml.Node, purpose SchemaValidationPurpose) {
+ if node == nil {
+ return
+ }
+ if node.Kind == yaml.MappingNode {
+ pruneRequiredAtSchema(node, purpose)
+ }
+ for _, child := range node.Content {
+ pruneDirectionalRequiredEverywhere(child, purpose)
+ }
+}
+
+// jsonPointerForNode returns the RFC 6901 pointer to targetNode relative to rootNode.
+func jsonPointerForNode(rootNode, targetNode *yaml.Node) (string, bool) {
+ if rootNode == nil || targetNode == nil {
+ return "", false
+ }
+ if rootNode == targetNode {
+ return "", true
+ }
+ if rootNode.Kind == yaml.DocumentNode && len(rootNode.Content) > 0 {
+ return jsonPointerForNode(rootNode.Content[0], targetNode)
+ }
+ if targetNode.Kind == yaml.DocumentNode && len(targetNode.Content) > 0 {
+ return jsonPointerForNode(rootNode, targetNode.Content[0])
+ }
+
+ var tokens []string
+ ok := appendJSONPointerTokensForNode(rootNode, targetNode, &tokens)
+ if !ok {
+ return "", false
+ }
+ return "/" + strings.Join(tokens, "/"), true
+}
+
+// jsonPointerTokensForNode returns the unjoined pointer tokens for targetNode relative to currentNode.
+func jsonPointerTokensForNode(currentNode, targetNode *yaml.Node) ([]string, bool) {
+ var tokens []string
+ ok := appendJSONPointerTokensForNode(currentNode, targetNode, &tokens)
+ return tokens, ok
+}
+
+// appendJSONPointerTokensForNode depth-first searches a YAML tree while maintaining the current pointer path.
+//
+// The path is pushed and popped in place so deep schemas avoid the O(depth^2)
+// allocations that come from prepending tokens during recursive unwind.
+func appendJSONPointerTokensForNode(currentNode, targetNode *yaml.Node, tokens *[]string) bool {
+ if currentNode == nil {
+ return false
+ }
+ if currentNode == targetNode {
+ return true
+ }
+
+ switch currentNode.Kind {
+ case yaml.DocumentNode:
+ if len(currentNode.Content) == 0 {
+ return false
+ }
+ return appendJSONPointerTokensForNode(currentNode.Content[0], targetNode, tokens)
+ case yaml.MappingNode:
+ for i := 0; i+1 < len(currentNode.Content); i += 2 {
+ keyNode := currentNode.Content[i]
+ valueNode := currentNode.Content[i+1]
+ token := ""
+ if keyNode != nil {
+ token = escapeJSONPointerToken(keyNode.Value)
+ }
+ *tokens = append(*tokens, token)
+ if appendJSONPointerTokensForNode(valueNode, targetNode, tokens) {
+ return true
+ }
+ *tokens = (*tokens)[:len(*tokens)-1]
+ }
+ case yaml.SequenceNode:
+ for i, valueNode := range currentNode.Content {
+ *tokens = append(*tokens, strconv.Itoa(i))
+ if appendJSONPointerTokensForNode(valueNode, targetNode, tokens) {
+ return true
+ }
+ *tokens = (*tokens)[:len(*tokens)-1]
+ }
+ }
+
+ return false
+}
+
+// escapeJSONPointerToken escapes a single token according to RFC 6901.
+func escapeJSONPointerToken(token string) string {
+ token = strings.ReplaceAll(token, "~", "~0")
+ return strings.ReplaceAll(token, "/", "~1")
+}
diff --git a/vendor/github.com/pb33f/libopenapi-validator/schema_validation/validate_document.go b/vendor/github.com/pb33f/libopenapi-validator/schema_validation/validate_document.go
index 1a914d2ea..02f838dca 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/schema_validation/validate_document.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/schema_validation/validate_document.go
@@ -1,4 +1,4 @@
-// Copyright 2023-2025 Princess Beef Heavy Industries, LLC / Dave Shanley
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
// SPDX-License-Identifier: MIT
package schema_validation
@@ -8,6 +8,8 @@ import (
"encoding/json"
"errors"
"fmt"
+ "strconv"
+ "strings"
"github.com/pb33f/libopenapi"
"github.com/santhosh-tekuri/jsonschema/v6"
@@ -20,14 +22,203 @@ import (
"github.com/pb33f/libopenapi-validator/helpers"
)
-func normalizeJSON(data any) any {
- d, _ := json.Marshal(data)
+type nonStringMappingKey struct {
+ Value string
+ Tag string
+ Path []string
+ Line int
+ Column int
+ Sequence bool
+}
+
+func normalizeJSON(data any) (any, error) {
+ d, err := json.Marshal(data)
+ if err != nil {
+ return nil, err
+ }
+
var normalized any
_ = json.Unmarshal(d, &normalized)
- return normalized
+ return normalized, nil
+}
+
+func findNonStringMappingKey(rootNode *yaml.Node) *nonStringMappingKey {
+ if rootNode == nil {
+ return nil
+ }
+ return findNonStringMappingKeyInNode(rootNode, nil)
+}
+
+func findNonStringMappingKeyInNode(node *yaml.Node, path []string) *nonStringMappingKey {
+ if node == nil {
+ return nil
+ }
+
+ switch node.Kind {
+ case yaml.DocumentNode:
+ for _, child := range node.Content {
+ if found := findNonStringMappingKeyInNode(child, path); found != nil {
+ return found
+ }
+ }
+ case yaml.MappingNode:
+ for i := 0; i+1 < len(node.Content); i += 2 {
+ keyNode := node.Content[i]
+ valueNode := node.Content[i+1]
+ if isMergeMappingKey(keyNode) {
+ if found := findNonStringMappingKeyInMergeValue(valueNode, path); found != nil {
+ return found
+ }
+ continue
+ }
+ nextPath := appendPathSegment(path, keyNode.Value)
+ if !isStringMappingKey(keyNode) {
+ return &nonStringMappingKey{
+ Value: keyNode.Value,
+ Tag: keyNode.ShortTag(),
+ Path: nextPath,
+ Line: keyNode.Line,
+ Column: keyNode.Column,
+ Sequence: keyNode.Kind == yaml.SequenceNode,
+ }
+ }
+ if found := findNonStringMappingKeyInNode(valueNode, nextPath); found != nil {
+ return found
+ }
+ }
+ case yaml.SequenceNode:
+ for i, child := range node.Content {
+ if found := findNonStringMappingKeyInNode(child, appendPathSegment(path, strconv.Itoa(i))); found != nil {
+ return found
+ }
+ }
+ }
+
+ return nil
+}
+
+func findNonStringMappingKeyInMergeValue(node *yaml.Node, path []string) *nonStringMappingKey {
+ if node == nil {
+ return nil
+ }
+
+ switch node.Kind {
+ case yaml.AliasNode:
+ return findNonStringMappingKeyInMergeValue(node.Alias, path)
+ case yaml.SequenceNode:
+ for _, child := range node.Content {
+ if found := findNonStringMappingKeyInMergeValue(child, path); found != nil {
+ return found
+ }
+ }
+ return nil
+ default:
+ return findNonStringMappingKeyInNode(node, path)
+ }
+}
+
+func isStringMappingKey(keyNode *yaml.Node) bool {
+ if keyNode == nil || keyNode.Kind != yaml.ScalarNode {
+ return false
+ }
+ return keyNode.ShortTag() == "!!str"
+}
+
+func isMergeMappingKey(keyNode *yaml.Node) bool {
+ if keyNode == nil || keyNode.Kind != yaml.ScalarNode {
+ return false
+ }
+ return keyNode.ShortTag() == "!!merge" && keyNode.Value == "<<"
+}
+
+func appendPathSegment(path []string, segment string) []string {
+ next := make([]string, 0, len(path)+1)
+ next = append(next, path...)
+ return append(next, segment)
+}
+
+func buildJSONPointer(path []string) string {
+ if len(path) == 0 {
+ return ""
+ }
+ var builder strings.Builder
+ for _, segment := range path {
+ builder.WriteByte('/')
+ builder.WriteString(helpers.EscapeJSONPointerSegment(segment))
+ }
+ return builder.String()
+}
+
+func buildNonStringMappingKeyError(key *nonStringMappingKey) *liberrors.ValidationError {
+ pointer := buildJSONPointer(key.Path)
+ reason := fmt.Sprintf("OpenAPI documents require string mapping keys, but found %s key %q at %s",
+ yamlKeyType(key), key.Value, pointer)
+ howToFix := "Quote YAML mapping keys that should be strings, because OpenAPI documents must be representable as JSON objects"
+
+ if isOperationResponseStatusCodeKey(key.Path) {
+ reason = fmt.Sprintf("Response status code keys must be strings, quote %s as %q at %s",
+ key.Value, key.Value, pointer)
+ howToFix = fmt.Sprintf("Quote the response status code key, for example use %q instead of %s",
+ key.Value, key.Value)
+ }
+
+ return &liberrors.ValidationError{
+ ValidationType: helpers.Schema,
+ ValidationSubType: "document",
+ Message: "OpenAPI document validation failed",
+ Reason: reason,
+ SpecLine: key.Line,
+ SpecCol: key.Column,
+ HowToFix: howToFix,
+ Context: pointer,
+ }
+}
+
+func yamlKeyType(key *nonStringMappingKey) string {
+ if key == nil {
+ return "non-string"
+ }
+ if key.Sequence {
+ return "sequence"
+ }
+ return strings.TrimPrefix(key.Tag, "!!")
+}
+
+func isOperationResponseStatusCodeKey(path []string) bool {
+ if len(path) < 5 || path[0] != "paths" || path[len(path)-2] != "responses" {
+ return false
+ }
+ for _, segment := range path[2 : len(path)-2] {
+ if isHTTPMethod(segment) {
+ return true
+ }
+ }
+ return false
}
-// ValidateOpenAPIDocument will validate an OpenAPI document against the OpenAPI 2, 3.0 and 3.1 schemas (depending on version)
+func isHTTPMethod(segment string) bool {
+ switch strings.ToLower(segment) {
+ case "get", "put", "post", "delete", "options", "head", "patch", "trace":
+ return true
+ default:
+ return false
+ }
+}
+
+func buildDocumentDecodeError(reason, context string) *liberrors.ValidationError {
+ return &liberrors.ValidationError{
+ ValidationType: helpers.Schema,
+ ValidationSubType: "document",
+ Message: "OpenAPI document validation failed",
+ Reason: reason,
+ SpecLine: 1,
+ SpecCol: 0,
+ HowToFix: "ensure the OpenAPI document is valid YAML/JSON and can be represented as JSON",
+ Context: context,
+ }
+}
+
+// ValidateOpenAPIDocument validates an OpenAPI document against the embedded OpenAPI 2, 3.0, 3.1, or 3.2 schema selected by libopenapi.
// It will return true if the document is valid, false if it is not and a slice of ValidationError pointers.
func ValidateOpenAPIDocument(doc libopenapi.Document, opts ...config.Option) (bool, []*liberrors.ValidationError) {
return ValidateOpenAPIDocumentWithPrecompiled(doc, nil, opts...)
@@ -44,8 +235,17 @@ func ValidateOpenAPIDocumentWithPrecompiled(doc libopenapi.Document, compiledSch
loadedSchema := info.APISchema
var validationErrors []*liberrors.ValidationError
- // Check if both JSON representations are nil before proceeding
- if info.SpecJSON == nil && info.SpecJSONBytes == nil {
+ // libopenapi builds the JSON view of the document lazily: the deprecated
+ // SpecJSON / SpecJSONBytes fields stay nil until an accessor runs, and the
+ // accessors return nil when conversion is disabled (SkipJSONConversion) or
+ // the document cannot be represented as JSON.
+ specJSON := info.GetSpecJSON()
+ specJSONBytes := info.GetSpecJSONBytes()
+
+ // Check if both JSON representations are unavailable before proceeding.
+ // Empty bytes count as unavailable: neither branch of the normalization
+ // ladder below would fire, and a nil document must not reach Validate.
+ if specJSON == nil && (specJSONBytes == nil || len(*specJSONBytes) == 0) {
validationErrors = append(validationErrors, &liberrors.ValidationError{
ValidationType: helpers.Schema,
ValidationSubType: "document",
@@ -59,6 +259,12 @@ func ValidateOpenAPIDocumentWithPrecompiled(doc libopenapi.Document, compiledSch
return false, validationErrors
}
+ if info.RootNode != nil {
+ if invalidKey := findNonStringMappingKey(info.RootNode); invalidKey != nil {
+ return false, []*liberrors.ValidationError{buildNonStringMappingKeyError(invalidKey)}
+ }
+ }
+
// Use the precompiled schema if provided, otherwise compile it
jsch := compiledSchema
if jsch == nil {
@@ -82,17 +288,44 @@ func ValidateOpenAPIDocumentWithPrecompiled(doc libopenapi.Document, compiledSch
// Build the normalized document value for validation.
// Prefer SpecJSONBytes (single unmarshal) over SpecJSON (marshal+unmarshal round-trip).
var normalized any
- if info.SpecJSONBytes != nil && len(*info.SpecJSONBytes) > 0 {
+ if specJSONBytes != nil && len(*specJSONBytes) > 0 {
var err error
- normalized, err = jsonschema.UnmarshalJSON(bytes.NewReader(*info.SpecJSONBytes))
+ normalized, err = jsonschema.UnmarshalJSON(bytes.NewReader(*specJSONBytes))
if err != nil {
// Fall back to normalizeJSON if UnmarshalJSON fails
- if info.SpecJSON != nil {
- normalized = normalizeJSON(*info.SpecJSON)
+ if specJSON != nil {
+ normalized, err = normalizeJSON(*specJSON)
+ if err != nil {
+ return false, []*liberrors.ValidationError{buildDocumentDecodeError(
+ fmt.Sprintf("The OpenAPI document cannot be converted to JSON: %s", err.Error()),
+ "SpecJSON",
+ )}
+ }
+ } else {
+ return false, []*liberrors.ValidationError{buildDocumentDecodeError(
+ fmt.Sprintf("The document's SpecJSONBytes cannot be decoded as JSON: %s", err.Error()),
+ "SpecJSONBytes",
+ )}
}
}
- } else if info.SpecJSON != nil {
- normalized = normalizeJSON(*info.SpecJSON)
+ } else if specJSON != nil {
+ var err error
+ normalized, err = normalizeJSON(*specJSON)
+ if err != nil {
+ return false, []*liberrors.ValidationError{buildDocumentDecodeError(
+ fmt.Sprintf("The OpenAPI document cannot be converted to JSON: %s", err.Error()),
+ "SpecJSON",
+ )}
+ }
+ }
+
+ // belt and braces: never validate a nil document - it produces misleading
+ // "got null, want object" schema errors instead of a clear reason.
+ if normalized == nil {
+ return false, []*liberrors.ValidationError{buildDocumentDecodeError(
+ "The document has no usable JSON representation to validate",
+ "SpecJSON",
+ )}
}
// Validate the document
@@ -145,6 +378,9 @@ func ValidateOpenAPIDocumentWithPrecompiled(doc libopenapi.Document, compiledSch
// location of the violation within the rendered schema.
violation.Line = line
violation.Column = located.Column
+ if source, err := yaml.Marshal(located); err == nil {
+ violation.ReferenceObject = strings.TrimSpace(string(source))
+ }
} else {
// handles property name validation errors that don't provide useful InstanceLocation
applyPropertyNameFallback(propertyInfo, info.RootNode.Content[0], violation)
@@ -155,14 +391,20 @@ func ValidateOpenAPIDocumentWithPrecompiled(doc libopenapi.Document, compiledSch
}
// add the error to the list
- validationErrors = append(validationErrors, &liberrors.ValidationError{
+ documentError := &liberrors.ValidationError{
ValidationType: helpers.Schema,
Message: "Document does not pass validation",
Reason: fmt.Sprintf("OpenAPI document is not valid according "+
"to the %s specification", info.Version),
SchemaValidationErrors: schemaValidationErrors,
HowToFix: liberrors.HowToFixInvalidSchema,
- })
+ }
+ if len(schemaValidationErrors) > 0 {
+ documentError.SpecLine = schemaValidationErrors[0].Line
+ documentError.SpecCol = schemaValidationErrors[0].Column
+ documentError.Context = schemaValidationErrors[0].FieldPath
+ }
+ validationErrors = append(validationErrors, documentError)
}
if len(validationErrors) > 0 {
return false, validationErrors
diff --git a/vendor/github.com/pb33f/libopenapi-validator/schema_validation/validate_schema.go b/vendor/github.com/pb33f/libopenapi-validator/schema_validation/validate_schema.go
index 7f1f05538..425eb59fe 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/schema_validation/validate_schema.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/schema_validation/validate_schema.go
@@ -1,5 +1,6 @@
-// Copyright 2023 Princess B33f Heavy Industries / Dave Shanley
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
// SPDX-License-Identifier: MIT
+
package schema_validation
import (
@@ -12,9 +13,7 @@ import (
"reflect"
"regexp"
"strconv"
- "sync"
- "github.com/pb33f/libopenapi-validator/cache"
"github.com/pb33f/libopenapi/datamodel/high/base"
"github.com/santhosh-tekuri/jsonschema/v6"
"go.yaml.in/yaml/v4"
@@ -65,6 +64,9 @@ type SchemaValidator interface {
// When version is 3.0, OpenAPI 3.0-specific keywords like 'nullable' are allowed and processed.
// When version is 3.1+, OpenAPI 3.0-specific keywords like 'nullable' will cause validation to fail.
ValidateSchemaBytesWithVersion(schema *base.Schema, payload []byte, version float32) (bool, []*liberrors.ValidationError)
+
+ // Release clears validator-owned options and logger references.
+ Release()
}
var instanceLocationRegex = regexp.MustCompile(`^/(\d+)`)
@@ -72,14 +74,13 @@ var instanceLocationRegex = regexp.MustCompile(`^/(\d+)`)
type schemaValidator struct {
options *config.ValidationOptions
logger *slog.Logger
- lock sync.Mutex
}
// NewSchemaValidatorWithLogger will create a new SchemaValidator instance, ready to accept schemas and payloads to validate.
func NewSchemaValidatorWithLogger(logger *slog.Logger, opts ...config.Option) SchemaValidator {
options := config.NewValidationOptions(opts...)
- return &schemaValidator{options: options, logger: logger, lock: sync.Mutex{}}
+ return &schemaValidator{options: options, logger: logger}
}
// NewSchemaValidator will create a new SchemaValidator instance, ready to accept schemas and payloads to validate.
@@ -90,6 +91,17 @@ func NewSchemaValidator(opts ...config.Option) SchemaValidator {
return NewSchemaValidatorWithLogger(logger, opts...)
}
+func (s *schemaValidator) Release() {
+ if s == nil {
+ return
+ }
+ if s.options != nil {
+ s.options.Release()
+ s.options = nil
+ }
+ s.logger = nil
+}
+
func (s *schemaValidator) ValidateSchemaString(schema *base.Schema, payload string) (bool, []*liberrors.ValidationError) {
return s.validateSchemaWithVersion(schema, []byte(payload), nil, s.logger, 3.1)
}
@@ -124,6 +136,7 @@ func (s *schemaValidator) validateSchemaWithVersion(schema *base.Schema, payload
var renderedSchema []byte
var renderedNode *yaml.Node
+ var resourceNodes map[string]*yaml.Node
var compiledSchema *jsonschema.Schema
// Check cache first — reuses existing SchemaCache (populated by NewValidationOptions).
@@ -136,58 +149,21 @@ func (s *schemaValidator) validateSchemaWithVersion(schema *base.Schema, payload
cached != nil && cached.CompiledSchema != nil {
renderedSchema = cached.RenderedInline
renderedNode = cached.RenderedNode
+ resourceNodes = cached.ResourceNodes
compiledSchema = cached.CompiledSchema
}
}
// Cache miss — render, convert to JSON, and compile.
if compiledSchema == nil {
- renderCtx := base.NewInlineRenderContextForValidation()
- s.lock.Lock()
- nodeIface, renderErr := schema.MarshalYAMLInlineWithContext(renderCtx)
- s.lock.Unlock()
-
- if renderErr != nil {
- validationErrors = append(validationErrors, &liberrors.ValidationError{
- ValidationType: helpers.RequestBodyValidation,
- ValidationSubType: helpers.Schema,
- Message: "schema does not pass validation",
- Reason: fmt.Sprintf("The schema cannot be decoded: %s", renderErr.Error()),
- SpecLine: schema.GoLow().GetRootNode().Line,
- SpecCol: schema.GoLow().GetRootNode().Column,
- HowToFix: liberrors.HowToFixInvalidSchema,
- Context: string(renderedSchema),
- })
- return false, validationErrors
- }
-
- // MarshalYAMLInlineWithContext returns *yaml.Node (from NodeBuilder.Render)
- renderedNode, _ = nodeIface.(*yaml.Node)
-
- // yaml.Node → map → JSON bytes (skips yaml.Marshal + yaml.Unmarshal round-trip)
- var jsonMap map[string]interface{}
- if renderedNode != nil {
- _ = renderedNode.Decode(&jsonMap)
- }
- jsonSchema, _ := json.Marshal(jsonMap)
-
- // YAML bytes generated once for error messages / context strings
- renderedSchema, _ = yaml.Marshal(renderedNode)
-
- path := ""
- if schema.GoLow().GetIndex() != nil {
- path = schema.GoLow().GetIndex().GetSpecAbsolutePath()
- }
-
- var compileErr error
- compiledSchema, compileErr = helpers.NewCompiledSchemaWithVersion(path, jsonSchema, s.options, version)
+ compiled, compileErr := CompileSchemaForValidation(
+ schema,
+ SchemaValidationPurposeGeneric,
+ s.options,
+ version,
+ )
if compileErr != nil {
- line := 1
- col := 0
- if schema.GoLow().Type.KeyNode != nil {
- line = schema.GoLow().Type.KeyNode.Line
- col = schema.GoLow().Type.KeyNode.Column
- }
+ line, col := schemaLineColumn(schema)
validationErrors = append(validationErrors, &liberrors.ValidationError{
ValidationType: helpers.Schema,
ValidationSubType: helpers.Schema,
@@ -200,17 +176,14 @@ func (s *schemaValidator) validateSchemaWithVersion(schema *base.Schema, payload
})
return false, validationErrors
}
+ renderedSchema = compiled.RenderedInline
+ renderedNode = compiled.RenderedNode
+ resourceNodes = compiled.ResourceNodes
+ compiledSchema = compiled.CompiledSchema
// Store in cache for subsequent validations of the same schema.
if canCache && compiledSchema != nil {
- s.options.SchemaCache.Store(cacheKey, &cache.SchemaCacheEntry{
- Schema: schema,
- RenderedInline: renderedSchema,
- ReferenceSchema: string(renderedSchema),
- RenderedJSON: jsonSchema,
- CompiledSchema: compiledSchema,
- RenderedNode: renderedNode,
- })
+ s.options.SchemaCache.Store(cacheKey, compiled.ToCacheEntry(schema))
}
}
@@ -218,12 +191,7 @@ func (s *schemaValidator) validateSchemaWithVersion(schema *base.Schema, payload
err := json.Unmarshal(payload, &decodedObject)
if err != nil {
// cannot decode the request body, so it's not valid
- line := 1
- col := 0
- if schema.GoLow().Type.KeyNode != nil {
- line = schema.GoLow().Type.KeyNode.Line
- col = schema.GoLow().Type.KeyNode.Column
- }
+ line, col := schemaLineColumn(schema)
validationErrors = append(validationErrors, &liberrors.ValidationError{
ValidationType: helpers.RequestBodyValidation,
ValidationSubType: helpers.Schema,
@@ -248,16 +216,11 @@ func (s *schemaValidator) validateSchemaWithVersion(schema *base.Schema, payload
if errors.As(scErrs, &jk) {
// flatten the validationErrors
- schFlatErr := jk.BasicOutput().Errors
+ schFlatErr := helpers.FlattenSchemaOutputErrors(jk.DetailedOutput())
schemaValidationErrors = extractBasicErrors(schFlatErr, renderedSchema,
- renderedNode, decodedObject, payload, jk, schemaValidationErrors)
- }
- line := 1
- col := 0
- if schema.GoLow().Type.KeyNode != nil {
- line = schema.GoLow().Type.KeyNode.Line
- col = schema.GoLow().Type.KeyNode.Column
+ renderedNode, resourceNodes, decodedObject, payload, jk, schemaValidationErrors)
}
+ line, col := schemaLineColumn(schema)
validationErrors = append(validationErrors, &liberrors.ValidationError{
ValidationType: helpers.Schema,
@@ -277,8 +240,16 @@ func (s *schemaValidator) validateSchemaWithVersion(schema *base.Schema, payload
return true, nil
}
+func schemaLineColumn(schema *base.Schema) (int, int) {
+ if schema == nil || schema.GoLow() == nil || schema.GoLow().Type.KeyNode == nil {
+ return 1, 0
+ }
+ return schema.GoLow().Type.KeyNode.Line, schema.GoLow().Type.KeyNode.Column
+}
+
func extractBasicErrors(schFlatErrs []jsonschema.OutputUnit,
renderedSchema []byte, renderedNode *yaml.Node,
+ resourceNodes map[string]*yaml.Node,
decodedObject interface{},
payload []byte, jk *jsonschema.ValidationError,
schemaValidationErrors []*liberrors.SchemaValidationFailure,
@@ -286,19 +257,7 @@ func extractBasicErrors(schFlatErrs []jsonschema.OutputUnit,
// Extract property name info once before processing errors (performance optimization)
propertyInfo := extractPropertyNameFromError(jk)
- // Determine root content node ONCE (not per-error).
- // NodeBuilder.Render() returns MappingNode directly, no DocumentNode unwrapping needed.
- var rootNode *yaml.Node
- if renderedNode != nil {
- rootNode = renderedNode
- } else if len(renderedSchema) > 0 {
- // Fallback: parse bytes ONCE
- var docNode yaml.Node
- _ = yaml.Unmarshal(renderedSchema, &docNode)
- if len(docNode.Content) > 0 {
- rootNode = docNode.Content[0]
- }
- }
+ rootNode, resourceNodes := DiagnosticLocationNodes(renderedSchema, renderedNode, resourceNodes)
for q := range schFlatErrs {
er := schFlatErrs[q]
@@ -312,7 +271,12 @@ func extractBasicErrors(schFlatErrs []jsonschema.OutputUnit,
// locate the violated property in the schema
var located *yaml.Node
if rootNode != nil {
- located = LocateSchemaPropertyNodeByJSONPath(rootNode, er.KeywordLocation)
+ located = LocateSchemaPropertyNodeByJSONPathWithResources(
+ rootNode,
+ resourceNodes,
+ er.KeywordLocation,
+ er.AbsoluteKeywordLocation,
+ )
}
// extract the element specified by the instance
@@ -364,3 +328,53 @@ func extractBasicErrors(schFlatErrs []jsonschema.OutputUnit,
}
return schemaValidationErrors
}
+
+// DiagnosticLocationNodes returns rendered-schema nodes for validation error locations.
+func DiagnosticLocationNodes(
+ renderedSchema []byte,
+ renderedNode *yaml.Node,
+ resourceNodes map[string]*yaml.Node,
+) (*yaml.Node, map[string]*yaml.Node) {
+ if len(renderedSchema) > 0 {
+ var docNode yaml.Node
+ if err := yaml.Unmarshal(renderedSchema, &docNode); err == nil && len(docNode.Content) > 0 {
+ rootNode := docNode.Content[0]
+ return rootNode, entryResourceNodesWithRenderedRoot(resourceNodes, renderedNode, rootNode)
+ }
+ }
+
+ rootNode := rootContentNode(renderedNode)
+ return rootNode, resourceNodes
+}
+
+func entryResourceNodesWithRenderedRoot(
+ resourceNodes map[string]*yaml.Node,
+ renderedNode *yaml.Node,
+ renderedRootNode *yaml.Node,
+) map[string]*yaml.Node {
+ if len(resourceNodes) == 0 || renderedNode == nil || renderedRootNode == nil {
+ return resourceNodes
+ }
+
+ diagnosticResourceNodes := make(map[string]*yaml.Node, len(resourceNodes)+1)
+ for name, resourceNode := range resourceNodes {
+ diagnosticResourceNodes[name] = resourceNode
+ }
+
+ if _, hasEntryResource := resourceNodes[""]; !hasEntryResource {
+ // Resource-graph compiles need the full document for absolute local refs
+ // like "#/components/...", while primary keyword locations use rootNode.
+ diagnosticResourceNodes[""] = rootContentNode(renderedNode)
+ return diagnosticResourceNodes
+ }
+
+ // Single-schema compiles index the entry schema by "", so swap in the
+ // reparsed root to keep diagnostic line/column data stable.
+ renderedSourceRoot := rootContentNode(renderedNode)
+ for name, resourceNode := range resourceNodes {
+ if resourceNode == renderedNode || rootContentNode(resourceNode) == renderedSourceRoot {
+ diagnosticResourceNodes[name] = renderedRootNode
+ }
+ }
+ return diagnosticResourceNodes
+}
diff --git a/vendor/github.com/pb33f/libopenapi-validator/strict/types.go b/vendor/github.com/pb33f/libopenapi-validator/strict/types.go
index 045fbee26..3d11222d5 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/strict/types.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/strict/types.go
@@ -1,4 +1,4 @@
-// Copyright 2023-2025 Princess Beef Heavy Industries, LLC / Dave Shanley
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
// SPDX-License-Identifier: MIT
// Package strict provides strict validation that detects undeclared
@@ -366,6 +366,20 @@ func NewValidator(options *config.ValidationOptions, version float32) *Validator
return v
}
+// Release clears cached validation state and drops references retained by the validator.
+func (v *Validator) Release() {
+ if v == nil {
+ return
+ }
+ v.options = nil
+ v.logger = nil
+ v.localCache = nil
+ v.patternCache = nil
+ v.renderCtx = nil
+ v.compiledIgnorePaths = nil
+ v.version = 0
+}
+
// discardHandler is a slog.Handler that discards all log records.
type discardHandler struct{}
diff --git a/vendor/github.com/pb33f/libopenapi-validator/validator.go b/vendor/github.com/pb33f/libopenapi-validator/validator.go
index 96b9f8993..c5e74edab 100644
--- a/vendor/github.com/pb33f/libopenapi-validator/validator.go
+++ b/vendor/github.com/pb33f/libopenapi-validator/validator.go
@@ -1,18 +1,15 @@
-// Copyright 2023-2025 Princess Beef Heavy Industries, LLC / Dave Shanley
+// Copyright 2023-2026 Princess Beef Heavy Industries, LLC / Dave Shanley
// SPDX-License-Identifier: MIT
package validator
import (
- "fmt"
"net/http"
"sort"
"sync"
"github.com/pb33f/libopenapi"
"github.com/pb33f/libopenapi/datamodel/high/base"
- "github.com/pb33f/libopenapi/utils"
- "go.yaml.in/yaml/v4"
v3 "github.com/pb33f/libopenapi/datamodel/high/v3"
@@ -20,11 +17,14 @@ import (
"github.com/pb33f/libopenapi-validator/config"
"github.com/pb33f/libopenapi-validator/errors"
"github.com/pb33f/libopenapi-validator/helpers"
+ "github.com/pb33f/libopenapi-validator/internal/bodycodec"
+ "github.com/pb33f/libopenapi-validator/internal/requeststate"
"github.com/pb33f/libopenapi-validator/parameters"
"github.com/pb33f/libopenapi-validator/paths"
"github.com/pb33f/libopenapi-validator/radix"
"github.com/pb33f/libopenapi-validator/requests"
"github.com/pb33f/libopenapi-validator/responses"
+ "github.com/pb33f/libopenapi-validator/router"
"github.com/pb33f/libopenapi-validator/schema_validation"
)
@@ -58,7 +58,7 @@ type Validator interface {
// The path, query, cookie and header parameters and request and response body are validated.
ValidateHttpRequestResponse(request *http.Request, response *http.Response) (bool, []*errors.ValidationError)
- // ValidateDocument will validate an OpenAPI 3+ document against the 3.0 or 3.1 OpenAPI 3+ specification
+ // ValidateDocument validates an OpenAPI document against the embedded 3.0, 3.1, or 3.2 specification schema.
ValidateDocument() (bool, []*errors.ValidationError)
// GetParameterValidator will return a parameters.ParameterValidator instance used to validate parameters
@@ -72,6 +72,9 @@ type Validator interface {
// SetDocument will set the OpenAPI 3+ document to be validated
SetDocument(document libopenapi.Document)
+
+ // Release clears validator-owned caches and drops references to the model, document, and child validators.
+ Release()
}
// NewValidator will create a new Validator from an OpenAPI 3+ document
@@ -88,18 +91,32 @@ func NewValidator(document libopenapi.Document, opts ...config.Option) (Validato
// NewValidatorFromV3Model will create a new Validator from an OpenAPI Model
func NewValidatorFromV3Model(m *v3.Document, opts ...config.Option) Validator {
options := config.NewValidationOptions(opts...)
+ bodycodec.Apply(options)
// Build radix tree for O(k) path lookup (where k = path depth)
// Skip if path tree is disabled or a custom tree was provided
if options.PathTree == nil && !options.IsPathTreeDisabled() {
options.PathTree = radix.BuildPathTree(m)
}
+ var routerOptions []router.Option
+ if options.PathTree != nil {
+ routerOptions = append(routerOptions, router.WithPathLookup(options.PathTree))
+ }
+ if options.RegexCache != nil {
+ routerOptions = append(routerOptions, router.WithRegexCache(options.RegexCache))
+ }
+ if !options.StrictServerMatching {
+ routerOptions = append(routerOptions, router.WithPathOnlyMatching())
+ }
+ routeFinder := router.NewRouter(m, routerOptions...)
+ options.Router = routeFinder
+ options.BodyRegistry = options.BodyRegistry.Precompute(declaredMediaTypes(m))
// warm the schema caches by pre-compiling all schemas in the document
// (warmSchemaCaches checks for nil cache and skips if disabled)
warmSchemaCaches(m, options)
- v := &validator{options: options, v3Model: m}
+ v := &validator{options: options, v3Model: m, router: routeFinder}
// create a new parameter validator
v.paramValidator = parameters.NewParameterValidator(m, config.WithExistingOpts(options))
@@ -113,10 +130,94 @@ func NewValidatorFromV3Model(m *v3.Document, opts ...config.Option) Validator {
return v
}
+func declaredMediaTypes(document *v3.Document) []string {
+ if document == nil || document.Paths == nil || document.Paths.PathItems == nil {
+ return nil
+ }
+ seen := make(map[string]struct{})
+ var mediaTypes []string
+ add := func(mediaType string) {
+ if _, ok := seen[mediaType]; !ok {
+ seen[mediaType] = struct{}{}
+ mediaTypes = append(mediaTypes, mediaType)
+ }
+ }
+ for path := document.Paths.PathItems.First(); path != nil; path = path.Next() {
+ pathItem := path.Value()
+ for operation := pathItem.GetOperations().First(); operation != nil; operation = operation.Next() {
+ op := operation.Value()
+ if op.RequestBody != nil && op.RequestBody.Content != nil {
+ for media := op.RequestBody.Content.First(); media != nil; media = media.Next() {
+ add(media.Key())
+ }
+ }
+ if op.Responses != nil {
+ if op.Responses.Codes != nil {
+ for response := op.Responses.Codes.First(); response != nil; response = response.Next() {
+ if response.Value() != nil && response.Value().Content != nil {
+ for media := response.Value().Content.First(); media != nil; media = media.Next() {
+ add(media.Key())
+ }
+ }
+ }
+ }
+ if op.Responses.Default != nil && op.Responses.Default.Content != nil {
+ for media := op.Responses.Default.Content.First(); media != nil; media = media.Next() {
+ add(media.Key())
+ }
+ }
+ }
+ for _, parameter := range op.Parameters {
+ if parameter != nil && parameter.Content != nil {
+ for media := parameter.Content.First(); media != nil; media = media.Next() {
+ add(media.Key())
+ }
+ }
+ }
+ }
+ for _, parameter := range pathItem.Parameters {
+ if parameter != nil && parameter.Content != nil {
+ for media := parameter.Content.First(); media != nil; media = media.Next() {
+ add(media.Key())
+ }
+ }
+ }
+ }
+ return mediaTypes
+}
+
func (v *validator) SetDocument(document libopenapi.Document) {
v.document = document
}
+func (v *validator) Release() {
+ if v == nil {
+ return
+ }
+ if v.router != nil {
+ v.router.Release()
+ v.router = nil
+ }
+ releaseIfSupported(v.paramValidator)
+ releaseIfSupported(v.requestValidator)
+ releaseIfSupported(v.responseValidator)
+ if v.options != nil {
+ v.options.Release()
+ v.options = nil
+ }
+ v.v3Model = nil
+ v.document = nil
+ v.paramValidator = nil
+ v.requestValidator = nil
+ v.responseValidator = nil
+}
+
+func releaseIfSupported(value any) {
+ if r, ok := value.(interface{ Release() }); ok {
+ r.Release()
+ }
+}
+
func (v *validator) GetParameterValidator() parameters.ParameterValidator {
return v.paramValidator
}
@@ -176,20 +277,18 @@ func (v *validator) ValidateHttpRequestResponse(
request *http.Request,
response *http.Response,
) (bool, []*errors.ValidationError) {
- var pathItem *v3.PathItem
- var pathValue string
- var errs []*errors.ValidationError
-
- pathItem, errs, pathValue = paths.FindPath(request, v.v3Model, v.options)
- if pathItem == nil || errs != nil {
+ route, errs := paths.ResolveRoute(request, v.v3Model, v.options)
+ if route == nil || errs != nil {
return false, errs
}
+ restoreRoute := requeststate.AttachRoute(request, route)
+ defer restoreRoute()
responseBodyValidator := v.responseValidator
// validate request and response
- _, requestErrors := v.ValidateHttpRequestWithPathItem(request, pathItem, pathValue)
- _, responseErrors := responseBodyValidator.ValidateResponseBodyWithPathItem(request, response, pathItem, pathValue)
+ _, requestErrors := v.ValidateHttpRequestWithPathItem(request, route.PathItem, route.Path)
+ _, responseErrors := responseBodyValidator.ValidateResponseBodyWithPathItem(request, response, route.PathItem, route.Path)
if len(requestErrors) > 0 || len(responseErrors) > 0 {
return false, append(requestErrors, responseErrors...)
@@ -198,14 +297,37 @@ func (v *validator) ValidateHttpRequestResponse(
}
func (v *validator) ValidateHttpRequest(request *http.Request) (bool, []*errors.ValidationError) {
- pathItem, errs, foundPath := paths.FindPath(request, v.v3Model, v.options)
+ route, errs := paths.ResolveRoute(request, v.v3Model, v.options)
if len(errs) > 0 {
return false, errs
}
- return v.ValidateHttpRequestWithPathItem(request, pathItem, foundPath)
+ restoreRoute := requeststate.AttachRoute(request, route)
+ defer restoreRoute()
+ return v.ValidateHttpRequestWithPathItem(request, route.PathItem, route.Path)
}
func (v *validator) ValidateHttpRequestWithPathItem(request *http.Request, pathItem *v3.PathItem, pathValue string) (bool, []*errors.ValidationError) {
+ restoreRoute := v.attachRoute(request, pathItem, pathValue)
+ defer restoreRoute()
+ if v.options != nil && v.options.RequestDefaults {
+ return v.validateWithRequestDefaults(request, pathItem, pathValue, v.validateHttpRequestWithPathItem)
+ }
+ return v.validateHttpRequestWithPathItem(request, pathItem, pathValue)
+}
+
+func (v *validator) validateHttpRequestWithPathItem(request *http.Request, pathItem *v3.PathItem, pathValue string) (bool, []*errors.ValidationError) {
+ if v.options != nil && v.options.AuthenticationFunc != nil {
+ if _, err := requeststate.Snapshot(request); err != nil {
+ return false, []*errors.ValidationError{{
+ ValidationType: helpers.RequestBodyValidation,
+ ValidationSubType: helpers.Schema,
+ Message: "request body could not be read for authentication",
+ Reason: err.Error(),
+ HowToFix: "provide a readable request body",
+ }}
+ }
+ return v.ValidateHttpRequestSyncWithPathItem(request, pathItem, pathValue)
+ }
// create a new parameter validator
paramValidator := v.paramValidator
@@ -228,9 +350,11 @@ func (v *validator) ValidateHttpRequestWithPathItem(request *http.Request, pathI
paramValidator.ValidatePathParamsWithPathItem,
paramValidator.ValidateCookieParamsWithPathItem,
paramValidator.ValidateHeaderParamsWithPathItem,
- paramValidator.ValidateQueryParamsWithPathItem,
paramValidator.ValidateSecurityWithPathItem,
}
+ if v.options.ValidateRequestQuery {
+ validations = append(validations, paramValidator.ValidateQueryParamsWithPathItem)
+ }
// listen for validation errors on parameters. everything will run async.
paramListener := func(control chan struct{}, errorChan chan []*errors.ValidationError) {
@@ -286,7 +410,9 @@ func (v *validator) ValidateHttpRequestWithPathItem(request *http.Request, pathI
// build async functions
asyncFunctions := []validationFunctionAsync{
parameterValidationFunc,
- requestBodyValidationFunc,
+ }
+ if v.options.ValidateRequestBody {
+ asyncFunctions = append(asyncFunctions, requestBodyValidationFunc)
}
var validationErrors []*errors.ValidationError
@@ -309,14 +435,41 @@ func (v *validator) ValidateHttpRequestWithPathItem(request *http.Request, pathI
}
func (v *validator) ValidateHttpRequestSync(request *http.Request) (bool, []*errors.ValidationError) {
- pathItem, errs, foundPath := paths.FindPath(request, v.v3Model, v.options)
+ route, errs := paths.ResolveRoute(request, v.v3Model, v.options)
if len(errs) > 0 {
return false, errs
}
- return v.ValidateHttpRequestSyncWithPathItem(request, pathItem, foundPath)
+ restoreRoute := requeststate.AttachRoute(request, route)
+ defer restoreRoute()
+ return v.ValidateHttpRequestSyncWithPathItem(request, route.PathItem, route.Path)
}
func (v *validator) ValidateHttpRequestSyncWithPathItem(request *http.Request, pathItem *v3.PathItem, pathValue string) (bool, []*errors.ValidationError) {
+ restoreRoute := v.attachRoute(request, pathItem, pathValue)
+ defer restoreRoute()
+ if v.options != nil && v.options.RequestDefaults {
+ return v.validateWithRequestDefaults(request, pathItem, pathValue, v.validateHttpRequestSyncWithPathItem)
+ }
+ return v.validateHttpRequestSyncWithPathItem(request, pathItem, pathValue)
+}
+
+func (v *validator) attachRoute(request *http.Request, pathItem *v3.PathItem, pathValue string) func() {
+ if requeststate.Route(request) != nil {
+ return func() {}
+ }
+ route := &router.Route{
+ Document: v.v3Model, Path: pathValue, PathItem: pathItem, Method: request.Method,
+ Operation: helpers.ExtractOperation(request, pathItem),
+ }
+ if v.options != nil && v.options.Router != nil {
+ if resolved, err := v.options.Router.FindRoute(request); err == nil && resolved != nil && resolved.PathItem == pathItem {
+ route = resolved
+ }
+ }
+ return requeststate.AttachRoute(request, route)
+}
+
+func (v *validator) validateHttpRequestSyncWithPathItem(request *http.Request, pathItem *v3.PathItem, pathValue string) (bool, []*errors.ValidationError) {
// create a new parameter validator
paramValidator := v.paramValidator
@@ -326,22 +479,27 @@ func (v *validator) ValidateHttpRequestSyncWithPathItem(request *http.Request, p
validationErrors := make([]*errors.ValidationError, 0)
paramValidationErrors := make([]*errors.ValidationError, 0)
- for _, validateFunc := range []validationFunction{
+ validations := []validationFunction{
paramValidator.ValidatePathParamsWithPathItem,
paramValidator.ValidateCookieParamsWithPathItem,
paramValidator.ValidateHeaderParamsWithPathItem,
- paramValidator.ValidateQueryParamsWithPathItem,
paramValidator.ValidateSecurityWithPathItem,
- } {
+ }
+ if v.options.ValidateRequestQuery {
+ validations = append(validations, paramValidator.ValidateQueryParamsWithPathItem)
+ }
+ for _, validateFunc := range validations {
valid, pErrs := validateFunc(request, pathItem, pathValue)
if !valid {
paramValidationErrors = append(paramValidationErrors, pErrs...)
}
}
- valid, pErrs := reqBodyValidator.ValidateRequestBodyWithPathItem(request, pathItem, pathValue)
- if !valid {
- paramValidationErrors = append(paramValidationErrors, pErrs...)
+ if v.options.ValidateRequestBody {
+ valid, pErrs := reqBodyValidator.ValidateRequestBodyWithPathItem(request, pathItem, pathValue)
+ if !valid {
+ paramValidationErrors = append(paramValidationErrors, pErrs...)
+ }
}
validationErrors = append(validationErrors, paramValidationErrors...)
@@ -355,6 +513,7 @@ type validator struct {
paramValidator parameters.ParameterValidator
requestValidator requests.RequestBodyValidator
responseValidator responses.ResponseBodyValidator
+ router router.Router
}
func runValidation(control, doneChan chan struct{},
@@ -408,6 +567,7 @@ func warmSchemaCaches(
}
schemaCache := options.SchemaCache
+ version := helpers.VersionToFloat(doc.Version)
// Walk through all paths and operations
for pathPair := doc.Paths.PathItems.First(); pathPair != nil; pathPair = pathPair.Next() {
@@ -415,22 +575,17 @@ func warmSchemaCaches(
// Get all operations for this path (handles all HTTP methods including OpenAPI 3.2+ extensions)
operations := pathItem.GetOperations()
- if operations == nil {
- continue
- }
for opPair := operations.First(); opPair != nil; opPair = opPair.Next() {
operation := opPair.Value()
- if operation == nil {
- continue
- }
// Warm request body schemas
if operation.RequestBody != nil && operation.RequestBody.Content != nil {
for contentPair := operation.RequestBody.Content.First(); contentPair != nil; contentPair = contentPair.Next() {
mediaType := contentPair.Value()
if mediaType.Schema != nil {
- warmMediaTypeSchema(mediaType, schemaCache, options)
+ warmMediaTypeSchema(mediaType, schemaCache, options, version,
+ schema_validation.SchemaValidationPurposeRequestBody)
}
}
}
@@ -445,7 +600,8 @@ func warmSchemaCaches(
for contentPair := response.Content.First(); contentPair != nil; contentPair = contentPair.Next() {
mediaType := contentPair.Value()
if mediaType.Schema != nil {
- warmMediaTypeSchema(mediaType, schemaCache, options)
+ warmMediaTypeSchema(mediaType, schemaCache, options, version,
+ schema_validation.SchemaValidationPurposeResponseBody)
}
}
}
@@ -457,7 +613,8 @@ func warmSchemaCaches(
for contentPair := operation.Responses.Default.Content.First(); contentPair != nil; contentPair = contentPair.Next() {
mediaType := contentPair.Value()
if mediaType.Schema != nil {
- warmMediaTypeSchema(mediaType, schemaCache, options)
+ warmMediaTypeSchema(mediaType, schemaCache, options, version,
+ schema_validation.SchemaValidationPurposeResponseBody)
}
}
}
@@ -467,7 +624,7 @@ func warmSchemaCaches(
if operation.Parameters != nil {
for _, param := range operation.Parameters {
if param != nil {
- warmParameterSchema(param, schemaCache, options)
+ warmParameterSchema(param, schemaCache, options, version)
}
}
}
@@ -477,7 +634,7 @@ func warmSchemaCaches(
if pathItem.Parameters != nil {
for _, param := range pathItem.Parameters {
if param != nil {
- warmParameterSchema(param, schemaCache, options)
+ warmParameterSchema(param, schemaCache, options, version)
}
}
}
@@ -485,87 +642,71 @@ func warmSchemaCaches(
}
// warmMediaTypeSchema warms the cache for a media type schema
-func warmMediaTypeSchema(mediaType *v3.MediaType, schemaCache cache.SchemaCache, options *config.ValidationOptions) {
+func warmMediaTypeSchema(
+ mediaType *v3.MediaType,
+ schemaCache cache.SchemaCache,
+ options *config.ValidationOptions,
+ version float32,
+ purpose schema_validation.SchemaValidationPurpose,
+) {
if mediaType != nil && mediaType.Schema != nil {
- hash := mediaType.GoLow().Schema.Value.Hash()
+ schema := mediaType.Schema.Schema()
+ if schema == nil || schema.GoLow() == nil {
+ return
+ }
+ hash := schema_validation.SchemaCacheKey(schema.GoLow().Hash(), version, purpose)
if _, exists := schemaCache.Load(hash); !exists {
- schema := mediaType.Schema.Schema()
- if schema != nil {
- renderCtx := base.NewInlineRenderContextForValidation()
- renderedInline, _ := schema.RenderInlineWithContext(renderCtx)
- referenceSchema := string(renderedInline)
- renderedJSON, _ := utils.ConvertYAMLtoJSON(renderedInline)
- if len(renderedInline) > 0 {
- compiledSchema, _ := helpers.NewCompiledSchema(fmt.Sprintf("%x", hash), renderedJSON, options)
-
- // Pre-parse YAML node for error reporting (avoids re-parsing on each error)
- var renderedNode yaml.Node
- _ = yaml.Unmarshal(renderedInline, &renderedNode)
-
- schemaCache.Store(hash, &cache.SchemaCacheEntry{
- Schema: schema,
- RenderedInline: renderedInline,
- ReferenceSchema: referenceSchema,
- RenderedJSON: renderedJSON,
- CompiledSchema: compiledSchema,
- RenderedNode: &renderedNode,
- })
- }
+ compiled, err := schema_validation.CompileSchemaForValidation(
+ schema,
+ purpose,
+ options,
+ version,
+ )
+ if err != nil || compiled == nil || compiled.CompiledSchema == nil {
+ return
}
+
+ schemaCache.Store(hash, compiled.ToCacheEntry(schema))
}
}
}
// warmParameterSchema warms the cache for a parameter schema
-func warmParameterSchema(param *v3.Parameter, schemaCache cache.SchemaCache, options *config.ValidationOptions) {
+func warmParameterSchema(param *v3.Parameter, schemaCache cache.SchemaCache, options *config.ValidationOptions, version float32) {
if param != nil {
var schema *base.Schema
- var hash uint64
// Parameters can have schemas in two places: schema property or content property
if param.Schema != nil {
schema = param.Schema.Schema()
- if schema != nil {
- hash = param.GoLow().Schema.Value.Hash()
- }
} else if param.Content != nil {
// Check content for schema
for contentPair := param.Content.First(); contentPair != nil; contentPair = contentPair.Next() {
mediaType := contentPair.Value()
if mediaType.Schema != nil {
schema = mediaType.Schema.Schema()
- if schema != nil {
- hash = mediaType.GoLow().Schema.Value.Hash()
- }
break // Only process first content type
}
}
}
- if schema != nil {
+ if schema != nil && schema.GoLow() != nil {
+ hash := schema_validation.SchemaCacheKey(schema.GoLow().Hash(), version,
+ schema_validation.SchemaValidationPurposeGeneric)
if _, exists := schemaCache.Load(hash); !exists {
- renderCtx := base.NewInlineRenderContextForValidation()
- renderedInline, _ := schema.RenderInlineWithContext(renderCtx)
- referenceSchema := string(renderedInline)
- renderedJSON, _ := utils.ConvertYAMLtoJSON(renderedInline)
- if len(renderedInline) > 0 {
- compiledSchema, _ := helpers.NewCompiledSchema(fmt.Sprintf("%x", hash), renderedJSON, options)
-
- // Pre-parse YAML node for error reporting (avoids re-parsing on each error)
- var renderedNode yaml.Node
- _ = yaml.Unmarshal(renderedInline, &renderedNode)
-
- // Store in cache using the shared SchemaCache type
- schemaCache.Store(hash, &cache.SchemaCacheEntry{
- Schema: schema,
- RenderedInline: renderedInline,
- ReferenceSchema: referenceSchema,
- RenderedJSON: renderedJSON,
- CompiledSchema: compiledSchema,
- RenderedNode: &renderedNode,
- })
+ compiled, err := schema_validation.CompileSchemaForValidation(
+ schema,
+ schema_validation.SchemaValidationPurposeGeneric,
+ options,
+ version,
+ )
+ if err != nil || compiled == nil || compiled.CompiledSchema == nil {
+ return
}
+
+ // Store in cache using the shared SchemaCache type
+ schemaCache.Store(hash, compiled.ToCacheEntry(schema))
}
}
}
diff --git a/vendor/github.com/pb33f/libopenapi/.gitignore b/vendor/github.com/pb33f/libopenapi/.gitignore
index 069611e7d..d890c2ef0 100644
--- a/vendor/github.com/pb33f/libopenapi/.gitignore
+++ b/vendor/github.com/pb33f/libopenapi/.gitignore
@@ -1,3 +1,4 @@
test-operation.yaml
.idea/
-*.iml
\ No newline at end of file
+*.iml
+.zed/
diff --git a/vendor/github.com/pb33f/libopenapi/AGENTS.md b/vendor/github.com/pb33f/libopenapi/AGENTS.md
index 850761ea5..c354ac0ea 100644
--- a/vendor/github.com/pb33f/libopenapi/AGENTS.md
+++ b/vendor/github.com/pb33f/libopenapi/AGENTS.md
@@ -90,7 +90,7 @@ This repo is a library, not an app. The root package exposes the public entry po
- **Hash contract**: every schema field must appear in `Schema.hash()` (`datamodel/low/base/schema_hash.go`). A missing field means equality and diff silently ignore it. Call `ClearSchemaQuickHashMap()` between document lifecycles or the global `sync.Map` cache returns stale hashes.
- **Circular refs**: `resolver_circular.go` detects loops by comparing `FullDefinition` strings. If ref rewriting (bundler, resolver) changes these inconsistently, loops go undetected and the resolver hangs or overflows the depth limit (500).
- **Reference cache staleness**: `index.cache` (`sync.Map`) is never cleared after bundler mutations. Lookups after bundling can return stale pre-rewrite refs pointing to external files that no longer apply.
-- **Bundler irreversibility**: `BundleDocument` / `BundleDocumentComposed` mutates the model in-place permanently. Never compare, re-bundle, or re-index a document after bundling — parse fresh from the rendered output instead.
+- **Bundler mutation**: `BundleDocument` / `BundleDocumentComposed` mutate the model in place. Inline reference preparation is idempotent, so repeating `BundleDocument` on the same model must not duplicate lifted components. Comparing or re-indexing a mutated model, and repeating composed bundling, remain unsupported; parse fresh from rendered output for those workflows.
- **Sibling ref idempotency**: `CreateAllOfStructure()` in `datamodel/low/base/sibling_ref_transformer.go` is not idempotent. Running it twice (e.g., bundle then re-index) produces nested `allOf` wrappers that break schema validity.
- **Resolver state leak**: `IgnorePoly` and `IgnoreArray` flags on the resolver persist between parses. Reusing a resolver across documents causes the second document's polymorphic circular refs to be silently missed.
diff --git a/vendor/github.com/pb33f/libopenapi/README.md b/vendor/github.com/pb33f/libopenapi/README.md
index fa79a5711..649ea081a 100644
--- a/vendor/github.com/pb33f/libopenapi/README.md
+++ b/vendor/github.com/pb33f/libopenapi/README.md
@@ -72,6 +72,8 @@ See all the documentation at https://pb33f.io/libopenapi/
- [What Changed / Diff Engine](https://pb33f.io/libopenapi/what-changed/)
- [Overlays](https://pb33f.io/libopenapi/overlays/)
- [Arazzo](https://pb33f.io/libopenapi/arazzo/)
+- [Generating Code](https://pb33f.io/libopenapi/generating-code/)
+- [Parsing Code](https://pb33f.io/libopenapi/parsing-code/)
- [FAQ](https://pb33f.io/libopenapi/faq/)
- [About libopenapi](https://pb33f.io/libopenapi/about/)
---
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/document_config.go b/vendor/github.com/pb33f/libopenapi/datamodel/document_config.go
index 5da94ef31..3a431005a 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/document_config.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/document_config.go
@@ -39,8 +39,8 @@ type DocumentConfiguration struct {
// RemoteURLHandler is a function that will be used to retrieve remote documents. If not set, the default
// remote document getter will be used.
//
- // The remote handler is only used if the BaseURL is set. If the BaseURL is not set, then the remote handler
- // will not be used, as there will be nothing to use it against.
+ // The remote handler is only used if AllowRemoteReferences is true. If AllowRemoteReferences is false, then
+ // the remote handler will not be used even when BaseURL is set.
//
// Resolves [#132]: https://github.com/pb33f/libopenapi/issues/132
RemoteURLHandler utils.RemoteURLHandler
@@ -89,12 +89,8 @@ type DocumentConfiguration struct {
// AllowRemoteReferences will allow the index to lookup remote references. This is disabled by default.
//
- // This behavior is now driven by the inclusion of a BaseURL. If a BaseURL is set, then the
- // rolodex will look for remote references. If no BaseURL is set, then the rolodex will not look for
- // remote references. This value has no effect as of version 0.13.0 and will be removed in a future release.
- //
- // This value when set, will force the creation of a remote file system even when the BaseURL has not been set.
- // it will suck in every http link it finds, and recurse through all references located in each document.
+ // BaseURL is used to resolve relative references, but it does not enable remote fetching on its own. Remote
+ // lookup only occurs when this value is true.
AllowRemoteReferences bool
// AvoidIndexBuild will avoid building the index. This is disabled by default, only use if you are sure you don't need it.
@@ -105,11 +101,16 @@ type DocumentConfiguration struct {
// passed in and used. Only enable this when parsing non openapi documents.
BypassDocumentCheck bool
- // SkipJSONConversion skips the YAML-to-JSON conversion during spec parsing.
- // SpecJSON and SpecJSONBytes on SpecInfo will be nil when enabled.
- // This also skips structural validation that parseJSON performs (e.g., duplicate key detection).
+ // SkipJSONConversion disables the JSON representation of the document entirely:
+ // SpecInfo.GetSpecJSON and GetSpecJSONBytes return nil when enabled (and the
+ // deprecated SpecJSON/SpecJSONBytes fields stay nil). This also skips the eager
+ // structural validation performed at parse time (e.g., duplicate key detection).
// Safe when document-level schema validation rules are not running and no custom
// functions depend on the JSON representation.
+ //
+ // Note: the JSON representation is built lazily on first accessor call, so leaving
+ // this disabled no longer costs anything at parse time. Enable it only to also
+ // skip the eager structural validation, or to guarantee accessors return nil.
SkipJSONConversion bool
// IgnorePolymorphicCircularReferences will skip over checking for circular references in polymorphic schemas.
@@ -143,6 +144,20 @@ type DocumentConfiguration struct {
// defaults to false (which means extensions will be included)
ExcludeExtensionRefs bool
+ // SkipMetadataCollection disables the collection of diagnostic metadata during indexing:
+ // descriptions, summaries, enums, objects-with-properties, security requirement
+ // references, and the JSONPath `Path` values on inline schema references. Skipping
+ // them significantly reduces allocations and retained memory when parsing large
+ // documents. Reference extraction, resolution and model building are unaffected.
+ //
+ // -- UNSAFE FOR DIAGNOSTIC, RULE, OR PATH CONSUMERS --
+ // When enabled, the index methods GetAllDescriptions, GetAllSummaries, GetAllEnums,
+ // GetAllObjectsWithProperties, GetSecurityRequirementReferences and the related
+ // counts are intentionally empty/zero, and inline schema Reference.Path values are
+ // empty strings. vacuum and any other tool that consumes index metadata or Path
+ // values must NOT enable this. Defaults to false (everything is collected).
+ SkipMetadataCollection bool
+
// BundleInlineRefs controls whether local component references are inlined during bundling.
// When false (default): Local refs like #/components/schemas/Pet are preserved
// When true: Local refs are also inlined (may break discriminator mappings)
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/high/base/discriminator.go b/vendor/github.com/pb33f/libopenapi/datamodel/high/base/discriminator.go
index df2ebd656..2df435213 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/high/base/discriminator.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/high/base/discriminator.go
@@ -4,6 +4,8 @@
package base
import (
+ "errors"
+
"github.com/pb33f/libopenapi/datamodel/high"
"github.com/pb33f/libopenapi/datamodel/low"
lowBase "github.com/pb33f/libopenapi/datamodel/low/base"
@@ -57,3 +59,47 @@ func (d *Discriminator) MarshalYAML() (interface{}, error) {
nb := high.NewNodeBuilder(d, d.low)
return nb.Render(), nil
}
+
+// MarshalYAMLInlineWithContext renders discriminator mappings with replacements
+// prepared for this render operation, without mutating their indexed YAML nodes.
+func (d *Discriminator) MarshalYAMLInlineWithContext(ctx any) (interface{}, error) {
+ nb := high.NewNodeBuilder(d, d.low)
+ rendered := nb.Render()
+ renderCtx, ok := ctx.(*InlineRenderContext)
+ if !ok || renderCtx == nil || d.low == nil || d.Mapping == nil {
+ return rendered, errors.Join(nb.Errors...)
+ }
+
+ mappingNode := discriminatorMappingNode(rendered)
+ if mappingNode != nil {
+ for pair := d.Mapping.First(); pair != nil; pair = pair.Next() {
+ lowValue := d.low.FindMappingValue(pair.Key())
+ if lowValue == nil {
+ continue
+ }
+ replacement, exists := renderCtx.MappingRewrite(lowValue.ValueNode)
+ if !exists {
+ continue
+ }
+ for i := 0; i+1 < len(mappingNode.Content); i += 2 {
+ if mappingNode.Content[i].Value == pair.Key() {
+ mappingNode.Content[i+1].Value = replacement
+ break
+ }
+ }
+ }
+ }
+ return rendered, errors.Join(nb.Errors...)
+}
+
+func discriminatorMappingNode(node *yaml.Node) *yaml.Node {
+ if node == nil || node.Kind != yaml.MappingNode {
+ return nil
+ }
+ for i := 0; i+1 < len(node.Content); i += 2 {
+ if node.Content[i].Value == "mapping" && node.Content[i+1].Kind == yaml.MappingNode {
+ return node.Content[i+1]
+ }
+ }
+ return nil
+}
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/high/base/schema.go b/vendor/github.com/pb33f/libopenapi/datamodel/high/base/schema.go
index 16f1070a4..3a7059c58 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/high/base/schema.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/high/base/schema.go
@@ -56,16 +56,19 @@ type Schema struct {
// 3.1 Specific properties
Contains *SchemaProxy `json:"contains,omitempty" yaml:"contains,omitempty"`
- MinContains *int64 `json:"minContains,omitempty" yaml:"minContains,omitempty"`
- MaxContains *int64 `json:"maxContains,omitempty" yaml:"maxContains,omitempty"`
+ MinContains *int64 `json:"minContains,renderZero,omitempty" yaml:"minContains,renderZero,omitempty"`
+ MaxContains *int64 `json:"maxContains,renderZero,omitempty" yaml:"maxContains,renderZero,omitempty"`
If *SchemaProxy `json:"if,omitempty" yaml:"if,omitempty"`
Else *SchemaProxy `json:"else,omitempty" yaml:"else,omitempty"`
Then *SchemaProxy `json:"then,omitempty" yaml:"then,omitempty"`
DependentSchemas *orderedmap.Map[string, *SchemaProxy] `json:"dependentSchemas,omitempty" yaml:"dependentSchemas,omitempty"`
DependentRequired *orderedmap.Map[string, []string] `json:"dependentRequired,omitempty" yaml:"dependentRequired,omitempty"`
PatternProperties *orderedmap.Map[string, *SchemaProxy] `json:"patternProperties,omitempty" yaml:"patternProperties,omitempty"`
- PropertyNames *SchemaProxy `json:"propertyNames,omitempty" yaml:"propertyNames,omitempty"`
- UnevaluatedItems *SchemaProxy `json:"unevaluatedItems,omitempty" yaml:"unevaluatedItems,omitempty"`
+
+ // Defs holds reusable JSON Schema definitions declared under the $defs keyword.
+ Defs *orderedmap.Map[string, *SchemaProxy] `json:"$defs,omitempty" yaml:"$defs,omitempty"`
+ PropertyNames *SchemaProxy `json:"propertyNames,omitempty" yaml:"propertyNames,omitempty"`
+ UnevaluatedItems *SchemaProxy `json:"unevaluatedItems,omitempty" yaml:"unevaluatedItems,omitempty"`
// in 3.1 UnevaluatedProperties can be a Schema or a boolean
// https://github.com/pb33f/libopenapi/issues/118
@@ -102,15 +105,15 @@ type Schema struct {
MultipleOf *float64 `json:"multipleOf,omitempty" yaml:"multipleOf,omitempty"`
Maximum *float64 `json:"maximum,renderZero,omitempty" yaml:"maximum,renderZero,omitempty"`
Minimum *float64 `json:"minimum,renderZero,omitempty," yaml:"minimum,renderZero,omitempty"`
- MaxLength *int64 `json:"maxLength,omitempty" yaml:"maxLength,omitempty"`
- MinLength *int64 `json:"minLength,omitempty" yaml:"minLength,omitempty"`
+ MaxLength *int64 `json:"maxLength,renderZero,omitempty" yaml:"maxLength,renderZero,omitempty"`
+ MinLength *int64 `json:"minLength,renderZero,omitempty" yaml:"minLength,renderZero,omitempty"`
Pattern string `json:"pattern,omitempty" yaml:"pattern,omitempty"`
Format string `json:"format,omitempty" yaml:"format,omitempty"`
- MaxItems *int64 `json:"maxItems,omitempty" yaml:"maxItems,omitempty"`
- MinItems *int64 `json:"minItems,omitempty" yaml:"minItems,omitempty"`
+ MaxItems *int64 `json:"maxItems,renderZero,omitempty" yaml:"maxItems,renderZero,omitempty"`
+ MinItems *int64 `json:"minItems,renderZero,omitempty" yaml:"minItems,renderZero,omitempty"`
UniqueItems *bool `json:"uniqueItems,omitempty" yaml:"uniqueItems,omitempty"`
- MaxProperties *int64 `json:"maxProperties,omitempty" yaml:"maxProperties,omitempty"`
- MinProperties *int64 `json:"minProperties,omitempty" yaml:"minProperties,omitempty"`
+ MaxProperties *int64 `json:"maxProperties,renderZero,omitempty" yaml:"maxProperties,renderZero,omitempty"`
+ MinProperties *int64 `json:"minProperties,renderZero,omitempty" yaml:"minProperties,renderZero,omitempty"`
Required []string `json:"required,omitempty" yaml:"required,omitempty"`
Enum []*yaml.Node `json:"enum,omitempty" yaml:"enum,omitempty"`
AdditionalProperties *DynamicValue[*SchemaProxy, bool] `json:"additionalProperties,renderZero,omitempty" yaml:"additionalProperties,renderZero,omitempty"`
@@ -367,50 +370,21 @@ func NewSchema(schema *base.Schema) *Schema {
}
s.Enum = enum
- // async work.
- // any polymorphic properties need to be handled in their own threads
- // any properties each need to be processed in their own thread.
- // we go as fast as we can.
- polyCompletedChan := make(chan struct{})
- errChan := make(chan error)
-
- type buildResult struct {
- idx int
- s *SchemaProxy
- }
-
- // for every item, build schema async
- buildSchema := func(sch lowmodel.ValueReference[*base.SchemaProxy], idx int, bChan chan buildResult) {
- n := &lowmodel.NodeReference[*base.SchemaProxy]{
- ValueNode: sch.ValueNode,
- Value: sch.Value,
- }
- n.SetReference(sch.GetReference(), sch.GetReferenceNode())
-
- p := NewSchemaProxy(n)
-
- bChan <- buildResult{idx: idx, s: p}
- }
-
- // schema async
- buildOutSchemas := func(schemas []lowmodel.ValueReference[*base.SchemaProxy], items *[]*SchemaProxy,
- doneChan chan struct{}, e chan error,
- ) {
- bChan := make(chan buildResult)
- totalSchemas := len(schemas)
+ // each item is a single SchemaProxy struct construction: spinning up goroutines
+ // and channels per item costs far more than the work itself, so build inline.
+ buildOutSchemas := func(schemas []lowmodel.ValueReference[*base.SchemaProxy]) []*SchemaProxy {
+ items := make([]*SchemaProxy, len(schemas))
for i := range schemas {
- go buildSchema(schemas[i], i, bChan)
- }
- j := 0
- for j < totalSchemas {
- r := <-bChan
- j++
- (*items)[r.idx] = r.s
+ n := &lowmodel.NodeReference[*base.SchemaProxy]{
+ ValueNode: schemas[i].ValueNode,
+ Value: schemas[i].Value,
+ }
+ n.SetReference(schemas[i].GetReference(), schemas[i].GetReferenceNode())
+ items[i] = NewSchemaProxy(n)
}
- doneChan <- struct{}{}
+ return items
}
- // props async
buildProps := func(k lowmodel.KeyReference[string], v lowmodel.ValueReference[*base.SchemaProxy],
props *orderedmap.Map[string, *SchemaProxy], sw int,
) {
@@ -427,15 +401,23 @@ func NewSchema(schema *base.Schema) *Schema {
s.DependentSchemas = props
case 2:
s.PatternProperties = props
+ case 3:
+ s.Defs = props
}
}
props := orderedmap.New[string, *SchemaProxy]()
+ if !schema.Properties.IsEmpty() {
+ s.Properties = props
+ }
for name, schemaProxy := range schema.Properties.Value.FromOldest() {
buildProps(name, schemaProxy, props, 0)
}
dependents := orderedmap.New[string, *SchemaProxy]()
+ if !schema.DependentSchemas.IsEmpty() {
+ s.DependentSchemas = dependents
+ }
for name, schemaProxy := range schema.DependentSchemas.Value.FromOldest() {
buildProps(name, schemaProxy, dependents, 1)
}
@@ -450,10 +432,20 @@ func NewSchema(schema *base.Schema) *Schema {
}
patternProps := orderedmap.New[string, *SchemaProxy]()
+ if !schema.PatternProperties.IsEmpty() {
+ s.PatternProperties = patternProps
+ }
for name, schemaProxy := range schema.PatternProperties.Value.FromOldest() {
buildProps(name, schemaProxy, patternProps, 2)
}
+ if !schema.Defs.IsEmpty() {
+ defs := orderedmap.New[string, *SchemaProxy]()
+ for name, schemaProxy := range schema.Defs.Value.FromOldest() {
+ buildProps(name, schemaProxy, defs, 3)
+ }
+ }
+
var allOf []*SchemaProxy
var oneOf []*SchemaProxy
var anyOf []*SchemaProxy
@@ -461,21 +453,14 @@ func NewSchema(schema *base.Schema) *Schema {
var items *DynamicValue[*SchemaProxy, bool]
var prefixItems []*SchemaProxy
- children := 0
if !schema.AllOf.IsEmpty() {
- children++
- allOf = make([]*SchemaProxy, len(schema.AllOf.Value))
- go buildOutSchemas(schema.AllOf.Value, &allOf, polyCompletedChan, errChan)
+ allOf = buildOutSchemas(schema.AllOf.Value)
}
if !schema.AnyOf.IsEmpty() {
- children++
- anyOf = make([]*SchemaProxy, len(schema.AnyOf.Value))
- go buildOutSchemas(schema.AnyOf.Value, &anyOf, polyCompletedChan, errChan)
+ anyOf = buildOutSchemas(schema.AnyOf.Value)
}
if !schema.OneOf.IsEmpty() {
- children++
- oneOf = make([]*SchemaProxy, len(schema.OneOf.Value))
- go buildOutSchemas(schema.OneOf.Value, &oneOf, polyCompletedChan, errChan)
+ oneOf = buildOutSchemas(schema.OneOf.Value)
}
if !schema.Not.IsEmpty() {
not = NewSchemaProxy(&schema.Not)
@@ -495,21 +480,7 @@ func NewSchema(schema *base.Schema) *Schema {
}
}
if !schema.PrefixItems.IsEmpty() {
- children++
- prefixItems = make([]*SchemaProxy, len(schema.PrefixItems.Value))
- go buildOutSchemas(schema.PrefixItems.Value, &prefixItems, polyCompletedChan, errChan)
- }
-
- completeChildren := 0
- if children > 0 {
- allDone:
- for {
- <-polyCompletedChan
- completeChildren++
- if children == completeChildren {
- break allDone
- }
- }
+ prefixItems = buildOutSchemas(schema.PrefixItems.Value)
}
s.OneOf = oneOf
s.AnyOf = anyOf
@@ -559,6 +530,12 @@ func (s *Schema) RenderInline() ([]byte, error) {
// MarshalYAML will create a ready to render YAML representation of the Schema object.
func (s *Schema) MarshalYAML() (interface{}, error) {
+ if s.ParentProxy != nil {
+ if node, ok, err := s.ParentProxy.renderTransformedRefWithSiblings(s); ok || err != nil {
+ return node, err
+ }
+ }
+
nb := high.NewNodeBuilder(s, s.low)
// determine index version
@@ -573,6 +550,14 @@ func (s *Schema) MarshalYAML() (interface{}, error) {
// MarshalJSON will create a ready to render JSON representation of the Schema object.
func (s *Schema) MarshalJSON() ([]byte, error) {
+ if s.ParentProxy != nil && s.ParentProxy.isParsedRefWithSiblings() {
+ node, err := s.ParentProxy.referenceYAMLNodeForSchema(s)
+ if err != nil {
+ return nil, err
+ }
+ return marshalYAMLNodeJSON(node)
+ }
+
nb := high.NewNodeBuilder(s, s.low)
// determine index version
@@ -584,13 +569,7 @@ func (s *Schema) MarshalJSON() ([]byte, error) {
}
// render node
node := nb.Render()
- var renderedJSON map[string]interface{}
-
- // marshal into struct
- _ = node.Decode(&renderedJSON)
-
- // return JSON bytes
- return json.Marshal(renderedJSON)
+ return marshalYAMLNodeJSON(node)
}
// MarshalYAMLInlineWithContext will render out the Schema pointer as YAML using the provided
@@ -606,6 +585,9 @@ func (s *Schema) MarshalYAMLInlineWithContext(ctx any) (interface{}, error) {
renderCtx = NewInlineRenderContext()
ctx = renderCtx
}
+ if s.ParentProxy != nil && s.ParentProxy.isParsedRefWithSiblings() {
+ return s.ParentProxy.marshalParsedRefWithSiblingsInline(renderCtx, s)
+ }
// determine if we should preserve discriminator refs based on rendering mode.
// in validation mode, we need to fully inline all refs for the JSON schema compiler.
@@ -615,12 +597,12 @@ func (s *Schema) MarshalYAMLInlineWithContext(ctx any) (interface{}, error) {
// this avoids mutating shared state and prevents race conditions.
for _, sp := range s.OneOf {
if sp != nil && sp.IsReference() {
- renderCtx.MarkRefAsPreserved(sp.GetReference())
+ markDiscriminatorReferenceAsPreserved(renderCtx, sp)
}
}
for _, sp := range s.AnyOf {
if sp != nil && sp.IsReference() {
- renderCtx.MarkRefAsPreserved(sp.GetReference())
+ markDiscriminatorReferenceAsPreserved(renderCtx, sp)
}
}
}
@@ -638,6 +620,14 @@ func (s *Schema) MarshalYAMLInlineWithContext(ctx any) (interface{}, error) {
return nb.Render(), errors.Join(nb.Errors...)
}
+func markDiscriminatorReferenceAsPreserved(ctx *InlineRenderContext, sp *SchemaProxy) {
+ if sp.GoLow() == nil {
+ ctx.MarkScopedRefAsPreserved(nil, sp.GetReference())
+ return
+ }
+ ctx.MarkReferenceNodeAsPreserved(sp.GetReferenceNode())
+}
+
// MarshalYAMLInline will render out the Schema pointer as YAML, and all refs will be inlined fully.
// This method creates a fresh InlineRenderContext internally.
func (s *Schema) MarshalYAMLInline() (interface{}, error) {
@@ -647,6 +637,14 @@ func (s *Schema) MarshalYAMLInline() (interface{}, error) {
// MarshalJSONInline will render out the Schema pointer as JSON, and all refs will be inlined fully
func (s *Schema) MarshalJSONInline() ([]byte, error) {
+ if s.ParentProxy != nil && s.ParentProxy.isParsedRefWithSiblings() {
+ rendered, err := s.MarshalYAMLInline()
+ if err != nil {
+ return nil, err
+ }
+ return marshalYAMLRenderJSON(rendered)
+ }
+
nb := high.NewNodeBuilder(s, s.low)
nb.Resolve = true
// determine index version
@@ -658,11 +656,21 @@ func (s *Schema) MarshalJSONInline() ([]byte, error) {
}
// render node
node := nb.Render()
- var renderedJSON map[string]interface{}
+ return marshalYAMLNodeJSON(node)
+}
- // marshal into struct
- _ = node.Decode(&renderedJSON)
+func marshalYAMLRenderJSON(rendered interface{}) ([]byte, error) {
+ node, ok := yamlNodeFromRender(rendered)
+ if !ok {
+ return nil, errors.New("unable to render schema as JSON: YAML render was not a node")
+ }
+ return marshalYAMLNodeJSON(node)
+}
- // return JSON bytes
+func marshalYAMLNodeJSON(node *yaml.Node) ([]byte, error) {
+ var renderedJSON map[string]interface{}
+ if err := node.Decode(&renderedJSON); err != nil {
+ return nil, err
+ }
return json.Marshal(renderedJSON)
}
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/high/base/schema_proxy.go b/vendor/github.com/pb33f/libopenapi/datamodel/high/base/schema_proxy.go
index 84b4ce2e2..edee4df71 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/high/base/schema_proxy.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/high/base/schema_proxy.go
@@ -44,17 +44,15 @@ func ClearInlineRenderingTracker() {
inlineRenderingTracker.Clear()
}
-// bundlingModeCount tracks the number of active bundling operations.
-// Uses reference counting to support concurrent BundleDocument calls safely.
-//
-// NOTE: This is process-wide. Any RenderInline() call made while bundling is active
-// (count > 0) will also preserve local component refs. This is intentional - the bundler
-// uses RenderInline internally, and concurrent bundles must all see consistent behavior.
-// Direct RenderInline() calls outside of bundling are unaffected when no bundles are running.
+// bundlingModeCount is retained for source compatibility with callers that use
+// SetBundlingMode and IsBundlingMode directly. New legacy render contexts
+// snapshot this state, while bundle policy is explicitly per operation.
var bundlingModeCount atomic.Int32
// SetBundlingMode increments or decrements the bundling mode reference count.
// Bundling mode is active when count > 0, supporting concurrent bundle operations.
+//
+// Deprecated: configure InlineRenderContext.PreserveLocalComponentRefs instead.
func SetBundlingMode(enabled bool) {
if enabled {
bundlingModeCount.Add(1)
@@ -64,6 +62,8 @@ func SetBundlingMode(enabled bool) {
}
// IsBundlingMode returns whether any bundling operation is active.
+//
+// Deprecated: bundle rendering no longer consults process-global bundling mode.
func IsBundlingMode() bool {
return bundlingModeCount.Load() > 0
}
@@ -86,14 +86,31 @@ const (
// Each render call-chain should use its own context to prevent false positive
// cycle detection when multiple goroutines render the same schemas concurrently.
type InlineRenderContext struct {
- tracker sync.Map
- Mode RenderingMode
- preservedRefs sync.Map // tracks refs that should be preserved in this render
+ tracker sync.Map
+ Mode RenderingMode
+ // PreserveLocalComponentRefs keeps root-local component references intact
+ // while external references continue through inline rendering.
+ PreserveLocalComponentRefs bool
+ // RootIndex identifies the authored root document for local-reference policy.
+ RootIndex *index.SpecIndex
+ // StrictCircularReferenceIdentity requires circular metadata to match the
+ // prepared canonical target instead of a bare authored reference string.
+ StrictCircularReferenceIdentity bool
+ preservedRefs sync.Map // scoped reference key -> struct{}
+ referenceRewrites sync.Map // scoped reference key -> root component ref
+ mappingRewrites sync.Map // discriminator mapping value node -> root component ref
+ referenceNodeSources sync.Map // authored reference node -> source index
+ referenceNodeTargets sync.Map // authored reference node -> canonical target
+ preservedReferenceNodes sync.Map // authored reference node -> struct{}
+ referenceNodeRewrites sync.Map // authored reference node -> root component ref
}
// NewInlineRenderContext creates a new isolated rendering context with default bundle mode.
func NewInlineRenderContext() *InlineRenderContext {
- return &InlineRenderContext{Mode: RenderingModeBundle}
+ return &InlineRenderContext{
+ Mode: RenderingModeBundle,
+ PreserveLocalComponentRefs: IsBundlingMode(),
+ }
}
// NewInlineRenderContextForValidation creates a context that fully inlines
@@ -103,6 +120,26 @@ func NewInlineRenderContextForValidation() *InlineRenderContext {
return &InlineRenderContext{Mode: RenderingModeValidation}
}
+// ScopedReferenceKey identifies an authored reference in the document where it
+// appears. The source qualification prevents equal local fragments in different
+// external documents from colliding during one render.
+func ScopedReferenceKey(source *index.SpecIndex, ref string) string {
+ if source == nil {
+ return scopedReferenceKey("", ref)
+ }
+ return scopedReferenceKey(source.GetSpecAbsolutePath(), ref)
+}
+
+func scopedReferenceKey(sourcePath, ref string) string {
+ if ref == "" {
+ return ""
+ }
+ if sourcePath == "" {
+ return "\x00" + ref
+ }
+ return sourcePath + "\x00" + ref
+}
+
// StartRendering marks a key as being rendered. Returns true if already rendering (cycle detected).
// The key should be stable and unique per schema instance (e.g., filePath:$ref).
func (ctx *InlineRenderContext) StartRendering(key string) bool {
@@ -122,21 +159,177 @@ func (ctx *InlineRenderContext) StopRendering(key string) {
// MarkRefAsPreserved marks a reference as one that should be preserved (not inlined) in this render.
// used by discriminator handling to track which refs need preservation without mutating shared state.
+//
+// Deprecated: use MarkScopedRefAsPreserved to qualify the authored reference by source document.
func (ctx *InlineRenderContext) MarkRefAsPreserved(ref string) {
- if ref != "" {
- ctx.preservedRefs.Store(ref, true)
- }
+ ctx.MarkScopedRefAsPreserved(nil, ref)
}
// ShouldPreserveRef returns true if the given reference was marked for preservation.
+//
+// Deprecated: use ShouldPreserveScopedRef to qualify the authored reference by source document.
func (ctx *InlineRenderContext) ShouldPreserveRef(ref string) bool {
- if ref == "" {
+ return ctx.ShouldPreserveScopedRef(nil, ref)
+}
+
+// MarkScopedRefAsPreserved marks an authored reference in a specific source
+// document as preserved for this render operation.
+func (ctx *InlineRenderContext) MarkScopedRefAsPreserved(source *index.SpecIndex, ref string) {
+ ctx.markRefAsPreserved(scopedReferencePath(source), ref)
+}
+
+func scopedReferencePath(source *index.SpecIndex) string {
+ if source == nil {
+ return ""
+ }
+ return source.GetSpecAbsolutePath()
+}
+
+func (ctx *InlineRenderContext) markRefAsPreserved(sourcePath, ref string) {
+ if key := scopedReferenceKey(sourcePath, ref); key != "" {
+ ctx.preservedRefs.Store(key, struct{}{})
+ }
+}
+
+// ShouldPreserveScopedRef reports whether the source-qualified authored
+// reference must remain a reference during this render operation.
+func (ctx *InlineRenderContext) ShouldPreserveScopedRef(source *index.SpecIndex, ref string) bool {
+ return ctx.shouldPreserveRef(scopedReferencePath(source), ref)
+}
+
+func (ctx *InlineRenderContext) shouldPreserveRef(sourcePath, ref string) bool {
+ key := scopedReferenceKey(sourcePath, ref)
+ if key == "" {
+ return false
+ }
+ _, ok := ctx.preservedRefs.Load(key)
+ return ok
+}
+
+// SetReferenceRewrite maps a source-qualified authored reference to a
+// self-contained root component reference for this render operation.
+func (ctx *InlineRenderContext) SetReferenceRewrite(source *index.SpecIndex, ref, replacement string) {
+ ctx.setReferenceRewrite(scopedReferencePath(source), ref, replacement)
+}
+
+func (ctx *InlineRenderContext) setReferenceRewrite(sourcePath, ref, replacement string) {
+ if key := scopedReferenceKey(sourcePath, ref); key != "" && replacement != "" {
+ ctx.referenceRewrites.Store(key, replacement)
+ }
+}
+
+// ReferenceRewrite returns the root component reference allocated for a
+// source-qualified authored reference.
+func (ctx *InlineRenderContext) ReferenceRewrite(source *index.SpecIndex, ref string) (string, bool) {
+ return ctx.referenceRewrite(scopedReferencePath(source), ref)
+}
+
+func (ctx *InlineRenderContext) referenceRewrite(sourcePath, ref string) (string, bool) {
+ key := scopedReferenceKey(sourcePath, ref)
+ if key == "" {
+ return "", false
+ }
+ replacement, ok := ctx.referenceRewrites.Load(key)
+ if !ok {
+ return "", false
+ }
+ return replacement.(string), true
+}
+
+// SetMappingRewrite records a replacement for one raw discriminator mapping
+// value without mutating the indexed YAML node.
+func (ctx *InlineRenderContext) SetMappingRewrite(node *yaml.Node, replacement string) {
+ if node != nil && replacement != "" {
+ ctx.mappingRewrites.Store(node, replacement)
+ }
+}
+
+// MappingRewrite returns a prepared discriminator mapping replacement.
+func (ctx *InlineRenderContext) MappingRewrite(node *yaml.Node) (string, bool) {
+ if node == nil {
+ return "", false
+ }
+ replacement, ok := ctx.mappingRewrites.Load(node)
+ if !ok {
+ return "", false
+ }
+ return replacement.(string), true
+}
+
+// SetReferenceNodeIdentity records the authored source and canonical target for
+// a reference node. Bundle preparation calls this once before rendering.
+func (ctx *InlineRenderContext) SetReferenceNodeIdentity(node *yaml.Node, source *index.SpecIndex, target string) {
+ if node == nil {
+ return
+ }
+ if source != nil {
+ ctx.referenceNodeSources.Store(node, source)
+ }
+ if target != "" {
+ ctx.referenceNodeTargets.Store(node, target)
+ }
+}
+
+// ReferenceNodeSource returns the authored source index prepared for node.
+func (ctx *InlineRenderContext) ReferenceNodeSource(node *yaml.Node) (*index.SpecIndex, bool) {
+ if node == nil {
+ return nil, false
+ }
+ source, ok := ctx.referenceNodeSources.Load(node)
+ if !ok {
+ return nil, false
+ }
+ return source.(*index.SpecIndex), true
+}
+
+// ReferenceNodeTarget returns the canonical resolved target prepared for node.
+func (ctx *InlineRenderContext) ReferenceNodeTarget(node *yaml.Node) (string, bool) {
+ if node == nil {
+ return "", false
+ }
+ target, ok := ctx.referenceNodeTargets.Load(node)
+ if !ok {
+ return "", false
+ }
+ return target.(string), true
+}
+
+// MarkReferenceNodeAsPreserved marks one authored reference occurrence for
+// preservation without relying on an ambiguous bare reference string.
+func (ctx *InlineRenderContext) MarkReferenceNodeAsPreserved(node *yaml.Node) {
+ if node != nil {
+ ctx.preservedReferenceNodes.Store(node, struct{}{})
+ }
+}
+
+// ShouldPreserveReferenceNode reports whether an authored occurrence is preserved.
+func (ctx *InlineRenderContext) ShouldPreserveReferenceNode(node *yaml.Node) bool {
+ if node == nil {
return false
}
- _, ok := ctx.preservedRefs.Load(ref)
+ _, ok := ctx.preservedReferenceNodes.Load(node)
return ok
}
+// SetReferenceNodeRewrite records the replacement for one authored reference occurrence.
+func (ctx *InlineRenderContext) SetReferenceNodeRewrite(node *yaml.Node, replacement string) {
+ if node != nil && replacement != "" {
+ ctx.referenceNodeRewrites.Store(node, replacement)
+ }
+}
+
+// ReferenceNodeRewrite returns the replacement for one authored reference occurrence.
+func (ctx *InlineRenderContext) ReferenceNodeRewrite(node *yaml.Node) (string, bool) {
+ if node == nil {
+ return "", false
+ }
+ replacement, ok := ctx.referenceNodeRewrites.Load(node)
+ if !ok {
+ return "", false
+ }
+ return replacement.(string), true
+}
+
// SchemaProxy exists as a stub that will create a Schema once (and only once) the Schema() method is called. An
// underlying low-level SchemaProxy backs this high-level one.
//
@@ -175,12 +368,12 @@ type SchemaProxy struct {
buildError error
rendered *Schema
refStr string
- lock *sync.Mutex
+ lock sync.Mutex
}
// NewSchemaProxy creates a new high-level SchemaProxy from a low-level one.
func NewSchemaProxy(schema *low.NodeReference[*base.SchemaProxy]) *SchemaProxy {
- return &SchemaProxy{schema: schema, lock: &sync.Mutex{}}
+ return &SchemaProxy{schema: schema}
}
// copySchemaWithParentProxy creates a shallow copy of a schema and sets the ParentProxy
@@ -193,13 +386,13 @@ func (sp *SchemaProxy) copySchemaWithParentProxy(schema *Schema) *Schema {
// CreateSchemaProxy will create a new high-level SchemaProxy from a high-level Schema, this acts the same
// as if the SchemaProxy is pre-rendered.
func CreateSchemaProxy(schema *Schema) *SchemaProxy {
- return &SchemaProxy{rendered: schema, lock: &sync.Mutex{}}
+ return &SchemaProxy{rendered: schema}
}
// CreateSchemaProxyRef will create a new high-level SchemaProxy from a reference string, this is used only when
// building out new models from scratch that require a reference rather than a schema implementation.
func CreateSchemaProxyRef(ref string) *SchemaProxy {
- return &SchemaProxy{refStr: ref, lock: &sync.Mutex{}}
+ return &SchemaProxy{refStr: ref}
}
// CreateSchemaProxyRefWithSchema creates a SchemaProxy that carries both a $ref and sibling schema
@@ -208,7 +401,7 @@ func CreateSchemaProxyRef(ref string) *SchemaProxy {
//
// If schema is nil, the result behaves identically to CreateSchemaProxyRef.
func CreateSchemaProxyRefWithSchema(ref string, schema *Schema) *SchemaProxy {
- return &SchemaProxy{refStr: ref, rendered: schema, lock: &sync.Mutex{}}
+ return &SchemaProxy{refStr: ref, rendered: schema}
}
// GetValueNode returns the value node of the SchemaProxy.
@@ -228,7 +421,7 @@ func (sp *SchemaProxy) GetValueNode() *yaml.Node {
// instead for proxies created using NewSchemaProxy or CreateSchema* methods.
// https://github.com/pb33f/libopenapi/issues/403
func (sp *SchemaProxy) Schema() *Schema {
- if sp == nil || sp.lock == nil {
+ if sp == nil {
return nil
}
@@ -243,6 +436,11 @@ func (sp *SchemaProxy) Schema() *Schema {
return nil
}
+ if sp.isParsedRefWithSiblings() {
+ sp.rendered = sp.buildSiblingOnlySchemaView()
+ return sp.rendered
+ }
+
// check the high-level cache first.
idx := sp.schema.Value.GetIndex()
if idx != nil && sp.schema.Value != nil {
@@ -294,6 +492,8 @@ func (sp *SchemaProxy) Schema() *Schema {
}
// IsReference returns true if the SchemaProxy is a reference to another Schema.
+// For parsed OpenAPI 3.1 $ref-with-siblings schemas, the low proxy is backed by
+// an internal allOf node, but the high-level API reflects the authored $ref.
func (sp *SchemaProxy) IsReference() bool {
if sp == nil {
return false
@@ -302,6 +502,9 @@ func (sp *SchemaProxy) IsReference() bool {
if sp.refStr != "" {
return true
}
+ if sp.isParsedRefWithSiblings() {
+ return true
+ }
if sp.schema != nil && sp.schema.Value != nil {
return sp.schema.Value.IsReference()
}
@@ -313,11 +516,17 @@ func (sp *SchemaProxy) GetReference() string {
if sp.refStr != "" {
return sp.refStr
}
+ if sp.isParsedRefWithSiblings() {
+ return sp.schema.Value.GetTransformedRefReference()
+ }
if refNode := sp.GetReferenceNode(); refNode != nil {
if refValNode := utils.GetRefValueNode(refNode); refValNode != nil {
return refValNode.Value
}
}
+ if sp.schema == nil || sp.schema.Value == nil {
+ return ""
+ }
return sp.schema.GetValue().GetReference()
}
@@ -332,6 +541,12 @@ func (sp *SchemaProxy) GetReferenceNode() *yaml.Node {
if sp.refStr != "" {
return utils.CreateRefNode(sp.refStr)
}
+ if sp.isParsedRefWithSiblings() {
+ return sp.schema.Value.TransformedRef
+ }
+ if sp.schema == nil || sp.schema.Value == nil {
+ return nil
+ }
return sp.schema.GetValue().GetReferenceNode()
}
@@ -354,9 +569,6 @@ func (sp *SchemaProxy) BuildSchema() (*Schema, error) {
return nil, nil
}
schema := sp.Schema()
- if sp.lock == nil {
- return schema, sp.buildError
- }
sp.lock.Lock()
er := sp.buildError
sp.lock.Unlock()
@@ -368,9 +580,6 @@ func (sp *SchemaProxy) GetBuildError() error {
if sp == nil {
return nil
}
- if sp.lock == nil {
- return sp.buildError
- }
sp.lock.Lock()
err := sp.buildError
sp.lock.Unlock()
@@ -397,6 +606,69 @@ func (sp *SchemaProxy) isRefWithSiblings() bool {
return sp.refStr != "" && sp.rendered != nil && sp.schema == nil
}
+// IsTransformedRefWithSiblings reports whether this high-level proxy represents
+// an authored OpenAPI 3.1 $ref with sibling schema keywords.
+func (sp *SchemaProxy) IsTransformedRefWithSiblings() bool {
+ return sp != nil &&
+ sp.schema != nil &&
+ sp.schema.Value != nil &&
+ sp.schema.Value.IsTransformedRefWithSiblings() &&
+ sp.shouldCollapseTransformedRefWithSiblings()
+}
+
+func (sp *SchemaProxy) isParsedRefWithSiblings() bool {
+ return sp.IsTransformedRefWithSiblings()
+}
+
+func (sp *SchemaProxy) buildSiblingOnlySchemaView() *Schema {
+ if sp == nil || sp.schema == nil || sp.schema.Value == nil {
+ return nil
+ }
+ lowProxy := sp.schema.Value
+ siblingNode := lowProxy.GetTransformedRefSiblingSchema()
+ if siblingNode == nil {
+ return nil
+ }
+
+ lowSchema := new(base.Schema)
+ if err := lowSchema.Build(lowProxy.GetContext(), siblingNode, lowProxy.GetIndex()); err != nil {
+ sp.buildError = err
+ return nil
+ }
+ lowSchema.ParentProxy = lowProxy
+
+ schema := NewSchema(lowSchema)
+ schema.ParentProxy = sp
+ return schema
+}
+
+// BuildTransformedRefSemanticSchema returns the internal semantic allOf view for
+// an authored $ref-with-siblings proxy, using current high-level sibling values.
+func (sp *SchemaProxy) BuildTransformedRefSemanticSchema(currentSibling *Schema) (*Schema, error) {
+ return sp.buildSemanticAllOfSchemaView(currentSibling)
+}
+
+func (sp *SchemaProxy) buildSemanticAllOfSchemaView(currentSibling *Schema) (*Schema, error) {
+ if sp == nil || sp.schema == nil || sp.schema.Value == nil {
+ return nil, nil
+ }
+ lowSchema := sp.schema.Value.Schema()
+ if lowSchema == nil {
+ return nil, sp.schema.Value.GetBuildError()
+ }
+ schema := NewSchema(lowSchema)
+ schema.ParentProxy = nil
+ if currentSibling == nil {
+ currentSibling = sp.Schema()
+ }
+ if currentSibling != nil && len(schema.AllOf) == 2 {
+ siblingCopy := *currentSibling
+ siblingCopy.ParentProxy = nil
+ schema.AllOf[0] = CreateSchemaProxy(&siblingCopy)
+ }
+ return schema, nil
+}
+
// renderRefWithSiblings builds a YAML mapping node containing $ref as the
// first key followed by all rendered schema sibling properties.
func (sp *SchemaProxy) renderRefWithSiblings() *yaml.Node {
@@ -412,6 +684,124 @@ func (sp *SchemaProxy) renderRefWithSiblings() *yaml.Node {
return node
}
+func (sp *SchemaProxy) renderTransformedRefWithSiblings(s *Schema) (*yaml.Node, bool, error) {
+ if sp == nil || sp.schema == nil || sp.schema.Value == nil || sp.schema.Value.TransformedRef == nil || s == nil {
+ return nil, false, nil
+ }
+ if !sp.shouldCollapseTransformedRefWithSiblings() {
+ return nil, false, nil
+ }
+
+ var siblingNode *yaml.Node
+ ref := sp.schema.Value.GetTransformedRefReference()
+
+ if !sp.schemaIsTransformedSiblingView(s) {
+ if len(s.AllOf) != 2 || s.AllOf[0] == nil || s.AllOf[1] == nil || !s.AllOf[1].IsReference() {
+ return nil, false, nil
+ }
+
+ // Only collapse the synthetic allOf created by the sibling-ref transformer.
+ // If callers add fields to the outer schema or change its composition, keep
+ // the explicit allOf so no mutations are hidden.
+ outerNode := high.NewNodeBuilder(s, s.low).Render()
+ if len(outerNode.Content) != 2 || outerNode.Content[0].Value != "allOf" {
+ return nil, false, nil
+ }
+
+ siblingRender, err := s.AllOf[0].MarshalYAML()
+ if err != nil {
+ return nil, true, err
+ }
+ var ok bool
+ siblingNode, ok = yamlNodeFromRender(siblingRender)
+ if !ok || !utils.IsNodeMap(siblingNode) {
+ return nil, false, nil
+ }
+ ref = s.AllOf[1].GetReference()
+ } else {
+ siblingNode = high.NewNodeBuilder(s, s.low).Render()
+ }
+
+ original := sp.schema.Value.TransformedRef
+ result := utils.CreateEmptyMapNode()
+ consumed := make(map[string]struct{}, len(siblingNode.Content)/2)
+
+ for i := 0; i+1 < len(original.Content); i += 2 {
+ keyNode := original.Content[i]
+ valueNode := original.Content[i+1]
+ if keyNode == nil {
+ continue
+ }
+ if keyNode.Value == "$ref" {
+ refKey := utils.CloneYAMLNode(keyNode)
+ refValue := utils.CloneYAMLNode(valueNode)
+ if refValue == nil {
+ refValue = utils.CreateStringNode(ref)
+ }
+ refValue.Value = ref
+ result.Content = append(result.Content, refKey, refValue)
+ continue
+ }
+ if _, siblingValue := findYAMLPair(siblingNode, keyNode.Value); siblingValue != nil {
+ renderKey := utils.CloneYAMLNode(keyNode)
+ result.Content = append(result.Content, renderKey, utils.CloneYAMLNode(siblingValue))
+ consumed[keyNode.Value] = struct{}{}
+ }
+ }
+
+ for i := 0; i+1 < len(siblingNode.Content); i += 2 {
+ keyNode := siblingNode.Content[i]
+ valueNode := siblingNode.Content[i+1]
+ if _, ok := consumed[keyNode.Value]; ok {
+ continue
+ }
+ result.Content = append(result.Content, utils.CloneYAMLNode(keyNode), utils.CloneYAMLNode(valueNode))
+ }
+
+ return result, true, nil
+}
+
+func (sp *SchemaProxy) schemaIsTransformedSiblingView(s *Schema) bool {
+ if sp == nil || sp.schema == nil || sp.schema.Value == nil || s == nil {
+ return false
+ }
+ return s.low != nil && s.low.RootNode == sp.schema.Value.GetTransformedRefSiblingSchema()
+}
+
+func (sp *SchemaProxy) shouldCollapseTransformedRefWithSiblings() bool {
+ if sp == nil || sp.schema == nil || sp.schema.Value == nil {
+ return false
+ }
+ idx := sp.schema.Value.GetIndex()
+ if idx == nil || idx.GetConfig() == nil || idx.GetConfig().SpecInfo == nil {
+ return true
+ }
+ return idx.GetConfig().SpecInfo.VersionNumeric >= 3.1
+}
+
+func yamlNodeFromRender(rendered interface{}) (*yaml.Node, bool) {
+ switch node := rendered.(type) {
+ case *yaml.Node:
+ return node, node != nil
+ case yaml.Node:
+ return &node, true
+ default:
+ return nil, false
+ }
+}
+
+func findYAMLPair(node *yaml.Node, key string) (*yaml.Node, *yaml.Node) {
+ if node == nil || !utils.IsNodeMap(node) {
+ return nil, nil
+ }
+ for i := 0; i+1 < len(node.Content); i += 2 {
+ if node.Content[i] != nil && node.Content[i].Value == key {
+ return node.Content[i], node.Content[i+1]
+ }
+ }
+ return nil, nil
+}
+
// Render will return a YAML representation of the Schema object as a byte slice.
func (sp *SchemaProxy) Render() ([]byte, error) {
return yaml.Marshal(sp)
@@ -419,11 +809,17 @@ func (sp *SchemaProxy) Render() ([]byte, error) {
// MarshalYAML will create a ready to render YAML representation of the SchemaProxy object.
func (sp *SchemaProxy) MarshalYAML() (interface{}, error) {
+ if sp.isParsedRefWithSiblings() {
+ return sp.referenceYAMLNodeForSchema(nil)
+ }
if !sp.IsReference() {
s, err := sp.BuildSchema()
if err != nil {
return nil, err
}
+ if node, ok, renderErr := sp.renderTransformedRefWithSiblings(s); ok || renderErr != nil {
+ return node, renderErr
+ }
nb := high.NewNodeBuilder(s, s.low)
return nb.Render(), nil
}
@@ -433,6 +829,112 @@ func (sp *SchemaProxy) MarshalYAML() (interface{}, error) {
return sp.GetReferenceNode(), nil
}
+func (sp *SchemaProxy) referenceYAMLNode() (*yaml.Node, error) {
+ return sp.referenceYAMLNodeForSchema(nil)
+}
+
+func (sp *SchemaProxy) sourceIndex() *index.SpecIndex {
+ if sp == nil || sp.schema == nil || sp.schema.Value == nil {
+ return nil
+ }
+ return sp.schema.Value.GetIndex()
+}
+
+func (sp *SchemaProxy) referenceSourceIndex(ctx *InlineRenderContext) *index.SpecIndex {
+ if ctx != nil {
+ if source, ok := ctx.ReferenceNodeSource(sp.GetReferenceNode()); ok {
+ return source
+ }
+ }
+ return sp.sourceIndex()
+}
+
+func (sp *SchemaProxy) referenceSourcePath(ctx *InlineRenderContext) string {
+ if source := sp.referenceSourceIndex(ctx); source != nil {
+ return source.GetSpecAbsolutePath()
+ }
+ return ""
+}
+
+func (sp *SchemaProxy) isRootLocalReference(ctx *InlineRenderContext) bool {
+ if sp == nil || !strings.HasPrefix(sp.GetReference(), "#/") {
+ return false
+ }
+ source := sp.referenceSourceIndex(ctx)
+ if source == nil {
+ return false
+ }
+ if ctx != nil && ctx.RootIndex != nil {
+ return source == ctx.RootIndex
+ }
+ return source.GetRolodex() != nil && source.GetRolodex().GetRootIndex() == source
+}
+
+func (sp *SchemaProxy) referenceTargetIdentity(ctx *InlineRenderContext) string {
+ if ctx != nil {
+ if target, ok := ctx.ReferenceNodeTarget(sp.GetReferenceNode()); ok {
+ return index.CanonicalReferenceIdentity(target)
+ }
+ }
+ ref := sp.GetReference()
+ if strings.HasPrefix(ref, "#") {
+ if source := sp.sourceIndex(); source != nil {
+ return index.CanonicalReferenceIdentity(source.GetSpecAbsolutePath() + ref)
+ }
+ }
+ return ""
+}
+
+// rewrittenReferenceNode clones the authored reference node and applies the
+// source-qualified replacement for this render, if one was prepared. Cloning
+// preserves $ref siblings and source metadata without mutating indexed nodes.
+func (sp *SchemaProxy) rewrittenReferenceNode(ctx *InlineRenderContext) (*yaml.Node, bool, error) {
+ node, err := sp.referenceYAMLNode()
+ if node == nil {
+ return nil, false, err
+ }
+ replacement, ok := ctx.ReferenceNodeRewrite(node)
+ if !ok {
+ replacement, ok = ctx.referenceRewrite(sp.referenceSourcePath(ctx), sp.GetReference())
+ }
+ if !ok {
+ return node, false, err
+ }
+ cloned := utils.CloneYAMLNode(node)
+ refValue := utils.GetRefValueNode(cloned)
+ if refValue == nil {
+ return nil, false, errors.Join(err, errors.New("unable to rewrite schema reference: $ref value node is missing"))
+ }
+ refValue.Value = replacement
+ return cloned, true, err
+}
+
+func (sp *SchemaProxy) circularReferenceResult(ctx *InlineRenderContext, node *yaml.Node, rewritten bool, refErr, circularErr error) (*yaml.Node, error) {
+ if rewritten || sp.isRootLocalReference(ctx) {
+ return node, refErr
+ }
+ return node, errors.Join(refErr, circularErr)
+}
+
+func (sp *SchemaProxy) referenceYAMLNodeForSchema(s *Schema) (*yaml.Node, error) {
+ if sp.isRefWithSiblings() {
+ return sp.renderRefWithSiblings(), nil
+ }
+ if sp.isParsedRefWithSiblings() {
+ if s == nil {
+ var err error
+ s, err = sp.BuildSchema()
+ if err != nil {
+ return nil, err
+ }
+ }
+ if node, ok, renderErr := sp.renderTransformedRefWithSiblings(s); ok || renderErr != nil {
+ return node, renderErr
+ }
+ }
+ return sp.GetReferenceNode(), nil
+}
+
// getInlineRenderKey generates a unique key for tracking this schema during inline rendering.
// This prevents infinite recursion when schemas reference each other circularly.
func (sp *SchemaProxy) getInlineRenderKey() string {
@@ -444,6 +946,22 @@ func (sp *SchemaProxy) getInlineRenderKey() string {
}
return ""
}
+ if sp.isParsedRefWithSiblings() && sp.schema.ValueNode != nil {
+ node := sp.schema.ValueNode
+ idx := sp.schema.Value.GetIndex()
+ if node.Line > 0 && node.Column > 0 {
+ source := "inline"
+ if idx != nil {
+ source = idx.GetSpecAbsolutePath()
+ }
+ return fmt.Sprintf("%s:%d:%d", source, node.Line, node.Column)
+ }
+ source := "inline"
+ if idx != nil {
+ source = fmt.Sprintf("%s:inline", idx.GetSpecAbsolutePath())
+ }
+ return fmt.Sprintf("%s:%p", source, node)
+ }
// Use the reference string if available
if sp.IsReference() {
ref := sp.GetReference()
@@ -501,13 +1019,11 @@ func (sp *SchemaProxy) MarshalYAMLInline() (interface{}, error) {
}
func (sp *SchemaProxy) marshalYAMLInlineInternal(ctx *InlineRenderContext) (interface{}, error) {
- // refNode returns the correct reference YAML node — with sibling
- // properties when this proxy carries both a $ref and schema data.
- refNode := func() *yaml.Node {
- if sp.isRefWithSiblings() {
- return sp.renderRefWithSiblings()
- }
- return sp.GetReferenceNode()
+ refNode := func() (*yaml.Node, error) {
+ return sp.referenceYAMLNode()
+ }
+ rewrittenRefNode := func() (*yaml.Node, bool, error) {
+ return sp.rewrittenReferenceNode(ctx)
}
// check if this reference should be preserved (set via context by discriminator handling).
@@ -515,15 +1031,21 @@ func (sp *SchemaProxy) marshalYAMLInlineInternal(ctx *InlineRenderContext) (inte
// need to guard against nil schema.Value which can happen with bad/incomplete proxies.
if sp.IsReference() {
ref := sp.GetReference()
- if ref != "" && ctx.ShouldPreserveRef(ref) {
- return refNode(), nil
+ refNode := sp.GetReferenceNode()
+ preserve := ctx.ShouldPreserveReferenceNode(refNode)
+ if !preserve {
+ preserve = ctx.shouldPreserveRef(sp.referenceSourcePath(ctx), ref) || ctx.ShouldPreserveRef(ref)
+ }
+ if ref != "" && preserve {
+ node, _, err := rewrittenRefNode()
+ return node, err
}
}
// In bundling mode, preserve local component refs that point to schemas in the SAME document.
// Only inline refs that point to schemas from EXTERNAL files.
// Outside of bundling mode (direct MarshalYAMLInline calls), inline everything.
- if IsBundlingMode() && sp.IsReference() {
+ if ctx.PreserveLocalComponentRefs && sp.IsReference() {
ref := sp.GetReference()
if strings.HasPrefix(ref, "#/components/") {
// Check if this ref points to a schema in the same root document.
@@ -536,8 +1058,8 @@ func (sp *SchemaProxy) marshalYAMLInlineInternal(ctx *InlineRenderContext) (inte
if rolodex != nil {
rootIdx := rolodex.GetRootIndex()
// If the schema is in the root index, preserve the ref
- if rootIdx != nil && schemaIdx == rootIdx {
- return refNode(), nil
+ if rootIdx != nil && sp.isRootLocalReference(ctx) {
+ return refNode()
}
}
}
@@ -553,8 +1075,9 @@ func (sp *SchemaProxy) marshalYAMLInlineInternal(ctx *InlineRenderContext) (inte
if ctx.StartRendering(renderKey) {
// We're already rendering this schema in THIS call chain - return ref to break the cycle
if sp.IsReference() {
- return refNode(),
- fmt.Errorf("schema render failure, circular reference: `%s`", sp.GetReference())
+ node, rewritten, refErr := rewrittenRefNode()
+ return sp.circularReferenceResult(ctx, node, rewritten, refErr,
+ fmt.Errorf("schema render failure, circular reference: `%s`", sp.GetReference()))
}
// For inline schemas, return an empty map to avoid infinite recursion
return &yaml.Node{Kind: yaml.MappingNode, Tag: "!!map"},
@@ -584,8 +1107,20 @@ func (sp *SchemaProxy) marshalYAMLInlineInternal(ctx *InlineRenderContext) (inte
for _, c := range circ {
if sp.IsReference() {
+ if c == nil || c.LoopPoint == nil {
+ continue
+ }
+ if ctx.StrictCircularReferenceIdentity {
+ target := sp.referenceTargetIdentity(ctx)
+ if target == "" || target != index.CanonicalReferenceIdentity(c.LoopPoint.FullDefinition) {
+ continue
+ }
+ node, rewritten, refErr := rewrittenRefNode()
+ return sp.circularReferenceResult(ctx, node, rewritten, refErr, cirError(c.LoopPoint.Definition))
+ }
if sp.GetReference() == c.LoopPoint.Definition {
- return refNode(), cirError(c.LoopPoint.Definition)
+ node, rewritten, refErr := rewrittenRefNode()
+ return sp.circularReferenceResult(ctx, node, rewritten, refErr, cirError(c.LoopPoint.Definition))
}
basePath := idx.GetSpecAbsolutePath()
@@ -594,7 +1129,8 @@ func (sp *SchemaProxy) marshalYAMLInlineInternal(ctx *InlineRenderContext) (inte
}
if basePath == c.LoopPoint.FullDefinition {
- return refNode(), cirError(c.LoopPoint.Definition)
+ node, rewritten, refErr := rewrittenRefNode()
+ return sp.circularReferenceResult(ctx, node, rewritten, refErr, cirError(c.LoopPoint.Definition))
}
a := utils.ReplaceWindowsDriveWithLinuxPath(strings.Replace(c.LoopPoint.FullDefinition, basePath, "", 1))
b := sp.GetReference()
@@ -616,14 +1152,16 @@ func (sp *SchemaProxy) marshalYAMLInlineInternal(ctx *InlineRenderContext) (inte
bBase, bFragment := index.SplitRefFragment(b)
if aFragment != "" && bFragment != "" && aFragment == bFragment {
- return refNode(), cirError(c.LoopPoint.Definition)
+ node, rewritten, refErr := rewrittenRefNode()
+ return sp.circularReferenceResult(ctx, node, rewritten, refErr, cirError(c.LoopPoint.Definition))
}
if aFragment == "" && bFragment == "" {
aNorm := strings.TrimPrefix(strings.TrimPrefix(aBase, "./"), "/")
bNorm := strings.TrimPrefix(strings.TrimPrefix(bBase, "./"), "/")
if aNorm != "" && bNorm != "" && aNorm == bNorm {
- return refNode(), cirError(c.LoopPoint.Definition)
+ node, rewritten, refErr := rewrittenRefNode()
+ return sp.circularReferenceResult(ctx, node, rewritten, refErr, cirError(c.LoopPoint.Definition))
}
}
}
@@ -634,6 +1172,9 @@ func (sp *SchemaProxy) marshalYAMLInlineInternal(ctx *InlineRenderContext) (inte
return nil, err
}
if s != nil {
+ if sp.isParsedRefWithSiblings() {
+ return sp.marshalParsedRefWithSiblingsInline(ctx, s)
+ }
// For programmatic ref+siblings proxies, render directly to avoid nil-deref
// in Schema.MarshalYAMLInlineWithContext which assumes s.GoLow() is non-nil.
if sp.isRefWithSiblings() {
@@ -647,3 +1188,14 @@ func (sp *SchemaProxy) marshalYAMLInlineInternal(ctx *InlineRenderContext) (inte
}
return nil, errors.New("unable to render schema")
}
+
+func (sp *SchemaProxy) marshalParsedRefWithSiblingsInline(ctx *InlineRenderContext, currentSibling *Schema) (interface{}, error) {
+ s, err := sp.buildSemanticAllOfSchemaView(currentSibling)
+ if err != nil {
+ return nil, err
+ }
+ if s == nil {
+ return nil, errors.New("unable to render transformed schema reference")
+ }
+ return s.MarshalYAMLInlineWithContext(ctx)
+}
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/high/node_builder.go b/vendor/github.com/pb33f/libopenapi/datamodel/high/node_builder.go
index dc1a991cb..b282dc079 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/high/node_builder.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/high/node_builder.go
@@ -5,6 +5,7 @@ package high
import (
"fmt"
+ "math"
"reflect"
"sort"
"strconv"
@@ -39,6 +40,32 @@ type RenderableInlineWithContext interface {
const renderZero = "renderZero"
+func originalFloatLexeme(value float64, lowValue any) (string, bool) {
+ vnut, ok := lowValue.(low.HasValueNodeUntyped)
+ if !ok {
+ return "", false
+ }
+
+ valueNode := vnut.GetValueNode()
+ if valueNode == nil || !utils.IsNodeNumberValue(valueNode) {
+ return "", false
+ }
+
+ parsed, err := strconv.ParseFloat(valueNode.Value, 64)
+ if err != nil {
+ return "", false
+ }
+
+ if parsed != value {
+ return "", false
+ }
+ if value == 0 && math.Signbit(parsed) != math.Signbit(value) {
+ return "", false
+ }
+
+ return valueNode.Value, true
+}
+
// NewNodeBuilder will create a new NodeBuilder instance, this is the only way to create a NodeBuilder.
// The function accepts a high level object and a low level object (need to be siblings/same type).
//
@@ -321,6 +348,19 @@ func (n *NodeBuilder) Render() *yaml.Node {
return m
}
+// encodeSafeValue returns a value safe to pass to (*yaml.Node).Encode. When the
+// value is a *yaml.Node it returns a deep copy: Encode desolves the represented
+// graph in place (Desolve rewrites Tag/Style), and the representer aliases input
+// nodes, so encoding a model-owned node would mutate it. With concurrent renders
+// (e.g. linters running rules in parallel) that mutation races with readers of
+// the same node. Encoding a copy keeps shared nodes immutable.
+func encodeSafeValue(value any) any {
+ if vn, ok := value.(*yaml.Node); ok {
+ return utils.CloneYAMLNode(vn)
+ }
+ return value
+}
+
// AddYAMLNode will add a new *yaml.Node to the parent node, using the tag, key and value provided.
// If the value is nil, then the node will not be added. This method is recursive, so it will dig down
// into any non-scalar types.
@@ -384,6 +424,9 @@ func (n *NodeBuilder) AddYAMLNode(parent *yaml.Node, entry *nodes.NodeEntry) *ya
precision = len(strings.Split(fmt.Sprint(entry.StringValue), ".")[1])
}
val := strconv.FormatFloat(value.(float64), 'f', precision, 64)
+ if original, ok := originalFloatLexeme(value.(float64), entry.LowValue); ok {
+ val = original
+ }
// Always create float node for float64 values, even if they don't contain decimal points
// This handles cases like negative zero (-0.0) which formats as "-0" but should remain float
valueNode = utils.CreateFloatNode(val)
@@ -462,7 +505,7 @@ func (n *NodeBuilder) AddYAMLNode(parent *yaml.Node, entry *nodes.NodeEntry) *ya
break
}
- err := rawNode.Encode(value)
+ err := rawNode.Encode(encodeSafeValue(value))
if err != nil {
return parent
} else {
@@ -589,6 +632,9 @@ func (n *NodeBuilder) AddYAMLNode(parent *yaml.Node, entry *nodes.NodeEntry) *ya
encodeSkip = true
if *b != 0 || entry.RenderZero {
formatFloat := strconv.FormatFloat(*b, 'f', -1, 64)
+ if original, ok := originalFloatLexeme(*b, entry.LowValue); ok {
+ formatFloat = original
+ }
// Always create float node for float64 values, even if they're whole numbers
// This handles cases like negative zero (-0.0) and ensures type consistency
@@ -612,7 +658,7 @@ func (n *NodeBuilder) AddYAMLNode(parent *yaml.Node, entry *nodes.NodeEntry) *ya
}
}
- err := rawNode.Encode(value)
+ err := rawNode.Encode(encodeSafeValue(value))
if err != nil {
return parent
} else {
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/high/shared.go b/vendor/github.com/pb33f/libopenapi/datamodel/high/shared.go
index bc72d0853..8fca606c7 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/high/shared.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/high/shared.go
@@ -15,11 +15,13 @@ package high
import (
"context"
+ "errors"
"fmt"
"github.com/pb33f/libopenapi/datamodel/low"
"github.com/pb33f/libopenapi/index"
"github.com/pb33f/libopenapi/orderedmap"
+ "github.com/pb33f/libopenapi/utils"
"go.yaml.in/yaml/v4"
)
@@ -60,7 +62,7 @@ func RenderInlineWithContext(high, low, ctx any) (interface{}, error) {
nb := NewNodeBuilder(high, low)
nb.Resolve = true
nb.RenderContext = ctx
- return nb.Render(), nil
+ return nb.Render(), errors.Join(nb.Errors...)
}
// UnpackExtensions is a convenience function that makes it easy and simple to unpack an objects extensions
@@ -147,6 +149,10 @@ func ResolveExternalRef[H any, L any](
return result, nil
}
+ if isResolvedExternalRefModel(lowObj) {
+ return result, nil
+ }
+
ref := lowObj.GetReference()
resolved := idx.FindComponent(context.Background(), ref)
if resolved == nil || resolved.Node == nil {
@@ -168,6 +174,22 @@ func ResolveExternalRef[H any, L any](
return result, nil
}
+func isResolvedExternalRefModel(lowObj ExternalRefResolver) bool {
+ if !utils.IsExternalRef(lowObj.GetReference()) {
+ return false
+ }
+ rooted, ok := lowObj.(low.HasRootNode)
+ if !ok {
+ return false
+ }
+ root := rooted.GetRootNode()
+ if root == nil {
+ return false
+ }
+ isRef, _, _ := utils.IsNodeRefValue(root)
+ return !isRef
+}
+
// RenderExternalRef is a convenience function that resolves an external reference and renders it inline.
// This combines ResolveExternalRef with RenderInline for the common case where you want to
// resolve and immediately render an external reference.
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/callback.go b/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/callback.go
index 8b9d8f2ae..f5c79f9a2 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/callback.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/callback.go
@@ -5,6 +5,7 @@ package v3
import (
"context"
+ "fmt"
"sort"
"github.com/pb33f/libopenapi/datamodel/high"
@@ -241,10 +242,14 @@ func (c *Callback) marshalYAMLInlineInternal(ctx any) (interface{}, error) {
for _, mp := range mapped {
if mp.pi != nil {
var rendered interface{}
+ var err error
if ctx != nil {
- rendered, _ = mp.pi.MarshalYAMLInlineWithContext(ctx)
+ rendered, err = mp.pi.MarshalYAMLInlineWithContext(ctx)
} else {
- rendered, _ = mp.pi.MarshalYAMLInline()
+ rendered, err = mp.pi.MarshalYAMLInline()
+ }
+ if err != nil {
+ return nil, fmt.Errorf("failed to render callback path %q inline: %w", mp.path, err)
}
kn := utils.CreateStringNode(mp.path)
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/components.go b/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/components.go
index 2548088c3..3d8b8c560 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/components.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/components.go
@@ -4,6 +4,7 @@
package v3
import (
+ "errors"
"sync"
"github.com/pb33f/libopenapi/datamodel"
@@ -197,6 +198,17 @@ func (c *Components) MarshalYAMLInline() (interface{}, error) {
return rendered, nil
}
+// MarshalYAMLInlineWithContext renders components with a shared inline render context.
+func (c *Components) MarshalYAMLInlineWithContext(ctx any) (interface{}, error) {
+ c.warnPreservedComponentMapRefs()
+ nb := high.NewNodeBuilder(c, c.low)
+ nb.Resolve = true
+ nb.RenderContext = ctx
+ rendered := nb.Render()
+ c.preserveInvalidComponentMapRefs(rendered)
+ return rendered, errors.Join(nb.Errors...)
+}
+
func (c *Components) warnPreservedComponentMapRefs() {
if c == nil || c.low == nil {
return
@@ -315,7 +327,7 @@ func preserveComponentRefEntries[T any](
sectionNode,
)
}
- upsertMapNodeEntry(sectionNode, cloneYAMLNode(keyNode), cloneYAMLNode(valueNode))
+ upsertMapNodeEntry(sectionNode, utils.CloneYAMLNode(keyNode), utils.CloneYAMLNode(valueNode))
}
}
@@ -346,20 +358,3 @@ func upsertMapNodeEntry(m *yaml.Node, keyNode, valueNode *yaml.Node) {
}
m.Content = append(m.Content, keyNode, valueNode)
}
-
-// cloneYAMLNode deep-copies a YAML node tree so preserved low-level nodes can be spliced into
-// rendered output without mutating the original parsed model.
-func cloneYAMLNode(node *yaml.Node) *yaml.Node {
- if node == nil {
- return nil
- }
-
- cloned := *node
- if len(node.Content) > 0 {
- cloned.Content = make([]*yaml.Node, len(node.Content))
- for i, child := range node.Content {
- cloned.Content[i] = cloneYAMLNode(child)
- }
- }
- return &cloned
-}
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/document.go b/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/document.go
index 5bbd231ee..efd427820 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/document.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/document.go
@@ -11,6 +11,7 @@ package v3
import (
"bytes"
+ "errors"
"github.com/pb33f/libopenapi/datamodel/high"
"github.com/pb33f/libopenapi/datamodel/high/base"
@@ -173,9 +174,10 @@ func (d *Document) Render() ([]byte, error) {
// the rendering will use the original indention of the document.
func (d *Document) RenderWithIndention(indent int) []byte {
var buf bytes.Buffer
- yamlEncoder := yaml.NewEncoder(&buf)
- yamlEncoder.SetIndent(indent)
- _ = yamlEncoder.Encode(d)
+ yamlDumper, _ := yaml.NewDumper(&buf, yaml.WithV3Defaults(), yaml.WithLineWidth(-1))
+ yamlDumper.SetIndent(indent)
+ _ = yamlDumper.Dump(d)
+ _ = yamlDumper.Close()
return buf.Bytes()
}
@@ -195,6 +197,16 @@ func (d *Document) RenderInline() ([]byte, error) {
return yaml.Marshal(di)
}
+// RenderInlineWithContext renders the document using one shared inline render
+// context and propagates every NodeBuilder error before marshaling output.
+func (d *Document) RenderInlineWithContext(ctx *base.InlineRenderContext) ([]byte, error) {
+ di, err := d.MarshalYAMLInlineWithContext(ctx)
+ if err != nil {
+ return nil, err
+ }
+ return yaml.Marshal(di)
+}
+
// MarshalYAML will create a ready to render YAML representation of the Document object.
func (d *Document) MarshalYAML() (interface{}, error) {
nb := high.NewNodeBuilder(d, d.low)
@@ -207,6 +219,24 @@ func (d *Document) MarshalYAMLInline() (interface{}, error) {
return nb.Render(), nil
}
+// MarshalYAMLInlineWithContext creates the inline YAML node graph using one
+// context for the complete document render and returns accumulated builder
+// errors instead of silently emitting a partial document.
+func (d *Document) MarshalYAMLInlineWithContext(ctx any) (interface{}, error) {
+ renderCtx, ok := ctx.(*base.InlineRenderContext)
+ if !ok || renderCtx == nil {
+ renderCtx = base.NewInlineRenderContext()
+ }
+ nb := high.NewNodeBuilder(d, d.low)
+ nb.Resolve = true
+ nb.RenderContext = renderCtx
+ node := nb.Render()
+ if err := errors.Join(nb.Errors...); err != nil {
+ return nil, err
+ }
+ return node, nil
+}
+
func (d *Document) GetIndex() *index.SpecIndex {
return d.Index
}
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/media_type.go b/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/media_type.go
index 1d90efa17..460906982 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/media_type.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/media_type.go
@@ -4,6 +4,8 @@
package v3
import (
+ "errors"
+
"github.com/pb33f/libopenapi/datamodel"
"github.com/pb33f/libopenapi/datamodel/high"
"github.com/pb33f/libopenapi/datamodel/high/base"
@@ -88,7 +90,7 @@ func (m *MediaType) MarshalYAMLInlineWithContext(ctx any) (interface{}, error) {
nb := high.NewNodeBuilder(m, m.low)
nb.Resolve = true
nb.RenderContext = ctx
- return nb.Render(), nil
+ return nb.Render(), errors.Join(nb.Errors...)
}
// ExtractContent takes in a complex and hard to navigate low-level content map, and converts it in to a much simpler
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/operation.go b/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/operation.go
index 5f831a4eb..25cc1e389 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/operation.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/operation.go
@@ -121,3 +121,8 @@ func (o *Operation) MarshalYAMLInline() (interface{}, error) {
nb.Resolve = true
return nb.Render(), nil
}
+
+// MarshalYAMLInlineWithContext renders the operation with a shared inline render context.
+func (o *Operation) MarshalYAMLInlineWithContext(ctx any) (interface{}, error) {
+ return high.RenderInlineWithContext(o, o.low, ctx)
+}
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/paths.go b/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/paths.go
index c07edd5e6..b50f80da5 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/paths.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/paths.go
@@ -145,6 +145,15 @@ func (p *Paths) MarshalYAML() (interface{}, error) {
}
func (p *Paths) MarshalYAMLInline() (interface{}, error) {
+ return p.marshalYAMLInlineWithContext(nil)
+}
+
+// MarshalYAMLInlineWithContext renders paths with a shared inline render context.
+func (p *Paths) MarshalYAMLInlineWithContext(ctx any) (interface{}, error) {
+ return p.marshalYAMLInlineWithContext(ctx)
+}
+
+func (p *Paths) marshalYAMLInlineWithContext(ctx any) (interface{}, error) {
// map keys correctly.
m := utils.CreateEmptyMapNode()
type pathItem struct {
@@ -177,6 +186,7 @@ func (p *Paths) MarshalYAMLInline() (interface{}, error) {
nb := high.NewNodeBuilder(p, p.low)
nb.Resolve = true
+ nb.RenderContext = ctx
extNode := nb.Render()
if extNode != nil && extNode.Content != nil {
var label string
@@ -197,7 +207,13 @@ func (p *Paths) MarshalYAMLInline() (interface{}, error) {
})
for _, mp := range mapped {
if mp.pi != nil {
- rendered, err := mp.pi.MarshalYAMLInline()
+ var rendered interface{}
+ var err error
+ if ctx != nil {
+ rendered, err = mp.pi.MarshalYAMLInlineWithContext(ctx)
+ } else {
+ rendered, err = mp.pi.MarshalYAMLInline()
+ }
if err != nil {
return nil, fmt.Errorf("failed to render path '%s' inline: %w", mp.path, err)
}
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/responses.go b/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/responses.go
index cdef1dcae..ff482974f 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/responses.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/high/v3/responses.go
@@ -4,6 +4,7 @@
package v3
import (
+ "errors"
"fmt"
"sort"
@@ -155,6 +156,15 @@ func (r *Responses) MarshalYAML() (interface{}, error) {
}
func (r *Responses) MarshalYAMLInline() (interface{}, error) {
+ return r.marshalYAMLInlineWithContext(nil)
+}
+
+// MarshalYAMLInlineWithContext renders responses with a shared inline render context.
+func (r *Responses) MarshalYAMLInlineWithContext(ctx any) (interface{}, error) {
+ return r.marshalYAMLInlineWithContext(ctx)
+}
+
+func (r *Responses) marshalYAMLInlineWithContext(ctx any) (interface{}, error) {
// map keys correctly.
m := utils.CreateEmptyMapNode()
type responseItem struct {
@@ -183,7 +193,11 @@ func (r *Responses) MarshalYAMLInline() (interface{}, error) {
// extract extensions
nb := high.NewNodeBuilder(r, r.low)
nb.Resolve = true
+ nb.RenderContext = ctx
extNode := nb.Render()
+ if err := errors.Join(nb.Errors...); err != nil {
+ return nil, err
+ }
if extNode != nil && extNode.Content != nil {
var label string
for u := range extNode.Content {
@@ -203,7 +217,16 @@ func (r *Responses) MarshalYAMLInline() (interface{}, error) {
})
for _, mp := range mapped {
if mp.resp != nil {
- rendered, _ := mp.resp.MarshalYAMLInline()
+ var rendered interface{}
+ var err error
+ if ctx != nil {
+ rendered, err = mp.resp.MarshalYAMLInlineWithContext(ctx)
+ } else {
+ rendered, err = mp.resp.MarshalYAMLInline()
+ }
+ if err != nil {
+ return nil, fmt.Errorf("failed to render response '%s' inline: %w", mp.code, err)
+ }
kn := utils.CreateStringNode(mp.code)
kn.Style = mp.style
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/low/base/constants.go b/vendor/github.com/pb33f/libopenapi/datamodel/low/base/constants.go
index 078ac9a99..ed20339da 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/low/base/constants.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/low/base/constants.go
@@ -31,6 +31,7 @@ const (
DependentSchemasLabel = "dependentSchemas"
DependentRequiredLabel = "dependentRequired"
PatternPropertiesLabel = "patternProperties"
+ DefsLabel = "$defs"
IfLabel = "if"
ElseLabel = "else"
ThenLabel = "then"
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/low/base/discriminator.go b/vendor/github.com/pb33f/libopenapi/datamodel/low/base/discriminator.go
index 77157492b..936af1471 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/low/base/discriminator.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/low/base/discriminator.go
@@ -4,12 +4,14 @@
package base
import (
+ "fmt"
"hash/maphash"
"go.yaml.in/yaml/v4"
"github.com/pb33f/libopenapi/datamodel/low"
"github.com/pb33f/libopenapi/orderedmap"
+ "github.com/pb33f/libopenapi/utils"
)
// Discriminator is only used by OpenAPI 3+ documents, it represents a polymorphic discriminator used for schemas
@@ -31,6 +33,68 @@ type Discriminator struct {
low.NodeMap
}
+// ValidateDiscriminatorMappingValueNodes checks that discriminator mapping values are scalar strings.
+func ValidateDiscriminatorMappingValueNodes(discriminatorNode *yaml.Node) error {
+ discriminatorNode = utils.NodeAlias(discriminatorNode)
+ if discriminatorNode == nil || discriminatorNode.Kind != yaml.MappingNode {
+ return nil
+ }
+ utils.CheckForMergeNodes(discriminatorNode)
+
+ for i := 0; i < len(discriminatorNode.Content); i += 2 {
+ keyNode := utils.NodeAlias(discriminatorNode.Content[i])
+ if keyNode == nil {
+ continue
+ }
+ if keyNode.Value != "mapping" {
+ continue
+ }
+
+ mappingNode := utils.NodeAlias(discriminatorNode.Content[i+1])
+ if mappingNode == nil || mappingNode.Kind != yaml.MappingNode {
+ return fmt.Errorf("discriminator.mapping must be an object")
+ }
+ utils.CheckForMergeNodes(mappingNode)
+
+ for j := 0; j < len(mappingNode.Content); j += 2 {
+ keyNode := utils.NodeAlias(mappingNode.Content[j])
+ if keyNode == nil {
+ continue
+ }
+ mappingName := keyNode.Value
+ valueNode := utils.NodeAlias(mappingNode.Content[j+1])
+ if valueNode == nil || valueNode.Kind != yaml.ScalarNode || valueNode.Tag != "!!str" {
+ return fmt.Errorf("discriminator.mapping.%s must be a string, found %s", mappingName, describeDiscriminatorMappingNode(valueNode))
+ }
+ }
+ return nil
+ }
+
+ return nil
+}
+
+func describeDiscriminatorMappingNode(node *yaml.Node) string {
+ if node == nil {
+ return "nil"
+ }
+ if node.Kind == yaml.ScalarNode {
+ return node.Tag
+ }
+
+ switch node.Kind {
+ case yaml.MappingNode:
+ return "object"
+ case yaml.SequenceNode:
+ return "array"
+ case yaml.DocumentNode:
+ return "document"
+ case yaml.AliasNode:
+ return "alias"
+ default:
+ return fmt.Sprintf("kind %d", node.Kind)
+ }
+}
+
// GetRootNode will return the root yaml node of the Discriminator object
func (d *Discriminator) GetRootNode() *yaml.Node {
return d.RootNode
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/low/base/property_merger.go b/vendor/github.com/pb33f/libopenapi/datamodel/low/base/property_merger.go
index 1ec44a708..416587f28 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/low/base/property_merger.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/low/base/property_merger.go
@@ -31,10 +31,10 @@ func (pm *PropertyMerger) MergeProperties(localNode, referencedNode *yaml.Node)
return nil, nil
}
if localNode == nil {
- return pm.copyNode(referencedNode), nil
+ return utils.CloneYAMLNode(referencedNode), nil
}
if referencedNode == nil {
- return pm.copyNode(localNode), nil
+ return utils.CloneYAMLNode(localNode), nil
}
// extract properties from both nodes
@@ -42,7 +42,7 @@ func (pm *PropertyMerger) MergeProperties(localNode, referencedNode *yaml.Node)
referencedProps := pm.extractProperties(referencedNode)
// create merged node starting with referenced content
- merged := pm.copyNode(referencedNode)
+ merged := utils.CloneYAMLNode(referencedNode)
mergedProps := pm.extractProperties(merged)
// apply merge strategy for each local property
@@ -101,42 +101,12 @@ func (pm *PropertyMerger) rebuildNodeFromProperties(baseNode *yaml.Node, props m
// rebuild content from properties
for key, value := range props {
keyNode := &yaml.Node{Kind: yaml.ScalarNode, Value: key}
- result.Content = append(result.Content, keyNode, pm.copyNode(value))
+ result.Content = append(result.Content, keyNode, utils.CloneYAMLNode(value))
}
return result
}
-// copyNode creates a deep copy of a yaml node
-func (pm *PropertyMerger) copyNode(node *yaml.Node) *yaml.Node {
- if node == nil {
- return nil
- }
-
- copied := &yaml.Node{
- Kind: node.Kind,
- Style: node.Style,
- Tag: node.Tag,
- Value: node.Value,
- Anchor: node.Anchor,
- Alias: node.Alias,
- Line: node.Line,
- Column: node.Column,
- HeadComment: node.HeadComment,
- LineComment: node.LineComment,
- FootComment: node.FootComment,
- }
-
- if node.Content != nil {
- copied.Content = make([]*yaml.Node, len(node.Content))
- for i, child := range node.Content {
- copied.Content[i] = pm.copyNode(child)
- }
- }
-
- return copied
-}
-
// ShouldMergeProperties determines if property merging should be applied based on configuration
func (pm *PropertyMerger) ShouldMergeProperties(localNode, referencedNode *yaml.Node, config *datamodel.DocumentConfiguration) bool {
if config == nil || !config.MergeReferencedProperties {
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/low/base/schema.go b/vendor/github.com/pb33f/libopenapi/datamodel/low/base/schema.go
index 6f81c0171..4b18f6683 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/low/base/schema.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/low/base/schema.go
@@ -2,8 +2,6 @@ package base
import (
"context"
- "errors"
- "fmt"
"sync"
"github.com/pb33f/libopenapi/datamodel/low"
@@ -90,7 +88,9 @@ type Schema struct {
DependentSchemas low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*SchemaProxy]]]
DependentRequired low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[[]string]]]
- PatternProperties low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*SchemaProxy]]]
+ PatternProperties low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*SchemaProxy]]]
+ // Defs holds reusable JSON Schema definitions declared under the $defs keyword.
+ Defs low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*SchemaProxy]]]
PropertyNames low.NodeReference[*SchemaProxy]
UnevaluatedItems low.NodeReference[*SchemaProxy]
UnevaluatedProperties low.NodeReference[*SchemaDynamicValue[*SchemaProxy, bool]]
@@ -153,81 +153,33 @@ type Schema struct {
// will specifically look for a key node named 'schema' and extract the value mapped to that key. If the operation
// fails then no NodeReference is returned and an error is returned instead.
func ExtractSchema(ctx context.Context, root *yaml.Node, idx *index.SpecIndex) (*low.NodeReference[*SchemaProxy], error) {
- var schLabel, schNode *yaml.Node
errStr := "schema build failed: reference '%s' cannot be found at line %d, col %d"
- refLocation := ""
- var refNode *yaml.Node
-
- foundIndex := idx
- foundCtx := ctx
- if rf, rl, rv := utils.IsNodeRefValue(root); rf {
- // locate reference in index.
- ref, fIdx, err, nCtx := low.LocateRefNodeWithContext(ctx, root, idx)
- if ref != nil {
- schNode = ref
- schLabel = rl
- foundCtx = nCtx
- foundIndex = fIdx
- } else if errors.Is(err, low.ErrExternalRefSkipped) {
- refLocation = rv
- schema := &SchemaProxy{kn: root, vn: root, idx: idx, ctx: ctx}
- _ = schema.Build(ctx, root, root, idx)
- n := &low.NodeReference[*SchemaProxy]{Value: schema, KeyNode: root, ValueNode: root}
- n.SetReference(refLocation, root)
- schema.SetReference(refLocation, root)
- return n, nil
- } else {
- v := root.Content[1].Value
- if root.Content[1].Value == "" {
- v = "[empty]"
- }
- return nil, fmt.Errorf(errStr,
- v, root.Content[1].Line, root.Content[1].Column)
- }
- } else {
- _, schLabel, schNode = utils.FindKeyNodeFull(SchemaLabel, root.Content)
- if schNode != nil {
- h := false
- if h, _, refLocation = utils.IsNodeRefValue(schNode); h {
- ref, fIdx, lerr, nCtx := low.LocateRefNodeWithContext(foundCtx, schNode, foundIndex)
- if ref != nil {
- refNode = schNode
- schNode = ref
- if fIdx != nil {
- foundIndex = fIdx
- }
- foundCtx = nCtx
- } else if errors.Is(lerr, low.ErrExternalRefSkipped) {
- refNode = schNode
- } else {
- v := schNode.Content[1].Value
- if schNode.Content[1].Value == "" {
- v = "[empty]"
- }
- return nil, fmt.Errorf(errStr,
- v, schNode.Content[1].Line, schNode.Content[1].Column)
- }
- }
- }
+ if rf, refLabel, _ := utils.IsNodeRefValue(root); rf {
+ return extractSchemaProxy(ctx, idx, refLabel, root, errStr)
}
+ _, schLabel, schNode := utils.FindKeyNodeFull(SchemaLabel, root.Content)
if schNode != nil {
- // check if schema has already been built.
- schema := &SchemaProxy{kn: schLabel, vn: schNode, idx: foundIndex, ctx: foundCtx}
-
- // call Build to ensure transformation happens
- _ = schema.Build(foundCtx, schLabel, schNode, foundIndex)
+ return extractSchemaProxy(ctx, idx, schLabel, schNode, errStr)
+ }
+ return nil, nil
+}
- schema.SetReference(refLocation, refNode)
+func extractSchemaProxy(ctx context.Context, idx *index.SpecIndex, keyNode, valueNode *yaml.Node, errFormat string) (*low.NodeReference[*SchemaProxy], error) {
+ resolved, err := resolveSchemaBuildInput(ctx, valueNode, idx, errFormat)
+ if err != nil {
+ return nil, err
+ }
- n := &low.NodeReference[*SchemaProxy]{
- Value: schema,
- KeyNode: schLabel,
- ValueNode: schema.vn, // use transformed node
- }
- n.SetReference(refLocation, refNode)
- return n, nil
+ built := buildSchemaProxy(resolved.ctx, resolved.idx, keyNode, resolved.valueNode, resolved.scopeNode, resolved.refNode, resolved.transformed, resolved.refLocation)
+ n := &low.NodeReference[*SchemaProxy]{
+ Value: built.Value,
+ KeyNode: keyNode,
+ ValueNode: built.ValueNode,
}
- return nil, nil
+ if resolved.refLocation != "" {
+ n.SetReference(resolved.refLocation, resolved.refNode)
+ }
+ return n, nil
}
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/low/base/schema_build.go b/vendor/github.com/pb33f/libopenapi/datamodel/low/base/schema_build.go
index 6e944f58f..597763a73 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/low/base/schema_build.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/low/base/schema_build.go
@@ -318,6 +318,9 @@ func (s *Schema) Build(ctx context.Context, root *yaml.Node, idx *index.SpecInde
_, discLabel, discNode := utils.FindKeyNodeFullTop(DiscriminatorLabel, root.Content)
if discNode != nil {
+ if err := ValidateDiscriminatorMappingValueNodes(discNode); err != nil {
+ return err
+ }
var discriminator Discriminator
_ = low.BuildModel(discNode, &discriminator)
discriminator.KeyNode = discLabel
@@ -377,6 +380,14 @@ func (s *Schema) Build(ctx context.Context, root *yaml.Node, idx *index.SpecInde
s.PatternProperties = *props
}
+ props, err = buildPropertyMap(ctx, s, root, idx, DefsLabel)
+ if err != nil {
+ return err
+ }
+ if props != nil {
+ s.Defs = *props
+ }
+
itemsIsBool := false
itemsBoolValue := false
_, itemsLabel, itemsValue := utils.FindKeyNodeFullTop(ItemsLabel, root.Content)
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/low/base/schema_build_helpers.go b/vendor/github.com/pb33f/libopenapi/datamodel/low/base/schema_build_helpers.go
index 661a1c23a..03328453f 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/low/base/schema_build_helpers.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/low/base/schema_build_helpers.go
@@ -19,7 +19,9 @@ type resolvedSchemaBuildInput struct {
ctx context.Context
idx *index.SpecIndex
valueNode *yaml.Node
+ scopeNode *yaml.Node
refNode *yaml.Node
+ transformed *transformedSiblingRef
refLocation string
}
@@ -41,7 +43,7 @@ func buildPropertyMap(ctx context.Context, parent *Schema, root *yaml.Node, idx
propertyMap.Set(low.KeyReference[string]{
KeyNode: currentProp,
Value: currentProp.Value,
- }, buildSchemaProxy(resolved.ctx, resolved.idx, currentProp, resolved.valueNode, resolved.refNode, resolved.refLocation != "", resolved.refLocation))
+ }, buildSchemaProxy(resolved.ctx, resolved.idx, currentProp, resolved.valueNode, resolved.scopeNode, resolved.refNode, resolved.transformed, resolved.refLocation))
}
return &low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*SchemaProxy]]]{
@@ -100,13 +102,9 @@ func (s *Schema) extractExtensions(root *yaml.Node) {
}
// buildSchemaProxy builds out a SchemaProxy for a single node.
-func buildSchemaProxy(ctx context.Context, idx *index.SpecIndex, kn, vn *yaml.Node, rf *yaml.Node, isRef bool, refLocation string) low.ValueReference[*SchemaProxy] {
+func buildSchemaProxy(ctx context.Context, idx *index.SpecIndex, kn, vn, scopeNode, rf *yaml.Node, transformed *transformedSiblingRef, refLocation string) low.ValueReference[*SchemaProxy] {
sp := new(SchemaProxy)
- if isRef {
- sp.prepareForResolvedBuild(ctx, kn, vn, idx, refLocation, rf)
- } else {
- sp.prepareForResolvedBuild(ctx, kn, vn, idx, "", nil)
- }
+ sp.prepareForResolvedBuild(ctx, kn, vn, scopeNode, idx, refLocation, rf, transformed)
return low.ValueReference[*SchemaProxy]{
Value: sp,
ValueNode: sp.vn,
@@ -130,7 +128,7 @@ func buildSchema(ctx context.Context, labelNode, valueNode *yaml.Node, idx *inde
return low.ValueReference[*SchemaProxy]{}, err
}
- return buildSchemaProxy(resolved.ctx, resolved.idx, labelNode, resolved.valueNode, resolved.refNode, resolved.refLocation != "", resolved.refLocation), nil
+ return buildSchemaProxy(resolved.ctx, resolved.idx, labelNode, resolved.valueNode, resolved.scopeNode, resolved.refNode, resolved.transformed, resolved.refLocation), nil
}
// buildSchemaList builds out child schemas for a parent schema. Expected to be an array of schema objects.
@@ -152,7 +150,7 @@ func buildSchemaList(ctx context.Context, labelNode, valueNode *yaml.Node, idx *
if err != nil {
return nil, err
}
- r := buildSchemaProxy(resolved.ctx, resolved.idx, resolved.valueNode, resolved.valueNode, resolved.refNode, resolved.refLocation != "", resolved.refLocation)
+ r := buildSchemaProxy(resolved.ctx, resolved.idx, resolved.valueNode, resolved.valueNode, resolved.scopeNode, resolved.refNode, resolved.transformed, resolved.refLocation)
results = append(results, r)
}
@@ -190,17 +188,25 @@ func resolveSchemaBuildInput(ctx context.Context, valueNode *yaml.Node, idx *ind
ctx: ctx,
idx: idx,
valueNode: valueNode,
+ scopeNode: valueNode,
}
if valueNode == nil {
return resolved, nil
}
+ if transformedValue, transformedRef, wasTransformed := transformSiblingRefNode(valueNode, idx); wasTransformed {
+ resolved.valueNode = transformedValue
+ resolved.transformed = transformedRef
+ return resolved, nil
+ }
+
if hasRef, _, refLocation := utils.IsNodeRefValue(valueNode); hasRef {
ref, foundIdx, err, foundCtx := low.LocateRefNodeWithContext(ctx, valueNode, idx)
if ref != nil {
resolved.refNode = valueNode
resolved.valueNode = ref
+ resolved.scopeNode = ref
resolved.refLocation = refLocation
resolved.ctx = foundCtx
resolved.idx = foundIdx
@@ -211,8 +217,16 @@ func resolveSchemaBuildInput(ctx context.Context, valueNode *yaml.Node, idx *ind
resolved.refLocation = refLocation
return resolved, nil
}
- return resolved, fmt.Errorf(errFormat, valueNode.Content[1].Value, valueNode.Content[1].Line, valueNode.Content[1].Column)
+ return resolved, schemaReferenceBuildError(errFormat, valueNode)
}
return resolved, nil
}
+
+func schemaReferenceBuildError(errFormat string, valueNode *yaml.Node) error {
+ refValue := valueNode.Content[1].Value
+ if refValue == "" {
+ refValue = "[empty]"
+ }
+ return fmt.Errorf(errFormat, refValue, valueNode.Content[1].Line, valueNode.Content[1].Column)
+}
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/low/base/schema_hash.go b/vendor/github.com/pb33f/libopenapi/datamodel/low/base/schema_hash.go
index f091e54ca..34064b2c7 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/low/base/schema_hash.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/low/base/schema_hash.go
@@ -324,6 +324,8 @@ func (s *Schema) hash(quick bool) uint64 {
writeSchemaMapHashes(sb, s.PatternProperties.Value)
+ writeSchemaMapHashes(sb, s.Defs.Value)
+
if len(s.PrefixItems.Value) > 0 {
scratch = resizeSchemaHashScratch(scratch, len(s.PrefixItems.Value))
for i := range s.PrefixItems.Value {
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/low/base/schema_proxy.go b/vendor/github.com/pb33f/libopenapi/datamodel/low/base/schema_proxy.go
index 1f3d76733..17f1fbeda 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/low/base/schema_proxy.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/low/base/schema_proxy.go
@@ -70,6 +70,7 @@ type SchemaProxy struct {
nodeStore sync.Map
nodeMap low.NodeMap
TransformedRef *yaml.Node // Original node that contained the ref before transformation
+ transformedRef *transformedSiblingRef
*low.NodeMap
}
@@ -85,18 +86,9 @@ func (sp *SchemaProxy) Build(ctx context.Context, key, value *yaml.Node, idx *in
// transform sibling refs to allOf structure if enabled and applicable
// this ensures sp.vn contains the pre-transformed YAML as the source of truth
- transformedValue := value
- wasTransformed := false
- if idx != nil && idx.GetConfig() != nil && idx.GetConfig().TransformSiblingRefs {
- transformer := NewSiblingRefTransformer(idx)
- if transformer.ShouldTransform(value) {
- transformed, _ := transformer.TransformSiblingRef(value)
- if transformed != nil {
- transformedValue = transformed
- wasTransformed = true
- sp.TransformedRef = value // store original node that had the ref
- }
- }
+ transformedValue, transformedRef, wasTransformed := transformSiblingRefNode(value, idx)
+ if wasTransformed {
+ sp.setTransformedRef(transformedRef)
}
sp.vn = transformedValue
@@ -117,14 +109,27 @@ func (sp *SchemaProxy) Build(ctx context.Context, key, value *yaml.Node, idx *in
return nil
}
+func transformSiblingRefNode(value *yaml.Node, idx *index.SpecIndex) (*yaml.Node, *transformedSiblingRef, bool) {
+ if idx == nil || idx.GetConfig() == nil || !idx.GetConfig().TransformSiblingRefs {
+ return value, nil, false
+ }
+ transformer := NewSiblingRefTransformer(idx)
+ transformed := transformer.transformSiblingRefWithMetadata(value)
+ if transformed == nil {
+ return value, nil, false
+ }
+ return transformed.allOfNode, transformed, true
+}
+
// prepareForResolvedBuild initializes proxy state when the caller has already resolved any reference metadata.
// This avoids re-running the full Build ref-detection path for child-schema helpers that already did that work.
-func (sp *SchemaProxy) prepareForResolvedBuild(ctx context.Context, key, value *yaml.Node, idx *index.SpecIndex, refLocation string, refNode *yaml.Node) {
+func (sp *SchemaProxy) prepareForResolvedBuild(ctx context.Context, key, value, scopeNode *yaml.Node, idx *index.SpecIndex, refLocation string, refNode *yaml.Node, transformed *transformedSiblingRef) {
sp.kn = key
sp.idx = idx
sp.vn = value
- sp.ctx = applySchemaIdScope(ctx, value, idx)
+ sp.ctx = applySchemaIdScope(ctx, scopeNode, idx)
sp.Reference = low.Reference{}
+ sp.setTransformedRef(transformed)
if refLocation != "" {
sp.SetReference(refLocation, refNode)
}
@@ -133,6 +138,47 @@ func (sp *SchemaProxy) prepareForResolvedBuild(ctx context.Context, key, value *
sp.NodeMap = &sp.nodeMap
}
+func (sp *SchemaProxy) setTransformedRef(transformed *transformedSiblingRef) {
+ sp.transformedRef = transformed
+ sp.TransformedRef = nil
+ if transformed != nil {
+ sp.TransformedRef = transformed.referenceNode
+ }
+}
+
+// IsTransformedRefWithSiblings reports whether this proxy was authored as a
+// schema-level $ref with sibling keywords and internally normalized to allOf.
+func (sp *SchemaProxy) IsTransformedRefWithSiblings() bool {
+ return sp != nil && sp.transformedRef != nil && sp.transformedRef.reference != ""
+}
+
+// GetTransformedRefSiblingSchema returns the sibling-only schema for an
+// internally transformed $ref-with-siblings node.
+func (sp *SchemaProxy) GetTransformedRefSiblingSchema() *yaml.Node {
+ if !sp.IsTransformedRefWithSiblings() {
+ return nil
+ }
+ return sp.transformedRef.siblingNode
+}
+
+// GetTransformedRefReference returns the original reference value for an
+// internally transformed $ref-with-siblings node.
+func (sp *SchemaProxy) GetTransformedRefReference() string {
+ if !sp.IsTransformedRefWithSiblings() {
+ return ""
+ }
+ return sp.transformedRef.reference
+}
+
+// GetTransformedRefAllOfSchema returns the internal allOf schema for an
+// authored $ref-with-siblings node.
+func (sp *SchemaProxy) GetTransformedRefAllOfSchema() *yaml.Node {
+ if !sp.IsTransformedRefWithSiblings() {
+ return nil
+ }
+ return sp.transformedRef.allOfNode
+}
+
func applySchemaIdScope(ctx context.Context, node *yaml.Node, idx *index.SpecIndex) context.Context {
if node == nil {
return ctx
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/low/base/sibling_ref_transformer.go b/vendor/github.com/pb33f/libopenapi/datamodel/low/base/sibling_ref_transformer.go
index 5173becd8..3cebab2fe 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/low/base/sibling_ref_transformer.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/low/base/sibling_ref_transformer.go
@@ -4,6 +4,8 @@
package base
import (
+ "sort"
+
"github.com/pb33f/libopenapi/index"
"github.com/pb33f/libopenapi/utils"
"go.yaml.in/yaml/v4"
@@ -15,6 +17,13 @@ type SiblingRefTransformer struct {
index *index.SpecIndex
}
+type transformedSiblingRef struct {
+ allOfNode *yaml.Node
+ siblingNode *yaml.Node
+ referenceNode *yaml.Node
+ reference string
+}
+
// NewSiblingRefTransformer creates a new transformer instance
func NewSiblingRefTransformer(idx *index.SpecIndex) *SiblingRefTransformer {
return &SiblingRefTransformer{
@@ -28,17 +37,51 @@ func NewSiblingRefTransformer(idx *index.SpecIndex) *SiblingRefTransformer {
// Input: {title: "MySchema", $ref: "#/components/schemas/Base"}
// Output: {allOf: [{title: "MySchema"}, {$ref: "#/components/schemas/Base"}]}
func (srt *SiblingRefTransformer) TransformSiblingRef(node *yaml.Node) (*yaml.Node, error) {
- if !srt.ShouldTransform(node) {
+ transformed := srt.transformSiblingRefWithMetadata(node)
+ if transformed == nil {
return node, nil // no transformation needed
}
+ return transformed.allOfNode, nil
+}
+func (srt *SiblingRefTransformer) transformSiblingRefWithMetadata(node *yaml.Node) *transformedSiblingRef {
+ if srt.index == nil || srt.index.GetConfig() == nil || !srt.index.GetConfig().TransformSiblingRefs {
+ return nil
+ }
siblings, refValue := srt.ExtractSiblingProperties(node)
- return srt.CreateAllOfStructure(refValue, siblings), nil
+ if len(siblings) == 0 || refValue == "" {
+ return nil
+ }
+ siblingNode := srt.createSiblingSchemaNode(node)
+ return &transformedSiblingRef{
+ allOfNode: srt.createAllOfStructureWithSiblingNode(refValue, siblingNode),
+ siblingNode: siblingNode,
+ referenceNode: node,
+ reference: refValue,
+ }
}
// CreateAllOfStructure creates an allOf node structure from ref value and sibling properties
func (srt *SiblingRefTransformer) CreateAllOfStructure(refValue string, siblings map[string]*yaml.Node) *yaml.Node {
+ var siblingSchemaNode *yaml.Node
+ if len(siblings) > 0 {
+ siblingSchemaNode = &yaml.Node{Kind: yaml.MappingNode, Tag: "!!map"}
+ keys := make([]string, 0, len(siblings))
+ for key := range siblings {
+ keys = append(keys, key)
+ }
+ sort.Strings(keys)
+ for _, key := range keys {
+ valueNode := siblings[key]
+ keyNode := &yaml.Node{Kind: yaml.ScalarNode, Tag: "!!str", Value: key}
+ copiedValueNode := utils.CloneYAMLNode(valueNode)
+ siblingSchemaNode.Content = append(siblingSchemaNode.Content, keyNode, copiedValueNode)
+ }
+ }
+ return srt.createAllOfStructureWithSiblingNode(refValue, siblingSchemaNode)
+}
+func (srt *SiblingRefTransformer) createAllOfStructureWithSiblingNode(refValue string, siblingSchemaNode *yaml.Node) *yaml.Node {
allOfNode := &yaml.Node{
Kind: yaml.MappingNode,
Tag: "!!map",
@@ -50,19 +93,10 @@ func (srt *SiblingRefTransformer) CreateAllOfStructure(refValue string, siblings
allOfArrayNode := allOfNode.Content[1]
- // first element: schema with sibling properties (excluding $ref)
- if len(siblings) > 0 {
- siblingSchemaNode := &yaml.Node{Kind: yaml.MappingNode, Tag: "!!map"}
- for key, valueNode := range siblings {
- keyNode := &yaml.Node{Kind: yaml.ScalarNode, Tag: "!!str", Value: key}
- // create a copy of the value node to avoid modifying original
- copiedValueNode := srt.copyNode(valueNode)
- siblingSchemaNode.Content = append(siblingSchemaNode.Content, keyNode, copiedValueNode)
- }
+ if siblingSchemaNode != nil && len(siblingSchemaNode.Content) > 0 {
allOfArrayNode.Content = append(allOfArrayNode.Content, siblingSchemaNode)
}
- // second element: the reference schema
refSchemaNode := &yaml.Node{
Kind: yaml.MappingNode,
Tag: "!!map",
@@ -76,6 +110,22 @@ func (srt *SiblingRefTransformer) CreateAllOfStructure(refValue string, siblings
return allOfNode
}
+func (srt *SiblingRefTransformer) createSiblingSchemaNode(node *yaml.Node) *yaml.Node {
+ if !utils.IsNodeMap(node) {
+ return nil
+ }
+ siblingNode := &yaml.Node{Kind: yaml.MappingNode, Tag: "!!map"}
+ for i := 0; i+1 < len(node.Content); i += 2 {
+ keyNode := node.Content[i]
+ valueNode := node.Content[i+1]
+ if keyNode == nil || keyNode.Value == "$ref" {
+ continue
+ }
+ siblingNode.Content = append(siblingNode.Content, utils.CloneYAMLNode(keyNode), utils.CloneYAMLNode(valueNode))
+ }
+ return siblingNode
+}
+
// ExtractSiblingProperties extracts sibling properties from a node containing $ref
// returns a map of sibling properties and the $ref value
func (srt *SiblingRefTransformer) ExtractSiblingProperties(node *yaml.Node) (map[string]*yaml.Node, string) {
@@ -121,33 +171,3 @@ func (srt *SiblingRefTransformer) ShouldTransform(node *yaml.Node) bool {
siblings, refValue := srt.ExtractSiblingProperties(node)
return len(siblings) > 0 && refValue != ""
}
-
-// copyNode creates a deep copy of a yaml node to avoid modifying the original
-func (srt *SiblingRefTransformer) copyNode(node *yaml.Node) *yaml.Node {
- if node == nil {
- return nil
- }
-
- copied := &yaml.Node{
- Kind: node.Kind,
- Style: node.Style,
- Tag: node.Tag,
- Value: node.Value,
- Anchor: node.Anchor,
- Alias: node.Alias,
- Line: node.Line,
- Column: node.Column,
- HeadComment: node.HeadComment,
- LineComment: node.LineComment,
- FootComment: node.FootComment,
- }
-
- if node.Content != nil {
- copied.Content = make([]*yaml.Node, len(node.Content))
- for i, child := range node.Content {
- copied.Content[i] = srt.copyNode(child)
- }
- }
-
- return copied
-}
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/low/extraction_functions.go b/vendor/github.com/pb33f/libopenapi/datamodel/low/extraction_functions.go
index f8f86d030..222aeec47 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/low/extraction_functions.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/low/extraction_functions.go
@@ -1100,13 +1100,17 @@ func ExtractExtensions(root *yaml.Node) *orderedmap.Map[KeyReference[string], Va
if root == nil {
return nil
}
- extensions := utils.FindExtensionNodes(root.Content)
extensionMap := orderedmap.New[KeyReference[string], ValueReference[*yaml.Node]]()
- for _, ext := range extensions {
- extensionMap.Set(KeyReference[string]{
- Value: ext.Key.Value,
- KeyNode: ext.Key,
- }, ValueReference[*yaml.Node]{Value: ext.Value, ValueNode: ext.Value})
+ content := root.Content
+ for i := 0; i+1 < len(content); i += 2 {
+ key := content[i]
+ if strings.HasPrefix(key.Value, "x-") {
+ value := utils.NodeAlias(content[i+1])
+ extensionMap.Set(KeyReference[string]{
+ Value: key.Value,
+ KeyNode: key,
+ }, ValueReference[*yaml.Node]{Value: value, ValueNode: value})
+ }
}
return extensionMap
}
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/low/model_builder.go b/vendor/github.com/pb33f/libopenapi/datamodel/low/model_builder.go
index 4cebe9057..7b721b8f7 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/low/model_builder.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/low/model_builder.go
@@ -9,6 +9,7 @@ import (
"strconv"
"strings"
"sync"
+ "unicode/utf8"
"github.com/pb33f/libopenapi/orderedmap"
"github.com/pb33f/libopenapi/utils"
@@ -48,6 +49,19 @@ func buildModelFields(modelType reflect.Type) []buildModelField {
return actual.([]buildModelField)
}
+// lowerIfNeeded returns the input unchanged when it contains no uppercase ASCII and no
+// multibyte runes (the overwhelmingly common case for OpenAPI keys), avoiding the
+// per-key allocation of strings.ToLower on the BuildModel hot path.
+func lowerIfNeeded(s string) string {
+ for i := 0; i < len(s); i++ {
+ c := s[i]
+ if c >= utf8.RuneSelf || ('A' <= c && c <= 'Z') {
+ return strings.ToLower(s)
+ }
+ }
+ return s
+}
+
// BuildModel accepts a yaml.Node pointer and a model, which can be any struct. Using reflection, the model is
// analyzed and the names of all the properties are extracted from the model and subsequently looked up from within
// the yaml.Node.Content value.
@@ -70,7 +84,7 @@ func BuildModel(node *yaml.Node, model interface{}) error {
content := node.Content
keyMap := make(map[string]int, len(content)/2)
for j := 0; j < len(content)-1; j += 2 {
- k := strings.ToLower(utils.NodeAlias(content[j]).Value)
+ k := lowerIfNeeded(utils.NodeAlias(content[j]).Value)
if _, exists := keyMap[k]; !exists {
keyMap[k] = j
}
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/low/v2/swagger.go b/vendor/github.com/pb33f/libopenapi/datamodel/low/v2/swagger.go
index 6d079cb9b..7e5211b0a 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/low/v2/swagger.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/low/v2/swagger.go
@@ -152,6 +152,7 @@ func createDocument(info *datamodel.SpecInfo, config *datamodel.DocumentConfigur
idxConfig.BasePath = config.BasePath
idxConfig.Logger = config.Logger
idxConfig.ExcludeExtensionRefs = config.ExcludeExtensionRefs
+ idxConfig.SkipMetadataCollection = config.SkipMetadataCollection
rolodex := index.NewRolodex(idxConfig)
rolodex.SetRootNode(info.RootNode)
doc.Rolodex = rolodex
@@ -195,8 +196,8 @@ func createDocument(info *datamodel.SpecInfo, config *datamodel.DocumentConfigur
}
}
- // if base url is provided, add a remote filesystem to the rolodex.
- if idxConfig.BaseURL != nil {
+ // Only create a remote filesystem when the caller explicitly allows remote references.
+ if config.AllowRemoteReferences {
// create a remote filesystem
remoteFS, _ := index.NewRemoteFSWithConfig(idxConfig)
@@ -206,7 +207,11 @@ func createDocument(info *datamodel.SpecInfo, config *datamodel.DocumentConfigur
idxConfig.AllowRemoteLookup = true
// add to the rolodex
- rolodex.AddRemoteFS(config.BaseURL.String(), remoteFS)
+ u := "default"
+ if config.BaseURL != nil {
+ u = config.BaseURL.String()
+ }
+ rolodex.AddRemoteFS(u, remoteFS)
}
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/low/v3/components.go b/vendor/github.com/pb33f/libopenapi/datamodel/low/v3/components.go
index 2f792c2d4..ce6dbdb06 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/low/v3/components.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/low/v3/components.go
@@ -5,6 +5,7 @@ package v3
import (
"context"
+ "errors"
"fmt"
"hash/maphash"
"reflect"
@@ -50,6 +51,7 @@ type Components struct {
type componentBuildResult[T any] struct {
key low.KeyReference[string]
value low.ValueReference[T]
+ err error
}
type componentInput struct {
@@ -302,14 +304,55 @@ func extractComponentValues[T low.Buildable[N], N any](ctx context.Context, labe
translateFunc := func(_ int, value componentInput) (componentBuildResult[T], error) {
var n T = new(N)
currentLabel := value.currentLabel
- node := value.node
+ node := utils.NodeAlias(value.node)
+ foundIndex := idx
+ foundContext := ctx
+ var localCircErr error
+ var refNode *yaml.Node
+ var referenceValue string
+ _, isSchemaProxy := any(n).(*base.SchemaProxy)
+
+ if h, _, rv := utils.IsNodeRefValue(node); h && rv != "" && !isSchemaProxy && foundIndex != nil {
+ ref, fIdx, err, nCtx := low.LocateRefNodeWithContext(foundContext, node, foundIndex)
+ if ref != nil {
+ refNode = node
+ node = ref
+ referenceValue = rv
+ if fIdx != nil {
+ foundIndex = fIdx
+ }
+ foundContext = nCtx
+ if err != nil {
+ localCircErr = err
+ }
+ } else if errors.Is(err, low.ErrExternalRefSkipped) {
+ low.SetReference(n, rv, node)
+ v := low.ValueReference[T]{
+ Value: n,
+ ValueNode: node,
+ }
+ v.SetReference(rv, node)
+ return componentBuildResult[T]{
+ key: low.KeyReference[string]{
+ KeyNode: currentLabel,
+ Value: currentLabel.Value,
+ },
+ value: v,
+ }, nil
+ } else if err != nil {
+ return componentBuildResult[T]{}, fmt.Errorf("component build failed: reference cannot be found: %s", err.Error())
+ }
+ }
// build.
_ = low.BuildModel(node, n)
- err := n.Build(ctx, currentLabel, node, idx)
+ err := n.Build(foundContext, currentLabel, node, foundIndex)
if err != nil {
return componentBuildResult[T]{}, err
}
+ if referenceValue != "" {
+ low.SetReference(n, referenceValue, refNode)
+ }
nType := reflect.TypeOf(n)
nValue := reflect.ValueOf(n)
@@ -333,18 +376,27 @@ func extractComponentValues[T low.Buildable[N], N any](ctx context.Context, labe
}
}
+ valueRef := low.ValueReference[T]{
+ Value: n,
+ ValueNode: finalValueNode, // use transformed node if available
+ }
+ if referenceValue != "" {
+ valueRef.SetReference(referenceValue, refNode)
+ }
return componentBuildResult[T]{
key: low.KeyReference[string]{
KeyNode: currentLabel,
Value: currentLabel.Value,
},
- value: low.ValueReference[T]{
- Value: n,
- ValueNode: finalValueNode, // use transformed node if available
- },
+ value: valueRef,
+ err: localCircErr,
}, nil
}
+ var circError error
err := datamodel.TranslateSliceParallel(inputs, translateFunc, func(result componentBuildResult[T]) error {
+ if result.err != nil {
+ circError = result.err
+ }
componentValues.Set(result.key, result.value)
return nil
})
@@ -357,5 +409,8 @@ func extractComponentValues[T low.Buildable[N], N any](ctx context.Context, labe
ValueNode: nodeValue,
Value: componentValues,
}
+ if circError != nil && (idx == nil || !idx.AllowCircularReferenceResolving()) {
+ return results, circError
+ }
return results, nil
}
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/low/v3/create_document.go b/vendor/github.com/pb33f/libopenapi/datamodel/low/v3/create_document.go
index 6d037846a..90e228eb3 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/low/v3/create_document.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/low/v3/create_document.go
@@ -151,6 +151,7 @@ func createDocument(info *datamodel.SpecInfo, config *datamodel.DocumentConfigur
idxConfig.SpecInfo = info
idxConfig.UseSchemaQuickHash = config.UseSchemaQuickHash
idxConfig.ExcludeExtensionRefs = config.ExcludeExtensionRefs
+ idxConfig.SkipMetadataCollection = config.SkipMetadataCollection
idxConfig.IgnoreArrayCircularReferences = config.IgnoreArrayCircularReferences
idxConfig.IgnorePolymorphicCircularReferences = config.IgnorePolymorphicCircularReferences
idxConfig.AllowUnknownExtensionContentDetection = config.AllowUnknownExtensionContentDetection
@@ -247,8 +248,8 @@ func createDocument(info *datamodel.SpecInfo, config *datamodel.DocumentConfigur
rolodex.AddLocalFS(cwd, fileFS)
}
}
- // if base url is provided, add a remote filesystem to the rolodex.
- if idxConfig.BaseURL != nil || config.AllowRemoteReferences {
+ // Only create a remote filesystem when the caller explicitly allows remote references.
+ if config.AllowRemoteReferences {
// create a remote filesystem
remoteFS, _ := index.NewRemoteFSWithConfig(idxConfig)
@@ -483,6 +484,11 @@ func extractPaths(ctx context.Context, root *yaml.Node, nodes documentTopLevelNo
}
func extractWebhooks(ctx context.Context, root *yaml.Node, nodes documentTopLevelNodes, doc *Document, idx *index.SpecIndex) error {
+ // without a genuine top-level key, ExtractMap can match a same-named scalar
+ // (e.g. "webhooks" in an extension value) and create an empty webhooks map.
+ if nodes.webhooks.value == nil {
+ return nil
+ }
hooks, hooksL, hooksN, err := low.ExtractMap[*PathItem](ctx, WebhooksLabel, root, idx)
if err != nil {
return err
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/spec_info.go b/vendor/github.com/pb33f/libopenapi/datamodel/spec_info.go
index f5200f042..ab947fd04 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/spec_info.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/spec_info.go
@@ -9,7 +9,10 @@ import (
"errors"
"fmt"
"strings"
+ "sync"
"time"
+ "unicode/utf16"
+ "unicode/utf8"
"github.com/pb33f/libopenapi/utils"
"go.yaml.in/yaml/v4"
@@ -23,24 +26,105 @@ const (
// SpecInfo represents a 'ready-to-process' OpenAPI Document. The RootNode is the most important property
// used by the library, this contains the top of the document tree that every single low model is based off.
type SpecInfo struct {
- SpecType string `json:"type"`
- NumLines int `json:"numLines"`
- Version string `json:"version"`
- VersionNumeric float32 `json:"versionNumeric"`
- SpecFormat string `json:"format"`
- SpecFileType string `json:"fileType"`
- SpecBytes *[]byte `json:"bytes"` // the original byte array
- RootNode *yaml.Node `json:"-"` // reference to the root node of the spec.
- SpecJSONBytes *[]byte `json:"-"` // original bytes converted to JSON
- SpecJSON *map[string]interface{} `json:"-"` // standard JSON map of original bytes
- Error error `json:"-"` // something go wrong?
- APISchema string `json:"-"` // API Schema for supplied spec type (2 or 3)
- Generated time.Time `json:"-"`
- OriginalIndentation int `json:"-"` // the original whitespace
- Self string `json:"-"` // the $self field for OpenAPI 3.2+ documents (base URI)
+ SpecType string `json:"type"`
+ NumLines int `json:"numLines"`
+ Version string `json:"version"`
+ VersionNumeric float32 `json:"versionNumeric"`
+ SpecFormat string `json:"format"`
+ SpecFileType string `json:"fileType"`
+ SpecBytes *[]byte `json:"bytes"` // the original byte array
+ RootNode *yaml.Node `json:"-"` // reference to the root node of the spec.
+
+ // SpecJSONBytes is the original document converted to JSON. It is populated lazily.
+ //
+ // Deprecated: read via GetSpecJSONBytes(), which builds the JSON representation on
+ // first use. This field is nil until GetSpecJSON or GetSpecJSONBytes is called.
+ // Concurrent readers must use the accessors: a direct field read racing the first
+ // accessor call is a data race.
+ SpecJSONBytes *[]byte `json:"-"`
+
+ // SpecJSON is the original document as a standard JSON map. It is populated lazily.
+ //
+ // Deprecated: read via GetSpecJSON(), which builds the JSON representation on
+ // first use. This field is nil until GetSpecJSON or GetSpecJSONBytes is called.
+ // Concurrent readers must use the accessors: a direct field read racing the first
+ // accessor call is a data race.
+ SpecJSON *map[string]interface{} `json:"-"`
+
+ Error error `json:"-"` // something go wrong?
+ APISchema string `json:"-"` // API Schema for supplied spec type (2 or 3)
+ Generated time.Time `json:"-"`
+ OriginalIndentation int `json:"-"` // the original whitespace
+ Self string `json:"-"` // the $self field for OpenAPI 3.2+ documents (base URI)
+
+ jsonOnce sync.Once // guards the lazy JSON build
+ jsonErr error // error from the lazy JSON build, if any
+ skipJSONBuild bool // set by SkipJSONConversion: accessors return nil, preserving the flag's contract
+}
+
+// GetSpecJSON returns the document as a standard JSON map, building it on first call.
+// Returns nil if the document cannot be converted, or if the SpecInfo has been
+// released (the node tree and original bytes are required to build the JSON view).
+func (s *SpecInfo) GetSpecJSON() *map[string]interface{} {
+ s.jsonOnce.Do(s.buildJSON)
+ return s.SpecJSON
+}
+
+// GetSpecJSONBytes returns the document converted to JSON bytes, building the
+// representation on first call. Returns nil if the document cannot be converted, or
+// if the SpecInfo has been released.
+func (s *SpecInfo) GetSpecJSONBytes() *[]byte {
+ s.jsonOnce.Do(s.buildJSON)
+ return s.SpecJSONBytes
+}
+
+// GetSpecJSONError returns the error from building the JSON view, building it first
+// if needed. It distinguishes a failed conversion (non-nil error) from a released
+// SpecInfo (nil error, nil JSON: there is nothing left to build, so nothing failed).
+func (s *SpecInfo) GetSpecJSONError() error {
+ s.jsonOnce.Do(s.buildJSON)
+ return s.jsonErr
+}
+
+// buildJSON populates SpecJSON and SpecJSONBytes from the parsed node tree (YAML) or
+// the original bytes (JSON). This is the same conversion the library used to perform
+// eagerly on every parse; it now runs only when the JSON view is requested.
+func (s *SpecInfo) buildJSON() {
+ if s.skipJSONBuild {
+ return
+ }
+ var jsonSpec map[string]interface{}
+ if s.SpecFileType == YAMLFileType {
+ if s.RootNode == nil {
+ return
+ }
+ if err := s.RootNode.Decode(&jsonSpec); err != nil {
+ s.jsonErr = fmt.Errorf("failed to decode YAML to JSON: %w", err)
+ return
+ }
+ // Marshal to JSON - if this fails due to unsupported types (e.g. map[interface{}]interface{}),
+ // we tolerate it as it doesn't indicate spec invalidity, just YAML/JSON incompatibility
+ b, err := json.Marshal(&jsonSpec)
+ if err == nil {
+ s.SpecJSONBytes = &b
+ }
+ s.SpecJSON = &jsonSpec
+ return
+ }
+ if s.SpecBytes == nil {
+ return
+ }
+ if err := json.Unmarshal(*s.SpecBytes, &jsonSpec); err != nil {
+ s.jsonErr = fmt.Errorf("failed to unmarshal JSON: %w", err)
+ return
+ }
+ s.SpecJSONBytes = s.SpecBytes
+ s.SpecJSON = &jsonSpec
}
// Release nils fields that pin the YAML node tree and large byte arrays in memory.
+// After release, GetSpecJSON and GetSpecJSONBytes return nil: the inputs needed to
+// build the JSON view are gone and will not be resurrected.
func (s *SpecInfo) Release() {
if s == nil {
return
@@ -79,7 +163,7 @@ func ExtractSpecInfoWithDocumentCheck(spec []byte, bypass bool) (*SpecInfo, erro
func extractSpecInfoInternal(spec []byte, bypass bool, skipJSON bool) (*SpecInfo, error) {
var parsedSpec yaml.Node
- specInfo := &SpecInfo{}
+ specInfo := &SpecInfo{skipJSONBuild: skipJSON}
// set original bytes
specInfo.SpecBytes = &spec
@@ -97,12 +181,11 @@ func extractSpecInfoInternal(spec []byte, bypass bool, skipJSON bool) (*SpecInfo
specInfo.NumLines = bytes.Count(spec, []byte{'\n'}) + 1
- // Pre-process JSON to handle \/ escape sequences that YAML parser doesn't recognize.
- // JSON (RFC 8259) allows \/ as an optional escape for forward slash, but YAML does not.
- // See: https://github.com/pb33f/libopenapi/issues/479
+ // Pre-process JSON escapes that YAML parsers do not accept even though
+ // they are valid JSON, while preserving the existing YAML-node parse path.
parseBytes := spec
if specInfo.SpecFileType == JSONFileType {
- parseBytes = unescapeJSONSlashes(spec)
+ parseBytes = normalizeJSONForYAMLParser(spec)
}
err := yaml.Unmarshal(parseBytes, &parsedSpec)
@@ -131,28 +214,41 @@ func extractSpecInfoInternal(spec []byte, bypass bool, skipJSON bool) (*SpecInfo
_, openAPI2 := utils.FindKeyNode(utils.OpenApi2, parsedSpec.Content)
_, asyncAPI := utils.FindKeyNode(utils.AsyncApi, parsedSpec.Content)
+ // validate document structure without building the JSON view: the root must be a
+ // mapping, YAML mappings must not contain duplicate keys (matching the yaml
+ // decoder's checks), and JSON input must be syntactically valid. The full JSON
+ // conversion is built lazily by GetSpecJSON/GetSpecJSONBytes.
parseJSON := func(bytes []byte, spec *SpecInfo, parsedNode *yaml.Node) error {
- var jsonSpec map[string]interface{}
if spec.SpecFileType == YAMLFileType {
- // Decode YAML to map - this is critical to catch structural errors like duplicate keys
- if err := parsedNode.Decode(&jsonSpec); err != nil {
- return fmt.Errorf("failed to decode YAML to JSON: %w", err)
+ root := parsedNode
+ if root.Kind == yaml.DocumentNode && len(root.Content) > 0 {
+ root = root.Content[0]
}
- // Marshal to JSON - if this fails due to unsupported types (e.g. map[interface{}]interface{}),
- // we tolerate it as it doesn't indicate spec invalidity, just YAML/JSON incompatibility
- b, err := json.Marshal(&jsonSpec)
- if err == nil {
- spec.SpecJSONBytes = &b
+ if root.Kind != yaml.MappingNode && root.Tag != "!!null" {
+ // the document cannot construct into a map: run the decoder purely to
+ // surface its exact construct error (garbage input is the rare path).
+ var jsonSpec map[string]interface{}
+ if err := parsedNode.Decode(&jsonSpec); err != nil {
+ return fmt.Errorf("failed to decode YAML to JSON: %w", err)
+ }
+ if jsonSpec == nil {
+ return fmt.Errorf("failed to decode YAML to JSON: YAML document root is %v, not a mapping", root.Kind)
+ }
}
- spec.SpecJSON = &jsonSpec
- } else {
- if err := json.Unmarshal(bytes, &jsonSpec); err != nil {
- return fmt.Errorf("failed to unmarshal JSON: %w", err)
+ if err := checkDuplicateMappingKeys(parsedNode); err != nil {
+ return fmt.Errorf("failed to decode YAML to JSON: %w", err)
}
- spec.SpecJSONBytes = &bytes
- spec.SpecJSON = &jsonSpec
+ return nil
}
- return nil
+ if json.Valid(bytes) {
+ return nil
+ }
+ // invalid JSON is the rare path: run the decoder purely to surface the same
+ // detailed error message the eager conversion produced. json.Valid and
+ // json.Unmarshal share the same scanner, so the decode always errors here.
+ var jsonSpec map[string]interface{}
+ err := json.Unmarshal(bytes, &jsonSpec)
+ return fmt.Errorf("failed to unmarshal JSON: %w", err)
}
// if !bypass {
@@ -294,10 +390,8 @@ func extractSpecInfoInternal(spec []byte, bypass bool, skipJSON bool) (*SpecInfo
// parseJSON(spec, specInfo, &parsedSpec)
//}
- if !parsed && !skipJSON {
- if err := parseJSON(spec, specInfo, &parsedSpec); err != nil && !bypass {
- return nil, err
- }
+ if !parsed && !skipJSON && bypass {
+ _ = parseJSON(spec, specInfo, &parsedSpec)
}
// detect the original whitespace indentation
@@ -315,6 +409,58 @@ func ExtractSpecInfo(spec []byte) (*SpecInfo, error) {
return ExtractSpecInfoWithDocumentCheck(spec, false)
}
+// checkDuplicateMappingKeys walks a parsed node tree and reports duplicate mapping
+// keys using the exact equality semantics of the go.yaml.in/yaml/v4 decoder: two keys
+// in the same mapping collide when their node Kind and raw Value match (no tag or
+// alias resolution). The collected construct errors are normalized onto the
+// public one-line error shape, and children of an offending mapping are not
+// descended into, mirroring the decoder halting construction of that mapping.
+//
+// Known divergence: an anchored mapping with duplicate keys that is aliased
+// elsewhere is reported ONCE here, while the decoder re-reports it on every
+// construction visit (anchor + each alias). The decoder's repeat count is an
+// artifact of construction order, not extra information, so the walker does
+// not replicate it. TestCheckDuplicateMappingKeys_MatchesDecoder pins parity
+// for everything else (and TestCheckDuplicateMappingKeys_AliasedAnchorDivergence
+// pins this exception); revisit both when go.yaml.in/yaml/v4 leaves rc.
+func checkDuplicateMappingKeys(node *yaml.Node) error {
+ var errs []string
+ walkDuplicateMappingKeys(node, &errs)
+ if len(errs) == 0 {
+ return nil
+ }
+ return errors.New("yaml: construct errors: " + strings.Join(errs, "; "))
+}
+
+func walkDuplicateMappingKeys(node *yaml.Node, errs *[]string) {
+ switch node.Kind {
+ case yaml.DocumentNode, yaml.SequenceNode:
+ for _, child := range node.Content {
+ walkDuplicateMappingKeys(child, errs)
+ }
+ case yaml.MappingNode:
+ l := len(node.Content)
+ found := false
+ for i := 0; i < l; i += 2 {
+ ni := node.Content[i]
+ for j := i + 2; j < l; j += 2 {
+ nj := node.Content[j]
+ if ni.Kind == nj.Kind && ni.Value == nj.Value {
+ *errs = append(*errs,
+ fmt.Sprintf("line %d: mapping key %#v already defined at line %d", nj.Line, nj.Value, ni.Line))
+ found = true
+ }
+ }
+ }
+ if found {
+ return
+ }
+ for _, child := range node.Content {
+ walkDuplicateMappingKeys(child, errs)
+ }
+ }
+}
+
// extract version number from specification
func parseVersionTypeData(d interface{}) (string, int, error) {
r := []rune(strings.TrimSpace(fmt.Sprintf("%v", d)))
@@ -324,39 +470,126 @@ func parseVersionTypeData(d interface{}) (string, int, error) {
return string(r), int(r[0]) - '0', nil
}
-// unescapeJSONSlashes replaces the optional \/ escape sequence in JSON with /
-// JSON (RFC 8259) allows \/ as an optional escape for forward slash, but YAML
-// parsers (including go.yaml.in/yaml/v4) do not recognize it.
-// This handles escaped backslashes correctly: \\/ becomes \/ not //
-// Returns the original slice if no transformation is needed (zero allocation).
-func unescapeJSONSlashes(jsonBytes []byte) []byte {
- // fast path: check if transformation is needed
- if !bytes.Contains(jsonBytes, []byte(`\/`)) {
+// normalizeJSONForYAMLParser rewrites the small set of JSON escapes accepted by
+// RFC 8259 but rejected by go.yaml.in/yaml/v4. It returns the original slice
+// without allocation unless a rewrite is required.
+func normalizeJSONForYAMLParser(jsonBytes []byte) []byte {
+ if bytes.IndexByte(jsonBytes, '\\') < 0 {
return jsonBytes
}
- result := make([]byte, 0, len(jsonBytes))
- i := 0
- for i < len(jsonBytes) {
- if jsonBytes[i] == '\\' && i+1 < len(jsonBytes) {
- switch jsonBytes[i+1] {
- case '/':
- // \/ -> / (json optional escape for solidus)
- result = append(result, '/')
- i += 2
- case '\\':
- // preserve escaped backslash to prevent \\/ becoming //
- result = append(result, '\\', '\\')
- i += 2
- default:
- // preserve other escape sequences (\n, \t, \", etc.)
- result = append(result, jsonBytes[i])
- i++
- }
- } else {
- result = append(result, jsonBytes[i])
- i++
+ var result []byte
+ var runeBytes [utf8.UTFMax]byte
+ last := 0
+ scan := 0
+
+ for scan < len(jsonBytes) {
+ rel := bytes.IndexByte(jsonBytes[scan:], '\\')
+ if rel < 0 {
+ break
+ }
+
+ escape := scan + rel
+ replacement, consumed, ok := jsonEscapeReplacement(jsonBytes, escape, &runeBytes)
+ if !ok {
+ scan = nextJSONEscapeScanOffset(jsonBytes, escape)
+ continue
}
+
+ if result == nil {
+ result = make([]byte, 0, len(jsonBytes))
+ }
+ result = append(result, jsonBytes[last:escape]...)
+ result = append(result, replacement...)
+ scan = escape + consumed
+ last = scan
+ }
+
+ if result == nil {
+ return jsonBytes
}
+
+ result = append(result, jsonBytes[last:]...)
return result
}
+
+func jsonEscapeReplacement(jsonBytes []byte, escape int, runeBytes *[utf8.UTFMax]byte) ([]byte, int, bool) {
+ if escape+1 >= len(jsonBytes) {
+ return nil, 0, false
+ }
+
+ switch jsonBytes[escape+1] {
+ case '/':
+ runeBytes[0] = '/'
+ return runeBytes[:1], 2, true
+ case 'u':
+ if escape+12 > len(jsonBytes) {
+ return nil, 0, false
+ }
+
+ high, ok := decodeJSONUnicodeEscape(jsonBytes[escape+2 : escape+6])
+ if !ok || !isHighSurrogate(high) {
+ return nil, 0, false
+ }
+
+ lowEscape := escape + 6
+ if jsonBytes[lowEscape] != '\\' || jsonBytes[lowEscape+1] != 'u' {
+ return nil, 0, false
+ }
+
+ low, ok := decodeJSONUnicodeEscape(jsonBytes[lowEscape+2 : lowEscape+6])
+ if !ok || !isLowSurrogate(low) {
+ return nil, 0, false
+ }
+
+ r := utf16.DecodeRune(rune(high), rune(low))
+ n := utf8.EncodeRune(runeBytes[:], r)
+ return runeBytes[:n], 12, true
+ default:
+ return nil, 0, false
+ }
+}
+
+func nextJSONEscapeScanOffset(jsonBytes []byte, escape int) int {
+ if escape+1 >= len(jsonBytes) {
+ return escape + 1
+ }
+ return escape + 2
+}
+
+func decodeJSONUnicodeEscape(hexBytes []byte) (uint16, bool) {
+ if len(hexBytes) != 4 {
+ return 0, false
+ }
+
+ var value uint16
+ for _, b := range hexBytes {
+ hex, ok := jsonHexValue(b)
+ if !ok {
+ return 0, false
+ }
+ value = value<<4 | uint16(hex)
+ }
+ return value, true
+}
+
+func jsonHexValue(b byte) (byte, bool) {
+ switch {
+ case b >= '0' && b <= '9':
+ return b - '0', true
+ case b >= 'a' && b <= 'f':
+ return b - 'a' + 10, true
+ case b >= 'A' && b <= 'F':
+ return b - 'A' + 10, true
+ default:
+ return 0, false
+ }
+}
+
+func isHighSurrogate(value uint16) bool {
+ return value >= 0xD800 && value <= 0xDBFF
+}
+
+func isLowSurrogate(value uint16) bool {
+ return value >= 0xDC00 && value <= 0xDFFF
+}
diff --git a/vendor/github.com/pb33f/libopenapi/datamodel/translate.go b/vendor/github.com/pb33f/libopenapi/datamodel/translate.go
index a5245c0cb..7e8ce6446 100644
--- a/vendor/github.com/pb33f/libopenapi/datamodel/translate.go
+++ b/vendor/github.com/pb33f/libopenapi/datamodel/translate.go
@@ -38,6 +38,11 @@ type pipelineResult[OUT any] struct {
err error
}
+// parallelTranslateThreshold is the collection size below which TranslateSliceParallel
+// and TranslateMapParallel run sequentially: worker pool setup (goroutines, channels,
+// pending map) costs more than translating a handful of items inline.
+const parallelTranslateThreshold = 16
+
// TranslateSliceParallel iterates a slice in parallel and calls translate()
// asynchronously.
// translate() may return `datamodel.Continue` to continue iteration.
@@ -48,6 +53,33 @@ func TranslateSliceParallel[IN any, OUT any](in []IN, translate TranslateSliceFu
return nil
}
+ // small collections run inline: same observable semantics, none of the
+ // worker pool overhead.
+ if len(in) <= parallelTranslateThreshold {
+ for i := range in {
+ out, err := translate(i, in[i])
+ if err == Continue {
+ continue
+ }
+ if err != nil {
+ if err == io.EOF {
+ return nil
+ }
+ return err
+ }
+ if result == nil {
+ continue
+ }
+ if err = result(out); err != nil {
+ if err == io.EOF {
+ return nil
+ }
+ return err
+ }
+ }
+ return nil
+ }
+
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
@@ -149,14 +181,33 @@ func TranslateMapParallel[K comparable, V any, RV any](m *orderedmap.Map[K, V],
return nil
}
- // Snapshot pairs for indexed access.
+ // small maps run inline: same observable semantics, none of the worker
+ // pool or pair snapshot overhead.
+ if m.Len() <= parallelTranslateThreshold {
+ for pair := orderedmap.First(m); pair != nil; pair = pair.Next() {
+ rv, err := translate(pair)
+ if err != nil {
+ if err == io.EOF {
+ return nil
+ }
+ return err
+ }
+ if err = result(rv); err != nil {
+ if err == io.EOF {
+ return nil
+ }
+ return err
+ }
+ }
+ return nil
+ }
+
+ // Snapshot pairs for indexed access. The map is larger than the sequential
+ // threshold, so pairs is never empty here.
pairs := make([]orderedmap.Pair[K, V], 0, m.Len())
for pair := orderedmap.First(m); pair != nil; pair = pair.Next() {
pairs = append(pairs, pair)
}
- if len(pairs) == 0 {
- return nil
- }
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
diff --git a/vendor/github.com/pb33f/libopenapi/document.go b/vendor/github.com/pb33f/libopenapi/document.go
index 65b571a77..9c9bf3e40 100644
--- a/vendor/github.com/pb33f/libopenapi/document.go
+++ b/vendor/github.com/pb33f/libopenapi/document.go
@@ -137,7 +137,7 @@ type DocumentModel[T v2high.Swagger | v3high.Document] struct {
// This function will NOT automatically follow (meaning load) any file or remote references that are found.
//
// If this isn't the behavior you want, then you can use the NewDocumentWithConfiguration() function instead, which allows you to set a configuration that
-// will allow you to control if file or remote references are allowed. In particular the `AllowFileReferences` and `FollowRemoteReferences`
+// will allow you to control if file or remote references are allowed. In particular the `AllowFileReferences` and `AllowRemoteReferences`
// properties.
func NewDocument(specByteArray []byte) (Document, error) {
return NewDocumentWithTypeCheck(specByteArray, false)
diff --git a/vendor/github.com/pb33f/libopenapi/index/extract_refs.go b/vendor/github.com/pb33f/libopenapi/index/extract_refs.go
index e0176ee41..da55e843d 100644
--- a/vendor/github.com/pb33f/libopenapi/index/extract_refs.go
+++ b/vendor/github.com/pb33f/libopenapi/index/extract_refs.go
@@ -20,7 +20,7 @@ func isSchemaContainingNode(v string) bool {
func isMapOfSchemaContainingNode(v string) bool {
switch v {
- case "properties", "patternProperties":
+ case "properties", "patternProperties", "$defs":
return true
}
return false
diff --git a/vendor/github.com/pb33f/libopenapi/index/extract_refs_inline.go b/vendor/github.com/pb33f/libopenapi/index/extract_refs_inline.go
index 3f80fe033..643c83739 100644
--- a/vendor/github.com/pb33f/libopenapi/index/extract_refs_inline.go
+++ b/vendor/github.com/pb33f/libopenapi/index/extract_refs_inline.go
@@ -11,6 +11,39 @@ import (
"go.yaml.in/yaml/v4"
)
+// buildDefinitionPath assembles absPath + "#/" + seenPath + extra segments joined by
+// '/' in a single allocation. The "#/..." definition is a zero-copy suffix slice of
+// the result, so callers derive both strings from one build.
+func buildDefinitionPath(absPath string, seenPath []string, extra ...string) string {
+ size := len(absPath) + 2
+ for _, s := range seenPath {
+ size += len(s) + 1
+ }
+ for _, s := range extra {
+ size += len(s) + 1
+ }
+ var b strings.Builder
+ b.Grow(size)
+ b.WriteString(absPath)
+ b.WriteString("#/")
+ first := true
+ for _, s := range seenPath {
+ if !first {
+ b.WriteByte('/')
+ }
+ b.WriteString(s)
+ first = false
+ }
+ for _, s := range extra {
+ if !first {
+ b.WriteByte('/')
+ }
+ b.WriteString(s)
+ first = false
+ }
+ return b.String()
+}
+
func (index *SpecIndex) collectInlineSchemaDefinition(parent, node *yaml.Node, seenPath []string, keyIndex int) {
if keyIndex+1 >= len(node.Content) {
return
@@ -21,11 +54,11 @@ func (index *SpecIndex) collectInlineSchemaDefinition(parent, node *yaml.Node, s
var jsonPath, definitionPath, fullDefinitionPath string
if len(seenPath) > 0 || keyNode.Value != "" {
- loc := append(seenPath, keyNode.Value)
- locPath := strings.Join(loc, "/")
- definitionPath = "#/" + locPath
- fullDefinitionPath = index.specAbsolutePath + "#/" + locPath
- _, jsonPath = utils.ConvertComponentIdIntoFriendlyPathSearch(definitionPath)
+ fullDefinitionPath = buildDefinitionPath(index.specAbsolutePath, seenPath, keyNode.Value)
+ definitionPath = fullDefinitionPath[len(index.specAbsolutePath):]
+ if !index.skipMetadataCollection() {
+ _, jsonPath = utils.ConvertComponentIdIntoFriendlyPathSearch(definitionPath)
+ }
}
ref := &Reference{
@@ -68,6 +101,7 @@ func (index *SpecIndex) collectMapSchemaDefinitions(parent, node *yaml.Node, see
}
label := ""
+ prefix := ""
for h, prop := range propertiesNode.Content {
if h%2 == 0 {
label = prop.Value
@@ -76,11 +110,14 @@ func (index *SpecIndex) collectMapSchemaDefinitions(parent, node *yaml.Node, see
var jsonPath, definitionPath, fullDefinitionPath string
if len(seenPath) > 0 || keyNode.Value != "" && label != "" {
- loc := append(seenPath, keyNode.Value, label)
- locPath := strings.Join(loc, "/")
- definitionPath = "#/" + locPath
- fullDefinitionPath = index.specAbsolutePath + "#/" + locPath
- _, jsonPath = utils.ConvertComponentIdIntoFriendlyPathSearch(definitionPath)
+ if prefix == "" {
+ prefix = buildDefinitionPath(index.specAbsolutePath, seenPath, keyNode.Value)
+ }
+ fullDefinitionPath = prefix + "/" + label
+ definitionPath = fullDefinitionPath[len(index.specAbsolutePath):]
+ if !index.skipMetadataCollection() {
+ _, jsonPath = utils.ConvertComponentIdIntoFriendlyPathSearch(definitionPath)
+ }
}
ref := &Reference{
@@ -111,17 +148,20 @@ func (index *SpecIndex) collectArraySchemaDefinitions(parent, node *yaml.Node, s
keyNode := node.Content[keyIndex]
arrayNode := node.Content[keyIndex+1]
+ prefix := ""
for h, element := range arrayNode.Content {
var jsonPath, definitionPath, fullDefinitionPath string
if len(seenPath) > 0 {
- loc := append(seenPath, keyNode.Value, strconv.Itoa(h))
- locPath := strings.Join(loc, "/")
- definitionPath = "#/" + locPath
- fullDefinitionPath = index.specAbsolutePath + "#/" + locPath
- _, jsonPath = utils.ConvertComponentIdIntoFriendlyPathSearch(definitionPath)
+ if prefix == "" {
+ prefix = buildDefinitionPath(index.specAbsolutePath, seenPath, keyNode.Value)
+ }
+ fullDefinitionPath = prefix + "/" + strconv.Itoa(h)
+ definitionPath = fullDefinitionPath[len(index.specAbsolutePath):]
} else {
definitionPath = "#/" + keyNode.Value
fullDefinitionPath = index.specAbsolutePath + "#/" + keyNode.Value
+ }
+ if !index.skipMetadataCollection() {
_, jsonPath = utils.ConvertComponentIdIntoFriendlyPathSearch(definitionPath)
}
diff --git a/vendor/github.com/pb33f/libopenapi/index/extract_refs_lookup.go b/vendor/github.com/pb33f/libopenapi/index/extract_refs_lookup.go
index 4062daca8..288ef7682 100644
--- a/vendor/github.com/pb33f/libopenapi/index/extract_refs_lookup.go
+++ b/vendor/github.com/pb33f/libopenapi/index/extract_refs_lookup.go
@@ -197,8 +197,9 @@ func (index *SpecIndex) ExtractComponentsFromRefs(ctx context.Context, refs []*R
}
func (index *SpecIndex) locateRef(ctx context.Context, ref *Reference) *Reference {
- uri := strings.Split(ref.FullDefinition, "#/")
- isExternalRef := len(uri) == 2 && len(uri[0]) > 0
+ // match strings.Split len==2 semantics: exactly one "#/" with a non-empty file part.
+ refFile, refFragment, refCut := strings.Cut(ref.FullDefinition, "#/")
+ isExternalRef := refCut && refFile != "" && !strings.Contains(refFragment, "#/")
if isExternalRef {
index.refLock.Lock()
}
@@ -221,11 +222,11 @@ func (index *SpecIndex) locateRef(ctx context.Context, ref *Reference) *Referenc
}
if located.Node != nil {
+ index.awaitNodeMap()
index.nodeMapLock.RLock()
- if located.Node.Line > 1 && len(index.nodeMap[located.Node.Line-1]) > 0 {
- for _, v := range index.nodeMap[located.Node.Line-1] {
- located.KeyNode = v
- break
+ if prevLine := located.Node.Line - 1; prevLine > 0 && prevLine < len(index.nodeLines) {
+ if entries := index.nodeLines[prevLine]; len(entries) > 0 {
+ located.KeyNode = entries[0].node
}
}
index.nodeMapLock.RUnlock()
diff --git a/vendor/github.com/pb33f/libopenapi/index/extract_refs_metadata.go b/vendor/github.com/pb33f/libopenapi/index/extract_refs_metadata.go
index ce9b82f78..085237792 100644
--- a/vendor/github.com/pb33f/libopenapi/index/extract_refs_metadata.go
+++ b/vendor/github.com/pb33f/libopenapi/index/extract_refs_metadata.go
@@ -16,6 +16,13 @@ type metadataPathAction struct {
stop bool
}
+// skipMetadataCollection reports whether diagnostic metadata collection is disabled.
+// Only collection is skipped: the path actions extractNodeMetadata returns drive
+// seenPath handling for every downstream ref, so that logic always runs.
+func (index *SpecIndex) skipMetadataCollection() bool {
+ return index.config != nil && index.config.SkipMetadataCollection
+}
+
func (index *SpecIndex) extractNodeMetadata(node, parent *yaml.Node, seenPath []string, keyIndex int) metadataPathAction {
keyNode := node.Content[keyIndex]
if keyNode == nil || keyNode.Value == "" || keyNode.Value == "$ref" || keyNode.Value == "$id" {
@@ -31,8 +38,7 @@ func (index *SpecIndex) extractNodeMetadata(node, parent *yaml.Node, seenPath []
var jsonPathComputed bool
computeJSONPath := func() string {
if !jsonPathComputed {
- loc := append(seenPath, segment)
- definitionPath := "#/" + strings.Join(loc, "/")
+ definitionPath := buildDefinitionPath("", seenPath, segment)
_, jsonPath = utils.ConvertComponentIdIntoFriendlyPathSearch(definitionPath)
jsonPathComputed = true
}
@@ -47,7 +53,7 @@ func (index *SpecIndex) extractNodeMetadata(node, parent *yaml.Node, seenPath []
if isMetadataPropertyNamePath(seenPath) {
return metadataPathAction{appendSegment: true, stop: true}
}
- if !metadataPathContainsExamples(seenPath) {
+ if !metadataPathContainsExamples(seenPath) && !index.skipMetadataCollection() {
refNode := metadataValueNode(node, keyIndex)
ref := &DescriptionReference{
ParentNode: parent,
@@ -69,25 +75,33 @@ func (index *SpecIndex) extractNodeMetadata(node, parent *yaml.Node, seenPath []
if metadataPathContainsExamples(seenPath) {
return metadataPathAction{stop: true}
}
- refNode := metadataValueNode(node, keyIndex)
- index.allSummaries = append(index.allSummaries, &DescriptionReference{
- ParentNode: parent,
- Content: refNode.Value,
- Path: computeJSONPath(),
- Node: refNode,
- KeyNode: keyNode,
- IsSummary: true,
- })
- index.summaryCount++
+ if !index.skipMetadataCollection() {
+ refNode := metadataValueNode(node, keyIndex)
+ index.allSummaries = append(index.allSummaries, &DescriptionReference{
+ ParentNode: parent,
+ Content: refNode.Value,
+ Path: computeJSONPath(),
+ Node: refNode,
+ KeyNode: keyNode,
+ IsSummary: true,
+ })
+ index.summaryCount++
+ }
case "security":
- index.collectSecurityRequirementMetadata(node, keyIndex, computeJSONPath())
+ if !index.skipMetadataCollection() {
+ index.collectSecurityRequirementMetadata(node, keyIndex, computeJSONPath())
+ }
case "enum":
if len(seenPath) > 0 && seenPath[len(seenPath)-1] == "properties" {
return metadataPathAction{appendSegment: true, stop: true}
}
- index.collectEnumMetadata(node, parent, keyIndex, computeJSONPath())
+ if !index.skipMetadataCollection() {
+ index.collectEnumMetadata(node, parent, keyIndex, computeJSONPath())
+ }
case "properties":
- index.collectObjectWithPropertiesMetadata(node, parent, keyNode, computeJSONPath())
+ if !index.skipMetadataCollection() {
+ index.collectObjectWithPropertiesMetadata(node, parent, keyNode, computeJSONPath())
+ }
}
return metadataPathAction{appendSegment: true}
diff --git a/vendor/github.com/pb33f/libopenapi/index/extract_refs_ref.go b/vendor/github.com/pb33f/libopenapi/index/extract_refs_ref.go
index 850c120e4..2aeef7f0d 100644
--- a/vendor/github.com/pb33f/libopenapi/index/extract_refs_ref.go
+++ b/vendor/github.com/pb33f/libopenapi/index/extract_refs_ref.go
@@ -80,6 +80,7 @@ func (index *SpecIndex) extractReferenceAt(
Node: node,
KeyNode: node.Content[keyIndex+1],
Path: path,
+ SourcePath: append([]string(nil), seenPath...),
Index: index,
IsExtensionRef: isExtensionPath,
HasSiblingProperties: len(siblingProps) > 0,
@@ -334,6 +335,7 @@ func (index *SpecIndex) storeReferenceWithSiblings(
Node: &copiedNode,
KeyNode: node.Content[keyIndex],
Path: path,
+ SourcePath: append([]string(nil), ref.SourcePath...),
Index: index,
IsExtensionRef: isExtensionPath,
HasSiblingProperties: len(siblingProps) > 0,
diff --git a/vendor/github.com/pb33f/libopenapi/index/find_component_build.go b/vendor/github.com/pb33f/libopenapi/index/find_component_build.go
index 5c027c28f..7c537d2a1 100644
--- a/vendor/github.com/pb33f/libopenapi/index/find_component_build.go
+++ b/vendor/github.com/pb33f/libopenapi/index/find_component_build.go
@@ -47,6 +47,7 @@ func buildResolvedComponentReference(
HasSiblingProperties: source.HasSiblingProperties,
In: source.In,
}
+ ref.SourcePath = append([]string(nil), source.SourcePath...)
ref.ParentNodeTypes = append([]string(nil), source.ParentNodeTypes...)
ref.SiblingKeys = append([]*yaml.Node(nil), source.SiblingKeys...)
ref.SiblingProperties = cloneSiblingProperties(source.SiblingProperties)
diff --git a/vendor/github.com/pb33f/libopenapi/index/index_model.go b/vendor/github.com/pb33f/libopenapi/index/index_model.go
index 46a5c386f..5e159d31f 100644
--- a/vendor/github.com/pb33f/libopenapi/index/index_model.go
+++ b/vendor/github.com/pb33f/libopenapi/index/index_model.go
@@ -40,6 +40,7 @@ type Reference struct {
Index *SpecIndex `json:"-"` // index that contains this reference.
RemoteLocation string `json:"remoteLocation,omitempty"`
Path string `json:"path,omitempty"` // this won't always be available.
+ SourcePath []string `json:"-"` // OpenAPI path to the source $ref location.
RequiredRefProperties map[string][]string `json:"requiredProperties,omitempty"` // definition names (eg, #/definitions/One) to a list of required properties on this definition which reference that definition
HasSiblingProperties bool `json:"-"` // indicates if ref has sibling properties
SiblingProperties map[string]*yaml.Node `json:"-"` // stores sibling property nodes
@@ -226,6 +227,20 @@ type SpecIndexConfig struct {
// PropertyMergeStrategy defines how to handle conflicts when merging properties.
PropertyMergeStrategy datamodel.PropertyMergeStrategy
+ // SkipMetadataCollection disables the collection of diagnostic metadata during indexing:
+ // descriptions, summaries, enums, objects-with-properties, security requirement
+ // references, and the JSONPath `Path` values on inline schema references. Skipping
+ // them significantly reduces allocations and retained memory when parsing large
+ // documents. Reference extraction and resolution are unaffected.
+ //
+ // -- UNSAFE FOR DIAGNOSTIC, RULE, OR PATH CONSUMERS --
+ // When enabled, GetAllDescriptions, GetAllSummaries, GetAllEnums,
+ // GetAllObjectsWithProperties, GetSecurityRequirementReferences and the related
+ // counts are intentionally empty/zero, and inline schema Reference.Path values are
+ // empty strings. vacuum and any other tool that consumes index metadata or Path
+ // values must NOT enable this. Defaults to false (everything is collected).
+ SkipMetadataCollection bool
+
// private fields
uri []string
id string
@@ -278,6 +293,7 @@ func (s *SpecIndexConfig) ToDocumentConfiguration() *datamodel.DocumentConfigura
ResolveNestedRefsWithDocumentContext: s.ResolveNestedRefsWithDocumentContext,
PropertyMergeStrategy: strategy,
SkipExternalRefResolution: s.SkipExternalRefResolution,
+ SkipMetadataCollection: s.SkipMetadataCollection,
Logger: s.Logger,
}
}
@@ -415,7 +431,8 @@ type SpecIndex struct {
built bool
uri []string
logger *slog.Logger
- nodeMap map[int]map[int]*yaml.Node
+ nodeLines [][]nodeLineEntry
+ legacyNodeMap map[int]map[int]*yaml.Node // materialized on demand by GetNodeMap only
nodeMapCompleted chan struct{}
pendingResolve []refMap
highModelCache Cache
@@ -443,8 +460,30 @@ func (index *SpecIndex) GetConfig() *SpecIndexConfig {
}
// GetNodeMap returns the line-to-column-to-node map built during indexing.
+// The map is materialized from the internal line index on first call and cached.
+//
+// Deprecated: use GetNode for single lookups; this method exists for API
+// compatibility and allocates a full legacy map on first use.
func (index *SpecIndex) GetNodeMap() map[int]map[int]*yaml.Node {
- return index.nodeMap
+ index.awaitNodeMap()
+ index.nodeMapLock.Lock()
+ defer index.nodeMapLock.Unlock()
+ if index.legacyNodeMap != nil || index.nodeLines == nil {
+ return index.legacyNodeMap
+ }
+ legacy := make(map[int]map[int]*yaml.Node)
+ for line, entries := range index.nodeLines {
+ if len(entries) == 0 {
+ continue
+ }
+ cols := make(map[int]*yaml.Node, len(entries))
+ for _, e := range entries {
+ cols[int(e.column)] = e.node
+ }
+ legacy[line] = cols
+ }
+ index.legacyNodeMap = legacy
+ return legacy
}
// GetCache returns the reference lookup cache used during resolution.
@@ -542,7 +581,12 @@ func (index *SpecIndex) releaseComponentIndexes() {
}
func (index *SpecIndex) releaseDerivedState() {
- index.nodeMap = nil
+ // node-map state is read concurrently via awaitNodeMap/GetNode; nil it
+ // under the same lock those readers use.
+ index.nodeMapLock.Lock()
+ index.nodeLines = nil
+ index.legacyNodeMap = nil
+ index.nodeMapLock.Unlock()
index.allDescriptions = nil
index.allSummaries = nil
index.allEnums = nil
@@ -602,7 +646,9 @@ func (index *SpecIndex) resetRuntimeState() {
index.built = false
index.componentIndexChan = nil
index.polyComponentIndexChan = nil
- index.nodeMapCompleted = nil
+ // nodeMapCompleted is deliberately NOT nilled: it is closed (retaining
+ // nothing) and awaitNodeMap reads the field without a lock on the GetNode
+ // hot path - writing nil here would race every reader for zero benefit.
}
// SetAbsolutePath sets the absolute path to the spec file for the index. Will be absolute, either as a http link or a file.
diff --git a/vendor/github.com/pb33f/libopenapi/index/map_index_nodes.go b/vendor/github.com/pb33f/libopenapi/index/map_index_nodes.go
index 4f8ecde50..84cb1f101 100644
--- a/vendor/github.com/pb33f/libopenapi/index/map_index_nodes.go
+++ b/vendor/github.com/pb33f/libopenapi/index/map_index_nodes.go
@@ -41,44 +41,96 @@ type NodeOrigin struct {
Index *SpecIndex `json:"-" yaml:"-"`
}
+// nodeLineEntry is a single (column, node) pair on one line of the spec. Lines hold very
+// few nodes, so a small slice scanned linearly is far cheaper than a per-line map.
+type nodeLineEntry struct {
+ column int32
+ node *yaml.Node
+}
+
// GetNode returns a node from the spec based on a line and column. The second return var bool is true
-// if the node was found, false if not.
+// if the node was found, false if not. Blocks until the node line index has been fully built.
func (index *SpecIndex) GetNode(line int, column int) (*yaml.Node, bool) {
+ index.awaitNodeMap()
index.nodeMapLock.RLock()
defer index.nodeMapLock.RUnlock()
- if index.nodeMap[line] == nil {
- return nil, false
- }
- node := index.nodeMap[line][column]
+ node := lookupNodeLines(index.nodeLines, line, column)
return node, node != nil
}
-// MapNodes maps all nodes in the document to a map of line/column to node.
-// Writes directly to index.nodeMap with lock protection (concurrent reads
-// may happen from ExtractRefs running in parallel).
+// awaitNodeMap blocks until MapNodes has published the node line index. It is a no-op
+// once the index has been built or released (the completion channel is close-only).
+func (index *SpecIndex) awaitNodeMap() {
+ if ch := index.nodeMapCompleted; ch != nil {
+ <-ch
+ }
+}
+
+// lookupNodeLines returns the node stored at line/column, or nil if absent.
+func lookupNodeLines(lines [][]nodeLineEntry, line, column int) *yaml.Node {
+ if line < 0 || line >= len(lines) {
+ return nil
+ }
+ for _, e := range lines[line] {
+ if int(e.column) == column {
+ return e.node
+ }
+ }
+ return nil
+}
+
+// MapNodes maps all nodes in the document by line and column. The index is built into a
+// local structure without locking, published under a single lock, and completion is
+// signalled by closing nodeMapCompleted (close-only: supports any number of waiters).
func (index *SpecIndex) MapNodes(rootNode *yaml.Node) {
- mapNodesRecursive(rootNode, index, true)
- index.nodeMapCompleted <- struct{}{}
+ sizeHint := 0
+ if index.config != nil && index.config.SpecInfo != nil {
+ sizeHint = index.config.SpecInfo.NumLines
+ }
+ // lines are 1-based; +1 so line NumLines is directly addressable.
+ lines := make([][]nodeLineEntry, sizeHint+1)
+ lines = mapNodesRecursive(rootNode, lines)
+ index.nodeMapLock.Lock()
+ index.nodeLines = lines
+ index.nodeMapLock.Unlock()
close(index.nodeMapCompleted)
}
-func mapNodesRecursive(node *yaml.Node, index *SpecIndex, root bool) {
+func mapNodesRecursive(node *yaml.Node, lines [][]nodeLineEntry) [][]nodeLineEntry {
if node.Kind == yaml.DocumentNode {
node = node.Content[0]
}
for _, child := range node.Content {
- index.nodeMapLock.Lock()
- if index.nodeMap[child.Line] == nil {
- index.nodeMap[child.Line] = make(map[int]*yaml.Node)
+ lines = addNodeLineEntry(lines, child)
+ lines = mapNodesRecursive(child, lines)
+ }
+ return addNodeLineEntry(lines, node)
+}
+
+// addNodeLineEntry records node at its line/column, preserving the previous map
+// semantics: a later write to the same line/column replaces the earlier one
+// (parents are written after their children, so parents win collisions).
+func addNodeLineEntry(lines [][]nodeLineEntry, node *yaml.Node) [][]nodeLineEntry {
+ line := node.Line
+ if line < 0 {
+ return lines
+ }
+ if line >= len(lines) {
+ grown := len(lines) * 2
+ if grown <= line {
+ grown = line + 1
}
- index.nodeMap[child.Line][child.Column] = child
- index.nodeMapLock.Unlock()
- mapNodesRecursive(child, index, false)
+ expanded := make([][]nodeLineEntry, grown)
+ copy(expanded, lines)
+ lines = expanded
}
- index.nodeMapLock.Lock()
- if index.nodeMap[node.Line] == nil {
- index.nodeMap[node.Line] = make(map[int]*yaml.Node)
+ entries := lines[line]
+ for i := range entries {
+ if int(entries[i].column) == node.Column {
+ entries[i].node = node
+ return lines
+ }
}
- index.nodeMap[node.Line][node.Column] = node
- index.nodeMapLock.Unlock()
+ lines[line] = append(entries, nodeLineEntry{column: int32(node.Column), node: node})
+ return lines
}
diff --git a/vendor/github.com/pb33f/libopenapi/index/reference_identity.go b/vendor/github.com/pb33f/libopenapi/index/reference_identity.go
new file mode 100644
index 000000000..6240e412d
--- /dev/null
+++ b/vendor/github.com/pb33f/libopenapi/index/reference_identity.go
@@ -0,0 +1,31 @@
+// Copyright 2026 Princess B33f Heavy Industries / Dave Shanley
+// SPDX-License-Identifier: MIT
+
+package index
+
+import (
+ "net/url"
+ "path"
+ "path/filepath"
+ "strings"
+
+ "github.com/pb33f/libopenapi/utils"
+)
+
+// CanonicalReferenceIdentity normalizes the document portion of a resolved
+// reference while preserving its JSON Pointer fragment. It is intended for
+// identity comparisons, not for rewriting authored reference values.
+func CanonicalReferenceIdentity(ref string) string {
+ base, fragment := SplitRefFragment(ref)
+ if base == "" {
+ return fragment
+ }
+ if parsed, err := url.Parse(base); err == nil && parsed.IsAbs() && parsed.Host != "" {
+ parsed.Path = path.Clean(parsed.Path)
+ return parsed.String() + fragment
+ }
+ base = utils.ReplaceWindowsDriveWithLinuxPath(base)
+ base = filepath.ToSlash(filepath.Clean(base))
+ base = strings.TrimSuffix(base, "/.")
+ return base + fragment
+}
diff --git a/vendor/github.com/pb33f/libopenapi/index/resolver_relatives.go b/vendor/github.com/pb33f/libopenapi/index/resolver_relatives.go
index ca33a60d9..4fee92f3a 100644
--- a/vendor/github.com/pb33f/libopenapi/index/resolver_relatives.go
+++ b/vendor/github.com/pb33f/libopenapi/index/resolver_relatives.go
@@ -144,6 +144,7 @@ func (resolver *Resolver) extractRelativeReference(
RemoteLocation: ref.RemoteLocation,
IsRemote: true,
Index: ref.Index,
+ SourcePath: append([]string(nil), ref.SourcePath...),
}
locatedRef, _, _ := resolver.searchReferenceWithContext(ref, searchRef)
diff --git a/vendor/github.com/pb33f/libopenapi/index/search_index.go b/vendor/github.com/pb33f/libopenapi/index/search_index.go
index 9e0c92d17..e03171163 100644
--- a/vendor/github.com/pb33f/libopenapi/index/search_index.go
+++ b/vendor/github.com/pb33f/libopenapi/index/search_index.go
@@ -171,47 +171,49 @@ func (index *SpecIndex) SearchIndexForReferenceByReferenceWithContext(ctx contex
absPath = index.config.BasePath
}
var roloLookup string
- uri := strings.Split(ref, "#/")
- if len(uri) == 2 {
- if uri[0] != "" {
- if strings.HasPrefix(uri[0], "http") {
+ uriFile, uriFragment, uriCut := strings.Cut(ref, "#/")
+ // match strings.Split(ref, "#/") len==2 semantics: exactly one separator.
+ singleFragment := uriCut && !strings.Contains(uriFragment, "#/")
+ if singleFragment {
+ if uriFile != "" {
+ if strings.HasPrefix(uriFile, "http") {
roloLookup = searchRef.FullDefinition
} else {
- if filepath.IsAbs(uri[0]) {
- roloLookup = uri[0]
+ if filepath.IsAbs(uriFile) {
+ roloLookup = uriFile
} else {
if filepath.Ext(absPath) != "" {
absPath = filepath.Dir(absPath)
}
- roloLookup = index.resolveRelativeFilePath(absPath, uri[0])
+ roloLookup = index.resolveRelativeFilePath(absPath, uriFile)
}
}
} else {
- if filepath.Ext(uri[1]) != "" {
+ if filepath.Ext(uriFragment) != "" {
roloLookup = absPath
} else {
roloLookup = ""
}
- ref = fmt.Sprintf("#/%s", uri[1])
- refAlt = fmt.Sprintf("%s#/%s", absPath, uri[1])
+ ref = fmt.Sprintf("#/%s", uriFragment)
+ refAlt = fmt.Sprintf("%s#/%s", absPath, uriFragment)
}
} else {
- if filepath.IsAbs(uri[0]) {
- roloLookup = uri[0]
+ if filepath.IsAbs(uriFile) {
+ roloLookup = uriFile
} else {
- if strings.HasPrefix(uri[0], "http") {
+ if strings.HasPrefix(uriFile, "http") {
roloLookup = ref
} else {
if filepath.Ext(absPath) != "" {
absPath = filepath.Dir(absPath)
}
- roloLookup = index.resolveRelativeFilePath(absPath, uri[0])
+ roloLookup = index.resolveRelativeFilePath(absPath, uriFile)
}
}
- ref = uri[0]
+ ref = uriFile
}
if strings.Contains(ref, "%") {
// decode the url.
@@ -258,9 +260,7 @@ func (index *SpecIndex) SearchIndexForReferenceByReferenceWithContext(ctx contex
// component-tree walking inside the remote file.
if roloLookup != "" {
- if strings.Contains(roloLookup, "#") {
- roloLookup = strings.Split(roloLookup, "#")[0]
- }
+ roloLookup, _, _ = strings.Cut(roloLookup, "#")
b := filepath.Base(roloLookup)
sfn := index.GetSpecFileName()
@@ -270,8 +270,8 @@ func (index *SpecIndex) SearchIndexForReferenceByReferenceWithContext(ctx contex
if b == sfn && roloLookup == abp {
// if the reference is the same as the spec file name, we should look through the index for the component
var r *Reference
- if len(uri) == 2 {
- r = index.FindComponentInRoot(ctx, fmt.Sprintf("#/%s", uri[1]))
+ if singleFragment {
+ r = index.FindComponentInRoot(ctx, fmt.Sprintf("#/%s", uriFragment))
}
return r, index, ctx
}
@@ -352,12 +352,12 @@ func (index *SpecIndex) SearchIndexForReferenceByReferenceWithContext(ctx contex
node, _ := rFile.GetContentAsYAMLNode()
if node != nil {
var found *Reference
- exp := strings.Split(ref, "#/")
+ expFile, expFragment, expCut := strings.Cut(ref, "#/")
compId := ref
- if len(exp) == 2 {
- compId = fmt.Sprintf("#/%s", exp[1])
- found = FindComponent(ctx, node, compId, exp[0], idx)
+ if expCut && !strings.Contains(expFragment, "#/") {
+ compId = fmt.Sprintf("#/%s", expFragment)
+ found = FindComponent(ctx, node, compId, expFile, idx)
}
if found == nil {
found = idx.FindComponent(ctx, ref)
diff --git a/vendor/github.com/pb33f/libopenapi/index/search_rolodex.go b/vendor/github.com/pb33f/libopenapi/index/search_rolodex.go
index 6eb3f4bb4..d61c6c50f 100644
--- a/vendor/github.com/pb33f/libopenapi/index/search_rolodex.go
+++ b/vendor/github.com/pb33f/libopenapi/index/search_rolodex.go
@@ -97,51 +97,49 @@ func (r *Rolodex) FindNodeOrigin(node *yaml.Node) *NodeOrigin {
// is returned, otherwise nil is returned.
func (index *SpecIndex) FindNodeOrigin(node *yaml.Node) *NodeOrigin {
if node != nil {
+ index.awaitNodeMap()
index.nodeMapLock.RLock()
- if index.nodeMap[node.Line] != nil {
- if index.nodeMap[node.Line][node.Column] != nil {
- foundNode := index.nodeMap[node.Line][node.Column]
- match := false
+ if foundNode := lookupNodeLines(index.nodeLines, node.Line, node.Column); foundNode != nil {
+ match := false
- if foundNode == node {
- match = true
+ if foundNode == node {
+ match = true
+ }
+
+ // if the found node is a map. iterate through the content until we locate the node at that position
+ if !match && (utils.IsNodeMap(foundNode) ||
+ utils.IsNodeArray(foundNode)) && (utils.IsNodeMap(node) || utils.IsNodeArray(node)) {
+ if len(node.Content) == len(foundNode.Content) {
+ // hash node and found node
+ match = checkHash(node, foundNode)
}
+ } else {
+ if !match {
+ // hash node and found node
+ match = checkHash(node, foundNode)
- // if the found node is a map. iterate through the content until we locate the node at that position
- if !match && (utils.IsNodeMap(foundNode) ||
- utils.IsNodeArray(foundNode)) && (utils.IsNodeMap(node) || utils.IsNodeArray(node)) {
- if len(node.Content) == len(foundNode.Content) {
- // hash node and found node
- match = checkHash(node, foundNode)
- }
- } else {
if !match {
- // hash node and found node
- match = checkHash(node, foundNode)
-
- if !match {
- // check if the found node is a map and if the first item in the map
- // has the same line and column, as well as the same value
- if utils.IsNodeMap(foundNode) && len(foundNode.Content) > 0 {
- if foundNode.Content[0].Line == node.Line &&
- foundNode.Content[0].Column == node.Column &&
- foundNode.Content[0].Value == node.Value {
- match = true
- }
+ // check if the found node is a map and if the first item in the map
+ // has the same line and column, as well as the same value
+ if utils.IsNodeMap(foundNode) && len(foundNode.Content) > 0 {
+ if foundNode.Content[0].Line == node.Line &&
+ foundNode.Content[0].Column == node.Column &&
+ foundNode.Content[0].Value == node.Value {
+ match = true
}
}
}
}
+ }
- if match {
- index.nodeMapLock.RUnlock()
- return &NodeOrigin{
- Node: foundNode,
- Line: node.Line,
- Column: node.Column,
- AbsoluteLocation: index.specAbsolutePath,
- Index: index,
- }
+ if match {
+ index.nodeMapLock.RUnlock()
+ return &NodeOrigin{
+ Node: foundNode,
+ Line: node.Line,
+ Column: node.Column,
+ AbsoluteLocation: index.specAbsolutePath,
+ Index: index,
}
}
}
diff --git a/vendor/github.com/pb33f/libopenapi/index/spec_index_build.go b/vendor/github.com/pb33f/libopenapi/index/spec_index_build.go
index 9df192ecd..544696d41 100644
--- a/vendor/github.com/pb33f/libopenapi/index/spec_index_build.go
+++ b/vendor/github.com/pb33f/libopenapi/index/spec_index_build.go
@@ -62,7 +62,6 @@ func createNewIndex(ctx context.Context, rootNode *yaml.Node, index *SpecIndex,
return index
}
index.nodeMapCompleted = make(chan struct{})
- index.nodeMap = make(map[int]map[int]*yaml.Node)
go index.MapNodes(rootNode)
index.cache = new(sync.Map)
diff --git a/vendor/github.com/pb33f/libopenapi/index/utility_methods.go b/vendor/github.com/pb33f/libopenapi/index/utility_methods.go
index 1e8fc191f..d201dcac5 100644
--- a/vendor/github.com/pb33f/libopenapi/index/utility_methods.go
+++ b/vendor/github.com/pb33f/libopenapi/index/utility_methods.go
@@ -555,16 +555,7 @@ func findIndex(index *SpecIndex, i *yaml.Node) *SpecIndex {
}
allIndexes := rolodex.GetIndexes()
for _, searchIndex := range allIndexes {
- nodeMap := searchIndex.GetNodeMap()
- line, ok := nodeMap[i.Line]
- if !ok {
- continue
- }
- node, ok := line[i.Column]
- if !ok {
- continue
- }
- if node == i {
+ if node, ok := searchIndex.GetNode(i.Line, i.Column); ok && node == i {
return searchIndex
}
}
diff --git a/vendor/github.com/pb33f/libopenapi/orderedmap/builder.go b/vendor/github.com/pb33f/libopenapi/orderedmap/builder.go
index 240314589..057a965a8 100644
--- a/vendor/github.com/pb33f/libopenapi/orderedmap/builder.go
+++ b/vendor/github.com/pb33f/libopenapi/orderedmap/builder.go
@@ -2,6 +2,7 @@ package orderedmap
import (
"fmt"
+ "reflect"
"strings"
"github.com/pb33f/libopenapi/datamodel/high/nodes"
@@ -33,6 +34,65 @@ type findValueUntyped interface {
FindValueUntyped(k string) any
}
+// MarshalYAML implements yaml.Marshaler for libopenapi's ordered map wrapper.
+func (o *Map[K, V]) MarshalYAML() (interface{}, error) {
+ if o == nil {
+ return nil, nil
+ }
+
+ node := yaml.Node{Kind: yaml.MappingNode}
+ for pair := First(o); pair != nil; pair = pair.Next() {
+ keyNode := &yaml.Node{}
+ keyValue, err := encodeMarshalYAMLValue(pair.Key())
+ if err != nil {
+ return nil, err
+ }
+ if err = keyNode.Encode(keyValue); err != nil {
+ return nil, err
+ }
+
+ valueNode := &yaml.Node{}
+ value, err := encodeMarshalYAMLValue(pair.Value())
+ if err != nil {
+ return nil, err
+ }
+ if err = valueNode.Encode(value); err != nil {
+ return nil, err
+ }
+
+ node.Content = append(node.Content, keyNode, valueNode)
+ }
+
+ return &node, nil
+}
+
+func encodeMarshalYAMLValue(value any) (any, error) {
+ for {
+ if value == nil {
+ return nil, nil
+ }
+ if node, ok := value.(*yaml.Node); ok {
+ return utils.CloneYAMLNode(node), nil
+ }
+
+ rv := reflect.ValueOf(value)
+ if rv.Kind() == reflect.Ptr && rv.IsNil() {
+ return value, nil
+ }
+
+ m, ok := value.(marshaler)
+ if !ok {
+ return value, nil
+ }
+
+ marshaled, err := m.MarshalYAML()
+ if err != nil {
+ return nil, err
+ }
+ value = marshaled
+ }
+}
+
// ToYamlNode converts the ordered map to a yaml node ready for marshalling.
func (o *Map[K, V]) ToYamlNode(n NodeBuilder, l any) *yaml.Node {
p := utils.CreateEmptyMapNode()
diff --git a/vendor/github.com/pb33f/libopenapi/overlay.go b/vendor/github.com/pb33f/libopenapi/overlay.go
index 2f475f0bd..ed37aff74 100644
--- a/vendor/github.com/pb33f/libopenapi/overlay.go
+++ b/vendor/github.com/pb33f/libopenapi/overlay.go
@@ -4,6 +4,7 @@
package libopenapi
import (
+ "bytes"
gocontext "context"
"github.com/pb33f/libopenapi/datamodel"
@@ -32,6 +33,10 @@ type OverlayResult struct {
// NewOverlayDocument creates a new overlay document from the provided bytes.
// The overlay document can then be applied to a target OpenAPI document using ApplyOverlay.
func NewOverlayDocument(overlayBytes []byte) (*highoverlay.Overlay, error) {
+ if len(bytes.TrimSpace(overlayBytes)) == 0 {
+ return nil, overlay.ErrInvalidOverlay
+ }
+
var node yaml.Node
if err := yaml.Unmarshal(overlayBytes, &node); err != nil {
return nil, err
diff --git a/vendor/github.com/pb33f/libopenapi/overlay/engine.go b/vendor/github.com/pb33f/libopenapi/overlay/engine.go
index 091c7f607..c58ac5b40 100644
--- a/vendor/github.com/pb33f/libopenapi/overlay/engine.go
+++ b/vendor/github.com/pb33f/libopenapi/overlay/engine.go
@@ -7,6 +7,7 @@ import (
"github.com/pb33f/jsonpath/pkg/jsonpath"
"github.com/pb33f/jsonpath/pkg/jsonpath/config"
highoverlay "github.com/pb33f/libopenapi/datamodel/high/overlay"
+ "github.com/pb33f/libopenapi/utils"
"go.yaml.in/yaml/v4"
)
@@ -210,7 +211,7 @@ func removeNode(idx parentIndex, node *yaml.Node) {
func mergeNode(node *yaml.Node, merge *yaml.Node) {
if node.Kind != merge.Kind {
- *node = *cloneNode(merge)
+ *node = *utils.CloneYAMLNode(merge)
return
}
switch node.Kind {
@@ -237,39 +238,13 @@ NextKey:
}
}
- node.Content = append(node.Content, merge.Content[i], cloneNode(mergeValue))
+ node.Content = append(node.Content, merge.Content[i], utils.CloneYAMLNode(mergeValue))
}
}
func mergeSequenceNode(node *yaml.Node, merge *yaml.Node) {
// clone each child individually to avoid wasteful intermediate allocation
for _, child := range merge.Content {
- node.Content = append(node.Content, cloneNode(child))
+ node.Content = append(node.Content, utils.CloneYAMLNode(child))
}
}
-
-func cloneNode(node *yaml.Node) *yaml.Node {
- if node == nil {
- return nil
- }
- newNode := &yaml.Node{
- Kind: node.Kind,
- Style: node.Style,
- Tag: node.Tag,
- Value: node.Value,
- Anchor: node.Anchor,
- HeadComment: node.HeadComment,
- LineComment: node.LineComment,
- FootComment: node.FootComment,
- }
- if node.Alias != nil {
- newNode.Alias = cloneNode(node.Alias)
- }
- if node.Content != nil {
- newNode.Content = make([]*yaml.Node, len(node.Content))
- for i, child := range node.Content {
- newNode.Content[i] = cloneNode(child)
- }
- }
- return newNode
-}
diff --git a/vendor/github.com/pb33f/libopenapi/utils/clone_node.go b/vendor/github.com/pb33f/libopenapi/utils/clone_node.go
new file mode 100644
index 000000000..37a32ef9f
--- /dev/null
+++ b/vendor/github.com/pb33f/libopenapi/utils/clone_node.go
@@ -0,0 +1,63 @@
+// Copyright 2026 Princess B33f Heavy Industries / Dave Shanley
+// SPDX-License-Identifier: MIT
+
+package utils
+
+import "go.yaml.in/yaml/v4"
+
+// YAMLNodeCloneFlags configures CloneYAMLNodeWithFlags behavior.
+type YAMLNodeCloneFlags uint8
+
+const (
+ // YAMLNodeCloneStripAnchors removes anchor names from every cloned node.
+ YAMLNodeCloneStripAnchors YAMLNodeCloneFlags = 1 << iota
+
+ // YAMLNodeCloneUnwrapDocument clones the document node's first child instead
+ // of cloning the document node itself.
+ YAMLNodeCloneUnwrapDocument
+)
+
+// CloneYAMLNode returns a deep copy of a YAML node graph.
+func CloneYAMLNode(node *yaml.Node) *yaml.Node {
+ return CloneYAMLNodeWithFlags(node, 0)
+}
+
+// CloneYAMLNodeWithFlags returns a deep copy of a YAML node graph, applying the
+// supplied flags while cloning.
+func CloneYAMLNodeWithFlags(node *yaml.Node, flags YAMLNodeCloneFlags) *yaml.Node {
+ if node == nil {
+ return nil
+ }
+ if flags&YAMLNodeCloneUnwrapDocument != 0 && node.Kind == yaml.DocumentNode && len(node.Content) > 0 {
+ node = node.Content[0]
+ }
+ return cloneYAMLNode(node, flags, make(map[*yaml.Node]*yaml.Node, 8))
+}
+
+func cloneYAMLNode(node *yaml.Node, flags YAMLNodeCloneFlags, seen map[*yaml.Node]*yaml.Node) *yaml.Node {
+ if node == nil {
+ return nil
+ }
+ if cloned, ok := seen[node]; ok {
+ return cloned
+ }
+
+ cloned := *node
+ if flags&YAMLNodeCloneStripAnchors != 0 {
+ cloned.Anchor = ""
+ }
+ cloned.Alias = nil
+ cloned.Content = nil
+ seen[node] = &cloned
+
+ if node.Alias != nil {
+ cloned.Alias = cloneYAMLNode(node.Alias, flags, seen)
+ }
+ if len(node.Content) > 0 {
+ cloned.Content = make([]*yaml.Node, len(node.Content))
+ for i, child := range node.Content {
+ cloned.Content[i] = cloneYAMLNode(child, flags, seen)
+ }
+ }
+ return &cloned
+}
diff --git a/vendor/github.com/pb33f/libopenapi/utils/utils.go b/vendor/github.com/pb33f/libopenapi/utils/utils.go
index a7eb2ee8b..f903ce9a4 100644
--- a/vendor/github.com/pb33f/libopenapi/utils/utils.go
+++ b/vendor/github.com/pb33f/libopenapi/utils/utils.go
@@ -521,10 +521,10 @@ func FindKeyNode(key string, nodes []*yaml.Node) (keyNode *yaml.Node, valueNode
}
return NodeAlias(v), NodeAlias(nodes[i+1]) // next node is what we need.
}
- for x, j := range mergedNodeContent(v) {
+ content := mergedNodeContent(v)
+ for x, j := range content {
if key == j.Value {
if IsNodeMap(v) {
- content := mergedNodeContent(v)
if x+1 == len(content) {
return NodeAlias(v), NodeAlias(content[x])
}
@@ -532,7 +532,7 @@ func FindKeyNode(key string, nodes []*yaml.Node) (keyNode *yaml.Node, valueNode
}
if IsNodeArray(v) {
- return NodeAlias(v), NodeAlias(mergedNodeContent(v)[x])
+ return NodeAlias(v), NodeAlias(content[x])
}
}
}
@@ -960,43 +960,6 @@ func isPathChar(s string) bool {
return true
}
-func appendSegment(sb *strings.Builder, segs []string, cleaned []string, i int, wrapInQuotes bool) {
- sb.Reset()
- if wrapInQuotes {
- sb.WriteString("['")
- sb.WriteString(segs[i])
- sb.WriteString("']")
- } else {
- sb.WriteString("[")
- sb.WriteString(segs[i])
- sb.WriteString("]")
- }
- c := sb.String()
- sb.Reset()
- sb.WriteString(cleaned[len(cleaned)-1])
- sb.WriteString(c)
- cleaned[len(cleaned)-1] = sb.String()
-}
-
-// appendSegmentOptimized uses strings.Builder more efficiently to avoid allocations
-func appendSegmentOptimized(segs []string, cleaned []string, i int, wrapInQuotes bool) {
- var builder strings.Builder
- if wrapInQuotes {
- builder.Grow(len(cleaned[len(cleaned)-1]) + len(segs[i]) + 4) // existing + [''] + segment
- builder.WriteString(cleaned[len(cleaned)-1])
- builder.WriteString("['")
- builder.WriteString(segs[i])
- builder.WriteString("']")
- } else {
- builder.Grow(len(cleaned[len(cleaned)-1]) + len(segs[i]) + 2) // existing + [] + segment
- builder.WriteString(cleaned[len(cleaned)-1])
- builder.WriteByte('[')
- builder.WriteString(segs[i])
- builder.WriteByte(']')
- }
- cleaned[len(cleaned)-1] = builder.String()
-}
-
// parseSmallUint returns the unsigned integer value and true if s is a string of
// digits representing a non-negative integer. Returns 0, false otherwise.
func parseSmallUint(s string) (int, bool) {
@@ -1016,15 +979,16 @@ func parseSmallUint(s string) (int, bool) {
// ConvertComponentIdIntoFriendlyPathSearch will convert a JSON Path into a friendly path search string.
// the friendliness comes from it being suitable for use with any JSON Path parser.
//
-// This function was re-written in v0.18.0 in order to fix a number of performance issues with the original
-// implementation. Allocations were high and this function is used a lot, this new implementation is much
-// lighter on string allocations by using a string builder.
+// Rewritten as a single pass over the input with one output builder: no segment slice,
+// no per-segment builders. Output is byte-identical to the previous implementation and
+// is pinned by the golden corpus in testdata/component_id_golden.txt.
func ConvertComponentIdIntoFriendlyPathSearch(id string) (string, string) {
if id == "" || id == "#/" {
return "", "$."
}
- segs := strings.Split(id, "/")
- lastSeg := segs[len(segs)-1]
+
+ // the name is the raw final segment, JSON-Pointer unescaped and URL decoded.
+ lastSeg := id[strings.LastIndexByte(id, '/')+1:]
if strings.Contains(lastSeg, "~1") {
lastSeg = strings.ReplaceAll(lastSeg, "~1", "/")
}
@@ -1033,151 +997,125 @@ func ConvertComponentIdIntoFriendlyPathSearch(id string) (string, string) {
}
name := lastSeg
- // Pre-allocate with estimated capacity
- estimatedCap := len(segs) + (len(segs) / 2)
- cleaned := make([]string, 0, estimatedCap)
+ idContainsHash := strings.Contains(id, "#")
+ lastIndex := strings.Count(id, "/") // absolute index of the final segment
- // check for strange spaces, chars and if found, wrap them up, clean them and create a new cleaned path.
- for i := range segs {
- if segs[i] == "" {
+ // note: we do NOT replace # with $ here. the leading # from JSON Pointer notation
+ // (e.g., "#/components/...") is dropped by the leading-segment rule, and any #
+ // characters within component names (e.g., "async_search.submit#wait_for_completion_timeout")
+ // should be preserved literally in the JSONPath query. see issue #485.
+ var b strings.Builder
+ b.Grow(len(id) + 16)
+ b.WriteString("$.")
+ elements := 0
+
+ // the plural-parent rule reads the previous segment as transformed by its own
+ // iteration (bracket-wrapped segments end in ']', stripped segments may shrink),
+ // so track what the previous segment ended up as, not what it started as.
+ prevNonEmpty := false
+ prevEndsInS := false
+
+ pos := 0
+ for i := 0; pos <= len(id); i++ {
+ var seg string
+ if next := strings.IndexByte(id[pos:], '/'); next >= 0 {
+ seg = id[pos : pos+next]
+ pos += next + 1
+ } else {
+ seg = id[pos:]
+ pos = len(id) + 1
+ }
+
+ if seg == "" {
+ prevNonEmpty = false
+ prevEndsInS = false
continue
}
- if !isPathChar(segs[i]) {
+ isLast := i == lastIndex
- if strings.Contains(segs[i], "~1") {
- segs[i] = strings.ReplaceAll(segs[i], "~1", "/")
+ if !isPathChar(seg) {
+ t := seg
+ if strings.Contains(t, "~1") {
+ t = strings.ReplaceAll(t, "~1", "/")
}
- if strings.ContainsRune(segs[i], '%') {
- segs[i], _ = url.QueryUnescape(segs[i])
+ if strings.ContainsRune(t, '%') {
+ t, _ = url.QueryUnescape(t)
}
-
- // Use string builder for bracket wrapping
- var bracketBuilder strings.Builder
- bracketBuilder.Grow(len(segs[i]) + 4)
- bracketBuilder.WriteString("['")
- bracketBuilder.WriteString(segs[i])
- bracketBuilder.WriteString("']")
- segs[i] = bracketBuilder.String()
-
- if len(cleaned) > 0 && i < len(segs)-1 {
- // Use string builder for concatenation with last cleaned element
- var concatBuilder strings.Builder
- concatBuilder.Grow(len(cleaned[len(cleaned)-1]) + len(segs[i]))
- concatBuilder.WriteString(cleaned[len(cleaned)-1])
- concatBuilder.WriteString(segs[i])
- cleaned[len(cleaned)-1] = concatBuilder.String()
+ // the transformed segment is bracket-wrapped: never empty, ends in ']'.
+ prevNonEmpty = true
+ prevEndsInS = false
+ if i == 0 && !isLast {
+ // a leading non-path segment (like the '#' of a JSON Pointer) is dropped.
continue
- } else {
- if i > 0 && i < len(segs)-1 {
- cleaned = append(cleaned, segs[i])
- continue
- }
- if i == len(segs)-1 {
- l := len(cleaned)
- if l > 0 {
- // Use string builder for concatenation
- var endBuilder strings.Builder
- endBuilder.Grow(len(cleaned[l-1]) + len(segs[i]))
- endBuilder.WriteString(cleaned[l-1])
- endBuilder.WriteString(segs[i])
- cleaned[l-1] = endBuilder.String()
- } else {
- cleaned = append(cleaned, segs[i])
- }
- }
}
- } else {
+ if elements == 0 {
+ elements++ // becomes the first element, no separator needed
+ }
+ b.WriteString("['")
+ b.WriteString(t)
+ b.WriteString("']")
+ continue
+ }
- // strip out any backslashes
- if strings.Contains(id, "#") && strings.Contains(segs[i], `\`) {
- segs[i] = strings.ReplaceAll(segs[i], `\`, "")
- cleaned = append(cleaned, segs[i])
- continue
+ // strip out any backslashes
+ if idContainsHash && strings.Contains(seg, `\`) {
+ t := strings.ReplaceAll(seg, `\`, "")
+ if elements > 0 {
+ b.WriteByte('.')
}
+ b.WriteString(t)
+ elements++
+ prevNonEmpty = t != ""
+ prevEndsInS = t != "" && t[len(t)-1] == 's'
+ continue
+ }
- intVal, isNum := parseSmallUint(segs[i])
- if isNum {
+ if intVal, isNum := parseSmallUint(seg); isNum {
+ // an index with no preceding element is dropped.
+ if elements > 0 {
if intVal <= 99 {
- if len(cleaned) > 0 {
- appendSegmentOptimized(segs, cleaned, i, false)
- }
+ b.WriteByte('[')
+ b.WriteString(seg)
+ b.WriteByte(']')
} else {
- if len(cleaned) > 0 {
- appendSegmentOptimized(segs, cleaned, i, true)
- }
+ b.WriteString("['")
+ b.WriteString(seg)
+ b.WriteString("']")
}
- continue
}
+ prevNonEmpty = true
+ prevEndsInS = false
+ continue
+ }
- // if we have a plural parent, wrap it in quotes.
- if i > 0 && segs[i-1] != "" && segs[i-1][len(segs[i-1])-1] == 's' {
- if i == 2 { // ignore first segment.
- cleaned = append(cleaned, segs[i])
- continue
+ // if we have a plural parent, wrap it in quotes.
+ if i > 0 && prevNonEmpty && prevEndsInS {
+ prevNonEmpty = true
+ prevEndsInS = seg[len(seg)-1] == 's'
+ if i == 2 { // ignore first segment.
+ if elements > 0 {
+ b.WriteByte('.')
}
-
- // Use string builder for plural wrapping
- var pluralBuilder strings.Builder
- pluralBuilder.Grow(len(cleaned[len(cleaned)-1]) + len(segs[i]) + 4)
- pluralBuilder.WriteString(cleaned[len(cleaned)-1])
- pluralBuilder.WriteString("['")
- pluralBuilder.WriteString(segs[i])
- pluralBuilder.WriteString("']")
- cleaned[len(cleaned)-1] = pluralBuilder.String()
+ b.WriteString(seg)
+ elements++
continue
}
-
- cleaned = append(cleaned, segs[i])
- }
- }
-
- // use single string builder for final assembly.
- // note: we do NOT replace # with $ here. the leading # from JSON Pointer notation
- // (e.g., "#/components/...") is already stripped when we split by "/", and any #
- // characters within component names (e.g., "async_search.submit#wait_for_completion_timeout")
- // should be preserved literally in the JSONPath query. see issue #485.
- var finalBuilder strings.Builder
- if len(cleaned) > 1 {
- // Estimate final size
- totalLen := 0
- for _, seg := range cleaned {
- totalLen += len(seg)
+ b.WriteString("['")
+ b.WriteString(seg)
+ b.WriteString("']")
+ continue
}
- finalBuilder.Grow(totalLen + len(cleaned) + 5) // segments + dots + $ + potential extra .
- finalBuilder.WriteByte('$')
- for i, segment := range cleaned {
- if i > 0 {
- finalBuilder.WriteByte('.')
- }
- finalBuilder.WriteString(segment)
- }
- } else {
- // Handle single segment case
- if len(cleaned) == 1 {
- finalBuilder.Grow(len(cleaned[0]) + 5)
- finalBuilder.WriteString("$.")
- finalBuilder.WriteString(cleaned[0])
- } else {
- finalBuilder.WriteString("$.")
+ if elements > 0 {
+ b.WriteByte('.')
}
+ b.WriteString(seg)
+ elements++
+ prevNonEmpty = true
+ prevEndsInS = seg[len(seg)-1] == 's'
}
- replaced := finalBuilder.String()
-
- // Ensure proper format
- if len(replaced) > 0 {
- if len(replaced) > 1 && replaced[1] != '.' {
- // Insert period after $
- var dotBuilder strings.Builder
- dotBuilder.Grow(len(replaced) + 1)
- dotBuilder.WriteByte(replaced[0]) // $
- dotBuilder.WriteByte('.') // .
- dotBuilder.WriteString(replaced[1:])
- replaced = dotBuilder.String()
- }
- }
- return name, replaced
+ return name, b.String()
}
// ConvertComponentIdIntoPath will convert a JSON Path into a component ID
diff --git a/vendor/github.com/pb33f/libopenapi/what-changed/model/breaking_rules_config.go b/vendor/github.com/pb33f/libopenapi/what-changed/model/breaking_rules_config.go
index b18834718..e673d4187 100644
--- a/vendor/github.com/pb33f/libopenapi/what-changed/model/breaking_rules_config.go
+++ b/vendor/github.com/pb33f/libopenapi/what-changed/model/breaking_rules_config.go
@@ -246,6 +246,10 @@ func buildValidComponentSet() map[string]bool {
// just "discriminator" at the top level) and returns all validation errors found.
// Returns nil if the configuration is valid.
func ValidateBreakingRulesConfigYAML(yamlBytes []byte) *ConfigValidationResult {
+ if len(strings.TrimSpace(string(yamlBytes))) == 0 {
+ return nil
+ }
+
var rootNode yaml.Node
if err := yaml.Unmarshal(yamlBytes, &rootNode); err != nil {
return &ConfigValidationResult{
diff --git a/vendor/github.com/pb33f/libopenapi/what-changed/model/comparison_functions.go b/vendor/github.com/pb33f/libopenapi/what-changed/model/comparison_functions.go
index 824e13848..27c0558ec 100644
--- a/vendor/github.com/pb33f/libopenapi/what-changed/model/comparison_functions.go
+++ b/vendor/github.com/pb33f/libopenapi/what-changed/model/comparison_functions.go
@@ -4,6 +4,7 @@
package model
import (
+ "bytes"
"fmt"
"reflect"
"strings"
@@ -412,10 +413,9 @@ func checkForAdditionInternal[T any](l, r *yaml.Node, label string, changes *[]*
if withEncoding {
createFn = CreateChangeWithEncoding
}
- // left doesn't exist if: nil OR (empty scalar AND not a map/array) OR (empty map/array)
+ // left doesn't exist if: nil OR an empty scalar. Empty maps and arrays are real values.
leftDoesNotExist := l == nil ||
- (l.Value == EMPTY_STR && !utils.IsNodeMap(l) && !utils.IsNodeArray(l)) ||
- ((utils.IsNodeMap(l) || utils.IsNodeArray(l)) && len(l.Content) == 0)
+ (l.Value == EMPTY_STR && !utils.IsNodeMap(l) && !utils.IsNodeArray(l))
// right exists if: not nil AND (has value OR is array OR is map)
rightExists := r != nil && (r.Value != EMPTY_STR || utils.IsNodeArray(r) || utils.IsNodeMap(r))
@@ -441,7 +441,7 @@ func checkForModificationInternal[T any](l, r *yaml.Node, label string, changes
createFn = CreateChangeWithEncoding
}
if l != nil && l.Value != EMPTY_STR && r != nil && r.Value != EMPTY_STR {
- if !low.CompareYAMLNodes(l, r) {
+ if !compareYAMLNodesForChanges(l, r) {
createFn(changes, Modified, label, l, r, breaking, orig, new)
}
return
@@ -469,20 +469,35 @@ func checkForModificationInternal[T any](l, r *yaml.Node, label string, changes
}
// Compare the YAML node trees directly without marshaling
- if !low.CompareYAMLNodes(l, r) {
+ if !compareYAMLNodesForChanges(l, r) {
createFn(changes, Modified, label, l, r, breaking, orig, new)
}
return
}
if l != nil && utils.IsNodeMap(l) && r != nil && utils.IsNodeMap(r) {
// Compare the YAML node trees directly without marshaling
- if !low.CompareYAMLNodes(l, r) {
+ if !compareYAMLNodesForChanges(l, r) {
createFn(changes, Modified, label, l, r, breaking, orig, new)
}
return
}
}
+func compareYAMLNodesForChanges(left, right *yaml.Node) bool {
+ if low.CompareYAMLNodes(left, right) {
+ return true
+ }
+ leftClone := utils.CloneYAMLNodeWithFlags(left, utils.YAMLNodeCloneStripAnchors)
+ rightClone := utils.CloneYAMLNodeWithFlags(right, utils.YAMLNodeCloneStripAnchors)
+ if low.CompareYAMLNodes(leftClone, rightClone) {
+ return true
+ }
+
+ leftBytes, leftErr := yaml.Marshal(leftClone)
+ rightBytes, rightErr := yaml.Marshal(rightClone)
+ return leftErr == nil && rightErr == nil && bytes.Equal(leftBytes, rightBytes)
+}
+
// CheckForModification will check left and right yaml.Node instances for changes. Anything that is found in both
// sides, but vary in value is considered a modification.
//
diff --git a/vendor/github.com/pb33f/libopenapi/what-changed/model/example.go b/vendor/github.com/pb33f/libopenapi/what-changed/model/example.go
index 8e6ea7306..35a8cf223 100644
--- a/vendor/github.com/pb33f/libopenapi/what-changed/model/example.go
+++ b/vendor/github.com/pb33f/libopenapi/what-changed/model/example.go
@@ -84,61 +84,63 @@ func CompareExamples(l, r *base.Example) *ExampleChanges {
// Value
if utils.IsNodeMap(l.Value.ValueNode) && utils.IsNodeMap(r.Value.ValueNode) {
- lKeys := make([]string, len(l.Value.ValueNode.Content)/2)
- rKeys := make([]string, len(r.Value.ValueNode.Content)/2)
- z := 0
- for k := range l.Value.ValueNode.Content {
- if k%2 == 0 {
- // if there is no value (value is another map or something else), render the node into yaml and hash it.
- // https://github.com/pb33f/libopenapi/issues/61
- val := l.Value.ValueNode.Content[k+1].Value
- if val == "" {
- val = low.HashYAMLNodeSlice(l.Value.ValueNode.Content[k+1].Content)
+ if !compareYAMLNodesForChanges(l.Value.ValueNode, r.Value.ValueNode) {
+ lKeys := make([]string, len(l.Value.ValueNode.Content)/2)
+ rKeys := make([]string, len(r.Value.ValueNode.Content)/2)
+ z := 0
+ for k := range l.Value.ValueNode.Content {
+ if k%2 == 0 {
+ // if there is no value (value is another map or something else), render the node into yaml and hash it.
+ // https://github.com/pb33f/libopenapi/issues/61
+ val := l.Value.ValueNode.Content[k+1].Value
+ if val == "" {
+ val = low.HashYAMLNodeSlice(l.Value.ValueNode.Content[k+1].Content)
+ }
+ lKeys[z] = fmt.Sprintf("%v-%v-%v",
+ l.Value.ValueNode.Content[k].Value,
+ l.Value.ValueNode.Content[k+1].Tag,
+ fmt.Sprintf("%x", val))
+ z++
+ } else {
+ continue
}
- lKeys[z] = fmt.Sprintf("%v-%v-%v",
- l.Value.ValueNode.Content[k].Value,
- l.Value.ValueNode.Content[k+1].Tag,
- fmt.Sprintf("%x", val))
- z++
- } else {
- continue
}
- }
- z = 0
- for k := range r.Value.ValueNode.Content {
- if k%2 == 0 {
- // if there is no value (value is another map or something else), render the node into yaml and hash it.
- // https://github.com/pb33f/libopenapi/issues/61
- val := r.Value.ValueNode.Content[k+1].Value
- if val == "" {
- val = low.HashYAMLNodeSlice(r.Value.ValueNode.Content[k+1].Content)
+ z = 0
+ for k := range r.Value.ValueNode.Content {
+ if k%2 == 0 {
+ // if there is no value (value is another map or something else), render the node into yaml and hash it.
+ // https://github.com/pb33f/libopenapi/issues/61
+ val := r.Value.ValueNode.Content[k+1].Value
+ if val == "" {
+ val = low.HashYAMLNodeSlice(r.Value.ValueNode.Content[k+1].Content)
+ }
+ rKeys[z] = fmt.Sprintf("%v-%v-%v",
+ r.Value.ValueNode.Content[k].Value,
+ r.Value.ValueNode.Content[k+1].Tag,
+ fmt.Sprintf("%x", val))
+ z++
+ } else {
+ continue
}
- rKeys[z] = fmt.Sprintf("%v-%v-%v",
- r.Value.ValueNode.Content[k].Value,
- r.Value.ValueNode.Content[k+1].Tag,
- fmt.Sprintf("%x", val))
- z++
- } else {
- continue
- }
- }
- sort.Strings(lKeys)
- sort.Strings(rKeys)
- for k := range lKeys {
- if k < len(rKeys) && lKeys[k] != rKeys[k] {
- CreateChangeWithEncoding(&changes, Modified, v3.ValueLabel,
- l.Value.GetValueNode(), r.Value.GetValueNode(), BreakingModified(CompExample, PropValue), l.Value.GetValue(), r.Value.GetValue())
- continue
}
- if k >= len(rKeys) {
- CreateChangeWithEncoding(&changes, PropertyRemoved, v3.ValueLabel,
- l.Value.ValueNode, r.Value.ValueNode, BreakingRemoved(CompExample, PropValue), l.Value.Value, r.Value.Value)
+ sort.Strings(lKeys)
+ sort.Strings(rKeys)
+ for k := range lKeys {
+ if k < len(rKeys) && lKeys[k] != rKeys[k] {
+ CreateChangeWithEncoding(&changes, Modified, v3.ValueLabel,
+ l.Value.GetValueNode(), r.Value.GetValueNode(), BreakingModified(CompExample, PropValue), l.Value.GetValue(), r.Value.GetValue())
+ continue
+ }
+ if k >= len(rKeys) {
+ CreateChangeWithEncoding(&changes, PropertyRemoved, v3.ValueLabel,
+ l.Value.ValueNode, r.Value.ValueNode, BreakingRemoved(CompExample, PropValue), l.Value.Value, r.Value.Value)
+ }
}
- }
- for k := range rKeys {
- if k >= len(lKeys) {
- CreateChangeWithEncoding(&changes, PropertyAdded, v3.ValueLabel,
- l.Value.ValueNode, r.Value.ValueNode, BreakingAdded(CompExample, PropValue), l.Value.Value, r.Value.Value)
+ for k := range rKeys {
+ if k >= len(lKeys) {
+ CreateChangeWithEncoding(&changes, PropertyAdded, v3.ValueLabel,
+ l.Value.ValueNode, r.Value.ValueNode, BreakingAdded(CompExample, PropValue), l.Value.Value, r.Value.Value)
+ }
}
}
} else {
diff --git a/vendor/github.com/prometheus/client_golang/exp/api/remote/remote_api.go b/vendor/github.com/prometheus/client_golang/exp/api/remote/remote_api.go
index d8cc86a74..8a1a9fdba 100644
--- a/vendor/github.com/prometheus/client_golang/exp/api/remote/remote_api.go
+++ b/vendor/github.com/prometheus/client_golang/exp/api/remote/remote_api.go
@@ -458,12 +458,6 @@ const maxDecodedSize = 32 * 1024 * 1024
// If the request body is not snappy-encoded, it returns an error.
// Used by default in NewHandler.
func SnappyDecodeMiddleware(logger *slog.Logger) func(http.Handler) http.Handler {
- bufPool := sync.Pool{
- New: func() any {
- return bytes.NewBuffer(nil)
- },
- }
-
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
enc := r.Header.Get("Content-Encoding")
@@ -474,16 +468,17 @@ func SnappyDecodeMiddleware(logger *slog.Logger) func(http.Handler) http.Handler
return
}
- buf := bufPool.Get().(*bytes.Buffer)
- buf.Reset()
- defer bufPool.Put(buf)
-
- bodyBytes, err := io.ReadAll(io.TeeReader(r.Body, buf))
+ bodyBytes, err := io.ReadAll(io.LimitReader(r.Body, maxDecodedSize+1))
if err != nil {
logger.Error("Error reading request body", "err", err)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
+ if int64(len(bodyBytes)) > maxDecodedSize {
+ logger.Error("Request body exceeds the limit", "limitBytes", maxDecodedSize)
+ http.Error(w, fmt.Sprintf("request body exceeds the %v bytes limit", maxDecodedSize), http.StatusRequestEntityTooLarge)
+ return
+ }
decodedSize, err := snappy.DecodedLen(bodyBytes)
if err != nil {
diff --git a/vendor/github.com/prometheus/common/config/config.go b/vendor/github.com/prometheus/common/config/config.go
index ff54cdd82..d0040763e 100644
--- a/vendor/github.com/prometheus/common/config/config.go
+++ b/vendor/github.com/prometheus/common/config/config.go
@@ -33,7 +33,7 @@ type Secret string
var MarshalSecretValue = false
// MarshalYAML implements the yaml.Marshaler interface for Secrets.
-func (s Secret) MarshalYAML() (interface{}, error) {
+func (s Secret) MarshalYAML() (any, error) {
if MarshalSecretValue {
return string(s), nil
}
@@ -44,7 +44,7 @@ func (s Secret) MarshalYAML() (interface{}, error) {
}
// UnmarshalYAML implements the yaml.Unmarshaler interface for Secrets.
-func (s *Secret) UnmarshalYAML(unmarshal func(interface{}) error) error {
+func (s *Secret) UnmarshalYAML(unmarshal func(any) error) error {
type plain Secret
return unmarshal((*plain)(s))
}
diff --git a/vendor/github.com/prometheus/common/config/http_config.go b/vendor/github.com/prometheus/common/config/http_config.go
index 55cc5b077..88457375f 100644
--- a/vendor/github.com/prometheus/common/config/http_config.go
+++ b/vendor/github.com/prometheus/common/config/http_config.go
@@ -22,6 +22,7 @@ import (
"encoding/json"
"errors"
"fmt"
+ "maps"
"net"
"net/http"
"net/url"
@@ -76,7 +77,7 @@ var TLSVersions = map[string]TLSVersion{
"TLS10": (TLSVersion)(tls.VersionTLS10),
}
-func (tv *TLSVersion) UnmarshalYAML(unmarshal func(interface{}) error) error {
+func (tv *TLSVersion) UnmarshalYAML(unmarshal func(any) error) error {
var s string
err := unmarshal(&s)
if err != nil {
@@ -89,7 +90,7 @@ func (tv *TLSVersion) UnmarshalYAML(unmarshal func(interface{}) error) error {
return fmt.Errorf("unknown TLS version: %s", s)
}
-func (tv TLSVersion) MarshalYAML() (interface{}, error) {
+func (tv TLSVersion) MarshalYAML() (any, error) {
for s, v := range TLSVersions {
if tv == v {
return s, nil
@@ -178,7 +179,7 @@ type URL struct {
}
// UnmarshalYAML implements the yaml.Unmarshaler interface for URLs.
-func (u *URL) UnmarshalYAML(unmarshal func(interface{}) error) error {
+func (u *URL) UnmarshalYAML(unmarshal func(any) error) error {
var s string
if err := unmarshal(&s); err != nil {
return err
@@ -193,7 +194,7 @@ func (u *URL) UnmarshalYAML(unmarshal func(interface{}) error) error {
}
// MarshalYAML implements the yaml.Marshaler interface for URLs.
-func (u URL) MarshalYAML() (interface{}, error) {
+func (u URL) MarshalYAML() (any, error) {
if u.URL != nil {
return u.Redacted(), nil
}
@@ -269,16 +270,16 @@ type OAuth2 struct {
Audience string `yaml:"audience,omitempty" json:"audience,omitempty"`
// Claims is a map of claims to be added to the JWT token. Only used if
// GrantType is set to "urn:ietf:params:oauth:grant-type:jwt-bearer".
- Claims map[string]interface{} `yaml:"claims,omitempty" json:"claims,omitempty"`
- Scopes []string `yaml:"scopes,omitempty" json:"scopes,omitempty"`
- TokenURL string `yaml:"token_url,omitempty" json:"token_url,omitempty"`
- EndpointParams map[string]string `yaml:"endpoint_params,omitempty" json:"endpoint_params,omitempty"`
- TLSConfig TLSConfig `yaml:"tls_config,omitempty"`
+ Claims map[string]any `yaml:"claims,omitempty" json:"claims,omitempty"`
+ Scopes []string `yaml:"scopes,omitempty" json:"scopes,omitempty"`
+ TokenURL string `yaml:"token_url,omitempty" json:"token_url,omitempty"`
+ EndpointParams map[string]string `yaml:"endpoint_params,omitempty" json:"endpoint_params,omitempty"`
+ TLSConfig TLSConfig `yaml:"tls_config,omitempty"`
ProxyConfig `yaml:",inline"`
}
// UnmarshalYAML implements the yaml.Unmarshaler interface.
-func (o *OAuth2) UnmarshalYAML(unmarshal func(interface{}) error) error {
+func (o *OAuth2) UnmarshalYAML(unmarshal func(any) error) error {
type plain OAuth2
if err := unmarshal((*plain)(o)); err != nil {
return err
@@ -324,7 +325,7 @@ func LoadHTTPConfigFile(filename string) (*HTTPClientConfig, []byte, error) {
if err != nil {
return nil, nil, err
}
- cfg.SetDirectory(filepath.Dir(filepath.Dir(filename)))
+ cfg.SetDirectory(filepath.Dir(filename))
return cfg, content, nil
}
@@ -463,7 +464,7 @@ func (c *HTTPClientConfig) Validate() error {
}
// UnmarshalYAML implements the yaml.Unmarshaler interface.
-func (c *HTTPClientConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
+func (c *HTTPClientConfig) UnmarshalYAML(unmarshal func(any) error) error {
type plain HTTPClientConfig
*c = DefaultHTTPClientConfig
if err := unmarshal((*plain)(c)); err != nil {
@@ -483,7 +484,7 @@ func (c *HTTPClientConfig) UnmarshalJSON(data []byte) error {
}
// UnmarshalYAML implements the yaml.Unmarshaler interface.
-func (a *BasicAuth) UnmarshalYAML(unmarshal func(interface{}) error) error {
+func (a *BasicAuth) UnmarshalYAML(unmarshal func(any) error) error {
type plain BasicAuth
return unmarshal((*plain)(a))
}
@@ -717,10 +718,18 @@ func NewRoundTripperFromConfigWithContext(ctx context.Context, cfg HTTPClientCon
return nil, fmt.Errorf("unable to use client secret: %w", err)
}
}
- rt = NewOAuth2RoundTripper(oauthCredential, cfg.OAuth2, rt, &opts)
+ rt = NewOAuth2RoundTripper(oauthCredential, cfg.OAuth2, rt, optFuncs...)
}
if cfg.HTTPHeaders != nil {
+ // Strip sensitive headers added by headersRoundTripper on cross-host
+ // redirects before they reach the transport. Only needed when
+ // redirects are actually followed; when FollowRedirects is false
+ // CheckRedirect returns ErrUseLastResponse immediately so there are
+ // no subsequent requests.
+ if cfg.FollowRedirects {
+ rt = &sensitiveHeadersStripRT{next: rt}
+ }
rt = NewHeadersRoundTripper(cfg.HTTPHeaders, rt)
}
@@ -862,7 +871,7 @@ func NewAuthorizationCredentialsRoundTripper(authType string, authCredentials Se
}
func (rt *authorizationCredentialsRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
- if len(req.Header.Get("Authorization")) != 0 {
+ if len(req.Header.Get("Authorization")) != 0 || isCrossHostRedirect(req) {
return rt.rt.RoundTrip(req)
}
@@ -900,7 +909,7 @@ func NewBasicAuthRoundTripper(username, password SecretReader, rt http.RoundTrip
}
func (rt *basicAuthRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
- if len(req.Header.Get("Authorization")) != 0 {
+ if len(req.Header.Get("Authorization")) != 0 || isCrossHostRedirect(req) {
return rt.rt.RoundTrip(req)
}
var username string
@@ -942,16 +951,26 @@ type oauth2RoundTripper struct {
client *http.Client
}
-func NewOAuth2RoundTripper(oauthCredential SecretReader, config *OAuth2, next http.RoundTripper, opts *httpClientOptions) http.RoundTripper {
+// NewOAuth2RoundTripper returns a round tripper that performs OAuth2
+// authentication. The opts variadic parameter accepts any HTTPClientOption
+// (e.g. WithDialContextFunc, WithKeepAlivesDisabled) so that callers outside
+// this package can fully configure the transport without needing access to the
+// unexported *httpClientOptions type.
+func NewOAuth2RoundTripper(oauthCredential SecretReader, config *OAuth2, next http.RoundTripper, optFuncs ...HTTPClientOption) http.RoundTripper {
if oauthCredential == nil {
oauthCredential = NewInlineSecret("")
}
+ opts := defaultHTTPClientOptions
+ for _, opt := range optFuncs {
+ opt.applyToHTTPClientOptions(&opts)
+ }
+
return &oauth2RoundTripper{
config: config,
// A correct tokenSource will be added later on.
lastRT: &oauth2.Transport{Base: next},
- opts: opts,
+ opts: &opts,
oauthCredential: oauthCredential,
}
}
@@ -977,6 +996,7 @@ func (rt *oauth2RoundTripper) newOauth2TokenSource(req *http.Request, clientCred
IdleConnTimeout: 10 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
+ DialContext: rt.opts.dialContextFunc,
}, nil
}
@@ -1048,11 +1068,29 @@ func (rt *oauth2RoundTripper) newOauth2TokenSource(req *http.Request, clientCred
}
func (rt *oauth2RoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
+ if isCrossHostRedirect(req) {
+ // Bypass the OAuth2 transport so no token is attached. Read Base under
+ // the lock to avoid a data race with concurrent reconfigurations.
+ rt.mtx.RLock()
+ base := rt.lastRT.Base
+ rt.mtx.RUnlock()
+ if base == nil {
+ base = http.DefaultTransport
+ }
+ return base.RoundTrip(req)
+ }
+
var (
secret string
needsInit bool
)
+ // This should not happen when config goes through the normal Prometheus
+ // validation path, but guard against a nil credential to avoid a panic.
+ if rt.oauthCredential == nil {
+ return nil, errors.New("oauth2 client secret is required")
+ }
+
rt.mtx.RLock()
secret = rt.lastSecret
needsInit = rt.lastRT.Source == nil
@@ -1106,6 +1144,98 @@ func mapToValues(m map[string]string) url.Values {
return v
}
+// isCrossHostRedirect reports whether req is a redirect that has left the
+// original request's host at any point in the chain. It detects this by walking
+// the req.Response chain (which Go's HTTP client populates on every redirect
+// hop) to find the original request's hostname, then checking every hop in the
+// chain against it.
+//
+// The decision is sticky, mirroring net/http: once any hop leaves the original
+// host's domain, credentials and sensitive headers stay stripped for the rest
+// of the chain, even if a later hop redirects back to the original host.
+//
+// This works regardless of whether the caller uses NewClientFromConfig or a
+// custom http.Client built from NewRoundTripperFromConfigWithContext directly.
+func isCrossHostRedirect(req *http.Request) bool {
+ if req.Response == nil {
+ return false
+ }
+ originalHost := strings.ToLower(originalRequestHost(req))
+ for r := req; r.Response != nil && r.Response.Request != nil; r = r.Response.Request {
+ if !isDomainOrSubdomain(strings.ToLower(r.URL.Hostname()), originalHost) {
+ return true
+ }
+ }
+ return false
+}
+
+func originalRequestHost(req *http.Request) string {
+ r := req
+ for r.Response != nil && r.Response.Request != nil {
+ r = r.Response.Request
+ }
+ return r.URL.Hostname()
+}
+
+// sensitiveHeadersOnRedirect lists the headers that must not be forwarded when
+// following a redirect to a different host. The first four entries match the
+// list stripped by makeHeadersCopier in net/http/client.go; we additionally
+// strip the Proxy-* headers, which net/http does not, to avoid leaking proxy
+// credentials to an untrusted host.
+var sensitiveHeadersOnRedirect = map[string]struct{}{
+ "Authorization": {},
+ // "Www-Authenticate" is the canonical form produced by
+ // textproto.CanonicalMIMEHeaderKey; it is not a typo of "WWW-Authenticate".
+ "Www-Authenticate": {},
+ "Cookie": {},
+ "Cookie2": {},
+ "Proxy-Authorization": {},
+ "Proxy-Authenticate": {},
+}
+
+// sensitiveHeadersStripRT strips sensitive headers from requests marked as
+// cross-host redirects before passing them to the underlying transport.
+type sensitiveHeadersStripRT struct {
+ next http.RoundTripper
+}
+
+func (rt *sensitiveHeadersStripRT) RoundTrip(req *http.Request) (*http.Response, error) {
+ if isCrossHostRedirect(req) {
+ req = cloneRequest(req)
+ for h := range sensitiveHeadersOnRedirect {
+ req.Header.Del(h)
+ }
+ }
+ return rt.next.RoundTrip(req)
+}
+
+func (rt *sensitiveHeadersStripRT) CloseIdleConnections() {
+ if ci, ok := rt.next.(closeIdler); ok {
+ ci.CloseIdleConnections()
+ }
+}
+
+// isDomainOrSubdomain reports whether sub is a subdomain (or exact match) of
+// parent. It mirrors isDomainOrSubdomain from net/http/client.go.
+func isDomainOrSubdomain(sub, parent string) bool {
+ if parent == "" {
+ return false
+ }
+ if sub == parent {
+ return true
+ }
+ // A colon means sub is an IPv6 address; a percent sign introduces an IPv6
+ // zone ID. Neither can be a hostname, and both could otherwise pass the
+ // suffix check below (e.g. "::1%.www.example.com" ends with "example.com").
+ if strings.ContainsAny(sub, ":%") {
+ return false
+ }
+ if !strings.HasSuffix(sub, parent) {
+ return false
+ }
+ return sub[len(sub)-len(parent)-1] == '.'
+}
+
// cloneRequest returns a clone of the provided *http.Request.
// The clone is a shallow copy of the struct and its Header map.
func cloneRequest(r *http.Request) *http.Request {
@@ -1113,10 +1243,7 @@ func cloneRequest(r *http.Request) *http.Request {
r2 := new(http.Request)
*r2 = *r
// Deep copy of the Header.
- r2.Header = make(http.Header)
- for k, s := range r.Header {
- r2.Header[k] = s
- }
+ maps.Copy(r.Header, r2.Header)
return r2
}
@@ -1239,7 +1366,7 @@ func (c *TLSConfig) SetDirectory(dir string) {
}
// UnmarshalYAML implements the yaml.Unmarshaler interface.
-func (c *TLSConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
+func (c *TLSConfig) UnmarshalYAML(unmarshal func(any) error) error {
type plain TLSConfig
if err := unmarshal((*plain)(c)); err != nil {
return err
@@ -1460,7 +1587,7 @@ func (t *tlsRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
rt := t.rt
t.mtx.RUnlock()
if equal {
- // The CA cert hasn't changed, use the existing RoundTripper.
+ // The TLS materials (CA, cert, key) haven't changed, use the existing RoundTripper.
return rt.RoundTrip(req)
}
@@ -1468,10 +1595,7 @@ func (t *tlsRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
// The cert and key files are read separately by the client
// using GetClientCertificate.
tlsConfig := t.tlsConfig.Clone()
- if !updateRootCA(tlsConfig, caData) {
- if t.settings.CA == nil {
- return nil, errors.New("unable to use specified CA cert: none configured")
- }
+ if t.settings.CA != nil && !updateRootCA(tlsConfig, caData) {
return nil, fmt.Errorf("unable to use specified CA cert %s", t.settings.CA.Description())
}
rt, err = t.newRT(tlsConfig)
diff --git a/vendor/github.com/prometheus/common/config/oauth_assertion.go b/vendor/github.com/prometheus/common/config/oauth_assertion.go
index bf4bcb949..ba5ffb4dc 100644
--- a/vendor/github.com/prometheus/common/config/oauth_assertion.go
+++ b/vendor/github.com/prometheus/common/config/oauth_assertion.go
@@ -18,6 +18,7 @@ import (
"encoding/json"
"fmt"
"io"
+ "maps"
"net/http"
"net/url"
"strings"
@@ -133,9 +134,7 @@ func (js jwtSource) Token() (*oauth2.Token, error) {
claims["scope"] = scopes
}
- for k, v := range js.conf.PrivateClaims {
- claims[k] = v
- }
+ maps.Copy(claims, js.conf.PrivateClaims)
assertion := jwt.NewWithClaims(js.conf.SigningAlgorithm, claims)
if js.conf.PrivateKeyID != "" {
diff --git a/vendor/github.com/prometheus/common/expfmt/expfmt.go b/vendor/github.com/prometheus/common/expfmt/expfmt.go
index 4e4c13e72..10bf35708 100644
--- a/vendor/github.com/prometheus/common/expfmt/expfmt.go
+++ b/vendor/github.com/prometheus/common/expfmt/expfmt.go
@@ -122,7 +122,7 @@ func NewOpenMetricsFormat(version string) (Format, error) {
// removed.
func (f Format) WithEscapingScheme(s model.EscapingScheme) Format {
var terms []string
- for _, p := range strings.Split(string(f), ";") {
+ for p := range strings.SplitSeq(string(f), ";") {
toks := strings.Split(p, "=")
if len(toks) != 2 {
trimmed := strings.TrimSpace(p)
@@ -194,7 +194,7 @@ func (f Format) FormatType() FormatType {
// "escaping" term exists, that will be used. Otherwise, the global default will
// be returned.
func (f Format) ToEscapingScheme() model.EscapingScheme {
- for _, p := range strings.Split(string(f), ";") {
+ for p := range strings.SplitSeq(string(f), ";") {
toks := strings.Split(p, "=")
if len(toks) != 2 {
continue
diff --git a/vendor/github.com/prometheus/common/expfmt/openmetrics_create.go b/vendor/github.com/prometheus/common/expfmt/openmetrics_create.go
index 21b93bca3..0480e7af5 100644
--- a/vendor/github.com/prometheus/common/expfmt/openmetrics_create.go
+++ b/vendor/github.com/prometheus/common/expfmt/openmetrics_create.go
@@ -30,7 +30,6 @@ import (
type encoderOption struct {
withCreatedLines bool
- withUnit bool
}
type EncoderOption func(*encoderOption)
@@ -51,17 +50,6 @@ func WithCreatedLines() EncoderOption {
}
}
-// WithUnit is an EncoderOption enabling a set unit to be written to the output
-// and to be added to the metric name, if it's not there already, as a suffix.
-// Without opting in this way, the unit will not be added to the metric name and,
-// on top of that, the unit will not be passed onto the output, even if it
-// were declared in the *dto.MetricFamily struct, i.e. even if in.Unit !=nil.
-func WithUnit() EncoderOption {
- return func(t *encoderOption) {
- t.withUnit = true
- }
-}
-
// MetricFamilyToOpenMetrics converts a MetricFamily proto message into the
// OpenMetrics text format and writes the resulting lines to 'out'. It returns
// the number of bytes written and any error encountered. The output will have
@@ -99,15 +87,6 @@ func WithUnit() EncoderOption {
// its type will be set to `unknown` in that case to avoid invalid OpenMetrics
// output.
//
-// - According to the OM specs, the `# UNIT` line is optional, but if populated,
-// the unit has to be present in the metric name as its suffix:
-// (see https://github.com/prometheus/OpenMetrics/blob/v1.0.0/specification/OpenMetrics.md#unit).
-// However, in order to accommodate any potential scenario where such a change in the
-// metric name is not desirable, the users are here given the choice of either explicitly
-// opt in, in case they wish for the unit to be included in the output AND in the metric name
-// as a suffix (see the description of the WithUnit function above),
-// or not to opt in, in case they don't want for any of that to happen.
-//
// - No support for the following (optional) features: info type,
// stateset type, gaugehistogram type.
//
@@ -151,9 +130,6 @@ func MetricFamilyToOpenMetrics(out io.Writer, in *dto.MetricFamily, options ...E
if metricType == dto.MetricType_COUNTER && strings.HasSuffix(compliantName, "_total") {
compliantName = name[:len(name)-6]
}
- if toOM.withUnit && in.Unit != nil && !strings.HasSuffix(compliantName, "_"+*in.Unit) {
- compliantName = compliantName + "_" + *in.Unit
- }
// Comments, first HELP, then TYPE.
if in.Help != nil {
@@ -217,7 +193,7 @@ func MetricFamilyToOpenMetrics(out io.Writer, in *dto.MetricFamily, options ...E
if err != nil {
return written, err
}
- if toOM.withUnit && in.Unit != nil {
+ if in.Unit != nil {
n, err = w.WriteString("# UNIT ")
written += n
if err != nil {
diff --git a/vendor/github.com/prometheus/common/expfmt/text_create.go b/vendor/github.com/prometheus/common/expfmt/text_create.go
index 6b8978145..f4074ae9a 100644
--- a/vendor/github.com/prometheus/common/expfmt/text_create.go
+++ b/vendor/github.com/prometheus/common/expfmt/text_create.go
@@ -42,12 +42,12 @@ const (
var (
bufPool = sync.Pool{
- New: func() interface{} {
+ New: func() any {
return bufio.NewWriter(io.Discard)
},
}
numBufPool = sync.Pool{
- New: func() interface{} {
+ New: func() any {
b := make([]byte, 0, initialNumBufSize)
return &b
},
diff --git a/vendor/github.com/prometheus/common/expfmt/text_parse.go b/vendor/github.com/prometheus/common/expfmt/text_parse.go
index 00c8841a1..4ce1f40b8 100644
--- a/vendor/github.com/prometheus/common/expfmt/text_parse.go
+++ b/vendor/github.com/prometheus/common/expfmt/text_parse.go
@@ -339,6 +339,16 @@ func (p *TextParser) startLabelName() stateFn {
return nil // Unexpected end of input.
}
if p.currentByte == '}' {
+ if p.currentMF == nil {
+ // The closing brace was reached before any metric name was read,
+ // e.g. for the input "{}". There is no metric to attach labels to,
+ // so this is a malformed exposition. This mirrors the guard in
+ // startLabelValue. currentMF (not currentMetric) is checked because
+ // reset only clears currentMF between parses.
+ p.parseError("invalid metric name")
+ p.currentLabelPairs = nil
+ return nil
+ }
p.currentMetric.Label = append(p.currentMetric.Label, p.currentLabelPairs...)
p.currentLabelPairs = nil
if p.skipBlankTab(); p.err != nil {
diff --git a/vendor/github.com/prometheus/common/helpers/templates/time.go b/vendor/github.com/prometheus/common/helpers/templates/time.go
index b7dc655f6..d9fcaa0ab 100644
--- a/vendor/github.com/prometheus/common/helpers/templates/time.go
+++ b/vendor/github.com/prometheus/common/helpers/templates/time.go
@@ -25,7 +25,7 @@ import (
var errNaNOrInf = errors.New("value is NaN or Inf")
-func ConvertToFloat(i interface{}) (float64, error) {
+func ConvertToFloat(i any) (float64, error) {
switch v := i.(type) {
case float64:
return v, nil
@@ -58,7 +58,7 @@ func FloatToTime(v float64) (*time.Time, error) {
return &t, nil
}
-func HumanizeDuration(i interface{}) (string, error) {
+func HumanizeDuration(i any) (string, error) {
v, err := ConvertToFloat(i)
if err != nil {
return "", err
@@ -105,7 +105,7 @@ func HumanizeDuration(i interface{}) (string, error) {
return fmt.Sprintf("%.4g%ss", v, prefix), nil
}
-func HumanizeTimestamp(i interface{}) (string, error) {
+func HumanizeTimestamp(i any) (string, error) {
v, err := ConvertToFloat(i)
if err != nil {
return "", err
diff --git a/vendor/github.com/prometheus/common/model/labels.go b/vendor/github.com/prometheus/common/model/labels.go
index dfeb34be5..29688a13c 100644
--- a/vendor/github.com/prometheus/common/model/labels.go
+++ b/vendor/github.com/prometheus/common/model/labels.go
@@ -124,7 +124,7 @@ func (ln LabelName) IsValidLegacy() bool {
}
// UnmarshalYAML implements the yaml.Unmarshaler interface.
-func (ln *LabelName) UnmarshalYAML(unmarshal func(interface{}) error) error {
+func (ln *LabelName) UnmarshalYAML(unmarshal func(any) error) error {
var s string
if err := unmarshal(&s); err != nil {
return err
diff --git a/vendor/github.com/prometheus/common/model/labelset.go b/vendor/github.com/prometheus/common/model/labelset.go
index 9de47b256..6010b26a8 100644
--- a/vendor/github.com/prometheus/common/model/labelset.go
+++ b/vendor/github.com/prometheus/common/model/labelset.go
@@ -16,6 +16,7 @@ package model
import (
"encoding/json"
"fmt"
+ "maps"
"sort"
)
@@ -107,9 +108,7 @@ func (ls LabelSet) Before(o LabelSet) bool {
// Clone returns a copy of the label set.
func (ls LabelSet) Clone() LabelSet {
lsn := make(LabelSet, len(ls))
- for ln, lv := range ls {
- lsn[ln] = lv
- }
+ maps.Copy(lsn, ls)
return lsn
}
@@ -117,13 +116,9 @@ func (ls LabelSet) Clone() LabelSet {
func (ls LabelSet) Merge(other LabelSet) LabelSet {
result := make(LabelSet, len(ls))
- for k, v := range ls {
- result[k] = v
- }
+ maps.Copy(result, ls)
- for k, v := range other {
- result[k] = v
- }
+ maps.Copy(result, other)
return result
}
diff --git a/vendor/github.com/prometheus/common/model/metric.go b/vendor/github.com/prometheus/common/model/metric.go
index 3feebf328..2fe461511 100644
--- a/vendor/github.com/prometheus/common/model/metric.go
+++ b/vendor/github.com/prometheus/common/model/metric.go
@@ -17,6 +17,7 @@ import (
"encoding/json"
"errors"
"fmt"
+ "maps"
"regexp"
"sort"
"strconv"
@@ -24,7 +25,6 @@ import (
"unicode/utf8"
dto "github.com/prometheus/client_model/go"
- "go.yaml.in/yaml/v2"
"google.golang.org/protobuf/proto"
)
@@ -78,14 +78,6 @@ const (
UTF8Validation
)
-var _ interface {
- yaml.Marshaler
- yaml.Unmarshaler
- json.Marshaler
- json.Unmarshaler
- fmt.Stringer
-} = new(ValidationScheme)
-
// String returns the string representation of s.
func (s ValidationScheme) String() string {
switch s {
@@ -267,9 +259,7 @@ func (m Metric) Before(o Metric) bool {
// Clone returns a copy of the Metric.
func (m Metric) Clone() Metric {
clone := make(Metric, len(m))
- for k, v := range m {
- clone[k] = v
- }
+ maps.Copy(clone, m)
return clone
}
diff --git a/vendor/github.com/prometheus/common/model/time.go b/vendor/github.com/prometheus/common/model/time.go
index 1730b0fdc..0854753f4 100644
--- a/vendor/github.com/prometheus/common/model/time.go
+++ b/vendor/github.com/prometheus/common/model/time.go
@@ -123,44 +123,38 @@ func (t Time) MarshalJSON() ([]byte, error) {
// UnmarshalJSON implements the json.Unmarshaler interface.
func (t *Time) UnmarshalJSON(b []byte) error {
- p := strings.Split(string(b), ".")
- switch len(p) {
- case 1:
- v, err := strconv.ParseInt(p[0], 10, 64)
+ base, frac, found := strings.Cut(string(b), ".")
+ if !found {
+ v, err := strconv.ParseInt(base, 10, 64)
if err != nil {
return err
}
*t = Time(v * second)
-
- case 2:
- v, err := strconv.ParseInt(p[0], 10, 64)
+ } else {
+ v, err := strconv.ParseInt(base, 10, 64)
if err != nil {
return err
}
- v *= second
- prec := dotPrecision - len(p[1])
+ prec := dotPrecision - len(frac)
if prec < 0 {
- p[1] = p[1][:dotPrecision]
- } else if prec > 0 {
- p[1] += strings.Repeat("0", prec)
+ frac = frac[:dotPrecision]
}
-
- va, err := strconv.ParseInt(p[1], 10, 32)
+ va, err := strconv.ParseInt(frac, 10, 32)
if err != nil {
return err
}
-
- // If the value was something like -0.1 the negative is lost in the
- // parsing because of the leading zero, this ensures that we capture it.
- if len(p[0]) > 0 && p[0][0] == '-' && v+va > 0 {
- *t = Time(v+va) * -1
- } else {
- *t = Time(v + va)
+ switch prec {
+ case 1:
+ va *= 10
+ case 2:
+ va *= 100
}
- default:
- return fmt.Errorf("invalid time %q", string(b))
+ if len(base) > 0 && base[0] == '-' {
+ va = -va
+ }
+ *t = Time(v*second + va)
}
return nil
}
@@ -340,12 +334,12 @@ func (d *Duration) UnmarshalText(text []byte) error {
}
// MarshalYAML implements the yaml.Marshaler interface.
-func (d Duration) MarshalYAML() (interface{}, error) {
+func (d Duration) MarshalYAML() (any, error) {
return d.String(), nil
}
// UnmarshalYAML implements the yaml.Unmarshaler interface.
-func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error {
+func (d *Duration) UnmarshalYAML(unmarshal func(any) error) error {
var s string
if err := unmarshal(&s); err != nil {
return err
diff --git a/vendor/github.com/prometheus/common/model/value.go b/vendor/github.com/prometheus/common/model/value.go
index a9995a37e..8dffd9c4a 100644
--- a/vendor/github.com/prometheus/common/model/value.go
+++ b/vendor/github.com/prometheus/common/model/value.go
@@ -259,13 +259,13 @@ func (s Scalar) String() string {
// MarshalJSON implements json.Marshaler.
func (s Scalar) MarshalJSON() ([]byte, error) {
v := strconv.FormatFloat(float64(s.Value), 'f', -1, 64)
- return json.Marshal([...]interface{}{s.Timestamp, v})
+ return json.Marshal([...]any{s.Timestamp, v})
}
// UnmarshalJSON implements json.Unmarshaler.
func (s *Scalar) UnmarshalJSON(b []byte) error {
var f string
- v := [...]interface{}{&s.Timestamp, &f}
+ v := [...]any{&s.Timestamp, &f}
if err := json.Unmarshal(b, &v); err != nil {
return err
@@ -291,12 +291,12 @@ func (s *String) String() string {
// MarshalJSON implements json.Marshaler.
func (s String) MarshalJSON() ([]byte, error) {
- return json.Marshal([]interface{}{s.Timestamp, s.Value})
+ return json.Marshal([]any{s.Timestamp, s.Value})
}
// UnmarshalJSON implements json.Unmarshaler.
func (s *String) UnmarshalJSON(b []byte) error {
- v := [...]interface{}{&s.Timestamp, &s.Value}
+ v := [...]any{&s.Timestamp, &s.Value}
return json.Unmarshal(b, &v)
}
diff --git a/vendor/github.com/prometheus/common/model/value_float.go b/vendor/github.com/prometheus/common/model/value_float.go
index 6bfc757d1..b7d93615e 100644
--- a/vendor/github.com/prometheus/common/model/value_float.go
+++ b/vendor/github.com/prometheus/common/model/value_float.go
@@ -79,7 +79,7 @@ func (s SamplePair) MarshalJSON() ([]byte, error) {
if err != nil {
return nil, err
}
- return []byte(fmt.Sprintf("[%s,%s]", t, v)), nil
+ return fmt.Appendf(nil, "[%s,%s]", t, v), nil
}
// UnmarshalJSON implements json.Unmarshaler.
diff --git a/vendor/github.com/prometheus/common/model/value_histogram.go b/vendor/github.com/prometheus/common/model/value_histogram.go
index 91ce5b7a4..f27856ccc 100644
--- a/vendor/github.com/prometheus/common/model/value_histogram.go
+++ b/vendor/github.com/prometheus/common/model/value_histogram.go
@@ -67,11 +67,11 @@ func (s HistogramBucket) MarshalJSON() ([]byte, error) {
if err != nil {
return nil, err
}
- return []byte(fmt.Sprintf("[%s,%s,%s,%s]", b, l, u, c)), nil
+ return fmt.Appendf(nil, "[%s,%s,%s,%s]", b, l, u, c), nil
}
func (s *HistogramBucket) UnmarshalJSON(buf []byte) error {
- tmp := []interface{}{&s.Boundaries, &s.Lower, &s.Upper, &s.Count}
+ tmp := []any{&s.Boundaries, &s.Lower, &s.Upper, &s.Count}
wantLen := len(tmp)
if err := json.Unmarshal(buf, &tmp); err != nil {
return err
@@ -152,11 +152,11 @@ func (s SampleHistogramPair) MarshalJSON() ([]byte, error) {
if err != nil {
return nil, err
}
- return []byte(fmt.Sprintf("[%s,%s]", t, v)), nil
+ return fmt.Appendf(nil, "[%s,%s]", t, v), nil
}
func (s *SampleHistogramPair) UnmarshalJSON(buf []byte) error {
- tmp := []interface{}{&s.Timestamp, &s.Histogram}
+ tmp := []any{&s.Timestamp, &s.Histogram}
wantLen := len(tmp)
if err := json.Unmarshal(buf, &tmp); err != nil {
return err
diff --git a/vendor/github.com/prometheus/common/promslog/slog.go b/vendor/github.com/prometheus/common/promslog/slog.go
index f5b9e98ba..f8f77165a 100644
--- a/vendor/github.com/prometheus/common/promslog/slog.go
+++ b/vendor/github.com/prometheus/common/promslog/slog.go
@@ -61,7 +61,7 @@ func NewLevel() *Level {
}
}
-func (l *Level) UnmarshalYAML(unmarshal func(interface{}) error) error {
+func (l *Level) UnmarshalYAML(unmarshal func(any) error) error {
var s string
type plain string
if err := unmarshal((*plain)(&s)); err != nil {
diff --git a/vendor/github.com/prometheus/common/version/info.go b/vendor/github.com/prometheus/common/version/info.go
index 61ed1ba31..112f35523 100644
--- a/vendor/github.com/prometheus/common/version/info.go
+++ b/vendor/github.com/prometheus/common/version/info.go
@@ -79,6 +79,24 @@ func BuildContext() string {
return fmt.Sprintf("(go=%s, platform=%s, user=%s, date=%s, tags=%s)", GoVersion, GoOS+"/"+GoArch, BuildUser, BuildDate, GetTags())
}
+// Slog returns a slice of strings for use with structured logging.
+//
+// Example:
+// logger := promslog.New(promslog.Config{})
+// logger.Info("Starting Prometheus Server", version.Slog()...)
+func Slog() []any {
+ return []any{
+ "version", Version,
+ "revision", Revision,
+ "branch", Branch,
+ "builduser", BuildUser,
+ "builddate", BuildDate,
+ "goversion", GoVersion,
+ "goos", GoOS,
+ "goarch", GoArch,
+ }
+}
+
func GetRevision() string {
if Revision != "" {
return Revision
diff --git a/vendor/github.com/prometheus/prometheus/storage/remote/azuread/azuread.go b/vendor/github.com/prometheus/prometheus/storage/remote/azuread/azuread.go
index 1ba55420f..751d7d6c4 100644
--- a/vendor/github.com/prometheus/prometheus/storage/remote/azuread/azuread.go
+++ b/vendor/github.com/prometheus/prometheus/storage/remote/azuread/azuread.go
@@ -27,6 +27,7 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/google/uuid"
"github.com/grafana/regexp"
+ config_util "github.com/prometheus/common/config"
)
// Clouds.
@@ -75,7 +76,7 @@ type OAuthConfig struct {
ClientID string `yaml:"client_id,omitempty"`
// ClientSecret is the clientSecret of the azure active directory application that is being used to authenticate.
- ClientSecret string `yaml:"client_secret,omitempty"`
+ ClientSecret config_util.Secret `yaml:"client_secret,omitempty"`
// TenantID is the tenantId of the azure active directory application that is being used to authenticate.
TenantID string `yaml:"tenant_id,omitempty"`
@@ -357,7 +358,7 @@ func newWorkloadIdentityTokenCredential(clientOpts *azcore.ClientOptions, worklo
// newOAuthTokenCredential returns new OAuth token credential.
func newOAuthTokenCredential(clientOpts *azcore.ClientOptions, oAuthConfig *OAuthConfig) (azcore.TokenCredential, error) {
opts := &azidentity.ClientSecretCredentialOptions{ClientOptions: *clientOpts}
- return azidentity.NewClientSecretCredential(oAuthConfig.TenantID, oAuthConfig.ClientID, oAuthConfig.ClientSecret, opts)
+ return azidentity.NewClientSecretCredential(oAuthConfig.TenantID, oAuthConfig.ClientID, string(oAuthConfig.ClientSecret), opts)
}
// newSDKTokenCredential returns new SDK token credential.
diff --git a/vendor/github.com/prometheus/prometheus/storage/remote/codec.go b/vendor/github.com/prometheus/prometheus/storage/remote/codec.go
index c689a5116..dec07dd6b 100644
--- a/vendor/github.com/prometheus/prometheus/storage/remote/codec.go
+++ b/vendor/github.com/prometheus/prometheus/storage/remote/codec.go
@@ -67,6 +67,14 @@ func DecodeReadRequest(r *http.Request) (*prompb.ReadRequest, error) {
return nil, err
}
+ decodedLen, err := snappy.DecodedLen(compressed)
+ if err != nil {
+ return nil, err
+ }
+ if decodedLen > decodeReadLimit {
+ return nil, fmt.Errorf("snappy: decoded length %d exceeds limit %d", decodedLen, decodeReadLimit)
+ }
+
reqBuf, err := snappy.Decode(nil, compressed)
if err != nil {
return nil, err
diff --git a/vendor/github.com/puzpuzpuz/xsync/v4/README.md b/vendor/github.com/puzpuzpuz/xsync/v4/README.md
index 7b482add1..98a262f59 100644
--- a/vendor/github.com/puzpuzpuz/xsync/v4/README.md
+++ b/vendor/github.com/puzpuzpuz/xsync/v4/README.md
@@ -8,7 +8,7 @@ Concurrent data structures for Go. Aims to provide more scalable alternatives fo
Apart from direct library dependencies, `xsync` data structures can also be met in-code in other libraries like [Otter](https://github.com/maypok86/otter/blob/8c526307556486ea0337280a4211135720bc29cc/internal/hashmap/map.go) caching library.
-Covered with tests following the approach described [here](https://puzpuzpuz.dev/testing-concurrent-code-for-fun-and-profit).
+Covered with concurrent stress tests following the approach described [here](https://puzpuzpuz.dev/testing-concurrent-code-for-fun-and-profit).
## Benchmarks
@@ -132,7 +132,8 @@ Make sure to implement proper back-off strategy to handle failed optimistic oper
A `MPMCQueue` is a bounded multi-producer multi-consumer concurrent queue.
```go
-q := xsync.NewMPMCQueue[string](1024)
+// capacity is rounded up to the next power of 2 (1000 -> 1024)
+q := xsync.NewMPMCQueue[string](1000)
// producer optimistically inserts an item into the queue
// optimistic insertion attempt; doesn't block
inserted := q.TryEnqueue("bar")
diff --git a/vendor/github.com/puzpuzpuz/xsync/v4/counter.go b/vendor/github.com/puzpuzpuz/xsync/v4/counter.go
index be3d7a9ae..1858788da 100644
--- a/vendor/github.com/puzpuzpuz/xsync/v4/counter.go
+++ b/vendor/github.com/puzpuzpuz/xsync/v4/counter.go
@@ -39,7 +39,7 @@ type cstripe struct {
// NewCounter creates a new Counter instance.
func NewCounter() *Counter {
- nstripes := nextPowOf2(parallelism())
+ nstripes := uint32(nextPowOf2(uint64(parallelism())))
c := Counter{
stripes: make([]cstripe, nstripes),
mask: nstripes - 1,
diff --git a/vendor/github.com/puzpuzpuz/xsync/v4/map.go b/vendor/github.com/puzpuzpuz/xsync/v4/map.go
index 03066f926..b69984b79 100644
--- a/vendor/github.com/puzpuzpuz/xsync/v4/map.go
+++ b/vendor/github.com/puzpuzpuz/xsync/v4/map.go
@@ -79,16 +79,6 @@ const (
loadAndDeleteOp
)
-type hashKind int
-
-const (
- hashKindComparable hashKind = iota
- hashKindInt
- hashKindInt64
- hashKindUint64
- hashKindUintptr
-)
-
// Deprecated: use [Map]
type MapOf[K comparable, V any] = Map[K, V]
@@ -131,7 +121,7 @@ type Map[K comparable, V any] struct {
resizeIdx atomic.Int64
minTableLen int
growOnly bool
- hashKind hashKind
+ intKey bool
}
type mapTable[K comparable, V any] struct {
@@ -224,12 +214,12 @@ func NewMap[K comparable, V any](options ...func(*MapConfig)) *Map[K, V] {
m := &Map[K, V]{}
m.resizeCond = *sync.NewCond(&m.resizeMu)
- m.hashKind = detectHashKind[K]()
+ m.intKey = detectIntKey[K]()
var table *mapTable[K, V]
if c.sizeHint <= defaultMinMapTableLen*entriesPerMapBucket {
table = newMapTable[K, V](defaultMinMapTableLen, maphash.MakeSeed())
} else {
- tableLen := nextPowOf2(uint32((float64(c.sizeHint) / entriesPerMapBucket) / mapLoadFactor))
+ tableLen := nextPowOf2(uint64((float64(c.sizeHint) / entriesPerMapBucket) / mapLoadFactor))
table = newMapTable[K, V](int(tableLen), maphash.MakeSeed())
}
m.minTableLen = len(table.buckets)
@@ -238,44 +228,40 @@ func NewMap[K comparable, V any](options ...func(*MapConfig)) *Map[K, V] {
return m
}
-// detectHashKind returns the appropriate hash kind for the key type.
-func detectHashKind[K comparable]() hashKind {
+// detectIntKey returns true if the key type is an integer type.
+func detectIntKey[K comparable]() bool {
var zero K
switch any(zero).(type) {
- case int:
- return hashKindInt
- case int64:
- return hashKindInt64
- case uint64:
- return hashKindUint64
- case uintptr:
- return hashKindUintptr
+ case int, uint, uintptr, int64, uint64, int32, uint32, int16, uint16, int8, uint8:
+ return true
default:
- return hashKindComparable
+ return false
}
}
-// hashUint64 computes a hash for integer keys using a 128-bit
-// multiply-xorshift mixer (wyhash-style). The constant is xxHash's
-// PRIME64_1 which provides excellent avalanche. This is significantly
-// faster than maphash.Comparable for integer types.
+// hashUint64 computes a hash for integer keys using two rounds of
+// multiply-xorshift mixing (wyhash-style).
+// This is significantly faster than maphash.Comparable for integer types.
func hashUint64(seed, v uint64) uint64 {
- hi, lo := bits.Mul64(v^seed, 0x9E3779B185EBCA87)
- return hi ^ lo
+ hi, lo := bits.Mul64(v^seed, 0x2d358dccaa6c78a5)
+ hi2, lo2 := bits.Mul64(hi^lo, 0x8bb84b93962eacc9)
+ return hi2 ^ lo2
}
-func hashKey[K comparable](k K, hashKind hashKind, seed maphash.Seed, intSeed uint64) uint64 {
- switch hashKind {
- case hashKindInt:
- return hashUint64(intSeed, uint64(any(k).(int)))
- case hashKindInt64:
- return hashUint64(intSeed, uint64(any(k).(int64)))
- case hashKindUint64:
- return hashUint64(intSeed, any(k).(uint64))
- case hashKindUintptr:
- return hashUint64(intSeed, uint64(any(k).(uintptr)))
+// toUint64 reinterprets integer-like keys as uint64 for hashUint64.
+// The size switch is folded per instantiated K by the compiler.
+func toUint64[K any](k K) uint64 {
+ switch unsafe.Sizeof(k) {
+ case 8:
+ return *(*uint64)(unsafe.Pointer(&k))
+ case 4:
+ return uint64(*(*uint32)(unsafe.Pointer(&k)))
+ case 2:
+ return uint64(*(*uint16)(unsafe.Pointer(&k)))
+ case 1:
+ return uint64(*(*uint8)(unsafe.Pointer(&k)))
default:
- return maphash.Comparable(seed, k)
+ panic("unreachable")
}
}
@@ -322,18 +308,10 @@ func ToPlainMap[K comparable, V any](m *Map[K, V]) map[K]V {
// The ok result indicates whether value was found in the map.
func (m *Map[K, V]) Load(key K) (value V, ok bool) {
table := m.table.Load()
- // This is hot path, hence hand-inlined hashKey().
var hash uint64
- switch m.hashKind {
- case hashKindInt:
- hash = hashUint64(table.intSeed, uint64(any(key).(int)))
- case hashKindInt64:
- hash = hashUint64(table.intSeed, uint64(any(key).(int64)))
- case hashKindUint64:
- hash = hashUint64(table.intSeed, any(key).(uint64))
- case hashKindUintptr:
- hash = hashUint64(table.intSeed, uint64(any(key).(uintptr)))
- default:
+ if m.intKey {
+ hash = hashUint64(table.intSeed, toUint64(key))
+ } else {
hash = maphash.Comparable(table.seed, key)
}
h1 := h1(hash)
@@ -385,18 +363,10 @@ func (m *Map[K, V]) Store(key K, value V) {
)
table := m.table.Load()
tableLen := len(table.buckets)
- // This is hot path, hence hand-inlined hashKey().
var hash uint64
- switch m.hashKind {
- case hashKindInt:
- hash = hashUint64(table.intSeed, uint64(any(key).(int)))
- case hashKindInt64:
- hash = hashUint64(table.intSeed, uint64(any(key).(int64)))
- case hashKindUint64:
- hash = hashUint64(table.intSeed, any(key).(uint64))
- case hashKindUintptr:
- hash = hashUint64(table.intSeed, uint64(any(key).(uintptr)))
- default:
+ if m.intKey {
+ hash = hashUint64(table.intSeed, toUint64(key))
+ } else {
hash = maphash.Comparable(table.seed, key)
}
h1 := h1(hash)
@@ -613,18 +583,10 @@ func (m *Map[K, V]) doCompute(
)
table := m.table.Load()
tableLen := len(table.buckets)
- // This is hot path, hence hand-inlined hashKey().
var hash uint64
- switch m.hashKind {
- case hashKindInt:
- hash = hashUint64(table.intSeed, uint64(any(key).(int)))
- case hashKindInt64:
- hash = hashUint64(table.intSeed, uint64(any(key).(int64)))
- case hashKindUint64:
- hash = hashUint64(table.intSeed, any(key).(uint64))
- case hashKindUintptr:
- hash = hashUint64(table.intSeed, uint64(any(key).(uintptr)))
- default:
+ if m.intKey {
+ hash = hashUint64(table.intSeed, toUint64(key))
+ } else {
hash = maphash.Comparable(table.seed, key)
}
h1 := h1(hash)
@@ -956,7 +918,7 @@ func (m *Map[K, V]) transfer(table, newTable *mapTable[K, V]) {
// Visit all source buckets that map to this destination bucket.
// When growing, runs once. When shrinking, runs twice.
for srcIdx := i; srcIdx < tableLen; srcIdx += baseLen {
- total += transferBucketUnsafe(&table.buckets[srcIdx], newTable, m.hashKind)
+ total += transferBucketUnsafe(&table.buckets[srcIdx], newTable, m.intKey)
}
}
// The exact counter stripe doesn't matter here, so pick up the one
@@ -969,7 +931,7 @@ func (m *Map[K, V]) transfer(table, newTable *mapTable[K, V]) {
func transferBucketUnsafe[K comparable, V any](
b *bucketPadded,
destTable *mapTable[K, V],
- hashKind hashKind,
+ intKey bool,
) (copied int) {
rootb := b
rootb.mu.Lock()
@@ -977,7 +939,12 @@ func transferBucketUnsafe[K comparable, V any](
for i := range entriesPerMapBucket {
if eptr := b.entries[i]; eptr != nil {
e := (*entry[K, V])(eptr)
- hash := hashKey(e.key, hashKind, destTable.seed, destTable.intSeed)
+ var hash uint64
+ if intKey {
+ hash = hashUint64(destTable.intSeed, toUint64(e.key))
+ } else {
+ hash = maphash.Comparable(destTable.seed, e.key)
+ }
bidx := uint64(len(destTable.buckets)-1) & h1(hash)
destb := &destTable.buckets[bidx]
appendToBucket(h2(hash), e, destb)
diff --git a/vendor/github.com/puzpuzpuz/xsync/v4/mpmcqueue.go b/vendor/github.com/puzpuzpuz/xsync/v4/mpmcqueue.go
index 2c7d25038..d9d42f60f 100644
--- a/vendor/github.com/puzpuzpuz/xsync/v4/mpmcqueue.go
+++ b/vendor/github.com/puzpuzpuz/xsync/v4/mpmcqueue.go
@@ -1,10 +1,13 @@
package xsync
import (
+ "math/bits"
"sync/atomic"
"unsafe"
)
+const mpmcQueueMaxRequestedCapacity uint64 = uint64(1) << (bits.UintSize - 2)
+
// Deprecated: use [MPMCQueue].
type MPMCQueueOf[I any] = MPMCQueue[I]
@@ -17,9 +20,11 @@ type MPMCQueueOf[I any] = MPMCQueue[I]
// Based on the data structure from the following C++ library:
// https://github.com/rigtorp/MPMCQueue
type MPMCQueue[I any] struct {
- cap uint64
- head uint64
- // Padding to prevent false sharing.
+ capMask uint64
+ capShift uint64
+ // Padding to isolate read-only fields from the head/tail counters.
+ _ [cacheLineSize - 16]byte
+ head uint64
_ [cacheLineSize - 8]byte
tail uint64
_ [cacheLineSize - 8]byte
@@ -50,14 +55,19 @@ func NewMPMCQueueOf[I any](capacity int) *MPMCQueue[I] {
}
// NewMPMCQueue creates a new MPMCQueue instance with the given
-// capacity.
+// capacity. The capacity is rounded up to the next power of 2.
func NewMPMCQueue[I any](capacity int) *MPMCQueue[I] {
if capacity < 1 {
panic("capacity must be positive number")
}
+ if uint64(capacity) > mpmcQueueMaxRequestedCapacity {
+ panic("capacity is too large")
+ }
+ capPow2 := nextPowOf2(uint64(capacity))
return &MPMCQueue[I]{
- cap: uint64(capacity),
- slots: make([]slotPadded[I], capacity),
+ capMask: capPow2 - 1,
+ capShift: uint64(bits.TrailingZeros64(capPow2)),
+ slots: make([]slotPadded[I], capPow2),
}
}
@@ -99,9 +109,9 @@ func (q *MPMCQueue[I]) TryDequeue() (item I, ok bool) {
}
func (q *MPMCQueue[I]) idx(i uint64) uint64 {
- return i % q.cap
+ return i & q.capMask
}
func (q *MPMCQueue[I]) turn(i uint64) uint64 {
- return i / q.cap
+ return i >> q.capShift
}
diff --git a/vendor/github.com/puzpuzpuz/xsync/v4/rbmutex.go b/vendor/github.com/puzpuzpuz/xsync/v4/rbmutex.go
index 4032b76ff..26744150c 100644
--- a/vendor/github.com/puzpuzpuz/xsync/v4/rbmutex.go
+++ b/vendor/github.com/puzpuzpuz/xsync/v4/rbmutex.go
@@ -55,7 +55,7 @@ type rslot struct {
// NewRBMutex creates a new RBMutex instance.
func NewRBMutex() *RBMutex {
- nslots := nextPowOf2(parallelism())
+ nslots := uint32(nextPowOf2(uint64(parallelism())))
mu := RBMutex{
rslots: make([]rslot, nslots),
rmask: nslots - 1,
diff --git a/vendor/github.com/puzpuzpuz/xsync/v4/util.go b/vendor/github.com/puzpuzpuz/xsync/v4/util.go
index 46fc68706..b600dbbd9 100644
--- a/vendor/github.com/puzpuzpuz/xsync/v4/util.go
+++ b/vendor/github.com/puzpuzpuz/xsync/v4/util.go
@@ -17,20 +17,12 @@ const (
cacheLineSize = 64
)
-// nextPowOf2 computes the next highest power of 2 of 32-bit v.
-// Source: https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
-func nextPowOf2(v uint32) uint32 {
- if v == 0 {
+// nextPowOf2 computes the next highest power of 2 of 64-bit v.
+func nextPowOf2(v uint64) uint64 {
+ if v <= 1 {
return 1
}
- v--
- v |= v >> 1
- v |= v >> 2
- v |= v >> 4
- v |= v >> 8
- v |= v >> 16
- v++
- return v
+ return 1 << bits.Len64(v-1)
}
func parallelism() uint32 {
diff --git a/vendor/github.com/tidwall/gjson/README.md b/vendor/github.com/tidwall/gjson/README.md
index 387766d50..f87b87377 100644
--- a/vendor/github.com/tidwall/gjson/README.md
+++ b/vendor/github.com/tidwall/gjson/README.md
@@ -56,7 +56,7 @@ This will print:
```
Prichard
```
-*There's also the [GetMany](#get-multiple-values-at-once) function to get multiple values at once, and [GetBytes](#working-with-bytes) for working with JSON byte slices.*
+*There's also [GetBytes](#working-with-bytes) for working with JSON byte slices.*
## Path Syntax
diff --git a/vendor/github.com/tidwall/gjson/gjson.go b/vendor/github.com/tidwall/gjson/gjson.go
index 5aa2a4ffa..97d6516ae 100644
--- a/vendor/github.com/tidwall/gjson/gjson.go
+++ b/vendor/github.com/tidwall/gjson/gjson.go
@@ -1,7 +1,14 @@
+// Copyright 2024 Joshua J Baker. All rights reserved.
+// Use of this source code is governed by an MIT-style
+// license that can be found in the LICENSE file.
+//
+// https://github.com/tidwall/gjson
+
// Package gjson provides searching for json strings.
package gjson
import (
+ "iter"
"strconv"
"strings"
"time"
@@ -3601,3 +3608,43 @@ func modDig(json, arg string) string {
out = append(out, ']')
return string(out)
}
+
+// All iterates over a json result.
+// This works identically to ForEach, but allows modern Go loops:
+//
+// for key, value := range res.All() {
+// fmt.Printf("%s %s\n", key, value)
+// }
+func (t Result) All() iter.Seq2[Result, Result] {
+ return func(yield func(Result, Result) bool) {
+ t.ForEach(yield)
+ }
+}
+
+// Keys iterates over a json result.
+// This works identically to ForEach, but allows modern Go loops:
+//
+// for key := range res.Keys() {
+// fmt.Printf("%s\n", key)
+// }
+func (t Result) Keys() iter.Seq[Result] {
+ return func(yield func(Result) bool) {
+ t.ForEach(func(key, _ Result) bool {
+ return yield(key)
+ })
+ }
+}
+
+// Values iterates over a json result.
+// This works identically to ForEach, but allows modern Go loops:
+//
+// for value := range res.Values() {
+// fmt.Printf("%s\n", value)
+// }
+func (t Result) Values() iter.Seq[Result] {
+ return func(yield func(Result) bool) {
+ t.ForEach(func(_, value Result) bool {
+ return yield(value)
+ })
+ }
+}
diff --git a/vendor/go.opentelemetry.io/collector/component/config.go b/vendor/go.opentelemetry.io/collector/component/config.go
index ca33da36a..cc94b4949 100644
--- a/vendor/go.opentelemetry.io/collector/component/config.go
+++ b/vendor/go.opentelemetry.io/collector/component/config.go
@@ -6,7 +6,7 @@ package component // import "go.opentelemetry.io/collector/component"
// Config defines the configuration for a component.Component.
//
// Implementations and/or any sub-configs (other types embedded or included in the Config implementation)
-// MUST implement xconfmap.Validator if any validation is required for that part of the configuration
+// MUST implement confmap.Validator if any validation is required for that part of the configuration
// (e.g. check if a required field is present).
//
// A valid implementation MUST pass the check componenttest.CheckConfigStruct (return nil error).
diff --git a/vendor/go.opentelemetry.io/collector/confmap/README.md b/vendor/go.opentelemetry.io/collector/confmap/README.md
index 0a58387d2..44af59c82 100644
--- a/vendor/go.opentelemetry.io/collector/confmap/README.md
+++ b/vendor/go.opentelemetry.io/collector/confmap/README.md
@@ -171,7 +171,7 @@ service:
Notice that the `service::extensions` list is a combination of both configurations. By default, the value of the last configuration source passed, `extra_extension`, would be used, so the extensions list would be: `service::extensions: [healthcheckv2]`.
> [!NOTE]
-> By enabling this feature gate, all the lists in the given configuration will be merged.
+> By enabling this feature gate, only the extensions, receivers and exporters under the `service` section are merged.
### Watching for Updates
After the configuration was processed, the `Resolver` can be used as a single point to watch for updates in the
diff --git a/vendor/go.opentelemetry.io/collector/confmap/confmap.go b/vendor/go.opentelemetry.io/collector/confmap/confmap.go
index a4848a53c..ddbf6f0c0 100644
--- a/vendor/go.opentelemetry.io/collector/confmap/confmap.go
+++ b/vendor/go.opentelemetry.io/collector/confmap/confmap.go
@@ -39,6 +39,16 @@ func WithIgnoreUnused() UnmarshalOption {
return internal.WithIgnoreUnused()
}
+// WithForceUnmarshaler sets an option to run a top-level Unmarshal method,
+// even if the Conf being unmarshaled is already a parameter from an Unmarshal method.
+// To avoid infinite recursion, this should only be used when unmarshaling into
+// a different type from the current Unmarshaler.
+// For instance, this should be used in wrapper types such as configoptional.Optional
+// to ensure the inner type's Unmarshal method is called.
+func WithForceUnmarshaler() UnmarshalOption {
+ return internal.WithForceUnmarshaler()
+}
+
type MarshalOption = internal.MarshalOption
// Unmarshaler interface may be implemented by types to customize their behavior when being unmarshaled from a Conf.
@@ -49,3 +59,42 @@ type Unmarshaler = internal.Unmarshaler
// A configuration struct can implement this interface to override the default
// marshaling.
type Marshaler = internal.Marshaler
+
+// ScalarValue provides access to a scalar configuration value and allows
+// calling back into the confmap decoding/encoding machinery.
+//
+// This interface is only provided to methods used for [ScalarUnmarshaler] and
+// [ScalarMarshaler] implementations and cannot be implemented by types outside
+// the confmap package.
+//
+// Experimental: This interface is experimental, and behavior may change without
+// backward compatibility until this notice is removed.
+type ScalarValue = internal.ScalarValue
+
+// ScalarUnmarshaler is an interface which may be implemented by wrapper types
+// to customize their behavior when the type under the wrapper is a scalar
+// value.
+//
+// This should be used for types like `Wrapper[T]` where T is a scalar type, and
+// the wrapper type needs to implement custom logic for unmarshaling from a
+// scalar value (e.g. `5` for `Wrapper[int]`) into the wrapper type (e.g.
+// `Wrapper[int]{inner: 5}`).
+//
+// Experimental: This interface is experimental, and behavior may change without
+// backward compatibility until this notice is removed.
+type ScalarUnmarshaler = internal.ScalarUnmarshaler
+
+// ScalarMarshaler is an interface which may be implemented by wrapper types
+// to customize their behavior when the type under the wrapper is a scalar value.
+//
+// Experimental: This interface is experimental, and behavior may change without
+// backward compatibility until this notice is removed.
+type ScalarMarshaler = internal.ScalarMarshaler
+
+// ErrValueNotApplicable is returned when a value provided to a
+// ScalarUnmarshaler or ScalarMarshaler is not handled by the interface's method
+// call and should instead be handled by another mapstructure hook.
+//
+// Typically this should be used when a non-scalar value is received and should
+// instead be handled by the regular Unmarshaler or Marshaler interfaces.
+var ErrValueNotApplicable = internal.ErrValueNotApplicable
diff --git a/vendor/go.opentelemetry.io/collector/confmap/documentation.md b/vendor/go.opentelemetry.io/collector/confmap/documentation.md
index a42acecbb..23ae1c3b8 100644
--- a/vendor/go.opentelemetry.io/collector/confmap/documentation.md
+++ b/vendor/go.opentelemetry.io/collector/confmap/documentation.md
@@ -9,6 +9,5 @@ This component has the following feature gates:
| Feature Gate | Stage | Description | From Version | To Version | Reference |
| ------------ | ----- | ----------- | ------------ | ---------- | --------- |
| `confmap.enableMergeAppendOption` | alpha | Combines lists when resolving configs from different sources. This feature gate will not be stabilized 'as is'; the current behavior will remain the default. | v0.120.0 | N/A | [Link](https://github.com/open-telemetry/opentelemetry-collector/issues/8754) |
-| `confmap.newExpandedValueSanitizer` | beta | Fixes some types of decoding errors where environment variables are parsed as non-string types but assigned to string fields. | v0.144.0 | N/A | [Link](https://github.com/open-telemetry/opentelemetry-collector/pull/14413) |
For more information about feature gates, see the [Feature Gates](https://github.com/open-telemetry/opentelemetry-collector/blob/main/featuregate/README.md) documentation.
diff --git a/vendor/go.opentelemetry.io/collector/confmap/internal/conf.go b/vendor/go.opentelemetry.io/collector/confmap/internal/conf.go
index 139ef3f1b..e817ad476 100644
--- a/vendor/go.opentelemetry.io/collector/confmap/internal/conf.go
+++ b/vendor/go.opentelemetry.io/collector/confmap/internal/conf.go
@@ -12,7 +12,6 @@ import (
"github.com/knadh/koanf/providers/confmap"
"github.com/knadh/koanf/v2"
- encoder "go.opentelemetry.io/collector/confmap/internal/mapstructure"
"go.opentelemetry.io/collector/confmap/internal/metadata"
)
@@ -68,8 +67,7 @@ func (l *Conf) Marshal(rawVal any, opts ...MarshalOption) error {
for _, opt := range opts {
opt.apply(&set)
}
- enc := encoder.New(EncoderConfig(rawVal, set))
- data, err := enc.Encode(rawVal)
+ data, err := Encode(rawVal, set)
if err != nil {
return err
}
@@ -196,12 +194,6 @@ func sanitize(a any) any {
return sanitizeExpanded(a, false)
}
-// sanitizeToStringMap recursively removes expandedValue references from the given data.
-// It uses the expandedValue.Original field to replace the expandedValue references.
-func sanitizeToStr(a any) any {
- return sanitizeExpanded(a, true)
-}
-
func sanitizeExpanded(a any, useOriginal bool) any {
switch m := a.(type) {
case map[string]any:
diff --git a/vendor/go.opentelemetry.io/collector/confmap/internal/decoder.go b/vendor/go.opentelemetry.io/collector/confmap/internal/decoder.go
index e06eeaec7..e94de4776 100644
--- a/vendor/go.opentelemetry.io/collector/confmap/internal/decoder.go
+++ b/vendor/go.opentelemetry.io/collector/confmap/internal/decoder.go
@@ -13,7 +13,6 @@ import (
"github.com/go-viper/mapstructure/v2"
- "go.opentelemetry.io/collector/confmap/internal/metadata"
"go.opentelemetry.io/collector/confmap/internal/third_party/composehook"
)
@@ -66,6 +65,10 @@ func Decode(input, result any, settings UnmarshalOptions, skipTopLevelUnmarshale
mapKeyStringToMapKeyTextUnmarshalerHookFunc(),
mapstructure.StringToTimeDurationHookFunc(),
mapstructure.TextUnmarshallerHookFunc(),
+ // This must come before unmarshalerHookFunc; the two may both want to trigger
+ // their corresponding interface for structs implementing both, and the scalar
+ // interfaces are the ones that will sometimes defer to the non-scalar interfaces.
+ scalarUnmarshalerHookFunc(),
unmarshalerHookFunc(result, skipTopLevelUnmarshaler && !settings.ForceUnmarshaler),
// after the main unmarshaler hook is called,
// we unmarshal the embedded structs if present to merge with the result:
@@ -100,22 +103,18 @@ func useExpandValue() mapstructure.DecodeHookFuncType {
) (any, error) {
if exp, ok := data.(ExpandedValue); ok {
var useOriginal bool
- if metadata.ConfmapNewExpandedValueSanitizerFeatureGate.IsEnabled() {
- // Check if the target field is string, *string, **string, etc.
- baseType := to
- pointed := false
- for baseType.Kind() == reflect.Pointer {
- baseType = baseType.Elem()
- pointed = true
- }
- useOriginal = baseType.Kind() == reflect.String
+ // Check if the target field is string, *string, **string, etc.
+ baseType := to
+ pointed := false
+ for baseType.Kind() == reflect.Pointer {
+ baseType = baseType.Elem()
+ pointed = true
+ }
+ useOriginal = baseType.Kind() == reflect.String
- // If the parsed value is nil and the target is a pointer, use the parsed value.
- if pointed && exp.Value == nil {
- useOriginal = false
- }
- } else {
- useOriginal = to.Kind() == reflect.String
+ // If the parsed value is nil and the target is a pointer, use the parsed value.
+ if pointed && exp.Value == nil {
+ useOriginal = false
}
v := castTo(exp, useOriginal)
@@ -127,19 +126,6 @@ func useExpandValue() mapstructure.DecodeHookFuncType {
}
return v, nil
}
-
- if !metadata.ConfmapNewExpandedValueSanitizerFeatureGate.IsEnabled() {
- switch to.Kind() {
- case reflect.Array, reflect.Slice, reflect.Map:
- if isStringyStructure(to) {
- // If the target field is a stringy structure, sanitize to use the original string value everywhere.
- return sanitizeToStr(data), nil
- }
-
- // Otherwise, sanitize to use the parsed value everywhere.
- return sanitize(data), nil
- }
- }
return data, nil
}
}
diff --git a/vendor/go.opentelemetry.io/collector/confmap/internal/encoder.go b/vendor/go.opentelemetry.io/collector/confmap/internal/encoder.go
index d0665897c..605a09ac7 100644
--- a/vendor/go.opentelemetry.io/collector/confmap/internal/encoder.go
+++ b/vendor/go.opentelemetry.io/collector/confmap/internal/encoder.go
@@ -11,6 +11,15 @@ import (
encoder "go.opentelemetry.io/collector/confmap/internal/mapstructure"
)
+func Encode(rawVal any, set MarshalOptions) (any, error) {
+ enc := encoder.New(EncoderConfig(rawVal, set))
+ data, err := enc.Encode(rawVal)
+ if err != nil {
+ return nil, err
+ }
+ return data, nil
+}
+
// EncoderConfig returns a default encoder.EncoderConfig that includes
// an EncodeHook that handles both TextMarshaler and Marshaler
// interfaces.
@@ -25,6 +34,10 @@ func EncoderConfig(rawVal any, opts MarshalOptions) *encoder.EncoderConfig {
hooks = append(hooks,
encoder.TextMarshalerHookFunc(),
+ // This must come before unmarshalerHookFunc; the two may both want to trigger
+ // their corresponding interface for structs implementing both, and the scalar
+ // interfaces are the ones that will sometimes defer to the non-scalar interfaces.
+ scalarMarshalerHookFunc(),
marshalerHookFunc(rawVal),
)
diff --git a/vendor/go.opentelemetry.io/collector/confmap/internal/marshaloption.go b/vendor/go.opentelemetry.io/collector/confmap/internal/marshaloption.go
index 0c3fc2780..5fb8f60c1 100644
--- a/vendor/go.opentelemetry.io/collector/confmap/internal/marshaloption.go
+++ b/vendor/go.opentelemetry.io/collector/confmap/internal/marshaloption.go
@@ -19,3 +19,13 @@ type MarshalOptionFunc func(*MarshalOptions)
func (fn MarshalOptionFunc) apply(set *MarshalOptions) {
fn(set)
}
+
+func ApplyMarshalOptions(set *MarshalOptions, opts []MarshalOption) *MarshalOptions {
+ if set == nil {
+ set = &MarshalOptions{}
+ }
+ for _, opt := range opts {
+ opt.apply(set)
+ }
+ return set
+}
diff --git a/vendor/go.opentelemetry.io/collector/confmap/internal/metadata/generated_feature_gates.go b/vendor/go.opentelemetry.io/collector/confmap/internal/metadata/generated_feature_gates.go
index d277f5542..8631b067c 100644
--- a/vendor/go.opentelemetry.io/collector/confmap/internal/metadata/generated_feature_gates.go
+++ b/vendor/go.opentelemetry.io/collector/confmap/internal/metadata/generated_feature_gates.go
@@ -13,11 +13,3 @@ var ConfmapEnableMergeAppendOptionFeatureGate = featuregate.GlobalRegistry().Mus
featuregate.WithRegisterReferenceURL("https://github.com/open-telemetry/opentelemetry-collector/issues/8754"),
featuregate.WithRegisterFromVersion("v0.120.0"),
)
-
-var ConfmapNewExpandedValueSanitizerFeatureGate = featuregate.GlobalRegistry().MustRegister(
- "confmap.newExpandedValueSanitizer",
- featuregate.StageBeta,
- featuregate.WithRegisterDescription("Fixes some types of decoding errors where environment variables are parsed as non-string types but assigned to string fields."),
- featuregate.WithRegisterReferenceURL("https://github.com/open-telemetry/opentelemetry-collector/pull/14413"),
- featuregate.WithRegisterFromVersion("v0.144.0"),
-)
diff --git a/vendor/go.opentelemetry.io/collector/confmap/internal/scalar.go b/vendor/go.opentelemetry.io/collector/confmap/internal/scalar.go
new file mode 100644
index 000000000..0c4dbea27
--- /dev/null
+++ b/vendor/go.opentelemetry.io/collector/confmap/internal/scalar.go
@@ -0,0 +1,161 @@
+// Copyright The OpenTelemetry Authors
+// SPDX-License-Identifier: Apache-2.0
+
+package internal // import "go.opentelemetry.io/collector/confmap/internal"
+
+import (
+ "errors"
+ "reflect"
+
+ "github.com/go-viper/mapstructure/v2"
+)
+
+// ErrValueNotApplicable is returned when a value provided to a
+// ScalarUnmarshaler or ScalarMarshaler is not handled by the interface's method
+// call and should instead be handled by another mapstructure hook.
+//
+// Typically this should be used when a non-scalar value is received and should
+// instead be handled by the regular Unmarshaler or Marshaler interfaces.
+var ErrValueNotApplicable = errors.New("the provided value is not applicable for handling by this type")
+
+// ScalarValue provides access to a scalar configuration value and allows
+// calling back into the confmap decoding/encoding machinery.
+//
+// Experimental: This interface is experimental, and behavior may change without
+// backward compatibility until this notice is removed.
+type ScalarValue interface {
+ GetRaw() any
+
+ Unmarshal(result any, opts ...UnmarshalOption) error
+
+ Marshal(value any, opts ...MarshalOption) error
+
+ // Seal the interface so it can't be implemented outside this package.
+ _unexported()
+}
+
+// ScalarUnmarshaler is an interface which may be implemented by wrapper types
+// to customize their behavior when the type under the wrapper is a scalar
+// value.
+//
+// This should be used for types like `Wrapper[T]` where T is a scalar type, and
+// the wrapper type needs to implement custom logic for unmarshaling from a
+// scalar value (e.g. `5` for `Wrapper[int]`) into the wrapper type (e.g.
+// `Wrapper[int]{inner: 5}`).
+//
+// Experimental: This interface is experimental, and behavior may change without
+// backward compatibility until this notice is removed.
+type ScalarUnmarshaler interface {
+ // UnmarshalScalar allows a type to unmarshal itself from a scalar value.
+ UnmarshalScalar(ScalarValue) error
+}
+
+// ScalarMarshaler is an interface which may be implemented by wrapper types
+// to customize their behavior when the type under the wrapper is a scalar value.
+//
+// Experimental: This interface is experimental, and behavior may change without
+// backward compatibility until this notice is removed.
+type ScalarMarshaler interface {
+ // MarshalScalar allows a type to marshal itself to a scalar value.
+ MarshalScalar(ScalarValue) error
+}
+
+var _ ScalarValue = (*scalarValue)(nil)
+
+type scalarValue struct {
+ val any
+}
+
+func (s *scalarValue) GetRaw() any {
+ return s.val
+}
+
+func (s *scalarValue) Unmarshal(result any, opts ...UnmarshalOption) error {
+ settings := ApplyUnmarshalOptions(nil, opts)
+ return Decode(s.val, result, *settings, false)
+}
+
+func (s *scalarValue) Marshal(value any, opts ...MarshalOption) error {
+ if value == nil {
+ // If we receive a nil value, we encode it as nil map, which is how
+ // mapstructure represents null values. We still pass it through the
+ // confmap machinery to give it the same handling as other values.
+ value = map[string]any(nil)
+ }
+
+ settings := ApplyMarshalOptions(nil, opts)
+ data, err := Encode(value, *settings)
+ if err != nil {
+ return err
+ }
+ s.val = data
+
+ return nil
+}
+
+func (s *scalarValue) _unexported() {}
+
+// scalarUnmarshalerHookFunc handles decoding for types implementing the
+// ScalarUnmarshaler interface.
+func scalarUnmarshalerHookFunc() mapstructure.DecodeHookFuncValue {
+ return safeWrapDecodeHookFunc(func(from, to reflect.Value) (any, error) {
+ if !to.CanAddr() {
+ return from.Interface(), nil
+ }
+
+ toPtr := to.Addr().Interface()
+
+ unmarshaler, ok := toPtr.(ScalarUnmarshaler)
+ if !ok {
+ return from.Interface(), nil
+ }
+
+ val := from.Interface()
+
+ if from.Kind() == reflect.Map {
+ // Non-nil maps shouldn't be handled by this hook as they indicate
+ // struct-typed input.
+ if !from.IsNil() {
+ return from.Interface(), nil
+ }
+
+ // Simplify nil value handling by making the value an any-typed nil
+ // value instead of a nil map.
+ val = nil
+ }
+
+ sv := &scalarValue{val: val}
+
+ if err := unmarshaler.UnmarshalScalar(sv); err != nil {
+ if errors.Is(err, ErrValueNotApplicable) {
+ return from.Interface(), nil
+ }
+
+ return nil, err
+ }
+
+ return unmarshaler, nil
+ })
+}
+
+// scalarMarshalerHookFunc handles encoding for types implementing the
+// ScalarMarshaler interface.
+func scalarMarshalerHookFunc() mapstructure.DecodeHookFuncValue {
+ return safeWrapDecodeHookFunc(func(from, _ reflect.Value) (any, error) {
+ marshaler, ok := from.Interface().(ScalarMarshaler)
+ if !ok {
+ return from.Interface(), nil
+ }
+
+ res := &scalarValue{}
+ if err := marshaler.MarshalScalar(res); err != nil {
+ if errors.Is(err, ErrValueNotApplicable) {
+ return from.Interface(), nil
+ }
+
+ return nil, err
+ }
+
+ return res.GetRaw(), nil
+ })
+}
diff --git a/vendor/go.opentelemetry.io/collector/confmap/internal/unmarshaloption.go b/vendor/go.opentelemetry.io/collector/confmap/internal/unmarshaloption.go
index 77e38417e..ccdc13aef 100644
--- a/vendor/go.opentelemetry.io/collector/confmap/internal/unmarshaloption.go
+++ b/vendor/go.opentelemetry.io/collector/confmap/internal/unmarshaloption.go
@@ -19,3 +19,13 @@ type UnmarshalOptionFunc func(*UnmarshalOptions)
func (fn UnmarshalOptionFunc) apply(set *UnmarshalOptions) {
fn(set)
}
+
+func ApplyUnmarshalOptions(set *UnmarshalOptions, opts []UnmarshalOption) *UnmarshalOptions {
+ if set == nil {
+ set = &UnmarshalOptions{}
+ }
+ for _, opt := range opts {
+ opt.apply(set)
+ }
+ return set
+}
diff --git a/vendor/go.opentelemetry.io/collector/confmap/internal/validation.go b/vendor/go.opentelemetry.io/collector/confmap/internal/validation.go
new file mode 100644
index 000000000..b3f95609a
--- /dev/null
+++ b/vendor/go.opentelemetry.io/collector/confmap/internal/validation.go
@@ -0,0 +1,204 @@
+// Copyright The OpenTelemetry Authors
+// SPDX-License-Identifier: Apache-2.0
+
+package internal // import "go.opentelemetry.io/collector/confmap/internal"
+
+import (
+ "errors"
+ "fmt"
+ "reflect"
+ "strconv"
+ "strings"
+)
+
+// As interface types are only used for static typing, a common idiom to find the reflection Type
+// for an interface type Foo is to use a *Foo value.
+var configValidatorType = reflect.TypeFor[Validator]()
+
+// Validator defines an optional interface for configuration structs to
+// implement to check for validity before Collector startup.
+type Validator interface {
+ // Validate the configuration and returns an error if invalid.
+ Validate() error
+}
+
+// Validate validates a config struct by recursively checking if it or any of
+// its fields implement the Validator interface and performing validation on
+// each one that does. A struct failing validation will not cause validation to
+// stop; all structs will be validated, and all errors will be returned with a
+// single error created from [errors.Join].
+//
+// It is highly recommended that all config structs and config fields are
+// exported.
+//
+// Note that cyclic structures are not expected, and are therefore not protected
+// against.
+func Validate(cfg any) error {
+ var err error
+
+ for _, validationErr := range validate(reflect.ValueOf(cfg)) {
+ err = errors.Join(err, validationErr)
+ }
+
+ return err
+}
+
+type pathError struct {
+ err error
+ path []string
+}
+
+func (pe pathError) Error() string {
+ if len(pe.path) > 0 {
+ var path string
+ sb := strings.Builder{}
+
+ _, _ = sb.WriteString(pe.path[len(pe.path)-1])
+ for i := len(pe.path) - 2; i >= 0; i-- {
+ _, _ = sb.WriteString(KeyDelimiter)
+ _, _ = sb.WriteString(pe.path[i])
+ }
+ path = sb.String()
+
+ return fmt.Sprintf("%s: %s", path, pe.err)
+ }
+
+ return pe.err.Error()
+}
+
+func (pe pathError) Unwrap() error {
+ return pe.err
+}
+
+func validate(v reflect.Value) []pathError {
+ errs := []pathError{}
+ // Validate the value itself.
+ switch v.Kind() {
+ case reflect.Invalid:
+ return nil
+ case reflect.Ptr, reflect.Interface:
+ return validate(v.Elem())
+ case reflect.Struct:
+ err := callValidateIfPossible(v)
+ if err != nil {
+ errs = append(errs, pathError{err: err})
+ }
+
+ // Reflect on the pointed data and check each of its fields.
+ for i := 0; i < v.NumField(); i++ {
+ if !v.Type().Field(i).IsExported() {
+ continue
+ }
+ field := v.Type().Field(i)
+ path := fieldName(field)
+
+ subpathErrs := validate(v.Field(i))
+ for _, err := range subpathErrs {
+ errs = append(errs, pathError{
+ err: err.err,
+ path: append(err.path, path),
+ })
+ }
+ }
+ return errs
+ case reflect.Slice, reflect.Array:
+ err := callValidateIfPossible(v)
+ if err != nil {
+ errs = append(errs, pathError{err: err})
+ }
+
+ // Reflect on the pointed data and check each of its fields.
+ for i := 0; i < v.Len(); i++ {
+ subPathErrs := validate(v.Index(i))
+
+ for _, err := range subPathErrs {
+ errs = append(errs, pathError{
+ err: err.err,
+ path: append(err.path, strconv.Itoa(i)),
+ })
+ }
+ }
+ return errs
+ case reflect.Map:
+ err := callValidateIfPossible(v)
+ if err != nil {
+ errs = append(errs, pathError{err: err})
+ }
+
+ iter := v.MapRange()
+ for iter.Next() {
+ keyErrs := validate(iter.Key())
+ valueErrs := validate(iter.Value())
+ key := stringifyMapKey(iter.Key())
+
+ for _, err := range keyErrs {
+ errs = append(errs, pathError{err: err.err, path: append(err.path, key)})
+ }
+
+ for _, err := range valueErrs {
+ errs = append(errs, pathError{err: err.err, path: append(err.path, key)})
+ }
+ }
+ return errs
+ default:
+ err := callValidateIfPossible(v)
+ if err != nil {
+ return []pathError{{err: err}}
+ }
+
+ return nil
+ }
+}
+
+func callValidateIfPossible(v reflect.Value) error {
+ // If the value type implements ConfigValidator just call Validate
+ if v.Type().Implements(configValidatorType) {
+ return v.Interface().(Validator).Validate()
+ }
+
+ // If the pointer type implements ConfigValidator call Validate on the pointer to the current value.
+ if reflect.PointerTo(v.Type()).Implements(configValidatorType) {
+ // If not addressable, then create a new *V pointer and set the value to current v.
+ if !v.CanAddr() {
+ pv := reflect.New(reflect.PointerTo(v.Type()).Elem())
+ pv.Elem().Set(v)
+ v = pv.Elem()
+ }
+ return v.Addr().Interface().(Validator).Validate()
+ }
+
+ return nil
+}
+
+func fieldName(field reflect.StructField) string {
+ var fieldName string
+ if tag, ok := field.Tag.Lookup(MapstructureTag); ok {
+ tags := strings.Split(tag, ",")
+ if len(tags) > 0 {
+ fieldName = tags[0]
+ }
+ }
+ // Even if the mapstructure tag exists, the field name may not
+ // be available, so set it if it is still blank.
+ if fieldName == "" {
+ fieldName = strings.ToLower(field.Name)
+ }
+
+ return fieldName
+}
+
+func stringifyMapKey(val reflect.Value) string {
+ switch v := val.Interface().(type) {
+ case string:
+ return v
+ case fmt.Stringer:
+ return v.String()
+ default:
+ switch val.Kind() {
+ case reflect.Ptr, reflect.Interface, reflect.Struct, reflect.Slice, reflect.Array, reflect.Map:
+ return fmt.Sprintf("[%T key]", val.Interface())
+ default:
+ return fmt.Sprintf("%v", val.Interface())
+ }
+ }
+}
diff --git a/vendor/go.opentelemetry.io/collector/confmap/metadata.yaml b/vendor/go.opentelemetry.io/collector/confmap/metadata.yaml
index 99b0141ee..c4fae2571 100644
--- a/vendor/go.opentelemetry.io/collector/confmap/metadata.yaml
+++ b/vendor/go.opentelemetry.io/collector/confmap/metadata.yaml
@@ -17,8 +17,4 @@ feature_gates:
stage: alpha
from_version: 'v0.120.0'
reference_url: 'https://github.com/open-telemetry/opentelemetry-collector/issues/8754'
- - id: confmap.newExpandedValueSanitizer
- description: 'Fixes some types of decoding errors where environment variables are parsed as non-string types but assigned to string fields.'
- stage: beta
- from_version: 'v0.144.0'
- reference_url: 'https://github.com/open-telemetry/opentelemetry-collector/pull/14413'
+ skip_strict_validation: true
diff --git a/vendor/go.opentelemetry.io/collector/confmap/resolver.go b/vendor/go.opentelemetry.io/collector/confmap/resolver.go
index 4fa84f016..6f9c928c8 100644
--- a/vendor/go.opentelemetry.io/collector/confmap/resolver.go
+++ b/vendor/go.opentelemetry.io/collector/confmap/resolver.go
@@ -29,6 +29,10 @@ type Resolver struct {
closers []CloseFunc
watcher chan error
+
+ // unexpandedConfMap holds the merged configuration captured during the most
+ // recent Resolve call before provider/env-var references were expanded.
+ unexpandedConfMap map[string]any
}
// ResolverSettings are the settings to configure the behavior of the Resolver.
@@ -181,6 +185,9 @@ func (mr *Resolver) Resolve(ctx context.Context) (*Conf, error) {
}
}
+ // Capture the pre-expansion map (provider references intact) before expanding.
+ mr.unexpandedConfMap = retMap.ToStringMap()
+
cfgMap := make(map[string]any)
for _, k := range retMap.AllKeys() {
ug := internal.UnsanitizedGetter{Conf: retMap}
@@ -202,6 +209,20 @@ func (mr *Resolver) Resolve(ctx context.Context) (*Conf, error) {
return retMap, nil
}
+// UnexpandedConf returns a Conf built from the merged configuration as captured
+// by the most recent Resolve call, before provider and env-var references were
+// expanded (i.e. with ${env:FOO} syntax intact). Returns nil if Resolve has not
+// been called.
+//
+// Experimental: This method is experimental. Its behavior may change without backward
+// compatibility until this notice is removed.
+func (mr *Resolver) UnexpandedConf() *Conf {
+ if mr.unexpandedConfMap == nil {
+ return nil
+ }
+ return NewFromStringMap(mr.unexpandedConfMap)
+}
+
func escapeDollarSigns(val any) any {
switch v := val.(type) {
case string:
diff --git a/vendor/go.opentelemetry.io/collector/confmap/validation.go b/vendor/go.opentelemetry.io/collector/confmap/validation.go
new file mode 100644
index 000000000..974c31b56
--- /dev/null
+++ b/vendor/go.opentelemetry.io/collector/confmap/validation.go
@@ -0,0 +1,21 @@
+// Copyright The OpenTelemetry Authors
+// SPDX-License-Identifier: Apache-2.0
+
+package confmap // import "go.opentelemetry.io/collector/confmap"
+
+import (
+ "go.opentelemetry.io/collector/confmap/internal"
+)
+
+// Validator defines an optional interface for configuration structs to
+// implement to check for validity before Collector startup.
+type Validator = internal.Validator
+
+// Validate validates a config struct by recursively checking if it or any of
+// its fields implement the Validator interface and performing validation
+// on each one that does. A struct failing validation will not cause
+// validation to stop; all structs will be validated, and all errors
+// will be returned with a single error created from [errors.Join].
+func Validate(cfg any) error {
+ return internal.Validate(cfg)
+}
diff --git a/vendor/go.opentelemetry.io/collector/confmap/xconfmap/config.go b/vendor/go.opentelemetry.io/collector/confmap/xconfmap/config.go
index 28b40cf8b..8a2417efc 100644
--- a/vendor/go.opentelemetry.io/collector/confmap/xconfmap/config.go
+++ b/vendor/go.opentelemetry.io/collector/confmap/xconfmap/config.go
@@ -4,196 +4,21 @@
package xconfmap // import "go.opentelemetry.io/collector/confmap/xconfmap"
import (
- "errors"
- "fmt"
- "reflect"
- "strconv"
- "strings"
-
"go.opentelemetry.io/collector/confmap"
"go.opentelemetry.io/collector/confmap/internal"
)
-// As interface types are only used for static typing, a common idiom to find the reflection Type
-// for an interface type Foo is to use a *Foo value.
-var configValidatorType = reflect.TypeFor[Validator]()
-
// Validator defines an optional interface for configurations to implement to do validation.
-type Validator interface {
- // Validate the configuration and returns an error if invalid.
- Validate() error
-}
+//
+// Deprecated [v0.152.0]: Use `confmap.Validator“ instead.
+type Validator = internal.Validator
// Validate validates a config, by doing this:
// - Call Validate on the config itself if the config implements ConfigValidator.
+//
+// Deprecated [v0.152.0]: Use `confmap.Validate“ instead.
func Validate(cfg any) error {
- var err error
-
- for _, validationErr := range validate(reflect.ValueOf(cfg)) {
- err = errors.Join(err, validationErr)
- }
-
- return err
-}
-
-type pathError struct {
- err error
- path []string
-}
-
-func (pe pathError) Error() string {
- if len(pe.path) > 0 {
- var path string
- sb := strings.Builder{}
-
- _, _ = sb.WriteString(pe.path[len(pe.path)-1])
- for i := len(pe.path) - 2; i >= 0; i-- {
- _, _ = sb.WriteString(confmap.KeyDelimiter)
- _, _ = sb.WriteString(pe.path[i])
- }
- path = sb.String()
-
- return fmt.Sprintf("%s: %s", path, pe.err)
- }
-
- return pe.err.Error()
-}
-
-func (pe pathError) Unwrap() error {
- return pe.err
-}
-
-func validate(v reflect.Value) []pathError {
- errs := []pathError{}
- // Validate the value itself.
- switch v.Kind() {
- case reflect.Invalid:
- return nil
- case reflect.Ptr, reflect.Interface:
- return validate(v.Elem())
- case reflect.Struct:
- err := callValidateIfPossible(v)
- if err != nil {
- errs = append(errs, pathError{err: err})
- }
-
- // Reflect on the pointed data and check each of its fields.
- for i := 0; i < v.NumField(); i++ {
- if !v.Type().Field(i).IsExported() {
- continue
- }
- field := v.Type().Field(i)
- path := fieldName(field)
-
- subpathErrs := validate(v.Field(i))
- for _, err := range subpathErrs {
- errs = append(errs, pathError{
- err: err.err,
- path: append(err.path, path),
- })
- }
- }
- return errs
- case reflect.Slice, reflect.Array:
- err := callValidateIfPossible(v)
- if err != nil {
- errs = append(errs, pathError{err: err})
- }
-
- // Reflect on the pointed data and check each of its fields.
- for i := 0; i < v.Len(); i++ {
- subPathErrs := validate(v.Index(i))
-
- for _, err := range subPathErrs {
- errs = append(errs, pathError{
- err: err.err,
- path: append(err.path, strconv.Itoa(i)),
- })
- }
- }
- return errs
- case reflect.Map:
- err := callValidateIfPossible(v)
- if err != nil {
- errs = append(errs, pathError{err: err})
- }
-
- iter := v.MapRange()
- for iter.Next() {
- keyErrs := validate(iter.Key())
- valueErrs := validate(iter.Value())
- key := stringifyMapKey(iter.Key())
-
- for _, err := range keyErrs {
- errs = append(errs, pathError{err: err.err, path: append(err.path, key)})
- }
-
- for _, err := range valueErrs {
- errs = append(errs, pathError{err: err.err, path: append(err.path, key)})
- }
- }
- return errs
- default:
- err := callValidateIfPossible(v)
- if err != nil {
- return []pathError{{err: err}}
- }
-
- return nil
- }
-}
-
-func callValidateIfPossible(v reflect.Value) error {
- // If the value type implements ConfigValidator just call Validate
- if v.Type().Implements(configValidatorType) {
- return v.Interface().(Validator).Validate()
- }
-
- // If the pointer type implements ConfigValidator call Validate on the pointer to the current value.
- if reflect.PointerTo(v.Type()).Implements(configValidatorType) {
- // If not addressable, then create a new *V pointer and set the value to current v.
- if !v.CanAddr() {
- pv := reflect.New(reflect.PointerTo(v.Type()).Elem())
- pv.Elem().Set(v)
- v = pv.Elem()
- }
- return v.Addr().Interface().(Validator).Validate()
- }
-
- return nil
-}
-
-func fieldName(field reflect.StructField) string {
- var fieldName string
- if tag, ok := field.Tag.Lookup(confmap.MapstructureTag); ok {
- tags := strings.Split(tag, ",")
- if len(tags) > 0 {
- fieldName = tags[0]
- }
- }
- // Even if the mapstructure tag exists, the field name may not
- // be available, so set it if it is still blank.
- if fieldName == "" {
- fieldName = strings.ToLower(field.Name)
- }
-
- return fieldName
-}
-
-func stringifyMapKey(val reflect.Value) string {
- switch v := val.Interface().(type) {
- case string:
- return v
- case fmt.Stringer:
- return v.String()
- default:
- switch val.Kind() {
- case reflect.Ptr, reflect.Interface, reflect.Struct, reflect.Slice, reflect.Array, reflect.Map:
- return fmt.Sprintf("[%T key]", val.Interface())
- default:
- return fmt.Sprintf("%v", val.Interface())
- }
- }
+ return internal.Validate(cfg)
}
// WithForceUnmarshaler sets an option to run a top-level Unmarshal method,
@@ -202,6 +27,8 @@ func stringifyMapKey(val reflect.Value) string {
// a different type from the current Unmarshaler.
// For instance, this should be used in wrapper types such as configoptional.Optional
// to ensure the inner type's Unmarshal method is called.
+//
+// Deprecated [v0.157.0]: Use [confmap.WithForceUnmarshaler] instead.
func WithForceUnmarshaler() confmap.UnmarshalOption {
return internal.WithForceUnmarshaler()
}
diff --git a/vendor/go.opentelemetry.io/collector/featuregate/README.md b/vendor/go.opentelemetry.io/collector/featuregate/README.md
index 11eaab166..812e296e0 100644
--- a/vendor/go.opentelemetry.io/collector/featuregate/README.md
+++ b/vendor/go.opentelemetry.io/collector/featuregate/README.md
@@ -6,25 +6,36 @@ be able to govern the behavior of the application starting as early as possible
and should be available to every component such that decisions may be made
based on flags at the component level.
-## Usage
+## Defining Feature Gates
-### With mdatagen
+### Declaratively in `metadata.yaml` (Recommended)
-In components that use mdatagen, feature gates should be defined in the
-component's `metadata.yml`.
+The preferred way to define feature gates is declaratively in the component's
+`metadata.yaml` file. The `mdatagen` code generator will automatically register
+the gate and generate the necessary Go code.
```yaml
feature_gates:
- id: namespaced.uniqueIdentifier
description: A brief description of what the gate controls
- stage: stable
+ stage: alpha
from_version: 'v0.65.0'
reference_url: 'https://github.com/open-telemetry/opentelemetry-collector/issues/6167'
```
-Running the mdatagen code generator with this configuration will initialize the
-feature flag in the `internal/metadata` submodule.
-The status of the gate can later be checked by calling that submodule:
+The supported fields are:
+
+| Field | Required | Description |
+|-------|----------|-------------|
+| `id` | Yes | Unique identifier for the feature gate |
+| `description` | Yes | Brief description of what the gate controls |
+| `stage` | Yes | Lifecycle stage: `alpha`, `beta`, `stable`, or `deprecated` |
+| `from_version` | Yes | Version when the feature gate was introduced |
+| `to_version` | For `stable`/`deprecated` | Version when the gate reached its current stage |
+| `reference_url` | Yes | URL with contextual information (issue or PR) |
+
+Running `mdatagen` will generate the gate registration in the `internal/metadata`
+submodule. The status of the gate can then be checked in code:
```go
if metadata.NamespacedUniqueIdentifierFeatureGate.IsEnabled() {
@@ -32,9 +43,11 @@ if metadata.NamespacedUniqueIdentifierFeatureGate.IsEnabled() {
}
```
-### In code
+See the [mdatagen documentation](../cmd/mdatagen/README.md) for more details.
+
+### Programmatically in code
-In components that don't use mdatagen, feature gates can be defined and
+For packages that don't use `mdatagen`, feature gates can be defined and
registered with the global registry in an `init()` function. This makes the
`Gate` available to be configured and queried with the defined
[`Stage`](#feature-lifecycle) default value.
diff --git a/vendor/go.opentelemetry.io/collector/featuregate/flag.go b/vendor/go.opentelemetry.io/collector/featuregate/flag.go
index 1c6f3a5e8..6f5a27070 100644
--- a/vendor/go.opentelemetry.io/collector/featuregate/flag.go
+++ b/vendor/go.opentelemetry.io/collector/featuregate/flag.go
@@ -5,6 +5,7 @@ package featuregate // import "go.opentelemetry.io/collector/featuregate"
import (
"flag"
+ "fmt"
"strings"
"go.uber.org/multierr"
@@ -57,6 +58,10 @@ func (f *flagValue) Set(s string) error {
ids := strings.Split(s, ",")
for i := range ids {
id := ids[i]
+ if id == "" {
+ errs = multierr.Append(errs, fmt.Errorf("empty feature gate identifier at index %d", i))
+ continue
+ }
val := true
switch id[0] {
case '-':
diff --git a/vendor/go.opentelemetry.io/collector/featuregate/gate.go b/vendor/go.opentelemetry.io/collector/featuregate/gate.go
index a250ceb9a..1a2bab916 100644
--- a/vendor/go.opentelemetry.io/collector/featuregate/gate.go
+++ b/vendor/go.opentelemetry.io/collector/featuregate/gate.go
@@ -52,7 +52,8 @@ func (g *Gate) FromVersion() string {
return fmt.Sprintf("v%s", g.fromVersion)
}
-// ToVersion returns the version information when Gate's in StageStable.
+// ToVersion returns the version information when Gate will be removed.
+// For Stable and Deprecated stages, this is the last Collector release where this gate can be used.
func (g *Gate) ToVersion() string {
return fmt.Sprintf("v%s", g.toVersion)
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_anyvalue.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_anyvalue.go
index 404c61891..032051078 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_anyvalue.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_anyvalue.go
@@ -523,7 +523,7 @@ func (orig *AnyValue) UnmarshalJSON(iter *json.Iterator) {
}
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_arrayvalue.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_arrayvalue.go
index dc041f4e6..40c8f5696 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_arrayvalue.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_arrayvalue.go
@@ -150,7 +150,7 @@ func (orig *ArrayValue) UnmarshalJSON(iter *json.Iterator) {
}
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_entityref.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_entityref.go
index 58c6b3249..a8bf994df 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_entityref.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_entityref.go
@@ -182,7 +182,7 @@ func (orig *EntityRef) UnmarshalJSON(iter *json.Iterator) {
}
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exemplar.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exemplar.go
index 231d1a79e..c277d671f 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exemplar.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exemplar.go
@@ -296,7 +296,7 @@ func (orig *Exemplar) UnmarshalJSON(iter *json.Iterator) {
orig.SpanId.UnmarshalJSON(iter)
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exponentialhistogram.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exponentialhistogram.go
index d46dc1344..6ea48296f 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exponentialhistogram.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exponentialhistogram.go
@@ -162,7 +162,7 @@ func (orig *ExponentialHistogram) UnmarshalJSON(iter *json.Iterator) {
case "aggregationTemporality", "aggregation_temporality":
orig.AggregationTemporality = AggregationTemporality(iter.ReadEnumValue(AggregationTemporality_value))
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exponentialhistogramdatapoint.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exponentialhistogramdatapoint.go
index c637459b3..2b674760a 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exponentialhistogramdatapoint.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exponentialhistogramdatapoint.go
@@ -298,7 +298,7 @@ func (orig *ExponentialHistogramDataPoint) UnmarshalJSON(iter *json.Iterator) {
case "zeroThreshold", "zero_threshold":
orig.ZeroThreshold = iter.ReadFloat64()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exponentialhistogramdatapointbuckets.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exponentialhistogramdatapointbuckets.go
index 6908a66d2..b4046ab04 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exponentialhistogramdatapointbuckets.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exponentialhistogramdatapointbuckets.go
@@ -156,7 +156,7 @@ func (orig *ExponentialHistogramDataPointBuckets) UnmarshalJSON(iter *json.Itera
}
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportlogspartialsuccess.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportlogspartialsuccess.go
index 2e3eb5060..f6eb015ed 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportlogspartialsuccess.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportlogspartialsuccess.go
@@ -146,7 +146,7 @@ func (orig *ExportLogsPartialSuccess) UnmarshalJSON(iter *json.Iterator) {
case "errorMessage", "error_message":
orig.ErrorMessage = iter.ReadString()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportlogsservicerequest.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportlogsservicerequest.go
index cdfb591d7..ef9948ee7 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportlogsservicerequest.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportlogsservicerequest.go
@@ -151,7 +151,7 @@ func (orig *ExportLogsServiceRequest) UnmarshalJSON(iter *json.Iterator) {
}
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportlogsserviceresponse.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportlogsserviceresponse.go
index b2271520f..2d2e70c4f 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportlogsserviceresponse.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportlogsserviceresponse.go
@@ -137,7 +137,7 @@ func (orig *ExportLogsServiceResponse) UnmarshalJSON(iter *json.Iterator) {
orig.PartialSuccess.UnmarshalJSON(iter)
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportmetricspartialsuccess.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportmetricspartialsuccess.go
index 27e965641..cbad581e3 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportmetricspartialsuccess.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportmetricspartialsuccess.go
@@ -146,7 +146,7 @@ func (orig *ExportMetricsPartialSuccess) UnmarshalJSON(iter *json.Iterator) {
case "errorMessage", "error_message":
orig.ErrorMessage = iter.ReadString()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportmetricsservicerequest.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportmetricsservicerequest.go
index c926b5487..24bf969ec 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportmetricsservicerequest.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportmetricsservicerequest.go
@@ -151,7 +151,7 @@ func (orig *ExportMetricsServiceRequest) UnmarshalJSON(iter *json.Iterator) {
}
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportmetricsserviceresponse.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportmetricsserviceresponse.go
index 222d5825f..183230b55 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportmetricsserviceresponse.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportmetricsserviceresponse.go
@@ -137,7 +137,7 @@ func (orig *ExportMetricsServiceResponse) UnmarshalJSON(iter *json.Iterator) {
orig.PartialSuccess.UnmarshalJSON(iter)
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportprofilespartialsuccess.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportprofilespartialsuccess.go
index 8077e8a04..ed8413e93 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportprofilespartialsuccess.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportprofilespartialsuccess.go
@@ -146,7 +146,7 @@ func (orig *ExportProfilesPartialSuccess) UnmarshalJSON(iter *json.Iterator) {
case "errorMessage", "error_message":
orig.ErrorMessage = iter.ReadString()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportprofilesservicerequest.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportprofilesservicerequest.go
index 72d876c97..d6700d35b 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportprofilesservicerequest.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportprofilesservicerequest.go
@@ -160,7 +160,7 @@ func (orig *ExportProfilesServiceRequest) UnmarshalJSON(iter *json.Iterator) {
orig.Dictionary.UnmarshalJSON(iter)
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportprofilesserviceresponse.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportprofilesserviceresponse.go
index 383058bc6..343b25b88 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportprofilesserviceresponse.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportprofilesserviceresponse.go
@@ -137,7 +137,7 @@ func (orig *ExportProfilesServiceResponse) UnmarshalJSON(iter *json.Iterator) {
orig.PartialSuccess.UnmarshalJSON(iter)
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exporttracepartialsuccess.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exporttracepartialsuccess.go
index bf6b8f6bf..237330dc1 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exporttracepartialsuccess.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exporttracepartialsuccess.go
@@ -146,7 +146,7 @@ func (orig *ExportTracePartialSuccess) UnmarshalJSON(iter *json.Iterator) {
case "errorMessage", "error_message":
orig.ErrorMessage = iter.ReadString()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exporttraceservicerequest.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exporttraceservicerequest.go
index 408d5aa46..014201455 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exporttraceservicerequest.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exporttraceservicerequest.go
@@ -151,7 +151,7 @@ func (orig *ExportTraceServiceRequest) UnmarshalJSON(iter *json.Iterator) {
}
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exporttraceserviceresponse.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exporttraceserviceresponse.go
index 4437f3dec..661771a2e 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exporttraceserviceresponse.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exporttraceserviceresponse.go
@@ -137,7 +137,7 @@ func (orig *ExportTraceServiceResponse) UnmarshalJSON(iter *json.Iterator) {
orig.PartialSuccess.UnmarshalJSON(iter)
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_function.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_function.go
index a2d0b1b86..5d3a772e6 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_function.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_function.go
@@ -162,7 +162,7 @@ func (orig *Function) UnmarshalJSON(iter *json.Iterator) {
case "startLine", "start_line":
orig.StartLine = iter.ReadInt64()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_gauge.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_gauge.go
index 5d2b46751..d91863263 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_gauge.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_gauge.go
@@ -150,7 +150,7 @@ func (orig *Gauge) UnmarshalJSON(iter *json.Iterator) {
}
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_histogram.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_histogram.go
index 3d9c149ce..cfd99b33f 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_histogram.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_histogram.go
@@ -161,7 +161,7 @@ func (orig *Histogram) UnmarshalJSON(iter *json.Iterator) {
case "aggregationTemporality", "aggregation_temporality":
orig.AggregationTemporality = AggregationTemporality(iter.ReadEnumValue(AggregationTemporality_value))
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_histogramdatapoint.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_histogramdatapoint.go
index 0d28369f4..ef558bad0 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_histogramdatapoint.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_histogramdatapoint.go
@@ -289,7 +289,7 @@ func (orig *HistogramDataPoint) UnmarshalJSON(iter *json.Iterator) {
orig.SetMax(iter.ReadFloat64())
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_instrumentationscope.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_instrumentationscope.go
index a8162b433..f557ff14c 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_instrumentationscope.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_instrumentationscope.go
@@ -177,7 +177,7 @@ func (orig *InstrumentationScope) UnmarshalJSON(iter *json.Iterator) {
case "droppedAttributesCount", "dropped_attributes_count":
orig.DroppedAttributesCount = iter.ReadUint32()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_ipaddr.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_ipaddr.go
index 3b72d1d22..adcb5a02b 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_ipaddr.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_ipaddr.go
@@ -146,7 +146,7 @@ func (orig *IPAddr) UnmarshalJSON(iter *json.Iterator) {
case "zone":
orig.Zone = iter.ReadString()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_keyvalue.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_keyvalue.go
index 5f80a111a..43099dd40 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_keyvalue.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_keyvalue.go
@@ -155,7 +155,7 @@ func (orig *KeyValue) UnmarshalJSON(iter *json.Iterator) {
case "keyStrindex", "key_strindex":
orig.KeyStrindex = iter.ReadInt32()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_keyvalueandunit.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_keyvalueandunit.go
index 3e0c6cf92..d9dec2874 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_keyvalueandunit.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_keyvalueandunit.go
@@ -158,7 +158,7 @@ func (orig *KeyValueAndUnit) UnmarshalJSON(iter *json.Iterator) {
case "unitStrindex", "unit_strindex":
orig.UnitStrindex = iter.ReadInt32()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_keyvaluelist.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_keyvaluelist.go
index 9cb772d4c..4e96b4bbc 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_keyvaluelist.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_keyvaluelist.go
@@ -150,7 +150,7 @@ func (orig *KeyValueList) UnmarshalJSON(iter *json.Iterator) {
}
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_line.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_line.go
index 0fe3a738b..8654a9871 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_line.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_line.go
@@ -154,7 +154,7 @@ func (orig *Line) UnmarshalJSON(iter *json.Iterator) {
case "column":
orig.Column = iter.ReadInt64()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_link.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_link.go
index 9d62117e8..2874c8bfe 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_link.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_link.go
@@ -150,7 +150,7 @@ func (orig *Link) UnmarshalJSON(iter *json.Iterator) {
orig.SpanId.UnmarshalJSON(iter)
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_location.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_location.go
index c75ed04c9..4c93c390f 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_location.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_location.go
@@ -187,7 +187,7 @@ func (orig *Location) UnmarshalJSON(iter *json.Iterator) {
}
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_logrecord.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_logrecord.go
index c3e449246..d878ca0c5 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_logrecord.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_logrecord.go
@@ -244,7 +244,7 @@ func (orig *LogRecord) UnmarshalJSON(iter *json.Iterator) {
case "eventName", "event_name":
orig.EventName = iter.ReadString()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_logsdata.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_logsdata.go
index 7f7f3bfb9..fb326ca5d 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_logsdata.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_logsdata.go
@@ -152,7 +152,7 @@ func (orig *LogsData) UnmarshalJSON(iter *json.Iterator) {
}
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_logsrequest.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_logsrequest.go
index 4e18c3050..9b3730afc 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_logsrequest.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_logsrequest.go
@@ -158,7 +158,7 @@ func (orig *LogsRequest) UnmarshalJSON(iter *json.Iterator) {
case "formatVersion", "format_version":
orig.FormatVersion = iter.ReadUint32()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_mapping.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_mapping.go
index ec1462389..a527313a1 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_mapping.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_mapping.go
@@ -180,7 +180,7 @@ func (orig *Mapping) UnmarshalJSON(iter *json.Iterator) {
}
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_metric.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_metric.go
index b7c1587b9..4ad7d15fa 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_metric.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_metric.go
@@ -439,7 +439,7 @@ func (orig *Metric) UnmarshalJSON(iter *json.Iterator) {
}
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_metricsdata.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_metricsdata.go
index 48248dc45..c7aee27ee 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_metricsdata.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_metricsdata.go
@@ -152,7 +152,7 @@ func (orig *MetricsData) UnmarshalJSON(iter *json.Iterator) {
}
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_metricsrequest.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_metricsrequest.go
index da51b989d..edfe90741 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_metricsrequest.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_metricsrequest.go
@@ -158,7 +158,7 @@ func (orig *MetricsRequest) UnmarshalJSON(iter *json.Iterator) {
case "formatVersion", "format_version":
orig.FormatVersion = iter.ReadUint32()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_numberdatapoint.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_numberdatapoint.go
index 99f5f7661..e74c59b33 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_numberdatapoint.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_numberdatapoint.go
@@ -311,7 +311,7 @@ func (orig *NumberDataPoint) UnmarshalJSON(iter *json.Iterator) {
case "flags":
orig.Flags = iter.ReadUint32()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profile.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profile.go
index d40303aee..553105af2 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profile.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profile.go
@@ -252,7 +252,7 @@ func (orig *Profile) UnmarshalJSON(iter *json.Iterator) {
}
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profilesdata.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profilesdata.go
index 491a81955..c83ea0164 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profilesdata.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profilesdata.go
@@ -161,7 +161,7 @@ func (orig *ProfilesData) UnmarshalJSON(iter *json.Iterator) {
orig.Dictionary.UnmarshalJSON(iter)
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profilesdictionary.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profilesdictionary.go
index 8471828e6..b82b650b3 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profilesdictionary.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profilesdictionary.go
@@ -280,7 +280,7 @@ func (orig *ProfilesDictionary) UnmarshalJSON(iter *json.Iterator) {
}
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profilesrequest.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profilesrequest.go
index 170547c09..2fd9d78b2 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profilesrequest.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profilesrequest.go
@@ -158,7 +158,7 @@ func (orig *ProfilesRequest) UnmarshalJSON(iter *json.Iterator) {
case "formatVersion", "format_version":
orig.FormatVersion = iter.ReadUint32()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_requestcontext.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_requestcontext.go
index 3aa89c1ca..808f7e364 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_requestcontext.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_requestcontext.go
@@ -374,7 +374,7 @@ func (orig *RequestContext) UnmarshalJSON(iter *json.Iterator) {
}
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resource.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resource.go
index 9a1a0bba1..2b89f32e0 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resource.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resource.go
@@ -181,7 +181,7 @@ func (orig *Resource) UnmarshalJSON(iter *json.Iterator) {
}
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourcelogs.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourcelogs.go
index d7b8c732b..de02d7d64 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourcelogs.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourcelogs.go
@@ -190,7 +190,7 @@ func (orig *ResourceLogs) UnmarshalJSON(iter *json.Iterator) {
}
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourcemetrics.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourcemetrics.go
index 364a719ba..7e375a012 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourcemetrics.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourcemetrics.go
@@ -190,7 +190,7 @@ func (orig *ResourceMetrics) UnmarshalJSON(iter *json.Iterator) {
}
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourceprofiles.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourceprofiles.go
index 3a6e83db2..8d759baaa 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourceprofiles.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourceprofiles.go
@@ -169,7 +169,7 @@ func (orig *ResourceProfiles) UnmarshalJSON(iter *json.Iterator) {
case "schemaUrl", "schema_url":
orig.SchemaUrl = iter.ReadString()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourcespans.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourcespans.go
index 4c1bb0786..18fe12bdb 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourcespans.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourcespans.go
@@ -190,7 +190,7 @@ func (orig *ResourceSpans) UnmarshalJSON(iter *json.Iterator) {
}
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_sample.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_sample.go
index c53dc105a..5d0cadd9b 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_sample.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_sample.go
@@ -203,7 +203,7 @@ func (orig *Sample) UnmarshalJSON(iter *json.Iterator) {
}
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopelogs.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopelogs.go
index 0a04cfdd3..21f101529 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopelogs.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopelogs.go
@@ -169,7 +169,7 @@ func (orig *ScopeLogs) UnmarshalJSON(iter *json.Iterator) {
case "schemaUrl", "schema_url":
orig.SchemaUrl = iter.ReadString()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopemetrics.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopemetrics.go
index 957d10305..51085e812 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopemetrics.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopemetrics.go
@@ -169,7 +169,7 @@ func (orig *ScopeMetrics) UnmarshalJSON(iter *json.Iterator) {
case "schemaUrl", "schema_url":
orig.SchemaUrl = iter.ReadString()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopeprofiles.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopeprofiles.go
index ca13dbc36..b8a9a4d3b 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopeprofiles.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopeprofiles.go
@@ -169,7 +169,7 @@ func (orig *ScopeProfiles) UnmarshalJSON(iter *json.Iterator) {
case "schemaUrl", "schema_url":
orig.SchemaUrl = iter.ReadString()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopespans.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopespans.go
index 85e4fae2d..0b9473c64 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopespans.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopespans.go
@@ -169,7 +169,7 @@ func (orig *ScopeSpans) UnmarshalJSON(iter *json.Iterator) {
case "schemaUrl", "schema_url":
orig.SchemaUrl = iter.ReadString()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_span.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_span.go
index 32dbe4f3c..43081e574 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_span.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_span.go
@@ -316,7 +316,7 @@ func (orig *Span) UnmarshalJSON(iter *json.Iterator) {
orig.Status.UnmarshalJSON(iter)
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_spancontext.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_spancontext.go
index e63b8ef49..bd98320ea 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_spancontext.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_spancontext.go
@@ -176,7 +176,7 @@ func (orig *SpanContext) UnmarshalJSON(iter *json.Iterator) {
case "remote":
orig.Remote = iter.ReadBool()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_spanevent.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_spanevent.go
index 269aee7d9..2211f06ba 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_spanevent.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_spanevent.go
@@ -179,7 +179,7 @@ func (orig *SpanEvent) UnmarshalJSON(iter *json.Iterator) {
case "droppedAttributesCount", "dropped_attributes_count":
orig.DroppedAttributesCount = iter.ReadUint32()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_spanlink.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_spanlink.go
index ee2ccfa06..e0b9f7d87 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_spanlink.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_spanlink.go
@@ -202,7 +202,7 @@ func (orig *SpanLink) UnmarshalJSON(iter *json.Iterator) {
case "flags":
orig.Flags = iter.ReadUint32()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_stack.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_stack.go
index 90bf79fa2..01564d8d6 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_stack.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_stack.go
@@ -149,7 +149,7 @@ func (orig *Stack) UnmarshalJSON(iter *json.Iterator) {
}
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_status.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_status.go
index 35ae797c9..34ba6a189 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_status.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_status.go
@@ -148,7 +148,7 @@ func (orig *Status) UnmarshalJSON(iter *json.Iterator) {
case "code":
orig.Code = StatusCode(iter.ReadEnumValue(StatusCode_value))
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_sum.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_sum.go
index d0c601ee8..b25f636ec 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_sum.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_sum.go
@@ -169,7 +169,7 @@ func (orig *Sum) UnmarshalJSON(iter *json.Iterator) {
case "isMonotonic", "is_monotonic":
orig.IsMonotonic = iter.ReadBool()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_summary.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_summary.go
index 0b62ef765..a625417cd 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_summary.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_summary.go
@@ -150,7 +150,7 @@ func (orig *Summary) UnmarshalJSON(iter *json.Iterator) {
}
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_summarydatapoint.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_summarydatapoint.go
index 5402264ee..cc1dfa170 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_summarydatapoint.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_summarydatapoint.go
@@ -217,7 +217,7 @@ func (orig *SummaryDataPoint) UnmarshalJSON(iter *json.Iterator) {
case "flags":
orig.Flags = iter.ReadUint32()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_summarydatapointvalueatquantile.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_summarydatapointvalueatquantile.go
index a2910b738..1777927ce 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_summarydatapointvalueatquantile.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_summarydatapointvalueatquantile.go
@@ -148,7 +148,7 @@ func (orig *SummaryDataPointValueAtQuantile) UnmarshalJSON(iter *json.Iterator)
case "value":
orig.Value = iter.ReadFloat64()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_tcpaddr.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_tcpaddr.go
index 5392f07d0..d92303717 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_tcpaddr.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_tcpaddr.go
@@ -154,7 +154,7 @@ func (orig *TCPAddr) UnmarshalJSON(iter *json.Iterator) {
case "zone":
orig.Zone = iter.ReadString()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_tracesdata.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_tracesdata.go
index e81853de7..fe6bc110f 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_tracesdata.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_tracesdata.go
@@ -152,7 +152,7 @@ func (orig *TracesData) UnmarshalJSON(iter *json.Iterator) {
}
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_tracesrequest.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_tracesrequest.go
index a54dedaef..7869b6d72 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_tracesrequest.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_tracesrequest.go
@@ -158,7 +158,7 @@ func (orig *TracesRequest) UnmarshalJSON(iter *json.Iterator) {
case "formatVersion", "format_version":
orig.FormatVersion = iter.ReadUint32()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_udpaddr.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_udpaddr.go
index efd539941..25044ff4c 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_udpaddr.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_udpaddr.go
@@ -154,7 +154,7 @@ func (orig *UDPAddr) UnmarshalJSON(iter *json.Iterator) {
case "zone":
orig.Zone = iter.ReadString()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_unixaddr.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_unixaddr.go
index c301df487..494cffea2 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_unixaddr.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_unixaddr.go
@@ -145,7 +145,7 @@ func (orig *UnixAddr) UnmarshalJSON(iter *json.Iterator) {
case "net":
orig.Net = iter.ReadString()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_valuetype.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_valuetype.go
index 676418994..55727332a 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_valuetype.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_valuetype.go
@@ -146,7 +146,7 @@ func (orig *ValueType) UnmarshalJSON(iter *json.Iterator) {
case "unitStrindex", "unit_strindex":
orig.UnitStrindex = iter.ReadInt32()
default:
- iter.Skip()
+ iter.HandleUnknownField(f)
}
}
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/json/iterator.go b/vendor/go.opentelemetry.io/collector/pdata/internal/json/iterator.go
index f0367e11d..16d57cae5 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/json/iterator.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/json/iterator.go
@@ -20,7 +20,28 @@ func ReturnIterator(s *Iterator) {
}
type Iterator struct {
- delegate *jsoniter.Iterator
+ delegate *jsoniter.Iterator
+ disallowUnknownFields bool
+}
+
+// SetDisallowUnknownFields configures whether unknown fields encountered during
+// JSON unmarshalling cause an error. When set to true, [Iterator.HandleUnknownField]
+// records an error instead of skipping the field.
+func (iter *Iterator) SetDisallowUnknownFields(b bool) *Iterator {
+ iter.disallowUnknownFields = b
+ return iter
+}
+
+// HandleUnknownField is called by generated UnmarshalJSON code when an
+// unrecognized JSON field is encountered. By default the field's value is
+// skipped, but if [Iterator.SetDisallowUnknownFields] was set to true, an
+// error is recorded on the iterator instead.
+func (iter *Iterator) HandleUnknownField(field string) {
+ if iter.disallowUnknownFields {
+ iter.ReportError("UnmarshalJSON", "unknown field \""+field+"\"")
+ return
+ }
+ iter.Skip()
}
// ReadInt32 unmarshalls JSON data into an int32. Accepts both numbers and strings decimal.
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/metadata/generated_feature_gates.go b/vendor/go.opentelemetry.io/collector/pdata/internal/metadata/generated_feature_gates.go
index 2fb2365cf..4bb5a4849 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/metadata/generated_feature_gates.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/metadata/generated_feature_gates.go
@@ -6,15 +6,6 @@ import (
"go.opentelemetry.io/collector/featuregate"
)
-var PdataUseCustomProtoEncodingFeatureGate = featuregate.GlobalRegistry().MustRegister(
- "pdata.useCustomProtoEncoding",
- featuregate.StageStable,
- featuregate.WithRegisterDescription("When enabled, enable custom proto encoding. This is a required step to enable featuregate pdata.useProtoPooling."),
- featuregate.WithRegisterReferenceURL("https://github.com/open-telemetry/opentelemetry-collector/issues/13631"),
- featuregate.WithRegisterFromVersion("v0.133.0"),
- featuregate.WithRegisterToVersion("v0.137.0"),
-)
-
var PdataUseProtoPoolingFeatureGate = featuregate.GlobalRegistry().MustRegister(
"pdata.useProtoPooling",
featuregate.StageAlpha,
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/otelgrpc/logs_service.go b/vendor/go.opentelemetry.io/collector/pdata/internal/otelgrpc/logs_service.go
index ef26e3654..4ef17b89a 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/otelgrpc/logs_service.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/otelgrpc/logs_service.go
@@ -57,7 +57,7 @@ func RegisterLogsServiceServer(s *grpc.Server, srv LogsServiceServer) {
//
//nolint:revive
func logsServiceExportHandler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
- in := new(internal.ExportLogsServiceRequest)
+ in := internal.NewExportLogsServiceRequest()
if err := dec(in); err != nil {
return nil, err
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/otelgrpc/metrics_service.go b/vendor/go.opentelemetry.io/collector/pdata/internal/otelgrpc/metrics_service.go
index daf4f5cc8..f05e76e1d 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/otelgrpc/metrics_service.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/otelgrpc/metrics_service.go
@@ -57,7 +57,7 @@ func RegisterMetricsServiceServer(s *grpc.Server, srv MetricsServiceServer) {
//
//nolint:revive
func metricsServiceExportHandler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
- in := new(internal.ExportMetricsServiceRequest)
+ in := internal.NewExportMetricsServiceRequest()
if err := dec(in); err != nil {
return nil, err
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/otelgrpc/profiles_service.go b/vendor/go.opentelemetry.io/collector/pdata/internal/otelgrpc/profiles_service.go
index db846146f..c91220b26 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/otelgrpc/profiles_service.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/otelgrpc/profiles_service.go
@@ -57,7 +57,7 @@ func RegisterProfilesServiceServer(s *grpc.Server, srv ProfilesServiceServer) {
//
//nolint:revive
func profilesServiceExportHandler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
- in := new(internal.ExportProfilesServiceRequest)
+ in := internal.NewExportProfilesServiceRequest()
if err := dec(in); err != nil {
return nil, err
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/otelgrpc/trace_service.go b/vendor/go.opentelemetry.io/collector/pdata/internal/otelgrpc/trace_service.go
index 943f61792..1f5fbe9a1 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/internal/otelgrpc/trace_service.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/internal/otelgrpc/trace_service.go
@@ -57,7 +57,7 @@ func RegisterTraceServiceServer(s *grpc.Server, srv TraceServiceServer) {
//
//nolint:revive
func traceServiceExportHandler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
- in := new(internal.ExportTraceServiceRequest)
+ in := internal.NewExportTraceServiceRequest()
if err := dec(in); err != nil {
return nil, err
}
diff --git a/vendor/go.opentelemetry.io/collector/pdata/pcommon/value.go b/vendor/go.opentelemetry.io/collector/pdata/pcommon/value.go
index 3c39e704e..807eae335 100644
--- a/vendor/go.opentelemetry.io/collector/pdata/pcommon/value.go
+++ b/vendor/go.opentelemetry.io/collector/pdata/pcommon/value.go
@@ -4,11 +4,13 @@
package pcommon // import "go.opentelemetry.io/collector/pdata/pcommon"
import (
+ "bytes"
"encoding/base64"
"encoding/json"
"fmt"
"math"
"strconv"
+ "strings"
"go.opentelemetry.io/collector/pdata/internal"
)
@@ -401,26 +403,47 @@ func (v Value) AsString() string {
return strconv.FormatInt(v.Int(), 10)
case ValueTypeMap:
- jsonStr, _ := json.Marshal(v.Map().AsRaw())
- return string(jsonStr)
+ return marshalJSONNoHTMLEscape(v.Map().AsRaw())
case ValueTypeBytes:
return base64.StdEncoding.EncodeToString(*v.Bytes().getOrig())
case ValueTypeSlice:
- jsonStr, _ := json.Marshal(v.Slice().AsRaw())
- return string(jsonStr)
+ return marshalJSONNoHTMLEscape(v.Slice().AsRaw())
default:
return fmt.Sprintf("