Skip to content

chore(api): updates to supported Voice IDs #325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2025
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
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 80
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-5ad6884898c07591750dde560118baf7074a59aecd1f367f930c5e42b04e848a.yml
openapi_spec_hash: 0c255269b89767eae26f4d4dc22d3cbd
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-6663c59193eb95b201e492de17dcbd5e126ba03d18ce66287a3e2c632ca56fe7.yml
openapi_spec_hash: 7996d2c34cc44fe2ce9ffe93c0ab774e
config_hash: d36e491b0afc4f79e3afad4b3c9bec70
27 changes: 3 additions & 24 deletions audiospeech.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,10 @@ type AudioSpeechNewParams struct {
// `tts-1`, `tts-1-hd` or `gpt-4o-mini-tts`.
Model SpeechModel `json:"model,omitzero,required"`
// The voice to use when generating the audio. Supported voices are `alloy`, `ash`,
// `coral`, `echo`, `fable`, `onyx`, `nova`, `sage` and `shimmer`. Previews of the
// voices are available in the
// `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and
// `verse`. Previews of the voices are available in the
// [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).
//
// Any of "alloy", "ash", "coral", "echo", "fable", "onyx", "nova", "sage",
// "shimmer".
Voice AudioSpeechNewParamsVoice `json:"voice,omitzero,required"`
Voice string `json:"voice,omitzero,required"`
// Control the voice of your generated audio with additional instructions. Does not
// work with `tts-1` or `tts-1-hd`.
Instructions param.Opt[string] `json:"instructions,omitzero"`
Expand All @@ -84,24 +81,6 @@ func (r AudioSpeechNewParams) MarshalJSON() (data []byte, err error) {
return param.MarshalObject(r, (*shadow)(&r))
}

// The voice to use when generating the audio. Supported voices are `alloy`, `ash`,
// `coral`, `echo`, `fable`, `onyx`, `nova`, `sage` and `shimmer`. Previews of the
// voices are available in the
// [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).
type AudioSpeechNewParamsVoice string

const (
AudioSpeechNewParamsVoiceAlloy AudioSpeechNewParamsVoice = "alloy"
AudioSpeechNewParamsVoiceAsh AudioSpeechNewParamsVoice = "ash"
AudioSpeechNewParamsVoiceCoral AudioSpeechNewParamsVoice = "coral"
AudioSpeechNewParamsVoiceEcho AudioSpeechNewParamsVoice = "echo"
AudioSpeechNewParamsVoiceFable AudioSpeechNewParamsVoice = "fable"
AudioSpeechNewParamsVoiceOnyx AudioSpeechNewParamsVoice = "onyx"
AudioSpeechNewParamsVoiceNova AudioSpeechNewParamsVoice = "nova"
AudioSpeechNewParamsVoiceSage AudioSpeechNewParamsVoice = "sage"
AudioSpeechNewParamsVoiceShimmer AudioSpeechNewParamsVoice = "shimmer"
)

// The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`,
// `wav`, and `pcm`.
type AudioSpeechNewParamsResponseFormat string
Expand Down
2 changes: 1 addition & 1 deletion audiospeech_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestAudioSpeechNewWithOptionalParams(t *testing.T) {
resp, err := client.Audio.Speech.New(context.TODO(), openai.AudioSpeechNewParams{
Input: "input",
Model: openai.SpeechModelTTS1,
Voice: openai.AudioSpeechNewParamsVoiceAlloy,
Voice: "alloy",
Instructions: openai.String("instructions"),
ResponseFormat: openai.AudioSpeechNewParamsResponseFormatMP3,
Speed: openai.Float(0.25),
Expand Down
19 changes: 1 addition & 18 deletions chatcompletion.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,9 +500,7 @@ type ChatCompletionAudioParam struct {
Format ChatCompletionAudioParamFormat `json:"format,omitzero,required"`
// The voice the model uses to respond. Supported voices are `alloy`, `ash`,
// `ballad`, `coral`, `echo`, `sage`, and `shimmer`.
//
// Any of "alloy", "ash", "ballad", "coral", "echo", "sage", "shimmer", "verse".
Voice ChatCompletionAudioParamVoice `json:"voice,omitzero,required"`
Voice string `json:"voice,omitzero,required"`
paramObj
}

Expand All @@ -526,21 +524,6 @@ const (
ChatCompletionAudioParamFormatPcm16 ChatCompletionAudioParamFormat = "pcm16"
)

// The voice the model uses to respond. Supported voices are `alloy`, `ash`,
// `ballad`, `coral`, `echo`, `sage`, and `shimmer`.
type ChatCompletionAudioParamVoice string

const (
ChatCompletionAudioParamVoiceAlloy ChatCompletionAudioParamVoice = "alloy"
ChatCompletionAudioParamVoiceAsh ChatCompletionAudioParamVoice = "ash"
ChatCompletionAudioParamVoiceBallad ChatCompletionAudioParamVoice = "ballad"
ChatCompletionAudioParamVoiceCoral ChatCompletionAudioParamVoice = "coral"
ChatCompletionAudioParamVoiceEcho ChatCompletionAudioParamVoice = "echo"
ChatCompletionAudioParamVoiceSage ChatCompletionAudioParamVoice = "sage"
ChatCompletionAudioParamVoiceShimmer ChatCompletionAudioParamVoice = "shimmer"
ChatCompletionAudioParamVoiceVerse ChatCompletionAudioParamVoice = "verse"
)

// Represents a streamed chunk of a chat completion response returned by the model,
// based on the provided input.
// [Learn more](https://platform.openai.com/docs/guides/streaming-responses).
Expand Down
2 changes: 1 addition & 1 deletion chatcompletion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestChatCompletionNewWithOptionalParams(t *testing.T) {
Model: shared.ChatModelO3Mini,
Audio: openai.ChatCompletionAudioParam{
Format: openai.ChatCompletionAudioParamFormatWAV,
Voice: openai.ChatCompletionAudioParamVoiceAlloy,
Voice: "alloy",
},
FrequencyPenalty: openai.Float(-2),
FunctionCall: openai.ChatCompletionNewParamsFunctionCallUnion{
Expand Down
3 changes: 3 additions & 0 deletions responses/inputitem.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ type InputItemListParams struct {
// 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:"-"`
// Additional fields to include in the response. See the `include` parameter for
// Response creation above for more information.
Include []ResponseIncludable `query:"include,omitzero" json:"-"`
// The order to return the input items in. Default is `asc`.
//
// - `asc`: Return the input items in ascending order.
Expand Down
9 changes: 5 additions & 4 deletions responses/inputitem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ func TestInputItemListWithOptionalParams(t *testing.T) {
context.TODO(),
"response_id",
responses.InputItemListParams{
After: openai.String("after"),
Before: openai.String("before"),
Limit: openai.Int(0),
Order: responses.InputItemListParamsOrderAsc,
After: openai.String("after"),
Before: openai.String("before"),
Include: []responses.ResponseIncludable{responses.ResponseIncludableFileSearchCallResults},
Limit: openai.Int(0),
Order: responses.InputItemListParamsOrderAsc,
},
)
if err != nil {
Expand Down
49 changes: 25 additions & 24 deletions responses/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,8 @@ type Response struct {
// context.
//
// When using along with `previous_response_id`, the instructions from a previous
// response will be not be carried over to the next response. This makes it simple
// to swap out system (or developer) messages in new responses.
// response will not be carried over to the next response. This makes it simple to
// swap out system (or developer) messages in new responses.
Instructions string `json:"instructions,required"`
// 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
Expand Down Expand Up @@ -2958,18 +2958,18 @@ type ResponseFormatTextConfigUnion struct {
// Any of "text", "json_schema", "json_object".
Type string `json:"type"`
// This field is from variant [ResponseFormatTextJSONSchemaConfig].
Name string `json:"name"`
// This field is from variant [ResponseFormatTextJSONSchemaConfig].
Schema map[string]interface{} `json:"schema"`
// This field is from variant [ResponseFormatTextJSONSchemaConfig].
Description string `json:"description"`
// This field is from variant [ResponseFormatTextJSONSchemaConfig].
Name string `json:"name"`
// This field is from variant [ResponseFormatTextJSONSchemaConfig].
Strict bool `json:"strict"`
JSON struct {
Type resp.Field
Name resp.Field
Schema resp.Field
Description resp.Field
Name resp.Field
Strict resp.Field
raw string
} `json:"-"`
Expand Down Expand Up @@ -3028,8 +3028,9 @@ func (r ResponseFormatTextConfigUnion) ToParam() ResponseFormatTextConfigUnionPa
return param.OverrideObj[ResponseFormatTextConfigUnionParam](r.RawJSON())
}

func ResponseFormatTextConfigParamOfJSONSchema(schema map[string]interface{}) ResponseFormatTextConfigUnionParam {
func ResponseFormatTextConfigParamOfJSONSchema(name string, schema map[string]interface{}) ResponseFormatTextConfigUnionParam {
var jsonSchema ResponseFormatTextJSONSchemaConfigParam
jsonSchema.Name = name
jsonSchema.Schema = schema
return ResponseFormatTextConfigUnionParam{OfJSONSchema: &jsonSchema}
}
Expand Down Expand Up @@ -3065,25 +3066,25 @@ func (u *ResponseFormatTextConfigUnionParam) asAny() any {
}

// Returns a pointer to the underlying variant's property, if present.
func (u ResponseFormatTextConfigUnionParam) GetSchema() map[string]interface{} {
func (u ResponseFormatTextConfigUnionParam) GetName() *string {
if vt := u.OfJSONSchema; vt != nil {
return vt.Schema
return &vt.Name
}
return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u ResponseFormatTextConfigUnionParam) GetDescription() *string {
if vt := u.OfJSONSchema; vt != nil && vt.Description.IsPresent() {
return &vt.Description.Value
func (u ResponseFormatTextConfigUnionParam) GetSchema() map[string]interface{} {
if vt := u.OfJSONSchema; vt != nil {
return vt.Schema
}
return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u ResponseFormatTextConfigUnionParam) GetName() *string {
if vt := u.OfJSONSchema; vt != nil && vt.Name.IsPresent() {
return &vt.Name.Value
func (u ResponseFormatTextConfigUnionParam) GetDescription() *string {
if vt := u.OfJSONSchema; vt != nil && vt.Description.IsPresent() {
return &vt.Description.Value
}
return nil
}
Expand Down Expand Up @@ -3133,6 +3134,9 @@ func init() {
// more about
// [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).
type ResponseFormatTextJSONSchemaConfig struct {
// The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores
// and dashes, with a maximum length of 64.
Name string `json:"name,required"`
// The schema for the response format, described as a JSON Schema object. Learn how
// to build JSON schemas [here](https://json-schema.org/).
Schema map[string]interface{} `json:"schema,required"`
Expand All @@ -3141,9 +3145,6 @@ type ResponseFormatTextJSONSchemaConfig struct {
// A description of what the response format is for, used by the model to determine
// how to respond in the format.
Description string `json:"description"`
// The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores
// and dashes, with a maximum length of 64.
Name string `json:"name"`
// Whether to enable strict schema adherence when generating the output. If set to
// true, the model will always follow the exact schema defined in the `schema`
// field. Only a subset of JSON Schema is supported when `strict` is `true`. To
Expand All @@ -3153,10 +3154,10 @@ type ResponseFormatTextJSONSchemaConfig struct {
// Metadata for the response, check the presence of optional fields with the
// [resp.Field.IsPresent] method.
JSON struct {
Name resp.Field
Schema resp.Field
Type resp.Field
Description resp.Field
Name resp.Field
Strict resp.Field
ExtraFields map[string]resp.Field
raw string
Expand All @@ -3183,8 +3184,11 @@ func (r ResponseFormatTextJSONSchemaConfig) ToParam() ResponseFormatTextJSONSche
// more about
// [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).
//
// The properties Schema, Type are required.
// The properties Name, Schema, Type are required.
type ResponseFormatTextJSONSchemaConfigParam struct {
// The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores
// and dashes, with a maximum length of 64.
Name string `json:"name,required"`
// The schema for the response format, described as a JSON Schema object. Learn how
// to build JSON schemas [here](https://json-schema.org/).
Schema map[string]interface{} `json:"schema,omitzero,required"`
Expand All @@ -3197,9 +3201,6 @@ type ResponseFormatTextJSONSchemaConfigParam struct {
// A description of what the response format is for, used by the model to determine
// how to respond in the format.
Description param.Opt[string] `json:"description,omitzero"`
// The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores
// and dashes, with a maximum length of 64.
Name param.Opt[string] `json:"name,omitzero"`
// The type of response format being defined. Always `json_schema`.
//
// This field can be elided, and will marshal its zero value as "json_schema".
Expand Down Expand Up @@ -7425,8 +7426,8 @@ type ResponseNewParams struct {
// context.
//
// When using along with `previous_response_id`, the instructions from a previous
// response will be not be carried over to the next response. This makes it simple
// to swap out system (or developer) messages in new responses.
// response will not be carried over to the next response. This makes it simple to
// swap out system (or developer) messages in new responses.
Instructions param.Opt[string] `json:"instructions,omitzero"`
// An upper bound for the number of tokens that can be generated for a response,
// including visible output tokens and
Expand Down