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
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (

"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
"github.com/openai/openai-go/shared"
)

func main() {
Expand All @@ -55,7 +56,7 @@ func main() {
Role: openai.F(openai.ChatCompletionUserMessageParamRoleUser),
Content: openai.F([]openai.ChatCompletionContentPartUnionParam{openai.ChatCompletionContentPartTextParam{Text: openai.F("text"), Type: openai.F(openai.ChatCompletionContentPartTextTypeText)}}),
}}),
Model: openai.F(openai.ChatModelO3Mini),
Model: openai.F(shared.ChatModelO3Mini),
})
if err != nil {
panic(err.Error())
Expand Down Expand Up @@ -242,7 +243,7 @@ client.Chat.Completions.New(
Role: openai.F(openai.ChatCompletionUserMessageParamRoleUser),
Content: openai.F([]openai.ChatCompletionContentPartUnionParam{openai.ChatCompletionContentPartTextParam{Text: openai.F("text"), Type: openai.F(openai.ChatCompletionContentPartTextTypeText)}}),
}}),
Model: openai.F(openai.ChatModelO3Mini),
Model: openai.F(shared.ChatModelO3Mini),
},
// This sets the per-retry timeout
option.WithRequestTimeout(20*time.Second),
Expand Down Expand Up @@ -305,7 +306,7 @@ client.Chat.Completions.New(
Role: openai.F(openai.ChatCompletionUserMessageParamRoleUser),
Content: openai.F([]openai.ChatCompletionContentPartUnionParam{openai.ChatCompletionContentPartTextParam{Text: openai.F("text"), Type: openai.F(openai.ChatCompletionContentPartTextTypeText)}}),
}}),
Model: openai.F(openai.ChatModelO3Mini),
Model: openai.F(shared.ChatModelO3Mini),
},
option.WithMaxRetries(5),
)
Expand All @@ -326,7 +327,7 @@ chatCompletion, err := client.Chat.Completions.New(
Role: openai.F(openai.ChatCompletionUserMessageParamRoleUser),
Content: openai.F([]openai.ChatCompletionContentPartUnionParam{openai.ChatCompletionContentPartTextParam{Text: openai.F("text"), Type: openai.F(openai.ChatCompletionContentPartTextTypeText)}}),
}}),
Model: openai.F(openai.ChatModelO3Mini),
Model: openai.F(shared.ChatModelO3Mini),
},
option.WithResponseInto(&response),
)
Expand Down
126 changes: 126 additions & 0 deletions aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,132 @@ import (

type Error = apierror.Error

// This is an alias to an internal type.
type ChatModel = shared.ChatModel

// This is an alias to an internal value.
const ChatModelO3Mini = shared.ChatModelO3Mini

// This is an alias to an internal value.
const ChatModelO3Mini2025_01_31 = shared.ChatModelO3Mini2025_01_31

// This is an alias to an internal value.
const ChatModelO1 = shared.ChatModelO1

// This is an alias to an internal value.
const ChatModelO1_2024_12_17 = shared.ChatModelO1_2024_12_17

// This is an alias to an internal value.
const ChatModelO1Preview = shared.ChatModelO1Preview

// This is an alias to an internal value.
const ChatModelO1Preview2024_09_12 = shared.ChatModelO1Preview2024_09_12

// This is an alias to an internal value.
const ChatModelO1Mini = shared.ChatModelO1Mini

// This is an alias to an internal value.
const ChatModelO1Mini2024_09_12 = shared.ChatModelO1Mini2024_09_12

// This is an alias to an internal value.
const ChatModelGPT4_5Preview = shared.ChatModelGPT4_5Preview

// This is an alias to an internal value.
const ChatModelGPT4_5Preview2025_02_27 = shared.ChatModelGPT4_5Preview2025_02_27

// This is an alias to an internal value.
const ChatModelGPT4o = shared.ChatModelGPT4o

// This is an alias to an internal value.
const ChatModelGPT4o2024_11_20 = shared.ChatModelGPT4o2024_11_20

// This is an alias to an internal value.
const ChatModelGPT4o2024_08_06 = shared.ChatModelGPT4o2024_08_06

// This is an alias to an internal value.
const ChatModelGPT4o2024_05_13 = shared.ChatModelGPT4o2024_05_13

// This is an alias to an internal value.
const ChatModelGPT4oAudioPreview = shared.ChatModelGPT4oAudioPreview

// This is an alias to an internal value.
const ChatModelGPT4oAudioPreview2024_10_01 = shared.ChatModelGPT4oAudioPreview2024_10_01

// This is an alias to an internal value.
const ChatModelGPT4oAudioPreview2024_12_17 = shared.ChatModelGPT4oAudioPreview2024_12_17

// This is an alias to an internal value.
const ChatModelGPT4oMiniAudioPreview = shared.ChatModelGPT4oMiniAudioPreview

// This is an alias to an internal value.
const ChatModelGPT4oMiniAudioPreview2024_12_17 = shared.ChatModelGPT4oMiniAudioPreview2024_12_17

// This is an alias to an internal value.
const ChatModelChatgpt4oLatest = shared.ChatModelChatgpt4oLatest

// This is an alias to an internal value.
const ChatModelGPT4oMini = shared.ChatModelGPT4oMini

// This is an alias to an internal value.
const ChatModelGPT4oMini2024_07_18 = shared.ChatModelGPT4oMini2024_07_18

// This is an alias to an internal value.
const ChatModelGPT4Turbo = shared.ChatModelGPT4Turbo

// This is an alias to an internal value.
const ChatModelGPT4Turbo2024_04_09 = shared.ChatModelGPT4Turbo2024_04_09

// This is an alias to an internal value.
const ChatModelGPT4_0125Preview = shared.ChatModelGPT4_0125Preview

// This is an alias to an internal value.
const ChatModelGPT4TurboPreview = shared.ChatModelGPT4TurboPreview

// This is an alias to an internal value.
const ChatModelGPT4_1106Preview = shared.ChatModelGPT4_1106Preview

// This is an alias to an internal value.
const ChatModelGPT4VisionPreview = shared.ChatModelGPT4VisionPreview

// This is an alias to an internal value.
const ChatModelGPT4 = shared.ChatModelGPT4

// This is an alias to an internal value.
const ChatModelGPT4_0314 = shared.ChatModelGPT4_0314

// This is an alias to an internal value.
const ChatModelGPT4_0613 = shared.ChatModelGPT4_0613

// This is an alias to an internal value.
const ChatModelGPT4_32k = shared.ChatModelGPT4_32k

// This is an alias to an internal value.
const ChatModelGPT4_32k0314 = shared.ChatModelGPT4_32k0314

// This is an alias to an internal value.
const ChatModelGPT4_32k0613 = shared.ChatModelGPT4_32k0613

// This is an alias to an internal value.
const ChatModelGPT3_5Turbo = shared.ChatModelGPT3_5Turbo

// This is an alias to an internal value.
const ChatModelGPT3_5Turbo16k = shared.ChatModelGPT3_5Turbo16k

// This is an alias to an internal value.
const ChatModelGPT3_5Turbo0301 = shared.ChatModelGPT3_5Turbo0301

// This is an alias to an internal value.
const ChatModelGPT3_5Turbo0613 = shared.ChatModelGPT3_5Turbo0613

// This is an alias to an internal value.
const ChatModelGPT3_5Turbo1106 = shared.ChatModelGPT3_5Turbo1106

// This is an alias to an internal value.
const ChatModelGPT3_5Turbo0125 = shared.ChatModelGPT3_5Turbo0125

// This is an alias to an internal value.
const ChatModelGPT3_5Turbo16k0613 = shared.ChatModelGPT3_5Turbo16k0613

// This is an alias to an internal type.
type ErrorObject = shared.ErrorObject

Expand Down
5 changes: 1 addition & 4 deletions api.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Shared Params Types

- <a href="https://pkg.go.dev/github.com/openai/openai-go/shared">shared</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/shared#ChatModel">ChatModel</a>
- <a href="https://pkg.go.dev/github.com/openai/openai-go/shared">shared</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/shared#FunctionDefinitionParam">FunctionDefinitionParam</a>
- <a href="https://pkg.go.dev/github.com/openai/openai-go/shared">shared</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/shared#FunctionParameters">FunctionParameters</a>
- <a href="https://pkg.go.dev/github.com/openai/openai-go/shared">shared</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/shared#MetadataParam">MetadataParam</a>
Expand Down Expand Up @@ -28,10 +29,6 @@ Methods:

# Chat

Params Types:

- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#ChatModel">ChatModel</a>

## Completions

Params Types:
Expand Down
2 changes: 1 addition & 1 deletion betaassistant.go
Original file line number Diff line number Diff line change
Expand Up @@ -2067,7 +2067,7 @@ type BetaAssistantNewParams struct {
// see all of your available models, or see our
// [Model overview](https://platform.openai.com/docs/models) for descriptions of
// them.
Model param.Field[ChatModel] `json:"model,required"`
Model param.Field[shared.ChatModel] `json:"model,required"`
// The description of the assistant. The maximum length is 512 characters.
Description param.Field[string] `json:"description"`
// The system instructions that the assistant uses. The maximum length is 256,000
Expand Down
2 changes: 1 addition & 1 deletion betaassistant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestBetaAssistantNewWithOptionalParams(t *testing.T) {
option.WithAPIKey("My API Key"),
)
_, err := client.Beta.Assistants.New(context.TODO(), openai.BetaAssistantNewParams{
Model: openai.F(openai.ChatModelO3Mini),
Model: openai.F(shared.ChatModelO3Mini),
Description: openai.F("description"),
Instructions: openai.F("instructions"),
Metadata: openai.F(shared.MetadataParam{
Expand Down
2 changes: 1 addition & 1 deletion betathread.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ type BetaThreadNewAndRunParams struct {
// be used to execute this run. If a value is provided here, it will override the
// model associated with the assistant. If not, the model associated with the
// assistant will be used.
Model param.Field[ChatModel] `json:"model"`
Model param.Field[shared.ChatModel] `json:"model"`
// Whether to enable
// [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling)
// during tool use.
Expand Down
2 changes: 1 addition & 1 deletion betathread_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func TestBetaThreadNewAndRunWithOptionalParams(t *testing.T) {
Metadata: openai.F(shared.MetadataParam{
"foo": "string",
}),
Model: openai.F(openai.ChatModelO3Mini),
Model: openai.F(shared.ChatModelO3Mini),
ParallelToolCalls: openai.F(true),
Temperature: openai.F(1.000000),
Thread: openai.F(openai.BetaThreadNewAndRunParamsThread{
Expand Down
2 changes: 1 addition & 1 deletion betathreadrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ type BetaThreadRunNewParams struct {
// be used to execute this run. If a value is provided here, it will override the
// model associated with the assistant. If not, the model associated with the
// assistant will be used.
Model param.Field[ChatModel] `json:"model"`
Model param.Field[shared.ChatModel] `json:"model"`
// Whether to enable
// [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling)
// during tool use.
Expand Down
2 changes: 1 addition & 1 deletion betathreadrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestBetaThreadRunNewWithOptionalParams(t *testing.T) {
Metadata: openai.F(shared.MetadataParam{
"foo": "string",
}),
Model: openai.F(openai.ChatModelO3Mini),
Model: openai.F(shared.ChatModelO3Mini),
ParallelToolCalls: openai.F(true),
ReasoningEffort: openai.F(openai.BetaThreadRunNewParamsReasoningEffortLow),
Temperature: openai.F(1.000000),
Expand Down
46 changes: 0 additions & 46 deletions chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,49 +26,3 @@ func NewChatService(opts ...option.RequestOption) (r *ChatService) {
r.Completions = NewChatCompletionService(opts...)
return
}

type ChatModel = string

const (
ChatModelO3Mini ChatModel = "o3-mini"
ChatModelO3Mini2025_01_31 ChatModel = "o3-mini-2025-01-31"
ChatModelO1 ChatModel = "o1"
ChatModelO1_2024_12_17 ChatModel = "o1-2024-12-17"
ChatModelO1Preview ChatModel = "o1-preview"
ChatModelO1Preview2024_09_12 ChatModel = "o1-preview-2024-09-12"
ChatModelO1Mini ChatModel = "o1-mini"
ChatModelO1Mini2024_09_12 ChatModel = "o1-mini-2024-09-12"
ChatModelGPT4_5Preview ChatModel = "gpt-4.5-preview"
ChatModelGPT4_5Preview2025_02_27 ChatModel = "gpt-4.5-preview-2025-02-27"
ChatModelGPT4o ChatModel = "gpt-4o"
ChatModelGPT4o2024_11_20 ChatModel = "gpt-4o-2024-11-20"
ChatModelGPT4o2024_08_06 ChatModel = "gpt-4o-2024-08-06"
ChatModelGPT4o2024_05_13 ChatModel = "gpt-4o-2024-05-13"
ChatModelGPT4oAudioPreview ChatModel = "gpt-4o-audio-preview"
ChatModelGPT4oAudioPreview2024_10_01 ChatModel = "gpt-4o-audio-preview-2024-10-01"
ChatModelGPT4oAudioPreview2024_12_17 ChatModel = "gpt-4o-audio-preview-2024-12-17"
ChatModelGPT4oMiniAudioPreview ChatModel = "gpt-4o-mini-audio-preview"
ChatModelGPT4oMiniAudioPreview2024_12_17 ChatModel = "gpt-4o-mini-audio-preview-2024-12-17"
ChatModelChatgpt4oLatest ChatModel = "chatgpt-4o-latest"
ChatModelGPT4oMini ChatModel = "gpt-4o-mini"
ChatModelGPT4oMini2024_07_18 ChatModel = "gpt-4o-mini-2024-07-18"
ChatModelGPT4Turbo ChatModel = "gpt-4-turbo"
ChatModelGPT4Turbo2024_04_09 ChatModel = "gpt-4-turbo-2024-04-09"
ChatModelGPT4_0125Preview ChatModel = "gpt-4-0125-preview"
ChatModelGPT4TurboPreview ChatModel = "gpt-4-turbo-preview"
ChatModelGPT4_1106Preview ChatModel = "gpt-4-1106-preview"
ChatModelGPT4VisionPreview ChatModel = "gpt-4-vision-preview"
ChatModelGPT4 ChatModel = "gpt-4"
ChatModelGPT4_0314 ChatModel = "gpt-4-0314"
ChatModelGPT4_0613 ChatModel = "gpt-4-0613"
ChatModelGPT4_32k ChatModel = "gpt-4-32k"
ChatModelGPT4_32k0314 ChatModel = "gpt-4-32k-0314"
ChatModelGPT4_32k0613 ChatModel = "gpt-4-32k-0613"
ChatModelGPT3_5Turbo ChatModel = "gpt-3.5-turbo"
ChatModelGPT3_5Turbo16k ChatModel = "gpt-3.5-turbo-16k"
ChatModelGPT3_5Turbo0301 ChatModel = "gpt-3.5-turbo-0301"
ChatModelGPT3_5Turbo0613 ChatModel = "gpt-3.5-turbo-0613"
ChatModelGPT3_5Turbo1106 ChatModel = "gpt-3.5-turbo-1106"
ChatModelGPT3_5Turbo0125 ChatModel = "gpt-3.5-turbo-0125"
ChatModelGPT3_5Turbo16k0613 ChatModel = "gpt-3.5-turbo-16k-0613"
)
2 changes: 1 addition & 1 deletion chatcompletion.go
Original file line number Diff line number Diff line change
Expand Up @@ -1826,7 +1826,7 @@ type ChatCompletionNewParams struct {
// ID of the model to use. See the
// [model endpoint compatibility](https://platform.openai.com/docs/models#model-endpoint-compatibility)
// table for details on which models work with the Chat API.
Model param.Field[ChatModel] `json:"model,required"`
Model param.Field[shared.ChatModel] `json:"model,required"`
// Parameters for audio output. Required when audio output is requested with
// `modalities: ["audio"]`.
// [Learn more](https://platform.openai.com/docs/guides/audio).
Expand Down
2 changes: 1 addition & 1 deletion chatcompletion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestChatCompletionNewWithOptionalParams(t *testing.T) {
Role: openai.F(openai.ChatCompletionDeveloperMessageParamRoleDeveloper),
Name: openai.F("name"),
}}),
Model: openai.F(openai.ChatModelO3Mini),
Model: openai.F(shared.ChatModelO3Mini),
Audio: openai.F(openai.ChatCompletionAudioParam{
Format: openai.F(openai.ChatCompletionAudioParamFormatWAV),
Voice: openai.F(openai.ChatCompletionAudioParamVoiceAlloy),
Expand Down
Loading