Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "3.6.1"
".": "3.7.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 123
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-a4bb37d110a22c2888f53e21281434686a6fffa3e672a40f2503ad9bd2759063.yml
openapi_spec_hash: 2d59eefb494dff4eea8c3d008c7e2070
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-f68f718cd45ac3f9336603601bccc38a718af44d0b26601031de3d0a71b7ce2f.yml
openapi_spec_hash: 1560717860bba4105936647dde8f618d
config_hash: 50ee3382a63c021a9f821a935950e926
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 3.7.0 (2025-10-28)

Full Changelog: [v3.6.1...v3.7.0](https://github.com/openai/openai-go/compare/v3.6.1...v3.7.0)

### Features

* **api:** remove InputAudio from ResponseInputContent ([cf50c53](https://github.com/openai/openai-go/commit/cf50c53f779784e1ee73b7d815456afaa3e1c447))
* **azure:** allow passing custom scopes ([#541](https://github.com/openai/openai-go/issues/541)) ([dffa08e](https://github.com/openai/openai-go/commit/dffa08ece6c860ae1f87a01a5b8c26f18ce7ab2b))


### Bug Fixes

* **api:** docs updates ([94d54c1](https://github.com/openai/openai-go/commit/94d54c1e19d0d58875f56058042e06410b23ac49))

## 3.6.1 (2025-10-20)

Full Changelog: [v3.6.0...v3.6.1](https://github.com/openai/openai-go/compare/v3.6.0...v3.6.1)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Or to pin the version:
<!-- x-release-please-start-version -->

```sh
go get -u 'github.com/openai/openai-go/v2@v3.6.1'
go get -u 'github.com/openai/openai-go/v2@v3.7.0'
```

<!-- x-release-please-end -->
Expand Down
2 changes: 2 additions & 0 deletions aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,8 @@ const ReasoningGenerateSummaryDetailed = shared.ReasoningGenerateSummaryDetailed
// debugging and understanding the model's reasoning process. One of `auto`,
// `concise`, or `detailed`.
//
// `concise` is only supported for `computer-use-preview` models.
//
// This is an alias to an internal type.
type ReasoningSummary = shared.ReasoningSummary

Expand Down
64 changes: 47 additions & 17 deletions azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,30 +91,60 @@ func WithEndpoint(endpoint string, apiVersion string) option.RequestOption {
})
}

type tokenCredentialConfig struct {
Scopes []string
}

// TokenCredentialOption is the type for any options that can be used to customize
// [WithTokenCredential], including things like using custom scopes.
type TokenCredentialOption func(*tokenCredentialConfig) error

// WithTokenCredentialScopes overrides the default scope used when requesting access tokens.
func WithTokenCredentialScopes(scopes []string) func(*tokenCredentialConfig) error {
return func(tc *tokenCredentialConfig) error {
tc.Scopes = scopes
return nil
}
}

// WithTokenCredential configures this client to authenticate using an [Azure Identity] TokenCredential.
// This function should be paired with a call to [WithEndpoint] to point to your Azure OpenAI instance.
//
// [Azure Identity]: https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity
func WithTokenCredential(tokenCredential azcore.TokenCredential) option.RequestOption {
bearerTokenPolicy := runtime.NewBearerTokenPolicy(tokenCredential, []string{"https://cognitiveservices.azure.com/.default"}, nil)

// add in a middleware that uses the bearer token generated from the token credential
return option.WithMiddleware(func(req *http.Request, next option.MiddlewareNext) (*http.Response, error) {
pipeline := runtime.NewPipeline("azopenai-extensions", version, runtime.PipelineOptions{}, &policy.ClientOptions{
InsecureAllowCredentialWithHTTP: true, // allow for plain HTTP proxies, etc..
PerRetryPolicies: []policy.Policy{
bearerTokenPolicy,
policyAdapter(next),
},
})

req2, err := runtime.NewRequestFromRequest(req)
func WithTokenCredential(tokenCredential azcore.TokenCredential, options ...TokenCredentialOption) option.RequestOption {
return requestconfig.RequestOptionFunc(func(rc *requestconfig.RequestConfig) error {
tc := &tokenCredentialConfig{
Scopes: []string{"https://cognitiveservices.azure.com/.default"},
}

if err != nil {
return nil, err
for _, option := range options {
if err := option(tc); err != nil {
return err
}
}

return pipeline.Do(req2)
bearerTokenPolicy := runtime.NewBearerTokenPolicy(tokenCredential, tc.Scopes, nil)

// add in a middleware that uses the bearer token generated from the token credential
middlewareOption := option.WithMiddleware(func(req *http.Request, next option.MiddlewareNext) (*http.Response, error) {
pipeline := runtime.NewPipeline("azopenai-extensions", version, runtime.PipelineOptions{}, &policy.ClientOptions{
InsecureAllowCredentialWithHTTP: true, // allow for plain HTTP proxies, etc..
PerRetryPolicies: []policy.Policy{
bearerTokenPolicy,
policyAdapter(next),
},
})

req2, err := runtime.NewRequestFromRequest(req)

if err != nil {
return nil, err
}

return pipeline.Do(req2)
})

return middlewareOption.Apply(rc)
})
}

Expand Down
26 changes: 26 additions & 0 deletions azure/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,29 @@ func Example_authentication() {
_ = client
}
}

func Example_authentication_custom_scopes() {
// Custom scopes can also be passed, if needed, when using Azure OpenAI endpoints.
const azureOpenAIEndpoint = "https://<your-azureopenai-instance>.openai.azure.com"
const azureOpenAIAPIVersion = "<api version string>"

// For a full list of credential types look at the documentation for the Azure Identity
// package: https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity
tokenCredential, err := azidentity.NewDefaultAzureCredential(nil)

if err != nil {
fmt.Printf("Failed to create TokenCredential: %s\n", err)
return
}

client := openai.NewClient(
azure.WithEndpoint(azureOpenAIEndpoint, azureOpenAIAPIVersion),
azure.WithTokenCredential(tokenCredential,
// This is an example of a custom scope. See documentation for your service
// endpoint for the proper value to pass.
azure.WithTokenCredentialScopes([]string{"your-custom-scope"}),
),
)

_ = client
}
2 changes: 2 additions & 0 deletions conversations/aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,8 @@ const ReasoningGenerateSummaryDetailed = shared.ReasoningGenerateSummaryDetailed
// debugging and understanding the model's reasoning process. One of `auto`,
// `concise`, or `detailed`.
//
// `concise` is only supported for `computer-use-preview` models.
//
// This is an alias to an internal type.
type ReasoningSummary = shared.ReasoningSummary

Expand Down
27 changes: 13 additions & 14 deletions file.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,19 @@ func NewFileService(opts ...option.RequestOption) (r FileService) {
// up to 512 MB, and the size of all files uploaded by one organization can be up
// to 1 TB.
//
// The Assistants API supports files up to 2 million tokens and of specific file
// types. See the
// [Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) for
// details.
//
// The Fine-tuning API only supports `.jsonl` files. The input also has certain
// required formats for fine-tuning
// [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) or
// [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
// models.
//
// 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).
// - The Assistants API supports files up to 2 million tokens and of specific file
// types. See the
// [Assistants Tools guide](https://platform.openai.com/docs/assistants/tools)
// for details.
// - The Fine-tuning API only supports `.jsonl` files. The input also has certain
// required formats for fine-tuning
// [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input)
// or
// [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
// models.
// - 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).
//
// Please [contact us](https://help.openai.com/) if you need to increase these
// storage limits.
Expand Down
2 changes: 1 addition & 1 deletion internal/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

package internal

const PackageVersion = "3.6.1" // x-release-please-version
const PackageVersion = "3.7.0" // x-release-please-version
2 changes: 2 additions & 0 deletions realtime/aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,8 @@ const ReasoningGenerateSummaryDetailed = shared.ReasoningGenerateSummaryDetailed
// debugging and understanding the model's reasoning process. One of `auto`,
// `concise`, or `detailed`.
//
// `concise` is only supported for `computer-use-preview` models.
//
// This is an alias to an internal type.
type ReasoningSummary = shared.ReasoningSummary

Expand Down
2 changes: 2 additions & 0 deletions responses/aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,8 @@ const ReasoningGenerateSummaryDetailed = shared.ReasoningGenerateSummaryDetailed
// debugging and understanding the model's reasoning process. One of `auto`,
// `concise`, or `detailed`.
//
// `concise` is only supported for `computer-use-preview` models.
//
// This is an alias to an internal type.
type ReasoningSummary = shared.ReasoningSummary

Expand Down
Loading