Skip to content

Commit b0e3afb

Browse files
fix(client)!: add enums (#327)
1 parent 8870c26 commit b0e3afb

12 files changed

+146
-11
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ To handle errors, we recommend that you use the `errors.As` pattern:
527527

528528
```go
529529
_, err := client.FineTuning.Jobs.New(context.TODO(), openai.FineTuningJobNewParams{
530-
Model: "babbage-002",
530+
Model: openai.FineTuningJobNewParamsModelBabbage002,
531531
TrainingFile: "file-abc123",
532532
})
533533
if err != nil {

Diff for: audiospeech.go

+21-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ type AudioSpeechNewParams struct {
5757
// `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and
5858
// `verse`. Previews of the voices are available in the
5959
// [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).
60-
Voice string `json:"voice,omitzero,required"`
60+
Voice AudioSpeechNewParamsVoice `json:"voice,omitzero,required"`
6161
// Control the voice of your generated audio with additional instructions. Does not
6262
// work with `tts-1` or `tts-1-hd`.
6363
Instructions param.Opt[string] `json:"instructions,omitzero"`
@@ -81,6 +81,26 @@ func (r AudioSpeechNewParams) MarshalJSON() (data []byte, err error) {
8181
return param.MarshalObject(r, (*shadow)(&r))
8282
}
8383

84+
// The voice to use when generating the audio. Supported voices are `alloy`, `ash`,
85+
// `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and
86+
// `verse`. Previews of the voices are available in the
87+
// [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).
88+
type AudioSpeechNewParamsVoice string
89+
90+
const (
91+
AudioSpeechNewParamsVoiceAlloy AudioSpeechNewParamsVoice = "alloy"
92+
AudioSpeechNewParamsVoiceAsh AudioSpeechNewParamsVoice = "ash"
93+
AudioSpeechNewParamsVoiceBallad AudioSpeechNewParamsVoice = "ballad"
94+
AudioSpeechNewParamsVoiceCoral AudioSpeechNewParamsVoice = "coral"
95+
AudioSpeechNewParamsVoiceEcho AudioSpeechNewParamsVoice = "echo"
96+
AudioSpeechNewParamsVoiceFable AudioSpeechNewParamsVoice = "fable"
97+
AudioSpeechNewParamsVoiceOnyx AudioSpeechNewParamsVoice = "onyx"
98+
AudioSpeechNewParamsVoiceNova AudioSpeechNewParamsVoice = "nova"
99+
AudioSpeechNewParamsVoiceSage AudioSpeechNewParamsVoice = "sage"
100+
AudioSpeechNewParamsVoiceShimmer AudioSpeechNewParamsVoice = "shimmer"
101+
AudioSpeechNewParamsVoiceVerse AudioSpeechNewParamsVoice = "verse"
102+
)
103+
84104
// The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`,
85105
// `wav`, and `pcm`.
86106
type AudioSpeechNewParamsResponseFormat string

Diff for: audiospeech_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func TestAudioSpeechNewWithOptionalParams(t *testing.T) {
2929
resp, err := client.Audio.Speech.New(context.TODO(), openai.AudioSpeechNewParams{
3030
Input: "input",
3131
Model: openai.SpeechModelTTS1,
32-
Voice: "alloy",
32+
Voice: openai.AudioSpeechNewParamsVoiceAlloy,
3333
Instructions: openai.String("instructions"),
3434
ResponseFormat: openai.AudioSpeechNewParamsResponseFormatMP3,
3535
Speed: openai.Float(0.25),

Diff for: betaassistant.go

+41-1
Original file line numberDiff line numberDiff line change
@@ -2093,7 +2093,7 @@ type BetaAssistantUpdateParams struct {
20932093
// see all of your available models, or see our
20942094
// [Model overview](https://platform.openai.com/docs/models) for descriptions of
20952095
// them.
2096-
Model string `json:"model,omitzero"`
2096+
Model BetaAssistantUpdateParamsModel `json:"model,omitzero"`
20972097
// Specifies the format that the model must output. Compatible with
20982098
// [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
20992099
// [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
@@ -2131,6 +2131,46 @@ func (r BetaAssistantUpdateParams) MarshalJSON() (data []byte, err error) {
21312131
return param.MarshalObject(r, (*shadow)(&r))
21322132
}
21332133

2134+
// ID of the model to use. You can use the
2135+
// [List models](https://platform.openai.com/docs/api-reference/models/list) API to
2136+
// see all of your available models, or see our
2137+
// [Model overview](https://platform.openai.com/docs/models) for descriptions of
2138+
// them.
2139+
type BetaAssistantUpdateParamsModel string
2140+
2141+
const (
2142+
BetaAssistantUpdateParamsModelO3Mini BetaAssistantUpdateParamsModel = "o3-mini"
2143+
BetaAssistantUpdateParamsModelO3Mini2025_01_31 BetaAssistantUpdateParamsModel = "o3-mini-2025-01-31"
2144+
BetaAssistantUpdateParamsModelO1 BetaAssistantUpdateParamsModel = "o1"
2145+
BetaAssistantUpdateParamsModelO1_2024_12_17 BetaAssistantUpdateParamsModel = "o1-2024-12-17"
2146+
BetaAssistantUpdateParamsModelGPT4o BetaAssistantUpdateParamsModel = "gpt-4o"
2147+
BetaAssistantUpdateParamsModelGPT4o2024_11_20 BetaAssistantUpdateParamsModel = "gpt-4o-2024-11-20"
2148+
BetaAssistantUpdateParamsModelGPT4o2024_08_06 BetaAssistantUpdateParamsModel = "gpt-4o-2024-08-06"
2149+
BetaAssistantUpdateParamsModelGPT4o2024_05_13 BetaAssistantUpdateParamsModel = "gpt-4o-2024-05-13"
2150+
BetaAssistantUpdateParamsModelGPT4oMini BetaAssistantUpdateParamsModel = "gpt-4o-mini"
2151+
BetaAssistantUpdateParamsModelGPT4oMini2024_07_18 BetaAssistantUpdateParamsModel = "gpt-4o-mini-2024-07-18"
2152+
BetaAssistantUpdateParamsModelGPT4_5Preview BetaAssistantUpdateParamsModel = "gpt-4.5-preview"
2153+
BetaAssistantUpdateParamsModelGPT4_5Preview2025_02_27 BetaAssistantUpdateParamsModel = "gpt-4.5-preview-2025-02-27"
2154+
BetaAssistantUpdateParamsModelGPT4Turbo BetaAssistantUpdateParamsModel = "gpt-4-turbo"
2155+
BetaAssistantUpdateParamsModelGPT4Turbo2024_04_09 BetaAssistantUpdateParamsModel = "gpt-4-turbo-2024-04-09"
2156+
BetaAssistantUpdateParamsModelGPT4_0125Preview BetaAssistantUpdateParamsModel = "gpt-4-0125-preview"
2157+
BetaAssistantUpdateParamsModelGPT4TurboPreview BetaAssistantUpdateParamsModel = "gpt-4-turbo-preview"
2158+
BetaAssistantUpdateParamsModelGPT4_1106Preview BetaAssistantUpdateParamsModel = "gpt-4-1106-preview"
2159+
BetaAssistantUpdateParamsModelGPT4VisionPreview BetaAssistantUpdateParamsModel = "gpt-4-vision-preview"
2160+
BetaAssistantUpdateParamsModelGPT4 BetaAssistantUpdateParamsModel = "gpt-4"
2161+
BetaAssistantUpdateParamsModelGPT4_0314 BetaAssistantUpdateParamsModel = "gpt-4-0314"
2162+
BetaAssistantUpdateParamsModelGPT4_0613 BetaAssistantUpdateParamsModel = "gpt-4-0613"
2163+
BetaAssistantUpdateParamsModelGPT4_32k BetaAssistantUpdateParamsModel = "gpt-4-32k"
2164+
BetaAssistantUpdateParamsModelGPT4_32k0314 BetaAssistantUpdateParamsModel = "gpt-4-32k-0314"
2165+
BetaAssistantUpdateParamsModelGPT4_32k0613 BetaAssistantUpdateParamsModel = "gpt-4-32k-0613"
2166+
BetaAssistantUpdateParamsModelGPT3_5Turbo BetaAssistantUpdateParamsModel = "gpt-3.5-turbo"
2167+
BetaAssistantUpdateParamsModelGPT3_5Turbo16k BetaAssistantUpdateParamsModel = "gpt-3.5-turbo-16k"
2168+
BetaAssistantUpdateParamsModelGPT3_5Turbo0613 BetaAssistantUpdateParamsModel = "gpt-3.5-turbo-0613"
2169+
BetaAssistantUpdateParamsModelGPT3_5Turbo1106 BetaAssistantUpdateParamsModel = "gpt-3.5-turbo-1106"
2170+
BetaAssistantUpdateParamsModelGPT3_5Turbo0125 BetaAssistantUpdateParamsModel = "gpt-3.5-turbo-0125"
2171+
BetaAssistantUpdateParamsModelGPT3_5Turbo16k0613 BetaAssistantUpdateParamsModel = "gpt-3.5-turbo-16k-0613"
2172+
)
2173+
21342174
// A set of resources that are used by the assistant's tools. The resources are
21352175
// specific to the type of tool. For example, the `code_interpreter` tool requires
21362176
// a list of file IDs, while the `file_search` tool requires a list of vector store

Diff for: betaassistant_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func TestBetaAssistantUpdateWithOptionalParams(t *testing.T) {
114114
Metadata: shared.MetadataParam{
115115
"foo": "string",
116116
},
117-
Model: "o3-mini",
117+
Model: openai.BetaAssistantUpdateParamsModelO3Mini,
118118
Name: openai.String("name"),
119119
ReasoningEffort: shared.ReasoningEffortLow,
120120
ResponseFormat: openai.AssistantResponseFormatOptionUnionParam{

Diff for: betathread.go

+12
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,18 @@ func (r AssistantToolChoiceOptionUnion) ToParam() AssistantToolChoiceOptionUnion
403403
return param.OverrideObj[AssistantToolChoiceOptionUnionParam](r.RawJSON())
404404
}
405405

406+
// `none` means the model will not call any tools and instead generates a message.
407+
// `auto` means the model can pick between generating a message or calling one or
408+
// more tools. `required` means the model must call one or more tools before
409+
// responding to the user.
410+
type AssistantToolChoiceOptionAuto string
411+
412+
const (
413+
AssistantToolChoiceOptionAutoNone AssistantToolChoiceOptionAuto = "none"
414+
AssistantToolChoiceOptionAutoAuto AssistantToolChoiceOptionAuto = "auto"
415+
AssistantToolChoiceOptionAutoRequired AssistantToolChoiceOptionAuto = "required"
416+
)
417+
406418
func AssistantToolChoiceOptionParamOfAssistantToolChoice(type_ AssistantToolChoiceType) AssistantToolChoiceOptionUnionParam {
407419
var variant AssistantToolChoiceParam
408420
variant.Type = type_

Diff for: chatcompletion.go

+40-1
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ type ChatCompletionAudioParam struct {
500500
Format ChatCompletionAudioParamFormat `json:"format,omitzero,required"`
501501
// The voice the model uses to respond. Supported voices are `alloy`, `ash`,
502502
// `ballad`, `coral`, `echo`, `sage`, and `shimmer`.
503-
Voice string `json:"voice,omitzero,required"`
503+
Voice ChatCompletionAudioParamVoice `json:"voice,omitzero,required"`
504504
paramObj
505505
}
506506

@@ -524,6 +524,24 @@ const (
524524
ChatCompletionAudioParamFormatPcm16 ChatCompletionAudioParamFormat = "pcm16"
525525
)
526526

527+
// The voice the model uses to respond. Supported voices are `alloy`, `ash`,
528+
// `ballad`, `coral`, `echo`, `sage`, and `shimmer`.
529+
type ChatCompletionAudioParamVoice string
530+
531+
const (
532+
ChatCompletionAudioParamVoiceAlloy ChatCompletionAudioParamVoice = "alloy"
533+
ChatCompletionAudioParamVoiceAsh ChatCompletionAudioParamVoice = "ash"
534+
ChatCompletionAudioParamVoiceBallad ChatCompletionAudioParamVoice = "ballad"
535+
ChatCompletionAudioParamVoiceCoral ChatCompletionAudioParamVoice = "coral"
536+
ChatCompletionAudioParamVoiceEcho ChatCompletionAudioParamVoice = "echo"
537+
ChatCompletionAudioParamVoiceFable ChatCompletionAudioParamVoice = "fable"
538+
ChatCompletionAudioParamVoiceOnyx ChatCompletionAudioParamVoice = "onyx"
539+
ChatCompletionAudioParamVoiceNova ChatCompletionAudioParamVoice = "nova"
540+
ChatCompletionAudioParamVoiceSage ChatCompletionAudioParamVoice = "sage"
541+
ChatCompletionAudioParamVoiceShimmer ChatCompletionAudioParamVoice = "shimmer"
542+
ChatCompletionAudioParamVoiceVerse ChatCompletionAudioParamVoice = "verse"
543+
)
544+
527545
// Represents a streamed chunk of a chat completion response returned by the model,
528546
// based on the provided input.
529547
// [Learn more](https://platform.openai.com/docs/guides/streaming-responses).
@@ -2054,6 +2072,17 @@ func (u ChatCompletionToolChoiceOptionUnionParam) GetType() *string {
20542072
return nil
20552073
}
20562074

2075+
// `none` means the model will not call any tool and instead generates a message.
2076+
// `auto` means the model can pick between generating a message or calling one or
2077+
// more tools. `required` means the model must call one or more tools.
2078+
type ChatCompletionToolChoiceOptionAuto string
2079+
2080+
const (
2081+
ChatCompletionToolChoiceOptionAutoNone ChatCompletionToolChoiceOptionAuto = "none"
2082+
ChatCompletionToolChoiceOptionAutoAuto ChatCompletionToolChoiceOptionAuto = "auto"
2083+
ChatCompletionToolChoiceOptionAutoRequired ChatCompletionToolChoiceOptionAuto = "required"
2084+
)
2085+
20572086
// The properties Content, Role, ToolCallID are required.
20582087
type ChatCompletionToolMessageParam struct {
20592088
// The contents of the tool message.
@@ -2390,6 +2419,16 @@ func (u ChatCompletionNewParamsFunctionCallUnion) GetName() *string {
23902419
return nil
23912420
}
23922421

2422+
// `none` means the model will not call a function and instead generates a message.
2423+
// `auto` means the model can pick between generating a message or calling a
2424+
// function.
2425+
type ChatCompletionNewParamsFunctionCallFunctionCallMode string
2426+
2427+
const (
2428+
ChatCompletionNewParamsFunctionCallFunctionCallModeNone ChatCompletionNewParamsFunctionCallFunctionCallMode = "none"
2429+
ChatCompletionNewParamsFunctionCallFunctionCallModeAuto ChatCompletionNewParamsFunctionCallFunctionCallMode = "auto"
2430+
)
2431+
23932432
// Deprecated: deprecated
23942433
//
23952434
// The property Name is required.

Diff for: chatcompletion_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestChatCompletionNewWithOptionalParams(t *testing.T) {
3838
Model: shared.ChatModelO3Mini,
3939
Audio: openai.ChatCompletionAudioParam{
4040
Format: openai.ChatCompletionAudioParamFormatWAV,
41-
Voice: "alloy",
41+
Voice: openai.ChatCompletionAudioParamVoiceAlloy,
4242
},
4343
FrequencyPenalty: openai.Float(-2),
4444
FunctionCall: openai.ChatCompletionNewParamsFunctionCallUnion{

Diff for: completion.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ type CompletionNewParams struct {
258258
// see all of your available models, or see our
259259
// [Model overview](https://platform.openai.com/docs/models) for descriptions of
260260
// them.
261-
Model string `json:"model,omitzero,required"`
261+
Model CompletionNewParamsModel `json:"model,omitzero,required"`
262262
// Generates `best_of` completions server-side and returns the "best" (the one with
263263
// the highest log probability per token). Results cannot be streamed.
264264
//
@@ -361,6 +361,19 @@ func (r CompletionNewParams) MarshalJSON() (data []byte, err error) {
361361
return param.MarshalObject(r, (*shadow)(&r))
362362
}
363363

364+
// ID of the model to use. You can use the
365+
// [List models](https://platform.openai.com/docs/api-reference/models/list) API to
366+
// see all of your available models, or see our
367+
// [Model overview](https://platform.openai.com/docs/models) for descriptions of
368+
// them.
369+
type CompletionNewParamsModel string
370+
371+
const (
372+
CompletionNewParamsModelGPT3_5TurboInstruct CompletionNewParamsModel = "gpt-3.5-turbo-instruct"
373+
CompletionNewParamsModelDavinci002 CompletionNewParamsModel = "davinci-002"
374+
CompletionNewParamsModelBabbage002 CompletionNewParamsModel = "babbage-002"
375+
)
376+
364377
// Only one field can be non-zero.
365378
//
366379
// Use [param.IsOmitted] to confirm if a field is set.

Diff for: completion_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestCompletionNewWithOptionalParams(t *testing.T) {
2626
option.WithAPIKey("My API Key"),
2727
)
2828
_, err := client.Completions.New(context.TODO(), openai.CompletionNewParams{
29-
Model: "gpt-3.5-turbo-instruct",
29+
Model: openai.CompletionNewParamsModelGPT3_5TurboInstruct,
3030
Prompt: openai.CompletionNewParamsPromptUnion{
3131
OfString: openai.String("This is a test."),
3232
},

Diff for: finetuningjob.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ func (r *FineTuningJobWandbIntegrationObject) UnmarshalJSON(data []byte) error {
917917
type FineTuningJobNewParams struct {
918918
// The name of the model to fine-tune. You can select one of the
919919
// [supported models](https://platform.openai.com/docs/guides/fine-tuning#which-models-can-be-fine-tuned).
920-
Model string `json:"model,omitzero,required"`
920+
Model FineTuningJobNewParamsModel `json:"model,omitzero,required"`
921921
// The ID of an uploaded file that contains training data.
922922
//
923923
// See [upload file](https://platform.openai.com/docs/api-reference/files/create)
@@ -985,6 +985,17 @@ func (r FineTuningJobNewParams) MarshalJSON() (data []byte, err error) {
985985
return param.MarshalObject(r, (*shadow)(&r))
986986
}
987987

988+
// The name of the model to fine-tune. You can select one of the
989+
// [supported models](https://platform.openai.com/docs/guides/fine-tuning#which-models-can-be-fine-tuned).
990+
type FineTuningJobNewParamsModel string
991+
992+
const (
993+
FineTuningJobNewParamsModelBabbage002 FineTuningJobNewParamsModel = "babbage-002"
994+
FineTuningJobNewParamsModelDavinci002 FineTuningJobNewParamsModel = "davinci-002"
995+
FineTuningJobNewParamsModelGPT3_5Turbo FineTuningJobNewParamsModel = "gpt-3.5-turbo"
996+
FineTuningJobNewParamsModelGPT4oMini FineTuningJobNewParamsModel = "gpt-4o-mini"
997+
)
998+
988999
// The hyperparameters used for the fine-tuning job. This value is now deprecated
9891000
// in favor of `method`, and should be passed in under the `method` parameter.
9901001
//

Diff for: finetuningjob_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestFineTuningJobNewWithOptionalParams(t *testing.T) {
2828
option.WithAPIKey("My API Key"),
2929
)
3030
_, err := client.FineTuning.Jobs.New(context.TODO(), openai.FineTuningJobNewParams{
31-
Model: "babbage-002",
31+
Model: openai.FineTuningJobNewParamsModelBabbage002,
3232
TrainingFile: "file-abc123",
3333
Hyperparameters: openai.FineTuningJobNewParamsHyperparameters{
3434
BatchSize: openai.FineTuningJobNewParamsHyperparametersBatchSizeUnion{

0 commit comments

Comments
 (0)