Skip to content

Commit 77c994b

Browse files
release: 2.0.0 (#466)
* feat(api): manual updates * feat(client): support optional json html escaping * feat(api): adds GPT-5 and new API features: platform.openai.com/docs/guides/gpt-5 * codegen metadata * chore: document breaking changes * chore: change readme warning and minimum version * feat(client): rename union helpers * chore: migrate examples * release: 2.0.0 * release: 2.0.0 * Update CHANGELOG.md --------- Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com> Co-authored-by: Jacob Zimmerman <[email protected]>
1 parent f5636ed commit 77c994b

File tree

141 files changed

+3337
-1409
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+3337
-1409
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "1.12.0"
2+
".": "2.0.0"
33
}

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 97
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-721e6ccaa72205ee14c71f8163129920464fb814b95d3df9567a9476bbd9b7fb.yml
3-
openapi_spec_hash: 2115413a21df8b5bf9e4552a74df4312
4-
config_hash: 9606bb315a193bfd8da0459040143242
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-d7e255da603b878e7e823135520211ce6a9e02890c9d549bbf3953a877ee5ef3.yml
3+
openapi_spec_hash: 3eb8d86c06f0bb5e1190983e5acfc9ba
4+
config_hash: 2e7cf948f94e24f94c7d12ba2de2734a

CHANGELOG.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,51 @@
11
# Changelog
22

