diff --git a/go.mod b/go.mod index e3f660eb1..c6072a362 100644 --- a/go.mod +++ b/go.mod @@ -142,7 +142,7 @@ require ( 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/openai/openai-go/v3 v3.41.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 diff --git a/go.sum b/go.sum index 49f9dee7a..f2ee6f954 100644 --- a/go.sum +++ b/go.sum @@ -390,8 +390,8 @@ github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.150.0 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/openai/openai-go/v3 v3.41.0 h1:9GkxcN02U5NG0WGdQjZ0cTSu/pMXEyzL2LfF0ruZCck= +github.com/openai/openai-go/v3 v3.41.0/go.mod h1:cdufnVK14cWcT9qA1rRtrXx4FTRsgbDPW7Ia7SS5cZo= 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= diff --git a/vendor/github.com/openai/openai-go/v3/.release-please-manifest.json b/vendor/github.com/openai/openai-go/v3/.release-please-manifest.json index 89303d577..2ee93a5e6 100644 --- a/vendor/github.com/openai/openai-go/v3/.release-please-manifest.json +++ b/vendor/github.com/openai/openai-go/v3/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "3.32.0" + ".": "3.41.0" } \ No newline at end of file diff --git a/vendor/github.com/openai/openai-go/v3/.stats.yml b/vendor/github.com/openai/openai-go/v3/.stats.yml index 482b4b703..f0ea95a62 100644 --- a/vendor/github.com/openai/openai-go/v3/.stats.yml +++ b/vendor/github.com/openai/openai-go/v3/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 139 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-64c6ba619ccbf87e56b4f464230d04401fd78ad924d2606176309d19ca281af5.yml -openapi_spec_hash: 5e4f2073040a12c26ce58e86a72fe47e -config_hash: 1a88b104658b6c854117996c080ebe6b +configured_endpoints: 251 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-b5b621065906a2579dc180db1236ee3b08a4fca9539accc2fbbf88da0ca3923f.yml +openapi_spec_hash: 45b1b4692b26e714008d8120ccfc7433 +config_hash: ef3ce17315a31703e7af0567b3e9738c diff --git a/vendor/github.com/openai/openai-go/v3/CHANGELOG.md b/vendor/github.com/openai/openai-go/v3/CHANGELOG.md index d6fa816d4..5a79a84e1 100644 --- a/vendor/github.com/openai/openai-go/v3/CHANGELOG.md +++ b/vendor/github.com/openai/openai-go/v3/CHANGELOG.md @@ -1,5 +1,149 @@ # Changelog +## 3.41.0 (2026-06-17) + +Full Changelog: [v3.40.0...v3.41.0](https://github.com/openai/openai-go/compare/v3.40.0...v3.41.0) + +### Features + +* **api:** update OpenAPI spec or Stainless config ([868891f](https://github.com/openai/openai-go/commit/868891f7fd02f5f92fa86a8b7a0fcd7a8c950bb1)) + +## 3.40.0 (2026-06-16) + +Full Changelog: [v3.39.0...v3.40.0](https://github.com/openai/openai-go/compare/v3.39.0...v3.40.0) + +### Features + +* **api:** admin spend_alerts ([26992e5](https://github.com/openai/openai-go/commit/26992e5e1d4553d51cc63dddb0c0817a6940448c)) +* **api:** manual updates ([28f7e09](https://github.com/openai/openai-go/commit/28f7e092c03b7458c69c0dd467fbcfcfb7a31864)) +* **api:** update OpenAPI spec or Stainless config ([57c307e](https://github.com/openai/openai-go/commit/57c307e3893744bfc186d23cbb5c0d1f2e9d798a)) + +## 3.39.0 (2026-06-03) + +Full Changelog: [v3.38.0...v3.39.0](https://github.com/openai/openai-go/compare/v3.38.0...v3.39.0) + +### Features + +* **api:** responses.moderation and chat_completions.moderation ([7a2dac0](https://github.com/openai/openai-go/commit/7a2dac0ddf6b92dfcaa45b190dbe7f51368e199c)) + +## 3.38.0 (2026-06-01) + +Full Changelog: [v3.37.0...v3.38.0](https://github.com/openai/openai-go/compare/v3.37.0...v3.38.0) + +### Features + +* **api:** manual updates ([d7dac81](https://github.com/openai/openai-go/commit/d7dac8192c292d882cb765d3379e10427930979e)) +* **api:** workload identity in audit logs, additional_tools item in responses, fix ActionSearch.query to be optional. ([4c3981c](https://github.com/openai/openai-go/commit/4c3981cfabc98ec1d67c2baf7c6a891ef6640f96)) + +## 3.37.0 (2026-05-21) + +Full Changelog: [v3.36.0...v3.37.0](https://github.com/openai/openai-go/compare/v3.36.0...v3.37.0) + +### Features + +* **api:** api update ([7f7416e](https://github.com/openai/openai-go/commit/7f7416ea4f6953a2861189dee6391515c3b995a9)) +* **api:** manual updates ([d646562](https://github.com/openai/openai-go/commit/d6465620413df87d971e7e37ae74bef4c70076b1)) +* **api:** update OpenAPI spec or Stainless config ([b34b78a](https://github.com/openai/openai-go/commit/b34b78a83433003a6168fffd175cc963ad719495)) +* **client:** optimize json encoder for internal types ([93adc6e](https://github.com/openai/openai-go/commit/93adc6e6247e8ce830152c3df0980a3154aa098a)) + + +### Bug Fixes + +* **go:** format generated admin paths ([1dd8f5e](https://github.com/openai/openai-go/commit/1dd8f5ec0adeeefef6a56068b5532ba5e3b3290e)) +* **go:** format generated project permission paths ([b751c37](https://github.com/openai/openai-go/commit/b751c37ce2d6348545d75451dfc253dd7dda0f4f)) + + +### Chores + +* **api:** docs updates ([08bc80e](https://github.com/openai/openai-go/commit/08bc80ea58a19ba0725942c1f3afbcfb043851a0)) + +## 3.36.0 (2026-05-13) + +Full Changelog: [v3.35.0...v3.36.0](https://github.com/openai/openai-go/compare/v3.35.0...v3.36.0) + +### Features + +* **api:** add service_tier parameter to response compact method ([bacd2c0](https://github.com/openai/openai-go/commit/bacd2c0bcf980e8d424d67446fb4d9c4ea897d24)) + + +### Bug Fixes + +* **go:** avoid panic when http.DefaultTransport is wrapped ([95a0250](https://github.com/openai/openai-go/commit/95a0250a9c770674f8deacb3a3fc1175e6808967)) + +## 3.35.0 (2026-05-07) + +Full Changelog: [v3.34.0...v3.35.0](https://github.com/openai/openai-go/compare/v3.34.0...v3.35.0) + +### Features + +* **api:** add quantity field to admin organization usage costs results ([899b6de](https://github.com/openai/openai-go/commit/899b6dec70bd180a98497150b892285261882625)) +* **api:** launch realtime translate + update image 2 ([1fbf3a6](https://github.com/openai/openai-go/commit/1fbf3a68e418f84993db1c291255c467e47dbe37)) +* **api:** manual updates ([cd9047f](https://github.com/openai/openai-go/commit/cd9047f7416cedba79c7479d96acce3f59ac2c86)) +* **api:** realtime 2 ([5b51410](https://github.com/openai/openai-go/commit/5b514101d40d0b9f36194bab0c7e49a7f6098c03)) + + +### Bug Fixes + +* **api:** fix imagegen `size` enum regression ([995778e](https://github.com/openai/openai-go/commit/995778eac4b36433a7d116f9a09999f34e78b91f)) +* **types:** add format tags for URI and timestamp fields across models ([a6c2198](https://github.com/openai/openai-go/commit/a6c219806da98fa140b837a1063d3ee7f5f51e8d)) + + +### Chores + +* **internal:** regenerate SDK with no functional changes ([71c80ef](https://github.com/openai/openai-go/commit/71c80ef9e4407d6714f9d0013bc9579dfab1a223)) +* redact api-key headers in debug logs ([ff51a02](https://github.com/openai/openai-go/commit/ff51a02d264f06535bac6000865b8ad27e4e8a72)) + + +### Documentation + +* **api:** document web_search_call.results output data option ([6c2d8ef](https://github.com/openai/openai-go/commit/6c2d8eff506aae6b4fea17fdca94748bd4b2cd3e)) + +## 3.34.0 (2026-05-01) + +Full Changelog: [v3.33.0...v3.34.0](https://github.com/openai/openai-go/compare/v3.33.0...v3.34.0) + +### Features + +* **api:** add group_type, external_key_id, user fields to admin organization models ([460f400](https://github.com/openai/openai-go/commit/460f400cc195d603631a13d6ce867d7bf9ca7fb3)) +* **api:** add support for Admin API Keys per endpoint ([51a0561](https://github.com/openai/openai-go/commit/51a0561845cb7f567e28074cddbe8bf1936f553a)) +* **api:** admin API updates ([a0ad21e](https://github.com/openai/openai-go/commit/a0ad21e5584562bc7c9c951a6872479bd1aa7773)) +* **api:** manual updates ([b60b3bc](https://github.com/openai/openai-go/commit/b60b3bcbc0bb9f11cd74d1b1cfba116ab1893465)) +* **api:** manual updates ([f4e0c1a](https://github.com/openai/openai-go/commit/f4e0c1a9f98d838d494b71b4d32e6f7fc5ffab2d)) + + +### Bug Fixes + +* **auth:** prefer admin keys for admin requests ([d128349](https://github.com/openai/openai-go/commit/d1283491698c89bf53acc945db02c5094741021d)) +* **types:** add format annotations to ChatKit timestamp and URL fields ([0b7d7d0](https://github.com/openai/openai-go/commit/0b7d7d036b4588877bb3f2fc1d46a56f23150468)) +* **types:** add format annotations to timestamp and URL fields across resources ([0ff11a7](https://github.com/openai/openai-go/commit/0ff11a7f0c9eff426e1e408b0b70bc101e01fca8)) +* **types:** change timestamp fields to float64 in Response ([d714e3c](https://github.com/openai/openai-go/commit/d714e3c84592cd2630b45e8f634ede88b19a4bb5)) + +## 3.33.0 (2026-04-28) + +Full Changelog: [v3.32.0...v3.33.0](https://github.com/openai/openai-go/compare/v3.32.0...v3.33.0) + +### Features + +* **go:** add default http client with timeout ([25dd39a](https://github.com/openai/openai-go/commit/25dd39aec0ca97f51be1fd32accd5b10ff441365)) +* support setting headers via env ([b4eaa78](https://github.com/openai/openai-go/commit/b4eaa78969c6c908ab81ec4e6c15fa9803e7de17)) + + +### Bug Fixes + +* **types:** change PromptCacheRetention enum in-memory to in_memory ([15e7432](https://github.com/openai/openai-go/commit/15e7432bd0a3fd4891be46f5d124ebc44301b611)) + + +### Chores + +* **internal:** more robust bootstrap script ([eb0cbcf](https://github.com/openai/openai-go/commit/eb0cbcf152867ad154c827dcf2c3c91adb773af9)) +* **tests:** bump steady to v0.22.1 ([ef28f59](https://github.com/openai/openai-go/commit/ef28f59c84a30ffd0d2342bc8d09bea5803c89a6)) + + +### Documentation + +* **api:** add rate limit and vector store guidance to file upload ([6c8c7fa](https://github.com/openai/openai-go/commit/6c8c7faa70bd73a673744107c3487ec2a7362dca)) +* **api:** update rate limit documentation in file upload method ([54fde2c](https://github.com/openai/openai-go/commit/54fde2c59e0f3b05741a93ec38cbe96495977848)) + ## 3.32.0 (2026-04-16) Full Changelog: [v3.31.0...v3.32.0](https://github.com/openai/openai-go/compare/v3.31.0...v3.32.0) diff --git a/vendor/github.com/openai/openai-go/v3/README.md b/vendor/github.com/openai/openai-go/v3/README.md index 2ec92a46b..ed172d464 100644 --- a/vendor/github.com/openai/openai-go/v3/README.md +++ b/vendor/github.com/openai/openai-go/v3/README.md @@ -30,7 +30,7 @@ Or to pin the version: ```sh -go get -u 'github.com/openai/openai-go/v3@v3.32.0' +go get -u 'github.com/openai/openai-go/v3@v3.41.0' ``` @@ -968,7 +968,6 @@ import ( client := openai.NewClient( option.WithWorkloadIdentity(auth.WorkloadIdentity{ - ClientID: "your-client-id", IdentityProviderID: "idp-123", ServiceAccountID: "sa-456", Provider: auth.K8sServiceAccountTokenProvider(""), @@ -981,7 +980,6 @@ client := openai.NewClient( ```go client := openai.NewClient( option.WithWorkloadIdentity(auth.WorkloadIdentity{ - ClientID: "your-client-id", IdentityProviderID: "idp-123", ServiceAccountID: "sa-456", Provider: auth.AzureManagedIdentityTokenProvider(nil), @@ -994,7 +992,6 @@ client := openai.NewClient( ```go client := openai.NewClient( option.WithWorkloadIdentity(auth.WorkloadIdentity{ - ClientID: "your-client-id", IdentityProviderID: "idp-123", ServiceAccountID: "sa-456", Provider: auth.GCPIDTokenProvider(nil), @@ -1027,7 +1024,6 @@ func (p *customTokenProvider) GetToken(ctx context.Context, httpClient auth.HTTP client := openai.NewClient( option.WithWorkloadIdentity(auth.WorkloadIdentity{ - ClientID: "your-client-id", IdentityProviderID: "idp-123", ServiceAccountID: "sa-456", Provider: &customTokenProvider{}, @@ -1042,7 +1038,6 @@ By default, tokens are refreshed 20 minutes (1200 seconds) before expiry. You ca ```go client := openai.NewClient( option.WithWorkloadIdentity(auth.WorkloadIdentity{ - ClientID: "your-client-id", IdentityProviderID: "idp-123", ServiceAccountID: "sa-456", Provider: auth.K8sServiceAccountTokenProvider(""), diff --git a/vendor/github.com/openai/openai-go/v3/admin.go b/vendor/github.com/openai/openai-go/v3/admin.go new file mode 100644 index 000000000..294661010 --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/admin.go @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "github.com/openai/openai-go/v3/option" +) + +// AdminService 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 [NewAdminService] method instead. +type AdminService struct { + Options []option.RequestOption + Organization AdminOrganizationService +} + +// NewAdminService 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 NewAdminService(opts ...option.RequestOption) (r AdminService) { + r = AdminService{} + r.Options = opts + r.Organization = NewAdminOrganizationService(opts...) + return +} diff --git a/vendor/github.com/openai/openai-go/v3/adminorganization.go b/vendor/github.com/openai/openai-go/v3/adminorganization.go new file mode 100644 index 000000000..ed4274ca9 --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganization.go @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "github.com/openai/openai-go/v3/option" +) + +// AdminOrganizationService 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 [NewAdminOrganizationService] method instead. +type AdminOrganizationService struct { + Options []option.RequestOption + // List user actions and configuration changes within this organization. + AuditLogs AdminOrganizationAuditLogService + AdminAPIKeys AdminOrganizationAdminAPIKeyService + Usage AdminOrganizationUsageService + Invites AdminOrganizationInviteService + Users AdminOrganizationUserService + Groups AdminOrganizationGroupService + Roles AdminOrganizationRoleService + DataRetention AdminOrganizationDataRetentionService + SpendAlerts AdminOrganizationSpendAlertService + Certificates AdminOrganizationCertificateService + Projects AdminOrganizationProjectService +} + +// NewAdminOrganizationService 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 NewAdminOrganizationService(opts ...option.RequestOption) (r AdminOrganizationService) { + r = AdminOrganizationService{} + r.Options = opts + r.AuditLogs = NewAdminOrganizationAuditLogService(opts...) + r.AdminAPIKeys = NewAdminOrganizationAdminAPIKeyService(opts...) + r.Usage = NewAdminOrganizationUsageService(opts...) + r.Invites = NewAdminOrganizationInviteService(opts...) + r.Users = NewAdminOrganizationUserService(opts...) + r.Groups = NewAdminOrganizationGroupService(opts...) + r.Roles = NewAdminOrganizationRoleService(opts...) + r.DataRetention = NewAdminOrganizationDataRetentionService(opts...) + r.SpendAlerts = NewAdminOrganizationSpendAlertService(opts...) + r.Certificates = NewAdminOrganizationCertificateService(opts...) + r.Projects = NewAdminOrganizationProjectService(opts...) + return +} diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationadminapikey.go b/vendor/github.com/openai/openai-go/v3/adminorganizationadminapikey.go new file mode 100644 index 000000000..72ea1790c --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationadminapikey.go @@ -0,0 +1,252 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "errors" + "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" +) + +// AdminOrganizationAdminAPIKeyService 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 [NewAdminOrganizationAdminAPIKeyService] method instead. +type AdminOrganizationAdminAPIKeyService struct { + Options []option.RequestOption +} + +// NewAdminOrganizationAdminAPIKeyService 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 NewAdminOrganizationAdminAPIKeyService(opts ...option.RequestOption) (r AdminOrganizationAdminAPIKeyService) { + r = AdminOrganizationAdminAPIKeyService{} + r.Options = opts + return +} + +// Create an organization admin API key +func (r *AdminOrganizationAdminAPIKeyService) New(ctx context.Context, body AdminOrganizationAdminAPIKeyNewParams, opts ...option.RequestOption) (res *AdminOrganizationAdminAPIKeyNewResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + path := "organization/admin_api_keys" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Retrieve a single organization API key +func (r *AdminOrganizationAdminAPIKeyService) Get(ctx context.Context, keyID string, opts ...option.RequestOption) (res *AdminAPIKey, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if keyID == "" { + err = errors.New("missing required key_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/admin_api_keys/%s", keyID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return res, err +} + +// List organization API keys +func (r *AdminOrganizationAdminAPIKeyService) List(ctx context.Context, query AdminOrganizationAdminAPIKeyListParams, opts ...option.RequestOption) (res *pagination.CursorPage[AdminAPIKey], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := "organization/admin_api_keys" + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// List organization API keys +func (r *AdminOrganizationAdminAPIKeyService) ListAutoPaging(ctx context.Context, query AdminOrganizationAdminAPIKeyListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[AdminAPIKey] { + return pagination.NewCursorPageAutoPager(r.List(ctx, query, opts...)) +} + +// Delete an organization admin API key +func (r *AdminOrganizationAdminAPIKeyService) Delete(ctx context.Context, keyID string, opts ...option.RequestOption) (res *AdminOrganizationAdminAPIKeyDeleteResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if keyID == "" { + err = errors.New("missing required key_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/admin_api_keys/%s", keyID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + return res, err +} + +// Represents an individual Admin API key in an org. +type AdminAPIKey struct { + // The identifier, which can be referenced in API endpoints + ID string `json:"id" api:"required"` + // The Unix timestamp (in seconds) of when the API key was created + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // The Unix timestamp (in seconds) of when the API key expires + ExpiresAt int64 `json:"expires_at" api:"required" format:"unixtime"` + // The object type, which is always `organization.admin_api_key` + Object constant.OrganizationAdminAPIKey `json:"object" default:"organization.admin_api_key"` + Owner AdminAPIKeyOwner `json:"owner" api:"required"` + // The redacted value of the API key + RedactedValue string `json:"redacted_value" api:"required"` + // The Unix timestamp (in seconds) of when the API key was last used + LastUsedAt int64 `json:"last_used_at" api:"nullable" format:"unixtime"` + // The name of the API key + Name string `json:"name" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + CreatedAt respjson.Field + ExpiresAt respjson.Field + Object respjson.Field + Owner respjson.Field + RedactedValue respjson.Field + LastUsedAt respjson.Field + Name respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminAPIKey) RawJSON() string { return r.JSON.raw } +func (r *AdminAPIKey) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminAPIKeyOwner struct { + // The identifier, which can be referenced in API endpoints + ID string `json:"id"` + // The Unix timestamp (in seconds) of when the user was created + CreatedAt int64 `json:"created_at" format:"unixtime"` + // The name of the user + Name string `json:"name"` + // The object type, which is always organization.user + Object string `json:"object"` + // Always `owner` + Role string `json:"role"` + // Always `user` + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + CreatedAt respjson.Field + Name respjson.Field + Object respjson.Field + Role respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminAPIKeyOwner) RawJSON() string { return r.JSON.raw } +func (r *AdminAPIKeyOwner) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Represents an individual Admin API key in an org. +type AdminOrganizationAdminAPIKeyNewResponse struct { + // The value of the API key. Only shown on create. + Value string `json:"value" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Value respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` + AdminAPIKey +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAdminAPIKeyNewResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAdminAPIKeyNewResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationAdminAPIKeyDeleteResponse struct { + ID string `json:"id" api:"required"` + Deleted bool `json:"deleted" api:"required"` + Object constant.OrganizationAdminAPIKeyDeleted `json:"object" default:"organization.admin_api_key.deleted"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Deleted respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAdminAPIKeyDeleteResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAdminAPIKeyDeleteResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationAdminAPIKeyNewParams struct { + Name string `json:"name" api:"required"` + // The number of seconds until the API key expires. Omit this field for a key that + // does not expire. + ExpiresInSeconds param.Opt[int64] `json:"expires_in_seconds,omitzero"` + paramObj +} + +func (r AdminOrganizationAdminAPIKeyNewParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationAdminAPIKeyNewParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationAdminAPIKeyNewParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationAdminAPIKeyListParams struct { + // Return keys with IDs that come after this ID in the pagination order. + After param.Opt[string] `query:"after,omitzero" json:"-"` + // Maximum number of keys to return. + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + // Order results by creation time, ascending or descending. + // + // Any of "asc", "desc". + Order AdminOrganizationAdminAPIKeyListParamsOrder `query:"order,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationAdminAPIKeyListParams]'s query parameters +// as `url.Values`. +func (r AdminOrganizationAdminAPIKeyListParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Order results by creation time, ascending or descending. +type AdminOrganizationAdminAPIKeyListParamsOrder string + +const ( + AdminOrganizationAdminAPIKeyListParamsOrderAsc AdminOrganizationAdminAPIKeyListParamsOrder = "asc" + AdminOrganizationAdminAPIKeyListParamsOrderDesc AdminOrganizationAdminAPIKeyListParamsOrder = "desc" +) diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationauditlog.go b/vendor/github.com/openai/openai-go/v3/adminorganizationauditlog.go new file mode 100644 index 000000000..66ef234fc --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationauditlog.go @@ -0,0 +1,2249 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "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" +) + +// List user actions and configuration changes within this organization. +// +// AdminOrganizationAuditLogService 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 [NewAdminOrganizationAuditLogService] method instead. +type AdminOrganizationAuditLogService struct { + Options []option.RequestOption +} + +// NewAdminOrganizationAuditLogService 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 NewAdminOrganizationAuditLogService(opts ...option.RequestOption) (r AdminOrganizationAuditLogService) { + r = AdminOrganizationAuditLogService{} + r.Options = opts + return +} + +// List user actions and configuration changes within this organization. +func (r *AdminOrganizationAuditLogService) List(ctx context.Context, query AdminOrganizationAuditLogListParams, opts ...option.RequestOption) (res *pagination.ConversationCursorPage[AdminOrganizationAuditLogListResponse], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := "organization/audit_logs" + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// List user actions and configuration changes within this organization. +func (r *AdminOrganizationAuditLogService) ListAutoPaging(ctx context.Context, query AdminOrganizationAuditLogListParams, opts ...option.RequestOption) *pagination.ConversationCursorPageAutoPager[AdminOrganizationAuditLogListResponse] { + return pagination.NewConversationCursorPageAutoPager(r.List(ctx, query, opts...)) +} + +// A log of a user action or configuration change within this organization. +type AdminOrganizationAuditLogListResponse struct { + // The ID of this log. + ID string `json:"id" api:"required"` + // The Unix timestamp (in seconds) of the event. + EffectiveAt int64 `json:"effective_at" api:"required" format:"unixtime"` + // The event type. + // + // Any of "api_key.created", "api_key.updated", "api_key.deleted", + // "certificate.created", "certificate.updated", "certificate.deleted", + // "certificates.activated", "certificates.deactivated", + // "checkpoint.permission.created", "checkpoint.permission.deleted", + // "external_key.registered", "external_key.removed", "group.created", + // "group.updated", "group.deleted", "invite.sent", "invite.accepted", + // "invite.deleted", "ip_allowlist.created", "ip_allowlist.updated", + // "ip_allowlist.deleted", "ip_allowlist.config.activated", + // "ip_allowlist.config.deactivated", "login.succeeded", "login.failed", + // "logout.succeeded", "logout.failed", "organization.updated", "project.created", + // "project.updated", "project.archived", "project.deleted", "rate_limit.updated", + // "rate_limit.deleted", "resource.deleted", "tunnel.created", "tunnel.updated", + // "tunnel.deleted", "workload_identity_provider.created", + // "workload_identity_provider.updated", "workload_identity_provider.deleted", + // "workload_identity_provider_mapping.created", + // "workload_identity_provider_mapping.updated", + // "workload_identity_provider_mapping.deleted", "role.created", "role.updated", + // "role.deleted", "role.assignment.created", "role.assignment.deleted", + // "role.bound_to_resource", "role.unbound_from_resource", "scim.enabled", + // "scim.disabled", "service_account.created", "service_account.updated", + // "service_account.deleted", "user.added", "user.updated", "user.deleted". + Type AdminOrganizationAuditLogListResponseType `json:"type" api:"required"` + // The actor who performed the audit logged action. + Actor AdminOrganizationAuditLogListResponseActor `json:"actor" api:"nullable"` + // The details for events with this `type`. + APIKeyCreated AdminOrganizationAuditLogListResponseAPIKeyCreated `json:"api_key.created"` + // The details for events with this `type`. + APIKeyDeleted AdminOrganizationAuditLogListResponseAPIKeyDeleted `json:"api_key.deleted"` + // The details for events with this `type`. + APIKeyUpdated AdminOrganizationAuditLogListResponseAPIKeyUpdated `json:"api_key.updated"` + // The details for events with this `type`. + CertificateCreated AdminOrganizationAuditLogListResponseCertificateCreated `json:"certificate.created"` + // The details for events with this `type`. + CertificateDeleted AdminOrganizationAuditLogListResponseCertificateDeleted `json:"certificate.deleted"` + // The details for events with this `type`. + CertificateUpdated AdminOrganizationAuditLogListResponseCertificateUpdated `json:"certificate.updated"` + // The details for events with this `type`. + CertificatesActivated AdminOrganizationAuditLogListResponseCertificatesActivated `json:"certificates.activated"` + // The details for events with this `type`. + CertificatesDeactivated AdminOrganizationAuditLogListResponseCertificatesDeactivated `json:"certificates.deactivated"` + // The project and fine-tuned model checkpoint that the checkpoint permission was + // created for. + CheckpointPermissionCreated AdminOrganizationAuditLogListResponseCheckpointPermissionCreated `json:"checkpoint.permission.created"` + // The details for events with this `type`. + CheckpointPermissionDeleted AdminOrganizationAuditLogListResponseCheckpointPermissionDeleted `json:"checkpoint.permission.deleted"` + // The details for events with this `type`. + ExternalKeyRegistered AdminOrganizationAuditLogListResponseExternalKeyRegistered `json:"external_key.registered"` + // The details for events with this `type`. + ExternalKeyRemoved AdminOrganizationAuditLogListResponseExternalKeyRemoved `json:"external_key.removed"` + // The details for events with this `type`. + GroupCreated AdminOrganizationAuditLogListResponseGroupCreated `json:"group.created"` + // The details for events with this `type`. + GroupDeleted AdminOrganizationAuditLogListResponseGroupDeleted `json:"group.deleted"` + // The details for events with this `type`. + GroupUpdated AdminOrganizationAuditLogListResponseGroupUpdated `json:"group.updated"` + // The details for events with this `type`. + InviteAccepted AdminOrganizationAuditLogListResponseInviteAccepted `json:"invite.accepted"` + // The details for events with this `type`. + InviteDeleted AdminOrganizationAuditLogListResponseInviteDeleted `json:"invite.deleted"` + // The details for events with this `type`. + InviteSent AdminOrganizationAuditLogListResponseInviteSent `json:"invite.sent"` + // The details for events with this `type`. + IPAllowlistConfigActivated AdminOrganizationAuditLogListResponseIPAllowlistConfigActivated `json:"ip_allowlist.config.activated"` + // The details for events with this `type`. + IPAllowlistConfigDeactivated AdminOrganizationAuditLogListResponseIPAllowlistConfigDeactivated `json:"ip_allowlist.config.deactivated"` + // The details for events with this `type`. + IPAllowlistCreated AdminOrganizationAuditLogListResponseIPAllowlistCreated `json:"ip_allowlist.created"` + // The details for events with this `type`. + IPAllowlistDeleted AdminOrganizationAuditLogListResponseIPAllowlistDeleted `json:"ip_allowlist.deleted"` + // The details for events with this `type`. + IPAllowlistUpdated AdminOrganizationAuditLogListResponseIPAllowlistUpdated `json:"ip_allowlist.updated"` + // The details for events with this `type`. + LoginFailed AdminOrganizationAuditLogListResponseLoginFailed `json:"login.failed"` + // This event has no additional fields beyond the standard audit log attributes. + LoginSucceeded any `json:"login.succeeded"` + // The details for events with this `type`. + LogoutFailed AdminOrganizationAuditLogListResponseLogoutFailed `json:"logout.failed"` + // This event has no additional fields beyond the standard audit log attributes. + LogoutSucceeded any `json:"logout.succeeded"` + // The details for events with this `type`. + OrganizationUpdated AdminOrganizationAuditLogListResponseOrganizationUpdated `json:"organization.updated"` + // The project that the action was scoped to. Absent for actions not scoped to + // projects. Note that any admin actions taken via Admin API keys are associated + // with the default project. + Project AdminOrganizationAuditLogListResponseProject `json:"project"` + // The details for events with this `type`. + ProjectArchived AdminOrganizationAuditLogListResponseProjectArchived `json:"project.archived"` + // The details for events with this `type`. + ProjectCreated AdminOrganizationAuditLogListResponseProjectCreated `json:"project.created"` + // The details for events with this `type`. + ProjectDeleted AdminOrganizationAuditLogListResponseProjectDeleted `json:"project.deleted"` + // The details for events with this `type`. + ProjectUpdated AdminOrganizationAuditLogListResponseProjectUpdated `json:"project.updated"` + // The details for events with this `type`. + RateLimitDeleted AdminOrganizationAuditLogListResponseRateLimitDeleted `json:"rate_limit.deleted"` + // The details for events with this `type`. + RateLimitUpdated AdminOrganizationAuditLogListResponseRateLimitUpdated `json:"rate_limit.updated"` + // The details for events with this `type`. + RoleAssignmentCreated AdminOrganizationAuditLogListResponseRoleAssignmentCreated `json:"role.assignment.created"` + // The details for events with this `type`. + RoleAssignmentDeleted AdminOrganizationAuditLogListResponseRoleAssignmentDeleted `json:"role.assignment.deleted"` + // The details for events with this `type`. + RoleBoundToResource AdminOrganizationAuditLogListResponseRoleBoundToResource `json:"role.bound_to_resource"` + // The details for events with this `type`. + RoleCreated AdminOrganizationAuditLogListResponseRoleCreated `json:"role.created"` + // The details for events with this `type`. + RoleDeleted AdminOrganizationAuditLogListResponseRoleDeleted `json:"role.deleted"` + // The details for events with this `type`. + RoleUnboundFromResource AdminOrganizationAuditLogListResponseRoleUnboundFromResource `json:"role.unbound_from_resource"` + // The details for events with this `type`. + RoleUpdated AdminOrganizationAuditLogListResponseRoleUpdated `json:"role.updated"` + // The details for events with this `type`. + ScimDisabled AdminOrganizationAuditLogListResponseScimDisabled `json:"scim.disabled"` + // The details for events with this `type`. + ScimEnabled AdminOrganizationAuditLogListResponseScimEnabled `json:"scim.enabled"` + // The details for events with this `type`. + ServiceAccountCreated AdminOrganizationAuditLogListResponseServiceAccountCreated `json:"service_account.created"` + // The details for events with this `type`. + ServiceAccountDeleted AdminOrganizationAuditLogListResponseServiceAccountDeleted `json:"service_account.deleted"` + // The details for events with this `type`. + ServiceAccountUpdated AdminOrganizationAuditLogListResponseServiceAccountUpdated `json:"service_account.updated"` + // The details for events with this `type`. + UserAdded AdminOrganizationAuditLogListResponseUserAdded `json:"user.added"` + // The details for events with this `type`. + UserDeleted AdminOrganizationAuditLogListResponseUserDeleted `json:"user.deleted"` + // The details for events with this `type`. + UserUpdated AdminOrganizationAuditLogListResponseUserUpdated `json:"user.updated"` + // The details for events with this `type`. + WorkloadIdentityProviderMappingCreated AdminOrganizationAuditLogListResponseWorkloadIdentityProviderMappingCreated `json:"workload_identity_provider_mapping.created"` + // The details for events with this `type`. + WorkloadIdentityProviderMappingDeleted AdminOrganizationAuditLogListResponseWorkloadIdentityProviderMappingDeleted `json:"workload_identity_provider_mapping.deleted"` + // The details for events with this `type`. + WorkloadIdentityProviderMappingUpdated AdminOrganizationAuditLogListResponseWorkloadIdentityProviderMappingUpdated `json:"workload_identity_provider_mapping.updated"` + // The details for events with this `type`. + WorkloadIdentityProviderCreated AdminOrganizationAuditLogListResponseWorkloadIdentityProviderCreated `json:"workload_identity_provider.created"` + // The details for events with this `type`. + WorkloadIdentityProviderDeleted AdminOrganizationAuditLogListResponseWorkloadIdentityProviderDeleted `json:"workload_identity_provider.deleted"` + // The details for events with this `type`. + WorkloadIdentityProviderUpdated AdminOrganizationAuditLogListResponseWorkloadIdentityProviderUpdated `json:"workload_identity_provider.updated"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + EffectiveAt respjson.Field + Type respjson.Field + Actor respjson.Field + APIKeyCreated respjson.Field + APIKeyDeleted respjson.Field + APIKeyUpdated respjson.Field + CertificateCreated respjson.Field + CertificateDeleted respjson.Field + CertificateUpdated respjson.Field + CertificatesActivated respjson.Field + CertificatesDeactivated respjson.Field + CheckpointPermissionCreated respjson.Field + CheckpointPermissionDeleted respjson.Field + ExternalKeyRegistered respjson.Field + ExternalKeyRemoved respjson.Field + GroupCreated respjson.Field + GroupDeleted respjson.Field + GroupUpdated respjson.Field + InviteAccepted respjson.Field + InviteDeleted respjson.Field + InviteSent respjson.Field + IPAllowlistConfigActivated respjson.Field + IPAllowlistConfigDeactivated respjson.Field + IPAllowlistCreated respjson.Field + IPAllowlistDeleted respjson.Field + IPAllowlistUpdated respjson.Field + LoginFailed respjson.Field + LoginSucceeded respjson.Field + LogoutFailed respjson.Field + LogoutSucceeded respjson.Field + OrganizationUpdated respjson.Field + Project respjson.Field + ProjectArchived respjson.Field + ProjectCreated respjson.Field + ProjectDeleted respjson.Field + ProjectUpdated respjson.Field + RateLimitDeleted respjson.Field + RateLimitUpdated respjson.Field + RoleAssignmentCreated respjson.Field + RoleAssignmentDeleted respjson.Field + RoleBoundToResource respjson.Field + RoleCreated respjson.Field + RoleDeleted respjson.Field + RoleUnboundFromResource respjson.Field + RoleUpdated respjson.Field + ScimDisabled respjson.Field + ScimEnabled respjson.Field + ServiceAccountCreated respjson.Field + ServiceAccountDeleted respjson.Field + ServiceAccountUpdated respjson.Field + UserAdded respjson.Field + UserDeleted respjson.Field + UserUpdated respjson.Field + WorkloadIdentityProviderMappingCreated respjson.Field + WorkloadIdentityProviderMappingDeleted respjson.Field + WorkloadIdentityProviderMappingUpdated respjson.Field + WorkloadIdentityProviderCreated respjson.Field + WorkloadIdentityProviderDeleted respjson.Field + WorkloadIdentityProviderUpdated respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The event type. +type AdminOrganizationAuditLogListResponseType string + +const ( + AdminOrganizationAuditLogListResponseTypeAPIKeyCreated AdminOrganizationAuditLogListResponseType = "api_key.created" + AdminOrganizationAuditLogListResponseTypeAPIKeyUpdated AdminOrganizationAuditLogListResponseType = "api_key.updated" + AdminOrganizationAuditLogListResponseTypeAPIKeyDeleted AdminOrganizationAuditLogListResponseType = "api_key.deleted" + AdminOrganizationAuditLogListResponseTypeCertificateCreated AdminOrganizationAuditLogListResponseType = "certificate.created" + AdminOrganizationAuditLogListResponseTypeCertificateUpdated AdminOrganizationAuditLogListResponseType = "certificate.updated" + AdminOrganizationAuditLogListResponseTypeCertificateDeleted AdminOrganizationAuditLogListResponseType = "certificate.deleted" + AdminOrganizationAuditLogListResponseTypeCertificatesActivated AdminOrganizationAuditLogListResponseType = "certificates.activated" + AdminOrganizationAuditLogListResponseTypeCertificatesDeactivated AdminOrganizationAuditLogListResponseType = "certificates.deactivated" + AdminOrganizationAuditLogListResponseTypeCheckpointPermissionCreated AdminOrganizationAuditLogListResponseType = "checkpoint.permission.created" + AdminOrganizationAuditLogListResponseTypeCheckpointPermissionDeleted AdminOrganizationAuditLogListResponseType = "checkpoint.permission.deleted" + AdminOrganizationAuditLogListResponseTypeExternalKeyRegistered AdminOrganizationAuditLogListResponseType = "external_key.registered" + AdminOrganizationAuditLogListResponseTypeExternalKeyRemoved AdminOrganizationAuditLogListResponseType = "external_key.removed" + AdminOrganizationAuditLogListResponseTypeGroupCreated AdminOrganizationAuditLogListResponseType = "group.created" + AdminOrganizationAuditLogListResponseTypeGroupUpdated AdminOrganizationAuditLogListResponseType = "group.updated" + AdminOrganizationAuditLogListResponseTypeGroupDeleted AdminOrganizationAuditLogListResponseType = "group.deleted" + AdminOrganizationAuditLogListResponseTypeInviteSent AdminOrganizationAuditLogListResponseType = "invite.sent" + AdminOrganizationAuditLogListResponseTypeInviteAccepted AdminOrganizationAuditLogListResponseType = "invite.accepted" + AdminOrganizationAuditLogListResponseTypeInviteDeleted AdminOrganizationAuditLogListResponseType = "invite.deleted" + AdminOrganizationAuditLogListResponseTypeIPAllowlistCreated AdminOrganizationAuditLogListResponseType = "ip_allowlist.created" + AdminOrganizationAuditLogListResponseTypeIPAllowlistUpdated AdminOrganizationAuditLogListResponseType = "ip_allowlist.updated" + AdminOrganizationAuditLogListResponseTypeIPAllowlistDeleted AdminOrganizationAuditLogListResponseType = "ip_allowlist.deleted" + AdminOrganizationAuditLogListResponseTypeIPAllowlistConfigActivated AdminOrganizationAuditLogListResponseType = "ip_allowlist.config.activated" + AdminOrganizationAuditLogListResponseTypeIPAllowlistConfigDeactivated AdminOrganizationAuditLogListResponseType = "ip_allowlist.config.deactivated" + AdminOrganizationAuditLogListResponseTypeLoginSucceeded AdminOrganizationAuditLogListResponseType = "login.succeeded" + AdminOrganizationAuditLogListResponseTypeLoginFailed AdminOrganizationAuditLogListResponseType = "login.failed" + AdminOrganizationAuditLogListResponseTypeLogoutSucceeded AdminOrganizationAuditLogListResponseType = "logout.succeeded" + AdminOrganizationAuditLogListResponseTypeLogoutFailed AdminOrganizationAuditLogListResponseType = "logout.failed" + AdminOrganizationAuditLogListResponseTypeOrganizationUpdated AdminOrganizationAuditLogListResponseType = "organization.updated" + AdminOrganizationAuditLogListResponseTypeProjectCreated AdminOrganizationAuditLogListResponseType = "project.created" + AdminOrganizationAuditLogListResponseTypeProjectUpdated AdminOrganizationAuditLogListResponseType = "project.updated" + AdminOrganizationAuditLogListResponseTypeProjectArchived AdminOrganizationAuditLogListResponseType = "project.archived" + AdminOrganizationAuditLogListResponseTypeProjectDeleted AdminOrganizationAuditLogListResponseType = "project.deleted" + AdminOrganizationAuditLogListResponseTypeRateLimitUpdated AdminOrganizationAuditLogListResponseType = "rate_limit.updated" + AdminOrganizationAuditLogListResponseTypeRateLimitDeleted AdminOrganizationAuditLogListResponseType = "rate_limit.deleted" + AdminOrganizationAuditLogListResponseTypeResourceDeleted AdminOrganizationAuditLogListResponseType = "resource.deleted" + AdminOrganizationAuditLogListResponseTypeTunnelCreated AdminOrganizationAuditLogListResponseType = "tunnel.created" + AdminOrganizationAuditLogListResponseTypeTunnelUpdated AdminOrganizationAuditLogListResponseType = "tunnel.updated" + AdminOrganizationAuditLogListResponseTypeTunnelDeleted AdminOrganizationAuditLogListResponseType = "tunnel.deleted" + AdminOrganizationAuditLogListResponseTypeWorkloadIdentityProviderCreated AdminOrganizationAuditLogListResponseType = "workload_identity_provider.created" + AdminOrganizationAuditLogListResponseTypeWorkloadIdentityProviderUpdated AdminOrganizationAuditLogListResponseType = "workload_identity_provider.updated" + AdminOrganizationAuditLogListResponseTypeWorkloadIdentityProviderDeleted AdminOrganizationAuditLogListResponseType = "workload_identity_provider.deleted" + AdminOrganizationAuditLogListResponseTypeWorkloadIdentityProviderMappingCreated AdminOrganizationAuditLogListResponseType = "workload_identity_provider_mapping.created" + AdminOrganizationAuditLogListResponseTypeWorkloadIdentityProviderMappingUpdated AdminOrganizationAuditLogListResponseType = "workload_identity_provider_mapping.updated" + AdminOrganizationAuditLogListResponseTypeWorkloadIdentityProviderMappingDeleted AdminOrganizationAuditLogListResponseType = "workload_identity_provider_mapping.deleted" + AdminOrganizationAuditLogListResponseTypeRoleCreated AdminOrganizationAuditLogListResponseType = "role.created" + AdminOrganizationAuditLogListResponseTypeRoleUpdated AdminOrganizationAuditLogListResponseType = "role.updated" + AdminOrganizationAuditLogListResponseTypeRoleDeleted AdminOrganizationAuditLogListResponseType = "role.deleted" + AdminOrganizationAuditLogListResponseTypeRoleAssignmentCreated AdminOrganizationAuditLogListResponseType = "role.assignment.created" + AdminOrganizationAuditLogListResponseTypeRoleAssignmentDeleted AdminOrganizationAuditLogListResponseType = "role.assignment.deleted" + AdminOrganizationAuditLogListResponseTypeRoleBoundToResource AdminOrganizationAuditLogListResponseType = "role.bound_to_resource" + AdminOrganizationAuditLogListResponseTypeRoleUnboundFromResource AdminOrganizationAuditLogListResponseType = "role.unbound_from_resource" + AdminOrganizationAuditLogListResponseTypeScimEnabled AdminOrganizationAuditLogListResponseType = "scim.enabled" + AdminOrganizationAuditLogListResponseTypeScimDisabled AdminOrganizationAuditLogListResponseType = "scim.disabled" + AdminOrganizationAuditLogListResponseTypeServiceAccountCreated AdminOrganizationAuditLogListResponseType = "service_account.created" + AdminOrganizationAuditLogListResponseTypeServiceAccountUpdated AdminOrganizationAuditLogListResponseType = "service_account.updated" + AdminOrganizationAuditLogListResponseTypeServiceAccountDeleted AdminOrganizationAuditLogListResponseType = "service_account.deleted" + AdminOrganizationAuditLogListResponseTypeUserAdded AdminOrganizationAuditLogListResponseType = "user.added" + AdminOrganizationAuditLogListResponseTypeUserUpdated AdminOrganizationAuditLogListResponseType = "user.updated" + AdminOrganizationAuditLogListResponseTypeUserDeleted AdminOrganizationAuditLogListResponseType = "user.deleted" +) + +// The actor who performed the audit logged action. +type AdminOrganizationAuditLogListResponseActor struct { + // The API Key used to perform the audit logged action. + APIKey AdminOrganizationAuditLogListResponseActorAPIKey `json:"api_key"` + // The session in which the audit logged action was performed. + Session AdminOrganizationAuditLogListResponseActorSession `json:"session"` + // The type of actor. Is either `session` or `api_key`. + // + // Any of "session", "api_key". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + APIKey respjson.Field + Session respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseActor) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseActor) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The API Key used to perform the audit logged action. +type AdminOrganizationAuditLogListResponseActorAPIKey struct { + // The tracking id of the API key. + ID string `json:"id"` + // The service account that performed the audit logged action. + ServiceAccount AdminOrganizationAuditLogListResponseActorAPIKeyServiceAccount `json:"service_account"` + // The type of API key. Can be either `user` or `service_account`. + // + // Any of "user", "service_account". + Type string `json:"type"` + // The user who performed the audit logged action. + User AdminOrganizationAuditLogListResponseActorAPIKeyUser `json:"user"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + ServiceAccount respjson.Field + Type respjson.Field + User respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseActorAPIKey) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseActorAPIKey) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The service account that performed the audit logged action. +type AdminOrganizationAuditLogListResponseActorAPIKeyServiceAccount struct { + // The service account id. + ID string `json:"id"` + // 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 AdminOrganizationAuditLogListResponseActorAPIKeyServiceAccount) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseActorAPIKeyServiceAccount) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The user who performed the audit logged action. +type AdminOrganizationAuditLogListResponseActorAPIKeyUser struct { + // The user id. + ID string `json:"id"` + // The user email. + Email string `json:"email"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Email respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseActorAPIKeyUser) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseActorAPIKeyUser) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The session in which the audit logged action was performed. +type AdminOrganizationAuditLogListResponseActorSession struct { + // The IP address from which the action was performed. + IPAddress string `json:"ip_address"` + // The user who performed the audit logged action. + User AdminOrganizationAuditLogListResponseActorSessionUser `json:"user"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + IPAddress respjson.Field + User respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseActorSession) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseActorSession) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The user who performed the audit logged action. +type AdminOrganizationAuditLogListResponseActorSessionUser struct { + // The user id. + ID string `json:"id"` + // The user email. + Email string `json:"email"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Email respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseActorSessionUser) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseActorSessionUser) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseAPIKeyCreated struct { + // The tracking ID of the API key. + ID string `json:"id"` + // The payload used to create the API key. + Data AdminOrganizationAuditLogListResponseAPIKeyCreatedData `json:"data"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Data respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseAPIKeyCreated) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseAPIKeyCreated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The payload used to create the API key. +type AdminOrganizationAuditLogListResponseAPIKeyCreatedData struct { + // A list of scopes allowed for the API key, e.g. `["api.model.request"]` + Scopes []string `json:"scopes"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Scopes respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseAPIKeyCreatedData) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseAPIKeyCreatedData) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseAPIKeyDeleted struct { + // The tracking ID of the API key. + ID string `json:"id"` + // 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 AdminOrganizationAuditLogListResponseAPIKeyDeleted) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseAPIKeyDeleted) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseAPIKeyUpdated struct { + // The tracking ID of the API key. + ID string `json:"id"` + // The payload used to update the API key. + ChangesRequested AdminOrganizationAuditLogListResponseAPIKeyUpdatedChangesRequested `json:"changes_requested"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + ChangesRequested respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseAPIKeyUpdated) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseAPIKeyUpdated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The payload used to update the API key. +type AdminOrganizationAuditLogListResponseAPIKeyUpdatedChangesRequested struct { + // A list of scopes allowed for the API key, e.g. `["api.model.request"]` + Scopes []string `json:"scopes"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Scopes respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseAPIKeyUpdatedChangesRequested) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseAPIKeyUpdatedChangesRequested) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseCertificateCreated struct { + // The certificate ID. + ID string `json:"id"` + // The name of the certificate. + Name string `json:"name"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Name respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseCertificateCreated) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseCertificateCreated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseCertificateDeleted struct { + // The certificate ID. + ID string `json:"id"` + // The certificate content in PEM format. + Certificate string `json:"certificate"` + // The name of the certificate. + Name string `json:"name"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Certificate respjson.Field + Name respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseCertificateDeleted) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseCertificateDeleted) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseCertificateUpdated struct { + // The certificate ID. + ID string `json:"id"` + // The name of the certificate. + Name string `json:"name"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Name respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseCertificateUpdated) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseCertificateUpdated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseCertificatesActivated struct { + Certificates []AdminOrganizationAuditLogListResponseCertificatesActivatedCertificate `json:"certificates"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Certificates respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseCertificatesActivated) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseCertificatesActivated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationAuditLogListResponseCertificatesActivatedCertificate struct { + // The certificate ID. + ID string `json:"id"` + // The name of the certificate. + Name string `json:"name"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Name respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseCertificatesActivatedCertificate) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseCertificatesActivatedCertificate) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseCertificatesDeactivated struct { + Certificates []AdminOrganizationAuditLogListResponseCertificatesDeactivatedCertificate `json:"certificates"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Certificates respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseCertificatesDeactivated) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseCertificatesDeactivated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationAuditLogListResponseCertificatesDeactivatedCertificate struct { + // The certificate ID. + ID string `json:"id"` + // The name of the certificate. + Name string `json:"name"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Name respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseCertificatesDeactivatedCertificate) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseCertificatesDeactivatedCertificate) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The project and fine-tuned model checkpoint that the checkpoint permission was +// created for. +type AdminOrganizationAuditLogListResponseCheckpointPermissionCreated struct { + // The ID of the checkpoint permission. + ID string `json:"id"` + // The payload used to create the checkpoint permission. + Data AdminOrganizationAuditLogListResponseCheckpointPermissionCreatedData `json:"data"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Data respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseCheckpointPermissionCreated) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseCheckpointPermissionCreated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The payload used to create the checkpoint permission. +type AdminOrganizationAuditLogListResponseCheckpointPermissionCreatedData struct { + // The ID of the fine-tuned model checkpoint. + FineTunedModelCheckpoint string `json:"fine_tuned_model_checkpoint"` + // The ID of the project that the checkpoint permission was created for. + ProjectID string `json:"project_id"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + FineTunedModelCheckpoint respjson.Field + ProjectID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseCheckpointPermissionCreatedData) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseCheckpointPermissionCreatedData) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseCheckpointPermissionDeleted struct { + // The ID of the checkpoint permission. + ID string `json:"id"` + // 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 AdminOrganizationAuditLogListResponseCheckpointPermissionDeleted) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseCheckpointPermissionDeleted) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseExternalKeyRegistered struct { + // The ID of the external key configuration. + ID string `json:"id"` + // The configuration for the external key. + Data any `json:"data"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Data respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseExternalKeyRegistered) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseExternalKeyRegistered) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseExternalKeyRemoved struct { + // The ID of the external key configuration. + ID string `json:"id"` + // 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 AdminOrganizationAuditLogListResponseExternalKeyRemoved) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseExternalKeyRemoved) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseGroupCreated struct { + // The ID of the group. + ID string `json:"id"` + // Information about the created group. + Data AdminOrganizationAuditLogListResponseGroupCreatedData `json:"data"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Data respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseGroupCreated) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseGroupCreated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Information about the created group. +type AdminOrganizationAuditLogListResponseGroupCreatedData struct { + // The group name. + GroupName string `json:"group_name"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + GroupName respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseGroupCreatedData) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseGroupCreatedData) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseGroupDeleted struct { + // The ID of the group. + ID string `json:"id"` + // 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 AdminOrganizationAuditLogListResponseGroupDeleted) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseGroupDeleted) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseGroupUpdated struct { + // The ID of the group. + ID string `json:"id"` + // The payload used to update the group. + ChangesRequested AdminOrganizationAuditLogListResponseGroupUpdatedChangesRequested `json:"changes_requested"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + ChangesRequested respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseGroupUpdated) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseGroupUpdated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The payload used to update the group. +type AdminOrganizationAuditLogListResponseGroupUpdatedChangesRequested struct { + // The updated group name. + GroupName string `json:"group_name"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + GroupName respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseGroupUpdatedChangesRequested) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseGroupUpdatedChangesRequested) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseInviteAccepted struct { + // The ID of the invite. + ID string `json:"id"` + // 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 AdminOrganizationAuditLogListResponseInviteAccepted) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseInviteAccepted) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseInviteDeleted struct { + // The ID of the invite. + ID string `json:"id"` + // 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 AdminOrganizationAuditLogListResponseInviteDeleted) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseInviteDeleted) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseInviteSent struct { + // The ID of the invite. + ID string `json:"id"` + // The payload used to create the invite. + Data AdminOrganizationAuditLogListResponseInviteSentData `json:"data"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Data respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseInviteSent) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseInviteSent) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The payload used to create the invite. +type AdminOrganizationAuditLogListResponseInviteSentData struct { + // The email invited to the organization. + Email string `json:"email"` + // The role the email was invited to be. Is either `owner` or `member`. + Role string `json:"role"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Email respjson.Field + Role respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseInviteSentData) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseInviteSentData) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseIPAllowlistConfigActivated struct { + // The configurations that were activated. + Configs []AdminOrganizationAuditLogListResponseIPAllowlistConfigActivatedConfig `json:"configs"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Configs respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseIPAllowlistConfigActivated) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseIPAllowlistConfigActivated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationAuditLogListResponseIPAllowlistConfigActivatedConfig struct { + // The ID of the IP allowlist configuration. + ID string `json:"id"` + // The name of the IP allowlist configuration. + Name string `json:"name"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Name respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseIPAllowlistConfigActivatedConfig) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseIPAllowlistConfigActivatedConfig) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseIPAllowlistConfigDeactivated struct { + // The configurations that were deactivated. + Configs []AdminOrganizationAuditLogListResponseIPAllowlistConfigDeactivatedConfig `json:"configs"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Configs respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseIPAllowlistConfigDeactivated) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseIPAllowlistConfigDeactivated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationAuditLogListResponseIPAllowlistConfigDeactivatedConfig struct { + // The ID of the IP allowlist configuration. + ID string `json:"id"` + // The name of the IP allowlist configuration. + Name string `json:"name"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Name respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseIPAllowlistConfigDeactivatedConfig) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseIPAllowlistConfigDeactivatedConfig) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseIPAllowlistCreated struct { + // The ID of the IP allowlist configuration. + ID string `json:"id"` + // The IP addresses or CIDR ranges included in the configuration. + AllowedIPs []string `json:"allowed_ips"` + // The name of the IP allowlist configuration. + Name string `json:"name"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + AllowedIPs respjson.Field + Name respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseIPAllowlistCreated) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseIPAllowlistCreated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseIPAllowlistDeleted struct { + // The ID of the IP allowlist configuration. + ID string `json:"id"` + // The IP addresses or CIDR ranges that were in the configuration. + AllowedIPs []string `json:"allowed_ips"` + // The name of the IP allowlist configuration. + Name string `json:"name"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + AllowedIPs respjson.Field + Name respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseIPAllowlistDeleted) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseIPAllowlistDeleted) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseIPAllowlistUpdated struct { + // The ID of the IP allowlist configuration. + ID string `json:"id"` + // The updated set of IP addresses or CIDR ranges in the configuration. + AllowedIPs []string `json:"allowed_ips"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + AllowedIPs respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseIPAllowlistUpdated) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseIPAllowlistUpdated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseLoginFailed struct { + // The error code of the failure. + ErrorCode string `json:"error_code"` + // The error message of the failure. + ErrorMessage string `json:"error_message"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ErrorCode respjson.Field + ErrorMessage respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseLoginFailed) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseLoginFailed) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseLogoutFailed struct { + // The error code of the failure. + ErrorCode string `json:"error_code"` + // The error message of the failure. + ErrorMessage string `json:"error_message"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ErrorCode respjson.Field + ErrorMessage respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseLogoutFailed) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseLogoutFailed) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseOrganizationUpdated struct { + // The organization ID. + ID string `json:"id"` + // The payload used to update the organization settings. + ChangesRequested AdminOrganizationAuditLogListResponseOrganizationUpdatedChangesRequested `json:"changes_requested"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + ChangesRequested respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseOrganizationUpdated) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseOrganizationUpdated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The payload used to update the organization settings. +type AdminOrganizationAuditLogListResponseOrganizationUpdatedChangesRequested struct { + // How your organization logs data from supported API calls. One of `disabled`, + // `enabled_per_call`, `enabled_for_all_projects`, or + // `enabled_for_selected_projects` + APICallLogging string `json:"api_call_logging"` + // The list of project ids if api_call_logging is set to + // `enabled_for_selected_projects` + APICallLoggingProjectIDs string `json:"api_call_logging_project_ids"` + // The organization description. + Description string `json:"description"` + // The organization name. + Name string `json:"name"` + // Visibility of the threads page which shows messages created with the Assistants + // API and Playground. One of `ANY_ROLE`, `OWNERS`, or `NONE`. + ThreadsUiVisibility string `json:"threads_ui_visibility"` + // The organization title. + Title string `json:"title"` + // Visibility of the usage dashboard which shows activity and costs for your + // organization. One of `ANY_ROLE` or `OWNERS`. + UsageDashboardVisibility string `json:"usage_dashboard_visibility"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + APICallLogging respjson.Field + APICallLoggingProjectIDs respjson.Field + Description respjson.Field + Name respjson.Field + ThreadsUiVisibility respjson.Field + Title respjson.Field + UsageDashboardVisibility respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseOrganizationUpdatedChangesRequested) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseOrganizationUpdatedChangesRequested) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The project that the action was scoped to. Absent for actions not scoped to +// projects. Note that any admin actions taken via Admin API keys are associated +// with the default project. +type AdminOrganizationAuditLogListResponseProject struct { + // The project ID. + ID string `json:"id"` + // The project title. + Name string `json:"name"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Name respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseProject) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseProject) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseProjectArchived struct { + // The project ID. + ID string `json:"id"` + // 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 AdminOrganizationAuditLogListResponseProjectArchived) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseProjectArchived) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseProjectCreated struct { + // The project ID. + ID string `json:"id"` + // The payload used to create the project. + Data AdminOrganizationAuditLogListResponseProjectCreatedData `json:"data"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Data respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseProjectCreated) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseProjectCreated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The payload used to create the project. +type AdminOrganizationAuditLogListResponseProjectCreatedData struct { + // The project name. + Name string `json:"name"` + // The title of the project as seen on the dashboard. + Title string `json:"title"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Name respjson.Field + Title respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseProjectCreatedData) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseProjectCreatedData) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseProjectDeleted struct { + // The project ID. + ID string `json:"id"` + // 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 AdminOrganizationAuditLogListResponseProjectDeleted) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseProjectDeleted) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseProjectUpdated struct { + // The project ID. + ID string `json:"id"` + // The payload used to update the project. + ChangesRequested AdminOrganizationAuditLogListResponseProjectUpdatedChangesRequested `json:"changes_requested"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + ChangesRequested respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseProjectUpdated) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseProjectUpdated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The payload used to update the project. +type AdminOrganizationAuditLogListResponseProjectUpdatedChangesRequested struct { + // The title of the project as seen on the dashboard. + Title string `json:"title"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Title respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseProjectUpdatedChangesRequested) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseProjectUpdatedChangesRequested) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseRateLimitDeleted struct { + // The rate limit ID + ID string `json:"id"` + // 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 AdminOrganizationAuditLogListResponseRateLimitDeleted) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseRateLimitDeleted) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseRateLimitUpdated struct { + // The rate limit ID + ID string `json:"id"` + // The payload used to update the rate limits. + ChangesRequested AdminOrganizationAuditLogListResponseRateLimitUpdatedChangesRequested `json:"changes_requested"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + ChangesRequested respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseRateLimitUpdated) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseRateLimitUpdated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The payload used to update the rate limits. +type AdminOrganizationAuditLogListResponseRateLimitUpdatedChangesRequested struct { + // The maximum batch input tokens per day. Only relevant for certain models. + Batch1DayMaxInputTokens int64 `json:"batch_1_day_max_input_tokens"` + // The maximum audio megabytes per minute. Only relevant for certain models. + MaxAudioMegabytesPer1Minute int64 `json:"max_audio_megabytes_per_1_minute"` + // The maximum images per minute. Only relevant for certain models. + MaxImagesPer1Minute int64 `json:"max_images_per_1_minute"` + // The maximum requests per day. Only relevant for certain models. + MaxRequestsPer1Day int64 `json:"max_requests_per_1_day"` + // The maximum requests per minute. + MaxRequestsPer1Minute int64 `json:"max_requests_per_1_minute"` + // The maximum tokens per minute. + MaxTokensPer1Minute int64 `json:"max_tokens_per_1_minute"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Batch1DayMaxInputTokens respjson.Field + MaxAudioMegabytesPer1Minute respjson.Field + MaxImagesPer1Minute respjson.Field + MaxRequestsPer1Day respjson.Field + MaxRequestsPer1Minute respjson.Field + MaxTokensPer1Minute respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseRateLimitUpdatedChangesRequested) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseRateLimitUpdatedChangesRequested) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseRoleAssignmentCreated struct { + // The identifier of the role assignment. + ID string `json:"id"` + // The principal (user or group) that received the role. + PrincipalID string `json:"principal_id"` + // The type of principal (user or group) that received the role. + PrincipalType string `json:"principal_type"` + // The resource the role assignment is scoped to. + ResourceID string `json:"resource_id"` + // The type of resource the role assignment is scoped to. + ResourceType string `json:"resource_type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + PrincipalID respjson.Field + PrincipalType respjson.Field + ResourceID respjson.Field + ResourceType respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseRoleAssignmentCreated) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseRoleAssignmentCreated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseRoleAssignmentDeleted struct { + // The identifier of the role assignment. + ID string `json:"id"` + // The principal (user or group) that had the role removed. + PrincipalID string `json:"principal_id"` + // The type of principal (user or group) that had the role removed. + PrincipalType string `json:"principal_type"` + // The resource the role assignment was scoped to. + ResourceID string `json:"resource_id"` + // The type of resource the role assignment was scoped to. + ResourceType string `json:"resource_type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + PrincipalID respjson.Field + PrincipalType respjson.Field + ResourceID respjson.Field + ResourceType respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseRoleAssignmentDeleted) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseRoleAssignmentDeleted) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseRoleBoundToResource struct { + // The ID of the resource the role was bound to. ChatGPT workspace connector + // resources use `__`. + ID string `json:"id"` + // The connector ID for a ChatGPT workspace connector resource. + ConnectorID string `json:"connector_id"` + // The connector display name for a ChatGPT workspace connector resource, or the + // connector ID when the display name could not be resolved. + ConnectorName string `json:"connector_name"` + // Whether the connector is enabled for the role. + Enabled bool `json:"enabled"` + // The permissions granted to the role for the resource. + Permissions []string `json:"permissions"` + // The ID of the resource the role was bound to. + ResourceID string `json:"resource_id"` + // The type of resource the role was bound to. + ResourceType string `json:"resource_type"` + // The ID of the role that was bound to the resource. + RoleID string `json:"role_id"` + // The connector role mutation path that produced the event. + // + // Any of "role_toggle", "role_connector_update", "role_delete", + // "workspace_permissions", "connector_publish". + Source string `json:"source"` + // The workspace ID for a ChatGPT workspace connector resource. + WorkspaceID string `json:"workspace_id"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + ConnectorID respjson.Field + ConnectorName respjson.Field + Enabled respjson.Field + Permissions respjson.Field + ResourceID respjson.Field + ResourceType respjson.Field + RoleID respjson.Field + Source respjson.Field + WorkspaceID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseRoleBoundToResource) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseRoleBoundToResource) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseRoleCreated struct { + // The role ID. + ID string `json:"id"` + // The permissions granted by the role. + Permissions []string `json:"permissions"` + // The resource the role is scoped to. + ResourceID string `json:"resource_id"` + // The type of resource the role belongs to. + ResourceType string `json:"resource_type"` + // The name of the role. + RoleName string `json:"role_name"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Permissions respjson.Field + ResourceID respjson.Field + ResourceType respjson.Field + RoleName respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseRoleCreated) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseRoleCreated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseRoleDeleted struct { + // The role ID. + ID string `json:"id"` + // 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 AdminOrganizationAuditLogListResponseRoleDeleted) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseRoleDeleted) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseRoleUnboundFromResource struct { + // The ID of the resource the role was unbound from. ChatGPT workspace connector + // resources use `__`. + ID string `json:"id"` + // The connector ID for a ChatGPT workspace connector resource. + ConnectorID string `json:"connector_id"` + // The connector display name for a ChatGPT workspace connector resource, or the + // connector ID when the display name could not be resolved. + ConnectorName string `json:"connector_name"` + // Whether the connector is enabled for the role. + Enabled bool `json:"enabled"` + // The permissions remaining for the role after the change. + Permissions []string `json:"permissions"` + // The ID of the resource the role was unbound from. + ResourceID string `json:"resource_id"` + // The type of resource the role was unbound from. + ResourceType string `json:"resource_type"` + // The ID of the role that was unbound from the resource. + RoleID string `json:"role_id"` + // The connector role mutation path that produced the event. + // + // Any of "role_toggle", "role_connector_update", "role_delete", + // "workspace_permissions", "connector_publish". + Source string `json:"source"` + // The workspace ID for a ChatGPT workspace connector resource. + WorkspaceID string `json:"workspace_id"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + ConnectorID respjson.Field + ConnectorName respjson.Field + Enabled respjson.Field + Permissions respjson.Field + ResourceID respjson.Field + ResourceType respjson.Field + RoleID respjson.Field + Source respjson.Field + WorkspaceID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseRoleUnboundFromResource) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseRoleUnboundFromResource) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseRoleUpdated struct { + // The role ID. + ID string `json:"id"` + // The payload used to update the role. + ChangesRequested AdminOrganizationAuditLogListResponseRoleUpdatedChangesRequested `json:"changes_requested"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + ChangesRequested respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseRoleUpdated) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseRoleUpdated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The payload used to update the role. +type AdminOrganizationAuditLogListResponseRoleUpdatedChangesRequested struct { + // The updated role description, when provided. + Description string `json:"description"` + // Additional metadata stored on the role. + Metadata any `json:"metadata"` + // The permissions added to the role. + PermissionsAdded []string `json:"permissions_added"` + // The permissions removed from the role. + PermissionsRemoved []string `json:"permissions_removed"` + // The resource the role is scoped to. + ResourceID string `json:"resource_id"` + // The type of resource the role belongs to. + ResourceType string `json:"resource_type"` + // The updated role name, when provided. + RoleName string `json:"role_name"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Description respjson.Field + Metadata respjson.Field + PermissionsAdded respjson.Field + PermissionsRemoved respjson.Field + ResourceID respjson.Field + ResourceType respjson.Field + RoleName respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseRoleUpdatedChangesRequested) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseRoleUpdatedChangesRequested) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseScimDisabled struct { + // The ID of the SCIM was disabled for. + ID string `json:"id"` + // 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 AdminOrganizationAuditLogListResponseScimDisabled) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseScimDisabled) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseScimEnabled struct { + // The ID of the SCIM was enabled for. + ID string `json:"id"` + // 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 AdminOrganizationAuditLogListResponseScimEnabled) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseScimEnabled) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseServiceAccountCreated struct { + // The service account ID. + ID string `json:"id"` + // The payload used to create the service account. + Data AdminOrganizationAuditLogListResponseServiceAccountCreatedData `json:"data"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Data respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseServiceAccountCreated) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseServiceAccountCreated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The payload used to create the service account. +type AdminOrganizationAuditLogListResponseServiceAccountCreatedData struct { + // The role of the service account. Is either `owner` or `member`. + Role string `json:"role"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Role respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseServiceAccountCreatedData) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseServiceAccountCreatedData) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseServiceAccountDeleted struct { + // The service account ID. + ID string `json:"id"` + // 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 AdminOrganizationAuditLogListResponseServiceAccountDeleted) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseServiceAccountDeleted) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseServiceAccountUpdated struct { + // The service account ID. + ID string `json:"id"` + // The payload used to updated the service account. + ChangesRequested AdminOrganizationAuditLogListResponseServiceAccountUpdatedChangesRequested `json:"changes_requested"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + ChangesRequested respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseServiceAccountUpdated) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseServiceAccountUpdated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The payload used to updated the service account. +type AdminOrganizationAuditLogListResponseServiceAccountUpdatedChangesRequested struct { + // The role of the service account. Is either `owner` or `member`. + Role string `json:"role"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Role respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseServiceAccountUpdatedChangesRequested) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseServiceAccountUpdatedChangesRequested) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseUserAdded struct { + // The user ID. + ID string `json:"id"` + // The payload used to add the user to the project. + Data AdminOrganizationAuditLogListResponseUserAddedData `json:"data"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Data respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseUserAdded) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseUserAdded) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The payload used to add the user to the project. +type AdminOrganizationAuditLogListResponseUserAddedData struct { + // The role of the user. Is either `owner` or `member`. + Role string `json:"role"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Role respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseUserAddedData) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseUserAddedData) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseUserDeleted struct { + // The user ID. + ID string `json:"id"` + // 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 AdminOrganizationAuditLogListResponseUserDeleted) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseUserDeleted) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseUserUpdated struct { + // The project ID. + ID string `json:"id"` + // The payload used to update the user. + ChangesRequested AdminOrganizationAuditLogListResponseUserUpdatedChangesRequested `json:"changes_requested"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + ChangesRequested respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseUserUpdated) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationAuditLogListResponseUserUpdated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The payload used to update the user. +type AdminOrganizationAuditLogListResponseUserUpdatedChangesRequested struct { + // The role of the user. Is either `owner` or `member`. + Role string `json:"role"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Role respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseUserUpdatedChangesRequested) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseUserUpdatedChangesRequested) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseWorkloadIdentityProviderMappingCreated struct { + // The workload identity provider mapping ID. + ID string `json:"id"` + // The payload used to create the workload identity provider mapping. + Data any `json:"data"` + // The workload identity provider ID. + IdentityProviderID string `json:"identity_provider_id"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Data respjson.Field + IdentityProviderID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseWorkloadIdentityProviderMappingCreated) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseWorkloadIdentityProviderMappingCreated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseWorkloadIdentityProviderMappingDeleted struct { + // The workload identity provider mapping ID. + ID string `json:"id"` + // The workload identity provider ID. + IdentityProviderID string `json:"identity_provider_id"` + // The project ID. + ProjectID string `json:"project_id"` + // The mapped service account ID. + ServiceAccountID string `json:"service_account_id"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + IdentityProviderID respjson.Field + ProjectID respjson.Field + ServiceAccountID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseWorkloadIdentityProviderMappingDeleted) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseWorkloadIdentityProviderMappingDeleted) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseWorkloadIdentityProviderMappingUpdated struct { + // The workload identity provider mapping ID. + ID string `json:"id"` + // The payload used to update the workload identity provider mapping. + ChangesRequested any `json:"changes_requested"` + // The workload identity provider ID. + IdentityProviderID string `json:"identity_provider_id"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + ChangesRequested respjson.Field + IdentityProviderID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseWorkloadIdentityProviderMappingUpdated) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseWorkloadIdentityProviderMappingUpdated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseWorkloadIdentityProviderCreated struct { + // The workload identity provider ID. + ID string `json:"id"` + // The payload used to create the workload identity provider. + Data any `json:"data"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Data respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseWorkloadIdentityProviderCreated) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseWorkloadIdentityProviderCreated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseWorkloadIdentityProviderDeleted struct { + // The workload identity provider ID. + ID string `json:"id"` + // The workload identity provider name. + Name string `json:"name"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Name respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseWorkloadIdentityProviderDeleted) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseWorkloadIdentityProviderDeleted) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The details for events with this `type`. +type AdminOrganizationAuditLogListResponseWorkloadIdentityProviderUpdated struct { + // The workload identity provider ID. + ID string `json:"id"` + // The payload used to update the workload identity provider. + ChangesRequested any `json:"changes_requested"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + ChangesRequested respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationAuditLogListResponseWorkloadIdentityProviderUpdated) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationAuditLogListResponseWorkloadIdentityProviderUpdated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationAuditLogListParams struct { + // A cursor for use in pagination. `after` is an object ID that defines your place + // in the list. For instance, if you make a list request and receive 100 objects, + // ending with obj_foo, your subsequent call can include after=obj_foo in order to + // fetch the next page of the list. + After param.Opt[string] `query:"after,omitzero" json:"-"` + // A cursor for use in pagination. `before` is an object ID that defines your place + // in the list. For instance, if you make a list request and receive 100 objects, + // starting with obj_foo, your subsequent call can include before=obj_foo in order + // to fetch the previous page of the list. + Before param.Opt[string] `query:"before,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:"-"` + // Return only tenant-scoped events associated with this organization. Required for + // tenant-scoped events such as `role.bound_to_resource` and + // `role.unbound_from_resource`. When `true`, all supplied event types must be + // tenant-scoped. + TenantOnly param.Opt[bool] `query:"tenant_only,omitzero" json:"-"` + // Return only events performed by users with these emails. + ActorEmails []string `query:"actor_emails,omitzero" json:"-"` + // Return only events performed by these actors. Can be a user ID, a service + // account ID, or an api key tracking ID. + ActorIDs []string `query:"actor_ids,omitzero" json:"-"` + // Return only events whose `effective_at` (Unix seconds) is in this range. + EffectiveAt AdminOrganizationAuditLogListParamsEffectiveAt `query:"effective_at,omitzero" json:"-"` + // Return only events with a `type` in one of these values. For example, + // `project.created`. For all options, see the documentation for the + // [audit log object](https://platform.openai.com/docs/api-reference/audit-logs/object). + // + // Any of "api_key.created", "api_key.updated", "api_key.deleted", + // "certificate.created", "certificate.updated", "certificate.deleted", + // "certificates.activated", "certificates.deactivated", + // "checkpoint.permission.created", "checkpoint.permission.deleted", + // "external_key.registered", "external_key.removed", "group.created", + // "group.updated", "group.deleted", "invite.sent", "invite.accepted", + // "invite.deleted", "ip_allowlist.created", "ip_allowlist.updated", + // "ip_allowlist.deleted", "ip_allowlist.config.activated", + // "ip_allowlist.config.deactivated", "login.succeeded", "login.failed", + // "logout.succeeded", "logout.failed", "organization.updated", "project.created", + // "project.updated", "project.archived", "project.deleted", "rate_limit.updated", + // "rate_limit.deleted", "resource.deleted", "tunnel.created", "tunnel.updated", + // "tunnel.deleted", "workload_identity_provider.created", + // "workload_identity_provider.updated", "workload_identity_provider.deleted", + // "workload_identity_provider_mapping.created", + // "workload_identity_provider_mapping.updated", + // "workload_identity_provider_mapping.deleted", "role.created", "role.updated", + // "role.deleted", "role.assignment.created", "role.assignment.deleted", + // "role.bound_to_resource", "role.unbound_from_resource", "scim.enabled", + // "scim.disabled", "service_account.created", "service_account.updated", + // "service_account.deleted", "user.added", "user.updated", "user.deleted". + EventTypes []string `query:"event_types,omitzero" json:"-"` + // Return only events for these projects. + ProjectIDs []string `query:"project_ids,omitzero" json:"-"` + // Return only events performed on these targets. For example, a project ID + // updated. For ChatGPT connector role events, use the workspace connector resource + // ID shown in `details.id`, such as `__`. + ResourceIDs []string `query:"resource_ids,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationAuditLogListParams]'s query parameters as +// `url.Values`. +func (r AdminOrganizationAuditLogListParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Return only events whose `effective_at` (Unix seconds) is in this range. +type AdminOrganizationAuditLogListParamsEffectiveAt struct { + // Return only events whose `effective_at` (Unix seconds) is greater than this + // value. + Gt param.Opt[int64] `query:"gt,omitzero" json:"-"` + // Return only events whose `effective_at` (Unix seconds) is greater than or equal + // to this value. + Gte param.Opt[int64] `query:"gte,omitzero" json:"-"` + // Return only events whose `effective_at` (Unix seconds) is less than this value. + Lt param.Opt[int64] `query:"lt,omitzero" json:"-"` + // Return only events whose `effective_at` (Unix seconds) is less than or equal to + // this value. + Lte param.Opt[int64] `query:"lte,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationAuditLogListParamsEffectiveAt]'s query +// parameters as `url.Values`. +func (r AdminOrganizationAuditLogListParamsEffectiveAt) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationcertificate.go b/vendor/github.com/openai/openai-go/v3/adminorganizationcertificate.go new file mode 100644 index 000000000..b1b4c8b26 --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationcertificate.go @@ -0,0 +1,547 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "errors" + "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" +) + +// AdminOrganizationCertificateService 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 [NewAdminOrganizationCertificateService] method instead. +type AdminOrganizationCertificateService struct { + Options []option.RequestOption +} + +// NewAdminOrganizationCertificateService 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 NewAdminOrganizationCertificateService(opts ...option.RequestOption) (r AdminOrganizationCertificateService) { + r = AdminOrganizationCertificateService{} + r.Options = opts + return +} + +// Upload a certificate to the organization. This does **not** automatically +// activate the certificate. +// +// Organizations can upload up to 50 certificates. +func (r *AdminOrganizationCertificateService) New(ctx context.Context, body AdminOrganizationCertificateNewParams, opts ...option.RequestOption) (res *Certificate, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + path := "organization/certificates" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Get a certificate that has been uploaded to the organization. +// +// You can get a certificate regardless of whether it is active or not. +func (r *AdminOrganizationCertificateService) Get(ctx context.Context, certificateID string, query AdminOrganizationCertificateGetParams, opts ...option.RequestOption) (res *Certificate, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if certificateID == "" { + err = errors.New("missing required certificate_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/certificates/%s", certificateID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return res, err +} + +// Modify a certificate. Note that only the name can be modified. +func (r *AdminOrganizationCertificateService) Update(ctx context.Context, certificateID string, body AdminOrganizationCertificateUpdateParams, opts ...option.RequestOption) (res *Certificate, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if certificateID == "" { + err = errors.New("missing required certificate_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/certificates/%s", certificateID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// List uploaded certificates for this organization. +func (r *AdminOrganizationCertificateService) List(ctx context.Context, query AdminOrganizationCertificateListParams, opts ...option.RequestOption) (res *pagination.ConversationCursorPage[AdminOrganizationCertificateListResponse], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := "organization/certificates" + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// List uploaded certificates for this organization. +func (r *AdminOrganizationCertificateService) ListAutoPaging(ctx context.Context, query AdminOrganizationCertificateListParams, opts ...option.RequestOption) *pagination.ConversationCursorPageAutoPager[AdminOrganizationCertificateListResponse] { + return pagination.NewConversationCursorPageAutoPager(r.List(ctx, query, opts...)) +} + +// Delete a certificate from the organization. +// +// The certificate must be inactive for the organization and all projects. +func (r *AdminOrganizationCertificateService) Delete(ctx context.Context, certificateID string, opts ...option.RequestOption) (res *AdminOrganizationCertificateDeleteResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if certificateID == "" { + err = errors.New("missing required certificate_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/certificates/%s", certificateID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + return res, err +} + +// Activate certificates at the organization level. +// +// You can atomically and idempotently activate up to 10 certificates at a time. +func (r *AdminOrganizationCertificateService) Activate(ctx context.Context, body AdminOrganizationCertificateActivateParams, opts ...option.RequestOption) (res *pagination.Page[AdminOrganizationCertificateActivateResponse], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := "organization/certificates/activate" + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, body, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Activate certificates at the organization level. +// +// You can atomically and idempotently activate up to 10 certificates at a time. +func (r *AdminOrganizationCertificateService) ActivateAutoPaging(ctx context.Context, body AdminOrganizationCertificateActivateParams, opts ...option.RequestOption) *pagination.PageAutoPager[AdminOrganizationCertificateActivateResponse] { + return pagination.NewPageAutoPager(r.Activate(ctx, body, opts...)) +} + +// Deactivate certificates at the organization level. +// +// You can atomically and idempotently deactivate up to 10 certificates at a time. +func (r *AdminOrganizationCertificateService) Deactivate(ctx context.Context, body AdminOrganizationCertificateDeactivateParams, opts ...option.RequestOption) (res *pagination.Page[AdminOrganizationCertificateDeactivateResponse], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := "organization/certificates/deactivate" + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, body, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Deactivate certificates at the organization level. +// +// You can atomically and idempotently deactivate up to 10 certificates at a time. +func (r *AdminOrganizationCertificateService) DeactivateAutoPaging(ctx context.Context, body AdminOrganizationCertificateDeactivateParams, opts ...option.RequestOption) *pagination.PageAutoPager[AdminOrganizationCertificateDeactivateResponse] { + return pagination.NewPageAutoPager(r.Deactivate(ctx, body, opts...)) +} + +// Represents an individual `certificate` uploaded to the organization. +type Certificate struct { + // The identifier, which can be referenced in API endpoints + ID string `json:"id" api:"required"` + CertificateDetails CertificateCertificateDetails `json:"certificate_details" api:"required"` + // The Unix timestamp (in seconds) of when the certificate was uploaded. + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // The name of the certificate. + Name string `json:"name" api:"required"` + // The object type. + // + // - If creating, updating, or getting a specific certificate, the object type is + // `certificate`. + // - If listing, activating, or deactivating certificates for the organization, the + // object type is `organization.certificate`. + // - If listing, activating, or deactivating certificates for a project, the object + // type is `organization.project.certificate`. + // + // Any of "certificate", "organization.certificate", + // "organization.project.certificate". + Object CertificateObject `json:"object" api:"required"` + // Whether the certificate is currently active at the specified scope. Not returned + // when getting details for a specific certificate. + Active bool `json:"active"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + CertificateDetails respjson.Field + CreatedAt respjson.Field + Name respjson.Field + Object respjson.Field + Active respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r Certificate) RawJSON() string { return r.JSON.raw } +func (r *Certificate) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type CertificateCertificateDetails struct { + // The content of the certificate in PEM format. + Content string `json:"content"` + // The Unix timestamp (in seconds) of when the certificate expires. + ExpiresAt int64 `json:"expires_at" format:"unixtime"` + // The Unix timestamp (in seconds) of when the certificate becomes valid. + ValidAt int64 `json:"valid_at" format:"unixtime"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Content respjson.Field + ExpiresAt respjson.Field + ValidAt respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r CertificateCertificateDetails) RawJSON() string { return r.JSON.raw } +func (r *CertificateCertificateDetails) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The object type. +// +// - If creating, updating, or getting a specific certificate, the object type is +// `certificate`. +// - If listing, activating, or deactivating certificates for the organization, the +// object type is `organization.certificate`. +// - If listing, activating, or deactivating certificates for a project, the object +// type is `organization.project.certificate`. +type CertificateObject string + +const ( + CertificateObjectCertificate CertificateObject = "certificate" + CertificateObjectOrganizationCertificate CertificateObject = "organization.certificate" + CertificateObjectOrganizationProjectCertificate CertificateObject = "organization.project.certificate" +) + +// Represents an individual certificate configured at the organization level. +type AdminOrganizationCertificateListResponse struct { + // The identifier, which can be referenced in API endpoints + ID string `json:"id" api:"required"` + // Whether the certificate is currently active at the organization level. + Active bool `json:"active" api:"required"` + CertificateDetails AdminOrganizationCertificateListResponseCertificateDetails `json:"certificate_details" api:"required"` + // The Unix timestamp (in seconds) of when the certificate was uploaded. + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // The name of the certificate. + Name string `json:"name" api:"required"` + // The object type, which is always `organization.certificate`. + Object constant.OrganizationCertificate `json:"object" default:"organization.certificate"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Active respjson.Field + CertificateDetails respjson.Field + CreatedAt respjson.Field + Name respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationCertificateListResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationCertificateListResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationCertificateListResponseCertificateDetails struct { + // The Unix timestamp (in seconds) of when the certificate expires. + ExpiresAt int64 `json:"expires_at" format:"unixtime"` + // The Unix timestamp (in seconds) of when the certificate becomes valid. + ValidAt int64 `json:"valid_at" format:"unixtime"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ExpiresAt respjson.Field + ValidAt respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationCertificateListResponseCertificateDetails) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationCertificateListResponseCertificateDetails) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationCertificateDeleteResponse struct { + // The ID of the certificate that was deleted. + ID string `json:"id" api:"required"` + // The object type, must be `certificate.deleted`. + Object constant.CertificateDeleted `json:"object" default:"certificate.deleted"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationCertificateDeleteResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationCertificateDeleteResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Represents an individual certificate configured at the organization level. +type AdminOrganizationCertificateActivateResponse struct { + // The identifier, which can be referenced in API endpoints + ID string `json:"id" api:"required"` + // Whether the certificate is currently active at the organization level. + Active bool `json:"active" api:"required"` + CertificateDetails AdminOrganizationCertificateActivateResponseCertificateDetails `json:"certificate_details" api:"required"` + // The Unix timestamp (in seconds) of when the certificate was uploaded. + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // The name of the certificate. + Name string `json:"name" api:"required"` + // The object type, which is always `organization.certificate`. + Object constant.OrganizationCertificate `json:"object" default:"organization.certificate"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Active respjson.Field + CertificateDetails respjson.Field + CreatedAt respjson.Field + Name respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationCertificateActivateResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationCertificateActivateResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationCertificateActivateResponseCertificateDetails struct { + // The Unix timestamp (in seconds) of when the certificate expires. + ExpiresAt int64 `json:"expires_at" format:"unixtime"` + // The Unix timestamp (in seconds) of when the certificate becomes valid. + ValidAt int64 `json:"valid_at" format:"unixtime"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ExpiresAt respjson.Field + ValidAt respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationCertificateActivateResponseCertificateDetails) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationCertificateActivateResponseCertificateDetails) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Represents an individual certificate configured at the organization level. +type AdminOrganizationCertificateDeactivateResponse struct { + // The identifier, which can be referenced in API endpoints + ID string `json:"id" api:"required"` + // Whether the certificate is currently active at the organization level. + Active bool `json:"active" api:"required"` + CertificateDetails AdminOrganizationCertificateDeactivateResponseCertificateDetails `json:"certificate_details" api:"required"` + // The Unix timestamp (in seconds) of when the certificate was uploaded. + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // The name of the certificate. + Name string `json:"name" api:"required"` + // The object type, which is always `organization.certificate`. + Object constant.OrganizationCertificate `json:"object" default:"organization.certificate"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Active respjson.Field + CertificateDetails respjson.Field + CreatedAt respjson.Field + Name respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationCertificateDeactivateResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationCertificateDeactivateResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationCertificateDeactivateResponseCertificateDetails struct { + // The Unix timestamp (in seconds) of when the certificate expires. + ExpiresAt int64 `json:"expires_at" format:"unixtime"` + // The Unix timestamp (in seconds) of when the certificate becomes valid. + ValidAt int64 `json:"valid_at" format:"unixtime"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ExpiresAt respjson.Field + ValidAt respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationCertificateDeactivateResponseCertificateDetails) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationCertificateDeactivateResponseCertificateDetails) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationCertificateNewParams struct { + // The certificate content in PEM format + Certificate string `json:"certificate" api:"required"` + // An optional name for the certificate + Name param.Opt[string] `json:"name,omitzero"` + paramObj +} + +func (r AdminOrganizationCertificateNewParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationCertificateNewParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationCertificateNewParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationCertificateGetParams struct { + // A list of additional fields to include in the response. Currently the only + // supported value is `content` to fetch the PEM content of the certificate. + // + // Any of "content". + Include []string `query:"include,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationCertificateGetParams]'s query parameters +// as `url.Values`. +func (r AdminOrganizationCertificateGetParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AdminOrganizationCertificateUpdateParams struct { + // The updated name for the certificate + Name param.Opt[string] `json:"name,omitzero"` + paramObj +} + +func (r AdminOrganizationCertificateUpdateParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationCertificateUpdateParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationCertificateUpdateParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationCertificateListParams struct { + // A cursor for use in pagination. `after` is an object ID that defines your place + // in the list. For instance, if you make a list request and receive 100 objects, + // ending with obj_foo, your subsequent call can include after=obj_foo in order to + // fetch the next page of the list. + 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:"-"` + // Sort order by the `created_at` timestamp of the objects. `asc` for ascending + // order and `desc` for descending order. + // + // Any of "asc", "desc". + Order AdminOrganizationCertificateListParamsOrder `query:"order,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationCertificateListParams]'s query parameters +// as `url.Values`. +func (r AdminOrganizationCertificateListParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Sort order by the `created_at` timestamp of the objects. `asc` for ascending +// order and `desc` for descending order. +type AdminOrganizationCertificateListParamsOrder string + +const ( + AdminOrganizationCertificateListParamsOrderAsc AdminOrganizationCertificateListParamsOrder = "asc" + AdminOrganizationCertificateListParamsOrderDesc AdminOrganizationCertificateListParamsOrder = "desc" +) + +type AdminOrganizationCertificateActivateParams struct { + CertificateIDs []string `json:"certificate_ids,omitzero" api:"required"` + paramObj +} + +func (r AdminOrganizationCertificateActivateParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationCertificateActivateParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationCertificateActivateParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationCertificateDeactivateParams struct { + CertificateIDs []string `json:"certificate_ids,omitzero" api:"required"` + paramObj +} + +func (r AdminOrganizationCertificateDeactivateParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationCertificateDeactivateParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationCertificateDeactivateParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationdataretention.go b/vendor/github.com/openai/openai-go/v3/adminorganizationdataretention.go new file mode 100644 index 000000000..df9264a1b --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationdataretention.go @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "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" +) + +// AdminOrganizationDataRetentionService 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 [NewAdminOrganizationDataRetentionService] method instead. +type AdminOrganizationDataRetentionService struct { + Options []option.RequestOption +} + +// NewAdminOrganizationDataRetentionService 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 NewAdminOrganizationDataRetentionService(opts ...option.RequestOption) (r AdminOrganizationDataRetentionService) { + r = AdminOrganizationDataRetentionService{} + r.Options = opts + return +} + +// Retrieves organization data retention controls. +func (r *AdminOrganizationDataRetentionService) Get(ctx context.Context, opts ...option.RequestOption) (res *OrganizationDataRetention, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + path := "organization/data_retention" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return res, err +} + +// Updates organization data retention controls. +func (r *AdminOrganizationDataRetentionService) Update(ctx context.Context, body AdminOrganizationDataRetentionUpdateParams, opts ...option.RequestOption) (res *OrganizationDataRetention, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + path := "organization/data_retention" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Represents the organization's data retention control setting. +type OrganizationDataRetention struct { + // The object type, which is always `organization.data_retention`. + Object constant.OrganizationDataRetention `json:"object" default:"organization.data_retention"` + // The configured organization data retention type. + // + // Any of "zero_data_retention", "modified_abuse_monitoring", + // "enhanced_zero_data_retention", "enhanced_modified_abuse_monitoring". + Type OrganizationDataRetentionType `json:"type" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r OrganizationDataRetention) RawJSON() string { return r.JSON.raw } +func (r *OrganizationDataRetention) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The configured organization data retention type. +type OrganizationDataRetentionType string + +const ( + OrganizationDataRetentionTypeZeroDataRetention OrganizationDataRetentionType = "zero_data_retention" + OrganizationDataRetentionTypeModifiedAbuseMonitoring OrganizationDataRetentionType = "modified_abuse_monitoring" + OrganizationDataRetentionTypeEnhancedZeroDataRetention OrganizationDataRetentionType = "enhanced_zero_data_retention" + OrganizationDataRetentionTypeEnhancedModifiedAbuseMonitoring OrganizationDataRetentionType = "enhanced_modified_abuse_monitoring" +) + +type AdminOrganizationDataRetentionUpdateParams struct { + // The desired organization data retention type. + // + // Any of "zero_data_retention", "modified_abuse_monitoring", + // "enhanced_zero_data_retention", "enhanced_modified_abuse_monitoring". + RetentionType AdminOrganizationDataRetentionUpdateParamsRetentionType `json:"retention_type,omitzero" api:"required"` + paramObj +} + +func (r AdminOrganizationDataRetentionUpdateParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationDataRetentionUpdateParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationDataRetentionUpdateParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The desired organization data retention type. +type AdminOrganizationDataRetentionUpdateParamsRetentionType string + +const ( + AdminOrganizationDataRetentionUpdateParamsRetentionTypeZeroDataRetention AdminOrganizationDataRetentionUpdateParamsRetentionType = "zero_data_retention" + AdminOrganizationDataRetentionUpdateParamsRetentionTypeModifiedAbuseMonitoring AdminOrganizationDataRetentionUpdateParamsRetentionType = "modified_abuse_monitoring" + AdminOrganizationDataRetentionUpdateParamsRetentionTypeEnhancedZeroDataRetention AdminOrganizationDataRetentionUpdateParamsRetentionType = "enhanced_zero_data_retention" + AdminOrganizationDataRetentionUpdateParamsRetentionTypeEnhancedModifiedAbuseMonitoring AdminOrganizationDataRetentionUpdateParamsRetentionType = "enhanced_modified_abuse_monitoring" +) diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationgroup.go b/vendor/github.com/openai/openai-go/v3/adminorganizationgroup.go new file mode 100644 index 000000000..17e4b314a --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationgroup.go @@ -0,0 +1,269 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "errors" + "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" +) + +// AdminOrganizationGroupService 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 [NewAdminOrganizationGroupService] method instead. +type AdminOrganizationGroupService struct { + Options []option.RequestOption + Users AdminOrganizationGroupUserService + Roles AdminOrganizationGroupRoleService +} + +// NewAdminOrganizationGroupService 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 NewAdminOrganizationGroupService(opts ...option.RequestOption) (r AdminOrganizationGroupService) { + r = AdminOrganizationGroupService{} + r.Options = opts + r.Users = NewAdminOrganizationGroupUserService(opts...) + r.Roles = NewAdminOrganizationGroupRoleService(opts...) + return +} + +// Creates a new group in the organization. +func (r *AdminOrganizationGroupService) New(ctx context.Context, body AdminOrganizationGroupNewParams, opts ...option.RequestOption) (res *Group, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + path := "organization/groups" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Retrieves a group. +func (r *AdminOrganizationGroupService) Get(ctx context.Context, groupID string, opts ...option.RequestOption) (res *Group, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if groupID == "" { + err = errors.New("missing required group_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/groups/%s", groupID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return res, err +} + +// Updates a group's information. +func (r *AdminOrganizationGroupService) Update(ctx context.Context, groupID string, body AdminOrganizationGroupUpdateParams, opts ...option.RequestOption) (res *AdminOrganizationGroupUpdateResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if groupID == "" { + err = errors.New("missing required group_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/groups/%s", groupID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Lists all groups in the organization. +func (r *AdminOrganizationGroupService) List(ctx context.Context, query AdminOrganizationGroupListParams, opts ...option.RequestOption) (res *pagination.NextCursorPage[Group], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := "organization/groups" + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Lists all groups in the organization. +func (r *AdminOrganizationGroupService) ListAutoPaging(ctx context.Context, query AdminOrganizationGroupListParams, opts ...option.RequestOption) *pagination.NextCursorPageAutoPager[Group] { + return pagination.NewNextCursorPageAutoPager(r.List(ctx, query, opts...)) +} + +// Deletes a group from the organization. +func (r *AdminOrganizationGroupService) Delete(ctx context.Context, groupID string, opts ...option.RequestOption) (res *AdminOrganizationGroupDeleteResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if groupID == "" { + err = errors.New("missing required group_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/groups/%s", groupID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + return res, err +} + +// Details about an organization group. +type Group struct { + // Identifier for the group. + ID string `json:"id" api:"required"` + // Unix timestamp (in seconds) when the group was created. + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // The type of the group. + // + // Any of "group", "tenant_group". + GroupType GroupGroupType `json:"group_type" api:"required"` + // Whether the group is managed through SCIM and controlled by your identity + // provider. + IsScimManaged bool `json:"is_scim_managed" api:"required"` + // Display name of the group. + Name string `json:"name" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + CreatedAt respjson.Field + GroupType respjson.Field + IsScimManaged respjson.Field + Name respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r Group) RawJSON() string { return r.JSON.raw } +func (r *Group) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The type of the group. +type GroupGroupType string + +const ( + GroupGroupTypeGroup GroupGroupType = "group" + GroupGroupTypeTenantGroup GroupGroupType = "tenant_group" +) + +// Response returned after updating a group. +type AdminOrganizationGroupUpdateResponse struct { + // Identifier for the group. + ID string `json:"id" api:"required"` + // Unix timestamp (in seconds) when the group was created. + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // Whether the group is managed through SCIM and controlled by your identity + // provider. + IsScimManaged bool `json:"is_scim_managed" api:"required"` + // Updated display name for the group. + Name string `json:"name" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + CreatedAt respjson.Field + IsScimManaged respjson.Field + Name respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationGroupUpdateResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationGroupUpdateResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Confirmation payload returned after deleting a group. +type AdminOrganizationGroupDeleteResponse struct { + // Identifier of the deleted group. + ID string `json:"id" api:"required"` + // Whether the group was deleted. + Deleted bool `json:"deleted" api:"required"` + // Always `group.deleted`. + Object constant.GroupDeleted `json:"object" default:"group.deleted"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Deleted respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationGroupDeleteResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationGroupDeleteResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationGroupNewParams struct { + // Human readable name for the group. + Name string `json:"name" api:"required"` + paramObj +} + +func (r AdminOrganizationGroupNewParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationGroupNewParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationGroupNewParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationGroupUpdateParams struct { + // New display name for the group. + Name string `json:"name" api:"required"` + paramObj +} + +func (r AdminOrganizationGroupUpdateParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationGroupUpdateParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationGroupUpdateParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationGroupListParams struct { + // A cursor for use in pagination. `after` is a group ID that defines your place in + // the list. For instance, if you make a list request and receive 100 objects, + // ending with group_abc, your subsequent call can include `after=group_abc` in + // order to fetch the next page of the list. + After param.Opt[string] `query:"after,omitzero" json:"-"` + // A limit on the number of groups to be returned. Limit can range between 0 and + // 1000, and the default is 100. + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + // Specifies the sort order of the returned groups. + // + // Any of "asc", "desc". + Order AdminOrganizationGroupListParamsOrder `query:"order,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationGroupListParams]'s query parameters as +// `url.Values`. +func (r AdminOrganizationGroupListParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Specifies the sort order of the returned groups. +type AdminOrganizationGroupListParamsOrder string + +const ( + AdminOrganizationGroupListParamsOrderAsc AdminOrganizationGroupListParamsOrder = "asc" + AdminOrganizationGroupListParamsOrderDesc AdminOrganizationGroupListParamsOrder = "desc" +) diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationgrouprole.go b/vendor/github.com/openai/openai-go/v3/adminorganizationgrouprole.go new file mode 100644 index 000000000..5b98a34c8 --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationgrouprole.go @@ -0,0 +1,374 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "errors" + "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" +) + +// AdminOrganizationGroupRoleService 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 [NewAdminOrganizationGroupRoleService] method instead. +type AdminOrganizationGroupRoleService struct { + Options []option.RequestOption +} + +// NewAdminOrganizationGroupRoleService 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 NewAdminOrganizationGroupRoleService(opts ...option.RequestOption) (r AdminOrganizationGroupRoleService) { + r = AdminOrganizationGroupRoleService{} + r.Options = opts + return +} + +// Assigns an organization role to a group within the organization. +func (r *AdminOrganizationGroupRoleService) New(ctx context.Context, groupID string, body AdminOrganizationGroupRoleNewParams, opts ...option.RequestOption) (res *AdminOrganizationGroupRoleNewResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if groupID == "" { + err = errors.New("missing required group_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/groups/%s/roles", groupID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Retrieves an organization role assigned to a group. +func (r *AdminOrganizationGroupRoleService) Get(ctx context.Context, groupID string, roleID string, opts ...option.RequestOption) (res *AdminOrganizationGroupRoleGetResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if groupID == "" { + err = errors.New("missing required group_id parameter") + return nil, err + } + if roleID == "" { + err = errors.New("missing required role_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/groups/%s/roles/%s", groupID, roleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return res, err +} + +// Lists the organization roles assigned to a group within the organization. +func (r *AdminOrganizationGroupRoleService) List(ctx context.Context, groupID string, query AdminOrganizationGroupRoleListParams, opts ...option.RequestOption) (res *pagination.NextCursorPage[AdminOrganizationGroupRoleListResponse], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + if groupID == "" { + err = errors.New("missing required group_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/groups/%s/roles", groupID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Lists the organization roles assigned to a group within the organization. +func (r *AdminOrganizationGroupRoleService) ListAutoPaging(ctx context.Context, groupID string, query AdminOrganizationGroupRoleListParams, opts ...option.RequestOption) *pagination.NextCursorPageAutoPager[AdminOrganizationGroupRoleListResponse] { + return pagination.NewNextCursorPageAutoPager(r.List(ctx, groupID, query, opts...)) +} + +// Unassigns an organization role from a group within the organization. +func (r *AdminOrganizationGroupRoleService) Delete(ctx context.Context, groupID string, roleID string, opts ...option.RequestOption) (res *AdminOrganizationGroupRoleDeleteResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if groupID == "" { + err = errors.New("missing required group_id parameter") + return nil, err + } + if roleID == "" { + err = errors.New("missing required role_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/groups/%s/roles/%s", groupID, roleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + return res, err +} + +// Role assignment linking a group to a role. +type AdminOrganizationGroupRoleNewResponse struct { + // Summary information about a group returned in role assignment responses. + Group AdminOrganizationGroupRoleNewResponseGroup `json:"group" api:"required"` + // Always `group.role`. + Object constant.GroupRole `json:"object" default:"group.role"` + // Details about a role that can be assigned through the public Roles API. + Role Role `json:"role" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Group respjson.Field + Object respjson.Field + Role respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationGroupRoleNewResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationGroupRoleNewResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Summary information about a group returned in role assignment responses. +type AdminOrganizationGroupRoleNewResponseGroup struct { + // Identifier for the group. + ID string `json:"id" api:"required"` + // Unix timestamp (in seconds) when the group was created. + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // Display name of the group. + Name string `json:"name" api:"required"` + // Always `group`. + Object constant.Group `json:"object" default:"group"` + // Whether the group is managed through SCIM. + ScimManaged bool `json:"scim_managed" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + CreatedAt respjson.Field + Name respjson.Field + Object respjson.Field + ScimManaged respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationGroupRoleNewResponseGroup) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationGroupRoleNewResponseGroup) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Detailed information about a role assignment entry returned when listing +// assignments. +type AdminOrganizationGroupRoleGetResponse struct { + // Identifier for the role. + ID string `json:"id" api:"required"` + // Principals from which the role assignment is inherited, when available. + AssignmentSources []AdminOrganizationGroupRoleGetResponseAssignmentSource `json:"assignment_sources" api:"required"` + // When the role was created. + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // Identifier of the actor who created the role. + CreatedBy string `json:"created_by" api:"required"` + // User details for the actor that created the role, when available. + CreatedByUserObj map[string]any `json:"created_by_user_obj" api:"required"` + // Description of the role. + Description string `json:"description" api:"required"` + // Arbitrary metadata stored on the role. + Metadata map[string]any `json:"metadata" api:"required"` + // Name of the role. + Name string `json:"name" api:"required"` + // Permissions associated with the role. + Permissions []string `json:"permissions" api:"required"` + // Whether the role is predefined by OpenAI. + PredefinedRole bool `json:"predefined_role" api:"required"` + // Resource type the role applies to. + ResourceType string `json:"resource_type" api:"required"` + // When the role was last updated. + UpdatedAt int64 `json:"updated_at" api:"required" format:"unixtime"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + AssignmentSources respjson.Field + CreatedAt respjson.Field + CreatedBy respjson.Field + CreatedByUserObj respjson.Field + Description respjson.Field + Metadata respjson.Field + Name respjson.Field + Permissions respjson.Field + PredefinedRole respjson.Field + ResourceType respjson.Field + UpdatedAt respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationGroupRoleGetResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationGroupRoleGetResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationGroupRoleGetResponseAssignmentSource struct { + PrincipalID string `json:"principal_id" api:"required"` + PrincipalType string `json:"principal_type" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + PrincipalID respjson.Field + PrincipalType respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationGroupRoleGetResponseAssignmentSource) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationGroupRoleGetResponseAssignmentSource) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Detailed information about a role assignment entry returned when listing +// assignments. +type AdminOrganizationGroupRoleListResponse struct { + // Identifier for the role. + ID string `json:"id" api:"required"` + // Principals from which the role assignment is inherited, when available. + AssignmentSources []AdminOrganizationGroupRoleListResponseAssignmentSource `json:"assignment_sources" api:"required"` + // When the role was created. + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // Identifier of the actor who created the role. + CreatedBy string `json:"created_by" api:"required"` + // User details for the actor that created the role, when available. + CreatedByUserObj map[string]any `json:"created_by_user_obj" api:"required"` + // Description of the role. + Description string `json:"description" api:"required"` + // Arbitrary metadata stored on the role. + Metadata map[string]any `json:"metadata" api:"required"` + // Name of the role. + Name string `json:"name" api:"required"` + // Permissions associated with the role. + Permissions []string `json:"permissions" api:"required"` + // Whether the role is predefined by OpenAI. + PredefinedRole bool `json:"predefined_role" api:"required"` + // Resource type the role applies to. + ResourceType string `json:"resource_type" api:"required"` + // When the role was last updated. + UpdatedAt int64 `json:"updated_at" api:"required" format:"unixtime"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + AssignmentSources respjson.Field + CreatedAt respjson.Field + CreatedBy respjson.Field + CreatedByUserObj respjson.Field + Description respjson.Field + Metadata respjson.Field + Name respjson.Field + Permissions respjson.Field + PredefinedRole respjson.Field + ResourceType respjson.Field + UpdatedAt respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationGroupRoleListResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationGroupRoleListResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationGroupRoleListResponseAssignmentSource struct { + PrincipalID string `json:"principal_id" api:"required"` + PrincipalType string `json:"principal_type" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + PrincipalID respjson.Field + PrincipalType respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationGroupRoleListResponseAssignmentSource) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationGroupRoleListResponseAssignmentSource) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Confirmation payload returned after unassigning a role. +type AdminOrganizationGroupRoleDeleteResponse struct { + // Whether the assignment was removed. + Deleted bool `json:"deleted" api:"required"` + // Identifier for the deleted assignment, such as `group.role.deleted` or + // `user.role.deleted`. + Object string `json:"object" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Deleted respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationGroupRoleDeleteResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationGroupRoleDeleteResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationGroupRoleNewParams struct { + // Identifier of the role to assign. + RoleID string `json:"role_id" api:"required"` + paramObj +} + +func (r AdminOrganizationGroupRoleNewParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationGroupRoleNewParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationGroupRoleNewParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationGroupRoleListParams struct { + // Cursor for pagination. Provide the value from the previous response's `next` + // field to continue listing organization roles. + After param.Opt[string] `query:"after,omitzero" json:"-"` + // A limit on the number of organization role assignments to return. + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + // Sort order for the returned organization roles. + // + // Any of "asc", "desc". + Order AdminOrganizationGroupRoleListParamsOrder `query:"order,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationGroupRoleListParams]'s query parameters as +// `url.Values`. +func (r AdminOrganizationGroupRoleListParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Sort order for the returned organization roles. +type AdminOrganizationGroupRoleListParamsOrder string + +const ( + AdminOrganizationGroupRoleListParamsOrderAsc AdminOrganizationGroupRoleListParamsOrder = "asc" + AdminOrganizationGroupRoleListParamsOrderDesc AdminOrganizationGroupRoleListParamsOrder = "desc" +) diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationgroupuser.go b/vendor/github.com/openai/openai-go/v3/adminorganizationgroupuser.go new file mode 100644 index 000000000..2e3af6d55 --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationgroupuser.go @@ -0,0 +1,271 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "errors" + "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" +) + +// AdminOrganizationGroupUserService 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 [NewAdminOrganizationGroupUserService] method instead. +type AdminOrganizationGroupUserService struct { + Options []option.RequestOption +} + +// NewAdminOrganizationGroupUserService 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 NewAdminOrganizationGroupUserService(opts ...option.RequestOption) (r AdminOrganizationGroupUserService) { + r = AdminOrganizationGroupUserService{} + r.Options = opts + return +} + +// Adds a user to a group. +func (r *AdminOrganizationGroupUserService) New(ctx context.Context, groupID string, body AdminOrganizationGroupUserNewParams, opts ...option.RequestOption) (res *AdminOrganizationGroupUserNewResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if groupID == "" { + err = errors.New("missing required group_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/groups/%s/users", groupID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Retrieves a user in a group. +func (r *AdminOrganizationGroupUserService) Get(ctx context.Context, groupID string, userID string, opts ...option.RequestOption) (res *AdminOrganizationGroupUserGetResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if groupID == "" { + err = errors.New("missing required group_id parameter") + return nil, err + } + if userID == "" { + err = errors.New("missing required user_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/groups/%s/users/%s", groupID, userID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return res, err +} + +// Lists the users assigned to a group. +func (r *AdminOrganizationGroupUserService) List(ctx context.Context, groupID string, query AdminOrganizationGroupUserListParams, opts ...option.RequestOption) (res *pagination.NextCursorPage[OrganizationGroupUser], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + if groupID == "" { + err = errors.New("missing required group_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/groups/%s/users", groupID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Lists the users assigned to a group. +func (r *AdminOrganizationGroupUserService) ListAutoPaging(ctx context.Context, groupID string, query AdminOrganizationGroupUserListParams, opts ...option.RequestOption) *pagination.NextCursorPageAutoPager[OrganizationGroupUser] { + return pagination.NewNextCursorPageAutoPager(r.List(ctx, groupID, query, opts...)) +} + +// Removes a user from a group. +func (r *AdminOrganizationGroupUserService) Delete(ctx context.Context, groupID string, userID string, opts ...option.RequestOption) (res *AdminOrganizationGroupUserDeleteResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if groupID == "" { + err = errors.New("missing required group_id parameter") + return nil, err + } + if userID == "" { + err = errors.New("missing required user_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/groups/%s/users/%s", groupID, userID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + return res, err +} + +// Represents an individual user returned when inspecting group membership. +type OrganizationGroupUser struct { + // The identifier, which can be referenced in API endpoints + ID string `json:"id" api:"required"` + // The email address of the user. + Email string `json:"email" api:"required"` + // The name of the user. + Name string `json:"name" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Email respjson.Field + Name respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r OrganizationGroupUser) RawJSON() string { return r.JSON.raw } +func (r *OrganizationGroupUser) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Confirmation payload returned after adding a user to a group. +type AdminOrganizationGroupUserNewResponse struct { + // Identifier of the group the user was added to. + GroupID string `json:"group_id" api:"required"` + // Always `group.user`. + Object constant.GroupUser `json:"object" default:"group.user"` + // Identifier of the user that was added. + UserID string `json:"user_id" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + GroupID respjson.Field + Object respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationGroupUserNewResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationGroupUserNewResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Details about a user returned from an organization group membership lookup. +type AdminOrganizationGroupUserGetResponse struct { + // Identifier for the user. + ID string `json:"id" api:"required"` + // Email address of the user, or `null` for users without an email. + Email string `json:"email" api:"required"` + // Whether the user is a service account. + IsServiceAccount bool `json:"is_service_account" api:"required"` + // Display name of the user. + Name string `json:"name" api:"required"` + // URL of the user's profile picture, if available. + Picture string `json:"picture" api:"required"` + // The type of user. + // + // Any of "user", "tenant_user". + UserType AdminOrganizationGroupUserGetResponseUserType `json:"user_type" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Email respjson.Field + IsServiceAccount respjson.Field + Name respjson.Field + Picture respjson.Field + UserType respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationGroupUserGetResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationGroupUserGetResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The type of user. +type AdminOrganizationGroupUserGetResponseUserType string + +const ( + AdminOrganizationGroupUserGetResponseUserTypeUser AdminOrganizationGroupUserGetResponseUserType = "user" + AdminOrganizationGroupUserGetResponseUserTypeTenantUser AdminOrganizationGroupUserGetResponseUserType = "tenant_user" +) + +// Confirmation payload returned after removing a user from a group. +type AdminOrganizationGroupUserDeleteResponse struct { + // Whether the group membership was removed. + Deleted bool `json:"deleted" api:"required"` + // Always `group.user.deleted`. + Object constant.GroupUserDeleted `json:"object" default:"group.user.deleted"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Deleted respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationGroupUserDeleteResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationGroupUserDeleteResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationGroupUserNewParams struct { + // Identifier of the user to add to the group. + UserID string `json:"user_id" api:"required"` + paramObj +} + +func (r AdminOrganizationGroupUserNewParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationGroupUserNewParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationGroupUserNewParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationGroupUserListParams struct { + // A cursor for use in pagination. Provide the ID of the last user from the + // previous list response to retrieve the next page. + After param.Opt[string] `query:"after,omitzero" json:"-"` + // A limit on the number of users to be returned. Limit can range between 0 and + // 1000, and the default is 100. + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + // Specifies the sort order of users in the list. + // + // Any of "asc", "desc". + Order AdminOrganizationGroupUserListParamsOrder `query:"order,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationGroupUserListParams]'s query parameters as +// `url.Values`. +func (r AdminOrganizationGroupUserListParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Specifies the sort order of users in the list. +type AdminOrganizationGroupUserListParamsOrder string + +const ( + AdminOrganizationGroupUserListParamsOrderAsc AdminOrganizationGroupUserListParamsOrder = "asc" + AdminOrganizationGroupUserListParamsOrderDesc AdminOrganizationGroupUserListParamsOrder = "desc" +) diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationinvite.go b/vendor/github.com/openai/openai-go/v3/adminorganizationinvite.go new file mode 100644 index 000000000..d81b64e48 --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationinvite.go @@ -0,0 +1,282 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "errors" + "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" +) + +// AdminOrganizationInviteService 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 [NewAdminOrganizationInviteService] method instead. +type AdminOrganizationInviteService struct { + Options []option.RequestOption +} + +// NewAdminOrganizationInviteService 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 NewAdminOrganizationInviteService(opts ...option.RequestOption) (r AdminOrganizationInviteService) { + r = AdminOrganizationInviteService{} + r.Options = opts + return +} + +// Create an invite for a user to the organization. The invite must be accepted by +// the user before they have access to the organization. +func (r *AdminOrganizationInviteService) New(ctx context.Context, body AdminOrganizationInviteNewParams, opts ...option.RequestOption) (res *Invite, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + path := "organization/invites" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Retrieves an invite. +func (r *AdminOrganizationInviteService) Get(ctx context.Context, inviteID string, opts ...option.RequestOption) (res *Invite, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if inviteID == "" { + err = errors.New("missing required invite_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/invites/%s", inviteID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return res, err +} + +// Returns a list of invites in the organization. +func (r *AdminOrganizationInviteService) List(ctx context.Context, query AdminOrganizationInviteListParams, opts ...option.RequestOption) (res *pagination.ConversationCursorPage[Invite], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := "organization/invites" + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &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 invites in the organization. +func (r *AdminOrganizationInviteService) ListAutoPaging(ctx context.Context, query AdminOrganizationInviteListParams, opts ...option.RequestOption) *pagination.ConversationCursorPageAutoPager[Invite] { + return pagination.NewConversationCursorPageAutoPager(r.List(ctx, query, opts...)) +} + +// Delete an invite. If the invite has already been accepted, it cannot be deleted. +func (r *AdminOrganizationInviteService) Delete(ctx context.Context, inviteID string, opts ...option.RequestOption) (res *AdminOrganizationInviteDeleteResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if inviteID == "" { + err = errors.New("missing required invite_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/invites/%s", inviteID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + return res, err +} + +// Represents an individual `invite` to the organization. +type Invite struct { + // The identifier, which can be referenced in API endpoints + ID string `json:"id" api:"required"` + // The Unix timestamp (in seconds) of when the invite was sent. + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // The email address of the individual to whom the invite was sent + Email string `json:"email" api:"required"` + // The object type, which is always `organization.invite` + Object constant.OrganizationInvite `json:"object" default:"organization.invite"` + // The projects that were granted membership upon acceptance of the invite. + Projects []InviteProject `json:"projects" api:"required"` + // `owner` or `reader` + // + // Any of "owner", "reader". + Role InviteRole `json:"role" api:"required"` + // `accepted`,`expired`, or `pending` + // + // Any of "accepted", "expired", "pending". + Status InviteStatus `json:"status" api:"required"` + // The Unix timestamp (in seconds) of when the invite was accepted. + AcceptedAt int64 `json:"accepted_at" api:"nullable" format:"unixtime"` + // The Unix timestamp (in seconds) of when the invite expires. + 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 + CreatedAt respjson.Field + Email respjson.Field + Object respjson.Field + Projects respjson.Field + Role respjson.Field + Status respjson.Field + AcceptedAt respjson.Field + ExpiresAt respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r Invite) RawJSON() string { return r.JSON.raw } +func (r *Invite) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type InviteProject struct { + // Project's public ID + ID string `json:"id" api:"required"` + // Project membership role + // + // Any of "member", "owner". + Role string `json:"role" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Role respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r InviteProject) RawJSON() string { return r.JSON.raw } +func (r *InviteProject) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// `owner` or `reader` +type InviteRole string + +const ( + InviteRoleOwner InviteRole = "owner" + InviteRoleReader InviteRole = "reader" +) + +// `accepted`,`expired`, or `pending` +type InviteStatus string + +const ( + InviteStatusAccepted InviteStatus = "accepted" + InviteStatusExpired InviteStatus = "expired" + InviteStatusPending InviteStatus = "pending" +) + +type AdminOrganizationInviteDeleteResponse struct { + ID string `json:"id" api:"required"` + Deleted bool `json:"deleted" api:"required"` + // The object type, which is always `organization.invite.deleted` + Object constant.OrganizationInviteDeleted `json:"object" default:"organization.invite.deleted"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Deleted respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationInviteDeleteResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationInviteDeleteResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationInviteNewParams struct { + // Send an email to this address + Email string `json:"email" api:"required"` + // `owner` or `reader` + // + // Any of "reader", "owner". + Role AdminOrganizationInviteNewParamsRole `json:"role,omitzero" api:"required"` + // An array of projects to which membership is granted at the same time the org + // invite is accepted. If omitted, the user will be invited to the default project + // for compatibility with legacy behavior. If empty list is passed, the user will + // not be invited to any projects, including the default one. + Projects []AdminOrganizationInviteNewParamsProject `json:"projects,omitzero"` + paramObj +} + +func (r AdminOrganizationInviteNewParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationInviteNewParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationInviteNewParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// `owner` or `reader` +type AdminOrganizationInviteNewParamsRole string + +const ( + AdminOrganizationInviteNewParamsRoleReader AdminOrganizationInviteNewParamsRole = "reader" + AdminOrganizationInviteNewParamsRoleOwner AdminOrganizationInviteNewParamsRole = "owner" +) + +// The properties ID, Role are required. +type AdminOrganizationInviteNewParamsProject struct { + // Project's public ID + ID string `json:"id" api:"required"` + // Project membership role + // + // Any of "member", "owner". + Role string `json:"role,omitzero" api:"required"` + paramObj +} + +func (r AdminOrganizationInviteNewParamsProject) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationInviteNewParamsProject + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationInviteNewParamsProject) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[AdminOrganizationInviteNewParamsProject]( + "role", "member", "owner", + ) +} + +type AdminOrganizationInviteListParams struct { + // A cursor for use in pagination. `after` is an object ID that defines your place + // in the list. For instance, if you make a list request and receive 100 objects, + // ending with obj_foo, your subsequent call can include after=obj_foo in order to + // fetch the next page of the list. + 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:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationInviteListParams]'s query parameters as +// `url.Values`. +func (r AdminOrganizationInviteListParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationproject.go b/vendor/github.com/openai/openai-go/v3/adminorganizationproject.go new file mode 100644 index 000000000..e57ff749b --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationproject.go @@ -0,0 +1,234 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "errors" + "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" +) + +// AdminOrganizationProjectService 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 [NewAdminOrganizationProjectService] method instead. +type AdminOrganizationProjectService struct { + Options []option.RequestOption + Users AdminOrganizationProjectUserService + ServiceAccounts AdminOrganizationProjectServiceAccountService + APIKeys AdminOrganizationProjectAPIKeyService + RateLimits AdminOrganizationProjectRateLimitService + ModelPermissions AdminOrganizationProjectModelPermissionService + HostedToolPermissions AdminOrganizationProjectHostedToolPermissionService + Groups AdminOrganizationProjectGroupService + Roles AdminOrganizationProjectRoleService + DataRetention AdminOrganizationProjectDataRetentionService + SpendAlerts AdminOrganizationProjectSpendAlertService + Certificates AdminOrganizationProjectCertificateService +} + +// NewAdminOrganizationProjectService 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 NewAdminOrganizationProjectService(opts ...option.RequestOption) (r AdminOrganizationProjectService) { + r = AdminOrganizationProjectService{} + r.Options = opts + r.Users = NewAdminOrganizationProjectUserService(opts...) + r.ServiceAccounts = NewAdminOrganizationProjectServiceAccountService(opts...) + r.APIKeys = NewAdminOrganizationProjectAPIKeyService(opts...) + r.RateLimits = NewAdminOrganizationProjectRateLimitService(opts...) + r.ModelPermissions = NewAdminOrganizationProjectModelPermissionService(opts...) + r.HostedToolPermissions = NewAdminOrganizationProjectHostedToolPermissionService(opts...) + r.Groups = NewAdminOrganizationProjectGroupService(opts...) + r.Roles = NewAdminOrganizationProjectRoleService(opts...) + r.DataRetention = NewAdminOrganizationProjectDataRetentionService(opts...) + r.SpendAlerts = NewAdminOrganizationProjectSpendAlertService(opts...) + r.Certificates = NewAdminOrganizationProjectCertificateService(opts...) + return +} + +// Create a new project in the organization. Projects can be created and archived, +// but cannot be deleted. +func (r *AdminOrganizationProjectService) New(ctx context.Context, body AdminOrganizationProjectNewParams, opts ...option.RequestOption) (res *Project, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + path := "organization/projects" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Retrieves a project. +func (r *AdminOrganizationProjectService) Get(ctx context.Context, projectID string, opts ...option.RequestOption) (res *Project, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s", projectID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return res, err +} + +// Modifies a project in the organization. +func (r *AdminOrganizationProjectService) Update(ctx context.Context, projectID string, body AdminOrganizationProjectUpdateParams, opts ...option.RequestOption) (res *Project, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s", projectID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Returns a list of projects. +func (r *AdminOrganizationProjectService) List(ctx context.Context, query AdminOrganizationProjectListParams, opts ...option.RequestOption) (res *pagination.ConversationCursorPage[Project], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := "organization/projects" + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &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 projects. +func (r *AdminOrganizationProjectService) ListAutoPaging(ctx context.Context, query AdminOrganizationProjectListParams, opts ...option.RequestOption) *pagination.ConversationCursorPageAutoPager[Project] { + return pagination.NewConversationCursorPageAutoPager(r.List(ctx, query, opts...)) +} + +// Archives a project in the organization. Archived projects cannot be used or +// updated. +func (r *AdminOrganizationProjectService) Archive(ctx context.Context, projectID string, opts ...option.RequestOption) (res *Project, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/archive", projectID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...) + return res, err +} + +// Represents an individual project. +type Project struct { + // The identifier, which can be referenced in API endpoints + ID string `json:"id" api:"required"` + // The Unix timestamp (in seconds) of when the project was created. + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // The object type, which is always `organization.project` + Object constant.OrganizationProject `json:"object" default:"organization.project"` + // The Unix timestamp (in seconds) of when the project was archived or `null`. + ArchivedAt int64 `json:"archived_at" api:"nullable" format:"unixtime"` + // The external key associated with the project. + ExternalKeyID string `json:"external_key_id" api:"nullable"` + // The name of the project. This appears in reporting. + Name string `json:"name" api:"nullable"` + // `active` or `archived` + Status string `json:"status" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + CreatedAt respjson.Field + Object respjson.Field + ArchivedAt respjson.Field + ExternalKeyID respjson.Field + Name respjson.Field + Status respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r Project) RawJSON() string { return r.JSON.raw } +func (r *Project) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectNewParams struct { + // The friendly name of the project, this name appears in reports. + Name string `json:"name" api:"required"` + // External key ID to associate with the project. + ExternalKeyID param.Opt[string] `json:"external_key_id,omitzero"` + // Create the project with the specified data residency region. Your organization + // must have access to Data residency functionality in order to use. See + // [data residency controls](https://platform.openai.com/docs/guides/your-data#data-residency-controls) + // to review the functionality and limitations of setting this field. + Geography param.Opt[string] `json:"geography,omitzero"` + paramObj +} + +func (r AdminOrganizationProjectNewParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectNewParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectNewParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectUpdateParams struct { + // External key ID to associate with the project. + ExternalKeyID param.Opt[string] `json:"external_key_id,omitzero"` + // Geography for the project. + Geography param.Opt[string] `json:"geography,omitzero"` + // The updated name of the project, this name appears in reports. + Name param.Opt[string] `json:"name,omitzero"` + paramObj +} + +func (r AdminOrganizationProjectUpdateParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectUpdateParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectUpdateParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectListParams struct { + // A cursor for use in pagination. `after` is an object ID that defines your place + // in the list. For instance, if you make a list request and receive 100 objects, + // ending with obj_foo, your subsequent call can include after=obj_foo in order to + // fetch the next page of the list. + After param.Opt[string] `query:"after,omitzero" json:"-"` + // If `true` returns all projects including those that have been `archived`. + // Archived projects are not included by default. + IncludeArchived param.Opt[bool] `query:"include_archived,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:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationProjectListParams]'s query parameters as +// `url.Values`. +func (r AdminOrganizationProjectListParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationprojectapikey.go b/vendor/github.com/openai/openai-go/v3/adminorganizationprojectapikey.go new file mode 100644 index 000000000..a7c74530f --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationprojectapikey.go @@ -0,0 +1,262 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "errors" + "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" +) + +// AdminOrganizationProjectAPIKeyService 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 [NewAdminOrganizationProjectAPIKeyService] method instead. +type AdminOrganizationProjectAPIKeyService struct { + Options []option.RequestOption +} + +// NewAdminOrganizationProjectAPIKeyService 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 NewAdminOrganizationProjectAPIKeyService(opts ...option.RequestOption) (r AdminOrganizationProjectAPIKeyService) { + r = AdminOrganizationProjectAPIKeyService{} + r.Options = opts + return +} + +// Retrieves an API key in the project. +func (r *AdminOrganizationProjectAPIKeyService) Get(ctx context.Context, projectID string, apiKeyID string, opts ...option.RequestOption) (res *ProjectAPIKey, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + if apiKeyID == "" { + err = errors.New("missing required api_key_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/api_keys/%s", projectID, apiKeyID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return res, err +} + +// Returns a list of API keys in the project. +func (r *AdminOrganizationProjectAPIKeyService) List(ctx context.Context, projectID string, query AdminOrganizationProjectAPIKeyListParams, opts ...option.RequestOption) (res *pagination.ConversationCursorPage[ProjectAPIKey], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/api_keys", projectID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &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 API keys in the project. +func (r *AdminOrganizationProjectAPIKeyService) ListAutoPaging(ctx context.Context, projectID string, query AdminOrganizationProjectAPIKeyListParams, opts ...option.RequestOption) *pagination.ConversationCursorPageAutoPager[ProjectAPIKey] { + return pagination.NewConversationCursorPageAutoPager(r.List(ctx, projectID, query, opts...)) +} + +// Deletes an API key from the project. +// +// Returns confirmation of the key deletion, or an error if the key belonged to a +// service account. +func (r *AdminOrganizationProjectAPIKeyService) Delete(ctx context.Context, projectID string, apiKeyID string, opts ...option.RequestOption) (res *AdminOrganizationProjectAPIKeyDeleteResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + if apiKeyID == "" { + err = errors.New("missing required api_key_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/api_keys/%s", projectID, apiKeyID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + return res, err +} + +// Represents an individual API key in a project. +type ProjectAPIKey struct { + // The identifier, which can be referenced in API endpoints + ID string `json:"id" api:"required"` + // The Unix timestamp (in seconds) of when the API key was created + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // The Unix timestamp (in seconds) of when the API key was last used. + LastUsedAt int64 `json:"last_used_at" api:"required" format:"unixtime"` + // The name of the API key + Name string `json:"name" api:"required"` + // The object type, which is always `organization.project.api_key` + Object constant.OrganizationProjectAPIKey `json:"object" default:"organization.project.api_key"` + Owner ProjectAPIKeyOwner `json:"owner" api:"required"` + // The redacted value of the API key + RedactedValue string `json:"redacted_value" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + CreatedAt respjson.Field + LastUsedAt respjson.Field + Name respjson.Field + Object respjson.Field + Owner respjson.Field + RedactedValue respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ProjectAPIKey) RawJSON() string { return r.JSON.raw } +func (r *ProjectAPIKey) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type ProjectAPIKeyOwner struct { + // The service account that owns a project API key. + ServiceAccount ProjectAPIKeyOwnerServiceAccount `json:"service_account"` + // `user` or `service_account` + // + // Any of "user", "service_account". + Type string `json:"type"` + // The user that owns a project API key. + User ProjectAPIKeyOwnerUser `json:"user"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ServiceAccount respjson.Field + Type respjson.Field + User respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ProjectAPIKeyOwner) RawJSON() string { return r.JSON.raw } +func (r *ProjectAPIKeyOwner) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The service account that owns a project API key. +type ProjectAPIKeyOwnerServiceAccount struct { + // The identifier, which can be referenced in API endpoints + ID string `json:"id" api:"required"` + // The Unix timestamp (in seconds) of when the service account was created. + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // The name of the service account. + Name string `json:"name" api:"required"` + // The service account's project role. + Role string `json:"role" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + CreatedAt respjson.Field + Name respjson.Field + Role respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ProjectAPIKeyOwnerServiceAccount) RawJSON() string { return r.JSON.raw } +func (r *ProjectAPIKeyOwnerServiceAccount) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The user that owns a project API key. +type ProjectAPIKeyOwnerUser struct { + // The identifier, which can be referenced in API endpoints + ID string `json:"id" api:"required"` + // The Unix timestamp (in seconds) of when the user was created. + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // The email address of the user. + Email string `json:"email" api:"required"` + // The name of the user. + Name string `json:"name" api:"required"` + // The user's project role. + Role string `json:"role" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + CreatedAt respjson.Field + Email respjson.Field + Name respjson.Field + Role respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ProjectAPIKeyOwnerUser) RawJSON() string { return r.JSON.raw } +func (r *ProjectAPIKeyOwnerUser) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectAPIKeyDeleteResponse struct { + ID string `json:"id" api:"required"` + Deleted bool `json:"deleted" api:"required"` + Object constant.OrganizationProjectAPIKeyDeleted `json:"object" default:"organization.project.api_key.deleted"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Deleted respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectAPIKeyDeleteResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationProjectAPIKeyDeleteResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectAPIKeyListParams struct { + // A cursor for use in pagination. `after` is an object ID that defines your place + // in the list. For instance, if you make a list request and receive 100 objects, + // ending with obj_foo, your subsequent call can include after=obj_foo in order to + // fetch the next page of the list. + 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:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationProjectAPIKeyListParams]'s query +// parameters as `url.Values`. +func (r AdminOrganizationProjectAPIKeyListParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationprojectcertificate.go b/vendor/github.com/openai/openai-go/v3/adminorganizationprojectcertificate.go new file mode 100644 index 000000000..7f1f70c2c --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationprojectcertificate.go @@ -0,0 +1,353 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "errors" + "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" +) + +// AdminOrganizationProjectCertificateService 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 [NewAdminOrganizationProjectCertificateService] method instead. +type AdminOrganizationProjectCertificateService struct { + Options []option.RequestOption +} + +// NewAdminOrganizationProjectCertificateService 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 NewAdminOrganizationProjectCertificateService(opts ...option.RequestOption) (r AdminOrganizationProjectCertificateService) { + r = AdminOrganizationProjectCertificateService{} + r.Options = opts + return +} + +// List certificates for this project. +func (r *AdminOrganizationProjectCertificateService) List(ctx context.Context, projectID string, query AdminOrganizationProjectCertificateListParams, opts ...option.RequestOption) (res *pagination.ConversationCursorPage[AdminOrganizationProjectCertificateListResponse], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/certificates", projectID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// List certificates for this project. +func (r *AdminOrganizationProjectCertificateService) ListAutoPaging(ctx context.Context, projectID string, query AdminOrganizationProjectCertificateListParams, opts ...option.RequestOption) *pagination.ConversationCursorPageAutoPager[AdminOrganizationProjectCertificateListResponse] { + return pagination.NewConversationCursorPageAutoPager(r.List(ctx, projectID, query, opts...)) +} + +// Activate certificates at the project level. +// +// You can atomically and idempotently activate up to 10 certificates at a time. +func (r *AdminOrganizationProjectCertificateService) Activate(ctx context.Context, projectID string, body AdminOrganizationProjectCertificateActivateParams, opts ...option.RequestOption) (res *pagination.Page[AdminOrganizationProjectCertificateActivateResponse], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/certificates/activate", projectID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, body, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Activate certificates at the project level. +// +// You can atomically and idempotently activate up to 10 certificates at a time. +func (r *AdminOrganizationProjectCertificateService) ActivateAutoPaging(ctx context.Context, projectID string, body AdminOrganizationProjectCertificateActivateParams, opts ...option.RequestOption) *pagination.PageAutoPager[AdminOrganizationProjectCertificateActivateResponse] { + return pagination.NewPageAutoPager(r.Activate(ctx, projectID, body, opts...)) +} + +// Deactivate certificates at the project level. You can atomically and +// idempotently deactivate up to 10 certificates at a time. +func (r *AdminOrganizationProjectCertificateService) Deactivate(ctx context.Context, projectID string, body AdminOrganizationProjectCertificateDeactivateParams, opts ...option.RequestOption) (res *pagination.Page[AdminOrganizationProjectCertificateDeactivateResponse], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/certificates/deactivate", projectID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, body, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Deactivate certificates at the project level. You can atomically and +// idempotently deactivate up to 10 certificates at a time. +func (r *AdminOrganizationProjectCertificateService) DeactivateAutoPaging(ctx context.Context, projectID string, body AdminOrganizationProjectCertificateDeactivateParams, opts ...option.RequestOption) *pagination.PageAutoPager[AdminOrganizationProjectCertificateDeactivateResponse] { + return pagination.NewPageAutoPager(r.Deactivate(ctx, projectID, body, opts...)) +} + +// Represents an individual certificate configured at the project level. +type AdminOrganizationProjectCertificateListResponse struct { + // The identifier, which can be referenced in API endpoints + ID string `json:"id" api:"required"` + // Whether the certificate is currently active at the project level. + Active bool `json:"active" api:"required"` + CertificateDetails AdminOrganizationProjectCertificateListResponseCertificateDetails `json:"certificate_details" api:"required"` + // The Unix timestamp (in seconds) of when the certificate was uploaded. + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // The name of the certificate. + Name string `json:"name" api:"required"` + // The object type, which is always `organization.project.certificate`. + Object constant.OrganizationProjectCertificate `json:"object" default:"organization.project.certificate"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Active respjson.Field + CertificateDetails respjson.Field + CreatedAt respjson.Field + Name respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectCertificateListResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationProjectCertificateListResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectCertificateListResponseCertificateDetails struct { + // The Unix timestamp (in seconds) of when the certificate expires. + ExpiresAt int64 `json:"expires_at" format:"unixtime"` + // The Unix timestamp (in seconds) of when the certificate becomes valid. + ValidAt int64 `json:"valid_at" format:"unixtime"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ExpiresAt respjson.Field + ValidAt respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectCertificateListResponseCertificateDetails) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationProjectCertificateListResponseCertificateDetails) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Represents an individual certificate configured at the project level. +type AdminOrganizationProjectCertificateActivateResponse struct { + // The identifier, which can be referenced in API endpoints + ID string `json:"id" api:"required"` + // Whether the certificate is currently active at the project level. + Active bool `json:"active" api:"required"` + CertificateDetails AdminOrganizationProjectCertificateActivateResponseCertificateDetails `json:"certificate_details" api:"required"` + // The Unix timestamp (in seconds) of when the certificate was uploaded. + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // The name of the certificate. + Name string `json:"name" api:"required"` + // The object type, which is always `organization.project.certificate`. + Object constant.OrganizationProjectCertificate `json:"object" default:"organization.project.certificate"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Active respjson.Field + CertificateDetails respjson.Field + CreatedAt respjson.Field + Name respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectCertificateActivateResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationProjectCertificateActivateResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectCertificateActivateResponseCertificateDetails struct { + // The Unix timestamp (in seconds) of when the certificate expires. + ExpiresAt int64 `json:"expires_at" format:"unixtime"` + // The Unix timestamp (in seconds) of when the certificate becomes valid. + ValidAt int64 `json:"valid_at" format:"unixtime"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ExpiresAt respjson.Field + ValidAt respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectCertificateActivateResponseCertificateDetails) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationProjectCertificateActivateResponseCertificateDetails) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Represents an individual certificate configured at the project level. +type AdminOrganizationProjectCertificateDeactivateResponse struct { + // The identifier, which can be referenced in API endpoints + ID string `json:"id" api:"required"` + // Whether the certificate is currently active at the project level. + Active bool `json:"active" api:"required"` + CertificateDetails AdminOrganizationProjectCertificateDeactivateResponseCertificateDetails `json:"certificate_details" api:"required"` + // The Unix timestamp (in seconds) of when the certificate was uploaded. + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // The name of the certificate. + Name string `json:"name" api:"required"` + // The object type, which is always `organization.project.certificate`. + Object constant.OrganizationProjectCertificate `json:"object" default:"organization.project.certificate"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Active respjson.Field + CertificateDetails respjson.Field + CreatedAt respjson.Field + Name respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectCertificateDeactivateResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationProjectCertificateDeactivateResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectCertificateDeactivateResponseCertificateDetails struct { + // The Unix timestamp (in seconds) of when the certificate expires. + ExpiresAt int64 `json:"expires_at" format:"unixtime"` + // The Unix timestamp (in seconds) of when the certificate becomes valid. + ValidAt int64 `json:"valid_at" format:"unixtime"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ExpiresAt respjson.Field + ValidAt respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectCertificateDeactivateResponseCertificateDetails) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationProjectCertificateDeactivateResponseCertificateDetails) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectCertificateListParams struct { + // A cursor for use in pagination. `after` is an object ID that defines your place + // in the list. For instance, if you make a list request and receive 100 objects, + // ending with obj_foo, your subsequent call can include after=obj_foo in order to + // fetch the next page of the list. + 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:"-"` + // Sort order by the `created_at` timestamp of the objects. `asc` for ascending + // order and `desc` for descending order. + // + // Any of "asc", "desc". + Order AdminOrganizationProjectCertificateListParamsOrder `query:"order,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationProjectCertificateListParams]'s query +// parameters as `url.Values`. +func (r AdminOrganizationProjectCertificateListParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Sort order by the `created_at` timestamp of the objects. `asc` for ascending +// order and `desc` for descending order. +type AdminOrganizationProjectCertificateListParamsOrder string + +const ( + AdminOrganizationProjectCertificateListParamsOrderAsc AdminOrganizationProjectCertificateListParamsOrder = "asc" + AdminOrganizationProjectCertificateListParamsOrderDesc AdminOrganizationProjectCertificateListParamsOrder = "desc" +) + +type AdminOrganizationProjectCertificateActivateParams struct { + CertificateIDs []string `json:"certificate_ids,omitzero" api:"required"` + paramObj +} + +func (r AdminOrganizationProjectCertificateActivateParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectCertificateActivateParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectCertificateActivateParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectCertificateDeactivateParams struct { + CertificateIDs []string `json:"certificate_ids,omitzero" api:"required"` + paramObj +} + +func (r AdminOrganizationProjectCertificateDeactivateParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectCertificateDeactivateParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectCertificateDeactivateParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationprojectdataretention.go b/vendor/github.com/openai/openai-go/v3/adminorganizationprojectdataretention.go new file mode 100644 index 000000000..8b085b718 --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationprojectdataretention.go @@ -0,0 +1,130 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "errors" + "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" +) + +// AdminOrganizationProjectDataRetentionService 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 [NewAdminOrganizationProjectDataRetentionService] method instead. +type AdminOrganizationProjectDataRetentionService struct { + Options []option.RequestOption +} + +// NewAdminOrganizationProjectDataRetentionService 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 NewAdminOrganizationProjectDataRetentionService(opts ...option.RequestOption) (r AdminOrganizationProjectDataRetentionService) { + r = AdminOrganizationProjectDataRetentionService{} + r.Options = opts + return +} + +// Retrieves project data retention controls. +func (r *AdminOrganizationProjectDataRetentionService) Get(ctx context.Context, projectID string, opts ...option.RequestOption) (res *ProjectDataRetention, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/data_retention", projectID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return res, err +} + +// Updates project data retention controls. +func (r *AdminOrganizationProjectDataRetentionService) Update(ctx context.Context, projectID string, body AdminOrganizationProjectDataRetentionUpdateParams, opts ...option.RequestOption) (res *ProjectDataRetention, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/data_retention", projectID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Represents a project's data retention control setting. +type ProjectDataRetention struct { + // The object type, which is always `project.data_retention`. + Object constant.ProjectDataRetention `json:"object" default:"project.data_retention"` + // The configured project data retention type. + // + // Any of "organization_default", "none", "zero_data_retention", + // "modified_abuse_monitoring", "enhanced_zero_data_retention", + // "enhanced_modified_abuse_monitoring". + Type ProjectDataRetentionType `json:"type" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ProjectDataRetention) RawJSON() string { return r.JSON.raw } +func (r *ProjectDataRetention) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The configured project data retention type. +type ProjectDataRetentionType string + +const ( + ProjectDataRetentionTypeOrganizationDefault ProjectDataRetentionType = "organization_default" + ProjectDataRetentionTypeNone ProjectDataRetentionType = "none" + ProjectDataRetentionTypeZeroDataRetention ProjectDataRetentionType = "zero_data_retention" + ProjectDataRetentionTypeModifiedAbuseMonitoring ProjectDataRetentionType = "modified_abuse_monitoring" + ProjectDataRetentionTypeEnhancedZeroDataRetention ProjectDataRetentionType = "enhanced_zero_data_retention" + ProjectDataRetentionTypeEnhancedModifiedAbuseMonitoring ProjectDataRetentionType = "enhanced_modified_abuse_monitoring" +) + +type AdminOrganizationProjectDataRetentionUpdateParams struct { + // The desired project data retention type. + // + // Any of "organization_default", "none", "zero_data_retention", + // "modified_abuse_monitoring", "enhanced_zero_data_retention", + // "enhanced_modified_abuse_monitoring". + RetentionType AdminOrganizationProjectDataRetentionUpdateParamsRetentionType `json:"retention_type,omitzero" api:"required"` + paramObj +} + +func (r AdminOrganizationProjectDataRetentionUpdateParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectDataRetentionUpdateParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectDataRetentionUpdateParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The desired project data retention type. +type AdminOrganizationProjectDataRetentionUpdateParamsRetentionType string + +const ( + AdminOrganizationProjectDataRetentionUpdateParamsRetentionTypeOrganizationDefault AdminOrganizationProjectDataRetentionUpdateParamsRetentionType = "organization_default" + AdminOrganizationProjectDataRetentionUpdateParamsRetentionTypeNone AdminOrganizationProjectDataRetentionUpdateParamsRetentionType = "none" + AdminOrganizationProjectDataRetentionUpdateParamsRetentionTypeZeroDataRetention AdminOrganizationProjectDataRetentionUpdateParamsRetentionType = "zero_data_retention" + AdminOrganizationProjectDataRetentionUpdateParamsRetentionTypeModifiedAbuseMonitoring AdminOrganizationProjectDataRetentionUpdateParamsRetentionType = "modified_abuse_monitoring" + AdminOrganizationProjectDataRetentionUpdateParamsRetentionTypeEnhancedZeroDataRetention AdminOrganizationProjectDataRetentionUpdateParamsRetentionType = "enhanced_zero_data_retention" + AdminOrganizationProjectDataRetentionUpdateParamsRetentionTypeEnhancedModifiedAbuseMonitoring AdminOrganizationProjectDataRetentionUpdateParamsRetentionType = "enhanced_modified_abuse_monitoring" +) diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationprojectgroup.go b/vendor/github.com/openai/openai-go/v3/adminorganizationprojectgroup.go new file mode 100644 index 000000000..ed18e6202 --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationprojectgroup.go @@ -0,0 +1,251 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "errors" + "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" +) + +// AdminOrganizationProjectGroupService 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 [NewAdminOrganizationProjectGroupService] method instead. +type AdminOrganizationProjectGroupService struct { + Options []option.RequestOption + Roles AdminOrganizationProjectGroupRoleService +} + +// NewAdminOrganizationProjectGroupService 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 NewAdminOrganizationProjectGroupService(opts ...option.RequestOption) (r AdminOrganizationProjectGroupService) { + r = AdminOrganizationProjectGroupService{} + r.Options = opts + r.Roles = NewAdminOrganizationProjectGroupRoleService(opts...) + return +} + +// Grants a group access to a project. +func (r *AdminOrganizationProjectGroupService) New(ctx context.Context, projectID string, body AdminOrganizationProjectGroupNewParams, opts ...option.RequestOption) (res *ProjectGroup, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/groups", projectID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Retrieves a project's group. +func (r *AdminOrganizationProjectGroupService) Get(ctx context.Context, projectID string, groupID string, query AdminOrganizationProjectGroupGetParams, opts ...option.RequestOption) (res *ProjectGroup, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + if groupID == "" { + err = errors.New("missing required group_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/groups/%s", projectID, groupID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return res, err +} + +// Lists the groups that have access to a project. +func (r *AdminOrganizationProjectGroupService) List(ctx context.Context, projectID string, query AdminOrganizationProjectGroupListParams, opts ...option.RequestOption) (res *pagination.NextCursorPage[ProjectGroup], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/groups", projectID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Lists the groups that have access to a project. +func (r *AdminOrganizationProjectGroupService) ListAutoPaging(ctx context.Context, projectID string, query AdminOrganizationProjectGroupListParams, opts ...option.RequestOption) *pagination.NextCursorPageAutoPager[ProjectGroup] { + return pagination.NewNextCursorPageAutoPager(r.List(ctx, projectID, query, opts...)) +} + +// Revokes a group's access to a project. +func (r *AdminOrganizationProjectGroupService) Delete(ctx context.Context, projectID string, groupID string, opts ...option.RequestOption) (res *AdminOrganizationProjectGroupDeleteResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + if groupID == "" { + err = errors.New("missing required group_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/groups/%s", projectID, groupID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + return res, err +} + +// Details about a group's membership in a project. +type ProjectGroup struct { + // Unix timestamp (in seconds) when the group was granted project access. + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // Identifier of the group that has access to the project. + GroupID string `json:"group_id" api:"required"` + // Display name of the group. + GroupName string `json:"group_name" api:"required"` + // The type of the group. + // + // Any of "group", "tenant_group". + GroupType ProjectGroupGroupType `json:"group_type" api:"required"` + // Always `project.group`. + Object constant.ProjectGroup `json:"object" default:"project.group"` + // Identifier of the project. + ProjectID string `json:"project_id" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + CreatedAt respjson.Field + GroupID respjson.Field + GroupName respjson.Field + GroupType respjson.Field + Object respjson.Field + ProjectID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ProjectGroup) RawJSON() string { return r.JSON.raw } +func (r *ProjectGroup) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The type of the group. +type ProjectGroupGroupType string + +const ( + ProjectGroupGroupTypeGroup ProjectGroupGroupType = "group" + ProjectGroupGroupTypeTenantGroup ProjectGroupGroupType = "tenant_group" +) + +// Confirmation payload returned after removing a group from a project. +type AdminOrganizationProjectGroupDeleteResponse struct { + // Whether the group membership in the project was removed. + Deleted bool `json:"deleted" api:"required"` + // Always `project.group.deleted`. + Object constant.ProjectGroupDeleted `json:"object" default:"project.group.deleted"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Deleted respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectGroupDeleteResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationProjectGroupDeleteResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectGroupNewParams struct { + // Identifier of the group to add to the project. + GroupID string `json:"group_id" api:"required"` + // Identifier of the project role to grant to the group. + Role string `json:"role" api:"required"` + paramObj +} + +func (r AdminOrganizationProjectGroupNewParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectGroupNewParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectGroupNewParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectGroupGetParams struct { + // The type of group to retrieve. + // + // Any of "group", "tenant_group". + GroupType AdminOrganizationProjectGroupGetParamsGroupType `query:"group_type,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationProjectGroupGetParams]'s query parameters +// as `url.Values`. +func (r AdminOrganizationProjectGroupGetParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// The type of group to retrieve. +type AdminOrganizationProjectGroupGetParamsGroupType string + +const ( + AdminOrganizationProjectGroupGetParamsGroupTypeGroup AdminOrganizationProjectGroupGetParamsGroupType = "group" + AdminOrganizationProjectGroupGetParamsGroupTypeTenantGroup AdminOrganizationProjectGroupGetParamsGroupType = "tenant_group" +) + +type AdminOrganizationProjectGroupListParams struct { + // Cursor for pagination. Provide the ID of the last group from the previous + // response to fetch the next page. + After param.Opt[string] `query:"after,omitzero" json:"-"` + // A limit on the number of project groups to return. Defaults to 20. + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + // Sort order for the returned groups. + // + // Any of "asc", "desc". + Order AdminOrganizationProjectGroupListParamsOrder `query:"order,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationProjectGroupListParams]'s query parameters +// as `url.Values`. +func (r AdminOrganizationProjectGroupListParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Sort order for the returned groups. +type AdminOrganizationProjectGroupListParamsOrder string + +const ( + AdminOrganizationProjectGroupListParamsOrderAsc AdminOrganizationProjectGroupListParamsOrder = "asc" + AdminOrganizationProjectGroupListParamsOrderDesc AdminOrganizationProjectGroupListParamsOrder = "desc" +) diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationprojectgrouprole.go b/vendor/github.com/openai/openai-go/v3/adminorganizationprojectgrouprole.go new file mode 100644 index 000000000..0c62e41a1 --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationprojectgrouprole.go @@ -0,0 +1,394 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "errors" + "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" +) + +// AdminOrganizationProjectGroupRoleService 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 [NewAdminOrganizationProjectGroupRoleService] method instead. +type AdminOrganizationProjectGroupRoleService struct { + Options []option.RequestOption +} + +// NewAdminOrganizationProjectGroupRoleService 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 NewAdminOrganizationProjectGroupRoleService(opts ...option.RequestOption) (r AdminOrganizationProjectGroupRoleService) { + r = AdminOrganizationProjectGroupRoleService{} + r.Options = opts + return +} + +// Assigns a project role to a group within a project. +func (r *AdminOrganizationProjectGroupRoleService) New(ctx context.Context, projectID string, groupID string, body AdminOrganizationProjectGroupRoleNewParams, opts ...option.RequestOption) (res *AdminOrganizationProjectGroupRoleNewResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + if groupID == "" { + err = errors.New("missing required group_id parameter") + return nil, err + } + path := requestconfig.FormatPath("projects/%s/groups/%s/roles", projectID, groupID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Retrieves a project role assigned to a group. +func (r *AdminOrganizationProjectGroupRoleService) Get(ctx context.Context, projectID string, groupID string, roleID string, opts ...option.RequestOption) (res *AdminOrganizationProjectGroupRoleGetResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + if groupID == "" { + err = errors.New("missing required group_id parameter") + return nil, err + } + if roleID == "" { + err = errors.New("missing required role_id parameter") + return nil, err + } + path := requestconfig.FormatPath("projects/%s/groups/%s/roles/%s", projectID, groupID, roleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return res, err +} + +// Lists the project roles assigned to a group within a project. +func (r *AdminOrganizationProjectGroupRoleService) List(ctx context.Context, projectID string, groupID string, query AdminOrganizationProjectGroupRoleListParams, opts ...option.RequestOption) (res *pagination.NextCursorPage[AdminOrganizationProjectGroupRoleListResponse], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + if groupID == "" { + err = errors.New("missing required group_id parameter") + return nil, err + } + path := requestconfig.FormatPath("projects/%s/groups/%s/roles", projectID, groupID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Lists the project roles assigned to a group within a project. +func (r *AdminOrganizationProjectGroupRoleService) ListAutoPaging(ctx context.Context, projectID string, groupID string, query AdminOrganizationProjectGroupRoleListParams, opts ...option.RequestOption) *pagination.NextCursorPageAutoPager[AdminOrganizationProjectGroupRoleListResponse] { + return pagination.NewNextCursorPageAutoPager(r.List(ctx, projectID, groupID, query, opts...)) +} + +// Unassigns a project role from a group within a project. +func (r *AdminOrganizationProjectGroupRoleService) Delete(ctx context.Context, projectID string, groupID string, roleID string, opts ...option.RequestOption) (res *AdminOrganizationProjectGroupRoleDeleteResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + if groupID == "" { + err = errors.New("missing required group_id parameter") + return nil, err + } + if roleID == "" { + err = errors.New("missing required role_id parameter") + return nil, err + } + path := requestconfig.FormatPath("projects/%s/groups/%s/roles/%s", projectID, groupID, roleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + return res, err +} + +// Role assignment linking a group to a role. +type AdminOrganizationProjectGroupRoleNewResponse struct { + // Summary information about a group returned in role assignment responses. + Group AdminOrganizationProjectGroupRoleNewResponseGroup `json:"group" api:"required"` + // Always `group.role`. + Object constant.GroupRole `json:"object" default:"group.role"` + // Details about a role that can be assigned through the public Roles API. + Role Role `json:"role" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Group respjson.Field + Object respjson.Field + Role respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectGroupRoleNewResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationProjectGroupRoleNewResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Summary information about a group returned in role assignment responses. +type AdminOrganizationProjectGroupRoleNewResponseGroup struct { + // Identifier for the group. + ID string `json:"id" api:"required"` + // Unix timestamp (in seconds) when the group was created. + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // Display name of the group. + Name string `json:"name" api:"required"` + // Always `group`. + Object constant.Group `json:"object" default:"group"` + // Whether the group is managed through SCIM. + ScimManaged bool `json:"scim_managed" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + CreatedAt respjson.Field + Name respjson.Field + Object respjson.Field + ScimManaged respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectGroupRoleNewResponseGroup) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationProjectGroupRoleNewResponseGroup) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Detailed information about a role assignment entry returned when listing +// assignments. +type AdminOrganizationProjectGroupRoleGetResponse struct { + // Identifier for the role. + ID string `json:"id" api:"required"` + // Principals from which the role assignment is inherited, when available. + AssignmentSources []AdminOrganizationProjectGroupRoleGetResponseAssignmentSource `json:"assignment_sources" api:"required"` + // When the role was created. + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // Identifier of the actor who created the role. + CreatedBy string `json:"created_by" api:"required"` + // User details for the actor that created the role, when available. + CreatedByUserObj map[string]any `json:"created_by_user_obj" api:"required"` + // Description of the role. + Description string `json:"description" api:"required"` + // Arbitrary metadata stored on the role. + Metadata map[string]any `json:"metadata" api:"required"` + // Name of the role. + Name string `json:"name" api:"required"` + // Permissions associated with the role. + Permissions []string `json:"permissions" api:"required"` + // Whether the role is predefined by OpenAI. + PredefinedRole bool `json:"predefined_role" api:"required"` + // Resource type the role applies to. + ResourceType string `json:"resource_type" api:"required"` + // When the role was last updated. + UpdatedAt int64 `json:"updated_at" api:"required" format:"unixtime"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + AssignmentSources respjson.Field + CreatedAt respjson.Field + CreatedBy respjson.Field + CreatedByUserObj respjson.Field + Description respjson.Field + Metadata respjson.Field + Name respjson.Field + Permissions respjson.Field + PredefinedRole respjson.Field + ResourceType respjson.Field + UpdatedAt respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectGroupRoleGetResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationProjectGroupRoleGetResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectGroupRoleGetResponseAssignmentSource struct { + PrincipalID string `json:"principal_id" api:"required"` + PrincipalType string `json:"principal_type" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + PrincipalID respjson.Field + PrincipalType respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectGroupRoleGetResponseAssignmentSource) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationProjectGroupRoleGetResponseAssignmentSource) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Detailed information about a role assignment entry returned when listing +// assignments. +type AdminOrganizationProjectGroupRoleListResponse struct { + // Identifier for the role. + ID string `json:"id" api:"required"` + // Principals from which the role assignment is inherited, when available. + AssignmentSources []AdminOrganizationProjectGroupRoleListResponseAssignmentSource `json:"assignment_sources" api:"required"` + // When the role was created. + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // Identifier of the actor who created the role. + CreatedBy string `json:"created_by" api:"required"` + // User details for the actor that created the role, when available. + CreatedByUserObj map[string]any `json:"created_by_user_obj" api:"required"` + // Description of the role. + Description string `json:"description" api:"required"` + // Arbitrary metadata stored on the role. + Metadata map[string]any `json:"metadata" api:"required"` + // Name of the role. + Name string `json:"name" api:"required"` + // Permissions associated with the role. + Permissions []string `json:"permissions" api:"required"` + // Whether the role is predefined by OpenAI. + PredefinedRole bool `json:"predefined_role" api:"required"` + // Resource type the role applies to. + ResourceType string `json:"resource_type" api:"required"` + // When the role was last updated. + UpdatedAt int64 `json:"updated_at" api:"required" format:"unixtime"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + AssignmentSources respjson.Field + CreatedAt respjson.Field + CreatedBy respjson.Field + CreatedByUserObj respjson.Field + Description respjson.Field + Metadata respjson.Field + Name respjson.Field + Permissions respjson.Field + PredefinedRole respjson.Field + ResourceType respjson.Field + UpdatedAt respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectGroupRoleListResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationProjectGroupRoleListResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectGroupRoleListResponseAssignmentSource struct { + PrincipalID string `json:"principal_id" api:"required"` + PrincipalType string `json:"principal_type" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + PrincipalID respjson.Field + PrincipalType respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectGroupRoleListResponseAssignmentSource) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationProjectGroupRoleListResponseAssignmentSource) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Confirmation payload returned after unassigning a role. +type AdminOrganizationProjectGroupRoleDeleteResponse struct { + // Whether the assignment was removed. + Deleted bool `json:"deleted" api:"required"` + // Identifier for the deleted assignment, such as `group.role.deleted` or + // `user.role.deleted`. + Object string `json:"object" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Deleted respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectGroupRoleDeleteResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationProjectGroupRoleDeleteResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectGroupRoleNewParams struct { + // Identifier of the role to assign. + RoleID string `json:"role_id" api:"required"` + paramObj +} + +func (r AdminOrganizationProjectGroupRoleNewParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectGroupRoleNewParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectGroupRoleNewParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectGroupRoleListParams struct { + // Cursor for pagination. Provide the value from the previous response's `next` + // field to continue listing project roles. + After param.Opt[string] `query:"after,omitzero" json:"-"` + // A limit on the number of project role assignments to return. + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + // Sort order for the returned project roles. + // + // Any of "asc", "desc". + Order AdminOrganizationProjectGroupRoleListParamsOrder `query:"order,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationProjectGroupRoleListParams]'s query +// parameters as `url.Values`. +func (r AdminOrganizationProjectGroupRoleListParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Sort order for the returned project roles. +type AdminOrganizationProjectGroupRoleListParamsOrder string + +const ( + AdminOrganizationProjectGroupRoleListParamsOrderAsc AdminOrganizationProjectGroupRoleListParamsOrder = "asc" + AdminOrganizationProjectGroupRoleListParamsOrderDesc AdminOrganizationProjectGroupRoleListParamsOrder = "desc" +) diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationprojecthostedtoolpermission.go b/vendor/github.com/openai/openai-go/v3/adminorganizationprojecthostedtoolpermission.go new file mode 100644 index 000000000..1a7223f75 --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationprojecthostedtoolpermission.go @@ -0,0 +1,289 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "errors" + "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" +) + +// AdminOrganizationProjectHostedToolPermissionService 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 [NewAdminOrganizationProjectHostedToolPermissionService] method instead. +type AdminOrganizationProjectHostedToolPermissionService struct { + Options []option.RequestOption +} + +// NewAdminOrganizationProjectHostedToolPermissionService 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 NewAdminOrganizationProjectHostedToolPermissionService(opts ...option.RequestOption) (r AdminOrganizationProjectHostedToolPermissionService) { + r = AdminOrganizationProjectHostedToolPermissionService{} + r.Options = opts + return +} + +// Returns hosted tool permissions for a project. +func (r *AdminOrganizationProjectHostedToolPermissionService) Get(ctx context.Context, projectID string, opts ...option.RequestOption) (res *ProjectHostedToolPermissions, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/hosted_tool_permissions", projectID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return res, err +} + +// Updates hosted tool permissions for a project. +func (r *AdminOrganizationProjectHostedToolPermissionService) Update(ctx context.Context, projectID string, body AdminOrganizationProjectHostedToolPermissionUpdateParams, opts ...option.RequestOption) (res *ProjectHostedToolPermissions, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/hosted_tool_permissions", projectID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Represents hosted tool permissions for a project. +type ProjectHostedToolPermissions struct { + // Permission state for a single hosted tool on a project. + CodeInterpreter ProjectHostedToolPermissionsCodeInterpreter `json:"code_interpreter" api:"required"` + // Permission state for a single hosted tool on a project. + FileSearch ProjectHostedToolPermissionsFileSearch `json:"file_search" api:"required"` + // Permission state for a single hosted tool on a project. + ImageGeneration ProjectHostedToolPermissionsImageGeneration `json:"image_generation" api:"required"` + // Permission state for a single hosted tool on a project. + Mcp ProjectHostedToolPermissionsMcp `json:"mcp" api:"required"` + // Permission state for a single hosted tool on a project. + WebSearch ProjectHostedToolPermissionsWebSearch `json:"web_search" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + CodeInterpreter respjson.Field + FileSearch respjson.Field + ImageGeneration respjson.Field + Mcp respjson.Field + WebSearch respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ProjectHostedToolPermissions) RawJSON() string { return r.JSON.raw } +func (r *ProjectHostedToolPermissions) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Permission state for a single hosted tool on a project. +type ProjectHostedToolPermissionsCodeInterpreter struct { + // Whether the hosted tool is enabled for the project. + Enabled bool `json:"enabled" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Enabled respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ProjectHostedToolPermissionsCodeInterpreter) RawJSON() string { return r.JSON.raw } +func (r *ProjectHostedToolPermissionsCodeInterpreter) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Permission state for a single hosted tool on a project. +type ProjectHostedToolPermissionsFileSearch struct { + // Whether the hosted tool is enabled for the project. + Enabled bool `json:"enabled" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Enabled respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ProjectHostedToolPermissionsFileSearch) RawJSON() string { return r.JSON.raw } +func (r *ProjectHostedToolPermissionsFileSearch) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Permission state for a single hosted tool on a project. +type ProjectHostedToolPermissionsImageGeneration struct { + // Whether the hosted tool is enabled for the project. + Enabled bool `json:"enabled" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Enabled respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ProjectHostedToolPermissionsImageGeneration) RawJSON() string { return r.JSON.raw } +func (r *ProjectHostedToolPermissionsImageGeneration) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Permission state for a single hosted tool on a project. +type ProjectHostedToolPermissionsMcp struct { + // Whether the hosted tool is enabled for the project. + Enabled bool `json:"enabled" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Enabled respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ProjectHostedToolPermissionsMcp) RawJSON() string { return r.JSON.raw } +func (r *ProjectHostedToolPermissionsMcp) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Permission state for a single hosted tool on a project. +type ProjectHostedToolPermissionsWebSearch struct { + // Whether the hosted tool is enabled for the project. + Enabled bool `json:"enabled" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Enabled respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ProjectHostedToolPermissionsWebSearch) RawJSON() string { return r.JSON.raw } +func (r *ProjectHostedToolPermissionsWebSearch) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectHostedToolPermissionUpdateParams struct { + // The code interpreter permission update. + CodeInterpreter AdminOrganizationProjectHostedToolPermissionUpdateParamsCodeInterpreter `json:"code_interpreter,omitzero"` + // The file search permission update. + FileSearch AdminOrganizationProjectHostedToolPermissionUpdateParamsFileSearch `json:"file_search,omitzero"` + // The image generation permission update. + ImageGeneration AdminOrganizationProjectHostedToolPermissionUpdateParamsImageGeneration `json:"image_generation,omitzero"` + // The MCP permission update. + Mcp AdminOrganizationProjectHostedToolPermissionUpdateParamsMcp `json:"mcp,omitzero"` + // The web search permission update. + WebSearch AdminOrganizationProjectHostedToolPermissionUpdateParamsWebSearch `json:"web_search,omitzero"` + paramObj +} + +func (r AdminOrganizationProjectHostedToolPermissionUpdateParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectHostedToolPermissionUpdateParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectHostedToolPermissionUpdateParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The code interpreter permission update. +// +// The property Enabled is required. +type AdminOrganizationProjectHostedToolPermissionUpdateParamsCodeInterpreter struct { + // Whether to enable the hosted tool for the project. + Enabled bool `json:"enabled" api:"required"` + paramObj +} + +func (r AdminOrganizationProjectHostedToolPermissionUpdateParamsCodeInterpreter) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectHostedToolPermissionUpdateParamsCodeInterpreter + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectHostedToolPermissionUpdateParamsCodeInterpreter) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The file search permission update. +// +// The property Enabled is required. +type AdminOrganizationProjectHostedToolPermissionUpdateParamsFileSearch struct { + // Whether to enable the hosted tool for the project. + Enabled bool `json:"enabled" api:"required"` + paramObj +} + +func (r AdminOrganizationProjectHostedToolPermissionUpdateParamsFileSearch) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectHostedToolPermissionUpdateParamsFileSearch + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectHostedToolPermissionUpdateParamsFileSearch) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The image generation permission update. +// +// The property Enabled is required. +type AdminOrganizationProjectHostedToolPermissionUpdateParamsImageGeneration struct { + // Whether to enable the hosted tool for the project. + Enabled bool `json:"enabled" api:"required"` + paramObj +} + +func (r AdminOrganizationProjectHostedToolPermissionUpdateParamsImageGeneration) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectHostedToolPermissionUpdateParamsImageGeneration + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectHostedToolPermissionUpdateParamsImageGeneration) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The MCP permission update. +// +// The property Enabled is required. +type AdminOrganizationProjectHostedToolPermissionUpdateParamsMcp struct { + // Whether to enable the hosted tool for the project. + Enabled bool `json:"enabled" api:"required"` + paramObj +} + +func (r AdminOrganizationProjectHostedToolPermissionUpdateParamsMcp) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectHostedToolPermissionUpdateParamsMcp + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectHostedToolPermissionUpdateParamsMcp) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The web search permission update. +// +// The property Enabled is required. +type AdminOrganizationProjectHostedToolPermissionUpdateParamsWebSearch struct { + // Whether to enable the hosted tool for the project. + Enabled bool `json:"enabled" api:"required"` + paramObj +} + +func (r AdminOrganizationProjectHostedToolPermissionUpdateParamsWebSearch) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectHostedToolPermissionUpdateParamsWebSearch + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectHostedToolPermissionUpdateParamsWebSearch) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationprojectmodelpermission.go b/vendor/github.com/openai/openai-go/v3/adminorganizationprojectmodelpermission.go new file mode 100644 index 000000000..33c83279c --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationprojectmodelpermission.go @@ -0,0 +1,157 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "errors" + "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" +) + +// AdminOrganizationProjectModelPermissionService 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 [NewAdminOrganizationProjectModelPermissionService] method instead. +type AdminOrganizationProjectModelPermissionService struct { + Options []option.RequestOption +} + +// NewAdminOrganizationProjectModelPermissionService 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 NewAdminOrganizationProjectModelPermissionService(opts ...option.RequestOption) (r AdminOrganizationProjectModelPermissionService) { + r = AdminOrganizationProjectModelPermissionService{} + r.Options = opts + return +} + +// Returns model permissions for a project. +func (r *AdminOrganizationProjectModelPermissionService) Get(ctx context.Context, projectID string, opts ...option.RequestOption) (res *ProjectModelPermissions, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/model_permissions", projectID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return res, err +} + +// Updates model permissions for a project. +func (r *AdminOrganizationProjectModelPermissionService) Update(ctx context.Context, projectID string, body AdminOrganizationProjectModelPermissionUpdateParams, opts ...option.RequestOption) (res *ProjectModelPermissions, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/model_permissions", projectID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Deletes model permissions for a project. +func (r *AdminOrganizationProjectModelPermissionService) Delete(ctx context.Context, projectID string, opts ...option.RequestOption) (res *ProjectModelPermissionsDeleted, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/model_permissions", projectID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + return res, err +} + +// Represents the model allowlist or denylist policy for a project. +type ProjectModelPermissions struct { + // Whether the project uses an allowlist or a denylist. + // + // Any of "allow_list", "deny_list". + Mode ProjectModelPermissionsMode `json:"mode" api:"required"` + // The model IDs included in the model permissions policy. + ModelIDs []string `json:"model_ids" api:"required"` + // The object type, which is always `project.model_permissions`. + Object constant.ProjectModelPermissions `json:"object" default:"project.model_permissions"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Mode respjson.Field + ModelIDs respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ProjectModelPermissions) RawJSON() string { return r.JSON.raw } +func (r *ProjectModelPermissions) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Whether the project uses an allowlist or a denylist. +type ProjectModelPermissionsMode string + +const ( + ProjectModelPermissionsModeAllowList ProjectModelPermissionsMode = "allow_list" + ProjectModelPermissionsModeDenyList ProjectModelPermissionsMode = "deny_list" +) + +// Confirmation payload returned after deleting project model permissions. +type ProjectModelPermissionsDeleted struct { + // Whether the project model permissions were deleted. + Deleted bool `json:"deleted" api:"required"` + // The object type, which is always `project.model_permissions.deleted`. + Object constant.ProjectModelPermissionsDeleted `json:"object" default:"project.model_permissions.deleted"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Deleted respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ProjectModelPermissionsDeleted) RawJSON() string { return r.JSON.raw } +func (r *ProjectModelPermissionsDeleted) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectModelPermissionUpdateParams struct { + // The model permissions mode to apply. + // + // Any of "allow_list", "deny_list". + Mode AdminOrganizationProjectModelPermissionUpdateParamsMode `json:"mode,omitzero" api:"required"` + // The model IDs included in this permissions policy. + ModelIDs []string `json:"model_ids,omitzero" api:"required"` + paramObj +} + +func (r AdminOrganizationProjectModelPermissionUpdateParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectModelPermissionUpdateParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectModelPermissionUpdateParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The model permissions mode to apply. +type AdminOrganizationProjectModelPermissionUpdateParamsMode string + +const ( + AdminOrganizationProjectModelPermissionUpdateParamsModeAllowList AdminOrganizationProjectModelPermissionUpdateParamsMode = "allow_list" + AdminOrganizationProjectModelPermissionUpdateParamsModeDenyList AdminOrganizationProjectModelPermissionUpdateParamsMode = "deny_list" +) diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationprojectratelimit.go b/vendor/github.com/openai/openai-go/v3/adminorganizationprojectratelimit.go new file mode 100644 index 000000000..75462c2ec --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationprojectratelimit.go @@ -0,0 +1,175 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "errors" + "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" +) + +// AdminOrganizationProjectRateLimitService 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 [NewAdminOrganizationProjectRateLimitService] method instead. +type AdminOrganizationProjectRateLimitService struct { + Options []option.RequestOption +} + +// NewAdminOrganizationProjectRateLimitService 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 NewAdminOrganizationProjectRateLimitService(opts ...option.RequestOption) (r AdminOrganizationProjectRateLimitService) { + r = AdminOrganizationProjectRateLimitService{} + r.Options = opts + return +} + +// Returns the rate limits per model for a project. +func (r *AdminOrganizationProjectRateLimitService) ListRateLimits(ctx context.Context, projectID string, query AdminOrganizationProjectRateLimitListRateLimitsParams, opts ...option.RequestOption) (res *pagination.ConversationCursorPage[ProjectRateLimit], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/rate_limits", projectID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &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 the rate limits per model for a project. +func (r *AdminOrganizationProjectRateLimitService) ListRateLimitsAutoPaging(ctx context.Context, projectID string, query AdminOrganizationProjectRateLimitListRateLimitsParams, opts ...option.RequestOption) *pagination.ConversationCursorPageAutoPager[ProjectRateLimit] { + return pagination.NewConversationCursorPageAutoPager(r.ListRateLimits(ctx, projectID, query, opts...)) +} + +// Updates a project rate limit. +func (r *AdminOrganizationProjectRateLimitService) UpdateRateLimit(ctx context.Context, projectID string, rateLimitID string, body AdminOrganizationProjectRateLimitUpdateRateLimitParams, opts ...option.RequestOption) (res *ProjectRateLimit, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + if rateLimitID == "" { + err = errors.New("missing required rate_limit_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/rate_limits/%s", projectID, rateLimitID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Represents a project rate limit config. +type ProjectRateLimit struct { + // The identifier, which can be referenced in API endpoints. + ID string `json:"id" api:"required"` + // The maximum requests per minute. + MaxRequestsPer1Minute int64 `json:"max_requests_per_1_minute" api:"required"` + // The maximum tokens per minute. + MaxTokensPer1Minute int64 `json:"max_tokens_per_1_minute" api:"required"` + // The model this rate limit applies to. + Model string `json:"model" api:"required"` + // The object type, which is always `project.rate_limit` + Object constant.ProjectRateLimit `json:"object" default:"project.rate_limit"` + // The maximum batch input tokens per day. Only present for relevant models. + Batch1DayMaxInputTokens int64 `json:"batch_1_day_max_input_tokens"` + // The maximum audio megabytes per minute. Only present for relevant models. + MaxAudioMegabytesPer1Minute int64 `json:"max_audio_megabytes_per_1_minute"` + // The maximum images per minute. Only present for relevant models. + MaxImagesPer1Minute int64 `json:"max_images_per_1_minute"` + // The maximum requests per day. Only present for relevant models. + MaxRequestsPer1Day int64 `json:"max_requests_per_1_day"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + MaxRequestsPer1Minute respjson.Field + MaxTokensPer1Minute respjson.Field + Model respjson.Field + Object respjson.Field + Batch1DayMaxInputTokens respjson.Field + MaxAudioMegabytesPer1Minute respjson.Field + MaxImagesPer1Minute respjson.Field + MaxRequestsPer1Day respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ProjectRateLimit) RawJSON() string { return r.JSON.raw } +func (r *ProjectRateLimit) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectRateLimitListRateLimitsParams struct { + // A cursor for use in pagination. `after` is an object ID that defines your place + // in the list. For instance, if you make a list request and receive 100 objects, + // ending with obj_foo, your subsequent call can include after=obj_foo in order to + // fetch the next page of the list. + After param.Opt[string] `query:"after,omitzero" json:"-"` + // A cursor for use in pagination. `before` is an object ID that defines your place + // in the list. For instance, if you make a list request and receive 100 objects, + // beginning with obj_foo, your subsequent call can include before=obj_foo in order + // to fetch the previous page of the list. + Before param.Opt[string] `query:"before,omitzero" json:"-"` + // A limit on the number of objects to be returned. The default is 100. + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationProjectRateLimitListRateLimitsParams]'s +// query parameters as `url.Values`. +func (r AdminOrganizationProjectRateLimitListRateLimitsParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AdminOrganizationProjectRateLimitUpdateRateLimitParams struct { + // The maximum batch input tokens per day. Only relevant for certain models. + Batch1DayMaxInputTokens param.Opt[int64] `json:"batch_1_day_max_input_tokens,omitzero"` + // The maximum audio megabytes per minute. Only relevant for certain models. + MaxAudioMegabytesPer1Minute param.Opt[int64] `json:"max_audio_megabytes_per_1_minute,omitzero"` + // The maximum images per minute. Only relevant for certain models. + MaxImagesPer1Minute param.Opt[int64] `json:"max_images_per_1_minute,omitzero"` + // The maximum requests per day. Only relevant for certain models. + MaxRequestsPer1Day param.Opt[int64] `json:"max_requests_per_1_day,omitzero"` + // The maximum requests per minute. + MaxRequestsPer1Minute param.Opt[int64] `json:"max_requests_per_1_minute,omitzero"` + // The maximum tokens per minute. + MaxTokensPer1Minute param.Opt[int64] `json:"max_tokens_per_1_minute,omitzero"` + paramObj +} + +func (r AdminOrganizationProjectRateLimitUpdateRateLimitParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectRateLimitUpdateRateLimitParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectRateLimitUpdateRateLimitParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationprojectrole.go b/vendor/github.com/openai/openai-go/v3/adminorganizationprojectrole.go new file mode 100644 index 000000000..d8d38f5a3 --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationprojectrole.go @@ -0,0 +1,221 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "errors" + "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" +) + +// AdminOrganizationProjectRoleService 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 [NewAdminOrganizationProjectRoleService] method instead. +type AdminOrganizationProjectRoleService struct { + Options []option.RequestOption +} + +// NewAdminOrganizationProjectRoleService 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 NewAdminOrganizationProjectRoleService(opts ...option.RequestOption) (r AdminOrganizationProjectRoleService) { + r = AdminOrganizationProjectRoleService{} + r.Options = opts + return +} + +// Creates a custom role for a project. +func (r *AdminOrganizationProjectRoleService) New(ctx context.Context, projectID string, body AdminOrganizationProjectRoleNewParams, opts ...option.RequestOption) (res *Role, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + path := requestconfig.FormatPath("projects/%s/roles", projectID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Retrieves a project role. +func (r *AdminOrganizationProjectRoleService) Get(ctx context.Context, projectID string, roleID string, opts ...option.RequestOption) (res *Role, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + if roleID == "" { + err = errors.New("missing required role_id parameter") + return nil, err + } + path := requestconfig.FormatPath("projects/%s/roles/%s", projectID, roleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return res, err +} + +// Updates an existing project role. +func (r *AdminOrganizationProjectRoleService) Update(ctx context.Context, projectID string, roleID string, body AdminOrganizationProjectRoleUpdateParams, opts ...option.RequestOption) (res *Role, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + if roleID == "" { + err = errors.New("missing required role_id parameter") + return nil, err + } + path := requestconfig.FormatPath("projects/%s/roles/%s", projectID, roleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Lists the roles configured for a project. +func (r *AdminOrganizationProjectRoleService) List(ctx context.Context, projectID string, query AdminOrganizationProjectRoleListParams, opts ...option.RequestOption) (res *pagination.NextCursorPage[Role], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + path := requestconfig.FormatPath("projects/%s/roles", projectID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Lists the roles configured for a project. +func (r *AdminOrganizationProjectRoleService) ListAutoPaging(ctx context.Context, projectID string, query AdminOrganizationProjectRoleListParams, opts ...option.RequestOption) *pagination.NextCursorPageAutoPager[Role] { + return pagination.NewNextCursorPageAutoPager(r.List(ctx, projectID, query, opts...)) +} + +// Deletes a custom role from a project. +func (r *AdminOrganizationProjectRoleService) Delete(ctx context.Context, projectID string, roleID string, opts ...option.RequestOption) (res *AdminOrganizationProjectRoleDeleteResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + if roleID == "" { + err = errors.New("missing required role_id parameter") + return nil, err + } + path := requestconfig.FormatPath("projects/%s/roles/%s", projectID, roleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + return res, err +} + +// Confirmation payload returned after deleting a role. +type AdminOrganizationProjectRoleDeleteResponse struct { + // Identifier of the deleted role. + ID string `json:"id" api:"required"` + // Whether the role was deleted. + Deleted bool `json:"deleted" api:"required"` + // Always `role.deleted`. + Object constant.RoleDeleted `json:"object" default:"role.deleted"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Deleted respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectRoleDeleteResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationProjectRoleDeleteResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectRoleNewParams struct { + // Permissions to grant to the role. + Permissions []string `json:"permissions,omitzero" api:"required"` + // Unique name for the role. + RoleName string `json:"role_name" api:"required"` + // Optional description of the role. + Description param.Opt[string] `json:"description,omitzero"` + paramObj +} + +func (r AdminOrganizationProjectRoleNewParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectRoleNewParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectRoleNewParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectRoleUpdateParams struct { + // New description for the role. + Description param.Opt[string] `json:"description,omitzero"` + // New name for the role. + RoleName param.Opt[string] `json:"role_name,omitzero"` + // Updated set of permissions for the role. + Permissions []string `json:"permissions,omitzero"` + paramObj +} + +func (r AdminOrganizationProjectRoleUpdateParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectRoleUpdateParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectRoleUpdateParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectRoleListParams struct { + // Cursor for pagination. Provide the value from the previous response's `next` + // field to continue listing roles. + After param.Opt[string] `query:"after,omitzero" json:"-"` + // A limit on the number of roles to return. Defaults to 1000. + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + // Sort order for the returned roles. + // + // Any of "asc", "desc". + Order AdminOrganizationProjectRoleListParamsOrder `query:"order,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationProjectRoleListParams]'s query parameters +// as `url.Values`. +func (r AdminOrganizationProjectRoleListParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Sort order for the returned roles. +type AdminOrganizationProjectRoleListParamsOrder string + +const ( + AdminOrganizationProjectRoleListParamsOrderAsc AdminOrganizationProjectRoleListParamsOrder = "asc" + AdminOrganizationProjectRoleListParamsOrderDesc AdminOrganizationProjectRoleListParamsOrder = "desc" +) diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationprojectserviceaccount.go b/vendor/github.com/openai/openai-go/v3/adminorganizationprojectserviceaccount.go new file mode 100644 index 000000000..2c06f93d6 --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationprojectserviceaccount.go @@ -0,0 +1,309 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "errors" + "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" +) + +// AdminOrganizationProjectServiceAccountService 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 [NewAdminOrganizationProjectServiceAccountService] method instead. +type AdminOrganizationProjectServiceAccountService struct { + Options []option.RequestOption +} + +// NewAdminOrganizationProjectServiceAccountService 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 NewAdminOrganizationProjectServiceAccountService(opts ...option.RequestOption) (r AdminOrganizationProjectServiceAccountService) { + r = AdminOrganizationProjectServiceAccountService{} + r.Options = opts + return +} + +// Creates a new service account in the project. This also returns an unredacted +// API key for the service account. +func (r *AdminOrganizationProjectServiceAccountService) New(ctx context.Context, projectID string, body AdminOrganizationProjectServiceAccountNewParams, opts ...option.RequestOption) (res *AdminOrganizationProjectServiceAccountNewResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/service_accounts", projectID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Retrieves a service account in the project. +func (r *AdminOrganizationProjectServiceAccountService) Get(ctx context.Context, projectID string, serviceAccountID string, opts ...option.RequestOption) (res *ProjectServiceAccount, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + if serviceAccountID == "" { + err = errors.New("missing required service_account_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/service_accounts/%s", projectID, serviceAccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return res, err +} + +// Updates a service account in the project. +func (r *AdminOrganizationProjectServiceAccountService) Update(ctx context.Context, projectID string, serviceAccountID string, body AdminOrganizationProjectServiceAccountUpdateParams, opts ...option.RequestOption) (res *ProjectServiceAccount, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + if serviceAccountID == "" { + err = errors.New("missing required service_account_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/service_accounts/%s", projectID, serviceAccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Returns a list of service accounts in the project. +func (r *AdminOrganizationProjectServiceAccountService) List(ctx context.Context, projectID string, query AdminOrganizationProjectServiceAccountListParams, opts ...option.RequestOption) (res *pagination.ConversationCursorPage[ProjectServiceAccount], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/service_accounts", projectID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &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 service accounts in the project. +func (r *AdminOrganizationProjectServiceAccountService) ListAutoPaging(ctx context.Context, projectID string, query AdminOrganizationProjectServiceAccountListParams, opts ...option.RequestOption) *pagination.ConversationCursorPageAutoPager[ProjectServiceAccount] { + return pagination.NewConversationCursorPageAutoPager(r.List(ctx, projectID, query, opts...)) +} + +// Deletes a service account from the project. +// +// Returns confirmation of service account deletion, or an error if the project is +// archived (archived projects have no service accounts). +func (r *AdminOrganizationProjectServiceAccountService) Delete(ctx context.Context, projectID string, serviceAccountID string, opts ...option.RequestOption) (res *AdminOrganizationProjectServiceAccountDeleteResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + if serviceAccountID == "" { + err = errors.New("missing required service_account_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/service_accounts/%s", projectID, serviceAccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + return res, err +} + +// Represents an individual service account in a project. +type ProjectServiceAccount struct { + // The identifier, which can be referenced in API endpoints + ID string `json:"id" api:"required"` + // The Unix timestamp (in seconds) of when the service account was created + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // The name of the service account + Name string `json:"name" api:"required"` + // The object type, which is always `organization.project.service_account` + Object constant.OrganizationProjectServiceAccount `json:"object" default:"organization.project.service_account"` + // `owner` or `member` + // + // Any of "owner", "member". + Role ProjectServiceAccountRole `json:"role" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + CreatedAt respjson.Field + Name respjson.Field + Object respjson.Field + Role respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ProjectServiceAccount) RawJSON() string { return r.JSON.raw } +func (r *ProjectServiceAccount) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// `owner` or `member` +type ProjectServiceAccountRole string + +const ( + ProjectServiceAccountRoleOwner ProjectServiceAccountRole = "owner" + ProjectServiceAccountRoleMember ProjectServiceAccountRole = "member" +) + +type AdminOrganizationProjectServiceAccountNewResponse struct { + ID string `json:"id" api:"required"` + APIKey AdminOrganizationProjectServiceAccountNewResponseAPIKey `json:"api_key" api:"required"` + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + Name string `json:"name" api:"required"` + Object constant.OrganizationProjectServiceAccount `json:"object" default:"organization.project.service_account"` + // Service accounts can only have one role of type `member` + Role constant.Member `json:"role" default:"member"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + APIKey respjson.Field + CreatedAt respjson.Field + Name respjson.Field + Object respjson.Field + Role respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectServiceAccountNewResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationProjectServiceAccountNewResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectServiceAccountNewResponseAPIKey struct { + ID string `json:"id" api:"required"` + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + Name string `json:"name" api:"required"` + // The object type, which is always `organization.project.service_account.api_key` + Object constant.OrganizationProjectServiceAccountAPIKey `json:"object" default:"organization.project.service_account.api_key"` + Value string `json:"value" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + CreatedAt respjson.Field + Name respjson.Field + Object respjson.Field + Value respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectServiceAccountNewResponseAPIKey) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationProjectServiceAccountNewResponseAPIKey) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectServiceAccountDeleteResponse struct { + ID string `json:"id" api:"required"` + Deleted bool `json:"deleted" api:"required"` + Object constant.OrganizationProjectServiceAccountDeleted `json:"object" default:"organization.project.service_account.deleted"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Deleted respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectServiceAccountDeleteResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationProjectServiceAccountDeleteResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectServiceAccountNewParams struct { + // The name of the service account being created. + Name string `json:"name" api:"required"` + paramObj +} + +func (r AdminOrganizationProjectServiceAccountNewParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectServiceAccountNewParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectServiceAccountNewParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectServiceAccountUpdateParams struct { + // The updated service account name. + Name param.Opt[string] `json:"name,omitzero"` + // The updated service account role. + // + // Any of "member", "owner". + Role AdminOrganizationProjectServiceAccountUpdateParamsRole `json:"role,omitzero"` + paramObj +} + +func (r AdminOrganizationProjectServiceAccountUpdateParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectServiceAccountUpdateParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectServiceAccountUpdateParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The updated service account role. +type AdminOrganizationProjectServiceAccountUpdateParamsRole string + +const ( + AdminOrganizationProjectServiceAccountUpdateParamsRoleMember AdminOrganizationProjectServiceAccountUpdateParamsRole = "member" + AdminOrganizationProjectServiceAccountUpdateParamsRoleOwner AdminOrganizationProjectServiceAccountUpdateParamsRole = "owner" +) + +type AdminOrganizationProjectServiceAccountListParams struct { + // A cursor for use in pagination. `after` is an object ID that defines your place + // in the list. For instance, if you make a list request and receive 100 objects, + // ending with obj_foo, your subsequent call can include after=obj_foo in order to + // fetch the next page of the list. + 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:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationProjectServiceAccountListParams]'s query +// parameters as `url.Values`. +func (r AdminOrganizationProjectServiceAccountListParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationprojectspendalert.go b/vendor/github.com/openai/openai-go/v3/adminorganizationprojectspendalert.go new file mode 100644 index 000000000..83795b2ae --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationprojectspendalert.go @@ -0,0 +1,386 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "errors" + "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" +) + +// AdminOrganizationProjectSpendAlertService 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 [NewAdminOrganizationProjectSpendAlertService] method instead. +type AdminOrganizationProjectSpendAlertService struct { + Options []option.RequestOption +} + +// NewAdminOrganizationProjectSpendAlertService 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 NewAdminOrganizationProjectSpendAlertService(opts ...option.RequestOption) (r AdminOrganizationProjectSpendAlertService) { + r = AdminOrganizationProjectSpendAlertService{} + r.Options = opts + return +} + +// Creates a project spend alert. +func (r *AdminOrganizationProjectSpendAlertService) New(ctx context.Context, projectID string, body AdminOrganizationProjectSpendAlertNewParams, opts ...option.RequestOption) (res *ProjectSpendAlert, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/spend_alerts", projectID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Retrieves a project spend alert. +func (r *AdminOrganizationProjectSpendAlertService) Get(ctx context.Context, projectID string, alertID string, opts ...option.RequestOption) (res *ProjectSpendAlert, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + if alertID == "" { + err = errors.New("missing required alert_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/spend_alerts/%s", projectID, alertID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return res, err +} + +// Updates a project spend alert. +func (r *AdminOrganizationProjectSpendAlertService) Update(ctx context.Context, projectID string, alertID string, body AdminOrganizationProjectSpendAlertUpdateParams, opts ...option.RequestOption) (res *ProjectSpendAlert, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + if alertID == "" { + err = errors.New("missing required alert_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/spend_alerts/%s", projectID, alertID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Lists project spend alerts. +func (r *AdminOrganizationProjectSpendAlertService) List(ctx context.Context, projectID string, query AdminOrganizationProjectSpendAlertListParams, opts ...option.RequestOption) (res *pagination.ConversationCursorPage[ProjectSpendAlert], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/spend_alerts", projectID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Lists project spend alerts. +func (r *AdminOrganizationProjectSpendAlertService) ListAutoPaging(ctx context.Context, projectID string, query AdminOrganizationProjectSpendAlertListParams, opts ...option.RequestOption) *pagination.ConversationCursorPageAutoPager[ProjectSpendAlert] { + return pagination.NewConversationCursorPageAutoPager(r.List(ctx, projectID, query, opts...)) +} + +// Deletes a project spend alert. +func (r *AdminOrganizationProjectSpendAlertService) Delete(ctx context.Context, projectID string, alertID string, opts ...option.RequestOption) (res *ProjectSpendAlertDeleted, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + if alertID == "" { + err = errors.New("missing required alert_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/spend_alerts/%s", projectID, alertID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + return res, err +} + +// Represents a spend alert configured at the project level. +type ProjectSpendAlert struct { + // The identifier, which can be referenced in API endpoints. + ID string `json:"id" api:"required"` + // The currency for the threshold amount. + // + // Any of "USD". + Currency ProjectSpendAlertCurrency `json:"currency" api:"required"` + // The time interval for evaluating spend against the threshold. + // + // Any of "month". + Interval ProjectSpendAlertInterval `json:"interval" api:"required"` + // Email notification settings for a spend alert. + NotificationChannel ProjectSpendAlertNotificationChannel `json:"notification_channel" api:"required"` + // The object type, which is always `project.spend_alert`. + Object constant.ProjectSpendAlert `json:"object" default:"project.spend_alert"` + // The alert threshold amount, in cents. + ThresholdAmount int64 `json:"threshold_amount" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Currency respjson.Field + Interval respjson.Field + NotificationChannel respjson.Field + Object respjson.Field + ThresholdAmount respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ProjectSpendAlert) RawJSON() string { return r.JSON.raw } +func (r *ProjectSpendAlert) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The currency for the threshold amount. +type ProjectSpendAlertCurrency string + +const ( + ProjectSpendAlertCurrencyUsd ProjectSpendAlertCurrency = "USD" +) + +// The time interval for evaluating spend against the threshold. +type ProjectSpendAlertInterval string + +const ( + ProjectSpendAlertIntervalMonth ProjectSpendAlertInterval = "month" +) + +// Email notification settings for a spend alert. +type ProjectSpendAlertNotificationChannel struct { + // Email addresses that receive the spend alert notification. + Recipients []string `json:"recipients" api:"required"` + // The notification channel type. Currently only `email` is supported. + Type constant.Email `json:"type" default:"email"` + // Optional subject prefix for alert emails. + SubjectPrefix string `json:"subject_prefix" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Recipients respjson.Field + Type respjson.Field + SubjectPrefix respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ProjectSpendAlertNotificationChannel) RawJSON() string { return r.JSON.raw } +func (r *ProjectSpendAlertNotificationChannel) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Confirmation payload returned after deleting a project spend alert. +type ProjectSpendAlertDeleted struct { + // The deleted spend alert ID. + ID string `json:"id" api:"required"` + // Whether the spend alert was deleted. + Deleted bool `json:"deleted" api:"required"` + // Always `project.spend_alert.deleted`. + Object constant.ProjectSpendAlertDeleted `json:"object" default:"project.spend_alert.deleted"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Deleted respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ProjectSpendAlertDeleted) RawJSON() string { return r.JSON.raw } +func (r *ProjectSpendAlertDeleted) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectSpendAlertNewParams struct { + // The currency for the threshold amount. + // + // Any of "USD". + Currency AdminOrganizationProjectSpendAlertNewParamsCurrency `json:"currency,omitzero" api:"required"` + // The time interval for evaluating spend against the threshold. + // + // Any of "month". + Interval AdminOrganizationProjectSpendAlertNewParamsInterval `json:"interval,omitzero" api:"required"` + // Email notification settings for a spend alert. + NotificationChannel AdminOrganizationProjectSpendAlertNewParamsNotificationChannel `json:"notification_channel,omitzero" api:"required"` + // The alert threshold amount, in cents. + ThresholdAmount int64 `json:"threshold_amount" api:"required"` + paramObj +} + +func (r AdminOrganizationProjectSpendAlertNewParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectSpendAlertNewParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectSpendAlertNewParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The currency for the threshold amount. +type AdminOrganizationProjectSpendAlertNewParamsCurrency string + +const ( + AdminOrganizationProjectSpendAlertNewParamsCurrencyUsd AdminOrganizationProjectSpendAlertNewParamsCurrency = "USD" +) + +// The time interval for evaluating spend against the threshold. +type AdminOrganizationProjectSpendAlertNewParamsInterval string + +const ( + AdminOrganizationProjectSpendAlertNewParamsIntervalMonth AdminOrganizationProjectSpendAlertNewParamsInterval = "month" +) + +// Email notification settings for a spend alert. +// +// The properties Recipients, Type are required. +type AdminOrganizationProjectSpendAlertNewParamsNotificationChannel struct { + // Email addresses that receive the spend alert notification. + Recipients []string `json:"recipients,omitzero" api:"required"` + // Optional subject prefix for alert emails. + SubjectPrefix param.Opt[string] `json:"subject_prefix,omitzero"` + // The notification channel type. Currently only `email` is supported. + // + // This field can be elided, and will marshal its zero value as "email". + Type constant.Email `json:"type" default:"email"` + paramObj +} + +func (r AdminOrganizationProjectSpendAlertNewParamsNotificationChannel) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectSpendAlertNewParamsNotificationChannel + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectSpendAlertNewParamsNotificationChannel) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectSpendAlertUpdateParams struct { + // The currency for the threshold amount. + // + // Any of "USD". + Currency AdminOrganizationProjectSpendAlertUpdateParamsCurrency `json:"currency,omitzero" api:"required"` + // The time interval for evaluating spend against the threshold. + // + // Any of "month". + Interval AdminOrganizationProjectSpendAlertUpdateParamsInterval `json:"interval,omitzero" api:"required"` + // Email notification settings for a spend alert. + NotificationChannel AdminOrganizationProjectSpendAlertUpdateParamsNotificationChannel `json:"notification_channel,omitzero" api:"required"` + // The alert threshold amount, in cents. + ThresholdAmount int64 `json:"threshold_amount" api:"required"` + paramObj +} + +func (r AdminOrganizationProjectSpendAlertUpdateParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectSpendAlertUpdateParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectSpendAlertUpdateParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The currency for the threshold amount. +type AdminOrganizationProjectSpendAlertUpdateParamsCurrency string + +const ( + AdminOrganizationProjectSpendAlertUpdateParamsCurrencyUsd AdminOrganizationProjectSpendAlertUpdateParamsCurrency = "USD" +) + +// The time interval for evaluating spend against the threshold. +type AdminOrganizationProjectSpendAlertUpdateParamsInterval string + +const ( + AdminOrganizationProjectSpendAlertUpdateParamsIntervalMonth AdminOrganizationProjectSpendAlertUpdateParamsInterval = "month" +) + +// Email notification settings for a spend alert. +// +// The properties Recipients, Type are required. +type AdminOrganizationProjectSpendAlertUpdateParamsNotificationChannel struct { + // Email addresses that receive the spend alert notification. + Recipients []string `json:"recipients,omitzero" api:"required"` + // Optional subject prefix for alert emails. + SubjectPrefix param.Opt[string] `json:"subject_prefix,omitzero"` + // The notification channel type. Currently only `email` is supported. + // + // This field can be elided, and will marshal its zero value as "email". + Type constant.Email `json:"type" default:"email"` + paramObj +} + +func (r AdminOrganizationProjectSpendAlertUpdateParamsNotificationChannel) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectSpendAlertUpdateParamsNotificationChannel + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectSpendAlertUpdateParamsNotificationChannel) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectSpendAlertListParams struct { + // Cursor for pagination. Provide the ID of the last spend alert from the previous + // response to fetch the next page. + After param.Opt[string] `query:"after,omitzero" json:"-"` + // Cursor for pagination. Provide the ID of the first spend alert from the previous + // response to fetch the previous page. + Before param.Opt[string] `query:"before,omitzero" json:"-"` + // A limit on the number of spend alerts to return. Defaults to 20. + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + // Sort order for the returned spend alerts. + // + // Any of "asc", "desc". + Order AdminOrganizationProjectSpendAlertListParamsOrder `query:"order,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationProjectSpendAlertListParams]'s query +// parameters as `url.Values`. +func (r AdminOrganizationProjectSpendAlertListParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Sort order for the returned spend alerts. +type AdminOrganizationProjectSpendAlertListParamsOrder string + +const ( + AdminOrganizationProjectSpendAlertListParamsOrderAsc AdminOrganizationProjectSpendAlertListParamsOrder = "asc" + AdminOrganizationProjectSpendAlertListParamsOrderDesc AdminOrganizationProjectSpendAlertListParamsOrder = "desc" +) diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationprojectuser.go b/vendor/github.com/openai/openai-go/v3/adminorganizationprojectuser.go new file mode 100644 index 000000000..9820d2fbf --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationprojectuser.go @@ -0,0 +1,243 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "errors" + "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" +) + +// AdminOrganizationProjectUserService 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 [NewAdminOrganizationProjectUserService] method instead. +type AdminOrganizationProjectUserService struct { + Options []option.RequestOption + Roles AdminOrganizationProjectUserRoleService +} + +// NewAdminOrganizationProjectUserService 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 NewAdminOrganizationProjectUserService(opts ...option.RequestOption) (r AdminOrganizationProjectUserService) { + r = AdminOrganizationProjectUserService{} + r.Options = opts + r.Roles = NewAdminOrganizationProjectUserRoleService(opts...) + return +} + +// Adds a user to the project. Users must already be members of the organization to +// be added to a project. +func (r *AdminOrganizationProjectUserService) New(ctx context.Context, projectID string, body AdminOrganizationProjectUserNewParams, opts ...option.RequestOption) (res *ProjectUser, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/users", projectID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Retrieves a user in the project. +func (r *AdminOrganizationProjectUserService) Get(ctx context.Context, projectID string, userID string, opts ...option.RequestOption) (res *ProjectUser, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + if userID == "" { + err = errors.New("missing required user_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/users/%s", projectID, userID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return res, err +} + +// Modifies a user's role in the project. +func (r *AdminOrganizationProjectUserService) Update(ctx context.Context, projectID string, userID string, body AdminOrganizationProjectUserUpdateParams, opts ...option.RequestOption) (res *ProjectUser, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + if userID == "" { + err = errors.New("missing required user_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/users/%s", projectID, userID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Returns a list of users in the project. +func (r *AdminOrganizationProjectUserService) List(ctx context.Context, projectID string, query AdminOrganizationProjectUserListParams, opts ...option.RequestOption) (res *pagination.ConversationCursorPage[ProjectUser], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/users", projectID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &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 users in the project. +func (r *AdminOrganizationProjectUserService) ListAutoPaging(ctx context.Context, projectID string, query AdminOrganizationProjectUserListParams, opts ...option.RequestOption) *pagination.ConversationCursorPageAutoPager[ProjectUser] { + return pagination.NewConversationCursorPageAutoPager(r.List(ctx, projectID, query, opts...)) +} + +// Deletes a user from the project. +// +// Returns confirmation of project user deletion, or an error if the project is +// archived (archived projects have no users). +func (r *AdminOrganizationProjectUserService) Delete(ctx context.Context, projectID string, userID string, opts ...option.RequestOption) (res *AdminOrganizationProjectUserDeleteResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + if userID == "" { + err = errors.New("missing required user_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/projects/%s/users/%s", projectID, userID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + return res, err +} + +// Represents an individual user in a project. +type ProjectUser struct { + // The identifier, which can be referenced in API endpoints + ID string `json:"id" api:"required"` + // The Unix timestamp (in seconds) of when the project was added. + AddedAt int64 `json:"added_at" api:"required" format:"unixtime"` + // The object type, which is always `organization.project.user` + Object constant.OrganizationProjectUser `json:"object" default:"organization.project.user"` + // `owner` or `member` + Role string `json:"role" api:"required"` + // The email address of the user + Email string `json:"email" api:"nullable"` + // The name of the user + Name string `json:"name" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + AddedAt respjson.Field + Object respjson.Field + Role respjson.Field + Email respjson.Field + Name respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ProjectUser) RawJSON() string { return r.JSON.raw } +func (r *ProjectUser) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectUserDeleteResponse struct { + ID string `json:"id" api:"required"` + Deleted bool `json:"deleted" api:"required"` + Object constant.OrganizationProjectUserDeleted `json:"object" default:"organization.project.user.deleted"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Deleted respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectUserDeleteResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationProjectUserDeleteResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectUserNewParams struct { + // `owner` or `member` + Role string `json:"role" api:"required"` + // Email of the user to add. + Email param.Opt[string] `json:"email,omitzero"` + // The ID of the user. + UserID param.Opt[string] `json:"user_id,omitzero"` + paramObj +} + +func (r AdminOrganizationProjectUserNewParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectUserNewParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectUserNewParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectUserUpdateParams struct { + // `owner` or `member` + Role param.Opt[string] `json:"role,omitzero"` + paramObj +} + +func (r AdminOrganizationProjectUserUpdateParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectUserUpdateParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectUserUpdateParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectUserListParams struct { + // A cursor for use in pagination. `after` is an object ID that defines your place + // in the list. For instance, if you make a list request and receive 100 objects, + // ending with obj_foo, your subsequent call can include after=obj_foo in order to + // fetch the next page of the list. + 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:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationProjectUserListParams]'s query parameters +// as `url.Values`. +func (r AdminOrganizationProjectUserListParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationprojectuserrole.go b/vendor/github.com/openai/openai-go/v3/adminorganizationprojectuserrole.go new file mode 100644 index 000000000..b50635dfa --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationprojectuserrole.go @@ -0,0 +1,364 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "errors" + "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" +) + +// AdminOrganizationProjectUserRoleService 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 [NewAdminOrganizationProjectUserRoleService] method instead. +type AdminOrganizationProjectUserRoleService struct { + Options []option.RequestOption +} + +// NewAdminOrganizationProjectUserRoleService 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 NewAdminOrganizationProjectUserRoleService(opts ...option.RequestOption) (r AdminOrganizationProjectUserRoleService) { + r = AdminOrganizationProjectUserRoleService{} + r.Options = opts + return +} + +// Assigns a project role to a user within a project. +func (r *AdminOrganizationProjectUserRoleService) New(ctx context.Context, projectID string, userID string, body AdminOrganizationProjectUserRoleNewParams, opts ...option.RequestOption) (res *AdminOrganizationProjectUserRoleNewResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + if userID == "" { + err = errors.New("missing required user_id parameter") + return nil, err + } + path := requestconfig.FormatPath("projects/%s/users/%s/roles", projectID, userID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Retrieves a project role assigned to a user. +func (r *AdminOrganizationProjectUserRoleService) Get(ctx context.Context, projectID string, userID string, roleID string, opts ...option.RequestOption) (res *AdminOrganizationProjectUserRoleGetResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + if userID == "" { + err = errors.New("missing required user_id parameter") + return nil, err + } + if roleID == "" { + err = errors.New("missing required role_id parameter") + return nil, err + } + path := requestconfig.FormatPath("projects/%s/users/%s/roles/%s", projectID, userID, roleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return res, err +} + +// Lists the project roles assigned to a user within a project. +func (r *AdminOrganizationProjectUserRoleService) List(ctx context.Context, projectID string, userID string, query AdminOrganizationProjectUserRoleListParams, opts ...option.RequestOption) (res *pagination.NextCursorPage[AdminOrganizationProjectUserRoleListResponse], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + if userID == "" { + err = errors.New("missing required user_id parameter") + return nil, err + } + path := requestconfig.FormatPath("projects/%s/users/%s/roles", projectID, userID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Lists the project roles assigned to a user within a project. +func (r *AdminOrganizationProjectUserRoleService) ListAutoPaging(ctx context.Context, projectID string, userID string, query AdminOrganizationProjectUserRoleListParams, opts ...option.RequestOption) *pagination.NextCursorPageAutoPager[AdminOrganizationProjectUserRoleListResponse] { + return pagination.NewNextCursorPageAutoPager(r.List(ctx, projectID, userID, query, opts...)) +} + +// Unassigns a project role from a user within a project. +func (r *AdminOrganizationProjectUserRoleService) Delete(ctx context.Context, projectID string, userID string, roleID string, opts ...option.RequestOption) (res *AdminOrganizationProjectUserRoleDeleteResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if projectID == "" { + err = errors.New("missing required project_id parameter") + return nil, err + } + if userID == "" { + err = errors.New("missing required user_id parameter") + return nil, err + } + if roleID == "" { + err = errors.New("missing required role_id parameter") + return nil, err + } + path := requestconfig.FormatPath("projects/%s/users/%s/roles/%s", projectID, userID, roleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + return res, err +} + +// Role assignment linking a user to a role. +type AdminOrganizationProjectUserRoleNewResponse struct { + // Always `user.role`. + Object constant.UserRole `json:"object" default:"user.role"` + // Details about a role that can be assigned through the public Roles API. + Role Role `json:"role" api:"required"` + // Represents an individual `user` within an organization. + User OrganizationUser `json:"user" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + Role respjson.Field + User respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectUserRoleNewResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationProjectUserRoleNewResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Detailed information about a role assignment entry returned when listing +// assignments. +type AdminOrganizationProjectUserRoleGetResponse struct { + // Identifier for the role. + ID string `json:"id" api:"required"` + // Principals from which the role assignment is inherited, when available. + AssignmentSources []AdminOrganizationProjectUserRoleGetResponseAssignmentSource `json:"assignment_sources" api:"required"` + // When the role was created. + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // Identifier of the actor who created the role. + CreatedBy string `json:"created_by" api:"required"` + // User details for the actor that created the role, when available. + CreatedByUserObj map[string]any `json:"created_by_user_obj" api:"required"` + // Description of the role. + Description string `json:"description" api:"required"` + // Arbitrary metadata stored on the role. + Metadata map[string]any `json:"metadata" api:"required"` + // Name of the role. + Name string `json:"name" api:"required"` + // Permissions associated with the role. + Permissions []string `json:"permissions" api:"required"` + // Whether the role is predefined by OpenAI. + PredefinedRole bool `json:"predefined_role" api:"required"` + // Resource type the role applies to. + ResourceType string `json:"resource_type" api:"required"` + // When the role was last updated. + UpdatedAt int64 `json:"updated_at" api:"required" format:"unixtime"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + AssignmentSources respjson.Field + CreatedAt respjson.Field + CreatedBy respjson.Field + CreatedByUserObj respjson.Field + Description respjson.Field + Metadata respjson.Field + Name respjson.Field + Permissions respjson.Field + PredefinedRole respjson.Field + ResourceType respjson.Field + UpdatedAt respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectUserRoleGetResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationProjectUserRoleGetResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectUserRoleGetResponseAssignmentSource struct { + PrincipalID string `json:"principal_id" api:"required"` + PrincipalType string `json:"principal_type" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + PrincipalID respjson.Field + PrincipalType respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectUserRoleGetResponseAssignmentSource) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationProjectUserRoleGetResponseAssignmentSource) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Detailed information about a role assignment entry returned when listing +// assignments. +type AdminOrganizationProjectUserRoleListResponse struct { + // Identifier for the role. + ID string `json:"id" api:"required"` + // Principals from which the role assignment is inherited, when available. + AssignmentSources []AdminOrganizationProjectUserRoleListResponseAssignmentSource `json:"assignment_sources" api:"required"` + // When the role was created. + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // Identifier of the actor who created the role. + CreatedBy string `json:"created_by" api:"required"` + // User details for the actor that created the role, when available. + CreatedByUserObj map[string]any `json:"created_by_user_obj" api:"required"` + // Description of the role. + Description string `json:"description" api:"required"` + // Arbitrary metadata stored on the role. + Metadata map[string]any `json:"metadata" api:"required"` + // Name of the role. + Name string `json:"name" api:"required"` + // Permissions associated with the role. + Permissions []string `json:"permissions" api:"required"` + // Whether the role is predefined by OpenAI. + PredefinedRole bool `json:"predefined_role" api:"required"` + // Resource type the role applies to. + ResourceType string `json:"resource_type" api:"required"` + // When the role was last updated. + UpdatedAt int64 `json:"updated_at" api:"required" format:"unixtime"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + AssignmentSources respjson.Field + CreatedAt respjson.Field + CreatedBy respjson.Field + CreatedByUserObj respjson.Field + Description respjson.Field + Metadata respjson.Field + Name respjson.Field + Permissions respjson.Field + PredefinedRole respjson.Field + ResourceType respjson.Field + UpdatedAt respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectUserRoleListResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationProjectUserRoleListResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectUserRoleListResponseAssignmentSource struct { + PrincipalID string `json:"principal_id" api:"required"` + PrincipalType string `json:"principal_type" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + PrincipalID respjson.Field + PrincipalType respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectUserRoleListResponseAssignmentSource) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationProjectUserRoleListResponseAssignmentSource) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Confirmation payload returned after unassigning a role. +type AdminOrganizationProjectUserRoleDeleteResponse struct { + // Whether the assignment was removed. + Deleted bool `json:"deleted" api:"required"` + // Identifier for the deleted assignment, such as `group.role.deleted` or + // `user.role.deleted`. + Object string `json:"object" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Deleted respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationProjectUserRoleDeleteResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationProjectUserRoleDeleteResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectUserRoleNewParams struct { + // Identifier of the role to assign. + RoleID string `json:"role_id" api:"required"` + paramObj +} + +func (r AdminOrganizationProjectUserRoleNewParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationProjectUserRoleNewParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationProjectUserRoleNewParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationProjectUserRoleListParams struct { + // Cursor for pagination. Provide the value from the previous response's `next` + // field to continue listing project roles. + After param.Opt[string] `query:"after,omitzero" json:"-"` + // A limit on the number of project role assignments to return. + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + // Sort order for the returned project roles. + // + // Any of "asc", "desc". + Order AdminOrganizationProjectUserRoleListParamsOrder `query:"order,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationProjectUserRoleListParams]'s query +// parameters as `url.Values`. +func (r AdminOrganizationProjectUserRoleListParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Sort order for the returned project roles. +type AdminOrganizationProjectUserRoleListParamsOrder string + +const ( + AdminOrganizationProjectUserRoleListParamsOrderAsc AdminOrganizationProjectUserRoleListParamsOrder = "asc" + AdminOrganizationProjectUserRoleListParamsOrderDesc AdminOrganizationProjectUserRoleListParamsOrder = "desc" +) diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationrole.go b/vendor/github.com/openai/openai-go/v3/adminorganizationrole.go new file mode 100644 index 000000000..87bb4d675 --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationrole.go @@ -0,0 +1,238 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "errors" + "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" +) + +// AdminOrganizationRoleService 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 [NewAdminOrganizationRoleService] method instead. +type AdminOrganizationRoleService struct { + Options []option.RequestOption +} + +// NewAdminOrganizationRoleService 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 NewAdminOrganizationRoleService(opts ...option.RequestOption) (r AdminOrganizationRoleService) { + r = AdminOrganizationRoleService{} + r.Options = opts + return +} + +// Creates a custom role for the organization. +func (r *AdminOrganizationRoleService) New(ctx context.Context, body AdminOrganizationRoleNewParams, opts ...option.RequestOption) (res *Role, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + path := "organization/roles" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Retrieves an organization role. +func (r *AdminOrganizationRoleService) Get(ctx context.Context, roleID string, opts ...option.RequestOption) (res *Role, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if roleID == "" { + err = errors.New("missing required role_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/roles/%s", roleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return res, err +} + +// Updates an existing organization role. +func (r *AdminOrganizationRoleService) Update(ctx context.Context, roleID string, body AdminOrganizationRoleUpdateParams, opts ...option.RequestOption) (res *Role, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if roleID == "" { + err = errors.New("missing required role_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/roles/%s", roleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Lists the roles configured for the organization. +func (r *AdminOrganizationRoleService) List(ctx context.Context, query AdminOrganizationRoleListParams, opts ...option.RequestOption) (res *pagination.NextCursorPage[Role], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := "organization/roles" + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Lists the roles configured for the organization. +func (r *AdminOrganizationRoleService) ListAutoPaging(ctx context.Context, query AdminOrganizationRoleListParams, opts ...option.RequestOption) *pagination.NextCursorPageAutoPager[Role] { + return pagination.NewNextCursorPageAutoPager(r.List(ctx, query, opts...)) +} + +// Deletes a custom role from the organization. +func (r *AdminOrganizationRoleService) Delete(ctx context.Context, roleID string, opts ...option.RequestOption) (res *AdminOrganizationRoleDeleteResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if roleID == "" { + err = errors.New("missing required role_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/roles/%s", roleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + return res, err +} + +// Details about a role that can be assigned through the public Roles API. +type Role struct { + // Identifier for the role. + ID string `json:"id" api:"required"` + // Optional description of the role. + Description string `json:"description" api:"required"` + // Unique name for the role. + Name string `json:"name" api:"required"` + // Always `role`. + Object constant.Role `json:"object" default:"role"` + // Permissions granted by the role. + Permissions []string `json:"permissions" api:"required"` + // Whether the role is predefined and managed by OpenAI. + PredefinedRole bool `json:"predefined_role" api:"required"` + // Resource type the role is bound to (for example `api.organization` or + // `api.project`). + ResourceType string `json:"resource_type" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Description respjson.Field + Name respjson.Field + Object respjson.Field + Permissions respjson.Field + PredefinedRole respjson.Field + ResourceType respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r Role) RawJSON() string { return r.JSON.raw } +func (r *Role) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Confirmation payload returned after deleting a role. +type AdminOrganizationRoleDeleteResponse struct { + // Identifier of the deleted role. + ID string `json:"id" api:"required"` + // Whether the role was deleted. + Deleted bool `json:"deleted" api:"required"` + // Always `role.deleted`. + Object constant.RoleDeleted `json:"object" default:"role.deleted"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Deleted respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationRoleDeleteResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationRoleDeleteResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationRoleNewParams struct { + // Permissions to grant to the role. + Permissions []string `json:"permissions,omitzero" api:"required"` + // Unique name for the role. + RoleName string `json:"role_name" api:"required"` + // Optional description of the role. + Description param.Opt[string] `json:"description,omitzero"` + paramObj +} + +func (r AdminOrganizationRoleNewParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationRoleNewParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationRoleNewParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationRoleUpdateParams struct { + // New description for the role. + Description param.Opt[string] `json:"description,omitzero"` + // New name for the role. + RoleName param.Opt[string] `json:"role_name,omitzero"` + // Updated set of permissions for the role. + Permissions []string `json:"permissions,omitzero"` + paramObj +} + +func (r AdminOrganizationRoleUpdateParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationRoleUpdateParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationRoleUpdateParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationRoleListParams struct { + // Cursor for pagination. Provide the value from the previous response's `next` + // field to continue listing roles. + After param.Opt[string] `query:"after,omitzero" json:"-"` + // A limit on the number of roles to return. Defaults to 1000. + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + // Sort order for the returned roles. + // + // Any of "asc", "desc". + Order AdminOrganizationRoleListParamsOrder `query:"order,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationRoleListParams]'s query parameters as +// `url.Values`. +func (r AdminOrganizationRoleListParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Sort order for the returned roles. +type AdminOrganizationRoleListParamsOrder string + +const ( + AdminOrganizationRoleListParamsOrderAsc AdminOrganizationRoleListParamsOrder = "asc" + AdminOrganizationRoleListParamsOrderDesc AdminOrganizationRoleListParamsOrder = "desc" +) diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationspendalert.go b/vendor/github.com/openai/openai-go/v3/adminorganizationspendalert.go new file mode 100644 index 000000000..bf6d478d5 --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationspendalert.go @@ -0,0 +1,365 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "errors" + "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" +) + +// AdminOrganizationSpendAlertService 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 [NewAdminOrganizationSpendAlertService] method instead. +type AdminOrganizationSpendAlertService struct { + Options []option.RequestOption +} + +// NewAdminOrganizationSpendAlertService 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 NewAdminOrganizationSpendAlertService(opts ...option.RequestOption) (r AdminOrganizationSpendAlertService) { + r = AdminOrganizationSpendAlertService{} + r.Options = opts + return +} + +// Creates an organization spend alert. +func (r *AdminOrganizationSpendAlertService) New(ctx context.Context, body AdminOrganizationSpendAlertNewParams, opts ...option.RequestOption) (res *OrganizationSpendAlert, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + path := "organization/spend_alerts" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Retrieves an organization spend alert. +func (r *AdminOrganizationSpendAlertService) Get(ctx context.Context, alertID string, opts ...option.RequestOption) (res *OrganizationSpendAlert, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if alertID == "" { + err = errors.New("missing required alert_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/spend_alerts/%s", alertID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return res, err +} + +// Updates an organization spend alert. +func (r *AdminOrganizationSpendAlertService) Update(ctx context.Context, alertID string, body AdminOrganizationSpendAlertUpdateParams, opts ...option.RequestOption) (res *OrganizationSpendAlert, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if alertID == "" { + err = errors.New("missing required alert_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/spend_alerts/%s", alertID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Lists organization spend alerts. +func (r *AdminOrganizationSpendAlertService) List(ctx context.Context, query AdminOrganizationSpendAlertListParams, opts ...option.RequestOption) (res *pagination.ConversationCursorPage[OrganizationSpendAlert], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := "organization/spend_alerts" + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Lists organization spend alerts. +func (r *AdminOrganizationSpendAlertService) ListAutoPaging(ctx context.Context, query AdminOrganizationSpendAlertListParams, opts ...option.RequestOption) *pagination.ConversationCursorPageAutoPager[OrganizationSpendAlert] { + return pagination.NewConversationCursorPageAutoPager(r.List(ctx, query, opts...)) +} + +// Deletes an organization spend alert. +func (r *AdminOrganizationSpendAlertService) Delete(ctx context.Context, alertID string, opts ...option.RequestOption) (res *OrganizationSpendAlertDeleted, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if alertID == "" { + err = errors.New("missing required alert_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/spend_alerts/%s", alertID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + return res, err +} + +// Represents a spend alert configured at the organization level. +type OrganizationSpendAlert struct { + // The identifier, which can be referenced in API endpoints. + ID string `json:"id" api:"required"` + // The currency for the threshold amount. + // + // Any of "USD". + Currency OrganizationSpendAlertCurrency `json:"currency" api:"required"` + // The time interval for evaluating spend against the threshold. + // + // Any of "month". + Interval OrganizationSpendAlertInterval `json:"interval" api:"required"` + // Email notification settings for a spend alert. + NotificationChannel OrganizationSpendAlertNotificationChannel `json:"notification_channel" api:"required"` + // The object type, which is always `organization.spend_alert`. + Object constant.OrganizationSpendAlert `json:"object" default:"organization.spend_alert"` + // The alert threshold amount, in cents. + ThresholdAmount int64 `json:"threshold_amount" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Currency respjson.Field + Interval respjson.Field + NotificationChannel respjson.Field + Object respjson.Field + ThresholdAmount respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r OrganizationSpendAlert) RawJSON() string { return r.JSON.raw } +func (r *OrganizationSpendAlert) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The currency for the threshold amount. +type OrganizationSpendAlertCurrency string + +const ( + OrganizationSpendAlertCurrencyUsd OrganizationSpendAlertCurrency = "USD" +) + +// The time interval for evaluating spend against the threshold. +type OrganizationSpendAlertInterval string + +const ( + OrganizationSpendAlertIntervalMonth OrganizationSpendAlertInterval = "month" +) + +// Email notification settings for a spend alert. +type OrganizationSpendAlertNotificationChannel struct { + // Email addresses that receive the spend alert notification. + Recipients []string `json:"recipients" api:"required"` + // The notification channel type. Currently only `email` is supported. + Type constant.Email `json:"type" default:"email"` + // Optional subject prefix for alert emails. + SubjectPrefix string `json:"subject_prefix" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Recipients respjson.Field + Type respjson.Field + SubjectPrefix respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r OrganizationSpendAlertNotificationChannel) RawJSON() string { return r.JSON.raw } +func (r *OrganizationSpendAlertNotificationChannel) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Confirmation payload returned after deleting an organization spend alert. +type OrganizationSpendAlertDeleted struct { + // The deleted spend alert ID. + ID string `json:"id" api:"required"` + // Whether the spend alert was deleted. + Deleted bool `json:"deleted" api:"required"` + // Always `organization.spend_alert.deleted`. + Object constant.OrganizationSpendAlertDeleted `json:"object" default:"organization.spend_alert.deleted"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Deleted respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r OrganizationSpendAlertDeleted) RawJSON() string { return r.JSON.raw } +func (r *OrganizationSpendAlertDeleted) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationSpendAlertNewParams struct { + // The currency for the threshold amount. + // + // Any of "USD". + Currency AdminOrganizationSpendAlertNewParamsCurrency `json:"currency,omitzero" api:"required"` + // The time interval for evaluating spend against the threshold. + // + // Any of "month". + Interval AdminOrganizationSpendAlertNewParamsInterval `json:"interval,omitzero" api:"required"` + // Email notification settings for a spend alert. + NotificationChannel AdminOrganizationSpendAlertNewParamsNotificationChannel `json:"notification_channel,omitzero" api:"required"` + // The alert threshold amount, in cents. + ThresholdAmount int64 `json:"threshold_amount" api:"required"` + paramObj +} + +func (r AdminOrganizationSpendAlertNewParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationSpendAlertNewParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationSpendAlertNewParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The currency for the threshold amount. +type AdminOrganizationSpendAlertNewParamsCurrency string + +const ( + AdminOrganizationSpendAlertNewParamsCurrencyUsd AdminOrganizationSpendAlertNewParamsCurrency = "USD" +) + +// The time interval for evaluating spend against the threshold. +type AdminOrganizationSpendAlertNewParamsInterval string + +const ( + AdminOrganizationSpendAlertNewParamsIntervalMonth AdminOrganizationSpendAlertNewParamsInterval = "month" +) + +// Email notification settings for a spend alert. +// +// The properties Recipients, Type are required. +type AdminOrganizationSpendAlertNewParamsNotificationChannel struct { + // Email addresses that receive the spend alert notification. + Recipients []string `json:"recipients,omitzero" api:"required"` + // Optional subject prefix for alert emails. + SubjectPrefix param.Opt[string] `json:"subject_prefix,omitzero"` + // The notification channel type. Currently only `email` is supported. + // + // This field can be elided, and will marshal its zero value as "email". + Type constant.Email `json:"type" default:"email"` + paramObj +} + +func (r AdminOrganizationSpendAlertNewParamsNotificationChannel) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationSpendAlertNewParamsNotificationChannel + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationSpendAlertNewParamsNotificationChannel) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationSpendAlertUpdateParams struct { + // The currency for the threshold amount. + // + // Any of "USD". + Currency AdminOrganizationSpendAlertUpdateParamsCurrency `json:"currency,omitzero" api:"required"` + // The time interval for evaluating spend against the threshold. + // + // Any of "month". + Interval AdminOrganizationSpendAlertUpdateParamsInterval `json:"interval,omitzero" api:"required"` + // Email notification settings for a spend alert. + NotificationChannel AdminOrganizationSpendAlertUpdateParamsNotificationChannel `json:"notification_channel,omitzero" api:"required"` + // The alert threshold amount, in cents. + ThresholdAmount int64 `json:"threshold_amount" api:"required"` + paramObj +} + +func (r AdminOrganizationSpendAlertUpdateParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationSpendAlertUpdateParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationSpendAlertUpdateParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The currency for the threshold amount. +type AdminOrganizationSpendAlertUpdateParamsCurrency string + +const ( + AdminOrganizationSpendAlertUpdateParamsCurrencyUsd AdminOrganizationSpendAlertUpdateParamsCurrency = "USD" +) + +// The time interval for evaluating spend against the threshold. +type AdminOrganizationSpendAlertUpdateParamsInterval string + +const ( + AdminOrganizationSpendAlertUpdateParamsIntervalMonth AdminOrganizationSpendAlertUpdateParamsInterval = "month" +) + +// Email notification settings for a spend alert. +// +// The properties Recipients, Type are required. +type AdminOrganizationSpendAlertUpdateParamsNotificationChannel struct { + // Email addresses that receive the spend alert notification. + Recipients []string `json:"recipients,omitzero" api:"required"` + // Optional subject prefix for alert emails. + SubjectPrefix param.Opt[string] `json:"subject_prefix,omitzero"` + // The notification channel type. Currently only `email` is supported. + // + // This field can be elided, and will marshal its zero value as "email". + Type constant.Email `json:"type" default:"email"` + paramObj +} + +func (r AdminOrganizationSpendAlertUpdateParamsNotificationChannel) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationSpendAlertUpdateParamsNotificationChannel + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationSpendAlertUpdateParamsNotificationChannel) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationSpendAlertListParams struct { + // Cursor for pagination. Provide the ID of the last spend alert from the previous + // response to fetch the next page. + After param.Opt[string] `query:"after,omitzero" json:"-"` + // Cursor for pagination. Provide the ID of the first spend alert from the previous + // response to fetch the previous page. + Before param.Opt[string] `query:"before,omitzero" json:"-"` + // A limit on the number of spend alerts to return. Defaults to 20. + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + // Sort order for the returned spend alerts. + // + // Any of "asc", "desc". + Order AdminOrganizationSpendAlertListParamsOrder `query:"order,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationSpendAlertListParams]'s query parameters +// as `url.Values`. +func (r AdminOrganizationSpendAlertListParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Sort order for the returned spend alerts. +type AdminOrganizationSpendAlertListParamsOrder string + +const ( + AdminOrganizationSpendAlertListParamsOrderAsc AdminOrganizationSpendAlertListParamsOrder = "asc" + AdminOrganizationSpendAlertListParamsOrderDesc AdminOrganizationSpendAlertListParamsOrder = "desc" +) diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationusage.go b/vendor/github.com/openai/openai-go/v3/adminorganizationusage.go new file mode 100644 index 000000000..db1368d28 --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationusage.go @@ -0,0 +1,9293 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "encoding/json" + "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/param" + "github.com/openai/openai-go/v3/packages/respjson" + "github.com/openai/openai-go/v3/shared/constant" +) + +// AdminOrganizationUsageService 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 [NewAdminOrganizationUsageService] method instead. +type AdminOrganizationUsageService struct { + Options []option.RequestOption +} + +// NewAdminOrganizationUsageService 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 NewAdminOrganizationUsageService(opts ...option.RequestOption) (r AdminOrganizationUsageService) { + r = AdminOrganizationUsageService{} + r.Options = opts + return +} + +// Get audio speeches usage details for the organization. +func (r *AdminOrganizationUsageService) AudioSpeeches(ctx context.Context, query AdminOrganizationUsageAudioSpeechesParams, opts ...option.RequestOption) (res *AdminOrganizationUsageAudioSpeechesResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + path := "organization/usage/audio_speeches" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return res, err +} + +// Get audio transcriptions usage details for the organization. +func (r *AdminOrganizationUsageService) AudioTranscriptions(ctx context.Context, query AdminOrganizationUsageAudioTranscriptionsParams, opts ...option.RequestOption) (res *AdminOrganizationUsageAudioTranscriptionsResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + path := "organization/usage/audio_transcriptions" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return res, err +} + +// Get code interpreter sessions usage details for the organization. +func (r *AdminOrganizationUsageService) CodeInterpreterSessions(ctx context.Context, query AdminOrganizationUsageCodeInterpreterSessionsParams, opts ...option.RequestOption) (res *AdminOrganizationUsageCodeInterpreterSessionsResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + path := "organization/usage/code_interpreter_sessions" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return res, err +} + +// Get completions usage details for the organization. +func (r *AdminOrganizationUsageService) Completions(ctx context.Context, query AdminOrganizationUsageCompletionsParams, opts ...option.RequestOption) (res *AdminOrganizationUsageCompletionsResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + path := "organization/usage/completions" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return res, err +} + +// Get costs details for the organization. +func (r *AdminOrganizationUsageService) Costs(ctx context.Context, query AdminOrganizationUsageCostsParams, opts ...option.RequestOption) (res *AdminOrganizationUsageCostsResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + path := "organization/costs" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return res, err +} + +// Get embeddings usage details for the organization. +func (r *AdminOrganizationUsageService) Embeddings(ctx context.Context, query AdminOrganizationUsageEmbeddingsParams, opts ...option.RequestOption) (res *AdminOrganizationUsageEmbeddingsResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + path := "organization/usage/embeddings" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return res, err +} + +// Get file search calls usage details for the organization. +func (r *AdminOrganizationUsageService) FileSearchCalls(ctx context.Context, query AdminOrganizationUsageFileSearchCallsParams, opts ...option.RequestOption) (res *AdminOrganizationUsageFileSearchCallsResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + path := "organization/usage/file_search_calls" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return res, err +} + +// Get images usage details for the organization. +func (r *AdminOrganizationUsageService) Images(ctx context.Context, query AdminOrganizationUsageImagesParams, opts ...option.RequestOption) (res *AdminOrganizationUsageImagesResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + path := "organization/usage/images" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return res, err +} + +// Get moderations usage details for the organization. +func (r *AdminOrganizationUsageService) Moderations(ctx context.Context, query AdminOrganizationUsageModerationsParams, opts ...option.RequestOption) (res *AdminOrganizationUsageModerationsResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + path := "organization/usage/moderations" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return res, err +} + +// Get vector stores usage details for the organization. +func (r *AdminOrganizationUsageService) VectorStores(ctx context.Context, query AdminOrganizationUsageVectorStoresParams, opts ...option.RequestOption) (res *AdminOrganizationUsageVectorStoresResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + path := "organization/usage/vector_stores" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return res, err +} + +// Get web search calls usage details for the organization. +func (r *AdminOrganizationUsageService) WebSearchCalls(ctx context.Context, query AdminOrganizationUsageWebSearchCallsParams, opts ...option.RequestOption) (res *AdminOrganizationUsageWebSearchCallsResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + path := "organization/usage/web_search_calls" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return res, err +} + +type AdminOrganizationUsageAudioSpeechesResponse struct { + Data []AdminOrganizationUsageAudioSpeechesResponseData `json:"data" api:"required"` + HasMore bool `json:"has_more" api:"required"` + NextPage string `json:"next_page" api:"required"` + Object constant.Page `json:"object" default:"page"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Data respjson.Field + HasMore respjson.Field + NextPage respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioSpeechesResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUsageAudioSpeechesResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUsageAudioSpeechesResponseData struct { + EndTime int64 `json:"end_time" api:"required"` + Object constant.Bucket `json:"object" default:"bucket"` + Results []AdminOrganizationUsageAudioSpeechesResponseDataResultUnion `json:"results" api:"required"` + StartTime int64 `json:"start_time" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + EndTime respjson.Field + Object respjson.Field + Results respjson.Field + StartTime respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioSpeechesResponseData) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUsageAudioSpeechesResponseData) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// AdminOrganizationUsageAudioSpeechesResponseDataResultUnion contains all possible +// properties and values from +// [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageCompletionsResult], +// [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageEmbeddingsResult], +// [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageModerationsResult], +// [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageImagesResult], +// [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageAudioSpeechesResult], +// [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageAudioTranscriptionsResult], +// [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageVectorStoresResult], +// [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageCodeInterpreterSessionsResult], +// [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageFileSearchesResult], +// [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageWebSearchesResult], +// [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationCostsResult]. +// +// Use the [AdminOrganizationUsageAudioSpeechesResponseDataResultUnion.AsAny] +// method to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type AdminOrganizationUsageAudioSpeechesResponseDataResultUnion struct { + InputTokens int64 `json:"input_tokens"` + NumModelRequests int64 `json:"num_model_requests"` + // Any of "organization.usage.completions.result", + // "organization.usage.embeddings.result", "organization.usage.moderations.result", + // "organization.usage.images.result", "organization.usage.audio_speeches.result", + // "organization.usage.audio_transcriptions.result", + // "organization.usage.vector_stores.result", + // "organization.usage.code_interpreter_sessions.result", + // "organization.usage.file_searches.result", + // "organization.usage.web_searches.result", "organization.costs.result". + Object string `json:"object"` + // This field is from variant + // [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageCompletionsResult]. + OutputTokens int64 `json:"output_tokens"` + APIKeyID string `json:"api_key_id"` + // This field is from variant + // [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageCompletionsResult]. + Batch bool `json:"batch"` + // This field is from variant + // [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageCompletionsResult]. + InputAudioTokens int64 `json:"input_audio_tokens"` + // This field is from variant + // [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageCompletionsResult]. + InputCachedTokens int64 `json:"input_cached_tokens"` + Model string `json:"model"` + // This field is from variant + // [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageCompletionsResult]. + OutputAudioTokens int64 `json:"output_audio_tokens"` + ProjectID string `json:"project_id"` + // This field is from variant + // [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageCompletionsResult]. + ServiceTier string `json:"service_tier"` + UserID string `json:"user_id"` + // This field is from variant + // [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageImagesResult]. + Images int64 `json:"images"` + // This field is from variant + // [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageImagesResult]. + Size string `json:"size"` + // This field is from variant + // [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageImagesResult]. + Source string `json:"source"` + // This field is from variant + // [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageAudioSpeechesResult]. + Characters int64 `json:"characters"` + // This field is from variant + // [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageAudioTranscriptionsResult]. + Seconds int64 `json:"seconds"` + // This field is from variant + // [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageVectorStoresResult]. + UsageBytes int64 `json:"usage_bytes"` + // This field is from variant + // [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageCodeInterpreterSessionsResult]. + NumSessions int64 `json:"num_sessions"` + NumRequests int64 `json:"num_requests"` + // This field is from variant + // [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageFileSearchesResult]. + VectorStoreID string `json:"vector_store_id"` + // This field is from variant + // [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageWebSearchesResult]. + ContextLevel string `json:"context_level"` + // This field is from variant + // [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationCostsResult]. + Amount AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationCostsResultAmount `json:"amount"` + // This field is from variant + // [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationCostsResult]. + LineItem string `json:"line_item"` + // This field is from variant + // [AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationCostsResult]. + Quantity float64 `json:"quantity"` + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + OutputTokens respjson.Field + APIKeyID respjson.Field + Batch respjson.Field + InputAudioTokens respjson.Field + InputCachedTokens respjson.Field + Model respjson.Field + OutputAudioTokens respjson.Field + ProjectID respjson.Field + ServiceTier respjson.Field + UserID respjson.Field + Images respjson.Field + Size respjson.Field + Source respjson.Field + Characters respjson.Field + Seconds respjson.Field + UsageBytes respjson.Field + NumSessions respjson.Field + NumRequests respjson.Field + VectorStoreID respjson.Field + ContextLevel respjson.Field + Amount respjson.Field + LineItem respjson.Field + Quantity respjson.Field + raw string + } `json:"-"` +} + +// anyAdminOrganizationUsageAudioSpeechesResponseDataResult is implemented by each +// variant of [AdminOrganizationUsageAudioSpeechesResponseDataResultUnion] to add +// type safety for the return type of +// [AdminOrganizationUsageAudioSpeechesResponseDataResultUnion.AsAny] +type anyAdminOrganizationUsageAudioSpeechesResponseDataResult interface { + implAdminOrganizationUsageAudioSpeechesResponseDataResultUnion() +} + +func (AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageCompletionsResult) implAdminOrganizationUsageAudioSpeechesResponseDataResultUnion() { +} +func (AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageEmbeddingsResult) implAdminOrganizationUsageAudioSpeechesResponseDataResultUnion() { +} +func (AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageModerationsResult) implAdminOrganizationUsageAudioSpeechesResponseDataResultUnion() { +} +func (AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageImagesResult) implAdminOrganizationUsageAudioSpeechesResponseDataResultUnion() { +} +func (AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageAudioSpeechesResult) implAdminOrganizationUsageAudioSpeechesResponseDataResultUnion() { +} +func (AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageAudioTranscriptionsResult) implAdminOrganizationUsageAudioSpeechesResponseDataResultUnion() { +} +func (AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageVectorStoresResult) implAdminOrganizationUsageAudioSpeechesResponseDataResultUnion() { +} +func (AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) implAdminOrganizationUsageAudioSpeechesResponseDataResultUnion() { +} +func (AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageFileSearchesResult) implAdminOrganizationUsageAudioSpeechesResponseDataResultUnion() { +} +func (AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageWebSearchesResult) implAdminOrganizationUsageAudioSpeechesResponseDataResultUnion() { +} +func (AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationCostsResult) implAdminOrganizationUsageAudioSpeechesResponseDataResultUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := AdminOrganizationUsageAudioSpeechesResponseDataResultUnion.AsAny().(type) { +// case openai.AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageCompletionsResult: +// case openai.AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageEmbeddingsResult: +// case openai.AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageModerationsResult: +// case openai.AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageImagesResult: +// case openai.AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageAudioSpeechesResult: +// case openai.AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageAudioTranscriptionsResult: +// case openai.AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageVectorStoresResult: +// case openai.AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageCodeInterpreterSessionsResult: +// case openai.AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageFileSearchesResult: +// case openai.AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageWebSearchesResult: +// case openai.AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationCostsResult: +// default: +// fmt.Errorf("no variant present") +// } +func (u AdminOrganizationUsageAudioSpeechesResponseDataResultUnion) AsAny() anyAdminOrganizationUsageAudioSpeechesResponseDataResult { + switch u.Object { + case "organization.usage.completions.result": + return u.AsOrganizationUsageCompletionsResult() + case "organization.usage.embeddings.result": + return u.AsOrganizationUsageEmbeddingsResult() + case "organization.usage.moderations.result": + return u.AsOrganizationUsageModerationsResult() + case "organization.usage.images.result": + return u.AsOrganizationUsageImagesResult() + case "organization.usage.audio_speeches.result": + return u.AsOrganizationUsageAudioSpeechesResult() + case "organization.usage.audio_transcriptions.result": + return u.AsOrganizationUsageAudioTranscriptionsResult() + case "organization.usage.vector_stores.result": + return u.AsOrganizationUsageVectorStoresResult() + case "organization.usage.code_interpreter_sessions.result": + return u.AsOrganizationUsageCodeInterpreterSessionsResult() + case "organization.usage.file_searches.result": + return u.AsOrganizationUsageFileSearchesResult() + case "organization.usage.web_searches.result": + return u.AsOrganizationUsageWebSearchesResult() + case "organization.costs.result": + return u.AsOrganizationCostsResult() + } + return nil +} + +func (u AdminOrganizationUsageAudioSpeechesResponseDataResultUnion) AsOrganizationUsageCompletionsResult() (v AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageCompletionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageAudioSpeechesResponseDataResultUnion) AsOrganizationUsageEmbeddingsResult() (v AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageEmbeddingsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageAudioSpeechesResponseDataResultUnion) AsOrganizationUsageModerationsResult() (v AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageModerationsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageAudioSpeechesResponseDataResultUnion) AsOrganizationUsageImagesResult() (v AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageImagesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageAudioSpeechesResponseDataResultUnion) AsOrganizationUsageAudioSpeechesResult() (v AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageAudioSpeechesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageAudioSpeechesResponseDataResultUnion) AsOrganizationUsageAudioTranscriptionsResult() (v AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageAudioTranscriptionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageAudioSpeechesResponseDataResultUnion) AsOrganizationUsageVectorStoresResult() (v AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageVectorStoresResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageAudioSpeechesResponseDataResultUnion) AsOrganizationUsageCodeInterpreterSessionsResult() (v AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageAudioSpeechesResponseDataResultUnion) AsOrganizationUsageFileSearchesResult() (v AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageFileSearchesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageAudioSpeechesResponseDataResultUnion) AsOrganizationUsageWebSearchesResult() (v AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageWebSearchesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageAudioSpeechesResponseDataResultUnion) AsOrganizationCostsResult() (v AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationCostsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u AdminOrganizationUsageAudioSpeechesResponseDataResultUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *AdminOrganizationUsageAudioSpeechesResponseDataResultUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated completions usage details of the specific time bucket. +type AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageCompletionsResult struct { + // The aggregated number of text input tokens used, including cached tokens. For + // customers subscribe to scale tier, this includes scale tier tokens. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageCompletionsResult `json:"object" default:"organization.usage.completions.result"` + // The aggregated number of text output tokens used. For customers subscribe to + // scale tier, this includes scale tier tokens. + OutputTokens int64 `json:"output_tokens" api:"required"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=batch`, this field tells whether the grouped usage result is + // batch or not. + Batch bool `json:"batch" api:"nullable"` + // The aggregated number of audio input tokens used, including cached tokens. + InputAudioTokens int64 `json:"input_audio_tokens"` + // The aggregated number of text input tokens that has been cached from previous + // requests. For customers subscribe to scale tier, this includes scale tier + // tokens. + InputCachedTokens int64 `json:"input_cached_tokens"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // The aggregated number of audio output tokens used. + OutputAudioTokens int64 `json:"output_audio_tokens"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=service_tier`, this field provides the service tier of the + // grouped usage result. + ServiceTier string `json:"service_tier" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + OutputTokens respjson.Field + APIKeyID respjson.Field + Batch respjson.Field + InputAudioTokens respjson.Field + InputCachedTokens respjson.Field + Model respjson.Field + OutputAudioTokens respjson.Field + ProjectID respjson.Field + ServiceTier respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageCompletionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageCompletionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated embeddings usage details of the specific time bucket. +type AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageEmbeddingsResult struct { + // The aggregated number of input tokens used. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageEmbeddingsResult `json:"object" default:"organization.usage.embeddings.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageEmbeddingsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageEmbeddingsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated moderations usage details of the specific time bucket. +type AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageModerationsResult struct { + // The aggregated number of input tokens used. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageModerationsResult `json:"object" default:"organization.usage.moderations.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageModerationsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageModerationsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated images usage details of the specific time bucket. +type AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageImagesResult struct { + // The number of images processed. + Images int64 `json:"images" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageImagesResult `json:"object" default:"organization.usage.images.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=size`, this field provides the image size of the grouped usage + // result. + Size string `json:"size" api:"nullable"` + // When `group_by=source`, this field provides the source of the grouped usage + // result, possible values are `image.generation`, `image.edit`, `image.variation`. + Source string `json:"source" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Images respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + Size respjson.Field + Source respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageImagesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageImagesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated audio speeches usage details of the specific time bucket. +type AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageAudioSpeechesResult struct { + // The number of characters processed. + Characters int64 `json:"characters" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageAudioSpeechesResult `json:"object" default:"organization.usage.audio_speeches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Characters respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageAudioSpeechesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageAudioSpeechesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated audio transcriptions usage details of the specific time bucket. +type AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageAudioTranscriptionsResult struct { + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageAudioTranscriptionsResult `json:"object" default:"organization.usage.audio_transcriptions.result"` + // The number of seconds processed. + Seconds int64 `json:"seconds" api:"required"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumModelRequests respjson.Field + Object respjson.Field + Seconds respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageAudioTranscriptionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageAudioTranscriptionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated vector stores usage details of the specific time bucket. +type AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageVectorStoresResult struct { + Object constant.OrganizationUsageVectorStoresResult `json:"object" default:"organization.usage.vector_stores.result"` + // The vector stores usage in bytes. + UsageBytes int64 `json:"usage_bytes" api:"required"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + UsageBytes respjson.Field + ProjectID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageVectorStoresResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageVectorStoresResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated code interpreter sessions usage details of the specific time +// bucket. +type AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageCodeInterpreterSessionsResult struct { + // The number of code interpreter sessions. + NumSessions int64 `json:"num_sessions" api:"required"` + Object constant.OrganizationUsageCodeInterpreterSessionsResult `json:"object" default:"organization.usage.code_interpreter_sessions.result"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumSessions respjson.Field + Object respjson.Field + ProjectID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated file search calls usage details of the specific time bucket. +type AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageFileSearchesResult struct { + // The count of file search calls. + NumRequests int64 `json:"num_requests" api:"required"` + Object constant.OrganizationUsageFileSearchesResult `json:"object" default:"organization.usage.file_searches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // When `group_by=vector_store_id`, this field provides the vector store ID of the + // grouped usage result. + VectorStoreID string `json:"vector_store_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + ProjectID respjson.Field + UserID respjson.Field + VectorStoreID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageFileSearchesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageFileSearchesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated web search calls usage details of the specific time bucket. +type AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageWebSearchesResult struct { + // The count of model requests. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + // The count of web search calls. + NumRequests int64 `json:"num_requests" api:"required"` + Object constant.OrganizationUsageWebSearchesResult `json:"object" default:"organization.usage.web_searches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=context_level`, this field provides the search context size of + // the grouped usage result. + ContextLevel string `json:"context_level" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumModelRequests respjson.Field + NumRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + ContextLevel respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageWebSearchesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageWebSearchesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated costs details of the specific time bucket. +type AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationCostsResult struct { + Object constant.OrganizationCostsResult `json:"object" default:"organization.costs.result"` + // The monetary value in its associated currency. + Amount AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationCostsResultAmount `json:"amount"` + // When `group_by=api_key_id`, this field provides the API Key ID of the grouped + // costs result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=line_item`, this field provides the line item of the grouped + // costs result. + LineItem string `json:"line_item" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // costs result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=line_item`, this field provides the quantity of the grouped costs + // result. + Quantity float64 `json:"quantity" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + Amount respjson.Field + APIKeyID respjson.Field + LineItem respjson.Field + ProjectID respjson.Field + Quantity respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationCostsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationCostsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The monetary value in its associated currency. +type AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationCostsResultAmount struct { + // Lowercase ISO-4217 currency e.g. "usd" + Currency string `json:"currency"` + // The numeric value of the cost. + Value float64 `json:"value"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Currency respjson.Field + Value respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationCostsResultAmount) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationCostsResultAmount) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUsageAudioTranscriptionsResponse struct { + Data []AdminOrganizationUsageAudioTranscriptionsResponseData `json:"data" api:"required"` + HasMore bool `json:"has_more" api:"required"` + NextPage string `json:"next_page" api:"required"` + Object constant.Page `json:"object" default:"page"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Data respjson.Field + HasMore respjson.Field + NextPage respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioTranscriptionsResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUsageAudioTranscriptionsResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUsageAudioTranscriptionsResponseData struct { + EndTime int64 `json:"end_time" api:"required"` + Object constant.Bucket `json:"object" default:"bucket"` + Results []AdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion `json:"results" api:"required"` + StartTime int64 `json:"start_time" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + EndTime respjson.Field + Object respjson.Field + Results respjson.Field + StartTime respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioTranscriptionsResponseData) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUsageAudioTranscriptionsResponseData) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// AdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion contains all +// possible properties and values from +// [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageCompletionsResult], +// [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageEmbeddingsResult], +// [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageModerationsResult], +// [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageImagesResult], +// [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageAudioSpeechesResult], +// [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageAudioTranscriptionsResult], +// [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageVectorStoresResult], +// [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult], +// [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageFileSearchesResult], +// [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageWebSearchesResult], +// [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationCostsResult]. +// +// Use the [AdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion.AsAny] +// method to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type AdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion struct { + InputTokens int64 `json:"input_tokens"` + NumModelRequests int64 `json:"num_model_requests"` + // Any of "organization.usage.completions.result", + // "organization.usage.embeddings.result", "organization.usage.moderations.result", + // "organization.usage.images.result", "organization.usage.audio_speeches.result", + // "organization.usage.audio_transcriptions.result", + // "organization.usage.vector_stores.result", + // "organization.usage.code_interpreter_sessions.result", + // "organization.usage.file_searches.result", + // "organization.usage.web_searches.result", "organization.costs.result". + Object string `json:"object"` + // This field is from variant + // [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageCompletionsResult]. + OutputTokens int64 `json:"output_tokens"` + APIKeyID string `json:"api_key_id"` + // This field is from variant + // [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageCompletionsResult]. + Batch bool `json:"batch"` + // This field is from variant + // [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageCompletionsResult]. + InputAudioTokens int64 `json:"input_audio_tokens"` + // This field is from variant + // [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageCompletionsResult]. + InputCachedTokens int64 `json:"input_cached_tokens"` + Model string `json:"model"` + // This field is from variant + // [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageCompletionsResult]. + OutputAudioTokens int64 `json:"output_audio_tokens"` + ProjectID string `json:"project_id"` + // This field is from variant + // [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageCompletionsResult]. + ServiceTier string `json:"service_tier"` + UserID string `json:"user_id"` + // This field is from variant + // [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageImagesResult]. + Images int64 `json:"images"` + // This field is from variant + // [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageImagesResult]. + Size string `json:"size"` + // This field is from variant + // [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageImagesResult]. + Source string `json:"source"` + // This field is from variant + // [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageAudioSpeechesResult]. + Characters int64 `json:"characters"` + // This field is from variant + // [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageAudioTranscriptionsResult]. + Seconds int64 `json:"seconds"` + // This field is from variant + // [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageVectorStoresResult]. + UsageBytes int64 `json:"usage_bytes"` + // This field is from variant + // [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult]. + NumSessions int64 `json:"num_sessions"` + NumRequests int64 `json:"num_requests"` + // This field is from variant + // [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageFileSearchesResult]. + VectorStoreID string `json:"vector_store_id"` + // This field is from variant + // [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageWebSearchesResult]. + ContextLevel string `json:"context_level"` + // This field is from variant + // [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationCostsResult]. + Amount AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationCostsResultAmount `json:"amount"` + // This field is from variant + // [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationCostsResult]. + LineItem string `json:"line_item"` + // This field is from variant + // [AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationCostsResult]. + Quantity float64 `json:"quantity"` + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + OutputTokens respjson.Field + APIKeyID respjson.Field + Batch respjson.Field + InputAudioTokens respjson.Field + InputCachedTokens respjson.Field + Model respjson.Field + OutputAudioTokens respjson.Field + ProjectID respjson.Field + ServiceTier respjson.Field + UserID respjson.Field + Images respjson.Field + Size respjson.Field + Source respjson.Field + Characters respjson.Field + Seconds respjson.Field + UsageBytes respjson.Field + NumSessions respjson.Field + NumRequests respjson.Field + VectorStoreID respjson.Field + ContextLevel respjson.Field + Amount respjson.Field + LineItem respjson.Field + Quantity respjson.Field + raw string + } `json:"-"` +} + +// anyAdminOrganizationUsageAudioTranscriptionsResponseDataResult is implemented by +// each variant of +// [AdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion] to add type +// safety for the return type of +// [AdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion.AsAny] +type anyAdminOrganizationUsageAudioTranscriptionsResponseDataResult interface { + implAdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion() +} + +func (AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageCompletionsResult) implAdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageEmbeddingsResult) implAdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageModerationsResult) implAdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageImagesResult) implAdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageAudioSpeechesResult) implAdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageAudioTranscriptionsResult) implAdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageVectorStoresResult) implAdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) implAdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageFileSearchesResult) implAdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageWebSearchesResult) implAdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationCostsResult) implAdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := AdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion.AsAny().(type) { +// case openai.AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageCompletionsResult: +// case openai.AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageEmbeddingsResult: +// case openai.AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageModerationsResult: +// case openai.AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageImagesResult: +// case openai.AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageAudioSpeechesResult: +// case openai.AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageAudioTranscriptionsResult: +// case openai.AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageVectorStoresResult: +// case openai.AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult: +// case openai.AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageFileSearchesResult: +// case openai.AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageWebSearchesResult: +// case openai.AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationCostsResult: +// default: +// fmt.Errorf("no variant present") +// } +func (u AdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion) AsAny() anyAdminOrganizationUsageAudioTranscriptionsResponseDataResult { + switch u.Object { + case "organization.usage.completions.result": + return u.AsOrganizationUsageCompletionsResult() + case "organization.usage.embeddings.result": + return u.AsOrganizationUsageEmbeddingsResult() + case "organization.usage.moderations.result": + return u.AsOrganizationUsageModerationsResult() + case "organization.usage.images.result": + return u.AsOrganizationUsageImagesResult() + case "organization.usage.audio_speeches.result": + return u.AsOrganizationUsageAudioSpeechesResult() + case "organization.usage.audio_transcriptions.result": + return u.AsOrganizationUsageAudioTranscriptionsResult() + case "organization.usage.vector_stores.result": + return u.AsOrganizationUsageVectorStoresResult() + case "organization.usage.code_interpreter_sessions.result": + return u.AsOrganizationUsageCodeInterpreterSessionsResult() + case "organization.usage.file_searches.result": + return u.AsOrganizationUsageFileSearchesResult() + case "organization.usage.web_searches.result": + return u.AsOrganizationUsageWebSearchesResult() + case "organization.costs.result": + return u.AsOrganizationCostsResult() + } + return nil +} + +func (u AdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion) AsOrganizationUsageCompletionsResult() (v AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageCompletionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion) AsOrganizationUsageEmbeddingsResult() (v AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageEmbeddingsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion) AsOrganizationUsageModerationsResult() (v AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageModerationsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion) AsOrganizationUsageImagesResult() (v AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageImagesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion) AsOrganizationUsageAudioSpeechesResult() (v AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageAudioSpeechesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion) AsOrganizationUsageAudioTranscriptionsResult() (v AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageAudioTranscriptionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion) AsOrganizationUsageVectorStoresResult() (v AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageVectorStoresResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion) AsOrganizationUsageCodeInterpreterSessionsResult() (v AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion) AsOrganizationUsageFileSearchesResult() (v AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageFileSearchesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion) AsOrganizationUsageWebSearchesResult() (v AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageWebSearchesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion) AsOrganizationCostsResult() (v AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationCostsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u AdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *AdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated completions usage details of the specific time bucket. +type AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageCompletionsResult struct { + // The aggregated number of text input tokens used, including cached tokens. For + // customers subscribe to scale tier, this includes scale tier tokens. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageCompletionsResult `json:"object" default:"organization.usage.completions.result"` + // The aggregated number of text output tokens used. For customers subscribe to + // scale tier, this includes scale tier tokens. + OutputTokens int64 `json:"output_tokens" api:"required"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=batch`, this field tells whether the grouped usage result is + // batch or not. + Batch bool `json:"batch" api:"nullable"` + // The aggregated number of audio input tokens used, including cached tokens. + InputAudioTokens int64 `json:"input_audio_tokens"` + // The aggregated number of text input tokens that has been cached from previous + // requests. For customers subscribe to scale tier, this includes scale tier + // tokens. + InputCachedTokens int64 `json:"input_cached_tokens"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // The aggregated number of audio output tokens used. + OutputAudioTokens int64 `json:"output_audio_tokens"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=service_tier`, this field provides the service tier of the + // grouped usage result. + ServiceTier string `json:"service_tier" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + OutputTokens respjson.Field + APIKeyID respjson.Field + Batch respjson.Field + InputAudioTokens respjson.Field + InputCachedTokens respjson.Field + Model respjson.Field + OutputAudioTokens respjson.Field + ProjectID respjson.Field + ServiceTier respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageCompletionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageCompletionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated embeddings usage details of the specific time bucket. +type AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageEmbeddingsResult struct { + // The aggregated number of input tokens used. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageEmbeddingsResult `json:"object" default:"organization.usage.embeddings.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageEmbeddingsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageEmbeddingsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated moderations usage details of the specific time bucket. +type AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageModerationsResult struct { + // The aggregated number of input tokens used. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageModerationsResult `json:"object" default:"organization.usage.moderations.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageModerationsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageModerationsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated images usage details of the specific time bucket. +type AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageImagesResult struct { + // The number of images processed. + Images int64 `json:"images" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageImagesResult `json:"object" default:"organization.usage.images.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=size`, this field provides the image size of the grouped usage + // result. + Size string `json:"size" api:"nullable"` + // When `group_by=source`, this field provides the source of the grouped usage + // result, possible values are `image.generation`, `image.edit`, `image.variation`. + Source string `json:"source" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Images respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + Size respjson.Field + Source respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageImagesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageImagesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated audio speeches usage details of the specific time bucket. +type AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageAudioSpeechesResult struct { + // The number of characters processed. + Characters int64 `json:"characters" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageAudioSpeechesResult `json:"object" default:"organization.usage.audio_speeches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Characters respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageAudioSpeechesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageAudioSpeechesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated audio transcriptions usage details of the specific time bucket. +type AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageAudioTranscriptionsResult struct { + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageAudioTranscriptionsResult `json:"object" default:"organization.usage.audio_transcriptions.result"` + // The number of seconds processed. + Seconds int64 `json:"seconds" api:"required"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumModelRequests respjson.Field + Object respjson.Field + Seconds respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageAudioTranscriptionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageAudioTranscriptionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated vector stores usage details of the specific time bucket. +type AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageVectorStoresResult struct { + Object constant.OrganizationUsageVectorStoresResult `json:"object" default:"organization.usage.vector_stores.result"` + // The vector stores usage in bytes. + UsageBytes int64 `json:"usage_bytes" api:"required"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + UsageBytes respjson.Field + ProjectID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageVectorStoresResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageVectorStoresResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated code interpreter sessions usage details of the specific time +// bucket. +type AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult struct { + // The number of code interpreter sessions. + NumSessions int64 `json:"num_sessions" api:"required"` + Object constant.OrganizationUsageCodeInterpreterSessionsResult `json:"object" default:"organization.usage.code_interpreter_sessions.result"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumSessions respjson.Field + Object respjson.Field + ProjectID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated file search calls usage details of the specific time bucket. +type AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageFileSearchesResult struct { + // The count of file search calls. + NumRequests int64 `json:"num_requests" api:"required"` + Object constant.OrganizationUsageFileSearchesResult `json:"object" default:"organization.usage.file_searches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // When `group_by=vector_store_id`, this field provides the vector store ID of the + // grouped usage result. + VectorStoreID string `json:"vector_store_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + ProjectID respjson.Field + UserID respjson.Field + VectorStoreID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageFileSearchesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageFileSearchesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated web search calls usage details of the specific time bucket. +type AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageWebSearchesResult struct { + // The count of model requests. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + // The count of web search calls. + NumRequests int64 `json:"num_requests" api:"required"` + Object constant.OrganizationUsageWebSearchesResult `json:"object" default:"organization.usage.web_searches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=context_level`, this field provides the search context size of + // the grouped usage result. + ContextLevel string `json:"context_level" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumModelRequests respjson.Field + NumRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + ContextLevel respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageWebSearchesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageWebSearchesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated costs details of the specific time bucket. +type AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationCostsResult struct { + Object constant.OrganizationCostsResult `json:"object" default:"organization.costs.result"` + // The monetary value in its associated currency. + Amount AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationCostsResultAmount `json:"amount"` + // When `group_by=api_key_id`, this field provides the API Key ID of the grouped + // costs result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=line_item`, this field provides the line item of the grouped + // costs result. + LineItem string `json:"line_item" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // costs result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=line_item`, this field provides the quantity of the grouped costs + // result. + Quantity float64 `json:"quantity" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + Amount respjson.Field + APIKeyID respjson.Field + LineItem respjson.Field + ProjectID respjson.Field + Quantity respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationCostsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationCostsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The monetary value in its associated currency. +type AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationCostsResultAmount struct { + // Lowercase ISO-4217 currency e.g. "usd" + Currency string `json:"currency"` + // The numeric value of the cost. + Value float64 `json:"value"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Currency respjson.Field + Value respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationCostsResultAmount) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationCostsResultAmount) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUsageCodeInterpreterSessionsResponse struct { + Data []AdminOrganizationUsageCodeInterpreterSessionsResponseData `json:"data" api:"required"` + HasMore bool `json:"has_more" api:"required"` + NextPage string `json:"next_page" api:"required"` + Object constant.Page `json:"object" default:"page"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Data respjson.Field + HasMore respjson.Field + NextPage respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCodeInterpreterSessionsResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUsageCodeInterpreterSessionsResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUsageCodeInterpreterSessionsResponseData struct { + EndTime int64 `json:"end_time" api:"required"` + Object constant.Bucket `json:"object" default:"bucket"` + Results []AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion `json:"results" api:"required"` + StartTime int64 `json:"start_time" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + EndTime respjson.Field + Object respjson.Field + Results respjson.Field + StartTime respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCodeInterpreterSessionsResponseData) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCodeInterpreterSessionsResponseData) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion contains +// all possible properties and values from +// [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageCompletionsResult], +// [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageEmbeddingsResult], +// [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageModerationsResult], +// [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageImagesResult], +// [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageAudioSpeechesResult], +// [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageAudioTranscriptionsResult], +// [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageVectorStoresResult], +// [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult], +// [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageFileSearchesResult], +// [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageWebSearchesResult], +// [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationCostsResult]. +// +// Use the +// [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion.AsAny] +// method to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion struct { + InputTokens int64 `json:"input_tokens"` + NumModelRequests int64 `json:"num_model_requests"` + // Any of "organization.usage.completions.result", + // "organization.usage.embeddings.result", "organization.usage.moderations.result", + // "organization.usage.images.result", "organization.usage.audio_speeches.result", + // "organization.usage.audio_transcriptions.result", + // "organization.usage.vector_stores.result", + // "organization.usage.code_interpreter_sessions.result", + // "organization.usage.file_searches.result", + // "organization.usage.web_searches.result", "organization.costs.result". + Object string `json:"object"` + // This field is from variant + // [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageCompletionsResult]. + OutputTokens int64 `json:"output_tokens"` + APIKeyID string `json:"api_key_id"` + // This field is from variant + // [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageCompletionsResult]. + Batch bool `json:"batch"` + // This field is from variant + // [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageCompletionsResult]. + InputAudioTokens int64 `json:"input_audio_tokens"` + // This field is from variant + // [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageCompletionsResult]. + InputCachedTokens int64 `json:"input_cached_tokens"` + Model string `json:"model"` + // This field is from variant + // [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageCompletionsResult]. + OutputAudioTokens int64 `json:"output_audio_tokens"` + ProjectID string `json:"project_id"` + // This field is from variant + // [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageCompletionsResult]. + ServiceTier string `json:"service_tier"` + UserID string `json:"user_id"` + // This field is from variant + // [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageImagesResult]. + Images int64 `json:"images"` + // This field is from variant + // [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageImagesResult]. + Size string `json:"size"` + // This field is from variant + // [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageImagesResult]. + Source string `json:"source"` + // This field is from variant + // [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageAudioSpeechesResult]. + Characters int64 `json:"characters"` + // This field is from variant + // [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageAudioTranscriptionsResult]. + Seconds int64 `json:"seconds"` + // This field is from variant + // [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageVectorStoresResult]. + UsageBytes int64 `json:"usage_bytes"` + // This field is from variant + // [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult]. + NumSessions int64 `json:"num_sessions"` + NumRequests int64 `json:"num_requests"` + // This field is from variant + // [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageFileSearchesResult]. + VectorStoreID string `json:"vector_store_id"` + // This field is from variant + // [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageWebSearchesResult]. + ContextLevel string `json:"context_level"` + // This field is from variant + // [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationCostsResult]. + Amount AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationCostsResultAmount `json:"amount"` + // This field is from variant + // [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationCostsResult]. + LineItem string `json:"line_item"` + // This field is from variant + // [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationCostsResult]. + Quantity float64 `json:"quantity"` + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + OutputTokens respjson.Field + APIKeyID respjson.Field + Batch respjson.Field + InputAudioTokens respjson.Field + InputCachedTokens respjson.Field + Model respjson.Field + OutputAudioTokens respjson.Field + ProjectID respjson.Field + ServiceTier respjson.Field + UserID respjson.Field + Images respjson.Field + Size respjson.Field + Source respjson.Field + Characters respjson.Field + Seconds respjson.Field + UsageBytes respjson.Field + NumSessions respjson.Field + NumRequests respjson.Field + VectorStoreID respjson.Field + ContextLevel respjson.Field + Amount respjson.Field + LineItem respjson.Field + Quantity respjson.Field + raw string + } `json:"-"` +} + +// anyAdminOrganizationUsageCodeInterpreterSessionsResponseDataResult is +// implemented by each variant of +// [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion] to add +// type safety for the return type of +// [AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion.AsAny] +type anyAdminOrganizationUsageCodeInterpreterSessionsResponseDataResult interface { + implAdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion() +} + +func (AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageCompletionsResult) implAdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageEmbeddingsResult) implAdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageModerationsResult) implAdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageImagesResult) implAdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageAudioSpeechesResult) implAdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageAudioTranscriptionsResult) implAdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageVectorStoresResult) implAdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) implAdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageFileSearchesResult) implAdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageWebSearchesResult) implAdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationCostsResult) implAdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion.AsAny().(type) { +// case openai.AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageCompletionsResult: +// case openai.AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageEmbeddingsResult: +// case openai.AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageModerationsResult: +// case openai.AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageImagesResult: +// case openai.AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageAudioSpeechesResult: +// case openai.AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageAudioTranscriptionsResult: +// case openai.AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageVectorStoresResult: +// case openai.AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult: +// case openai.AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageFileSearchesResult: +// case openai.AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageWebSearchesResult: +// case openai.AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationCostsResult: +// default: +// fmt.Errorf("no variant present") +// } +func (u AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion) AsAny() anyAdminOrganizationUsageCodeInterpreterSessionsResponseDataResult { + switch u.Object { + case "organization.usage.completions.result": + return u.AsOrganizationUsageCompletionsResult() + case "organization.usage.embeddings.result": + return u.AsOrganizationUsageEmbeddingsResult() + case "organization.usage.moderations.result": + return u.AsOrganizationUsageModerationsResult() + case "organization.usage.images.result": + return u.AsOrganizationUsageImagesResult() + case "organization.usage.audio_speeches.result": + return u.AsOrganizationUsageAudioSpeechesResult() + case "organization.usage.audio_transcriptions.result": + return u.AsOrganizationUsageAudioTranscriptionsResult() + case "organization.usage.vector_stores.result": + return u.AsOrganizationUsageVectorStoresResult() + case "organization.usage.code_interpreter_sessions.result": + return u.AsOrganizationUsageCodeInterpreterSessionsResult() + case "organization.usage.file_searches.result": + return u.AsOrganizationUsageFileSearchesResult() + case "organization.usage.web_searches.result": + return u.AsOrganizationUsageWebSearchesResult() + case "organization.costs.result": + return u.AsOrganizationCostsResult() + } + return nil +} + +func (u AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion) AsOrganizationUsageCompletionsResult() (v AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageCompletionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion) AsOrganizationUsageEmbeddingsResult() (v AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageEmbeddingsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion) AsOrganizationUsageModerationsResult() (v AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageModerationsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion) AsOrganizationUsageImagesResult() (v AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageImagesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion) AsOrganizationUsageAudioSpeechesResult() (v AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageAudioSpeechesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion) AsOrganizationUsageAudioTranscriptionsResult() (v AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageAudioTranscriptionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion) AsOrganizationUsageVectorStoresResult() (v AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageVectorStoresResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion) AsOrganizationUsageCodeInterpreterSessionsResult() (v AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion) AsOrganizationUsageFileSearchesResult() (v AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageFileSearchesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion) AsOrganizationUsageWebSearchesResult() (v AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageWebSearchesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion) AsOrganizationCostsResult() (v AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationCostsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated completions usage details of the specific time bucket. +type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageCompletionsResult struct { + // The aggregated number of text input tokens used, including cached tokens. For + // customers subscribe to scale tier, this includes scale tier tokens. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageCompletionsResult `json:"object" default:"organization.usage.completions.result"` + // The aggregated number of text output tokens used. For customers subscribe to + // scale tier, this includes scale tier tokens. + OutputTokens int64 `json:"output_tokens" api:"required"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=batch`, this field tells whether the grouped usage result is + // batch or not. + Batch bool `json:"batch" api:"nullable"` + // The aggregated number of audio input tokens used, including cached tokens. + InputAudioTokens int64 `json:"input_audio_tokens"` + // The aggregated number of text input tokens that has been cached from previous + // requests. For customers subscribe to scale tier, this includes scale tier + // tokens. + InputCachedTokens int64 `json:"input_cached_tokens"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // The aggregated number of audio output tokens used. + OutputAudioTokens int64 `json:"output_audio_tokens"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=service_tier`, this field provides the service tier of the + // grouped usage result. + ServiceTier string `json:"service_tier" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + OutputTokens respjson.Field + APIKeyID respjson.Field + Batch respjson.Field + InputAudioTokens respjson.Field + InputCachedTokens respjson.Field + Model respjson.Field + OutputAudioTokens respjson.Field + ProjectID respjson.Field + ServiceTier respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageCompletionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageCompletionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated embeddings usage details of the specific time bucket. +type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageEmbeddingsResult struct { + // The aggregated number of input tokens used. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageEmbeddingsResult `json:"object" default:"organization.usage.embeddings.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageEmbeddingsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageEmbeddingsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated moderations usage details of the specific time bucket. +type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageModerationsResult struct { + // The aggregated number of input tokens used. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageModerationsResult `json:"object" default:"organization.usage.moderations.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageModerationsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageModerationsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated images usage details of the specific time bucket. +type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageImagesResult struct { + // The number of images processed. + Images int64 `json:"images" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageImagesResult `json:"object" default:"organization.usage.images.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=size`, this field provides the image size of the grouped usage + // result. + Size string `json:"size" api:"nullable"` + // When `group_by=source`, this field provides the source of the grouped usage + // result, possible values are `image.generation`, `image.edit`, `image.variation`. + Source string `json:"source" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Images respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + Size respjson.Field + Source respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageImagesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageImagesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated audio speeches usage details of the specific time bucket. +type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageAudioSpeechesResult struct { + // The number of characters processed. + Characters int64 `json:"characters" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageAudioSpeechesResult `json:"object" default:"organization.usage.audio_speeches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Characters respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageAudioSpeechesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageAudioSpeechesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated audio transcriptions usage details of the specific time bucket. +type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageAudioTranscriptionsResult struct { + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageAudioTranscriptionsResult `json:"object" default:"organization.usage.audio_transcriptions.result"` + // The number of seconds processed. + Seconds int64 `json:"seconds" api:"required"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumModelRequests respjson.Field + Object respjson.Field + Seconds respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageAudioTranscriptionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageAudioTranscriptionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated vector stores usage details of the specific time bucket. +type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageVectorStoresResult struct { + Object constant.OrganizationUsageVectorStoresResult `json:"object" default:"organization.usage.vector_stores.result"` + // The vector stores usage in bytes. + UsageBytes int64 `json:"usage_bytes" api:"required"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + UsageBytes respjson.Field + ProjectID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageVectorStoresResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageVectorStoresResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated code interpreter sessions usage details of the specific time +// bucket. +type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult struct { + // The number of code interpreter sessions. + NumSessions int64 `json:"num_sessions" api:"required"` + Object constant.OrganizationUsageCodeInterpreterSessionsResult `json:"object" default:"organization.usage.code_interpreter_sessions.result"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumSessions respjson.Field + Object respjson.Field + ProjectID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated file search calls usage details of the specific time bucket. +type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageFileSearchesResult struct { + // The count of file search calls. + NumRequests int64 `json:"num_requests" api:"required"` + Object constant.OrganizationUsageFileSearchesResult `json:"object" default:"organization.usage.file_searches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // When `group_by=vector_store_id`, this field provides the vector store ID of the + // grouped usage result. + VectorStoreID string `json:"vector_store_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + ProjectID respjson.Field + UserID respjson.Field + VectorStoreID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageFileSearchesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageFileSearchesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated web search calls usage details of the specific time bucket. +type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageWebSearchesResult struct { + // The count of model requests. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + // The count of web search calls. + NumRequests int64 `json:"num_requests" api:"required"` + Object constant.OrganizationUsageWebSearchesResult `json:"object" default:"organization.usage.web_searches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=context_level`, this field provides the search context size of + // the grouped usage result. + ContextLevel string `json:"context_level" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumModelRequests respjson.Field + NumRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + ContextLevel respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageWebSearchesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageWebSearchesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated costs details of the specific time bucket. +type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationCostsResult struct { + Object constant.OrganizationCostsResult `json:"object" default:"organization.costs.result"` + // The monetary value in its associated currency. + Amount AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationCostsResultAmount `json:"amount"` + // When `group_by=api_key_id`, this field provides the API Key ID of the grouped + // costs result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=line_item`, this field provides the line item of the grouped + // costs result. + LineItem string `json:"line_item" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // costs result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=line_item`, this field provides the quantity of the grouped costs + // result. + Quantity float64 `json:"quantity" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + Amount respjson.Field + APIKeyID respjson.Field + LineItem respjson.Field + ProjectID respjson.Field + Quantity respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationCostsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationCostsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The monetary value in its associated currency. +type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationCostsResultAmount struct { + // Lowercase ISO-4217 currency e.g. "usd" + Currency string `json:"currency"` + // The numeric value of the cost. + Value float64 `json:"value"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Currency respjson.Field + Value respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationCostsResultAmount) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationCostsResultAmount) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUsageCompletionsResponse struct { + Data []AdminOrganizationUsageCompletionsResponseData `json:"data" api:"required"` + HasMore bool `json:"has_more" api:"required"` + NextPage string `json:"next_page" api:"required"` + Object constant.Page `json:"object" default:"page"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Data respjson.Field + HasMore respjson.Field + NextPage respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCompletionsResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUsageCompletionsResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUsageCompletionsResponseData struct { + EndTime int64 `json:"end_time" api:"required"` + Object constant.Bucket `json:"object" default:"bucket"` + Results []AdminOrganizationUsageCompletionsResponseDataResultUnion `json:"results" api:"required"` + StartTime int64 `json:"start_time" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + EndTime respjson.Field + Object respjson.Field + Results respjson.Field + StartTime respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCompletionsResponseData) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUsageCompletionsResponseData) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// AdminOrganizationUsageCompletionsResponseDataResultUnion contains all possible +// properties and values from +// [AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageCompletionsResult], +// [AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageEmbeddingsResult], +// [AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageModerationsResult], +// [AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageImagesResult], +// [AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageAudioSpeechesResult], +// [AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageAudioTranscriptionsResult], +// [AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageVectorStoresResult], +// [AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult], +// [AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageFileSearchesResult], +// [AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageWebSearchesResult], +// [AdminOrganizationUsageCompletionsResponseDataResultOrganizationCostsResult]. +// +// Use the [AdminOrganizationUsageCompletionsResponseDataResultUnion.AsAny] method +// to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type AdminOrganizationUsageCompletionsResponseDataResultUnion struct { + InputTokens int64 `json:"input_tokens"` + NumModelRequests int64 `json:"num_model_requests"` + // Any of "organization.usage.completions.result", + // "organization.usage.embeddings.result", "organization.usage.moderations.result", + // "organization.usage.images.result", "organization.usage.audio_speeches.result", + // "organization.usage.audio_transcriptions.result", + // "organization.usage.vector_stores.result", + // "organization.usage.code_interpreter_sessions.result", + // "organization.usage.file_searches.result", + // "organization.usage.web_searches.result", "organization.costs.result". + Object string `json:"object"` + // This field is from variant + // [AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageCompletionsResult]. + OutputTokens int64 `json:"output_tokens"` + APIKeyID string `json:"api_key_id"` + // This field is from variant + // [AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageCompletionsResult]. + Batch bool `json:"batch"` + // This field is from variant + // [AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageCompletionsResult]. + InputAudioTokens int64 `json:"input_audio_tokens"` + // This field is from variant + // [AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageCompletionsResult]. + InputCachedTokens int64 `json:"input_cached_tokens"` + Model string `json:"model"` + // This field is from variant + // [AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageCompletionsResult]. + OutputAudioTokens int64 `json:"output_audio_tokens"` + ProjectID string `json:"project_id"` + // This field is from variant + // [AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageCompletionsResult]. + ServiceTier string `json:"service_tier"` + UserID string `json:"user_id"` + // This field is from variant + // [AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageImagesResult]. + Images int64 `json:"images"` + // This field is from variant + // [AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageImagesResult]. + Size string `json:"size"` + // This field is from variant + // [AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageImagesResult]. + Source string `json:"source"` + // This field is from variant + // [AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageAudioSpeechesResult]. + Characters int64 `json:"characters"` + // This field is from variant + // [AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageAudioTranscriptionsResult]. + Seconds int64 `json:"seconds"` + // This field is from variant + // [AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageVectorStoresResult]. + UsageBytes int64 `json:"usage_bytes"` + // This field is from variant + // [AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult]. + NumSessions int64 `json:"num_sessions"` + NumRequests int64 `json:"num_requests"` + // This field is from variant + // [AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageFileSearchesResult]. + VectorStoreID string `json:"vector_store_id"` + // This field is from variant + // [AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageWebSearchesResult]. + ContextLevel string `json:"context_level"` + // This field is from variant + // [AdminOrganizationUsageCompletionsResponseDataResultOrganizationCostsResult]. + Amount AdminOrganizationUsageCompletionsResponseDataResultOrganizationCostsResultAmount `json:"amount"` + // This field is from variant + // [AdminOrganizationUsageCompletionsResponseDataResultOrganizationCostsResult]. + LineItem string `json:"line_item"` + // This field is from variant + // [AdminOrganizationUsageCompletionsResponseDataResultOrganizationCostsResult]. + Quantity float64 `json:"quantity"` + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + OutputTokens respjson.Field + APIKeyID respjson.Field + Batch respjson.Field + InputAudioTokens respjson.Field + InputCachedTokens respjson.Field + Model respjson.Field + OutputAudioTokens respjson.Field + ProjectID respjson.Field + ServiceTier respjson.Field + UserID respjson.Field + Images respjson.Field + Size respjson.Field + Source respjson.Field + Characters respjson.Field + Seconds respjson.Field + UsageBytes respjson.Field + NumSessions respjson.Field + NumRequests respjson.Field + VectorStoreID respjson.Field + ContextLevel respjson.Field + Amount respjson.Field + LineItem respjson.Field + Quantity respjson.Field + raw string + } `json:"-"` +} + +// anyAdminOrganizationUsageCompletionsResponseDataResult is implemented by each +// variant of [AdminOrganizationUsageCompletionsResponseDataResultUnion] to add +// type safety for the return type of +// [AdminOrganizationUsageCompletionsResponseDataResultUnion.AsAny] +type anyAdminOrganizationUsageCompletionsResponseDataResult interface { + implAdminOrganizationUsageCompletionsResponseDataResultUnion() +} + +func (AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageCompletionsResult) implAdminOrganizationUsageCompletionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageEmbeddingsResult) implAdminOrganizationUsageCompletionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageModerationsResult) implAdminOrganizationUsageCompletionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageImagesResult) implAdminOrganizationUsageCompletionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageAudioSpeechesResult) implAdminOrganizationUsageCompletionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageAudioTranscriptionsResult) implAdminOrganizationUsageCompletionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageVectorStoresResult) implAdminOrganizationUsageCompletionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) implAdminOrganizationUsageCompletionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageFileSearchesResult) implAdminOrganizationUsageCompletionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageWebSearchesResult) implAdminOrganizationUsageCompletionsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCompletionsResponseDataResultOrganizationCostsResult) implAdminOrganizationUsageCompletionsResponseDataResultUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := AdminOrganizationUsageCompletionsResponseDataResultUnion.AsAny().(type) { +// case openai.AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageCompletionsResult: +// case openai.AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageEmbeddingsResult: +// case openai.AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageModerationsResult: +// case openai.AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageImagesResult: +// case openai.AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageAudioSpeechesResult: +// case openai.AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageAudioTranscriptionsResult: +// case openai.AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageVectorStoresResult: +// case openai.AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult: +// case openai.AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageFileSearchesResult: +// case openai.AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageWebSearchesResult: +// case openai.AdminOrganizationUsageCompletionsResponseDataResultOrganizationCostsResult: +// default: +// fmt.Errorf("no variant present") +// } +func (u AdminOrganizationUsageCompletionsResponseDataResultUnion) AsAny() anyAdminOrganizationUsageCompletionsResponseDataResult { + switch u.Object { + case "organization.usage.completions.result": + return u.AsOrganizationUsageCompletionsResult() + case "organization.usage.embeddings.result": + return u.AsOrganizationUsageEmbeddingsResult() + case "organization.usage.moderations.result": + return u.AsOrganizationUsageModerationsResult() + case "organization.usage.images.result": + return u.AsOrganizationUsageImagesResult() + case "organization.usage.audio_speeches.result": + return u.AsOrganizationUsageAudioSpeechesResult() + case "organization.usage.audio_transcriptions.result": + return u.AsOrganizationUsageAudioTranscriptionsResult() + case "organization.usage.vector_stores.result": + return u.AsOrganizationUsageVectorStoresResult() + case "organization.usage.code_interpreter_sessions.result": + return u.AsOrganizationUsageCodeInterpreterSessionsResult() + case "organization.usage.file_searches.result": + return u.AsOrganizationUsageFileSearchesResult() + case "organization.usage.web_searches.result": + return u.AsOrganizationUsageWebSearchesResult() + case "organization.costs.result": + return u.AsOrganizationCostsResult() + } + return nil +} + +func (u AdminOrganizationUsageCompletionsResponseDataResultUnion) AsOrganizationUsageCompletionsResult() (v AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageCompletionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCompletionsResponseDataResultUnion) AsOrganizationUsageEmbeddingsResult() (v AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageEmbeddingsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCompletionsResponseDataResultUnion) AsOrganizationUsageModerationsResult() (v AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageModerationsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCompletionsResponseDataResultUnion) AsOrganizationUsageImagesResult() (v AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageImagesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCompletionsResponseDataResultUnion) AsOrganizationUsageAudioSpeechesResult() (v AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageAudioSpeechesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCompletionsResponseDataResultUnion) AsOrganizationUsageAudioTranscriptionsResult() (v AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageAudioTranscriptionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCompletionsResponseDataResultUnion) AsOrganizationUsageVectorStoresResult() (v AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageVectorStoresResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCompletionsResponseDataResultUnion) AsOrganizationUsageCodeInterpreterSessionsResult() (v AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCompletionsResponseDataResultUnion) AsOrganizationUsageFileSearchesResult() (v AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageFileSearchesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCompletionsResponseDataResultUnion) AsOrganizationUsageWebSearchesResult() (v AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageWebSearchesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCompletionsResponseDataResultUnion) AsOrganizationCostsResult() (v AdminOrganizationUsageCompletionsResponseDataResultOrganizationCostsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u AdminOrganizationUsageCompletionsResponseDataResultUnion) RawJSON() string { return u.JSON.raw } + +func (r *AdminOrganizationUsageCompletionsResponseDataResultUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated completions usage details of the specific time bucket. +type AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageCompletionsResult struct { + // The aggregated number of text input tokens used, including cached tokens. For + // customers subscribe to scale tier, this includes scale tier tokens. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageCompletionsResult `json:"object" default:"organization.usage.completions.result"` + // The aggregated number of text output tokens used. For customers subscribe to + // scale tier, this includes scale tier tokens. + OutputTokens int64 `json:"output_tokens" api:"required"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=batch`, this field tells whether the grouped usage result is + // batch or not. + Batch bool `json:"batch" api:"nullable"` + // The aggregated number of audio input tokens used, including cached tokens. + InputAudioTokens int64 `json:"input_audio_tokens"` + // The aggregated number of text input tokens that has been cached from previous + // requests. For customers subscribe to scale tier, this includes scale tier + // tokens. + InputCachedTokens int64 `json:"input_cached_tokens"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // The aggregated number of audio output tokens used. + OutputAudioTokens int64 `json:"output_audio_tokens"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=service_tier`, this field provides the service tier of the + // grouped usage result. + ServiceTier string `json:"service_tier" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + OutputTokens respjson.Field + APIKeyID respjson.Field + Batch respjson.Field + InputAudioTokens respjson.Field + InputCachedTokens respjson.Field + Model respjson.Field + OutputAudioTokens respjson.Field + ProjectID respjson.Field + ServiceTier respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageCompletionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageCompletionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated embeddings usage details of the specific time bucket. +type AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageEmbeddingsResult struct { + // The aggregated number of input tokens used. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageEmbeddingsResult `json:"object" default:"organization.usage.embeddings.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageEmbeddingsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageEmbeddingsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated moderations usage details of the specific time bucket. +type AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageModerationsResult struct { + // The aggregated number of input tokens used. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageModerationsResult `json:"object" default:"organization.usage.moderations.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageModerationsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageModerationsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated images usage details of the specific time bucket. +type AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageImagesResult struct { + // The number of images processed. + Images int64 `json:"images" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageImagesResult `json:"object" default:"organization.usage.images.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=size`, this field provides the image size of the grouped usage + // result. + Size string `json:"size" api:"nullable"` + // When `group_by=source`, this field provides the source of the grouped usage + // result, possible values are `image.generation`, `image.edit`, `image.variation`. + Source string `json:"source" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Images respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + Size respjson.Field + Source respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageImagesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageImagesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated audio speeches usage details of the specific time bucket. +type AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageAudioSpeechesResult struct { + // The number of characters processed. + Characters int64 `json:"characters" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageAudioSpeechesResult `json:"object" default:"organization.usage.audio_speeches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Characters respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageAudioSpeechesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageAudioSpeechesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated audio transcriptions usage details of the specific time bucket. +type AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageAudioTranscriptionsResult struct { + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageAudioTranscriptionsResult `json:"object" default:"organization.usage.audio_transcriptions.result"` + // The number of seconds processed. + Seconds int64 `json:"seconds" api:"required"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumModelRequests respjson.Field + Object respjson.Field + Seconds respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageAudioTranscriptionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageAudioTranscriptionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated vector stores usage details of the specific time bucket. +type AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageVectorStoresResult struct { + Object constant.OrganizationUsageVectorStoresResult `json:"object" default:"organization.usage.vector_stores.result"` + // The vector stores usage in bytes. + UsageBytes int64 `json:"usage_bytes" api:"required"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + UsageBytes respjson.Field + ProjectID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageVectorStoresResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageVectorStoresResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated code interpreter sessions usage details of the specific time +// bucket. +type AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult struct { + // The number of code interpreter sessions. + NumSessions int64 `json:"num_sessions" api:"required"` + Object constant.OrganizationUsageCodeInterpreterSessionsResult `json:"object" default:"organization.usage.code_interpreter_sessions.result"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumSessions respjson.Field + Object respjson.Field + ProjectID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated file search calls usage details of the specific time bucket. +type AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageFileSearchesResult struct { + // The count of file search calls. + NumRequests int64 `json:"num_requests" api:"required"` + Object constant.OrganizationUsageFileSearchesResult `json:"object" default:"organization.usage.file_searches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // When `group_by=vector_store_id`, this field provides the vector store ID of the + // grouped usage result. + VectorStoreID string `json:"vector_store_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + ProjectID respjson.Field + UserID respjson.Field + VectorStoreID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageFileSearchesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageFileSearchesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated web search calls usage details of the specific time bucket. +type AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageWebSearchesResult struct { + // The count of model requests. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + // The count of web search calls. + NumRequests int64 `json:"num_requests" api:"required"` + Object constant.OrganizationUsageWebSearchesResult `json:"object" default:"organization.usage.web_searches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=context_level`, this field provides the search context size of + // the grouped usage result. + ContextLevel string `json:"context_level" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumModelRequests respjson.Field + NumRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + ContextLevel respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageWebSearchesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageWebSearchesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated costs details of the specific time bucket. +type AdminOrganizationUsageCompletionsResponseDataResultOrganizationCostsResult struct { + Object constant.OrganizationCostsResult `json:"object" default:"organization.costs.result"` + // The monetary value in its associated currency. + Amount AdminOrganizationUsageCompletionsResponseDataResultOrganizationCostsResultAmount `json:"amount"` + // When `group_by=api_key_id`, this field provides the API Key ID of the grouped + // costs result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=line_item`, this field provides the line item of the grouped + // costs result. + LineItem string `json:"line_item" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // costs result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=line_item`, this field provides the quantity of the grouped costs + // result. + Quantity float64 `json:"quantity" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + Amount respjson.Field + APIKeyID respjson.Field + LineItem respjson.Field + ProjectID respjson.Field + Quantity respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCompletionsResponseDataResultOrganizationCostsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCompletionsResponseDataResultOrganizationCostsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The monetary value in its associated currency. +type AdminOrganizationUsageCompletionsResponseDataResultOrganizationCostsResultAmount struct { + // Lowercase ISO-4217 currency e.g. "usd" + Currency string `json:"currency"` + // The numeric value of the cost. + Value float64 `json:"value"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Currency respjson.Field + Value respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCompletionsResponseDataResultOrganizationCostsResultAmount) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCompletionsResponseDataResultOrganizationCostsResultAmount) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUsageCostsResponse struct { + Data []AdminOrganizationUsageCostsResponseData `json:"data" api:"required"` + HasMore bool `json:"has_more" api:"required"` + NextPage string `json:"next_page" api:"required"` + Object constant.Page `json:"object" default:"page"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Data respjson.Field + HasMore respjson.Field + NextPage respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCostsResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUsageCostsResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUsageCostsResponseData struct { + EndTime int64 `json:"end_time" api:"required"` + Object constant.Bucket `json:"object" default:"bucket"` + Results []AdminOrganizationUsageCostsResponseDataResultUnion `json:"results" api:"required"` + StartTime int64 `json:"start_time" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + EndTime respjson.Field + Object respjson.Field + Results respjson.Field + StartTime respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCostsResponseData) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUsageCostsResponseData) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// AdminOrganizationUsageCostsResponseDataResultUnion contains all possible +// properties and values from +// [AdminOrganizationUsageCostsResponseDataResultOrganizationUsageCompletionsResult], +// [AdminOrganizationUsageCostsResponseDataResultOrganizationUsageEmbeddingsResult], +// [AdminOrganizationUsageCostsResponseDataResultOrganizationUsageModerationsResult], +// [AdminOrganizationUsageCostsResponseDataResultOrganizationUsageImagesResult], +// [AdminOrganizationUsageCostsResponseDataResultOrganizationUsageAudioSpeechesResult], +// [AdminOrganizationUsageCostsResponseDataResultOrganizationUsageAudioTranscriptionsResult], +// [AdminOrganizationUsageCostsResponseDataResultOrganizationUsageVectorStoresResult], +// [AdminOrganizationUsageCostsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult], +// [AdminOrganizationUsageCostsResponseDataResultOrganizationUsageFileSearchesResult], +// [AdminOrganizationUsageCostsResponseDataResultOrganizationUsageWebSearchesResult], +// [AdminOrganizationUsageCostsResponseDataResultOrganizationCostsResult]. +// +// Use the [AdminOrganizationUsageCostsResponseDataResultUnion.AsAny] method to +// switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type AdminOrganizationUsageCostsResponseDataResultUnion struct { + InputTokens int64 `json:"input_tokens"` + NumModelRequests int64 `json:"num_model_requests"` + // Any of "organization.usage.completions.result", + // "organization.usage.embeddings.result", "organization.usage.moderations.result", + // "organization.usage.images.result", "organization.usage.audio_speeches.result", + // "organization.usage.audio_transcriptions.result", + // "organization.usage.vector_stores.result", + // "organization.usage.code_interpreter_sessions.result", + // "organization.usage.file_searches.result", + // "organization.usage.web_searches.result", "organization.costs.result". + Object string `json:"object"` + // This field is from variant + // [AdminOrganizationUsageCostsResponseDataResultOrganizationUsageCompletionsResult]. + OutputTokens int64 `json:"output_tokens"` + APIKeyID string `json:"api_key_id"` + // This field is from variant + // [AdminOrganizationUsageCostsResponseDataResultOrganizationUsageCompletionsResult]. + Batch bool `json:"batch"` + // This field is from variant + // [AdminOrganizationUsageCostsResponseDataResultOrganizationUsageCompletionsResult]. + InputAudioTokens int64 `json:"input_audio_tokens"` + // This field is from variant + // [AdminOrganizationUsageCostsResponseDataResultOrganizationUsageCompletionsResult]. + InputCachedTokens int64 `json:"input_cached_tokens"` + Model string `json:"model"` + // This field is from variant + // [AdminOrganizationUsageCostsResponseDataResultOrganizationUsageCompletionsResult]. + OutputAudioTokens int64 `json:"output_audio_tokens"` + ProjectID string `json:"project_id"` + // This field is from variant + // [AdminOrganizationUsageCostsResponseDataResultOrganizationUsageCompletionsResult]. + ServiceTier string `json:"service_tier"` + UserID string `json:"user_id"` + // This field is from variant + // [AdminOrganizationUsageCostsResponseDataResultOrganizationUsageImagesResult]. + Images int64 `json:"images"` + // This field is from variant + // [AdminOrganizationUsageCostsResponseDataResultOrganizationUsageImagesResult]. + Size string `json:"size"` + // This field is from variant + // [AdminOrganizationUsageCostsResponseDataResultOrganizationUsageImagesResult]. + Source string `json:"source"` + // This field is from variant + // [AdminOrganizationUsageCostsResponseDataResultOrganizationUsageAudioSpeechesResult]. + Characters int64 `json:"characters"` + // This field is from variant + // [AdminOrganizationUsageCostsResponseDataResultOrganizationUsageAudioTranscriptionsResult]. + Seconds int64 `json:"seconds"` + // This field is from variant + // [AdminOrganizationUsageCostsResponseDataResultOrganizationUsageVectorStoresResult]. + UsageBytes int64 `json:"usage_bytes"` + // This field is from variant + // [AdminOrganizationUsageCostsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult]. + NumSessions int64 `json:"num_sessions"` + NumRequests int64 `json:"num_requests"` + // This field is from variant + // [AdminOrganizationUsageCostsResponseDataResultOrganizationUsageFileSearchesResult]. + VectorStoreID string `json:"vector_store_id"` + // This field is from variant + // [AdminOrganizationUsageCostsResponseDataResultOrganizationUsageWebSearchesResult]. + ContextLevel string `json:"context_level"` + // This field is from variant + // [AdminOrganizationUsageCostsResponseDataResultOrganizationCostsResult]. + Amount AdminOrganizationUsageCostsResponseDataResultOrganizationCostsResultAmount `json:"amount"` + // This field is from variant + // [AdminOrganizationUsageCostsResponseDataResultOrganizationCostsResult]. + LineItem string `json:"line_item"` + // This field is from variant + // [AdminOrganizationUsageCostsResponseDataResultOrganizationCostsResult]. + Quantity float64 `json:"quantity"` + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + OutputTokens respjson.Field + APIKeyID respjson.Field + Batch respjson.Field + InputAudioTokens respjson.Field + InputCachedTokens respjson.Field + Model respjson.Field + OutputAudioTokens respjson.Field + ProjectID respjson.Field + ServiceTier respjson.Field + UserID respjson.Field + Images respjson.Field + Size respjson.Field + Source respjson.Field + Characters respjson.Field + Seconds respjson.Field + UsageBytes respjson.Field + NumSessions respjson.Field + NumRequests respjson.Field + VectorStoreID respjson.Field + ContextLevel respjson.Field + Amount respjson.Field + LineItem respjson.Field + Quantity respjson.Field + raw string + } `json:"-"` +} + +// anyAdminOrganizationUsageCostsResponseDataResult is implemented by each variant +// of [AdminOrganizationUsageCostsResponseDataResultUnion] to add type safety for +// the return type of [AdminOrganizationUsageCostsResponseDataResultUnion.AsAny] +type anyAdminOrganizationUsageCostsResponseDataResult interface { + implAdminOrganizationUsageCostsResponseDataResultUnion() +} + +func (AdminOrganizationUsageCostsResponseDataResultOrganizationUsageCompletionsResult) implAdminOrganizationUsageCostsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCostsResponseDataResultOrganizationUsageEmbeddingsResult) implAdminOrganizationUsageCostsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCostsResponseDataResultOrganizationUsageModerationsResult) implAdminOrganizationUsageCostsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCostsResponseDataResultOrganizationUsageImagesResult) implAdminOrganizationUsageCostsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCostsResponseDataResultOrganizationUsageAudioSpeechesResult) implAdminOrganizationUsageCostsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCostsResponseDataResultOrganizationUsageAudioTranscriptionsResult) implAdminOrganizationUsageCostsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCostsResponseDataResultOrganizationUsageVectorStoresResult) implAdminOrganizationUsageCostsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCostsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) implAdminOrganizationUsageCostsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCostsResponseDataResultOrganizationUsageFileSearchesResult) implAdminOrganizationUsageCostsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCostsResponseDataResultOrganizationUsageWebSearchesResult) implAdminOrganizationUsageCostsResponseDataResultUnion() { +} +func (AdminOrganizationUsageCostsResponseDataResultOrganizationCostsResult) implAdminOrganizationUsageCostsResponseDataResultUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := AdminOrganizationUsageCostsResponseDataResultUnion.AsAny().(type) { +// case openai.AdminOrganizationUsageCostsResponseDataResultOrganizationUsageCompletionsResult: +// case openai.AdminOrganizationUsageCostsResponseDataResultOrganizationUsageEmbeddingsResult: +// case openai.AdminOrganizationUsageCostsResponseDataResultOrganizationUsageModerationsResult: +// case openai.AdminOrganizationUsageCostsResponseDataResultOrganizationUsageImagesResult: +// case openai.AdminOrganizationUsageCostsResponseDataResultOrganizationUsageAudioSpeechesResult: +// case openai.AdminOrganizationUsageCostsResponseDataResultOrganizationUsageAudioTranscriptionsResult: +// case openai.AdminOrganizationUsageCostsResponseDataResultOrganizationUsageVectorStoresResult: +// case openai.AdminOrganizationUsageCostsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult: +// case openai.AdminOrganizationUsageCostsResponseDataResultOrganizationUsageFileSearchesResult: +// case openai.AdminOrganizationUsageCostsResponseDataResultOrganizationUsageWebSearchesResult: +// case openai.AdminOrganizationUsageCostsResponseDataResultOrganizationCostsResult: +// default: +// fmt.Errorf("no variant present") +// } +func (u AdminOrganizationUsageCostsResponseDataResultUnion) AsAny() anyAdminOrganizationUsageCostsResponseDataResult { + switch u.Object { + case "organization.usage.completions.result": + return u.AsOrganizationUsageCompletionsResult() + case "organization.usage.embeddings.result": + return u.AsOrganizationUsageEmbeddingsResult() + case "organization.usage.moderations.result": + return u.AsOrganizationUsageModerationsResult() + case "organization.usage.images.result": + return u.AsOrganizationUsageImagesResult() + case "organization.usage.audio_speeches.result": + return u.AsOrganizationUsageAudioSpeechesResult() + case "organization.usage.audio_transcriptions.result": + return u.AsOrganizationUsageAudioTranscriptionsResult() + case "organization.usage.vector_stores.result": + return u.AsOrganizationUsageVectorStoresResult() + case "organization.usage.code_interpreter_sessions.result": + return u.AsOrganizationUsageCodeInterpreterSessionsResult() + case "organization.usage.file_searches.result": + return u.AsOrganizationUsageFileSearchesResult() + case "organization.usage.web_searches.result": + return u.AsOrganizationUsageWebSearchesResult() + case "organization.costs.result": + return u.AsOrganizationCostsResult() + } + return nil +} + +func (u AdminOrganizationUsageCostsResponseDataResultUnion) AsOrganizationUsageCompletionsResult() (v AdminOrganizationUsageCostsResponseDataResultOrganizationUsageCompletionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCostsResponseDataResultUnion) AsOrganizationUsageEmbeddingsResult() (v AdminOrganizationUsageCostsResponseDataResultOrganizationUsageEmbeddingsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCostsResponseDataResultUnion) AsOrganizationUsageModerationsResult() (v AdminOrganizationUsageCostsResponseDataResultOrganizationUsageModerationsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCostsResponseDataResultUnion) AsOrganizationUsageImagesResult() (v AdminOrganizationUsageCostsResponseDataResultOrganizationUsageImagesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCostsResponseDataResultUnion) AsOrganizationUsageAudioSpeechesResult() (v AdminOrganizationUsageCostsResponseDataResultOrganizationUsageAudioSpeechesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCostsResponseDataResultUnion) AsOrganizationUsageAudioTranscriptionsResult() (v AdminOrganizationUsageCostsResponseDataResultOrganizationUsageAudioTranscriptionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCostsResponseDataResultUnion) AsOrganizationUsageVectorStoresResult() (v AdminOrganizationUsageCostsResponseDataResultOrganizationUsageVectorStoresResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCostsResponseDataResultUnion) AsOrganizationUsageCodeInterpreterSessionsResult() (v AdminOrganizationUsageCostsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCostsResponseDataResultUnion) AsOrganizationUsageFileSearchesResult() (v AdminOrganizationUsageCostsResponseDataResultOrganizationUsageFileSearchesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCostsResponseDataResultUnion) AsOrganizationUsageWebSearchesResult() (v AdminOrganizationUsageCostsResponseDataResultOrganizationUsageWebSearchesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageCostsResponseDataResultUnion) AsOrganizationCostsResult() (v AdminOrganizationUsageCostsResponseDataResultOrganizationCostsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u AdminOrganizationUsageCostsResponseDataResultUnion) RawJSON() string { return u.JSON.raw } + +func (r *AdminOrganizationUsageCostsResponseDataResultUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated completions usage details of the specific time bucket. +type AdminOrganizationUsageCostsResponseDataResultOrganizationUsageCompletionsResult struct { + // The aggregated number of text input tokens used, including cached tokens. For + // customers subscribe to scale tier, this includes scale tier tokens. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageCompletionsResult `json:"object" default:"organization.usage.completions.result"` + // The aggregated number of text output tokens used. For customers subscribe to + // scale tier, this includes scale tier tokens. + OutputTokens int64 `json:"output_tokens" api:"required"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=batch`, this field tells whether the grouped usage result is + // batch or not. + Batch bool `json:"batch" api:"nullable"` + // The aggregated number of audio input tokens used, including cached tokens. + InputAudioTokens int64 `json:"input_audio_tokens"` + // The aggregated number of text input tokens that has been cached from previous + // requests. For customers subscribe to scale tier, this includes scale tier + // tokens. + InputCachedTokens int64 `json:"input_cached_tokens"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // The aggregated number of audio output tokens used. + OutputAudioTokens int64 `json:"output_audio_tokens"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=service_tier`, this field provides the service tier of the + // grouped usage result. + ServiceTier string `json:"service_tier" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + OutputTokens respjson.Field + APIKeyID respjson.Field + Batch respjson.Field + InputAudioTokens respjson.Field + InputCachedTokens respjson.Field + Model respjson.Field + OutputAudioTokens respjson.Field + ProjectID respjson.Field + ServiceTier respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCostsResponseDataResultOrganizationUsageCompletionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCostsResponseDataResultOrganizationUsageCompletionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated embeddings usage details of the specific time bucket. +type AdminOrganizationUsageCostsResponseDataResultOrganizationUsageEmbeddingsResult struct { + // The aggregated number of input tokens used. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageEmbeddingsResult `json:"object" default:"organization.usage.embeddings.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCostsResponseDataResultOrganizationUsageEmbeddingsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCostsResponseDataResultOrganizationUsageEmbeddingsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated moderations usage details of the specific time bucket. +type AdminOrganizationUsageCostsResponseDataResultOrganizationUsageModerationsResult struct { + // The aggregated number of input tokens used. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageModerationsResult `json:"object" default:"organization.usage.moderations.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCostsResponseDataResultOrganizationUsageModerationsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCostsResponseDataResultOrganizationUsageModerationsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated images usage details of the specific time bucket. +type AdminOrganizationUsageCostsResponseDataResultOrganizationUsageImagesResult struct { + // The number of images processed. + Images int64 `json:"images" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageImagesResult `json:"object" default:"organization.usage.images.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=size`, this field provides the image size of the grouped usage + // result. + Size string `json:"size" api:"nullable"` + // When `group_by=source`, this field provides the source of the grouped usage + // result, possible values are `image.generation`, `image.edit`, `image.variation`. + Source string `json:"source" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Images respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + Size respjson.Field + Source respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCostsResponseDataResultOrganizationUsageImagesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCostsResponseDataResultOrganizationUsageImagesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated audio speeches usage details of the specific time bucket. +type AdminOrganizationUsageCostsResponseDataResultOrganizationUsageAudioSpeechesResult struct { + // The number of characters processed. + Characters int64 `json:"characters" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageAudioSpeechesResult `json:"object" default:"organization.usage.audio_speeches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Characters respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCostsResponseDataResultOrganizationUsageAudioSpeechesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCostsResponseDataResultOrganizationUsageAudioSpeechesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated audio transcriptions usage details of the specific time bucket. +type AdminOrganizationUsageCostsResponseDataResultOrganizationUsageAudioTranscriptionsResult struct { + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageAudioTranscriptionsResult `json:"object" default:"organization.usage.audio_transcriptions.result"` + // The number of seconds processed. + Seconds int64 `json:"seconds" api:"required"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumModelRequests respjson.Field + Object respjson.Field + Seconds respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCostsResponseDataResultOrganizationUsageAudioTranscriptionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCostsResponseDataResultOrganizationUsageAudioTranscriptionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated vector stores usage details of the specific time bucket. +type AdminOrganizationUsageCostsResponseDataResultOrganizationUsageVectorStoresResult struct { + Object constant.OrganizationUsageVectorStoresResult `json:"object" default:"organization.usage.vector_stores.result"` + // The vector stores usage in bytes. + UsageBytes int64 `json:"usage_bytes" api:"required"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + UsageBytes respjson.Field + ProjectID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCostsResponseDataResultOrganizationUsageVectorStoresResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCostsResponseDataResultOrganizationUsageVectorStoresResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated code interpreter sessions usage details of the specific time +// bucket. +type AdminOrganizationUsageCostsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult struct { + // The number of code interpreter sessions. + NumSessions int64 `json:"num_sessions" api:"required"` + Object constant.OrganizationUsageCodeInterpreterSessionsResult `json:"object" default:"organization.usage.code_interpreter_sessions.result"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumSessions respjson.Field + Object respjson.Field + ProjectID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCostsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCostsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated file search calls usage details of the specific time bucket. +type AdminOrganizationUsageCostsResponseDataResultOrganizationUsageFileSearchesResult struct { + // The count of file search calls. + NumRequests int64 `json:"num_requests" api:"required"` + Object constant.OrganizationUsageFileSearchesResult `json:"object" default:"organization.usage.file_searches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // When `group_by=vector_store_id`, this field provides the vector store ID of the + // grouped usage result. + VectorStoreID string `json:"vector_store_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + ProjectID respjson.Field + UserID respjson.Field + VectorStoreID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCostsResponseDataResultOrganizationUsageFileSearchesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCostsResponseDataResultOrganizationUsageFileSearchesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated web search calls usage details of the specific time bucket. +type AdminOrganizationUsageCostsResponseDataResultOrganizationUsageWebSearchesResult struct { + // The count of model requests. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + // The count of web search calls. + NumRequests int64 `json:"num_requests" api:"required"` + Object constant.OrganizationUsageWebSearchesResult `json:"object" default:"organization.usage.web_searches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=context_level`, this field provides the search context size of + // the grouped usage result. + ContextLevel string `json:"context_level" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumModelRequests respjson.Field + NumRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + ContextLevel respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCostsResponseDataResultOrganizationUsageWebSearchesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCostsResponseDataResultOrganizationUsageWebSearchesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated costs details of the specific time bucket. +type AdminOrganizationUsageCostsResponseDataResultOrganizationCostsResult struct { + Object constant.OrganizationCostsResult `json:"object" default:"organization.costs.result"` + // The monetary value in its associated currency. + Amount AdminOrganizationUsageCostsResponseDataResultOrganizationCostsResultAmount `json:"amount"` + // When `group_by=api_key_id`, this field provides the API Key ID of the grouped + // costs result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=line_item`, this field provides the line item of the grouped + // costs result. + LineItem string `json:"line_item" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // costs result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=line_item`, this field provides the quantity of the grouped costs + // result. + Quantity float64 `json:"quantity" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + Amount respjson.Field + APIKeyID respjson.Field + LineItem respjson.Field + ProjectID respjson.Field + Quantity respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCostsResponseDataResultOrganizationCostsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCostsResponseDataResultOrganizationCostsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The monetary value in its associated currency. +type AdminOrganizationUsageCostsResponseDataResultOrganizationCostsResultAmount struct { + // Lowercase ISO-4217 currency e.g. "usd" + Currency string `json:"currency"` + // The numeric value of the cost. + Value float64 `json:"value"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Currency respjson.Field + Value respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageCostsResponseDataResultOrganizationCostsResultAmount) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageCostsResponseDataResultOrganizationCostsResultAmount) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUsageEmbeddingsResponse struct { + Data []AdminOrganizationUsageEmbeddingsResponseData `json:"data" api:"required"` + HasMore bool `json:"has_more" api:"required"` + NextPage string `json:"next_page" api:"required"` + Object constant.Page `json:"object" default:"page"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Data respjson.Field + HasMore respjson.Field + NextPage respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageEmbeddingsResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUsageEmbeddingsResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUsageEmbeddingsResponseData struct { + EndTime int64 `json:"end_time" api:"required"` + Object constant.Bucket `json:"object" default:"bucket"` + Results []AdminOrganizationUsageEmbeddingsResponseDataResultUnion `json:"results" api:"required"` + StartTime int64 `json:"start_time" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + EndTime respjson.Field + Object respjson.Field + Results respjson.Field + StartTime respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageEmbeddingsResponseData) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUsageEmbeddingsResponseData) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// AdminOrganizationUsageEmbeddingsResponseDataResultUnion contains all possible +// properties and values from +// [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageCompletionsResult], +// [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageEmbeddingsResult], +// [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageModerationsResult], +// [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageImagesResult], +// [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageAudioSpeechesResult], +// [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageAudioTranscriptionsResult], +// [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageVectorStoresResult], +// [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult], +// [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageFileSearchesResult], +// [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageWebSearchesResult], +// [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationCostsResult]. +// +// Use the [AdminOrganizationUsageEmbeddingsResponseDataResultUnion.AsAny] method +// to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type AdminOrganizationUsageEmbeddingsResponseDataResultUnion struct { + InputTokens int64 `json:"input_tokens"` + NumModelRequests int64 `json:"num_model_requests"` + // Any of "organization.usage.completions.result", + // "organization.usage.embeddings.result", "organization.usage.moderations.result", + // "organization.usage.images.result", "organization.usage.audio_speeches.result", + // "organization.usage.audio_transcriptions.result", + // "organization.usage.vector_stores.result", + // "organization.usage.code_interpreter_sessions.result", + // "organization.usage.file_searches.result", + // "organization.usage.web_searches.result", "organization.costs.result". + Object string `json:"object"` + // This field is from variant + // [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageCompletionsResult]. + OutputTokens int64 `json:"output_tokens"` + APIKeyID string `json:"api_key_id"` + // This field is from variant + // [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageCompletionsResult]. + Batch bool `json:"batch"` + // This field is from variant + // [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageCompletionsResult]. + InputAudioTokens int64 `json:"input_audio_tokens"` + // This field is from variant + // [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageCompletionsResult]. + InputCachedTokens int64 `json:"input_cached_tokens"` + Model string `json:"model"` + // This field is from variant + // [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageCompletionsResult]. + OutputAudioTokens int64 `json:"output_audio_tokens"` + ProjectID string `json:"project_id"` + // This field is from variant + // [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageCompletionsResult]. + ServiceTier string `json:"service_tier"` + UserID string `json:"user_id"` + // This field is from variant + // [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageImagesResult]. + Images int64 `json:"images"` + // This field is from variant + // [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageImagesResult]. + Size string `json:"size"` + // This field is from variant + // [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageImagesResult]. + Source string `json:"source"` + // This field is from variant + // [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageAudioSpeechesResult]. + Characters int64 `json:"characters"` + // This field is from variant + // [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageAudioTranscriptionsResult]. + Seconds int64 `json:"seconds"` + // This field is from variant + // [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageVectorStoresResult]. + UsageBytes int64 `json:"usage_bytes"` + // This field is from variant + // [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult]. + NumSessions int64 `json:"num_sessions"` + NumRequests int64 `json:"num_requests"` + // This field is from variant + // [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageFileSearchesResult]. + VectorStoreID string `json:"vector_store_id"` + // This field is from variant + // [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageWebSearchesResult]. + ContextLevel string `json:"context_level"` + // This field is from variant + // [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationCostsResult]. + Amount AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationCostsResultAmount `json:"amount"` + // This field is from variant + // [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationCostsResult]. + LineItem string `json:"line_item"` + // This field is from variant + // [AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationCostsResult]. + Quantity float64 `json:"quantity"` + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + OutputTokens respjson.Field + APIKeyID respjson.Field + Batch respjson.Field + InputAudioTokens respjson.Field + InputCachedTokens respjson.Field + Model respjson.Field + OutputAudioTokens respjson.Field + ProjectID respjson.Field + ServiceTier respjson.Field + UserID respjson.Field + Images respjson.Field + Size respjson.Field + Source respjson.Field + Characters respjson.Field + Seconds respjson.Field + UsageBytes respjson.Field + NumSessions respjson.Field + NumRequests respjson.Field + VectorStoreID respjson.Field + ContextLevel respjson.Field + Amount respjson.Field + LineItem respjson.Field + Quantity respjson.Field + raw string + } `json:"-"` +} + +// anyAdminOrganizationUsageEmbeddingsResponseDataResult is implemented by each +// variant of [AdminOrganizationUsageEmbeddingsResponseDataResultUnion] to add type +// safety for the return type of +// [AdminOrganizationUsageEmbeddingsResponseDataResultUnion.AsAny] +type anyAdminOrganizationUsageEmbeddingsResponseDataResult interface { + implAdminOrganizationUsageEmbeddingsResponseDataResultUnion() +} + +func (AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageCompletionsResult) implAdminOrganizationUsageEmbeddingsResponseDataResultUnion() { +} +func (AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageEmbeddingsResult) implAdminOrganizationUsageEmbeddingsResponseDataResultUnion() { +} +func (AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageModerationsResult) implAdminOrganizationUsageEmbeddingsResponseDataResultUnion() { +} +func (AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageImagesResult) implAdminOrganizationUsageEmbeddingsResponseDataResultUnion() { +} +func (AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageAudioSpeechesResult) implAdminOrganizationUsageEmbeddingsResponseDataResultUnion() { +} +func (AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageAudioTranscriptionsResult) implAdminOrganizationUsageEmbeddingsResponseDataResultUnion() { +} +func (AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageVectorStoresResult) implAdminOrganizationUsageEmbeddingsResponseDataResultUnion() { +} +func (AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) implAdminOrganizationUsageEmbeddingsResponseDataResultUnion() { +} +func (AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageFileSearchesResult) implAdminOrganizationUsageEmbeddingsResponseDataResultUnion() { +} +func (AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageWebSearchesResult) implAdminOrganizationUsageEmbeddingsResponseDataResultUnion() { +} +func (AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationCostsResult) implAdminOrganizationUsageEmbeddingsResponseDataResultUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := AdminOrganizationUsageEmbeddingsResponseDataResultUnion.AsAny().(type) { +// case openai.AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageCompletionsResult: +// case openai.AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageEmbeddingsResult: +// case openai.AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageModerationsResult: +// case openai.AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageImagesResult: +// case openai.AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageAudioSpeechesResult: +// case openai.AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageAudioTranscriptionsResult: +// case openai.AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageVectorStoresResult: +// case openai.AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult: +// case openai.AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageFileSearchesResult: +// case openai.AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageWebSearchesResult: +// case openai.AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationCostsResult: +// default: +// fmt.Errorf("no variant present") +// } +func (u AdminOrganizationUsageEmbeddingsResponseDataResultUnion) AsAny() anyAdminOrganizationUsageEmbeddingsResponseDataResult { + switch u.Object { + case "organization.usage.completions.result": + return u.AsOrganizationUsageCompletionsResult() + case "organization.usage.embeddings.result": + return u.AsOrganizationUsageEmbeddingsResult() + case "organization.usage.moderations.result": + return u.AsOrganizationUsageModerationsResult() + case "organization.usage.images.result": + return u.AsOrganizationUsageImagesResult() + case "organization.usage.audio_speeches.result": + return u.AsOrganizationUsageAudioSpeechesResult() + case "organization.usage.audio_transcriptions.result": + return u.AsOrganizationUsageAudioTranscriptionsResult() + case "organization.usage.vector_stores.result": + return u.AsOrganizationUsageVectorStoresResult() + case "organization.usage.code_interpreter_sessions.result": + return u.AsOrganizationUsageCodeInterpreterSessionsResult() + case "organization.usage.file_searches.result": + return u.AsOrganizationUsageFileSearchesResult() + case "organization.usage.web_searches.result": + return u.AsOrganizationUsageWebSearchesResult() + case "organization.costs.result": + return u.AsOrganizationCostsResult() + } + return nil +} + +func (u AdminOrganizationUsageEmbeddingsResponseDataResultUnion) AsOrganizationUsageCompletionsResult() (v AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageCompletionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageEmbeddingsResponseDataResultUnion) AsOrganizationUsageEmbeddingsResult() (v AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageEmbeddingsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageEmbeddingsResponseDataResultUnion) AsOrganizationUsageModerationsResult() (v AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageModerationsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageEmbeddingsResponseDataResultUnion) AsOrganizationUsageImagesResult() (v AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageImagesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageEmbeddingsResponseDataResultUnion) AsOrganizationUsageAudioSpeechesResult() (v AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageAudioSpeechesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageEmbeddingsResponseDataResultUnion) AsOrganizationUsageAudioTranscriptionsResult() (v AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageAudioTranscriptionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageEmbeddingsResponseDataResultUnion) AsOrganizationUsageVectorStoresResult() (v AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageVectorStoresResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageEmbeddingsResponseDataResultUnion) AsOrganizationUsageCodeInterpreterSessionsResult() (v AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageEmbeddingsResponseDataResultUnion) AsOrganizationUsageFileSearchesResult() (v AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageFileSearchesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageEmbeddingsResponseDataResultUnion) AsOrganizationUsageWebSearchesResult() (v AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageWebSearchesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageEmbeddingsResponseDataResultUnion) AsOrganizationCostsResult() (v AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationCostsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u AdminOrganizationUsageEmbeddingsResponseDataResultUnion) RawJSON() string { return u.JSON.raw } + +func (r *AdminOrganizationUsageEmbeddingsResponseDataResultUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated completions usage details of the specific time bucket. +type AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageCompletionsResult struct { + // The aggregated number of text input tokens used, including cached tokens. For + // customers subscribe to scale tier, this includes scale tier tokens. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageCompletionsResult `json:"object" default:"organization.usage.completions.result"` + // The aggregated number of text output tokens used. For customers subscribe to + // scale tier, this includes scale tier tokens. + OutputTokens int64 `json:"output_tokens" api:"required"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=batch`, this field tells whether the grouped usage result is + // batch or not. + Batch bool `json:"batch" api:"nullable"` + // The aggregated number of audio input tokens used, including cached tokens. + InputAudioTokens int64 `json:"input_audio_tokens"` + // The aggregated number of text input tokens that has been cached from previous + // requests. For customers subscribe to scale tier, this includes scale tier + // tokens. + InputCachedTokens int64 `json:"input_cached_tokens"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // The aggregated number of audio output tokens used. + OutputAudioTokens int64 `json:"output_audio_tokens"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=service_tier`, this field provides the service tier of the + // grouped usage result. + ServiceTier string `json:"service_tier" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + OutputTokens respjson.Field + APIKeyID respjson.Field + Batch respjson.Field + InputAudioTokens respjson.Field + InputCachedTokens respjson.Field + Model respjson.Field + OutputAudioTokens respjson.Field + ProjectID respjson.Field + ServiceTier respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageCompletionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageCompletionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated embeddings usage details of the specific time bucket. +type AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageEmbeddingsResult struct { + // The aggregated number of input tokens used. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageEmbeddingsResult `json:"object" default:"organization.usage.embeddings.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageEmbeddingsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageEmbeddingsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated moderations usage details of the specific time bucket. +type AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageModerationsResult struct { + // The aggregated number of input tokens used. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageModerationsResult `json:"object" default:"organization.usage.moderations.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageModerationsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageModerationsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated images usage details of the specific time bucket. +type AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageImagesResult struct { + // The number of images processed. + Images int64 `json:"images" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageImagesResult `json:"object" default:"organization.usage.images.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=size`, this field provides the image size of the grouped usage + // result. + Size string `json:"size" api:"nullable"` + // When `group_by=source`, this field provides the source of the grouped usage + // result, possible values are `image.generation`, `image.edit`, `image.variation`. + Source string `json:"source" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Images respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + Size respjson.Field + Source respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageImagesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageImagesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated audio speeches usage details of the specific time bucket. +type AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageAudioSpeechesResult struct { + // The number of characters processed. + Characters int64 `json:"characters" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageAudioSpeechesResult `json:"object" default:"organization.usage.audio_speeches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Characters respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageAudioSpeechesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageAudioSpeechesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated audio transcriptions usage details of the specific time bucket. +type AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageAudioTranscriptionsResult struct { + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageAudioTranscriptionsResult `json:"object" default:"organization.usage.audio_transcriptions.result"` + // The number of seconds processed. + Seconds int64 `json:"seconds" api:"required"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumModelRequests respjson.Field + Object respjson.Field + Seconds respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageAudioTranscriptionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageAudioTranscriptionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated vector stores usage details of the specific time bucket. +type AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageVectorStoresResult struct { + Object constant.OrganizationUsageVectorStoresResult `json:"object" default:"organization.usage.vector_stores.result"` + // The vector stores usage in bytes. + UsageBytes int64 `json:"usage_bytes" api:"required"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + UsageBytes respjson.Field + ProjectID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageVectorStoresResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageVectorStoresResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated code interpreter sessions usage details of the specific time +// bucket. +type AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult struct { + // The number of code interpreter sessions. + NumSessions int64 `json:"num_sessions" api:"required"` + Object constant.OrganizationUsageCodeInterpreterSessionsResult `json:"object" default:"organization.usage.code_interpreter_sessions.result"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumSessions respjson.Field + Object respjson.Field + ProjectID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated file search calls usage details of the specific time bucket. +type AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageFileSearchesResult struct { + // The count of file search calls. + NumRequests int64 `json:"num_requests" api:"required"` + Object constant.OrganizationUsageFileSearchesResult `json:"object" default:"organization.usage.file_searches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // When `group_by=vector_store_id`, this field provides the vector store ID of the + // grouped usage result. + VectorStoreID string `json:"vector_store_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + ProjectID respjson.Field + UserID respjson.Field + VectorStoreID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageFileSearchesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageFileSearchesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated web search calls usage details of the specific time bucket. +type AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageWebSearchesResult struct { + // The count of model requests. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + // The count of web search calls. + NumRequests int64 `json:"num_requests" api:"required"` + Object constant.OrganizationUsageWebSearchesResult `json:"object" default:"organization.usage.web_searches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=context_level`, this field provides the search context size of + // the grouped usage result. + ContextLevel string `json:"context_level" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumModelRequests respjson.Field + NumRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + ContextLevel respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageWebSearchesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageWebSearchesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated costs details of the specific time bucket. +type AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationCostsResult struct { + Object constant.OrganizationCostsResult `json:"object" default:"organization.costs.result"` + // The monetary value in its associated currency. + Amount AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationCostsResultAmount `json:"amount"` + // When `group_by=api_key_id`, this field provides the API Key ID of the grouped + // costs result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=line_item`, this field provides the line item of the grouped + // costs result. + LineItem string `json:"line_item" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // costs result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=line_item`, this field provides the quantity of the grouped costs + // result. + Quantity float64 `json:"quantity" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + Amount respjson.Field + APIKeyID respjson.Field + LineItem respjson.Field + ProjectID respjson.Field + Quantity respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationCostsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationCostsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The monetary value in its associated currency. +type AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationCostsResultAmount struct { + // Lowercase ISO-4217 currency e.g. "usd" + Currency string `json:"currency"` + // The numeric value of the cost. + Value float64 `json:"value"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Currency respjson.Field + Value respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationCostsResultAmount) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationCostsResultAmount) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUsageFileSearchCallsResponse struct { + Data []AdminOrganizationUsageFileSearchCallsResponseData `json:"data" api:"required"` + HasMore bool `json:"has_more" api:"required"` + NextPage string `json:"next_page" api:"required"` + Object constant.Page `json:"object" default:"page"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Data respjson.Field + HasMore respjson.Field + NextPage respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageFileSearchCallsResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUsageFileSearchCallsResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUsageFileSearchCallsResponseData struct { + EndTime int64 `json:"end_time" api:"required"` + Object constant.Bucket `json:"object" default:"bucket"` + Results []AdminOrganizationUsageFileSearchCallsResponseDataResultUnion `json:"results" api:"required"` + StartTime int64 `json:"start_time" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + EndTime respjson.Field + Object respjson.Field + Results respjson.Field + StartTime respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageFileSearchCallsResponseData) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUsageFileSearchCallsResponseData) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// AdminOrganizationUsageFileSearchCallsResponseDataResultUnion contains all +// possible properties and values from +// [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageCompletionsResult], +// [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageEmbeddingsResult], +// [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageModerationsResult], +// [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageImagesResult], +// [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageAudioSpeechesResult], +// [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageAudioTranscriptionsResult], +// [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageVectorStoresResult], +// [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult], +// [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageFileSearchesResult], +// [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageWebSearchesResult], +// [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationCostsResult]. +// +// Use the [AdminOrganizationUsageFileSearchCallsResponseDataResultUnion.AsAny] +// method to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type AdminOrganizationUsageFileSearchCallsResponseDataResultUnion struct { + InputTokens int64 `json:"input_tokens"` + NumModelRequests int64 `json:"num_model_requests"` + // Any of "organization.usage.completions.result", + // "organization.usage.embeddings.result", "organization.usage.moderations.result", + // "organization.usage.images.result", "organization.usage.audio_speeches.result", + // "organization.usage.audio_transcriptions.result", + // "organization.usage.vector_stores.result", + // "organization.usage.code_interpreter_sessions.result", + // "organization.usage.file_searches.result", + // "organization.usage.web_searches.result", "organization.costs.result". + Object string `json:"object"` + // This field is from variant + // [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageCompletionsResult]. + OutputTokens int64 `json:"output_tokens"` + APIKeyID string `json:"api_key_id"` + // This field is from variant + // [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageCompletionsResult]. + Batch bool `json:"batch"` + // This field is from variant + // [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageCompletionsResult]. + InputAudioTokens int64 `json:"input_audio_tokens"` + // This field is from variant + // [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageCompletionsResult]. + InputCachedTokens int64 `json:"input_cached_tokens"` + Model string `json:"model"` + // This field is from variant + // [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageCompletionsResult]. + OutputAudioTokens int64 `json:"output_audio_tokens"` + ProjectID string `json:"project_id"` + // This field is from variant + // [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageCompletionsResult]. + ServiceTier string `json:"service_tier"` + UserID string `json:"user_id"` + // This field is from variant + // [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageImagesResult]. + Images int64 `json:"images"` + // This field is from variant + // [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageImagesResult]. + Size string `json:"size"` + // This field is from variant + // [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageImagesResult]. + Source string `json:"source"` + // This field is from variant + // [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageAudioSpeechesResult]. + Characters int64 `json:"characters"` + // This field is from variant + // [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageAudioTranscriptionsResult]. + Seconds int64 `json:"seconds"` + // This field is from variant + // [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageVectorStoresResult]. + UsageBytes int64 `json:"usage_bytes"` + // This field is from variant + // [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult]. + NumSessions int64 `json:"num_sessions"` + NumRequests int64 `json:"num_requests"` + // This field is from variant + // [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageFileSearchesResult]. + VectorStoreID string `json:"vector_store_id"` + // This field is from variant + // [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageWebSearchesResult]. + ContextLevel string `json:"context_level"` + // This field is from variant + // [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationCostsResult]. + Amount AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationCostsResultAmount `json:"amount"` + // This field is from variant + // [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationCostsResult]. + LineItem string `json:"line_item"` + // This field is from variant + // [AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationCostsResult]. + Quantity float64 `json:"quantity"` + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + OutputTokens respjson.Field + APIKeyID respjson.Field + Batch respjson.Field + InputAudioTokens respjson.Field + InputCachedTokens respjson.Field + Model respjson.Field + OutputAudioTokens respjson.Field + ProjectID respjson.Field + ServiceTier respjson.Field + UserID respjson.Field + Images respjson.Field + Size respjson.Field + Source respjson.Field + Characters respjson.Field + Seconds respjson.Field + UsageBytes respjson.Field + NumSessions respjson.Field + NumRequests respjson.Field + VectorStoreID respjson.Field + ContextLevel respjson.Field + Amount respjson.Field + LineItem respjson.Field + Quantity respjson.Field + raw string + } `json:"-"` +} + +// anyAdminOrganizationUsageFileSearchCallsResponseDataResult is implemented by +// each variant of [AdminOrganizationUsageFileSearchCallsResponseDataResultUnion] +// to add type safety for the return type of +// [AdminOrganizationUsageFileSearchCallsResponseDataResultUnion.AsAny] +type anyAdminOrganizationUsageFileSearchCallsResponseDataResult interface { + implAdminOrganizationUsageFileSearchCallsResponseDataResultUnion() +} + +func (AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageCompletionsResult) implAdminOrganizationUsageFileSearchCallsResponseDataResultUnion() { +} +func (AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageEmbeddingsResult) implAdminOrganizationUsageFileSearchCallsResponseDataResultUnion() { +} +func (AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageModerationsResult) implAdminOrganizationUsageFileSearchCallsResponseDataResultUnion() { +} +func (AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageImagesResult) implAdminOrganizationUsageFileSearchCallsResponseDataResultUnion() { +} +func (AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageAudioSpeechesResult) implAdminOrganizationUsageFileSearchCallsResponseDataResultUnion() { +} +func (AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageAudioTranscriptionsResult) implAdminOrganizationUsageFileSearchCallsResponseDataResultUnion() { +} +func (AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageVectorStoresResult) implAdminOrganizationUsageFileSearchCallsResponseDataResultUnion() { +} +func (AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) implAdminOrganizationUsageFileSearchCallsResponseDataResultUnion() { +} +func (AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageFileSearchesResult) implAdminOrganizationUsageFileSearchCallsResponseDataResultUnion() { +} +func (AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageWebSearchesResult) implAdminOrganizationUsageFileSearchCallsResponseDataResultUnion() { +} +func (AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationCostsResult) implAdminOrganizationUsageFileSearchCallsResponseDataResultUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := AdminOrganizationUsageFileSearchCallsResponseDataResultUnion.AsAny().(type) { +// case openai.AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageCompletionsResult: +// case openai.AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageEmbeddingsResult: +// case openai.AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageModerationsResult: +// case openai.AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageImagesResult: +// case openai.AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageAudioSpeechesResult: +// case openai.AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageAudioTranscriptionsResult: +// case openai.AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageVectorStoresResult: +// case openai.AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult: +// case openai.AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageFileSearchesResult: +// case openai.AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageWebSearchesResult: +// case openai.AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationCostsResult: +// default: +// fmt.Errorf("no variant present") +// } +func (u AdminOrganizationUsageFileSearchCallsResponseDataResultUnion) AsAny() anyAdminOrganizationUsageFileSearchCallsResponseDataResult { + switch u.Object { + case "organization.usage.completions.result": + return u.AsOrganizationUsageCompletionsResult() + case "organization.usage.embeddings.result": + return u.AsOrganizationUsageEmbeddingsResult() + case "organization.usage.moderations.result": + return u.AsOrganizationUsageModerationsResult() + case "organization.usage.images.result": + return u.AsOrganizationUsageImagesResult() + case "organization.usage.audio_speeches.result": + return u.AsOrganizationUsageAudioSpeechesResult() + case "organization.usage.audio_transcriptions.result": + return u.AsOrganizationUsageAudioTranscriptionsResult() + case "organization.usage.vector_stores.result": + return u.AsOrganizationUsageVectorStoresResult() + case "organization.usage.code_interpreter_sessions.result": + return u.AsOrganizationUsageCodeInterpreterSessionsResult() + case "organization.usage.file_searches.result": + return u.AsOrganizationUsageFileSearchesResult() + case "organization.usage.web_searches.result": + return u.AsOrganizationUsageWebSearchesResult() + case "organization.costs.result": + return u.AsOrganizationCostsResult() + } + return nil +} + +func (u AdminOrganizationUsageFileSearchCallsResponseDataResultUnion) AsOrganizationUsageCompletionsResult() (v AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageCompletionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageFileSearchCallsResponseDataResultUnion) AsOrganizationUsageEmbeddingsResult() (v AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageEmbeddingsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageFileSearchCallsResponseDataResultUnion) AsOrganizationUsageModerationsResult() (v AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageModerationsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageFileSearchCallsResponseDataResultUnion) AsOrganizationUsageImagesResult() (v AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageImagesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageFileSearchCallsResponseDataResultUnion) AsOrganizationUsageAudioSpeechesResult() (v AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageAudioSpeechesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageFileSearchCallsResponseDataResultUnion) AsOrganizationUsageAudioTranscriptionsResult() (v AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageAudioTranscriptionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageFileSearchCallsResponseDataResultUnion) AsOrganizationUsageVectorStoresResult() (v AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageVectorStoresResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageFileSearchCallsResponseDataResultUnion) AsOrganizationUsageCodeInterpreterSessionsResult() (v AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageFileSearchCallsResponseDataResultUnion) AsOrganizationUsageFileSearchesResult() (v AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageFileSearchesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageFileSearchCallsResponseDataResultUnion) AsOrganizationUsageWebSearchesResult() (v AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageWebSearchesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageFileSearchCallsResponseDataResultUnion) AsOrganizationCostsResult() (v AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationCostsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u AdminOrganizationUsageFileSearchCallsResponseDataResultUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *AdminOrganizationUsageFileSearchCallsResponseDataResultUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated completions usage details of the specific time bucket. +type AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageCompletionsResult struct { + // The aggregated number of text input tokens used, including cached tokens. For + // customers subscribe to scale tier, this includes scale tier tokens. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageCompletionsResult `json:"object" default:"organization.usage.completions.result"` + // The aggregated number of text output tokens used. For customers subscribe to + // scale tier, this includes scale tier tokens. + OutputTokens int64 `json:"output_tokens" api:"required"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=batch`, this field tells whether the grouped usage result is + // batch or not. + Batch bool `json:"batch" api:"nullable"` + // The aggregated number of audio input tokens used, including cached tokens. + InputAudioTokens int64 `json:"input_audio_tokens"` + // The aggregated number of text input tokens that has been cached from previous + // requests. For customers subscribe to scale tier, this includes scale tier + // tokens. + InputCachedTokens int64 `json:"input_cached_tokens"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // The aggregated number of audio output tokens used. + OutputAudioTokens int64 `json:"output_audio_tokens"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=service_tier`, this field provides the service tier of the + // grouped usage result. + ServiceTier string `json:"service_tier" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + OutputTokens respjson.Field + APIKeyID respjson.Field + Batch respjson.Field + InputAudioTokens respjson.Field + InputCachedTokens respjson.Field + Model respjson.Field + OutputAudioTokens respjson.Field + ProjectID respjson.Field + ServiceTier respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageCompletionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageCompletionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated embeddings usage details of the specific time bucket. +type AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageEmbeddingsResult struct { + // The aggregated number of input tokens used. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageEmbeddingsResult `json:"object" default:"organization.usage.embeddings.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageEmbeddingsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageEmbeddingsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated moderations usage details of the specific time bucket. +type AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageModerationsResult struct { + // The aggregated number of input tokens used. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageModerationsResult `json:"object" default:"organization.usage.moderations.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageModerationsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageModerationsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated images usage details of the specific time bucket. +type AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageImagesResult struct { + // The number of images processed. + Images int64 `json:"images" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageImagesResult `json:"object" default:"organization.usage.images.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=size`, this field provides the image size of the grouped usage + // result. + Size string `json:"size" api:"nullable"` + // When `group_by=source`, this field provides the source of the grouped usage + // result, possible values are `image.generation`, `image.edit`, `image.variation`. + Source string `json:"source" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Images respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + Size respjson.Field + Source respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageImagesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageImagesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated audio speeches usage details of the specific time bucket. +type AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageAudioSpeechesResult struct { + // The number of characters processed. + Characters int64 `json:"characters" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageAudioSpeechesResult `json:"object" default:"organization.usage.audio_speeches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Characters respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageAudioSpeechesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageAudioSpeechesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated audio transcriptions usage details of the specific time bucket. +type AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageAudioTranscriptionsResult struct { + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageAudioTranscriptionsResult `json:"object" default:"organization.usage.audio_transcriptions.result"` + // The number of seconds processed. + Seconds int64 `json:"seconds" api:"required"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumModelRequests respjson.Field + Object respjson.Field + Seconds respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageAudioTranscriptionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageAudioTranscriptionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated vector stores usage details of the specific time bucket. +type AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageVectorStoresResult struct { + Object constant.OrganizationUsageVectorStoresResult `json:"object" default:"organization.usage.vector_stores.result"` + // The vector stores usage in bytes. + UsageBytes int64 `json:"usage_bytes" api:"required"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + UsageBytes respjson.Field + ProjectID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageVectorStoresResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageVectorStoresResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated code interpreter sessions usage details of the specific time +// bucket. +type AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult struct { + // The number of code interpreter sessions. + NumSessions int64 `json:"num_sessions" api:"required"` + Object constant.OrganizationUsageCodeInterpreterSessionsResult `json:"object" default:"organization.usage.code_interpreter_sessions.result"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumSessions respjson.Field + Object respjson.Field + ProjectID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated file search calls usage details of the specific time bucket. +type AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageFileSearchesResult struct { + // The count of file search calls. + NumRequests int64 `json:"num_requests" api:"required"` + Object constant.OrganizationUsageFileSearchesResult `json:"object" default:"organization.usage.file_searches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // When `group_by=vector_store_id`, this field provides the vector store ID of the + // grouped usage result. + VectorStoreID string `json:"vector_store_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + ProjectID respjson.Field + UserID respjson.Field + VectorStoreID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageFileSearchesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageFileSearchesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated web search calls usage details of the specific time bucket. +type AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageWebSearchesResult struct { + // The count of model requests. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + // The count of web search calls. + NumRequests int64 `json:"num_requests" api:"required"` + Object constant.OrganizationUsageWebSearchesResult `json:"object" default:"organization.usage.web_searches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=context_level`, this field provides the search context size of + // the grouped usage result. + ContextLevel string `json:"context_level" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumModelRequests respjson.Field + NumRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + ContextLevel respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageWebSearchesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationUsageWebSearchesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated costs details of the specific time bucket. +type AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationCostsResult struct { + Object constant.OrganizationCostsResult `json:"object" default:"organization.costs.result"` + // The monetary value in its associated currency. + Amount AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationCostsResultAmount `json:"amount"` + // When `group_by=api_key_id`, this field provides the API Key ID of the grouped + // costs result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=line_item`, this field provides the line item of the grouped + // costs result. + LineItem string `json:"line_item" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // costs result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=line_item`, this field provides the quantity of the grouped costs + // result. + Quantity float64 `json:"quantity" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + Amount respjson.Field + APIKeyID respjson.Field + LineItem respjson.Field + ProjectID respjson.Field + Quantity respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationCostsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationCostsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The monetary value in its associated currency. +type AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationCostsResultAmount struct { + // Lowercase ISO-4217 currency e.g. "usd" + Currency string `json:"currency"` + // The numeric value of the cost. + Value float64 `json:"value"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Currency respjson.Field + Value respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationCostsResultAmount) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageFileSearchCallsResponseDataResultOrganizationCostsResultAmount) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUsageImagesResponse struct { + Data []AdminOrganizationUsageImagesResponseData `json:"data" api:"required"` + HasMore bool `json:"has_more" api:"required"` + NextPage string `json:"next_page" api:"required"` + Object constant.Page `json:"object" default:"page"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Data respjson.Field + HasMore respjson.Field + NextPage respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageImagesResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUsageImagesResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUsageImagesResponseData struct { + EndTime int64 `json:"end_time" api:"required"` + Object constant.Bucket `json:"object" default:"bucket"` + Results []AdminOrganizationUsageImagesResponseDataResultUnion `json:"results" api:"required"` + StartTime int64 `json:"start_time" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + EndTime respjson.Field + Object respjson.Field + Results respjson.Field + StartTime respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageImagesResponseData) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUsageImagesResponseData) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// AdminOrganizationUsageImagesResponseDataResultUnion contains all possible +// properties and values from +// [AdminOrganizationUsageImagesResponseDataResultOrganizationUsageCompletionsResult], +// [AdminOrganizationUsageImagesResponseDataResultOrganizationUsageEmbeddingsResult], +// [AdminOrganizationUsageImagesResponseDataResultOrganizationUsageModerationsResult], +// [AdminOrganizationUsageImagesResponseDataResultOrganizationUsageImagesResult], +// [AdminOrganizationUsageImagesResponseDataResultOrganizationUsageAudioSpeechesResult], +// [AdminOrganizationUsageImagesResponseDataResultOrganizationUsageAudioTranscriptionsResult], +// [AdminOrganizationUsageImagesResponseDataResultOrganizationUsageVectorStoresResult], +// [AdminOrganizationUsageImagesResponseDataResultOrganizationUsageCodeInterpreterSessionsResult], +// [AdminOrganizationUsageImagesResponseDataResultOrganizationUsageFileSearchesResult], +// [AdminOrganizationUsageImagesResponseDataResultOrganizationUsageWebSearchesResult], +// [AdminOrganizationUsageImagesResponseDataResultOrganizationCostsResult]. +// +// Use the [AdminOrganizationUsageImagesResponseDataResultUnion.AsAny] method to +// switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type AdminOrganizationUsageImagesResponseDataResultUnion struct { + InputTokens int64 `json:"input_tokens"` + NumModelRequests int64 `json:"num_model_requests"` + // Any of "organization.usage.completions.result", + // "organization.usage.embeddings.result", "organization.usage.moderations.result", + // "organization.usage.images.result", "organization.usage.audio_speeches.result", + // "organization.usage.audio_transcriptions.result", + // "organization.usage.vector_stores.result", + // "organization.usage.code_interpreter_sessions.result", + // "organization.usage.file_searches.result", + // "organization.usage.web_searches.result", "organization.costs.result". + Object string `json:"object"` + // This field is from variant + // [AdminOrganizationUsageImagesResponseDataResultOrganizationUsageCompletionsResult]. + OutputTokens int64 `json:"output_tokens"` + APIKeyID string `json:"api_key_id"` + // This field is from variant + // [AdminOrganizationUsageImagesResponseDataResultOrganizationUsageCompletionsResult]. + Batch bool `json:"batch"` + // This field is from variant + // [AdminOrganizationUsageImagesResponseDataResultOrganizationUsageCompletionsResult]. + InputAudioTokens int64 `json:"input_audio_tokens"` + // This field is from variant + // [AdminOrganizationUsageImagesResponseDataResultOrganizationUsageCompletionsResult]. + InputCachedTokens int64 `json:"input_cached_tokens"` + Model string `json:"model"` + // This field is from variant + // [AdminOrganizationUsageImagesResponseDataResultOrganizationUsageCompletionsResult]. + OutputAudioTokens int64 `json:"output_audio_tokens"` + ProjectID string `json:"project_id"` + // This field is from variant + // [AdminOrganizationUsageImagesResponseDataResultOrganizationUsageCompletionsResult]. + ServiceTier string `json:"service_tier"` + UserID string `json:"user_id"` + // This field is from variant + // [AdminOrganizationUsageImagesResponseDataResultOrganizationUsageImagesResult]. + Images int64 `json:"images"` + // This field is from variant + // [AdminOrganizationUsageImagesResponseDataResultOrganizationUsageImagesResult]. + Size string `json:"size"` + // This field is from variant + // [AdminOrganizationUsageImagesResponseDataResultOrganizationUsageImagesResult]. + Source string `json:"source"` + // This field is from variant + // [AdminOrganizationUsageImagesResponseDataResultOrganizationUsageAudioSpeechesResult]. + Characters int64 `json:"characters"` + // This field is from variant + // [AdminOrganizationUsageImagesResponseDataResultOrganizationUsageAudioTranscriptionsResult]. + Seconds int64 `json:"seconds"` + // This field is from variant + // [AdminOrganizationUsageImagesResponseDataResultOrganizationUsageVectorStoresResult]. + UsageBytes int64 `json:"usage_bytes"` + // This field is from variant + // [AdminOrganizationUsageImagesResponseDataResultOrganizationUsageCodeInterpreterSessionsResult]. + NumSessions int64 `json:"num_sessions"` + NumRequests int64 `json:"num_requests"` + // This field is from variant + // [AdminOrganizationUsageImagesResponseDataResultOrganizationUsageFileSearchesResult]. + VectorStoreID string `json:"vector_store_id"` + // This field is from variant + // [AdminOrganizationUsageImagesResponseDataResultOrganizationUsageWebSearchesResult]. + ContextLevel string `json:"context_level"` + // This field is from variant + // [AdminOrganizationUsageImagesResponseDataResultOrganizationCostsResult]. + Amount AdminOrganizationUsageImagesResponseDataResultOrganizationCostsResultAmount `json:"amount"` + // This field is from variant + // [AdminOrganizationUsageImagesResponseDataResultOrganizationCostsResult]. + LineItem string `json:"line_item"` + // This field is from variant + // [AdminOrganizationUsageImagesResponseDataResultOrganizationCostsResult]. + Quantity float64 `json:"quantity"` + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + OutputTokens respjson.Field + APIKeyID respjson.Field + Batch respjson.Field + InputAudioTokens respjson.Field + InputCachedTokens respjson.Field + Model respjson.Field + OutputAudioTokens respjson.Field + ProjectID respjson.Field + ServiceTier respjson.Field + UserID respjson.Field + Images respjson.Field + Size respjson.Field + Source respjson.Field + Characters respjson.Field + Seconds respjson.Field + UsageBytes respjson.Field + NumSessions respjson.Field + NumRequests respjson.Field + VectorStoreID respjson.Field + ContextLevel respjson.Field + Amount respjson.Field + LineItem respjson.Field + Quantity respjson.Field + raw string + } `json:"-"` +} + +// anyAdminOrganizationUsageImagesResponseDataResult is implemented by each variant +// of [AdminOrganizationUsageImagesResponseDataResultUnion] to add type safety for +// the return type of [AdminOrganizationUsageImagesResponseDataResultUnion.AsAny] +type anyAdminOrganizationUsageImagesResponseDataResult interface { + implAdminOrganizationUsageImagesResponseDataResultUnion() +} + +func (AdminOrganizationUsageImagesResponseDataResultOrganizationUsageCompletionsResult) implAdminOrganizationUsageImagesResponseDataResultUnion() { +} +func (AdminOrganizationUsageImagesResponseDataResultOrganizationUsageEmbeddingsResult) implAdminOrganizationUsageImagesResponseDataResultUnion() { +} +func (AdminOrganizationUsageImagesResponseDataResultOrganizationUsageModerationsResult) implAdminOrganizationUsageImagesResponseDataResultUnion() { +} +func (AdminOrganizationUsageImagesResponseDataResultOrganizationUsageImagesResult) implAdminOrganizationUsageImagesResponseDataResultUnion() { +} +func (AdminOrganizationUsageImagesResponseDataResultOrganizationUsageAudioSpeechesResult) implAdminOrganizationUsageImagesResponseDataResultUnion() { +} +func (AdminOrganizationUsageImagesResponseDataResultOrganizationUsageAudioTranscriptionsResult) implAdminOrganizationUsageImagesResponseDataResultUnion() { +} +func (AdminOrganizationUsageImagesResponseDataResultOrganizationUsageVectorStoresResult) implAdminOrganizationUsageImagesResponseDataResultUnion() { +} +func (AdminOrganizationUsageImagesResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) implAdminOrganizationUsageImagesResponseDataResultUnion() { +} +func (AdminOrganizationUsageImagesResponseDataResultOrganizationUsageFileSearchesResult) implAdminOrganizationUsageImagesResponseDataResultUnion() { +} +func (AdminOrganizationUsageImagesResponseDataResultOrganizationUsageWebSearchesResult) implAdminOrganizationUsageImagesResponseDataResultUnion() { +} +func (AdminOrganizationUsageImagesResponseDataResultOrganizationCostsResult) implAdminOrganizationUsageImagesResponseDataResultUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := AdminOrganizationUsageImagesResponseDataResultUnion.AsAny().(type) { +// case openai.AdminOrganizationUsageImagesResponseDataResultOrganizationUsageCompletionsResult: +// case openai.AdminOrganizationUsageImagesResponseDataResultOrganizationUsageEmbeddingsResult: +// case openai.AdminOrganizationUsageImagesResponseDataResultOrganizationUsageModerationsResult: +// case openai.AdminOrganizationUsageImagesResponseDataResultOrganizationUsageImagesResult: +// case openai.AdminOrganizationUsageImagesResponseDataResultOrganizationUsageAudioSpeechesResult: +// case openai.AdminOrganizationUsageImagesResponseDataResultOrganizationUsageAudioTranscriptionsResult: +// case openai.AdminOrganizationUsageImagesResponseDataResultOrganizationUsageVectorStoresResult: +// case openai.AdminOrganizationUsageImagesResponseDataResultOrganizationUsageCodeInterpreterSessionsResult: +// case openai.AdminOrganizationUsageImagesResponseDataResultOrganizationUsageFileSearchesResult: +// case openai.AdminOrganizationUsageImagesResponseDataResultOrganizationUsageWebSearchesResult: +// case openai.AdminOrganizationUsageImagesResponseDataResultOrganizationCostsResult: +// default: +// fmt.Errorf("no variant present") +// } +func (u AdminOrganizationUsageImagesResponseDataResultUnion) AsAny() anyAdminOrganizationUsageImagesResponseDataResult { + switch u.Object { + case "organization.usage.completions.result": + return u.AsOrganizationUsageCompletionsResult() + case "organization.usage.embeddings.result": + return u.AsOrganizationUsageEmbeddingsResult() + case "organization.usage.moderations.result": + return u.AsOrganizationUsageModerationsResult() + case "organization.usage.images.result": + return u.AsOrganizationUsageImagesResult() + case "organization.usage.audio_speeches.result": + return u.AsOrganizationUsageAudioSpeechesResult() + case "organization.usage.audio_transcriptions.result": + return u.AsOrganizationUsageAudioTranscriptionsResult() + case "organization.usage.vector_stores.result": + return u.AsOrganizationUsageVectorStoresResult() + case "organization.usage.code_interpreter_sessions.result": + return u.AsOrganizationUsageCodeInterpreterSessionsResult() + case "organization.usage.file_searches.result": + return u.AsOrganizationUsageFileSearchesResult() + case "organization.usage.web_searches.result": + return u.AsOrganizationUsageWebSearchesResult() + case "organization.costs.result": + return u.AsOrganizationCostsResult() + } + return nil +} + +func (u AdminOrganizationUsageImagesResponseDataResultUnion) AsOrganizationUsageCompletionsResult() (v AdminOrganizationUsageImagesResponseDataResultOrganizationUsageCompletionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageImagesResponseDataResultUnion) AsOrganizationUsageEmbeddingsResult() (v AdminOrganizationUsageImagesResponseDataResultOrganizationUsageEmbeddingsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageImagesResponseDataResultUnion) AsOrganizationUsageModerationsResult() (v AdminOrganizationUsageImagesResponseDataResultOrganizationUsageModerationsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageImagesResponseDataResultUnion) AsOrganizationUsageImagesResult() (v AdminOrganizationUsageImagesResponseDataResultOrganizationUsageImagesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageImagesResponseDataResultUnion) AsOrganizationUsageAudioSpeechesResult() (v AdminOrganizationUsageImagesResponseDataResultOrganizationUsageAudioSpeechesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageImagesResponseDataResultUnion) AsOrganizationUsageAudioTranscriptionsResult() (v AdminOrganizationUsageImagesResponseDataResultOrganizationUsageAudioTranscriptionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageImagesResponseDataResultUnion) AsOrganizationUsageVectorStoresResult() (v AdminOrganizationUsageImagesResponseDataResultOrganizationUsageVectorStoresResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageImagesResponseDataResultUnion) AsOrganizationUsageCodeInterpreterSessionsResult() (v AdminOrganizationUsageImagesResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageImagesResponseDataResultUnion) AsOrganizationUsageFileSearchesResult() (v AdminOrganizationUsageImagesResponseDataResultOrganizationUsageFileSearchesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageImagesResponseDataResultUnion) AsOrganizationUsageWebSearchesResult() (v AdminOrganizationUsageImagesResponseDataResultOrganizationUsageWebSearchesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageImagesResponseDataResultUnion) AsOrganizationCostsResult() (v AdminOrganizationUsageImagesResponseDataResultOrganizationCostsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u AdminOrganizationUsageImagesResponseDataResultUnion) RawJSON() string { return u.JSON.raw } + +func (r *AdminOrganizationUsageImagesResponseDataResultUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated completions usage details of the specific time bucket. +type AdminOrganizationUsageImagesResponseDataResultOrganizationUsageCompletionsResult struct { + // The aggregated number of text input tokens used, including cached tokens. For + // customers subscribe to scale tier, this includes scale tier tokens. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageCompletionsResult `json:"object" default:"organization.usage.completions.result"` + // The aggregated number of text output tokens used. For customers subscribe to + // scale tier, this includes scale tier tokens. + OutputTokens int64 `json:"output_tokens" api:"required"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=batch`, this field tells whether the grouped usage result is + // batch or not. + Batch bool `json:"batch" api:"nullable"` + // The aggregated number of audio input tokens used, including cached tokens. + InputAudioTokens int64 `json:"input_audio_tokens"` + // The aggregated number of text input tokens that has been cached from previous + // requests. For customers subscribe to scale tier, this includes scale tier + // tokens. + InputCachedTokens int64 `json:"input_cached_tokens"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // The aggregated number of audio output tokens used. + OutputAudioTokens int64 `json:"output_audio_tokens"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=service_tier`, this field provides the service tier of the + // grouped usage result. + ServiceTier string `json:"service_tier" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + OutputTokens respjson.Field + APIKeyID respjson.Field + Batch respjson.Field + InputAudioTokens respjson.Field + InputCachedTokens respjson.Field + Model respjson.Field + OutputAudioTokens respjson.Field + ProjectID respjson.Field + ServiceTier respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageImagesResponseDataResultOrganizationUsageCompletionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageImagesResponseDataResultOrganizationUsageCompletionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated embeddings usage details of the specific time bucket. +type AdminOrganizationUsageImagesResponseDataResultOrganizationUsageEmbeddingsResult struct { + // The aggregated number of input tokens used. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageEmbeddingsResult `json:"object" default:"organization.usage.embeddings.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageImagesResponseDataResultOrganizationUsageEmbeddingsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageImagesResponseDataResultOrganizationUsageEmbeddingsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated moderations usage details of the specific time bucket. +type AdminOrganizationUsageImagesResponseDataResultOrganizationUsageModerationsResult struct { + // The aggregated number of input tokens used. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageModerationsResult `json:"object" default:"organization.usage.moderations.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageImagesResponseDataResultOrganizationUsageModerationsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageImagesResponseDataResultOrganizationUsageModerationsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated images usage details of the specific time bucket. +type AdminOrganizationUsageImagesResponseDataResultOrganizationUsageImagesResult struct { + // The number of images processed. + Images int64 `json:"images" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageImagesResult `json:"object" default:"organization.usage.images.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=size`, this field provides the image size of the grouped usage + // result. + Size string `json:"size" api:"nullable"` + // When `group_by=source`, this field provides the source of the grouped usage + // result, possible values are `image.generation`, `image.edit`, `image.variation`. + Source string `json:"source" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Images respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + Size respjson.Field + Source respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageImagesResponseDataResultOrganizationUsageImagesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageImagesResponseDataResultOrganizationUsageImagesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated audio speeches usage details of the specific time bucket. +type AdminOrganizationUsageImagesResponseDataResultOrganizationUsageAudioSpeechesResult struct { + // The number of characters processed. + Characters int64 `json:"characters" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageAudioSpeechesResult `json:"object" default:"organization.usage.audio_speeches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Characters respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageImagesResponseDataResultOrganizationUsageAudioSpeechesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageImagesResponseDataResultOrganizationUsageAudioSpeechesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated audio transcriptions usage details of the specific time bucket. +type AdminOrganizationUsageImagesResponseDataResultOrganizationUsageAudioTranscriptionsResult struct { + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageAudioTranscriptionsResult `json:"object" default:"organization.usage.audio_transcriptions.result"` + // The number of seconds processed. + Seconds int64 `json:"seconds" api:"required"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumModelRequests respjson.Field + Object respjson.Field + Seconds respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageImagesResponseDataResultOrganizationUsageAudioTranscriptionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageImagesResponseDataResultOrganizationUsageAudioTranscriptionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated vector stores usage details of the specific time bucket. +type AdminOrganizationUsageImagesResponseDataResultOrganizationUsageVectorStoresResult struct { + Object constant.OrganizationUsageVectorStoresResult `json:"object" default:"organization.usage.vector_stores.result"` + // The vector stores usage in bytes. + UsageBytes int64 `json:"usage_bytes" api:"required"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + UsageBytes respjson.Field + ProjectID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageImagesResponseDataResultOrganizationUsageVectorStoresResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageImagesResponseDataResultOrganizationUsageVectorStoresResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated code interpreter sessions usage details of the specific time +// bucket. +type AdminOrganizationUsageImagesResponseDataResultOrganizationUsageCodeInterpreterSessionsResult struct { + // The number of code interpreter sessions. + NumSessions int64 `json:"num_sessions" api:"required"` + Object constant.OrganizationUsageCodeInterpreterSessionsResult `json:"object" default:"organization.usage.code_interpreter_sessions.result"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumSessions respjson.Field + Object respjson.Field + ProjectID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageImagesResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageImagesResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated file search calls usage details of the specific time bucket. +type AdminOrganizationUsageImagesResponseDataResultOrganizationUsageFileSearchesResult struct { + // The count of file search calls. + NumRequests int64 `json:"num_requests" api:"required"` + Object constant.OrganizationUsageFileSearchesResult `json:"object" default:"organization.usage.file_searches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // When `group_by=vector_store_id`, this field provides the vector store ID of the + // grouped usage result. + VectorStoreID string `json:"vector_store_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + ProjectID respjson.Field + UserID respjson.Field + VectorStoreID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageImagesResponseDataResultOrganizationUsageFileSearchesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageImagesResponseDataResultOrganizationUsageFileSearchesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated web search calls usage details of the specific time bucket. +type AdminOrganizationUsageImagesResponseDataResultOrganizationUsageWebSearchesResult struct { + // The count of model requests. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + // The count of web search calls. + NumRequests int64 `json:"num_requests" api:"required"` + Object constant.OrganizationUsageWebSearchesResult `json:"object" default:"organization.usage.web_searches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=context_level`, this field provides the search context size of + // the grouped usage result. + ContextLevel string `json:"context_level" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumModelRequests respjson.Field + NumRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + ContextLevel respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageImagesResponseDataResultOrganizationUsageWebSearchesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageImagesResponseDataResultOrganizationUsageWebSearchesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated costs details of the specific time bucket. +type AdminOrganizationUsageImagesResponseDataResultOrganizationCostsResult struct { + Object constant.OrganizationCostsResult `json:"object" default:"organization.costs.result"` + // The monetary value in its associated currency. + Amount AdminOrganizationUsageImagesResponseDataResultOrganizationCostsResultAmount `json:"amount"` + // When `group_by=api_key_id`, this field provides the API Key ID of the grouped + // costs result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=line_item`, this field provides the line item of the grouped + // costs result. + LineItem string `json:"line_item" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // costs result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=line_item`, this field provides the quantity of the grouped costs + // result. + Quantity float64 `json:"quantity" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + Amount respjson.Field + APIKeyID respjson.Field + LineItem respjson.Field + ProjectID respjson.Field + Quantity respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageImagesResponseDataResultOrganizationCostsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageImagesResponseDataResultOrganizationCostsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The monetary value in its associated currency. +type AdminOrganizationUsageImagesResponseDataResultOrganizationCostsResultAmount struct { + // Lowercase ISO-4217 currency e.g. "usd" + Currency string `json:"currency"` + // The numeric value of the cost. + Value float64 `json:"value"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Currency respjson.Field + Value respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageImagesResponseDataResultOrganizationCostsResultAmount) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageImagesResponseDataResultOrganizationCostsResultAmount) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUsageModerationsResponse struct { + Data []AdminOrganizationUsageModerationsResponseData `json:"data" api:"required"` + HasMore bool `json:"has_more" api:"required"` + NextPage string `json:"next_page" api:"required"` + Object constant.Page `json:"object" default:"page"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Data respjson.Field + HasMore respjson.Field + NextPage respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageModerationsResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUsageModerationsResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUsageModerationsResponseData struct { + EndTime int64 `json:"end_time" api:"required"` + Object constant.Bucket `json:"object" default:"bucket"` + Results []AdminOrganizationUsageModerationsResponseDataResultUnion `json:"results" api:"required"` + StartTime int64 `json:"start_time" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + EndTime respjson.Field + Object respjson.Field + Results respjson.Field + StartTime respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageModerationsResponseData) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUsageModerationsResponseData) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// AdminOrganizationUsageModerationsResponseDataResultUnion contains all possible +// properties and values from +// [AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageCompletionsResult], +// [AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageEmbeddingsResult], +// [AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageModerationsResult], +// [AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageImagesResult], +// [AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageAudioSpeechesResult], +// [AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageAudioTranscriptionsResult], +// [AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageVectorStoresResult], +// [AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult], +// [AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageFileSearchesResult], +// [AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageWebSearchesResult], +// [AdminOrganizationUsageModerationsResponseDataResultOrganizationCostsResult]. +// +// Use the [AdminOrganizationUsageModerationsResponseDataResultUnion.AsAny] method +// to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type AdminOrganizationUsageModerationsResponseDataResultUnion struct { + InputTokens int64 `json:"input_tokens"` + NumModelRequests int64 `json:"num_model_requests"` + // Any of "organization.usage.completions.result", + // "organization.usage.embeddings.result", "organization.usage.moderations.result", + // "organization.usage.images.result", "organization.usage.audio_speeches.result", + // "organization.usage.audio_transcriptions.result", + // "organization.usage.vector_stores.result", + // "organization.usage.code_interpreter_sessions.result", + // "organization.usage.file_searches.result", + // "organization.usage.web_searches.result", "organization.costs.result". + Object string `json:"object"` + // This field is from variant + // [AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageCompletionsResult]. + OutputTokens int64 `json:"output_tokens"` + APIKeyID string `json:"api_key_id"` + // This field is from variant + // [AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageCompletionsResult]. + Batch bool `json:"batch"` + // This field is from variant + // [AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageCompletionsResult]. + InputAudioTokens int64 `json:"input_audio_tokens"` + // This field is from variant + // [AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageCompletionsResult]. + InputCachedTokens int64 `json:"input_cached_tokens"` + Model string `json:"model"` + // This field is from variant + // [AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageCompletionsResult]. + OutputAudioTokens int64 `json:"output_audio_tokens"` + ProjectID string `json:"project_id"` + // This field is from variant + // [AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageCompletionsResult]. + ServiceTier string `json:"service_tier"` + UserID string `json:"user_id"` + // This field is from variant + // [AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageImagesResult]. + Images int64 `json:"images"` + // This field is from variant + // [AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageImagesResult]. + Size string `json:"size"` + // This field is from variant + // [AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageImagesResult]. + Source string `json:"source"` + // This field is from variant + // [AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageAudioSpeechesResult]. + Characters int64 `json:"characters"` + // This field is from variant + // [AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageAudioTranscriptionsResult]. + Seconds int64 `json:"seconds"` + // This field is from variant + // [AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageVectorStoresResult]. + UsageBytes int64 `json:"usage_bytes"` + // This field is from variant + // [AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult]. + NumSessions int64 `json:"num_sessions"` + NumRequests int64 `json:"num_requests"` + // This field is from variant + // [AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageFileSearchesResult]. + VectorStoreID string `json:"vector_store_id"` + // This field is from variant + // [AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageWebSearchesResult]. + ContextLevel string `json:"context_level"` + // This field is from variant + // [AdminOrganizationUsageModerationsResponseDataResultOrganizationCostsResult]. + Amount AdminOrganizationUsageModerationsResponseDataResultOrganizationCostsResultAmount `json:"amount"` + // This field is from variant + // [AdminOrganizationUsageModerationsResponseDataResultOrganizationCostsResult]. + LineItem string `json:"line_item"` + // This field is from variant + // [AdminOrganizationUsageModerationsResponseDataResultOrganizationCostsResult]. + Quantity float64 `json:"quantity"` + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + OutputTokens respjson.Field + APIKeyID respjson.Field + Batch respjson.Field + InputAudioTokens respjson.Field + InputCachedTokens respjson.Field + Model respjson.Field + OutputAudioTokens respjson.Field + ProjectID respjson.Field + ServiceTier respjson.Field + UserID respjson.Field + Images respjson.Field + Size respjson.Field + Source respjson.Field + Characters respjson.Field + Seconds respjson.Field + UsageBytes respjson.Field + NumSessions respjson.Field + NumRequests respjson.Field + VectorStoreID respjson.Field + ContextLevel respjson.Field + Amount respjson.Field + LineItem respjson.Field + Quantity respjson.Field + raw string + } `json:"-"` +} + +// anyAdminOrganizationUsageModerationsResponseDataResult is implemented by each +// variant of [AdminOrganizationUsageModerationsResponseDataResultUnion] to add +// type safety for the return type of +// [AdminOrganizationUsageModerationsResponseDataResultUnion.AsAny] +type anyAdminOrganizationUsageModerationsResponseDataResult interface { + implAdminOrganizationUsageModerationsResponseDataResultUnion() +} + +func (AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageCompletionsResult) implAdminOrganizationUsageModerationsResponseDataResultUnion() { +} +func (AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageEmbeddingsResult) implAdminOrganizationUsageModerationsResponseDataResultUnion() { +} +func (AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageModerationsResult) implAdminOrganizationUsageModerationsResponseDataResultUnion() { +} +func (AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageImagesResult) implAdminOrganizationUsageModerationsResponseDataResultUnion() { +} +func (AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageAudioSpeechesResult) implAdminOrganizationUsageModerationsResponseDataResultUnion() { +} +func (AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageAudioTranscriptionsResult) implAdminOrganizationUsageModerationsResponseDataResultUnion() { +} +func (AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageVectorStoresResult) implAdminOrganizationUsageModerationsResponseDataResultUnion() { +} +func (AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) implAdminOrganizationUsageModerationsResponseDataResultUnion() { +} +func (AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageFileSearchesResult) implAdminOrganizationUsageModerationsResponseDataResultUnion() { +} +func (AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageWebSearchesResult) implAdminOrganizationUsageModerationsResponseDataResultUnion() { +} +func (AdminOrganizationUsageModerationsResponseDataResultOrganizationCostsResult) implAdminOrganizationUsageModerationsResponseDataResultUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := AdminOrganizationUsageModerationsResponseDataResultUnion.AsAny().(type) { +// case openai.AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageCompletionsResult: +// case openai.AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageEmbeddingsResult: +// case openai.AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageModerationsResult: +// case openai.AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageImagesResult: +// case openai.AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageAudioSpeechesResult: +// case openai.AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageAudioTranscriptionsResult: +// case openai.AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageVectorStoresResult: +// case openai.AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult: +// case openai.AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageFileSearchesResult: +// case openai.AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageWebSearchesResult: +// case openai.AdminOrganizationUsageModerationsResponseDataResultOrganizationCostsResult: +// default: +// fmt.Errorf("no variant present") +// } +func (u AdminOrganizationUsageModerationsResponseDataResultUnion) AsAny() anyAdminOrganizationUsageModerationsResponseDataResult { + switch u.Object { + case "organization.usage.completions.result": + return u.AsOrganizationUsageCompletionsResult() + case "organization.usage.embeddings.result": + return u.AsOrganizationUsageEmbeddingsResult() + case "organization.usage.moderations.result": + return u.AsOrganizationUsageModerationsResult() + case "organization.usage.images.result": + return u.AsOrganizationUsageImagesResult() + case "organization.usage.audio_speeches.result": + return u.AsOrganizationUsageAudioSpeechesResult() + case "organization.usage.audio_transcriptions.result": + return u.AsOrganizationUsageAudioTranscriptionsResult() + case "organization.usage.vector_stores.result": + return u.AsOrganizationUsageVectorStoresResult() + case "organization.usage.code_interpreter_sessions.result": + return u.AsOrganizationUsageCodeInterpreterSessionsResult() + case "organization.usage.file_searches.result": + return u.AsOrganizationUsageFileSearchesResult() + case "organization.usage.web_searches.result": + return u.AsOrganizationUsageWebSearchesResult() + case "organization.costs.result": + return u.AsOrganizationCostsResult() + } + return nil +} + +func (u AdminOrganizationUsageModerationsResponseDataResultUnion) AsOrganizationUsageCompletionsResult() (v AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageCompletionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageModerationsResponseDataResultUnion) AsOrganizationUsageEmbeddingsResult() (v AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageEmbeddingsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageModerationsResponseDataResultUnion) AsOrganizationUsageModerationsResult() (v AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageModerationsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageModerationsResponseDataResultUnion) AsOrganizationUsageImagesResult() (v AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageImagesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageModerationsResponseDataResultUnion) AsOrganizationUsageAudioSpeechesResult() (v AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageAudioSpeechesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageModerationsResponseDataResultUnion) AsOrganizationUsageAudioTranscriptionsResult() (v AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageAudioTranscriptionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageModerationsResponseDataResultUnion) AsOrganizationUsageVectorStoresResult() (v AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageVectorStoresResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageModerationsResponseDataResultUnion) AsOrganizationUsageCodeInterpreterSessionsResult() (v AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageModerationsResponseDataResultUnion) AsOrganizationUsageFileSearchesResult() (v AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageFileSearchesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageModerationsResponseDataResultUnion) AsOrganizationUsageWebSearchesResult() (v AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageWebSearchesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageModerationsResponseDataResultUnion) AsOrganizationCostsResult() (v AdminOrganizationUsageModerationsResponseDataResultOrganizationCostsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u AdminOrganizationUsageModerationsResponseDataResultUnion) RawJSON() string { return u.JSON.raw } + +func (r *AdminOrganizationUsageModerationsResponseDataResultUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated completions usage details of the specific time bucket. +type AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageCompletionsResult struct { + // The aggregated number of text input tokens used, including cached tokens. For + // customers subscribe to scale tier, this includes scale tier tokens. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageCompletionsResult `json:"object" default:"organization.usage.completions.result"` + // The aggregated number of text output tokens used. For customers subscribe to + // scale tier, this includes scale tier tokens. + OutputTokens int64 `json:"output_tokens" api:"required"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=batch`, this field tells whether the grouped usage result is + // batch or not. + Batch bool `json:"batch" api:"nullable"` + // The aggregated number of audio input tokens used, including cached tokens. + InputAudioTokens int64 `json:"input_audio_tokens"` + // The aggregated number of text input tokens that has been cached from previous + // requests. For customers subscribe to scale tier, this includes scale tier + // tokens. + InputCachedTokens int64 `json:"input_cached_tokens"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // The aggregated number of audio output tokens used. + OutputAudioTokens int64 `json:"output_audio_tokens"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=service_tier`, this field provides the service tier of the + // grouped usage result. + ServiceTier string `json:"service_tier" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + OutputTokens respjson.Field + APIKeyID respjson.Field + Batch respjson.Field + InputAudioTokens respjson.Field + InputCachedTokens respjson.Field + Model respjson.Field + OutputAudioTokens respjson.Field + ProjectID respjson.Field + ServiceTier respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageCompletionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageCompletionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated embeddings usage details of the specific time bucket. +type AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageEmbeddingsResult struct { + // The aggregated number of input tokens used. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageEmbeddingsResult `json:"object" default:"organization.usage.embeddings.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageEmbeddingsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageEmbeddingsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated moderations usage details of the specific time bucket. +type AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageModerationsResult struct { + // The aggregated number of input tokens used. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageModerationsResult `json:"object" default:"organization.usage.moderations.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageModerationsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageModerationsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated images usage details of the specific time bucket. +type AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageImagesResult struct { + // The number of images processed. + Images int64 `json:"images" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageImagesResult `json:"object" default:"organization.usage.images.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=size`, this field provides the image size of the grouped usage + // result. + Size string `json:"size" api:"nullable"` + // When `group_by=source`, this field provides the source of the grouped usage + // result, possible values are `image.generation`, `image.edit`, `image.variation`. + Source string `json:"source" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Images respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + Size respjson.Field + Source respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageImagesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageImagesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated audio speeches usage details of the specific time bucket. +type AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageAudioSpeechesResult struct { + // The number of characters processed. + Characters int64 `json:"characters" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageAudioSpeechesResult `json:"object" default:"organization.usage.audio_speeches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Characters respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageAudioSpeechesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageAudioSpeechesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated audio transcriptions usage details of the specific time bucket. +type AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageAudioTranscriptionsResult struct { + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageAudioTranscriptionsResult `json:"object" default:"organization.usage.audio_transcriptions.result"` + // The number of seconds processed. + Seconds int64 `json:"seconds" api:"required"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumModelRequests respjson.Field + Object respjson.Field + Seconds respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageAudioTranscriptionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageAudioTranscriptionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated vector stores usage details of the specific time bucket. +type AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageVectorStoresResult struct { + Object constant.OrganizationUsageVectorStoresResult `json:"object" default:"organization.usage.vector_stores.result"` + // The vector stores usage in bytes. + UsageBytes int64 `json:"usage_bytes" api:"required"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + UsageBytes respjson.Field + ProjectID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageVectorStoresResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageVectorStoresResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated code interpreter sessions usage details of the specific time +// bucket. +type AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult struct { + // The number of code interpreter sessions. + NumSessions int64 `json:"num_sessions" api:"required"` + Object constant.OrganizationUsageCodeInterpreterSessionsResult `json:"object" default:"organization.usage.code_interpreter_sessions.result"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumSessions respjson.Field + Object respjson.Field + ProjectID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated file search calls usage details of the specific time bucket. +type AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageFileSearchesResult struct { + // The count of file search calls. + NumRequests int64 `json:"num_requests" api:"required"` + Object constant.OrganizationUsageFileSearchesResult `json:"object" default:"organization.usage.file_searches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // When `group_by=vector_store_id`, this field provides the vector store ID of the + // grouped usage result. + VectorStoreID string `json:"vector_store_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + ProjectID respjson.Field + UserID respjson.Field + VectorStoreID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageFileSearchesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageFileSearchesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated web search calls usage details of the specific time bucket. +type AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageWebSearchesResult struct { + // The count of model requests. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + // The count of web search calls. + NumRequests int64 `json:"num_requests" api:"required"` + Object constant.OrganizationUsageWebSearchesResult `json:"object" default:"organization.usage.web_searches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=context_level`, this field provides the search context size of + // the grouped usage result. + ContextLevel string `json:"context_level" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumModelRequests respjson.Field + NumRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + ContextLevel respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageWebSearchesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageWebSearchesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated costs details of the specific time bucket. +type AdminOrganizationUsageModerationsResponseDataResultOrganizationCostsResult struct { + Object constant.OrganizationCostsResult `json:"object" default:"organization.costs.result"` + // The monetary value in its associated currency. + Amount AdminOrganizationUsageModerationsResponseDataResultOrganizationCostsResultAmount `json:"amount"` + // When `group_by=api_key_id`, this field provides the API Key ID of the grouped + // costs result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=line_item`, this field provides the line item of the grouped + // costs result. + LineItem string `json:"line_item" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // costs result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=line_item`, this field provides the quantity of the grouped costs + // result. + Quantity float64 `json:"quantity" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + Amount respjson.Field + APIKeyID respjson.Field + LineItem respjson.Field + ProjectID respjson.Field + Quantity respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageModerationsResponseDataResultOrganizationCostsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageModerationsResponseDataResultOrganizationCostsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The monetary value in its associated currency. +type AdminOrganizationUsageModerationsResponseDataResultOrganizationCostsResultAmount struct { + // Lowercase ISO-4217 currency e.g. "usd" + Currency string `json:"currency"` + // The numeric value of the cost. + Value float64 `json:"value"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Currency respjson.Field + Value respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageModerationsResponseDataResultOrganizationCostsResultAmount) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageModerationsResponseDataResultOrganizationCostsResultAmount) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUsageVectorStoresResponse struct { + Data []AdminOrganizationUsageVectorStoresResponseData `json:"data" api:"required"` + HasMore bool `json:"has_more" api:"required"` + NextPage string `json:"next_page" api:"required"` + Object constant.Page `json:"object" default:"page"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Data respjson.Field + HasMore respjson.Field + NextPage respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageVectorStoresResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUsageVectorStoresResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUsageVectorStoresResponseData struct { + EndTime int64 `json:"end_time" api:"required"` + Object constant.Bucket `json:"object" default:"bucket"` + Results []AdminOrganizationUsageVectorStoresResponseDataResultUnion `json:"results" api:"required"` + StartTime int64 `json:"start_time" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + EndTime respjson.Field + Object respjson.Field + Results respjson.Field + StartTime respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageVectorStoresResponseData) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUsageVectorStoresResponseData) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// AdminOrganizationUsageVectorStoresResponseDataResultUnion contains all possible +// properties and values from +// [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageCompletionsResult], +// [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageEmbeddingsResult], +// [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageModerationsResult], +// [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageImagesResult], +// [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageAudioSpeechesResult], +// [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageAudioTranscriptionsResult], +// [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageVectorStoresResult], +// [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageCodeInterpreterSessionsResult], +// [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageFileSearchesResult], +// [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageWebSearchesResult], +// [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationCostsResult]. +// +// Use the [AdminOrganizationUsageVectorStoresResponseDataResultUnion.AsAny] method +// to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type AdminOrganizationUsageVectorStoresResponseDataResultUnion struct { + InputTokens int64 `json:"input_tokens"` + NumModelRequests int64 `json:"num_model_requests"` + // Any of "organization.usage.completions.result", + // "organization.usage.embeddings.result", "organization.usage.moderations.result", + // "organization.usage.images.result", "organization.usage.audio_speeches.result", + // "organization.usage.audio_transcriptions.result", + // "organization.usage.vector_stores.result", + // "organization.usage.code_interpreter_sessions.result", + // "organization.usage.file_searches.result", + // "organization.usage.web_searches.result", "organization.costs.result". + Object string `json:"object"` + // This field is from variant + // [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageCompletionsResult]. + OutputTokens int64 `json:"output_tokens"` + APIKeyID string `json:"api_key_id"` + // This field is from variant + // [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageCompletionsResult]. + Batch bool `json:"batch"` + // This field is from variant + // [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageCompletionsResult]. + InputAudioTokens int64 `json:"input_audio_tokens"` + // This field is from variant + // [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageCompletionsResult]. + InputCachedTokens int64 `json:"input_cached_tokens"` + Model string `json:"model"` + // This field is from variant + // [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageCompletionsResult]. + OutputAudioTokens int64 `json:"output_audio_tokens"` + ProjectID string `json:"project_id"` + // This field is from variant + // [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageCompletionsResult]. + ServiceTier string `json:"service_tier"` + UserID string `json:"user_id"` + // This field is from variant + // [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageImagesResult]. + Images int64 `json:"images"` + // This field is from variant + // [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageImagesResult]. + Size string `json:"size"` + // This field is from variant + // [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageImagesResult]. + Source string `json:"source"` + // This field is from variant + // [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageAudioSpeechesResult]. + Characters int64 `json:"characters"` + // This field is from variant + // [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageAudioTranscriptionsResult]. + Seconds int64 `json:"seconds"` + // This field is from variant + // [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageVectorStoresResult]. + UsageBytes int64 `json:"usage_bytes"` + // This field is from variant + // [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageCodeInterpreterSessionsResult]. + NumSessions int64 `json:"num_sessions"` + NumRequests int64 `json:"num_requests"` + // This field is from variant + // [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageFileSearchesResult]. + VectorStoreID string `json:"vector_store_id"` + // This field is from variant + // [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageWebSearchesResult]. + ContextLevel string `json:"context_level"` + // This field is from variant + // [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationCostsResult]. + Amount AdminOrganizationUsageVectorStoresResponseDataResultOrganizationCostsResultAmount `json:"amount"` + // This field is from variant + // [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationCostsResult]. + LineItem string `json:"line_item"` + // This field is from variant + // [AdminOrganizationUsageVectorStoresResponseDataResultOrganizationCostsResult]. + Quantity float64 `json:"quantity"` + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + OutputTokens respjson.Field + APIKeyID respjson.Field + Batch respjson.Field + InputAudioTokens respjson.Field + InputCachedTokens respjson.Field + Model respjson.Field + OutputAudioTokens respjson.Field + ProjectID respjson.Field + ServiceTier respjson.Field + UserID respjson.Field + Images respjson.Field + Size respjson.Field + Source respjson.Field + Characters respjson.Field + Seconds respjson.Field + UsageBytes respjson.Field + NumSessions respjson.Field + NumRequests respjson.Field + VectorStoreID respjson.Field + ContextLevel respjson.Field + Amount respjson.Field + LineItem respjson.Field + Quantity respjson.Field + raw string + } `json:"-"` +} + +// anyAdminOrganizationUsageVectorStoresResponseDataResult is implemented by each +// variant of [AdminOrganizationUsageVectorStoresResponseDataResultUnion] to add +// type safety for the return type of +// [AdminOrganizationUsageVectorStoresResponseDataResultUnion.AsAny] +type anyAdminOrganizationUsageVectorStoresResponseDataResult interface { + implAdminOrganizationUsageVectorStoresResponseDataResultUnion() +} + +func (AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageCompletionsResult) implAdminOrganizationUsageVectorStoresResponseDataResultUnion() { +} +func (AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageEmbeddingsResult) implAdminOrganizationUsageVectorStoresResponseDataResultUnion() { +} +func (AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageModerationsResult) implAdminOrganizationUsageVectorStoresResponseDataResultUnion() { +} +func (AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageImagesResult) implAdminOrganizationUsageVectorStoresResponseDataResultUnion() { +} +func (AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageAudioSpeechesResult) implAdminOrganizationUsageVectorStoresResponseDataResultUnion() { +} +func (AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageAudioTranscriptionsResult) implAdminOrganizationUsageVectorStoresResponseDataResultUnion() { +} +func (AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageVectorStoresResult) implAdminOrganizationUsageVectorStoresResponseDataResultUnion() { +} +func (AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) implAdminOrganizationUsageVectorStoresResponseDataResultUnion() { +} +func (AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageFileSearchesResult) implAdminOrganizationUsageVectorStoresResponseDataResultUnion() { +} +func (AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageWebSearchesResult) implAdminOrganizationUsageVectorStoresResponseDataResultUnion() { +} +func (AdminOrganizationUsageVectorStoresResponseDataResultOrganizationCostsResult) implAdminOrganizationUsageVectorStoresResponseDataResultUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := AdminOrganizationUsageVectorStoresResponseDataResultUnion.AsAny().(type) { +// case openai.AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageCompletionsResult: +// case openai.AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageEmbeddingsResult: +// case openai.AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageModerationsResult: +// case openai.AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageImagesResult: +// case openai.AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageAudioSpeechesResult: +// case openai.AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageAudioTranscriptionsResult: +// case openai.AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageVectorStoresResult: +// case openai.AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageCodeInterpreterSessionsResult: +// case openai.AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageFileSearchesResult: +// case openai.AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageWebSearchesResult: +// case openai.AdminOrganizationUsageVectorStoresResponseDataResultOrganizationCostsResult: +// default: +// fmt.Errorf("no variant present") +// } +func (u AdminOrganizationUsageVectorStoresResponseDataResultUnion) AsAny() anyAdminOrganizationUsageVectorStoresResponseDataResult { + switch u.Object { + case "organization.usage.completions.result": + return u.AsOrganizationUsageCompletionsResult() + case "organization.usage.embeddings.result": + return u.AsOrganizationUsageEmbeddingsResult() + case "organization.usage.moderations.result": + return u.AsOrganizationUsageModerationsResult() + case "organization.usage.images.result": + return u.AsOrganizationUsageImagesResult() + case "organization.usage.audio_speeches.result": + return u.AsOrganizationUsageAudioSpeechesResult() + case "organization.usage.audio_transcriptions.result": + return u.AsOrganizationUsageAudioTranscriptionsResult() + case "organization.usage.vector_stores.result": + return u.AsOrganizationUsageVectorStoresResult() + case "organization.usage.code_interpreter_sessions.result": + return u.AsOrganizationUsageCodeInterpreterSessionsResult() + case "organization.usage.file_searches.result": + return u.AsOrganizationUsageFileSearchesResult() + case "organization.usage.web_searches.result": + return u.AsOrganizationUsageWebSearchesResult() + case "organization.costs.result": + return u.AsOrganizationCostsResult() + } + return nil +} + +func (u AdminOrganizationUsageVectorStoresResponseDataResultUnion) AsOrganizationUsageCompletionsResult() (v AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageCompletionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageVectorStoresResponseDataResultUnion) AsOrganizationUsageEmbeddingsResult() (v AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageEmbeddingsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageVectorStoresResponseDataResultUnion) AsOrganizationUsageModerationsResult() (v AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageModerationsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageVectorStoresResponseDataResultUnion) AsOrganizationUsageImagesResult() (v AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageImagesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageVectorStoresResponseDataResultUnion) AsOrganizationUsageAudioSpeechesResult() (v AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageAudioSpeechesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageVectorStoresResponseDataResultUnion) AsOrganizationUsageAudioTranscriptionsResult() (v AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageAudioTranscriptionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageVectorStoresResponseDataResultUnion) AsOrganizationUsageVectorStoresResult() (v AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageVectorStoresResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageVectorStoresResponseDataResultUnion) AsOrganizationUsageCodeInterpreterSessionsResult() (v AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageVectorStoresResponseDataResultUnion) AsOrganizationUsageFileSearchesResult() (v AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageFileSearchesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageVectorStoresResponseDataResultUnion) AsOrganizationUsageWebSearchesResult() (v AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageWebSearchesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageVectorStoresResponseDataResultUnion) AsOrganizationCostsResult() (v AdminOrganizationUsageVectorStoresResponseDataResultOrganizationCostsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u AdminOrganizationUsageVectorStoresResponseDataResultUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *AdminOrganizationUsageVectorStoresResponseDataResultUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated completions usage details of the specific time bucket. +type AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageCompletionsResult struct { + // The aggregated number of text input tokens used, including cached tokens. For + // customers subscribe to scale tier, this includes scale tier tokens. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageCompletionsResult `json:"object" default:"organization.usage.completions.result"` + // The aggregated number of text output tokens used. For customers subscribe to + // scale tier, this includes scale tier tokens. + OutputTokens int64 `json:"output_tokens" api:"required"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=batch`, this field tells whether the grouped usage result is + // batch or not. + Batch bool `json:"batch" api:"nullable"` + // The aggregated number of audio input tokens used, including cached tokens. + InputAudioTokens int64 `json:"input_audio_tokens"` + // The aggregated number of text input tokens that has been cached from previous + // requests. For customers subscribe to scale tier, this includes scale tier + // tokens. + InputCachedTokens int64 `json:"input_cached_tokens"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // The aggregated number of audio output tokens used. + OutputAudioTokens int64 `json:"output_audio_tokens"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=service_tier`, this field provides the service tier of the + // grouped usage result. + ServiceTier string `json:"service_tier" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + OutputTokens respjson.Field + APIKeyID respjson.Field + Batch respjson.Field + InputAudioTokens respjson.Field + InputCachedTokens respjson.Field + Model respjson.Field + OutputAudioTokens respjson.Field + ProjectID respjson.Field + ServiceTier respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageCompletionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageCompletionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated embeddings usage details of the specific time bucket. +type AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageEmbeddingsResult struct { + // The aggregated number of input tokens used. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageEmbeddingsResult `json:"object" default:"organization.usage.embeddings.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageEmbeddingsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageEmbeddingsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated moderations usage details of the specific time bucket. +type AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageModerationsResult struct { + // The aggregated number of input tokens used. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageModerationsResult `json:"object" default:"organization.usage.moderations.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageModerationsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageModerationsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated images usage details of the specific time bucket. +type AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageImagesResult struct { + // The number of images processed. + Images int64 `json:"images" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageImagesResult `json:"object" default:"organization.usage.images.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=size`, this field provides the image size of the grouped usage + // result. + Size string `json:"size" api:"nullable"` + // When `group_by=source`, this field provides the source of the grouped usage + // result, possible values are `image.generation`, `image.edit`, `image.variation`. + Source string `json:"source" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Images respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + Size respjson.Field + Source respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageImagesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageImagesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated audio speeches usage details of the specific time bucket. +type AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageAudioSpeechesResult struct { + // The number of characters processed. + Characters int64 `json:"characters" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageAudioSpeechesResult `json:"object" default:"organization.usage.audio_speeches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Characters respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageAudioSpeechesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageAudioSpeechesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated audio transcriptions usage details of the specific time bucket. +type AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageAudioTranscriptionsResult struct { + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageAudioTranscriptionsResult `json:"object" default:"organization.usage.audio_transcriptions.result"` + // The number of seconds processed. + Seconds int64 `json:"seconds" api:"required"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumModelRequests respjson.Field + Object respjson.Field + Seconds respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageAudioTranscriptionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageAudioTranscriptionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated vector stores usage details of the specific time bucket. +type AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageVectorStoresResult struct { + Object constant.OrganizationUsageVectorStoresResult `json:"object" default:"organization.usage.vector_stores.result"` + // The vector stores usage in bytes. + UsageBytes int64 `json:"usage_bytes" api:"required"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + UsageBytes respjson.Field + ProjectID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageVectorStoresResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageVectorStoresResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated code interpreter sessions usage details of the specific time +// bucket. +type AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageCodeInterpreterSessionsResult struct { + // The number of code interpreter sessions. + NumSessions int64 `json:"num_sessions" api:"required"` + Object constant.OrganizationUsageCodeInterpreterSessionsResult `json:"object" default:"organization.usage.code_interpreter_sessions.result"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumSessions respjson.Field + Object respjson.Field + ProjectID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated file search calls usage details of the specific time bucket. +type AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageFileSearchesResult struct { + // The count of file search calls. + NumRequests int64 `json:"num_requests" api:"required"` + Object constant.OrganizationUsageFileSearchesResult `json:"object" default:"organization.usage.file_searches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // When `group_by=vector_store_id`, this field provides the vector store ID of the + // grouped usage result. + VectorStoreID string `json:"vector_store_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + ProjectID respjson.Field + UserID respjson.Field + VectorStoreID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageFileSearchesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageFileSearchesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated web search calls usage details of the specific time bucket. +type AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageWebSearchesResult struct { + // The count of model requests. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + // The count of web search calls. + NumRequests int64 `json:"num_requests" api:"required"` + Object constant.OrganizationUsageWebSearchesResult `json:"object" default:"organization.usage.web_searches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=context_level`, this field provides the search context size of + // the grouped usage result. + ContextLevel string `json:"context_level" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumModelRequests respjson.Field + NumRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + ContextLevel respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageWebSearchesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageWebSearchesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated costs details of the specific time bucket. +type AdminOrganizationUsageVectorStoresResponseDataResultOrganizationCostsResult struct { + Object constant.OrganizationCostsResult `json:"object" default:"organization.costs.result"` + // The monetary value in its associated currency. + Amount AdminOrganizationUsageVectorStoresResponseDataResultOrganizationCostsResultAmount `json:"amount"` + // When `group_by=api_key_id`, this field provides the API Key ID of the grouped + // costs result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=line_item`, this field provides the line item of the grouped + // costs result. + LineItem string `json:"line_item" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // costs result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=line_item`, this field provides the quantity of the grouped costs + // result. + Quantity float64 `json:"quantity" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + Amount respjson.Field + APIKeyID respjson.Field + LineItem respjson.Field + ProjectID respjson.Field + Quantity respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageVectorStoresResponseDataResultOrganizationCostsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageVectorStoresResponseDataResultOrganizationCostsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The monetary value in its associated currency. +type AdminOrganizationUsageVectorStoresResponseDataResultOrganizationCostsResultAmount struct { + // Lowercase ISO-4217 currency e.g. "usd" + Currency string `json:"currency"` + // The numeric value of the cost. + Value float64 `json:"value"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Currency respjson.Field + Value respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageVectorStoresResponseDataResultOrganizationCostsResultAmount) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageVectorStoresResponseDataResultOrganizationCostsResultAmount) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUsageWebSearchCallsResponse struct { + Data []AdminOrganizationUsageWebSearchCallsResponseData `json:"data" api:"required"` + HasMore bool `json:"has_more" api:"required"` + NextPage string `json:"next_page" api:"required"` + Object constant.Page `json:"object" default:"page"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Data respjson.Field + HasMore respjson.Field + NextPage respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageWebSearchCallsResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUsageWebSearchCallsResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUsageWebSearchCallsResponseData struct { + EndTime int64 `json:"end_time" api:"required"` + Object constant.Bucket `json:"object" default:"bucket"` + Results []AdminOrganizationUsageWebSearchCallsResponseDataResultUnion `json:"results" api:"required"` + StartTime int64 `json:"start_time" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + EndTime respjson.Field + Object respjson.Field + Results respjson.Field + StartTime respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageWebSearchCallsResponseData) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUsageWebSearchCallsResponseData) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// AdminOrganizationUsageWebSearchCallsResponseDataResultUnion contains all +// possible properties and values from +// [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageCompletionsResult], +// [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageEmbeddingsResult], +// [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageModerationsResult], +// [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageImagesResult], +// [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageAudioSpeechesResult], +// [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageAudioTranscriptionsResult], +// [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageVectorStoresResult], +// [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult], +// [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageFileSearchesResult], +// [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageWebSearchesResult], +// [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationCostsResult]. +// +// Use the [AdminOrganizationUsageWebSearchCallsResponseDataResultUnion.AsAny] +// method to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type AdminOrganizationUsageWebSearchCallsResponseDataResultUnion struct { + InputTokens int64 `json:"input_tokens"` + NumModelRequests int64 `json:"num_model_requests"` + // Any of "organization.usage.completions.result", + // "organization.usage.embeddings.result", "organization.usage.moderations.result", + // "organization.usage.images.result", "organization.usage.audio_speeches.result", + // "organization.usage.audio_transcriptions.result", + // "organization.usage.vector_stores.result", + // "organization.usage.code_interpreter_sessions.result", + // "organization.usage.file_searches.result", + // "organization.usage.web_searches.result", "organization.costs.result". + Object string `json:"object"` + // This field is from variant + // [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageCompletionsResult]. + OutputTokens int64 `json:"output_tokens"` + APIKeyID string `json:"api_key_id"` + // This field is from variant + // [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageCompletionsResult]. + Batch bool `json:"batch"` + // This field is from variant + // [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageCompletionsResult]. + InputAudioTokens int64 `json:"input_audio_tokens"` + // This field is from variant + // [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageCompletionsResult]. + InputCachedTokens int64 `json:"input_cached_tokens"` + Model string `json:"model"` + // This field is from variant + // [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageCompletionsResult]. + OutputAudioTokens int64 `json:"output_audio_tokens"` + ProjectID string `json:"project_id"` + // This field is from variant + // [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageCompletionsResult]. + ServiceTier string `json:"service_tier"` + UserID string `json:"user_id"` + // This field is from variant + // [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageImagesResult]. + Images int64 `json:"images"` + // This field is from variant + // [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageImagesResult]. + Size string `json:"size"` + // This field is from variant + // [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageImagesResult]. + Source string `json:"source"` + // This field is from variant + // [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageAudioSpeechesResult]. + Characters int64 `json:"characters"` + // This field is from variant + // [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageAudioTranscriptionsResult]. + Seconds int64 `json:"seconds"` + // This field is from variant + // [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageVectorStoresResult]. + UsageBytes int64 `json:"usage_bytes"` + // This field is from variant + // [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult]. + NumSessions int64 `json:"num_sessions"` + NumRequests int64 `json:"num_requests"` + // This field is from variant + // [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageFileSearchesResult]. + VectorStoreID string `json:"vector_store_id"` + // This field is from variant + // [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageWebSearchesResult]. + ContextLevel string `json:"context_level"` + // This field is from variant + // [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationCostsResult]. + Amount AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationCostsResultAmount `json:"amount"` + // This field is from variant + // [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationCostsResult]. + LineItem string `json:"line_item"` + // This field is from variant + // [AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationCostsResult]. + Quantity float64 `json:"quantity"` + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + OutputTokens respjson.Field + APIKeyID respjson.Field + Batch respjson.Field + InputAudioTokens respjson.Field + InputCachedTokens respjson.Field + Model respjson.Field + OutputAudioTokens respjson.Field + ProjectID respjson.Field + ServiceTier respjson.Field + UserID respjson.Field + Images respjson.Field + Size respjson.Field + Source respjson.Field + Characters respjson.Field + Seconds respjson.Field + UsageBytes respjson.Field + NumSessions respjson.Field + NumRequests respjson.Field + VectorStoreID respjson.Field + ContextLevel respjson.Field + Amount respjson.Field + LineItem respjson.Field + Quantity respjson.Field + raw string + } `json:"-"` +} + +// anyAdminOrganizationUsageWebSearchCallsResponseDataResult is implemented by each +// variant of [AdminOrganizationUsageWebSearchCallsResponseDataResultUnion] to add +// type safety for the return type of +// [AdminOrganizationUsageWebSearchCallsResponseDataResultUnion.AsAny] +type anyAdminOrganizationUsageWebSearchCallsResponseDataResult interface { + implAdminOrganizationUsageWebSearchCallsResponseDataResultUnion() +} + +func (AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageCompletionsResult) implAdminOrganizationUsageWebSearchCallsResponseDataResultUnion() { +} +func (AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageEmbeddingsResult) implAdminOrganizationUsageWebSearchCallsResponseDataResultUnion() { +} +func (AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageModerationsResult) implAdminOrganizationUsageWebSearchCallsResponseDataResultUnion() { +} +func (AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageImagesResult) implAdminOrganizationUsageWebSearchCallsResponseDataResultUnion() { +} +func (AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageAudioSpeechesResult) implAdminOrganizationUsageWebSearchCallsResponseDataResultUnion() { +} +func (AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageAudioTranscriptionsResult) implAdminOrganizationUsageWebSearchCallsResponseDataResultUnion() { +} +func (AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageVectorStoresResult) implAdminOrganizationUsageWebSearchCallsResponseDataResultUnion() { +} +func (AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) implAdminOrganizationUsageWebSearchCallsResponseDataResultUnion() { +} +func (AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageFileSearchesResult) implAdminOrganizationUsageWebSearchCallsResponseDataResultUnion() { +} +func (AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageWebSearchesResult) implAdminOrganizationUsageWebSearchCallsResponseDataResultUnion() { +} +func (AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationCostsResult) implAdminOrganizationUsageWebSearchCallsResponseDataResultUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := AdminOrganizationUsageWebSearchCallsResponseDataResultUnion.AsAny().(type) { +// case openai.AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageCompletionsResult: +// case openai.AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageEmbeddingsResult: +// case openai.AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageModerationsResult: +// case openai.AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageImagesResult: +// case openai.AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageAudioSpeechesResult: +// case openai.AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageAudioTranscriptionsResult: +// case openai.AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageVectorStoresResult: +// case openai.AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult: +// case openai.AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageFileSearchesResult: +// case openai.AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageWebSearchesResult: +// case openai.AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationCostsResult: +// default: +// fmt.Errorf("no variant present") +// } +func (u AdminOrganizationUsageWebSearchCallsResponseDataResultUnion) AsAny() anyAdminOrganizationUsageWebSearchCallsResponseDataResult { + switch u.Object { + case "organization.usage.completions.result": + return u.AsOrganizationUsageCompletionsResult() + case "organization.usage.embeddings.result": + return u.AsOrganizationUsageEmbeddingsResult() + case "organization.usage.moderations.result": + return u.AsOrganizationUsageModerationsResult() + case "organization.usage.images.result": + return u.AsOrganizationUsageImagesResult() + case "organization.usage.audio_speeches.result": + return u.AsOrganizationUsageAudioSpeechesResult() + case "organization.usage.audio_transcriptions.result": + return u.AsOrganizationUsageAudioTranscriptionsResult() + case "organization.usage.vector_stores.result": + return u.AsOrganizationUsageVectorStoresResult() + case "organization.usage.code_interpreter_sessions.result": + return u.AsOrganizationUsageCodeInterpreterSessionsResult() + case "organization.usage.file_searches.result": + return u.AsOrganizationUsageFileSearchesResult() + case "organization.usage.web_searches.result": + return u.AsOrganizationUsageWebSearchesResult() + case "organization.costs.result": + return u.AsOrganizationCostsResult() + } + return nil +} + +func (u AdminOrganizationUsageWebSearchCallsResponseDataResultUnion) AsOrganizationUsageCompletionsResult() (v AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageCompletionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageWebSearchCallsResponseDataResultUnion) AsOrganizationUsageEmbeddingsResult() (v AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageEmbeddingsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageWebSearchCallsResponseDataResultUnion) AsOrganizationUsageModerationsResult() (v AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageModerationsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageWebSearchCallsResponseDataResultUnion) AsOrganizationUsageImagesResult() (v AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageImagesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageWebSearchCallsResponseDataResultUnion) AsOrganizationUsageAudioSpeechesResult() (v AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageAudioSpeechesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageWebSearchCallsResponseDataResultUnion) AsOrganizationUsageAudioTranscriptionsResult() (v AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageAudioTranscriptionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageWebSearchCallsResponseDataResultUnion) AsOrganizationUsageVectorStoresResult() (v AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageVectorStoresResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageWebSearchCallsResponseDataResultUnion) AsOrganizationUsageCodeInterpreterSessionsResult() (v AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageWebSearchCallsResponseDataResultUnion) AsOrganizationUsageFileSearchesResult() (v AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageFileSearchesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageWebSearchCallsResponseDataResultUnion) AsOrganizationUsageWebSearchesResult() (v AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageWebSearchesResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u AdminOrganizationUsageWebSearchCallsResponseDataResultUnion) AsOrganizationCostsResult() (v AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationCostsResult) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u AdminOrganizationUsageWebSearchCallsResponseDataResultUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *AdminOrganizationUsageWebSearchCallsResponseDataResultUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated completions usage details of the specific time bucket. +type AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageCompletionsResult struct { + // The aggregated number of text input tokens used, including cached tokens. For + // customers subscribe to scale tier, this includes scale tier tokens. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageCompletionsResult `json:"object" default:"organization.usage.completions.result"` + // The aggregated number of text output tokens used. For customers subscribe to + // scale tier, this includes scale tier tokens. + OutputTokens int64 `json:"output_tokens" api:"required"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=batch`, this field tells whether the grouped usage result is + // batch or not. + Batch bool `json:"batch" api:"nullable"` + // The aggregated number of audio input tokens used, including cached tokens. + InputAudioTokens int64 `json:"input_audio_tokens"` + // The aggregated number of text input tokens that has been cached from previous + // requests. For customers subscribe to scale tier, this includes scale tier + // tokens. + InputCachedTokens int64 `json:"input_cached_tokens"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // The aggregated number of audio output tokens used. + OutputAudioTokens int64 `json:"output_audio_tokens"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=service_tier`, this field provides the service tier of the + // grouped usage result. + ServiceTier string `json:"service_tier" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + OutputTokens respjson.Field + APIKeyID respjson.Field + Batch respjson.Field + InputAudioTokens respjson.Field + InputCachedTokens respjson.Field + Model respjson.Field + OutputAudioTokens respjson.Field + ProjectID respjson.Field + ServiceTier respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageCompletionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageCompletionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated embeddings usage details of the specific time bucket. +type AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageEmbeddingsResult struct { + // The aggregated number of input tokens used. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageEmbeddingsResult `json:"object" default:"organization.usage.embeddings.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageEmbeddingsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageEmbeddingsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated moderations usage details of the specific time bucket. +type AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageModerationsResult struct { + // The aggregated number of input tokens used. + InputTokens int64 `json:"input_tokens" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageModerationsResult `json:"object" default:"organization.usage.moderations.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageModerationsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageModerationsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated images usage details of the specific time bucket. +type AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageImagesResult struct { + // The number of images processed. + Images int64 `json:"images" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageImagesResult `json:"object" default:"organization.usage.images.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=size`, this field provides the image size of the grouped usage + // result. + Size string `json:"size" api:"nullable"` + // When `group_by=source`, this field provides the source of the grouped usage + // result, possible values are `image.generation`, `image.edit`, `image.variation`. + Source string `json:"source" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Images respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + Size respjson.Field + Source respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageImagesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageImagesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated audio speeches usage details of the specific time bucket. +type AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageAudioSpeechesResult struct { + // The number of characters processed. + Characters int64 `json:"characters" api:"required"` + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageAudioSpeechesResult `json:"object" default:"organization.usage.audio_speeches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Characters respjson.Field + NumModelRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageAudioSpeechesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageAudioSpeechesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated audio transcriptions usage details of the specific time bucket. +type AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageAudioTranscriptionsResult struct { + // The count of requests made to the model. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + Object constant.OrganizationUsageAudioTranscriptionsResult `json:"object" default:"organization.usage.audio_transcriptions.result"` + // The number of seconds processed. + Seconds int64 `json:"seconds" api:"required"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumModelRequests respjson.Field + Object respjson.Field + Seconds respjson.Field + APIKeyID respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageAudioTranscriptionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageAudioTranscriptionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated vector stores usage details of the specific time bucket. +type AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageVectorStoresResult struct { + Object constant.OrganizationUsageVectorStoresResult `json:"object" default:"organization.usage.vector_stores.result"` + // The vector stores usage in bytes. + UsageBytes int64 `json:"usage_bytes" api:"required"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + UsageBytes respjson.Field + ProjectID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageVectorStoresResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageVectorStoresResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated code interpreter sessions usage details of the specific time +// bucket. +type AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult struct { + // The number of code interpreter sessions. + NumSessions int64 `json:"num_sessions" api:"required"` + Object constant.OrganizationUsageCodeInterpreterSessionsResult `json:"object" default:"organization.usage.code_interpreter_sessions.result"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumSessions respjson.Field + Object respjson.Field + ProjectID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated file search calls usage details of the specific time bucket. +type AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageFileSearchesResult struct { + // The count of file search calls. + NumRequests int64 `json:"num_requests" api:"required"` + Object constant.OrganizationUsageFileSearchesResult `json:"object" default:"organization.usage.file_searches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // When `group_by=vector_store_id`, this field provides the vector store ID of the + // grouped usage result. + VectorStoreID string `json:"vector_store_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + ProjectID respjson.Field + UserID respjson.Field + VectorStoreID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageFileSearchesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageFileSearchesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated web search calls usage details of the specific time bucket. +type AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageWebSearchesResult struct { + // The count of model requests. + NumModelRequests int64 `json:"num_model_requests" api:"required"` + // The count of web search calls. + NumRequests int64 `json:"num_requests" api:"required"` + Object constant.OrganizationUsageWebSearchesResult `json:"object" default:"organization.usage.web_searches.result"` + // When `group_by=api_key_id`, this field provides the API key ID of the grouped + // usage result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=context_level`, this field provides the search context size of + // the grouped usage result. + ContextLevel string `json:"context_level" api:"nullable"` + // When `group_by=model`, this field provides the model name of the grouped usage + // result. + Model string `json:"model" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // usage result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=user_id`, this field provides the user ID of the grouped usage + // result. + UserID string `json:"user_id" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + NumModelRequests respjson.Field + NumRequests respjson.Field + Object respjson.Field + APIKeyID respjson.Field + ContextLevel respjson.Field + Model respjson.Field + ProjectID respjson.Field + UserID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageWebSearchesResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationUsageWebSearchesResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The aggregated costs details of the specific time bucket. +type AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationCostsResult struct { + Object constant.OrganizationCostsResult `json:"object" default:"organization.costs.result"` + // The monetary value in its associated currency. + Amount AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationCostsResultAmount `json:"amount"` + // When `group_by=api_key_id`, this field provides the API Key ID of the grouped + // costs result. + APIKeyID string `json:"api_key_id" api:"nullable"` + // When `group_by=line_item`, this field provides the line item of the grouped + // costs result. + LineItem string `json:"line_item" api:"nullable"` + // When `group_by=project_id`, this field provides the project ID of the grouped + // costs result. + ProjectID string `json:"project_id" api:"nullable"` + // When `group_by=line_item`, this field provides the quantity of the grouped costs + // result. + Quantity float64 `json:"quantity" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + Amount respjson.Field + APIKeyID respjson.Field + LineItem respjson.Field + ProjectID respjson.Field + Quantity respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationCostsResult) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationCostsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// The monetary value in its associated currency. +type AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationCostsResultAmount struct { + // Lowercase ISO-4217 currency e.g. "usd" + Currency string `json:"currency"` + // The numeric value of the cost. + Value float64 `json:"value"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Currency respjson.Field + Value respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationCostsResultAmount) RawJSON() string { + return r.JSON.raw +} +func (r *AdminOrganizationUsageWebSearchCallsResponseDataResultOrganizationCostsResultAmount) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUsageAudioSpeechesParams struct { + // Start time (Unix seconds) of the query time range, inclusive. + StartTime int64 `query:"start_time" api:"required" json:"-"` + // End time (Unix seconds) of the query time range, exclusive. + EndTime param.Opt[int64] `query:"end_time,omitzero" json:"-"` + // Specifies the number of buckets to return. + // + // - `bucket_width=1d`: default: 7, max: 31 + // - `bucket_width=1h`: default: 24, max: 168 + // - `bucket_width=1m`: default: 60, max: 1440 + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + // A cursor for use in pagination. Corresponding to the `next_page` field from the + // previous response. + Page param.Opt[string] `query:"page,omitzero" json:"-"` + // Return only usage for these API keys. + APIKeyIDs []string `query:"api_key_ids,omitzero" json:"-"` + // Width of each time bucket in response. Currently `1m`, `1h` and `1d` are + // supported, default to `1d`. + // + // Any of "1m", "1h", "1d". + BucketWidth AdminOrganizationUsageAudioSpeechesParamsBucketWidth `query:"bucket_width,omitzero" json:"-"` + // Group the usage data by the specified fields. Support fields include + // `project_id`, `user_id`, `api_key_id`, `model` or any combination of them. + // + // Any of "project_id", "user_id", "api_key_id", "model". + GroupBy []string `query:"group_by,omitzero" json:"-"` + // Return only usage for these models. + Models []string `query:"models,omitzero" json:"-"` + // Return only usage for these projects. + ProjectIDs []string `query:"project_ids,omitzero" json:"-"` + // Return only usage for these users. + UserIDs []string `query:"user_ids,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationUsageAudioSpeechesParams]'s query +// parameters as `url.Values`. +func (r AdminOrganizationUsageAudioSpeechesParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Width of each time bucket in response. Currently `1m`, `1h` and `1d` are +// supported, default to `1d`. +type AdminOrganizationUsageAudioSpeechesParamsBucketWidth string + +const ( + AdminOrganizationUsageAudioSpeechesParamsBucketWidth1m AdminOrganizationUsageAudioSpeechesParamsBucketWidth = "1m" + AdminOrganizationUsageAudioSpeechesParamsBucketWidth1h AdminOrganizationUsageAudioSpeechesParamsBucketWidth = "1h" + AdminOrganizationUsageAudioSpeechesParamsBucketWidth1d AdminOrganizationUsageAudioSpeechesParamsBucketWidth = "1d" +) + +type AdminOrganizationUsageAudioTranscriptionsParams struct { + // Start time (Unix seconds) of the query time range, inclusive. + StartTime int64 `query:"start_time" api:"required" json:"-"` + // End time (Unix seconds) of the query time range, exclusive. + EndTime param.Opt[int64] `query:"end_time,omitzero" json:"-"` + // Specifies the number of buckets to return. + // + // - `bucket_width=1d`: default: 7, max: 31 + // - `bucket_width=1h`: default: 24, max: 168 + // - `bucket_width=1m`: default: 60, max: 1440 + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + // A cursor for use in pagination. Corresponding to the `next_page` field from the + // previous response. + Page param.Opt[string] `query:"page,omitzero" json:"-"` + // Return only usage for these API keys. + APIKeyIDs []string `query:"api_key_ids,omitzero" json:"-"` + // Width of each time bucket in response. Currently `1m`, `1h` and `1d` are + // supported, default to `1d`. + // + // Any of "1m", "1h", "1d". + BucketWidth AdminOrganizationUsageAudioTranscriptionsParamsBucketWidth `query:"bucket_width,omitzero" json:"-"` + // Group the usage data by the specified fields. Support fields include + // `project_id`, `user_id`, `api_key_id`, `model` or any combination of them. + // + // Any of "project_id", "user_id", "api_key_id", "model". + GroupBy []string `query:"group_by,omitzero" json:"-"` + // Return only usage for these models. + Models []string `query:"models,omitzero" json:"-"` + // Return only usage for these projects. + ProjectIDs []string `query:"project_ids,omitzero" json:"-"` + // Return only usage for these users. + UserIDs []string `query:"user_ids,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationUsageAudioTranscriptionsParams]'s query +// parameters as `url.Values`. +func (r AdminOrganizationUsageAudioTranscriptionsParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Width of each time bucket in response. Currently `1m`, `1h` and `1d` are +// supported, default to `1d`. +type AdminOrganizationUsageAudioTranscriptionsParamsBucketWidth string + +const ( + AdminOrganizationUsageAudioTranscriptionsParamsBucketWidth1m AdminOrganizationUsageAudioTranscriptionsParamsBucketWidth = "1m" + AdminOrganizationUsageAudioTranscriptionsParamsBucketWidth1h AdminOrganizationUsageAudioTranscriptionsParamsBucketWidth = "1h" + AdminOrganizationUsageAudioTranscriptionsParamsBucketWidth1d AdminOrganizationUsageAudioTranscriptionsParamsBucketWidth = "1d" +) + +type AdminOrganizationUsageCodeInterpreterSessionsParams struct { + // Start time (Unix seconds) of the query time range, inclusive. + StartTime int64 `query:"start_time" api:"required" json:"-"` + // End time (Unix seconds) of the query time range, exclusive. + EndTime param.Opt[int64] `query:"end_time,omitzero" json:"-"` + // Specifies the number of buckets to return. + // + // - `bucket_width=1d`: default: 7, max: 31 + // - `bucket_width=1h`: default: 24, max: 168 + // - `bucket_width=1m`: default: 60, max: 1440 + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + // A cursor for use in pagination. Corresponding to the `next_page` field from the + // previous response. + Page param.Opt[string] `query:"page,omitzero" json:"-"` + // Width of each time bucket in response. Currently `1m`, `1h` and `1d` are + // supported, default to `1d`. + // + // Any of "1m", "1h", "1d". + BucketWidth AdminOrganizationUsageCodeInterpreterSessionsParamsBucketWidth `query:"bucket_width,omitzero" json:"-"` + // Group the usage data by the specified fields. Support fields include + // `project_id`. + // + // Any of "project_id". + GroupBy []string `query:"group_by,omitzero" json:"-"` + // Return only usage for these projects. + ProjectIDs []string `query:"project_ids,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationUsageCodeInterpreterSessionsParams]'s +// query parameters as `url.Values`. +func (r AdminOrganizationUsageCodeInterpreterSessionsParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Width of each time bucket in response. Currently `1m`, `1h` and `1d` are +// supported, default to `1d`. +type AdminOrganizationUsageCodeInterpreterSessionsParamsBucketWidth string + +const ( + AdminOrganizationUsageCodeInterpreterSessionsParamsBucketWidth1m AdminOrganizationUsageCodeInterpreterSessionsParamsBucketWidth = "1m" + AdminOrganizationUsageCodeInterpreterSessionsParamsBucketWidth1h AdminOrganizationUsageCodeInterpreterSessionsParamsBucketWidth = "1h" + AdminOrganizationUsageCodeInterpreterSessionsParamsBucketWidth1d AdminOrganizationUsageCodeInterpreterSessionsParamsBucketWidth = "1d" +) + +type AdminOrganizationUsageCompletionsParams struct { + // Start time (Unix seconds) of the query time range, inclusive. + StartTime int64 `query:"start_time" api:"required" json:"-"` + // If `true`, return batch jobs only. If `false`, return non-batch jobs only. By + // default, return both. + Batch param.Opt[bool] `query:"batch,omitzero" json:"-"` + // End time (Unix seconds) of the query time range, exclusive. + EndTime param.Opt[int64] `query:"end_time,omitzero" json:"-"` + // Specifies the number of buckets to return. + // + // - `bucket_width=1d`: default: 7, max: 31 + // - `bucket_width=1h`: default: 24, max: 168 + // - `bucket_width=1m`: default: 60, max: 1440 + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + // A cursor for use in pagination. Corresponding to the `next_page` field from the + // previous response. + Page param.Opt[string] `query:"page,omitzero" json:"-"` + // Return only usage for these API keys. + APIKeyIDs []string `query:"api_key_ids,omitzero" json:"-"` + // Width of each time bucket in response. Currently `1m`, `1h` and `1d` are + // supported, default to `1d`. + // + // Any of "1m", "1h", "1d". + BucketWidth AdminOrganizationUsageCompletionsParamsBucketWidth `query:"bucket_width,omitzero" json:"-"` + // Group the usage data by the specified fields. Support fields include + // `project_id`, `user_id`, `api_key_id`, `model`, `batch`, `service_tier` or any + // combination of them. + // + // Any of "project_id", "user_id", "api_key_id", "model", "batch", "service_tier". + GroupBy []string `query:"group_by,omitzero" json:"-"` + // Return only usage for these models. + Models []string `query:"models,omitzero" json:"-"` + // Return only usage for these projects. + ProjectIDs []string `query:"project_ids,omitzero" json:"-"` + // Return only usage for these users. + UserIDs []string `query:"user_ids,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationUsageCompletionsParams]'s query parameters +// as `url.Values`. +func (r AdminOrganizationUsageCompletionsParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Width of each time bucket in response. Currently `1m`, `1h` and `1d` are +// supported, default to `1d`. +type AdminOrganizationUsageCompletionsParamsBucketWidth string + +const ( + AdminOrganizationUsageCompletionsParamsBucketWidth1m AdminOrganizationUsageCompletionsParamsBucketWidth = "1m" + AdminOrganizationUsageCompletionsParamsBucketWidth1h AdminOrganizationUsageCompletionsParamsBucketWidth = "1h" + AdminOrganizationUsageCompletionsParamsBucketWidth1d AdminOrganizationUsageCompletionsParamsBucketWidth = "1d" +) + +type AdminOrganizationUsageCostsParams struct { + // Start time (Unix seconds) of the query time range, inclusive. + StartTime int64 `query:"start_time" api:"required" json:"-"` + // End time (Unix seconds) of the query time range, exclusive. + EndTime param.Opt[int64] `query:"end_time,omitzero" json:"-"` + // A limit on the number of buckets to be returned. Limit can range between 1 and + // 180, and the default is 7. + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + // A cursor for use in pagination. Corresponding to the `next_page` field from the + // previous response. + Page param.Opt[string] `query:"page,omitzero" json:"-"` + // Return only costs for these API keys. + APIKeyIDs []string `query:"api_key_ids,omitzero" json:"-"` + // Width of each time bucket in response. Currently only `1d` is supported, default + // to `1d`. + // + // Any of "1d". + BucketWidth AdminOrganizationUsageCostsParamsBucketWidth `query:"bucket_width,omitzero" json:"-"` + // Group the costs by the specified fields. Support fields include `project_id`, + // `line_item`, `api_key_id` and any combination of them. + // + // Any of "project_id", "line_item", "api_key_id". + GroupBy []string `query:"group_by,omitzero" json:"-"` + // Return only costs for these projects. + ProjectIDs []string `query:"project_ids,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationUsageCostsParams]'s query parameters as +// `url.Values`. +func (r AdminOrganizationUsageCostsParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Width of each time bucket in response. Currently only `1d` is supported, default +// to `1d`. +type AdminOrganizationUsageCostsParamsBucketWidth string + +const ( + AdminOrganizationUsageCostsParamsBucketWidth1d AdminOrganizationUsageCostsParamsBucketWidth = "1d" +) + +type AdminOrganizationUsageEmbeddingsParams struct { + // Start time (Unix seconds) of the query time range, inclusive. + StartTime int64 `query:"start_time" api:"required" json:"-"` + // End time (Unix seconds) of the query time range, exclusive. + EndTime param.Opt[int64] `query:"end_time,omitzero" json:"-"` + // Specifies the number of buckets to return. + // + // - `bucket_width=1d`: default: 7, max: 31 + // - `bucket_width=1h`: default: 24, max: 168 + // - `bucket_width=1m`: default: 60, max: 1440 + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + // A cursor for use in pagination. Corresponding to the `next_page` field from the + // previous response. + Page param.Opt[string] `query:"page,omitzero" json:"-"` + // Return only usage for these API keys. + APIKeyIDs []string `query:"api_key_ids,omitzero" json:"-"` + // Width of each time bucket in response. Currently `1m`, `1h` and `1d` are + // supported, default to `1d`. + // + // Any of "1m", "1h", "1d". + BucketWidth AdminOrganizationUsageEmbeddingsParamsBucketWidth `query:"bucket_width,omitzero" json:"-"` + // Group the usage data by the specified fields. Support fields include + // `project_id`, `user_id`, `api_key_id`, `model` or any combination of them. + // + // Any of "project_id", "user_id", "api_key_id", "model". + GroupBy []string `query:"group_by,omitzero" json:"-"` + // Return only usage for these models. + Models []string `query:"models,omitzero" json:"-"` + // Return only usage for these projects. + ProjectIDs []string `query:"project_ids,omitzero" json:"-"` + // Return only usage for these users. + UserIDs []string `query:"user_ids,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationUsageEmbeddingsParams]'s query parameters +// as `url.Values`. +func (r AdminOrganizationUsageEmbeddingsParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Width of each time bucket in response. Currently `1m`, `1h` and `1d` are +// supported, default to `1d`. +type AdminOrganizationUsageEmbeddingsParamsBucketWidth string + +const ( + AdminOrganizationUsageEmbeddingsParamsBucketWidth1m AdminOrganizationUsageEmbeddingsParamsBucketWidth = "1m" + AdminOrganizationUsageEmbeddingsParamsBucketWidth1h AdminOrganizationUsageEmbeddingsParamsBucketWidth = "1h" + AdminOrganizationUsageEmbeddingsParamsBucketWidth1d AdminOrganizationUsageEmbeddingsParamsBucketWidth = "1d" +) + +type AdminOrganizationUsageFileSearchCallsParams struct { + // Start time (Unix seconds) of the query time range, inclusive. + StartTime int64 `query:"start_time" api:"required" json:"-"` + // End time (Unix seconds) of the query time range, exclusive. + EndTime param.Opt[int64] `query:"end_time,omitzero" json:"-"` + // Specifies the number of buckets to return. + // + // - `bucket_width=1d`: default: 7, max: 31 + // - `bucket_width=1h`: default: 24, max: 168 + // - `bucket_width=1m`: default: 60, max: 1440 + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + // A cursor for use in pagination. Corresponding to the `next_page` field from the + // previous response. + Page param.Opt[string] `query:"page,omitzero" json:"-"` + // Return only usage for these API keys. + APIKeyIDs []string `query:"api_key_ids,omitzero" json:"-"` + // Width of each time bucket in response. Currently `1m`, `1h` and `1d` are + // supported, default to `1d`. + // + // Any of "1m", "1h", "1d". + BucketWidth AdminOrganizationUsageFileSearchCallsParamsBucketWidth `query:"bucket_width,omitzero" json:"-"` + // Group the usage data by the specified fields. Support fields include + // `project_id`, `user_id`, `api_key_id`, `vector_store_id` or any combination of + // them. + // + // Any of "project_id", "user_id", "api_key_id", "vector_store_id". + GroupBy []string `query:"group_by,omitzero" json:"-"` + // Return only usage for these projects. + ProjectIDs []string `query:"project_ids,omitzero" json:"-"` + // Return only usage for these users. + UserIDs []string `query:"user_ids,omitzero" json:"-"` + // Return only usage for these vector stores. + VectorStoreIDs []string `query:"vector_store_ids,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationUsageFileSearchCallsParams]'s query +// parameters as `url.Values`. +func (r AdminOrganizationUsageFileSearchCallsParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Width of each time bucket in response. Currently `1m`, `1h` and `1d` are +// supported, default to `1d`. +type AdminOrganizationUsageFileSearchCallsParamsBucketWidth string + +const ( + AdminOrganizationUsageFileSearchCallsParamsBucketWidth1m AdminOrganizationUsageFileSearchCallsParamsBucketWidth = "1m" + AdminOrganizationUsageFileSearchCallsParamsBucketWidth1h AdminOrganizationUsageFileSearchCallsParamsBucketWidth = "1h" + AdminOrganizationUsageFileSearchCallsParamsBucketWidth1d AdminOrganizationUsageFileSearchCallsParamsBucketWidth = "1d" +) + +type AdminOrganizationUsageImagesParams struct { + // Start time (Unix seconds) of the query time range, inclusive. + StartTime int64 `query:"start_time" api:"required" json:"-"` + // End time (Unix seconds) of the query time range, exclusive. + EndTime param.Opt[int64] `query:"end_time,omitzero" json:"-"` + // Specifies the number of buckets to return. + // + // - `bucket_width=1d`: default: 7, max: 31 + // - `bucket_width=1h`: default: 24, max: 168 + // - `bucket_width=1m`: default: 60, max: 1440 + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + // A cursor for use in pagination. Corresponding to the `next_page` field from the + // previous response. + Page param.Opt[string] `query:"page,omitzero" json:"-"` + // Return only usage for these API keys. + APIKeyIDs []string `query:"api_key_ids,omitzero" json:"-"` + // Width of each time bucket in response. Currently `1m`, `1h` and `1d` are + // supported, default to `1d`. + // + // Any of "1m", "1h", "1d". + BucketWidth AdminOrganizationUsageImagesParamsBucketWidth `query:"bucket_width,omitzero" json:"-"` + // Group the usage data by the specified fields. Support fields include + // `project_id`, `user_id`, `api_key_id`, `model`, `size`, `source` or any + // combination of them. + // + // Any of "project_id", "user_id", "api_key_id", "model", "size", "source". + GroupBy []string `query:"group_by,omitzero" json:"-"` + // Return only usage for these models. + Models []string `query:"models,omitzero" json:"-"` + // Return only usage for these projects. + ProjectIDs []string `query:"project_ids,omitzero" json:"-"` + // Return only usages for these image sizes. Possible values are `256x256`, + // `512x512`, `1024x1024`, `1792x1792`, `1024x1792` or any combination of them. + // + // Any of "256x256", "512x512", "1024x1024", "1792x1792", "1024x1792". + Sizes []string `query:"sizes,omitzero" json:"-"` + // Return only usages for these sources. Possible values are `image.generation`, + // `image.edit`, `image.variation` or any combination of them. + // + // Any of "image.generation", "image.edit", "image.variation". + Sources []string `query:"sources,omitzero" json:"-"` + // Return only usage for these users. + UserIDs []string `query:"user_ids,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationUsageImagesParams]'s query parameters as +// `url.Values`. +func (r AdminOrganizationUsageImagesParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Width of each time bucket in response. Currently `1m`, `1h` and `1d` are +// supported, default to `1d`. +type AdminOrganizationUsageImagesParamsBucketWidth string + +const ( + AdminOrganizationUsageImagesParamsBucketWidth1m AdminOrganizationUsageImagesParamsBucketWidth = "1m" + AdminOrganizationUsageImagesParamsBucketWidth1h AdminOrganizationUsageImagesParamsBucketWidth = "1h" + AdminOrganizationUsageImagesParamsBucketWidth1d AdminOrganizationUsageImagesParamsBucketWidth = "1d" +) + +type AdminOrganizationUsageModerationsParams struct { + // Start time (Unix seconds) of the query time range, inclusive. + StartTime int64 `query:"start_time" api:"required" json:"-"` + // End time (Unix seconds) of the query time range, exclusive. + EndTime param.Opt[int64] `query:"end_time,omitzero" json:"-"` + // Specifies the number of buckets to return. + // + // - `bucket_width=1d`: default: 7, max: 31 + // - `bucket_width=1h`: default: 24, max: 168 + // - `bucket_width=1m`: default: 60, max: 1440 + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + // A cursor for use in pagination. Corresponding to the `next_page` field from the + // previous response. + Page param.Opt[string] `query:"page,omitzero" json:"-"` + // Return only usage for these API keys. + APIKeyIDs []string `query:"api_key_ids,omitzero" json:"-"` + // Width of each time bucket in response. Currently `1m`, `1h` and `1d` are + // supported, default to `1d`. + // + // Any of "1m", "1h", "1d". + BucketWidth AdminOrganizationUsageModerationsParamsBucketWidth `query:"bucket_width,omitzero" json:"-"` + // Group the usage data by the specified fields. Support fields include + // `project_id`, `user_id`, `api_key_id`, `model` or any combination of them. + // + // Any of "project_id", "user_id", "api_key_id", "model". + GroupBy []string `query:"group_by,omitzero" json:"-"` + // Return only usage for these models. + Models []string `query:"models,omitzero" json:"-"` + // Return only usage for these projects. + ProjectIDs []string `query:"project_ids,omitzero" json:"-"` + // Return only usage for these users. + UserIDs []string `query:"user_ids,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationUsageModerationsParams]'s query parameters +// as `url.Values`. +func (r AdminOrganizationUsageModerationsParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Width of each time bucket in response. Currently `1m`, `1h` and `1d` are +// supported, default to `1d`. +type AdminOrganizationUsageModerationsParamsBucketWidth string + +const ( + AdminOrganizationUsageModerationsParamsBucketWidth1m AdminOrganizationUsageModerationsParamsBucketWidth = "1m" + AdminOrganizationUsageModerationsParamsBucketWidth1h AdminOrganizationUsageModerationsParamsBucketWidth = "1h" + AdminOrganizationUsageModerationsParamsBucketWidth1d AdminOrganizationUsageModerationsParamsBucketWidth = "1d" +) + +type AdminOrganizationUsageVectorStoresParams struct { + // Start time (Unix seconds) of the query time range, inclusive. + StartTime int64 `query:"start_time" api:"required" json:"-"` + // End time (Unix seconds) of the query time range, exclusive. + EndTime param.Opt[int64] `query:"end_time,omitzero" json:"-"` + // Specifies the number of buckets to return. + // + // - `bucket_width=1d`: default: 7, max: 31 + // - `bucket_width=1h`: default: 24, max: 168 + // - `bucket_width=1m`: default: 60, max: 1440 + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + // A cursor for use in pagination. Corresponding to the `next_page` field from the + // previous response. + Page param.Opt[string] `query:"page,omitzero" json:"-"` + // Width of each time bucket in response. Currently `1m`, `1h` and `1d` are + // supported, default to `1d`. + // + // Any of "1m", "1h", "1d". + BucketWidth AdminOrganizationUsageVectorStoresParamsBucketWidth `query:"bucket_width,omitzero" json:"-"` + // Group the usage data by the specified fields. Support fields include + // `project_id`. + // + // Any of "project_id". + GroupBy []string `query:"group_by,omitzero" json:"-"` + // Return only usage for these projects. + ProjectIDs []string `query:"project_ids,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationUsageVectorStoresParams]'s query +// parameters as `url.Values`. +func (r AdminOrganizationUsageVectorStoresParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Width of each time bucket in response. Currently `1m`, `1h` and `1d` are +// supported, default to `1d`. +type AdminOrganizationUsageVectorStoresParamsBucketWidth string + +const ( + AdminOrganizationUsageVectorStoresParamsBucketWidth1m AdminOrganizationUsageVectorStoresParamsBucketWidth = "1m" + AdminOrganizationUsageVectorStoresParamsBucketWidth1h AdminOrganizationUsageVectorStoresParamsBucketWidth = "1h" + AdminOrganizationUsageVectorStoresParamsBucketWidth1d AdminOrganizationUsageVectorStoresParamsBucketWidth = "1d" +) + +type AdminOrganizationUsageWebSearchCallsParams struct { + // Start time (Unix seconds) of the query time range, inclusive. + StartTime int64 `query:"start_time" api:"required" json:"-"` + // End time (Unix seconds) of the query time range, exclusive. + EndTime param.Opt[int64] `query:"end_time,omitzero" json:"-"` + // Specifies the number of buckets to return. + // + // - `bucket_width=1d`: default: 7, max: 31 + // - `bucket_width=1h`: default: 24, max: 168 + // - `bucket_width=1m`: default: 60, max: 1440 + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + // A cursor for use in pagination. Corresponding to the `next_page` field from the + // previous response. + Page param.Opt[string] `query:"page,omitzero" json:"-"` + // Return only usage for these API keys. + APIKeyIDs []string `query:"api_key_ids,omitzero" json:"-"` + // Width of each time bucket in response. Currently `1m`, `1h` and `1d` are + // supported, default to `1d`. + // + // Any of "1m", "1h", "1d". + BucketWidth AdminOrganizationUsageWebSearchCallsParamsBucketWidth `query:"bucket_width,omitzero" json:"-"` + // Return only web search usage for these context levels. + // + // Any of "low", "medium", "high". + ContextLevels []string `query:"context_levels,omitzero" json:"-"` + // Group the usage data by the specified fields. Support fields include + // `project_id`, `user_id`, `api_key_id`, `model`, `context_level` or any + // combination of them. + // + // Any of "project_id", "user_id", "api_key_id", "model", "context_level". + GroupBy []string `query:"group_by,omitzero" json:"-"` + // Return only usage for these models. + Models []string `query:"models,omitzero" json:"-"` + // Return only usage for these projects. + ProjectIDs []string `query:"project_ids,omitzero" json:"-"` + // Return only usage for these users. + UserIDs []string `query:"user_ids,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationUsageWebSearchCallsParams]'s query +// parameters as `url.Values`. +func (r AdminOrganizationUsageWebSearchCallsParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Width of each time bucket in response. Currently `1m`, `1h` and `1d` are +// supported, default to `1d`. +type AdminOrganizationUsageWebSearchCallsParamsBucketWidth string + +const ( + AdminOrganizationUsageWebSearchCallsParamsBucketWidth1m AdminOrganizationUsageWebSearchCallsParamsBucketWidth = "1m" + AdminOrganizationUsageWebSearchCallsParamsBucketWidth1h AdminOrganizationUsageWebSearchCallsParamsBucketWidth = "1h" + AdminOrganizationUsageWebSearchCallsParamsBucketWidth1d AdminOrganizationUsageWebSearchCallsParamsBucketWidth = "1d" +) diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationuser.go b/vendor/github.com/openai/openai-go/v3/adminorganizationuser.go new file mode 100644 index 000000000..8d60ca4d8 --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationuser.go @@ -0,0 +1,300 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "errors" + "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" +) + +// AdminOrganizationUserService 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 [NewAdminOrganizationUserService] method instead. +type AdminOrganizationUserService struct { + Options []option.RequestOption + Roles AdminOrganizationUserRoleService +} + +// NewAdminOrganizationUserService 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 NewAdminOrganizationUserService(opts ...option.RequestOption) (r AdminOrganizationUserService) { + r = AdminOrganizationUserService{} + r.Options = opts + r.Roles = NewAdminOrganizationUserRoleService(opts...) + return +} + +// Retrieves a user by their identifier. +func (r *AdminOrganizationUserService) Get(ctx context.Context, userID string, opts ...option.RequestOption) (res *OrganizationUser, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if userID == "" { + err = errors.New("missing required user_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/users/%s", userID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return res, err +} + +// Modifies a user's role in the organization. +func (r *AdminOrganizationUserService) Update(ctx context.Context, userID string, body AdminOrganizationUserUpdateParams, opts ...option.RequestOption) (res *OrganizationUser, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if userID == "" { + err = errors.New("missing required user_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/users/%s", userID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Lists all of the users in the organization. +func (r *AdminOrganizationUserService) List(ctx context.Context, query AdminOrganizationUserListParams, opts ...option.RequestOption) (res *pagination.ConversationCursorPage[OrganizationUser], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := "organization/users" + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Lists all of the users in the organization. +func (r *AdminOrganizationUserService) ListAutoPaging(ctx context.Context, query AdminOrganizationUserListParams, opts ...option.RequestOption) *pagination.ConversationCursorPageAutoPager[OrganizationUser] { + return pagination.NewConversationCursorPageAutoPager(r.List(ctx, query, opts...)) +} + +// Deletes a user from the organization. +func (r *AdminOrganizationUserService) Delete(ctx context.Context, userID string, opts ...option.RequestOption) (res *AdminOrganizationUserDeleteResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if userID == "" { + err = errors.New("missing required user_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/users/%s", userID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + return res, err +} + +// Represents an individual `user` within an organization. +type OrganizationUser struct { + // The identifier, which can be referenced in API endpoints + ID string `json:"id" api:"required"` + // The Unix timestamp (in seconds) of when the user was added. + AddedAt int64 `json:"added_at" api:"required" format:"unixtime"` + // The object type, which is always `organization.user` + Object constant.OrganizationUser `json:"object" default:"organization.user"` + // The Unix timestamp (in seconds) of the user's last API key usage. + APIKeyLastUsedAt int64 `json:"api_key_last_used_at" api:"nullable" format:"unixtime"` + // The Unix timestamp (in seconds) of when the user was created. + Created int64 `json:"created" format:"unixtime"` + // The developer persona metadata for the user. + DeveloperPersona string `json:"developer_persona" api:"nullable"` + // The email address of the user + Email string `json:"email" api:"nullable"` + // Whether this is the organization's default user. + IsDefault bool `json:"is_default"` + // Whether the user is an authorized purchaser for Scale Tier. + IsScaleTierAuthorizedPurchaser bool `json:"is_scale_tier_authorized_purchaser" api:"nullable"` + // Whether the user is managed through SCIM. + IsScimManaged bool `json:"is_scim_managed"` + // Whether the user is a service account. + IsServiceAccount bool `json:"is_service_account"` + // The name of the user + Name string `json:"name" api:"nullable"` + // Projects associated with the user, if included. + Projects OrganizationUserProjects `json:"projects" api:"nullable"` + // `owner` or `reader` + Role string `json:"role" api:"nullable"` + // The technical level metadata for the user. + TechnicalLevel string `json:"technical_level" api:"nullable"` + // Nested user details. + User OrganizationUserUser `json:"user"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + AddedAt respjson.Field + Object respjson.Field + APIKeyLastUsedAt respjson.Field + Created respjson.Field + DeveloperPersona respjson.Field + Email respjson.Field + IsDefault respjson.Field + IsScaleTierAuthorizedPurchaser respjson.Field + IsScimManaged respjson.Field + IsServiceAccount respjson.Field + Name respjson.Field + Projects respjson.Field + Role respjson.Field + TechnicalLevel respjson.Field + User respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r OrganizationUser) RawJSON() string { return r.JSON.raw } +func (r *OrganizationUser) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Projects associated with the user, if included. +type OrganizationUserProjects struct { + Data []OrganizationUserProjectsData `json:"data" api:"required"` + Object constant.List `json:"object" default:"list"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Data respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r OrganizationUserProjects) RawJSON() string { return r.JSON.raw } +func (r *OrganizationUserProjects) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type OrganizationUserProjectsData struct { + ID string `json:"id" api:"nullable"` + Name string `json:"name" api:"nullable"` + Role string `json:"role" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Name respjson.Field + Role respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r OrganizationUserProjectsData) RawJSON() string { return r.JSON.raw } +func (r *OrganizationUserProjectsData) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Nested user details. +type OrganizationUserUser struct { + ID string `json:"id" api:"required"` + Object constant.User `json:"object" default:"user"` + Banned bool `json:"banned" api:"nullable"` + BannedAt int64 `json:"banned_at" api:"nullable" format:"unixtime"` + Email string `json:"email" api:"nullable"` + Enabled bool `json:"enabled" api:"nullable"` + Name string `json:"name" api:"nullable"` + Picture string `json:"picture" api:"nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Object respjson.Field + Banned respjson.Field + BannedAt respjson.Field + Email respjson.Field + Enabled respjson.Field + Name respjson.Field + Picture respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r OrganizationUserUser) RawJSON() string { return r.JSON.raw } +func (r *OrganizationUserUser) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUserDeleteResponse struct { + ID string `json:"id" api:"required"` + Deleted bool `json:"deleted" api:"required"` + Object constant.OrganizationUserDeleted `json:"object" default:"organization.user.deleted"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Deleted respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUserDeleteResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUserDeleteResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUserUpdateParams struct { + // Developer persona metadata. + DeveloperPersona param.Opt[string] `json:"developer_persona,omitzero"` + // `owner` or `reader` + Role param.Opt[string] `json:"role,omitzero"` + // Role ID to assign to the user. + RoleID param.Opt[string] `json:"role_id,omitzero"` + // Technical level metadata. + TechnicalLevel param.Opt[string] `json:"technical_level,omitzero"` + paramObj +} + +func (r AdminOrganizationUserUpdateParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationUserUpdateParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationUserUpdateParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUserListParams struct { + // A cursor for use in pagination. `after` is an object ID that defines your place + // in the list. For instance, if you make a list request and receive 100 objects, + // ending with obj_foo, your subsequent call can include after=obj_foo in order to + // fetch the next page of the list. + 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:"-"` + // Filter by the email address of users. + Emails []string `query:"emails,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationUserListParams]'s query parameters as +// `url.Values`. +func (r AdminOrganizationUserListParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} diff --git a/vendor/github.com/openai/openai-go/v3/adminorganizationuserrole.go b/vendor/github.com/openai/openai-go/v3/adminorganizationuserrole.go new file mode 100644 index 000000000..01b48fc14 --- /dev/null +++ b/vendor/github.com/openai/openai-go/v3/adminorganizationuserrole.go @@ -0,0 +1,344 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package openai + +import ( + "context" + "errors" + "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" +) + +// AdminOrganizationUserRoleService 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 [NewAdminOrganizationUserRoleService] method instead. +type AdminOrganizationUserRoleService struct { + Options []option.RequestOption +} + +// NewAdminOrganizationUserRoleService 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 NewAdminOrganizationUserRoleService(opts ...option.RequestOption) (r AdminOrganizationUserRoleService) { + r = AdminOrganizationUserRoleService{} + r.Options = opts + return +} + +// Assigns an organization role to a user within the organization. +func (r *AdminOrganizationUserRoleService) New(ctx context.Context, userID string, body AdminOrganizationUserRoleNewParams, opts ...option.RequestOption) (res *AdminOrganizationUserRoleNewResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if userID == "" { + err = errors.New("missing required user_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/users/%s/roles", userID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return res, err +} + +// Retrieves an organization role assigned to a user. +func (r *AdminOrganizationUserRoleService) Get(ctx context.Context, userID string, roleID string, opts ...option.RequestOption) (res *AdminOrganizationUserRoleGetResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if userID == "" { + err = errors.New("missing required user_id parameter") + return nil, err + } + if roleID == "" { + err = errors.New("missing required role_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/users/%s/roles/%s", userID, roleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return res, err +} + +// Lists the organization roles assigned to a user within the organization. +func (r *AdminOrganizationUserRoleService) List(ctx context.Context, userID string, query AdminOrganizationUserRoleListParams, opts ...option.RequestOption) (res *pagination.NextCursorPage[AdminOrganizationUserRoleListResponse], err error) { + var raw *http.Response + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + if userID == "" { + err = errors.New("missing required user_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/users/%s/roles", userID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Lists the organization roles assigned to a user within the organization. +func (r *AdminOrganizationUserRoleService) ListAutoPaging(ctx context.Context, userID string, query AdminOrganizationUserRoleListParams, opts ...option.RequestOption) *pagination.NextCursorPageAutoPager[AdminOrganizationUserRoleListResponse] { + return pagination.NewNextCursorPageAutoPager(r.List(ctx, userID, query, opts...)) +} + +// Unassigns an organization role from a user within the organization. +func (r *AdminOrganizationUserRoleService) Delete(ctx context.Context, userID string, roleID string, opts ...option.RequestOption) (res *AdminOrganizationUserRoleDeleteResponse, err error) { + var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()} + opts = slices.Concat(preClientOpts, r.Options, opts) + if userID == "" { + err = errors.New("missing required user_id parameter") + return nil, err + } + if roleID == "" { + err = errors.New("missing required role_id parameter") + return nil, err + } + path := requestconfig.FormatPath("organization/users/%s/roles/%s", userID, roleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + return res, err +} + +// Role assignment linking a user to a role. +type AdminOrganizationUserRoleNewResponse struct { + // Always `user.role`. + Object constant.UserRole `json:"object" default:"user.role"` + // Details about a role that can be assigned through the public Roles API. + Role Role `json:"role" api:"required"` + // Represents an individual `user` within an organization. + User OrganizationUser `json:"user" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Object respjson.Field + Role respjson.Field + User respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUserRoleNewResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUserRoleNewResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Detailed information about a role assignment entry returned when listing +// assignments. +type AdminOrganizationUserRoleGetResponse struct { + // Identifier for the role. + ID string `json:"id" api:"required"` + // Principals from which the role assignment is inherited, when available. + AssignmentSources []AdminOrganizationUserRoleGetResponseAssignmentSource `json:"assignment_sources" api:"required"` + // When the role was created. + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // Identifier of the actor who created the role. + CreatedBy string `json:"created_by" api:"required"` + // User details for the actor that created the role, when available. + CreatedByUserObj map[string]any `json:"created_by_user_obj" api:"required"` + // Description of the role. + Description string `json:"description" api:"required"` + // Arbitrary metadata stored on the role. + Metadata map[string]any `json:"metadata" api:"required"` + // Name of the role. + Name string `json:"name" api:"required"` + // Permissions associated with the role. + Permissions []string `json:"permissions" api:"required"` + // Whether the role is predefined by OpenAI. + PredefinedRole bool `json:"predefined_role" api:"required"` + // Resource type the role applies to. + ResourceType string `json:"resource_type" api:"required"` + // When the role was last updated. + UpdatedAt int64 `json:"updated_at" api:"required" format:"unixtime"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + AssignmentSources respjson.Field + CreatedAt respjson.Field + CreatedBy respjson.Field + CreatedByUserObj respjson.Field + Description respjson.Field + Metadata respjson.Field + Name respjson.Field + Permissions respjson.Field + PredefinedRole respjson.Field + ResourceType respjson.Field + UpdatedAt respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUserRoleGetResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUserRoleGetResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUserRoleGetResponseAssignmentSource struct { + PrincipalID string `json:"principal_id" api:"required"` + PrincipalType string `json:"principal_type" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + PrincipalID respjson.Field + PrincipalType respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUserRoleGetResponseAssignmentSource) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUserRoleGetResponseAssignmentSource) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Detailed information about a role assignment entry returned when listing +// assignments. +type AdminOrganizationUserRoleListResponse struct { + // Identifier for the role. + ID string `json:"id" api:"required"` + // Principals from which the role assignment is inherited, when available. + AssignmentSources []AdminOrganizationUserRoleListResponseAssignmentSource `json:"assignment_sources" api:"required"` + // When the role was created. + CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"` + // Identifier of the actor who created the role. + CreatedBy string `json:"created_by" api:"required"` + // User details for the actor that created the role, when available. + CreatedByUserObj map[string]any `json:"created_by_user_obj" api:"required"` + // Description of the role. + Description string `json:"description" api:"required"` + // Arbitrary metadata stored on the role. + Metadata map[string]any `json:"metadata" api:"required"` + // Name of the role. + Name string `json:"name" api:"required"` + // Permissions associated with the role. + Permissions []string `json:"permissions" api:"required"` + // Whether the role is predefined by OpenAI. + PredefinedRole bool `json:"predefined_role" api:"required"` + // Resource type the role applies to. + ResourceType string `json:"resource_type" api:"required"` + // When the role was last updated. + UpdatedAt int64 `json:"updated_at" api:"required" format:"unixtime"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + AssignmentSources respjson.Field + CreatedAt respjson.Field + CreatedBy respjson.Field + CreatedByUserObj respjson.Field + Description respjson.Field + Metadata respjson.Field + Name respjson.Field + Permissions respjson.Field + PredefinedRole respjson.Field + ResourceType respjson.Field + UpdatedAt respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUserRoleListResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUserRoleListResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUserRoleListResponseAssignmentSource struct { + PrincipalID string `json:"principal_id" api:"required"` + PrincipalType string `json:"principal_type" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + PrincipalID respjson.Field + PrincipalType respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUserRoleListResponseAssignmentSource) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUserRoleListResponseAssignmentSource) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Confirmation payload returned after unassigning a role. +type AdminOrganizationUserRoleDeleteResponse struct { + // Whether the assignment was removed. + Deleted bool `json:"deleted" api:"required"` + // Identifier for the deleted assignment, such as `group.role.deleted` or + // `user.role.deleted`. + Object string `json:"object" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Deleted respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AdminOrganizationUserRoleDeleteResponse) RawJSON() string { return r.JSON.raw } +func (r *AdminOrganizationUserRoleDeleteResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUserRoleNewParams struct { + // Identifier of the role to assign. + RoleID string `json:"role_id" api:"required"` + paramObj +} + +func (r AdminOrganizationUserRoleNewParams) MarshalJSON() (data []byte, err error) { + type shadow AdminOrganizationUserRoleNewParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AdminOrganizationUserRoleNewParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type AdminOrganizationUserRoleListParams struct { + // Cursor for pagination. Provide the value from the previous response's `next` + // field to continue listing organization roles. + After param.Opt[string] `query:"after,omitzero" json:"-"` + // A limit on the number of organization role assignments to return. + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + // Sort order for the returned organization roles. + // + // Any of "asc", "desc". + Order AdminOrganizationUserRoleListParamsOrder `query:"order,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [AdminOrganizationUserRoleListParams]'s query parameters as +// `url.Values`. +func (r AdminOrganizationUserRoleListParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Sort order for the returned organization roles. +type AdminOrganizationUserRoleListParamsOrder string + +const ( + AdminOrganizationUserRoleListParamsOrderAsc AdminOrganizationUserRoleListParamsOrder = "asc" + AdminOrganizationUserRoleListParamsOrderDesc AdminOrganizationUserRoleListParamsOrder = "desc" +) diff --git a/vendor/github.com/openai/openai-go/v3/aliases.go b/vendor/github.com/openai/openai-go/v3/aliases.go index ba6299454..0f71f7bfd 100644 --- a/vendor/github.com/openai/openai-go/v3/aliases.go +++ b/vendor/github.com/openai/openai-go/v3/aliases.go @@ -465,6 +465,22 @@ 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. +// 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 diff --git a/vendor/github.com/openai/openai-go/v3/api.md b/vendor/github.com/openai/openai-go/v3/api.md index ffb6159e5..bb0ce9999 100644 --- a/vendor/github.com/openai/openai-go/v3/api.md +++ b/vendor/github.com/openai/openai-go/v3/api.md @@ -656,6 +656,411 @@ 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.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/betaassistant.go b/vendor/github.com/openai/openai-go/v3/betaassistant.go index a36f36eb6..51adb04bd 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 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/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..6b54880c9 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`. 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..a299961da 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 @@ -512,7 +858,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 +992,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 +1040,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 @@ -869,6 +1219,352 @@ 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) +} + +// 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 { + 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 ChatCompletionChunkModerationOutputModerationResults) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionChunkModerationOutputModerationResults) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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 { + 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 ChatCompletionChunkModerationOutputModerationResultsResult) RawJSON() string { + return r.JSON.raw +} +func (r *ChatCompletionChunkModerationOutputModerationResultsResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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 { + 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 ChatCompletionChunkModerationOutputError) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionChunkModerationOutputError) 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 @@ -1688,7 +2384,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 @@ -2595,8 +3291,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 { @@ -3016,8 +3711,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 @@ -3080,12 +3776,22 @@ 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"` // 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). + // 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". PromptCacheRetention ChatCompletionNewParamsPromptCacheRetention `json:"prompt_cache_retention,omitzero"` // Constrains effort on reasoning for // [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently @@ -3262,14 +3968,40 @@ 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"` + 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 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). +// 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" ) 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..f085295d0 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 := []option.RequestOption{option.WithHTTPClient(defaultHTTPClient()), option.WithEnvironmentProduction()} 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,11 +82,19 @@ 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 } // 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. @@ -105,6 +118,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 +161,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..c48b392fc 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" 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..7262ee4bf 100644 --- a/vendor/github.com/openai/openai-go/v3/conversations/aliases.go +++ b/vendor/github.com/openai/openai-go/v3/conversations/aliases.go @@ -465,6 +465,22 @@ 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. +// 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 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..8f8b52ebb 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,7 +101,7 @@ 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"` @@ -135,7 +138,7 @@ type Conversation struct { 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 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..46cc04035 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,9 @@ 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], +// [responses.ResponseCompactionItem], [responses.ResponseCodeInterpreterToolCall], +// [ConversationItemLocalShellCall], [ConversationItemLocalShellCallOutput], // [responses.ResponseFunctionShellToolCall], // [responses.ResponseFunctionShellToolCallOutput], // [responses.ResponseApplyPatchToolCall], @@ -140,17 +143,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", - // "custom_tool_call_output". + // "computer_call_output", "tool_search_call", "tool_search_output", + // "additional_tools", "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", "custom_tool_call_output". Type string `json:"type"` // This field is from variant [Message]. Phase MessagePhase `json:"phase"` @@ -184,7 +186,7 @@ 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]. @@ -259,6 +261,7 @@ type anyConversationItem interface { func (Message) ImplConversationItemUnion() {} func (ConversationItemImageGenerationCall) ImplConversationItemUnion() {} +func (ConversationItemAdditionalTools) ImplConversationItemUnion() {} func (ConversationItemLocalShellCall) ImplConversationItemUnion() {} func (ConversationItemLocalShellCallOutput) ImplConversationItemUnion() {} func (ConversationItemMcpListTools) ImplConversationItemUnion() {} @@ -279,6 +282,7 @@ func (ConversationItemMcpCall) ImplConversationItemUnion() {} // case responses.ResponseComputerToolCallOutputItem: // case responses.ResponseToolSearchCall: // case responses.ResponseToolSearchOutputItem: +// case conversations.ConversationItemAdditionalTools: // case responses.ResponseReasoningItem: // case responses.ResponseCompactionItem: // case responses.ResponseCodeInterpreterToolCall: @@ -319,6 +323,8 @@ 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 "compaction": @@ -403,6 +409,11 @@ 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 @@ -585,12 +596,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 +633,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 +718,35 @@ 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) +} + // 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..b013ccee4 100644 --- a/vendor/github.com/openai/openai-go/v3/gradergradermodel.go +++ b/vendor/github.com/openai/openai-go/v3/gradergradermodel.go @@ -121,7 +121,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 @@ -257,7 +257,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"` @@ -449,7 +449,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 @@ -656,7 +656,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"` @@ -1270,7 +1270,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 @@ -1522,7 +1522,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"` 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..4804f3e85 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 @@ -31,6 +31,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": @@ -178,11 +197,18 @@ 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 } + // 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 +241,19 @@ 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 + 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. @@ -590,22 +621,58 @@ 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, + 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 +715,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..f59a2475c 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.41.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..4be098757 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,10 @@ 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", "cookie", "set-cookie"} + // WithDebugLog logs the HTTP request and response content. // If the logger parameter is nil, it uses the default logger. // @@ -20,7 +24,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 +33,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/realtime/aliases.go b/vendor/github.com/openai/openai-go/v3/realtime/aliases.go index 98c0ca804..a27bfa6b8 100644 --- a/vendor/github.com/openai/openai-go/v3/realtime/aliases.go +++ b/vendor/github.com/openai/openai-go/v3/realtime/aliases.go @@ -465,6 +465,22 @@ 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. +// 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 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..d9370c188 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,7 @@ type RealtimeSessionCreateResponseModel string const ( RealtimeSessionCreateResponseModelGPTRealtime RealtimeSessionCreateResponseModel = "gpt-realtime" RealtimeSessionCreateResponseModelGPTRealtime1_5 RealtimeSessionCreateResponseModel = "gpt-realtime-1.5" + RealtimeSessionCreateResponseModelGPTRealtime2 RealtimeSessionCreateResponseModel = "gpt-realtime-2" 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" @@ -642,7 +623,9 @@ 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 @@ -656,6 +639,7 @@ type RealtimeSessionCreateResponseToolUnion struct { RequireApproval respjson.Field ServerDescription respjson.Field ServerURL respjson.Field + TunnelID respjson.Field raw string } `json:"-"` } @@ -692,8 +676,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,9 +704,12 @@ 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 @@ -735,6 +722,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 +1020,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 +1069,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 +1118,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 +1154,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 +1184,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 +1204,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 +1213,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 +1502,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 +1518,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..5c57a603d 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,7 @@ type RealtimeSessionCreateRequestModel = string const ( RealtimeSessionCreateRequestModelGPTRealtime RealtimeSessionCreateRequestModel = "gpt-realtime" RealtimeSessionCreateRequestModelGPTRealtime1_5 RealtimeSessionCreateRequestModel = "gpt-realtime-1.5" + RealtimeSessionCreateRequestModelGPTRealtime2 RealtimeSessionCreateRequestModel = "gpt-realtime-2" 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" @@ -1185,6 +1283,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 +1325,12 @@ 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"` // 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 +1339,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 +1599,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..06aad2704 100644 --- a/vendor/github.com/openai/openai-go/v3/responses/aliases.go +++ b/vendor/github.com/openai/openai-go/v3/responses/aliases.go @@ -465,6 +465,22 @@ 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. +// 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 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..f6b1bd82d 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: // 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..15cc00f5b 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 @@ -211,7 +217,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, @@ -875,6 +881,367 @@ func init() { ) } +func init() { + apijson.RegisterFieldValidator[ComputerActionClickParam]( + "button", "left", "right", "wheel", "back", "forward", + ) +} + +func init() { + apijson.RegisterUnion[ContainerAutoNetworkPolicyUnionParam]( + "type", + apijson.Discriminator[ContainerNetworkPolicyDisabledParam]("disabled"), + apijson.Discriminator[ContainerNetworkPolicyAllowlistParam]("allowlist"), + ) +} + +func init() { + apijson.RegisterUnion[ContainerAutoSkillUnionParam]( + "type", + apijson.Discriminator[SkillReferenceParam]("skill_reference"), + apijson.Discriminator[InlineSkillParam]("inline"), + ) +} + +func init() { + apijson.RegisterFieldValidator[FileSearchToolRankingOptionsParam]( + "ranker", "auto", "default-2024-11-15", + ) +} + +func init() { + apijson.RegisterUnion[FunctionShellToolEnvironmentUnionParam]( + "type", + apijson.Discriminator[ContainerAutoParam]("container_auto"), + apijson.Discriminator[LocalEnvironmentParam]("local"), + apijson.Discriminator[ContainerReferenceParam]("container_reference"), + ) +} + +func init() { + apijson.RegisterUnion[NamespaceToolToolUnionParam]( + "type", + apijson.Discriminator[NamespaceToolToolFunctionParam]("function"), + apijson.Discriminator[CustomToolParam]("custom"), + ) +} + +func init() { + apijson.RegisterUnion[ResponseCodeInterpreterToolCallOutputUnionParam]( + "type", + apijson.Discriminator[ResponseCodeInterpreterToolCallOutputLogsParam]("logs"), + apijson.Discriminator[ResponseCodeInterpreterToolCallOutputImageParam]("image"), + ) +} + +func init() { + apijson.RegisterUnion[ResponseComputerToolCallActionUnionParam]( + "type", + apijson.Discriminator[ResponseComputerToolCallActionClickParam]("click"), + apijson.Discriminator[ResponseComputerToolCallActionDoubleClickParam]("double_click"), + apijson.Discriminator[ResponseComputerToolCallActionDragParam]("drag"), + apijson.Discriminator[ResponseComputerToolCallActionKeypressParam]("keypress"), + apijson.Discriminator[ResponseComputerToolCallActionMoveParam]("move"), + apijson.Discriminator[ResponseComputerToolCallActionScreenshotParam]("screenshot"), + apijson.Discriminator[ResponseComputerToolCallActionScrollParam]("scroll"), + apijson.Discriminator[ResponseComputerToolCallActionTypeParam]("type"), + apijson.Discriminator[ResponseComputerToolCallActionWaitParam]("wait"), + ) +} + +func init() { + apijson.RegisterFieldValidator[ResponseComputerToolCallActionClickParam]( + "button", "left", "right", "wheel", "back", "forward", + ) +} + +func init() { + apijson.RegisterUnion[ResponseCustomToolCallOutputOutputOutputContentListItemUnionParam]( + "type", + apijson.Discriminator[ResponseInputTextParam]("input_text"), + apijson.Discriminator[ResponseInputImageParam]("input_image"), + apijson.Discriminator[ResponseInputFileParam]("input_file"), + ) +} + +func init() { + apijson.RegisterUnion[ResponseFormatTextConfigUnionParam]( + "type", + apijson.Discriminator[shared.ResponseFormatTextParam]("text"), + apijson.Discriminator[ResponseFormatTextJSONSchemaConfigParam]("json_schema"), + apijson.Discriminator[shared.ResponseFormatJSONObjectParam]("json_object"), + ) +} + +func init() { + apijson.RegisterUnion[ResponseFunctionCallOutputItemUnionParam]( + "type", + apijson.Discriminator[ResponseInputTextContentParam]("input_text"), + apijson.Discriminator[ResponseInputImageContentParam]("input_image"), + apijson.Discriminator[ResponseInputFileContentParam]("input_file"), + ) +} + +func init() { + apijson.RegisterUnion[ResponseFunctionShellCallOutputContentOutcomeUnionParam]( + "type", + apijson.Discriminator[ResponseFunctionShellCallOutputContentOutcomeTimeoutParam]("timeout"), + apijson.Discriminator[ResponseFunctionShellCallOutputContentOutcomeExitParam]("exit"), + ) +} + +func init() { + apijson.RegisterUnion[ResponseFunctionWebSearchActionUnionParam]( + "type", + apijson.Discriminator[ResponseFunctionWebSearchActionSearchParam]("search"), + apijson.Discriminator[ResponseFunctionWebSearchActionOpenPageParam]("open_page"), + apijson.Discriminator[ResponseFunctionWebSearchActionFindParam]("find_in_page"), + ) +} + +func init() { + apijson.RegisterFieldValidator[ResponseInputAudioInputAudioParam]( + "format", "mp3", "wav", + ) +} + +func init() { + apijson.RegisterUnion[ResponseInputContentUnionParam]( + "type", + apijson.Discriminator[ResponseInputTextParam]("input_text"), + apijson.Discriminator[ResponseInputImageParam]("input_image"), + apijson.Discriminator[ResponseInputFileParam]("input_file"), + ) +} + +func init() { + apijson.RegisterUnion[ResponseInputItemUnionParam]( + "type", + apijson.Discriminator[EasyInputMessageParam]("message"), + apijson.Discriminator[ResponseInputItemMessageParam]("message"), + apijson.Discriminator[ResponseOutputMessageParam]("message"), + apijson.Discriminator[ResponseFileSearchToolCallParam]("file_search_call"), + apijson.Discriminator[ResponseComputerToolCallParam]("computer_call"), + apijson.Discriminator[ResponseInputItemComputerCallOutputParam]("computer_call_output"), + apijson.Discriminator[ResponseFunctionWebSearchParam]("web_search_call"), + apijson.Discriminator[ResponseFunctionToolCallParam]("function_call"), + 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"), + apijson.Discriminator[ResponseCodeInterpreterToolCallParam]("code_interpreter_call"), + apijson.Discriminator[ResponseInputItemLocalShellCallParam]("local_shell_call"), + apijson.Discriminator[ResponseInputItemLocalShellCallOutputParam]("local_shell_call_output"), + apijson.Discriminator[ResponseInputItemShellCallParam]("shell_call"), + apijson.Discriminator[ResponseInputItemShellCallOutputParam]("shell_call_output"), + apijson.Discriminator[ResponseInputItemApplyPatchCallParam]("apply_patch_call"), + apijson.Discriminator[ResponseInputItemApplyPatchCallOutputParam]("apply_patch_call_output"), + apijson.Discriminator[ResponseInputItemMcpListToolsParam]("mcp_list_tools"), + apijson.Discriminator[ResponseInputItemMcpApprovalRequestParam]("mcp_approval_request"), + apijson.Discriminator[ResponseInputItemMcpApprovalResponseParam]("mcp_approval_response"), + 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"), + ) +} + +func init() { + apijson.RegisterFieldValidator[ResponseInputItemMessageParam]( + "role", "user", "system", "developer", + ) + apijson.RegisterFieldValidator[ResponseInputItemMessageParam]( + "status", "in_progress", "completed", "incomplete", + ) + apijson.RegisterFieldValidator[ResponseInputItemMessageParam]( + "type", "message", + ) +} + +func init() { + apijson.RegisterFieldValidator[ResponseInputItemComputerCallOutputParam]( + "status", "in_progress", "completed", "incomplete", + ) +} + +func init() { + apijson.RegisterFieldValidator[ResponseInputItemFunctionCallOutputParam]( + "status", "in_progress", "completed", "incomplete", + ) +} + +func init() { + apijson.RegisterFieldValidator[ResponseInputItemToolSearchCallParam]( + "execution", "server", "client", + ) + apijson.RegisterFieldValidator[ResponseInputItemToolSearchCallParam]( + "status", "in_progress", "completed", "incomplete", + ) +} + +func init() { + apijson.RegisterFieldValidator[ResponseInputItemImageGenerationCallParam]( + "status", "in_progress", "completed", "generating", "failed", + ) +} + +func init() { + apijson.RegisterFieldValidator[ResponseInputItemLocalShellCallParam]( + "status", "in_progress", "completed", "incomplete", + ) +} + +func init() { + apijson.RegisterFieldValidator[ResponseInputItemLocalShellCallOutputParam]( + "status", "in_progress", "completed", "incomplete", + ) +} + +func init() { + apijson.RegisterFieldValidator[ResponseInputItemShellCallParam]( + "status", "in_progress", "completed", "incomplete", + ) +} + +func init() { + apijson.RegisterUnion[ResponseInputItemShellCallEnvironmentUnionParam]( + "type", + apijson.Discriminator[LocalEnvironmentParam]("local"), + apijson.Discriminator[ContainerReferenceParam]("container_reference"), + ) +} + +func init() { + apijson.RegisterFieldValidator[ResponseInputItemShellCallOutputParam]( + "status", "in_progress", "completed", "incomplete", + ) +} + +func init() { + apijson.RegisterFieldValidator[ResponseInputItemApplyPatchCallParam]( + "status", "in_progress", "completed", + ) +} + +func init() { + apijson.RegisterUnion[ResponseInputItemApplyPatchCallOperationUnionParam]( + "type", + apijson.Discriminator[ResponseInputItemApplyPatchCallOperationCreateFileParam]("create_file"), + apijson.Discriminator[ResponseInputItemApplyPatchCallOperationDeleteFileParam]("delete_file"), + apijson.Discriminator[ResponseInputItemApplyPatchCallOperationUpdateFileParam]("update_file"), + ) +} + +func init() { + apijson.RegisterFieldValidator[ResponseInputItemApplyPatchCallOutputParam]( + "status", "completed", "failed", + ) +} + +func init() { + apijson.RegisterFieldValidator[ResponseInputItemMcpCallParam]( + "status", "in_progress", "completed", "incomplete", "calling", "failed", + ) +} + +func init() { + apijson.RegisterFieldValidator[ResponseInputItemItemReferenceParam]( + "type", "item_reference", + ) +} + +func init() { + apijson.RegisterUnion[ResponseOutputMessageContentUnionParam]( + "type", + apijson.Discriminator[ResponseOutputTextParam]("output_text"), + apijson.Discriminator[ResponseOutputRefusalParam]("refusal"), + ) +} + +func init() { + apijson.RegisterUnion[ResponseOutputTextAnnotationUnionParam]( + "type", + apijson.Discriminator[ResponseOutputTextAnnotationFileCitationParam]("file_citation"), + apijson.Discriminator[ResponseOutputTextAnnotationURLCitationParam]("url_citation"), + apijson.Discriminator[ResponseOutputTextAnnotationContainerFileCitationParam]("container_file_citation"), + apijson.Discriminator[ResponseOutputTextAnnotationFilePathParam]("file_path"), + ) +} + +func init() { + apijson.RegisterUnion[ToolUnionParam]( + "type", + apijson.Discriminator[FunctionToolParam]("function"), + apijson.Discriminator[FileSearchToolParam]("file_search"), + apijson.Discriminator[ComputerToolParam]("computer"), + apijson.Discriminator[ComputerUsePreviewToolParam]("computer_use_preview"), + apijson.Discriminator[WebSearchToolParam]("web_search"), + apijson.Discriminator[WebSearchToolParam]("web_search_2025_08_26"), + apijson.Discriminator[ToolMcpParam]("mcp"), + apijson.Discriminator[ToolCodeInterpreterParam]("code_interpreter"), + apijson.Discriminator[ToolImageGenerationParam]("image_generation"), + apijson.Discriminator[ToolLocalShellParam]("local_shell"), + apijson.Discriminator[FunctionShellToolParam]("shell"), + apijson.Discriminator[CustomToolParam]("custom"), + apijson.Discriminator[NamespaceToolParam]("namespace"), + apijson.Discriminator[ToolSearchToolParam]("tool_search"), + apijson.Discriminator[WebSearchPreviewToolParam]("web_search_preview"), + apijson.Discriminator[WebSearchPreviewToolParam]("web_search_preview_2025_03_11"), + apijson.Discriminator[ApplyPatchToolParam]("apply_patch"), + ) +} + +func init() { + apijson.RegisterFieldValidator[ToolMcpParam]( + "connector_id", "connector_dropbox", "connector_gmail", "connector_googlecalendar", "connector_googledrive", "connector_microsoftteams", "connector_outlookcalendar", "connector_outlookemail", "connector_sharepoint", + ) +} + +func init() { + apijson.RegisterFieldValidator[ToolCodeInterpreterContainerCodeInterpreterContainerAutoParam]( + "memory_limit", "1g", "4g", "16g", "64g", + ) +} + +func init() { + apijson.RegisterUnion[ToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnionParam]( + "type", + apijson.Discriminator[ContainerNetworkPolicyDisabledParam]("disabled"), + apijson.Discriminator[ContainerNetworkPolicyAllowlistParam]("allowlist"), + ) +} + +func init() { + apijson.RegisterFieldValidator[ToolImageGenerationParam]( + "action", "generate", "edit", "auto", + ) + apijson.RegisterFieldValidator[ToolImageGenerationParam]( + "background", "transparent", "opaque", "auto", + ) + apijson.RegisterFieldValidator[ToolImageGenerationParam]( + "input_fidelity", "high", "low", + ) + apijson.RegisterFieldValidator[ToolImageGenerationParam]( + "moderation", "auto", "low", + ) + apijson.RegisterFieldValidator[ToolImageGenerationParam]( + "output_format", "png", "webp", "jpeg", + ) + apijson.RegisterFieldValidator[ToolImageGenerationParam]( + "quality", "low", "medium", "high", "auto", + ) +} + +func init() { + apijson.RegisterFieldValidator[WebSearchToolUserLocationParam]( + "type", "approximate", + ) +} + // A click action. // // The properties Button, Type, X, Y are required. @@ -905,12 +1272,6 @@ func (r *ComputerActionClickParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -func init() { - apijson.RegisterFieldValidator[ComputerActionClickParam]( - "button", "left", "right", "wheel", "back", "forward", - ) -} - // A double click action. // // The properties Keys, Type, X, Y are required. @@ -1545,14 +1906,6 @@ func (u ContainerAutoNetworkPolicyUnionParam) GetType() *string { return nil } -func init() { - apijson.RegisterUnion[ContainerAutoNetworkPolicyUnionParam]( - "type", - apijson.Discriminator[ContainerNetworkPolicyDisabledParam]("disabled"), - apijson.Discriminator[ContainerNetworkPolicyAllowlistParam]("allowlist"), - ) -} - // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. @@ -1628,14 +1981,6 @@ func (u ContainerAutoSkillUnionParam) GetType() *string { return nil } -func init() { - apijson.RegisterUnion[ContainerAutoSkillUnionParam]( - "type", - apijson.Discriminator[SkillReferenceParam]("skill_reference"), - apijson.Discriminator[InlineSkillParam]("inline"), - ) -} - type ContainerNetworkPolicyAllowlist struct { // A list of allowed domains when type is `allowlist`. AllowedDomains []string `json:"allowed_domains" api:"required"` @@ -2332,12 +2677,6 @@ func (r *FileSearchToolRankingOptionsParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -func init() { - apijson.RegisterFieldValidator[FileSearchToolRankingOptionsParam]( - "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. // @@ -2617,15 +2956,6 @@ type functionShellToolEnvironmentUnionParamSkills struct{ any } // } func (u functionShellToolEnvironmentUnionParamSkills) AsAny() any { return u.any } -func init() { - apijson.RegisterUnion[FunctionShellToolEnvironmentUnionParam]( - "type", - apijson.Discriminator[ContainerAutoParam]("container_auto"), - apijson.Discriminator[LocalEnvironmentParam]("local"), - apijson.Discriminator[ContainerReferenceParam]("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). @@ -3169,14 +3499,6 @@ func (u NamespaceToolToolUnionParam) GetDescription() *string { return nil } -func init() { - apijson.RegisterUnion[NamespaceToolToolUnionParam]( - "type", - apijson.Discriminator[NamespaceToolToolFunctionParam]("function"), - apijson.Discriminator[CustomToolParam]("custom"), - ) -} - // The properties Name, Type are required. type NamespaceToolToolFunctionParam struct { Name string `json:"name" api:"required"` @@ -3202,7 +3524,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 +3600,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 +3613,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). @@ -3307,8 +3632,16 @@ type Response struct { // 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). + // 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". PromptCacheRetention ResponsePromptCacheRetention `json:"prompt_cache_retention" api:"nullable"` // **gpt-5 and o-series models only** // @@ -3353,8 +3686,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,6 +3732,7 @@ type Response struct { Conversation respjson.Field MaxOutputTokens respjson.Field MaxToolCalls respjson.Field + Moderation respjson.Field PreviousResponseID respjson.Field Prompt respjson.Field PromptCacheKey respjson.Field @@ -3589,14 +3924,324 @@ 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 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). +// 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" ) @@ -4256,7 +4901,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 @@ -4369,14 +5014,6 @@ func (u ResponseCodeInterpreterToolCallOutputUnionParam) GetType() *string { return nil } -func init() { - apijson.RegisterUnion[ResponseCodeInterpreterToolCallOutputUnionParam]( - "type", - apijson.Discriminator[ResponseCodeInterpreterToolCallOutputLogsParam]("logs"), - apijson.Discriminator[ResponseCodeInterpreterToolCallOutputImageParam]("image"), - ) -} - // The logs output from the code interpreter. // // The properties Logs, Type are required. @@ -4403,7 +5040,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". @@ -5262,22 +5899,7 @@ func (u ResponseComputerToolCallActionUnionParam) GetKeys() []string { } else if vt := u.OfScroll; vt != nil { return vt.Keys } - return nil -} - -func init() { - apijson.RegisterUnion[ResponseComputerToolCallActionUnionParam]( - "type", - apijson.Discriminator[ResponseComputerToolCallActionClickParam]("click"), - apijson.Discriminator[ResponseComputerToolCallActionDoubleClickParam]("double_click"), - apijson.Discriminator[ResponseComputerToolCallActionDragParam]("drag"), - apijson.Discriminator[ResponseComputerToolCallActionKeypressParam]("keypress"), - apijson.Discriminator[ResponseComputerToolCallActionMoveParam]("move"), - apijson.Discriminator[ResponseComputerToolCallActionScreenshotParam]("screenshot"), - apijson.Discriminator[ResponseComputerToolCallActionScrollParam]("scroll"), - apijson.Discriminator[ResponseComputerToolCallActionTypeParam]("type"), - apijson.Discriminator[ResponseComputerToolCallActionWaitParam]("wait"), - ) + return nil } // A click action. @@ -5310,12 +5932,6 @@ func (r *ResponseComputerToolCallActionClickParam) UnmarshalJSON(data []byte) er return apijson.UnmarshalRoot(data, r) } -func init() { - apijson.RegisterFieldValidator[ResponseComputerToolCallActionClickParam]( - "button", "left", "right", "wheel", "back", "forward", - ) -} - // A double click action. // // The properties Keys, Type, X, Y are required. @@ -5632,7 +6248,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 +6282,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`. // @@ -6502,15 +7118,6 @@ func (u ResponseCustomToolCallOutputOutputOutputContentListItemUnionParam) GetFi return nil } -func init() { - apijson.RegisterUnion[ResponseCustomToolCallOutputOutputOutputContentListItemUnionParam]( - "type", - apijson.Discriminator[ResponseInputTextParam]("input_text"), - apijson.Discriminator[ResponseInputImageParam]("input_image"), - apijson.Discriminator[ResponseInputFileParam]("input_file"), - ) -} - // 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. @@ -7117,15 +7724,6 @@ func (u ResponseFormatTextConfigUnionParam) GetType() *string { return nil } -func init() { - apijson.RegisterUnion[ResponseFormatTextConfigUnionParam]( - "type", - apijson.Discriminator[shared.ResponseFormatTextParam]("text"), - apijson.Discriminator[ResponseFormatTextJSONSchemaConfigParam]("json_schema"), - apijson.Discriminator[shared.ResponseFormatJSONObjectParam]("json_object"), - ) -} - // JSON Schema response format. Used to generate structured JSON responses. Learn // more about // [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs). @@ -7479,15 +8077,6 @@ func (u ResponseFunctionCallOutputItemUnionParam) GetFileID() *string { return nil } -func init() { - apijson.RegisterUnion[ResponseFunctionCallOutputItemUnionParam]( - "type", - apijson.Discriminator[ResponseInputTextContentParam]("input_text"), - apijson.Discriminator[ResponseInputImageContentParam]("input_image"), - apijson.Discriminator[ResponseInputFileContentParam]("input_file"), - ) -} - type ResponseFunctionCallOutputItemList []ResponseFunctionCallOutputItemUnion type ResponseFunctionCallOutputItemListParam []ResponseFunctionCallOutputItemUnionParam @@ -7697,14 +8286,6 @@ func (u ResponseFunctionShellCallOutputContentOutcomeUnionParam) GetType() *stri return nil } -func init() { - apijson.RegisterUnion[ResponseFunctionShellCallOutputContentOutcomeUnionParam]( - "type", - apijson.Discriminator[ResponseFunctionShellCallOutputContentOutcomeTimeoutParam]("timeout"), - apijson.Discriminator[ResponseFunctionShellCallOutputContentOutcomeExitParam]("exit"), - ) -} - func NewResponseFunctionShellCallOutputContentOutcomeTimeoutParam() ResponseFunctionShellCallOutputContentOutcomeTimeoutParam { return ResponseFunctionShellCallOutputContentOutcomeTimeoutParam{ Type: "timeout", @@ -8444,21 +9025,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 +9103,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 +9135,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 +9265,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 } @@ -8735,21 +9318,14 @@ func (u ResponseFunctionWebSearchActionUnionParam) GetURL() *string { return nil } -func init() { - apijson.RegisterUnion[ResponseFunctionWebSearchActionUnionParam]( - "type", - apijson.Discriminator[ResponseFunctionWebSearchActionSearchParam]("search"), - apijson.Discriminator[ResponseFunctionWebSearchActionOpenPageParam]("open_page"), - apijson.Discriminator[ResponseFunctionWebSearchActionFindParam]("find_in_page"), - ) -} - // 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 +9350,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 +9554,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 @@ -9122,12 +9700,6 @@ func (r *ResponseInputAudioInputAudioParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -func init() { - apijson.RegisterFieldValidator[ResponseInputAudioInputAudioParam]( - "format", "mp3", "wav", - ) -} - // ResponseInputContentUnion contains all possible properties and values from // [ResponseInputText], [ResponseInputImage], [ResponseInputFile]. // @@ -9338,15 +9910,6 @@ func (u ResponseInputContentUnionParam) GetFileID() *string { return nil } -func init() { - apijson.RegisterUnion[ResponseInputContentUnionParam]( - "type", - apijson.Discriminator[ResponseInputTextParam]("input_text"), - apijson.Discriminator[ResponseInputImageParam]("input_image"), - apijson.Discriminator[ResponseInputFileParam]("input_file"), - ) -} - // A file input to the model. type ResponseInputFile struct { // The type of the input item. Always `input_file`. @@ -9362,7 +9925,7 @@ type ResponseInputFile struct { // 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. @@ -9414,7 +9977,7 @@ 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 @@ -9453,7 +10016,7 @@ type ResponseInputFileContent struct { // 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. @@ -9504,7 +10067,7 @@ 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 @@ -9542,7 +10105,7 @@ type ResponseInputImage 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Detail respjson.Field @@ -9596,7 +10159,7 @@ 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"` // The type of the input item. Always `input_image`. // // This field can be elided, and will marshal its zero value as "input_image". @@ -9626,7 +10189,7 @@ 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Type respjson.Field @@ -9674,7 +10237,7 @@ 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`. // @@ -9701,14 +10264,15 @@ func (r *ResponseInputImageContentParam) UnmarshalJSON(data []byte) error { // [ResponseInputItemComputerCallOutput], [ResponseFunctionWebSearch], // [ResponseFunctionToolCall], [ResponseInputItemFunctionCallOutput], // [ResponseInputItemToolSearchCall], [ResponseToolSearchOutputItemParamResp], -// [ResponseReasoningItem], [ResponseCompactionItemParamResp], -// [ResponseInputItemImageGenerationCall], [ResponseCodeInterpreterToolCall], -// [ResponseInputItemLocalShellCall], [ResponseInputItemLocalShellCallOutput], -// [ResponseInputItemShellCall], [ResponseInputItemShellCallOutput], -// [ResponseInputItemApplyPatchCall], [ResponseInputItemApplyPatchCallOutput], -// [ResponseInputItemMcpListTools], [ResponseInputItemMcpApprovalRequest], -// [ResponseInputItemMcpApprovalResponse], [ResponseInputItemMcpCall], -// [ResponseCustomToolCallOutput], [ResponseCustomToolCall], +// [ResponseInputItemAdditionalTools], [ResponseReasoningItem], +// [ResponseCompactionItemParamResp], [ResponseInputItemImageGenerationCall], +// [ResponseCodeInterpreterToolCall], [ResponseInputItemLocalShellCall], +// [ResponseInputItemLocalShellCallOutput], [ResponseInputItemShellCall], +// [ResponseInputItemShellCallOutput], [ResponseInputItemApplyPatchCall], +// [ResponseInputItemApplyPatchCallOutput], [ResponseInputItemMcpListTools], +// [ResponseInputItemMcpApprovalRequest], [ResponseInputItemMcpApprovalResponse], +// [ResponseInputItemMcpCall], [ResponseCustomToolCallOutput], +// [ResponseCustomToolCall], [ResponseInputItemCompactionTrigger], // [ResponseInputItemItemReference]. // // Use the [ResponseInputItemUnion.AsAny] method to switch on the variant. @@ -9723,12 +10287,13 @@ 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". Type string `json:"type"` Status string `json:"status"` ID string `json:"id"` @@ -9757,7 +10322,8 @@ type ResponseInputItemUnion struct { 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 [[]ToolUnion], [[]ToolUnion], + // [[]ResponseInputItemMcpListToolsTool] Tools ResponseInputItemUnionTools `json:"tools"` // This field is from variant [ResponseReasoningItem]. Summary []ResponseReasoningItemSummary `json:"summary"` @@ -9841,6 +10407,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,6 +10424,7 @@ func (ResponseInputItemMcpApprovalResponse) implResponseInputItemUnion() {} func (ResponseInputItemMcpCall) implResponseInputItemUnion() {} func (ResponseCustomToolCallOutput) implResponseInputItemUnion() {} func (ResponseCustomToolCall) implResponseInputItemUnion() {} +func (ResponseInputItemCompactionTrigger) implResponseInputItemUnion() {} func (ResponseInputItemItemReference) implResponseInputItemUnion() {} // Use the following switch statement to find the correct variant @@ -9873,6 +10441,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,6 +10458,7 @@ func (ResponseInputItemItemReference) implResponseInputItemUnion() {} // case responses.ResponseInputItemMcpCall: // case responses.ResponseCustomToolCallOutput: // case responses.ResponseCustomToolCall: +// case responses.ResponseInputItemCompactionTrigger: // case responses.ResponseInputItemItemReference: // default: // fmt.Errorf("no variant present") @@ -9913,6 +10483,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,6 +10517,8 @@ 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() } @@ -10006,6 +10580,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,6 +10665,11 @@ 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 @@ -10155,10 +10739,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 +10770,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 @@ -10518,6 +11102,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. @@ -11189,6 +11799,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. @@ -11303,6 +11931,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 +12061,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,6 +12078,7 @@ 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"` paramUnion } @@ -11459,6 +12095,7 @@ func (u ResponseInputItemUnionParam) MarshalJSON() ([]byte, error) { u.OfFunctionCallOutput, u.OfToolSearchCall, u.OfToolSearchOutput, + u.OfAdditionalTools, u.OfReasoning, u.OfCompaction, u.OfImageGenerationCall, @@ -11475,6 +12112,7 @@ func (u ResponseInputItemUnionParam) MarshalJSON() ([]byte, error) { u.OfMcpCall, u.OfCustomToolCallOutput, u.OfCustomToolCall, + u.OfCompactionTrigger, u.OfItemReference) } func (u *ResponseInputItemUnionParam) UnmarshalJSON(data []byte) error { @@ -11504,6 +12142,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,6 +12176,8 @@ 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 } @@ -11678,6 +12320,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 +12360,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,6 +12394,8 @@ 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) } @@ -11820,6 +12468,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() { @@ -12099,19 +12749,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 } @@ -12324,6 +12974,8 @@ func (u responseInputItemUnionParamArguments) AsAny() any { return u.any } 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 } @@ -12344,40 +12996,6 @@ type responseInputItemUnionParamTools struct{ any } // } func (u responseInputItemUnionParamTools) AsAny() any { return u.any } -func init() { - apijson.RegisterUnion[ResponseInputItemUnionParam]( - "type", - apijson.Discriminator[EasyInputMessageParam]("message"), - apijson.Discriminator[ResponseInputItemMessageParam]("message"), - apijson.Discriminator[ResponseOutputMessageParam]("message"), - apijson.Discriminator[ResponseFileSearchToolCallParam]("file_search_call"), - apijson.Discriminator[ResponseComputerToolCallParam]("computer_call"), - apijson.Discriminator[ResponseInputItemComputerCallOutputParam]("computer_call_output"), - apijson.Discriminator[ResponseFunctionWebSearchParam]("web_search_call"), - apijson.Discriminator[ResponseFunctionToolCallParam]("function_call"), - apijson.Discriminator[ResponseInputItemFunctionCallOutputParam]("function_call_output"), - apijson.Discriminator[ResponseInputItemToolSearchCallParam]("tool_search_call"), - apijson.Discriminator[ResponseToolSearchOutputItemParam]("tool_search_output"), - apijson.Discriminator[ResponseReasoningItemParam]("reasoning"), - apijson.Discriminator[ResponseCompactionItemParam]("compaction"), - apijson.Discriminator[ResponseInputItemImageGenerationCallParam]("image_generation_call"), - apijson.Discriminator[ResponseCodeInterpreterToolCallParam]("code_interpreter_call"), - apijson.Discriminator[ResponseInputItemLocalShellCallParam]("local_shell_call"), - apijson.Discriminator[ResponseInputItemLocalShellCallOutputParam]("local_shell_call_output"), - apijson.Discriminator[ResponseInputItemShellCallParam]("shell_call"), - apijson.Discriminator[ResponseInputItemShellCallOutputParam]("shell_call_output"), - apijson.Discriminator[ResponseInputItemApplyPatchCallParam]("apply_patch_call"), - apijson.Discriminator[ResponseInputItemApplyPatchCallOutputParam]("apply_patch_call_output"), - apijson.Discriminator[ResponseInputItemMcpListToolsParam]("mcp_list_tools"), - apijson.Discriminator[ResponseInputItemMcpApprovalRequestParam]("mcp_approval_request"), - apijson.Discriminator[ResponseInputItemMcpApprovalResponseParam]("mcp_approval_response"), - apijson.Discriminator[ResponseInputItemMcpCallParam]("mcp_call"), - apijson.Discriminator[ResponseCustomToolCallOutputParam]("custom_tool_call_output"), - apijson.Discriminator[ResponseCustomToolCallParam]("custom_tool_call"), - apijson.Discriminator[ResponseInputItemItemReferenceParam]("item_reference"), - ) -} - // 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. @@ -12411,18 +13029,6 @@ func (r *ResponseInputItemMessageParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -func init() { - apijson.RegisterFieldValidator[ResponseInputItemMessageParam]( - "role", "user", "system", "developer", - ) - apijson.RegisterFieldValidator[ResponseInputItemMessageParam]( - "status", "in_progress", "completed", "incomplete", - ) - apijson.RegisterFieldValidator[ResponseInputItemMessageParam]( - "type", "message", - ) -} - // The output of a computer tool call. // // The properties CallID, Output, Type are required. @@ -12457,12 +13063,6 @@ func (r *ResponseInputItemComputerCallOutputParam) UnmarshalJSON(data []byte) er return apijson.UnmarshalRoot(data, r) } -func init() { - apijson.RegisterFieldValidator[ResponseInputItemComputerCallOutputParam]( - "status", "in_progress", "completed", "incomplete", - ) -} - // A pending safety check for the computer call. // // The property ID is required. @@ -12516,12 +13116,6 @@ func (r *ResponseInputItemFunctionCallOutputParam) UnmarshalJSON(data []byte) er return apijson.UnmarshalRoot(data, r) } -func init() { - apijson.RegisterFieldValidator[ResponseInputItemFunctionCallOutputParam]( - "status", "in_progress", "completed", "incomplete", - ) -} - // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. @@ -12578,13 +13172,29 @@ func (r *ResponseInputItemToolSearchCallParam) UnmarshalJSON(data []byte) error return apijson.UnmarshalRoot(data, r) } -func init() { - apijson.RegisterFieldValidator[ResponseInputItemToolSearchCallParam]( - "execution", "server", "client", - ) - apijson.RegisterFieldValidator[ResponseInputItemToolSearchCallParam]( - "status", "in_progress", "completed", "incomplete", - ) +// 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. @@ -12615,12 +13225,6 @@ func (r *ResponseInputItemImageGenerationCallParam) UnmarshalJSON(data []byte) e return apijson.UnmarshalRoot(data, r) } -func init() { - apijson.RegisterFieldValidator[ResponseInputItemImageGenerationCallParam]( - "status", "in_progress", "completed", "generating", "failed", - ) -} - // A tool call to run a command on the local shell. // // The properties ID, Action, CallID, Status, Type are required. @@ -12650,12 +13254,6 @@ func (r *ResponseInputItemLocalShellCallParam) UnmarshalJSON(data []byte) error return apijson.UnmarshalRoot(data, r) } -func init() { - apijson.RegisterFieldValidator[ResponseInputItemLocalShellCallParam]( - "status", "in_progress", "completed", "incomplete", - ) -} - // Execute a shell command on the server. // // The properties Command, Env, Type are required. @@ -12713,12 +13311,6 @@ func (r *ResponseInputItemLocalShellCallOutputParam) UnmarshalJSON(data []byte) return apijson.UnmarshalRoot(data, r) } -func init() { - apijson.RegisterFieldValidator[ResponseInputItemLocalShellCallOutputParam]( - "status", "in_progress", "completed", "incomplete", - ) -} - // A tool representing a request to execute one or more shell commands. // // The properties Action, CallID, Type are required. @@ -12748,14 +13340,8 @@ func (r ResponseInputItemShellCallParam) MarshalJSON() (data []byte, err error) type shadow ResponseInputItemShellCallParam return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ResponseInputItemShellCallParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -func init() { - apijson.RegisterFieldValidator[ResponseInputItemShellCallParam]( - "status", "in_progress", "completed", "incomplete", - ) +func (r *ResponseInputItemShellCallParam) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } // The shell commands and limits that describe how to run the tool call. @@ -12831,14 +13417,6 @@ func (u ResponseInputItemShellCallEnvironmentUnionParam) GetType() *string { return nil } -func init() { - apijson.RegisterUnion[ResponseInputItemShellCallEnvironmentUnionParam]( - "type", - apijson.Discriminator[LocalEnvironmentParam]("local"), - apijson.Discriminator[ContainerReferenceParam]("container_reference"), - ) -} - // The streamed output items emitted by a shell tool call. // // The properties CallID, Output, Type are required. @@ -12874,12 +13452,6 @@ func (r *ResponseInputItemShellCallOutputParam) UnmarshalJSON(data []byte) error return apijson.UnmarshalRoot(data, r) } -func init() { - apijson.RegisterFieldValidator[ResponseInputItemShellCallOutputParam]( - "status", "in_progress", "completed", "incomplete", - ) -} - // A tool call representing a request to create, delete, or update files using diff // patches. // @@ -12912,12 +13484,6 @@ func (r *ResponseInputItemApplyPatchCallParam) UnmarshalJSON(data []byte) error return apijson.UnmarshalRoot(data, r) } -func init() { - apijson.RegisterFieldValidator[ResponseInputItemApplyPatchCallParam]( - "status", "in_progress", "completed", - ) -} - // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. @@ -12980,15 +13546,6 @@ func (u ResponseInputItemApplyPatchCallOperationUnionParam) GetType() *string { return nil } -func init() { - apijson.RegisterUnion[ResponseInputItemApplyPatchCallOperationUnionParam]( - "type", - apijson.Discriminator[ResponseInputItemApplyPatchCallOperationCreateFileParam]("create_file"), - apijson.Discriminator[ResponseInputItemApplyPatchCallOperationDeleteFileParam]("delete_file"), - apijson.Discriminator[ResponseInputItemApplyPatchCallOperationUpdateFileParam]("update_file"), - ) -} - // Instruction for creating a new file via the apply_patch tool. // // The properties Diff, Path, Type are required. @@ -13088,12 +13645,6 @@ func (r *ResponseInputItemApplyPatchCallOutputParam) UnmarshalJSON(data []byte) return apijson.UnmarshalRoot(data, r) } -func init() { - apijson.RegisterFieldValidator[ResponseInputItemApplyPatchCallOutputParam]( - "status", "completed", "failed", - ) -} - // A list of tools available on an MCP server. // // The properties ID, ServerLabel, Tools, Type are required. @@ -13240,10 +13791,28 @@ func (r *ResponseInputItemMcpCallParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -func init() { - apijson.RegisterFieldValidator[ResponseInputItemMcpCallParam]( - "status", "in_progress", "completed", "incomplete", "calling", "failed", - ) +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. @@ -13267,12 +13836,6 @@ func (r *ResponseInputItemItemReferenceParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -func init() { - apijson.RegisterFieldValidator[ResponseInputItemItemReferenceParam]( - "type", "item_reference", - ) -} - type ResponseInputMessageContentList []ResponseInputContentUnion type ResponseInputMessageContentListParam []ResponseInputContentUnionParam @@ -13442,14 +14005,15 @@ func (r *ResponseInputTextContentParam) UnmarshalJSON(data []byte) error { // [ResponseComputerToolCallOutputItem], [ResponseFunctionWebSearch], // [ResponseFunctionToolCallItem], [ResponseFunctionToolCallOutputItem], // [ResponseToolSearchCall], [ResponseToolSearchOutputItem], -// [ResponseReasoningItem], [ResponseCompactionItem], -// [ResponseItemImageGenerationCall], [ResponseCodeInterpreterToolCall], -// [ResponseItemLocalShellCall], [ResponseItemLocalShellCallOutput], -// [ResponseFunctionShellToolCall], [ResponseFunctionShellToolCallOutput], -// [ResponseApplyPatchToolCall], [ResponseApplyPatchToolCallOutput], -// [ResponseItemMcpListTools], [ResponseItemMcpApprovalRequest], -// [ResponseItemMcpApprovalResponse], [ResponseItemMcpCall], -// [ResponseCustomToolCallItem], [ResponseCustomToolCallOutputItem]. +// [ResponseItemAdditionalTools], [ResponseReasoningItem], +// [ResponseCompactionItem], [ResponseItemImageGenerationCall], +// [ResponseCodeInterpreterToolCall], [ResponseItemLocalShellCall], +// [ResponseItemLocalShellCallOutput], [ResponseFunctionShellToolCall], +// [ResponseFunctionShellToolCallOutput], [ResponseApplyPatchToolCall], +// [ResponseApplyPatchToolCallOutput], [ResponseItemMcpListTools], +// [ResponseItemMcpApprovalRequest], [ResponseItemMcpApprovalResponse], +// [ResponseItemMcpCall], [ResponseCustomToolCallItem], +// [ResponseCustomToolCallOutputItem]. // // Use the [ResponseItemUnion.AsAny] method to switch on the variant. // @@ -13462,12 +14026,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", "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]. @@ -13498,7 +14063,8 @@ type ResponseItemUnion struct { 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 [[]ToolUnion], [[]ToolUnion], + // [[]ResponseItemMcpListToolsTool] Tools ResponseItemUnionTools `json:"tools"` // This field is from variant [ResponseReasoningItem]. Summary []ResponseReasoningItemSummary `json:"summary"` @@ -13582,6 +14148,7 @@ func (ResponseFunctionToolCallItem) implResponseItemUnion() {} func (ResponseFunctionToolCallOutputItem) implResponseItemUnion() {} func (ResponseToolSearchCall) implResponseItemUnion() {} func (ResponseToolSearchOutputItem) implResponseItemUnion() {} +func (ResponseItemAdditionalTools) implResponseItemUnion() {} func (ResponseReasoningItem) implResponseItemUnion() {} func (ResponseCompactionItem) implResponseItemUnion() {} func (ResponseItemImageGenerationCall) implResponseItemUnion() {} @@ -13612,6 +14179,7 @@ func (ResponseCustomToolCallOutputItem) implResponseItemUnion() {} // case responses.ResponseFunctionToolCallOutputItem: // case responses.ResponseToolSearchCall: // case responses.ResponseToolSearchOutputItem: +// case responses.ResponseItemAdditionalTools: // case responses.ResponseReasoningItem: // case responses.ResponseCompactionItem: // case responses.ResponseItemImageGenerationCall: @@ -13651,6 +14219,8 @@ 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 "compaction": @@ -13737,6 +14307,11 @@ 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 @@ -13878,10 +14453,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 +14484,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 @@ -14021,6 +14596,35 @@ 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) +} + // An image generation request made by the model. type ResponseItemImageGenerationCall struct { // The unique ID of the image generation call. @@ -14557,14 +15161,14 @@ func (r *ResponseMcpListToolsInProgressEvent) UnmarshalJSON(data []byte) error { // [ResponseFunctionWebSearch], [ResponseComputerToolCall], // [ResponseComputerToolCallOutputItem], [ResponseReasoningItem], // [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,16 +15176,16 @@ 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", - // "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". + // "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 from variant [ResponseOutputMessage]. Phase ResponseOutputMessagePhase `json:"phase"` @@ -14614,7 +15218,8 @@ type ResponseOutputItemUnion struct { Summary []ResponseReasoningItemSummary `json:"summary"` EncryptedContent string `json:"encrypted_content"` Execution string `json:"execution"` - // This field is a union of [[]ToolUnion], [[]ResponseOutputItemMcpListToolsTool] + // This field is a union of [[]ToolUnion], [[]ToolUnion], + // [[]ResponseOutputItemMcpListToolsTool] Tools ResponseOutputItemUnionTools `json:"tools"` // This field is from variant [ResponseOutputItemImageGenerationCall]. Result string `json:"result"` @@ -14696,6 +15301,7 @@ func (ResponseComputerToolCallOutputItem) implResponseOutputItemUnion() {} func (ResponseReasoningItem) implResponseOutputItemUnion() {} func (ResponseToolSearchCall) implResponseOutputItemUnion() {} func (ResponseToolSearchOutputItem) implResponseOutputItemUnion() {} +func (ResponseOutputItemAdditionalTools) implResponseOutputItemUnion() {} func (ResponseCompactionItem) implResponseOutputItemUnion() {} func (ResponseOutputItemImageGenerationCall) implResponseOutputItemUnion() {} func (ResponseCodeInterpreterToolCall) implResponseOutputItemUnion() {} @@ -14725,6 +15331,7 @@ func (ResponseCustomToolCallOutputItem) implResponseOutputItemUnion() {} // case responses.ResponseReasoningItem: // case responses.ResponseToolSearchCall: // case responses.ResponseToolSearchOutputItem: +// case responses.ResponseOutputItemAdditionalTools: // case responses.ResponseCompactionItem: // case responses.ResponseOutputItemImageGenerationCall: // case responses.ResponseCodeInterpreterToolCall: @@ -14765,6 +15372,8 @@ func (u ResponseOutputItemUnion) AsAny() anyResponseOutputItem { 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": @@ -14849,6 +15458,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 @@ -15004,12 +15618,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 +15655,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 @@ -15096,6 +15710,35 @@ func (r *ResponseOutputItemUnionTools) 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) +} + // An image generation request made by the model. type ResponseOutputItemImageGenerationCall struct { // The unique ID of the image generation call. @@ -15687,14 +16330,6 @@ func (u ResponseOutputMessageContentUnionParam) GetType() *string { return nil } -func init() { - apijson.RegisterUnion[ResponseOutputMessageContentUnionParam]( - "type", - apijson.Discriminator[ResponseOutputTextParam]("output_text"), - apijson.Discriminator[ResponseOutputRefusalParam]("refusal"), - ) -} - // A refusal from the model. type ResponseOutputRefusal struct { // The refusal explanation from the model. @@ -15924,7 +16559,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 @@ -16189,16 +16824,6 @@ func (u ResponseOutputTextAnnotationUnionParam) GetStartIndex() *int64 { return nil } -func init() { - apijson.RegisterUnion[ResponseOutputTextAnnotationUnionParam]( - "type", - apijson.Discriminator[ResponseOutputTextAnnotationFileCitationParam]("file_citation"), - apijson.Discriminator[ResponseOutputTextAnnotationURLCitationParam]("url_citation"), - apijson.Discriminator[ResponseOutputTextAnnotationContainerFileCitationParam]("container_file_citation"), - apijson.Discriminator[ResponseOutputTextAnnotationFilePathParam]("file_path"), - ) -} - // A citation to a file. // // The properties FileID, Filename, Index, Type are required. @@ -16235,7 +16860,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". @@ -17969,7 +18594,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 +18676,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 { @@ -18557,6 +19182,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]. @@ -18613,6 +19240,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 @@ -18857,8 +19485,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,9 +19513,12 @@ 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 @@ -18900,6 +19531,7 @@ type ToolMcp struct { RequireApproval respjson.Field ServerDescription respjson.Field ServerURL respjson.Field + TunnelID respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -19278,8 +19910,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 +19956,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 { @@ -19641,6 +20290,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 { @@ -20129,29 +20786,6 @@ func (u toolUnionParamUserLocation) GetType() *string { return nil } -func init() { - apijson.RegisterUnion[ToolUnionParam]( - "type", - apijson.Discriminator[FunctionToolParam]("function"), - apijson.Discriminator[FileSearchToolParam]("file_search"), - apijson.Discriminator[ComputerToolParam]("computer"), - apijson.Discriminator[ComputerUsePreviewToolParam]("computer_use_preview"), - apijson.Discriminator[WebSearchToolParam]("web_search"), - apijson.Discriminator[WebSearchToolParam]("web_search_2025_08_26"), - apijson.Discriminator[ToolMcpParam]("mcp"), - apijson.Discriminator[ToolCodeInterpreterParam]("code_interpreter"), - apijson.Discriminator[ToolImageGenerationParam]("image_generation"), - apijson.Discriminator[ToolLocalShellParam]("local_shell"), - apijson.Discriminator[FunctionShellToolParam]("shell"), - apijson.Discriminator[CustomToolParam]("custom"), - apijson.Discriminator[NamespaceToolParam]("namespace"), - apijson.Discriminator[ToolSearchToolParam]("tool_search"), - apijson.Discriminator[WebSearchPreviewToolParam]("web_search_preview"), - apijson.Discriminator[WebSearchPreviewToolParam]("web_search_preview_2025_03_11"), - apijson.Discriminator[ApplyPatchToolParam]("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). @@ -20168,9 +20802,12 @@ 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"` // 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 +20816,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: @@ -20213,12 +20850,6 @@ func (r *ToolMcpParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -func init() { - apijson.RegisterFieldValidator[ToolMcpParam]( - "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. @@ -20425,12 +21056,6 @@ func (r *ToolCodeInterpreterContainerCodeInterpreterContainerAutoParam) Unmarsha return apijson.UnmarshalRoot(data, r) } -func init() { - apijson.RegisterFieldValidator[ToolCodeInterpreterContainerCodeInterpreterContainerAutoParam]( - "memory_limit", "1g", "4g", "16g", "64g", - ) -} - // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. @@ -20482,14 +21107,6 @@ func (u ToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnionPar return nil } -func init() { - apijson.RegisterUnion[ToolCodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicyUnionParam]( - "type", - apijson.Discriminator[ContainerNetworkPolicyDisabledParam]("disabled"), - apijson.Discriminator[ContainerNetworkPolicyAllowlistParam]("allowlist"), - ) -} - // A tool that generates images using the GPT image models. // // The property Type is required. @@ -20510,8 +21127,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 +21161,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`. // @@ -20554,30 +21188,6 @@ func (r *ToolImageGenerationParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -func init() { - apijson.RegisterFieldValidator[ToolImageGenerationParam]( - "action", "generate", "edit", "auto", - ) - apijson.RegisterFieldValidator[ToolImageGenerationParam]( - "background", "transparent", "opaque", "auto", - ) - apijson.RegisterFieldValidator[ToolImageGenerationParam]( - "input_fidelity", "high", "low", - ) - apijson.RegisterFieldValidator[ToolImageGenerationParam]( - "moderation", "auto", "low", - ) - apijson.RegisterFieldValidator[ToolImageGenerationParam]( - "output_format", "png", "webp", "jpeg", - ) - 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 // `file_id` (string, optional). type ToolImageGenerationInputImageMaskParam struct { @@ -21521,12 +22131,6 @@ func (r *WebSearchToolUserLocationParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -func init() { - apijson.RegisterFieldValidator[WebSearchToolUserLocationParam]( - "type", "approximate", - ) -} - type ResponseNewParams struct { // Whether to run the model response in the background. // [Learn more](https://platform.openai.com/docs/guides/background). @@ -21560,8 +22164,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 @@ -21619,6 +22224,8 @@ 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"` @@ -21626,8 +22233,16 @@ type ResponseNewParams struct { // 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). + // 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. // @@ -21789,14 +22404,40 @@ 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"` + 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 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). +// 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" ) @@ -22016,6 +22657,10 @@ type ResponseCompactParams struct { // // 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 } @@ -22161,3 +22806,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..7fcad6ba0 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,7 @@ func ValueOf[T Constant[T]]() T { } type Active string // Always "active" +type AdditionalTools string // Always "additional_tools" type AllowedTools string // Always "allowed_tools" type Allowlist string // Always "allowlist" type ApplicationZip string // Always "application/zip" @@ -35,6 +36,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 +57,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" @@ -91,6 +95,7 @@ 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 Error string // Always "error" type EvalRunCanceled string // Always "eval.run.canceled" @@ -114,6 +119,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" @@ -159,13 +169,50 @@ type McpListTools string // Always "mcp_list type McpListToolsCompleted string // Always "mcp_list_tools.completed" type McpListToolsFailed string // Always "mcp_list_tools.failed" type McpListToolsInProgress string // Always "mcp_list_tools.in_progress" +type Member string // Always "member" 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 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 +220,22 @@ 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 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" @@ -246,13 +303,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 +380,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 +388,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 +403,7 @@ 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 AllowedTools) Default() AllowedTools { return "allowed_tools" } func (c Allowlist) Default() Allowlist { return "allowlist" } func (c ApplicationZip) Default() ApplicationZip { return "application/zip" } @@ -352,6 +420,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 +443,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" } @@ -430,6 +501,7 @@ func (c Disabled) Default() Disabled { return "disab 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 Error) Default() Error { return "error" } func (c EvalRunCanceled) Default() EvalRunCanceled { return "eval.run.canceled" } @@ -455,6 +527,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" } @@ -516,13 +593,108 @@ func (c McpListTools) Default() McpListTools { return "mcp_l func (c McpListToolsCompleted) Default() McpListToolsCompleted { return "mcp_list_tools.completed" } func (c McpListToolsFailed) Default() McpListToolsFailed { return "mcp_list_tools.failed" } func (c McpListToolsInProgress) Default() McpListToolsInProgress { return "mcp_list_tools.in_progress" } +func (c Member) Default() Member { return "member" } 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 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" } @@ -536,12 +708,28 @@ func (c OutputAudioBufferStopped) Default() OutputAudioBufferStopped { return "output_audio_buffer.stopped" } func (c OutputText) Default() OutputText { return "output_text" } +func (c Page) Default() Page { return "page" } +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" } @@ -694,14 +882,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 +980,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 +988,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 +1007,7 @@ 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 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 +1024,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 +1045,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 +1076,151 @@ 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 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 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 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 Member) 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 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 +1228,22 @@ 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 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) } @@ -1040,13 +1315,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 +1392,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 +1400,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..4d404d24b 100644 --- a/vendor/github.com/openai/openai-go/v3/shared/shared.go +++ b/vendor/github.com/openai/openai-go/v3/shared/shared.go @@ -796,6 +796,12 @@ const ( // Configuration options for // [reasoning models](https://platform.openai.com/docs/guides/reasoning). type Reasoning struct { + // Controls which reasoning items are rendered back to the model on later turns. + // When returned on a response, this is the effective reasoning context mode used + // for the response. + // + // Any of "auto", "current_turn", "all_turns". + Context ReasoningContext `json:"context" 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`. @@ -833,6 +839,7 @@ 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 Summary respjson.Field @@ -856,6 +863,17 @@ 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. +// 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 @@ -888,6 +906,12 @@ const ( // Configuration options for // [reasoning models](https://platform.openai.com/docs/guides/reasoning). type ReasoningParam struct { + // Controls which reasoning items are rendered back to the model on later turns. + // When returned on a response, this is the effective reasoning context mode used + // for the response. + // + // Any of "auto", "current_turn", "all_turns". + Context ReasoningContext `json:"context,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`. 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..de49fad74 100644 --- a/vendor/github.com/openai/openai-go/v3/webhooks/aliases.go +++ b/vendor/github.com/openai/openai-go/v3/webhooks/aliases.go @@ -465,6 +465,22 @@ 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. +// 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 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/modules.txt b/vendor/modules.txt index b203638da..b256acec3 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -605,7 +605,7 @@ github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumul github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor/internal/metrics github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor/internal/putil/pslice github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor/internal/telemetry -# github.com/openai/openai-go/v3 v3.32.0 +# github.com/openai/openai-go/v3 v3.41.0 ## explicit; go 1.22 github.com/openai/openai-go/v3 github.com/openai/openai-go/v3/auth