3+
## 2.0.0 (2025-08-07)
4+
5+
Full Changelog: [v1.12.0...v2.0.0](https://github.com/openai/openai-go/compare/v1.12.0...v2.0.0)
6+
7+
### Breaking changes
8+
9+
With the launch of `custom` tools in Chat Completions, `function` tools have been renamed to clarify the difference between the two.
10+
11+
`ChatCompletionToolParam` has become a union and is now named `ChatCompletionToolUnionParam`.
12+
13+
Older versions of the SDK used function tools: to migrate
14+
15+
16+
```diff
17+
- openai.ChatCompletionToolParam{
18+
- Function: openai.FunctionDefinitionParam{
19+
+ openai.ChatCompletionFunctionTool(
20+
+ openai.FunctionDefinitionParam{
21+
Name: "get_weather",
22+
Description: openai.String("Get weather at the given location"),
23+
Parameters: openai.FunctionParameters{ … },
24+
+ },
25+
+ )
26+
- },
27+
```
28+
29+
### Features
30+
31+
* **api:** adds GPT-5 and new API features: platform.openai.com/docs/guides/gpt-5 ([af46c88](https://github.com/openai/openai-go/commit/af46c885ea2414ba2b960f5d3accce89699a6250))
32+
* **api:** manual updates ([219f209](https://github.com/openai/openai-go/commit/219f2092a6d7f1952d119b5b4ec32512956825ff))
33+
* **client:** remove HTML escaping in JSON ([aea5ebc](https://github.com/openai/openai-go/commit/aea5ebccacb4fd854197dbf2547821860a62debc))
34+
* **client:** rename union helpers ([645e881](https://github.com/openai/openai-go/commit/645e881dee5799d81fb4fd40d6494a296710d0ce))
35+
* **client:** support optional json html escaping ([1d2336b](https://github.com/openai/openai-go/commit/1d2336b0d92f810fad3bf5faf5bf9e74975adf61))
36+
37+
38+
### Bug Fixes
39+
40+
* **client:** revert path param changes ([9239f06](https://github.com/openai/openai-go/commit/9239f06bf0cb537d80980cee140a90d07b6d14f2))
41+
42+
43+
### Chores
44+
45+
* change readme warning and minimum version ([1d0e22f](https://github.com/openai/openai-go/commit/1d0e22f85593a70f006f285f4461a05243b0fd74))
46+
* document breaking changes ([afaa2b8](https://github.com/openai/openai-go/commit/afaa2b8482e8d10ea508716ad9b241517c9affa1))
47+
* migrate examples ([9c57dd7](https://github.com/openai/openai-go/commit/9c57dd72515aab1c6d05d604870c5d0cf7fc1652))
48+
349
## 1.12.0 (2025-07-30)
450

551
Full Changelog: [v1.11.1...v1.12.0](https://github.com/openai/openai-go/compare/v1.11.1...v1.12.0)

MIGRATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# OpenAI Go Migration Guide
22

3-
<a href="https://pkg.go.dev/github.com/openai/openai-go"><img src="https://pkg.go.dev/badge/github.com/openai/openai-go.svg" alt="Go Reference"></a>
3+
<a href="https://pkg.go.dev/github.com/openai/openai-go/v2"><img src="https://pkg.go.dev/badge/github.com/openai/openai-go.svg" alt="Go Reference"></a>
44

55
This SDK includes breaking changes to improve the ergonomics of constructing parameters and accessing responses.
66

README.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# OpenAI Go API Library
22

3-
<a href="https://pkg.go.dev/github.com/openai/openai-go"><img src="https://pkg.go.dev/badge/github.com/openai/openai-go.svg" alt="Go Reference"></a>
3+
<a href="https://pkg.go.dev/github.com/openai/openai-go/v2"><img src="https://pkg.go.dev/badge/github.com/openai/openai-go.svg" alt="Go Reference"></a>
44

55
The OpenAI Go library provides convenient access to the [OpenAI REST API](https://platform.openai.com/docs)
66
from applications written in Go.
77

88
> [!WARNING]
9-
> The latest version of this package uses a new design with significant breaking changes.
10-
> Please refer to the [migration guide](./MIGRATION.md) for more information on how to update your code.
9+
> The latest version of this package has small and limited breaking changes.
10+
> See the [changelog](CHANGELOG.md) for details.
1111
1212
## Installation
1313

1414
<!-- x-release-please-start-version -->
1515

1616
```go
1717
import (
18-
"github.com/openai/openai-go" // imported as openai
18+
"github.com/openai/openai-go/v2" // imported as openai
1919
)
2020
```
2121

@@ -26,14 +26,14 @@ Or to pin the version:
2626
<!-- x-release-please-start-version -->
2727

2828
```sh
29-
go get -u 'github.com/openai/openai-go@v1.12.0'
29+
go get -u 'github.com/openai/openai-go@v2.0.0'
3030
```
3131

3232
<!-- x-release-please-end -->
3333

3434
## Requirements
3535

36-
This library requires Go 1.18+.
36+
This library requires Go 1.21+.
3737

3838
## Usage
3939

@@ -46,9 +46,9 @@ import (
4646
"context"
4747
"fmt"
4848

49-
"github.com/openai/openai-go"
50-
"github.com/openai/openai-go/option"
51-
"github.com/openai/openai-go/shared"
49+
"github.com/openai/openai-go/v2"
50+
"github.com/openai/openai-go/v2/option"
51+
"github.com/openai/openai-go/v2/shared"
5252
)
5353

5454
func main() {
@@ -589,7 +589,7 @@ client.Chat.Completions.New(
589589
},
590590
},
591591
}},
592-
Model: shared.ChatModelGPT4_1,
592+
Model: shared.ChatModelGPT5,
593593
},
594594
// This sets the per-retry timeout
595595
option.WithRequestTimeout(20*time.Second),
@@ -652,9 +652,9 @@ import (
652652
"os"
653653

654654
"github.com/gin-gonic/gin"
655-
"github.com/openai/openai-go"
656-
"github.com/openai/openai-go/option"
657-
"github.com/openai/openai-go/webhooks"
655+
"github.com/openai/openai-go/v2"
656+
"github.com/openai/openai-go/v2/option"
657+
"github.com/openai/openai-go/v2/webhooks"
658658
)
659659

660660
func main() {
@@ -663,7 +663,7 @@ func main() {
663663
)
664664

665665
r := gin.Default()
666-
666+
667667
r.POST("/webhook", func(c *gin.Context) {
668668
body, err := io.ReadAll(c.Request.Body)
669669
if err != nil {
@@ -712,8 +712,8 @@ import (
712712
"os"
713713

714714
"github.com/gin-gonic/gin"
715-
"github.com/openai/openai-go"
716-
"github.com/openai/openai-go/option"
715+
"github.com/openai/openai-go/v2"
716+
"github.com/openai/openai-go/v2/option"
717717
)
718718

719719
func main() {
@@ -722,7 +722,7 @@ func main() {
722722
)
723723

724724
r := gin.Default()
725-
725+
726726
r.POST("/webhook", func(c *gin.Context) {
727727
body, err := io.ReadAll(c.Request.Body)
728728
if err != nil {
@@ -737,7 +737,7 @@ func main() {
737737
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid signature"})
738738
return
739739
}
740-
740+
741741
c.JSON(http.StatusOK, gin.H{"message": "ok"})
742742
})
743743

@@ -770,7 +770,7 @@ client.Chat.Completions.New(
770770
},
771771
},
772772
}},
773-
Model: shared.ChatModelGPT4_1,
773+
Model: shared.ChatModelGPT5,
774774
},
775775
option.WithMaxRetries(5),
776776
)
@@ -794,7 +794,7 @@ chatCompletion, err := client.Chat.Completions.New(
794794
},
795795
},
796796
}},
797-
Model: shared.ChatModelGPT4_1,
797+
Model: shared.ChatModelGPT5,
798798
},
799799
option.WithResponseInto(&response),
800800
)
@@ -903,8 +903,8 @@ package main
903903

904904
import (
905905
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
906-
"github.com/openai/openai-go"
907-
"github.com/openai/openai-go/azure"
906+
"github.com/openai/openai-go/v2"
907+
"github.com/openai/openai-go/v2/azure"
908908
)
909909

910910
func main() {

aliases.go

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
package openai
44

55
import (
6-
"github.com/openai/openai-go/internal/apierror"
7-
"github.com/openai/openai-go/packages/param"
8-
"github.com/openai/openai-go/shared"
6+
"github.com/openai/openai-go/v2/internal/apierror"
7+
"github.com/openai/openai-go/v2/packages/param"
8+
"github.com/openai/openai-go/v2/shared"
99
)
1010

1111
// aliased to make [param.APIUnion] private when embedding
@@ -19,6 +19,27 @@ type Error = apierror.Error
1919
// This is an alias to an internal type.
2020
type ChatModel = shared.ChatModel
2121

22+
// Equals "gpt-5"
23+
const ChatModelGPT5 = shared.ChatModelGPT5
24+
25+
// Equals "gpt-5-mini"
26+
const ChatModelGPT5Mini = shared.ChatModelGPT5Mini
27+
28+
// Equals "gpt-5-nano"
29+
const ChatModelGPT5Nano = shared.ChatModelGPT5Nano
30+
31+
// Equals "gpt-5-2025-08-07"
32+
const ChatModelGPT5_2025_08_07 = shared.ChatModelGPT5_2025_08_07
33+
34+
// Equals "gpt-5-mini-2025-08-07"
35+
const ChatModelGPT5Mini2025_08_07 = shared.ChatModelGPT5Mini2025_08_07
36+
37+
// Equals "gpt-5-nano-2025-08-07"
38+
const ChatModelGPT5Nano2025_08_07 = shared.ChatModelGPT5Nano2025_08_07
39+
40+
// Equals "gpt-5-chat-latest"
41+
const ChatModelGPT5ChatLatest = shared.ChatModelGPT5ChatLatest
42+
2243
// Equals "gpt-4.1"
2344
const ChatModelGPT4_1 = shared.ChatModelGPT4_1
2445

@@ -259,6 +280,36 @@ const CompoundFilterTypeOr = shared.CompoundFilterTypeOr
259280
// This is an alias to an internal type.
260281
type CompoundFilterParam = shared.CompoundFilterParam
261282

283+
// The input format for the custom tool. Default is unconstrained text.
284+
//
285+
// This is an alias to an internal type.
286+
type CustomToolInputFormatUnion = shared.CustomToolInputFormatUnion
287+
288+
// Unconstrained free-form text.
289+
//
290+
// This is an alias to an internal type.
291+
type CustomToolInputFormatText = shared.CustomToolInputFormatText
292+
293+
// A grammar defined by the user.
294+
//
295+
// This is an alias to an internal type.
296+
type CustomToolInputFormatGrammar = shared.CustomToolInputFormatGrammar
297+
298+
// The input format for the custom tool. Default is unconstrained text.
299+
//
300+
// This is an alias to an internal type.
301+
type CustomToolInputFormatUnionParam = shared.CustomToolInputFormatUnionParam
302+
303+
// Unconstrained free-form text.
304+
//
305+
// This is an alias to an internal type.
306+
type CustomToolInputFormatTextParam = shared.CustomToolInputFormatTextParam
307+
308+
// A grammar defined by the user.
309+
//
310+
// This is an alias to an internal type.
311+
type CustomToolInputFormatGrammarParam = shared.CustomToolInputFormatGrammarParam
312+
262313
// This is an alias to an internal type.
263314
type ErrorObject = shared.ErrorObject
264315

@@ -339,16 +390,18 @@ const ReasoningSummaryDetailed = shared.ReasoningSummaryDetailed
339390
// This is an alias to an internal type.
340391
type ReasoningParam = shared.ReasoningParam
341392

342-
// **o-series models only**
343-
//
344393
// Constrains effort on reasoning for
345394
// [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
346-
// supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
347-
// result in faster responses and fewer tokens used on reasoning in a response.
395+
// supported values are `minimal`, `low`, `medium`, and `high`. Reducing reasoning
396+
// effort can result in faster responses and fewer tokens used on reasoning in a
397+
// response.
348398
//
349399
// This is an alias to an internal type.
350400
type ReasoningEffort = shared.ReasoningEffort
351401

402+
// Equals "minimal"
403+
const ReasoningEffortMinimal = shared.ReasoningEffortMinimal
404+
352405
// Equals "low"
353406
const ReasoningEffortLow = shared.ReasoningEffortLow
354407

0 commit comments

Comments
 (0)