@@ -4,11 +4,11 @@ package openai
9 "net/http"
10 "net/http"
13 "github.com/openai/openai-go/internal/apijson"
13 "github.com/openai/openai-go/internal/apijson"
14 "github.com/openai/openai-go/internal/apiquery"
14 "github.com/openai/openai-go/internal/apiquery"
@@ -16,11 +16,10 @@ import (
16 "github.com/openai/openai-go/option"
16 "github.com/openai/openai-go/option"
17 "github.com/openai/openai-go/packages/pagination"
17 "github.com/openai/openai-go/packages/pagination"
18 "github.com/openai/openai-go/packages/param"
18 "github.com/openai/openai-go/packages/param"
19− "github.com/openai/openai-go/packages/resp"
19+ "github.com/openai/openai-go/packages/respjson"
20 "github.com/openai/openai-go/packages/ssestream"
20 "github.com/openai/openai-go/packages/ssestream"
21 "github.com/openai/openai-go/shared"
21 "github.com/openai/openai-go/shared"
22 "github.com/openai/openai-go/shared/constant"
22 "github.com/openai/openai-go/shared/constant"
23− "github.com/tidwall/gjson"
26// ChatCompletionService contains methods and other services that help with
25// ChatCompletionService contains methods and other services that help with
@@ -176,9 +175,25 @@ type ChatCompletion struct {
176 Model string `json:"model,required"`
175 Model string `json:"model,required"`
177 // The object type, which is always `chat.completion`.
176 // The object type, which is always `chat.completion`.
178 Object constant.ChatCompletion `json:"object,required"`
177 Object constant.ChatCompletion `json:"object,required"`
179− // The service tier used for processing the request.
178+ // Specifies the processing type used for serving the request.
180+ // - If set to 'auto', then the request will be processed with the service tier
181+ // configured in the Project settings. Unless otherwise configured, the Project
182+ // will use 'default'.
183+ // - If set to 'default', then the requset will be processed with the standard
184+ // pricing and performance for the selected model.
185+ // - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
186+ // 'priority', then the request will be processed with the corresponding service
187+ // tier. [Contact sales](https://openai.com/contact-sales) to learn more about
188+ // Priority processing.
189+ // - When not set, the default behavior is 'auto'.
191+ // When the `service_tier` parameter is set, the response body will include the
192+ // `service_tier` value based on the processing mode actually used to serve the
193+ // request. This response value may be different from the value set in the
181− // Any of "scale", "default".
196+ // Any of "auto", "default", "flex", "scale", "priority".
182 ServiceTier ChatCompletionServiceTier `json:"service_tier,nullable"`
197 ServiceTier ChatCompletionServiceTier `json:"service_tier,nullable"`
183 // This fingerprint represents the backend configuration that the model runs with.
198 // This fingerprint represents the backend configuration that the model runs with.
@@ -187,18 +202,17 @@ type ChatCompletion struct {
187 SystemFingerprint string `json:"system_fingerprint"`
202 SystemFingerprint string `json:"system_fingerprint"`
188 // Usage statistics for the completion request.
203 // Usage statistics for the completion request.
189 Usage CompletionUsage `json:"usage"`
204 Usage CompletionUsage `json:"usage"`
190− // Metadata for the response, check the presence of optional fields with the
205+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
191− // [resp.Field.IsPresent] method.
192 JSON struct {
206 JSON struct {
193− ID resp.Field
207+ ID respjson.Field
194− Choices resp.Field
208+ Choices respjson.Field
195− Created resp.Field
209+ Created respjson.Field
196− Model resp.Field
210+ Model respjson.Field
197− Object resp.Field
211+ Object respjson.Field
198− ServiceTier resp.Field
212+ ServiceTier respjson.Field
199− SystemFingerprint resp.Field
213+ SystemFingerprint respjson.Field
200− Usage resp.Field
214+ Usage respjson.Field
201− ExtraFields map[string]resp.Field
215+ ExtraFields map[string]respjson.Field
202 raw string
216 raw string
203 } `json:"-"`
217 } `json:"-"`
@@ -225,14 +239,13 @@ type ChatCompletionChoice struct {
225 Logprobs ChatCompletionChoiceLogprobs `json:"logprobs,required"`
239 Logprobs ChatCompletionChoiceLogprobs `json:"logprobs,required"`
226 // A chat completion message generated by the model.
240 // A chat completion message generated by the model.
227 Message ChatCompletionMessage `json:"message,required"`
241 Message ChatCompletionMessage `json:"message,required"`
228− // Metadata for the response, check the presence of optional fields with the
242+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
229− // [resp.Field.IsPresent] method.
230 JSON struct {
243 JSON struct {
231− FinishReason resp.Field
244+ FinishReason respjson.Field
232− Index resp.Field
245+ Index respjson.Field
233− Logprobs resp.Field
246+ Logprobs respjson.Field
234− Message resp.Field
247+ Message respjson.Field
235− ExtraFields map[string]resp.Field
248+ ExtraFields map[string]respjson.Field
236 raw string
249 raw string
237 } `json:"-"`
250 } `json:"-"`
@@ -249,12 +262,11 @@ type ChatCompletionChoiceLogprobs struct {
249 Content []ChatCompletionTokenLogprob `json:"content,required"`
262 Content []ChatCompletionTokenLogprob `json:"content,required"`
250 // A list of message refusal tokens with log probability information.
263 // A list of message refusal tokens with log probability information.
251 Refusal []ChatCompletionTokenLogprob `json:"refusal,required"`
264 Refusal []ChatCompletionTokenLogprob `json:"refusal,required"`
252− // Metadata for the response, check the presence of optional fields with the
265+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
253− // [resp.Field.IsPresent] method.
254 JSON struct {
266 JSON struct {
255− Content resp.Field
267+ Content respjson.Field
256− Refusal resp.Field
268+ Refusal respjson.Field
257− ExtraFields map[string]resp.Field
269+ ExtraFields map[string]respjson.Field
258 raw string
270 raw string
259 } `json:"-"`
271 } `json:"-"`
@@ -265,12 +277,31 @@ func (r *ChatCompletionChoiceLogprobs) UnmarshalJSON(data []byte) error {
265 return apijson.UnmarshalRoot(data, r)
277 return apijson.UnmarshalRoot(data, r)
268−// The service tier used for processing the request.
280+// Specifies the processing type used for serving the request.
282+// - If set to 'auto', then the request will be processed with the service tier
283+// configured in the Project settings. Unless otherwise configured, the Project
284+// will use 'default'.
285+// - If set to 'default', then the requset will be processed with the standard
286+// pricing and performance for the selected model.
287+// - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
288+// 'priority', then the request will be processed with the corresponding service
289+// tier. [Contact sales](https://openai.com/contact-sales) to learn more about
290+// Priority processing.
291+// - When not set, the default behavior is 'auto'.
293+// When the `service_tier` parameter is set, the response body will include the
294+// `service_tier` value based on the processing mode actually used to serve the
295+// request. This response value may be different from the value set in the
269type ChatCompletionServiceTier string
297type ChatCompletionServiceTier string
300+ ChatCompletionServiceTierAuto ChatCompletionServiceTier = "auto"
301+ ChatCompletionServiceTierDefault ChatCompletionServiceTier = "default"
302+ ChatCompletionServiceTierFlex ChatCompletionServiceTier = "flex"
272− ChatCompletionServiceTierScale ChatCompletionServiceTier = "scale"
303+ ChatCompletionServiceTierScale ChatCompletionServiceTier = "scale"
273− ChatCompletionServiceTierDefault ChatCompletionServiceTier = "default"
304+ ChatCompletionServiceTierPriority ChatCompletionServiceTier = "priority"
276// Messages sent by the model in response to user messages.
307// Messages sent by the model in response to user messages.
@@ -302,15 +333,13 @@ type ChatCompletionAssistantMessageParam struct {
305−// IsPresent returns true if the field's value is not omitted and not the JSON
306−// "null". To check if this field is omitted, use [param.IsOmitted].
307−func (f ChatCompletionAssistantMessageParam) IsPresent() bool {
308− return !param.IsOmitted(f) && !f.IsNull()
310func (r ChatCompletionAssistantMessageParam) MarshalJSON() (data []byte, err error) {
336func (r ChatCompletionAssistantMessageParam) MarshalJSON() (data []byte, err error) {
311 type shadow ChatCompletionAssistantMessageParam
337 type shadow ChatCompletionAssistantMessageParam
312 return param.MarshalObject(r, (*shadow)(&r))
338 return param.MarshalObject(r, (*shadow)(&r))
340+func (r *ChatCompletionAssistantMessageParam) UnmarshalJSON(data []byte) error {
341+ return apijson.UnmarshalRoot(data, r)
315// Data about a previous audio response from the model.
344// Data about a previous audio response from the model.
316// [Learn more](https://platform.openai.com/docs/guides/audio).
345// [Learn more](https://platform.openai.com/docs/guides/audio).
@@ -322,15 +351,13 @@ type ChatCompletionAssistantMessageParamAudio struct {
325−// IsPresent returns true if the field's value is not omitted and not the JSON
326−// "null". To check if this field is omitted, use [param.IsOmitted].
327−func (f ChatCompletionAssistantMessageParamAudio) IsPresent() bool {
328− return !param.IsOmitted(f) && !f.IsNull()
330func (r ChatCompletionAssistantMessageParamAudio) MarshalJSON() (data []byte, err error) {
354func (r ChatCompletionAssistantMessageParamAudio) MarshalJSON() (data []byte, err error) {
331 type shadow ChatCompletionAssistantMessageParamAudio
355 type shadow ChatCompletionAssistantMessageParamAudio
332 return param.MarshalObject(r, (*shadow)(&r))
356 return param.MarshalObject(r, (*shadow)(&r))
358+func (r *ChatCompletionAssistantMessageParamAudio) UnmarshalJSON(data []byte) error {
359+ return apijson.UnmarshalRoot(data, r)
335// Only one field can be non-zero.
362// Only one field can be non-zero.
@@ -341,13 +368,11 @@ type ChatCompletionAssistantMessageParamContentUnion struct {
341 paramUnion
368 paramUnion
344−// IsPresent returns true if the field's value is not omitted and not the JSON
345−// "null". To check if this field is omitted, use [param.IsOmitted].
346−func (u ChatCompletionAssistantMessageParamContentUnion) IsPresent() bool {
347− return !param.IsOmitted(u) && !u.IsNull()
349func (u ChatCompletionAssistantMessageParamContentUnion) MarshalJSON() ([]byte, error) {
371func (u ChatCompletionAssistantMessageParamContentUnion) MarshalJSON() ([]byte, error) {
372+ return param.MarshalUnion(u, u.OfString, u.OfArrayOfContentParts)
350− return param.MarshalUnion[ChatCompletionAssistantMessageParamContentUnion](u.OfString, u.OfArrayOfContentParts)
374+func (u *ChatCompletionAssistantMessageParamContentUnion) UnmarshalJSON(data []byte) error {
375+ return apijson.UnmarshalRoot(data, u)
353func (u *ChatCompletionAssistantMessageParamContentUnion) asAny() any {
378func (u *ChatCompletionAssistantMessageParamContentUnion) asAny() any {
@@ -368,13 +393,11 @@ type ChatCompletionAssistantMessageParamContentArrayOfContentPartUnion struct {
368 paramUnion
393 paramUnion
371−// IsPresent returns true if the field's value is not omitted and not the JSON
372−// "null". To check if this field is omitted, use [param.IsOmitted].
373−func (u ChatCompletionAssistantMessageParamContentArrayOfContentPartUnion) IsPresent() bool {
374− return !param.IsOmitted(u) && !u.IsNull()
376func (u ChatCompletionAssistantMessageParamContentArrayOfContentPartUnion) MarshalJSON() ([]byte, error) {
396func (u ChatCompletionAssistantMessageParamContentArrayOfContentPartUnion) MarshalJSON() ([]byte, error) {
397+ return param.MarshalUnion(u, u.OfText, u.OfRefusal)
377− return param.MarshalUnion[ChatCompletionAssistantMessageParamContentArrayOfContentPartUnion](u.OfText, u.OfRefusal)
399+func (u *ChatCompletionAssistantMessageParamContentArrayOfContentPartUnion) UnmarshalJSON(data []byte) error {
400+ return apijson.UnmarshalRoot(data, u)
380func (u *ChatCompletionAssistantMessageParamContentArrayOfContentPartUnion) asAny() any {
403func (u *ChatCompletionAssistantMessageParamContentArrayOfContentPartUnion) asAny() any {
@@ -415,16 +438,8 @@ func (u ChatCompletionAssistantMessageParamContentArrayOfContentPartUnion) GetTy
415func init() {
438func init() {
416 apijson.RegisterUnion[ChatCompletionAssistantMessageParamContentArrayOfContentPartUnion](
439 apijson.RegisterUnion[ChatCompletionAssistantMessageParamContentArrayOfContentPartUnion](
418− apijson.UnionVariant{
419− TypeFilter: gjson.JSON,
420− Type: reflect.TypeOf(ChatCompletionContentPartTextParam{}),
441+ apijson.Discriminator[ChatCompletionContentPartTextParam]("text"),
421− DiscriminatorValue: "text",
423− apijson.UnionVariant{
424− TypeFilter: gjson.JSON,
425− Type: reflect.TypeOf(ChatCompletionContentPartRefusalParam{}),
442+ apijson.Discriminator[ChatCompletionContentPartRefusalParam]("refusal"),
426− DiscriminatorValue: "refusal",
@@ -445,15 +460,13 @@ type ChatCompletionAssistantMessageParamFunctionCall struct {
448−// IsPresent returns true if the field's value is not omitted and not the JSON
449−// "null". To check if this field is omitted, use [param.IsOmitted].
450−func (f ChatCompletionAssistantMessageParamFunctionCall) IsPresent() bool {
451− return !param.IsOmitted(f) && !f.IsNull()
453func (r ChatCompletionAssistantMessageParamFunctionCall) MarshalJSON() (data []byte, err error) {
463func (r ChatCompletionAssistantMessageParamFunctionCall) MarshalJSON() (data []byte, err error) {
454 type shadow ChatCompletionAssistantMessageParamFunctionCall
464 type shadow ChatCompletionAssistantMessageParamFunctionCall
455 return param.MarshalObject(r, (*shadow)(&r))
465 return param.MarshalObject(r, (*shadow)(&r))
467+func (r *ChatCompletionAssistantMessageParamFunctionCall) UnmarshalJSON(data []byte) error {
468+ return apijson.UnmarshalRoot(data, r)
458// If the audio output modality is requested, this object contains data about the
471// If the audio output modality is requested, this object contains data about the
459// audio response from the model.
472// audio response from the model.
@@ -469,14 +482,13 @@ type ChatCompletionAudio struct {
469 ExpiresAt int64 `json:"expires_at,required"`
482 ExpiresAt int64 `json:"expires_at,required"`
470 // Transcript of the audio generated by the model.
483 // Transcript of the audio generated by the model.
471 Transcript string `json:"transcript,required"`
484 Transcript string `json:"transcript,required"`
472− // Metadata for the response, check the presence of optional fields with the
485+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
473− // [resp.Field.IsPresent] method.
474 JSON struct {
486 JSON struct {
475− ID resp.Field
487+ ID respjson.Field
476− Data resp.Field
488+ Data respjson.Field
477− ExpiresAt resp.Field
489+ ExpiresAt respjson.Field
478− Transcript resp.Field
490+ Transcript respjson.Field
479− ExtraFields map[string]resp.Field
491+ ExtraFields map[string]respjson.Field
480 raw string
492 raw string
481 } `json:"-"`
493 } `json:"-"`
@@ -496,23 +508,21 @@ type ChatCompletionAudioParam struct {
496 // Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`, `opus`,
508 // Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`, `opus`,
497 // or `pcm16`.
509 // or `pcm16`.
499− // Any of "wav", "mp3", "flac", "opus", "pcm16".
511+ // Any of "wav", "aac", "mp3", "flac", "opus", "pcm16".
500 Format ChatCompletionAudioParamFormat `json:"format,omitzero,required"`
512 Format ChatCompletionAudioParamFormat `json:"format,omitzero,required"`
501 // The voice the model uses to respond. Supported voices are `alloy`, `ash`,
513 // The voice the model uses to respond. Supported voices are `alloy`, `ash`,
502− // `ballad`, `coral`, `echo`, `sage`, and `shimmer`.
514+ // `ballad`, `coral`, `echo`, `fable`, `nova`, `onyx`, `sage`, and `shimmer`.
504− // Any of "alloy", "ash", "ballad", "coral", "echo", "sage", "shimmer", "verse".
505 Voice ChatCompletionAudioParamVoice `json:"voice,omitzero,required"`
515 Voice ChatCompletionAudioParamVoice `json:"voice,omitzero,required"`
509−// IsPresent returns true if the field's value is not omitted and not the JSON
510−// "null". To check if this field is omitted, use [param.IsOmitted].
511−func (f ChatCompletionAudioParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
512func (r ChatCompletionAudioParam) MarshalJSON() (data []byte, err error) {
519func (r ChatCompletionAudioParam) MarshalJSON() (data []byte, err error) {
513 type shadow ChatCompletionAudioParam
520 type shadow ChatCompletionAudioParam
514 return param.MarshalObject(r, (*shadow)(&r))
521 return param.MarshalObject(r, (*shadow)(&r))
523+func (r *ChatCompletionAudioParam) UnmarshalJSON(data []byte) error {
524+ return apijson.UnmarshalRoot(data, r)
517// Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`, `opus`,
527// Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`, `opus`,
518// or `pcm16`.
528// or `pcm16`.
@@ -520,6 +530,7 @@ type ChatCompletionAudioParamFormat string
522 ChatCompletionAudioParamFormatWAV ChatCompletionAudioParamFormat = "wav"
532 ChatCompletionAudioParamFormatWAV ChatCompletionAudioParamFormat = "wav"
533+ ChatCompletionAudioParamFormatAAC ChatCompletionAudioParamFormat = "aac"
523 ChatCompletionAudioParamFormatMP3 ChatCompletionAudioParamFormat = "mp3"
534 ChatCompletionAudioParamFormatMP3 ChatCompletionAudioParamFormat = "mp3"
524 ChatCompletionAudioParamFormatFLAC ChatCompletionAudioParamFormat = "flac"
535 ChatCompletionAudioParamFormatFLAC ChatCompletionAudioParamFormat = "flac"
525 ChatCompletionAudioParamFormatOpus ChatCompletionAudioParamFormat = "opus"
536 ChatCompletionAudioParamFormatOpus ChatCompletionAudioParamFormat = "opus"
@@ -527,7 +538,7 @@ const (
529// The voice the model uses to respond. Supported voices are `alloy`, `ash`,
540// The voice the model uses to respond. Supported voices are `alloy`, `ash`,
530−// `ballad`, `coral`, `echo`, `sage`, and `shimmer`.
541+// `ballad`, `coral`, `echo`, `fable`, `nova`, `onyx`, `sage`, and `shimmer`.
531type ChatCompletionAudioParamVoice string
542type ChatCompletionAudioParamVoice string
@@ -536,6 +547,9 @@ const (
536 ChatCompletionAudioParamVoiceBallad ChatCompletionAudioParamVoice = "ballad"
547 ChatCompletionAudioParamVoiceBallad ChatCompletionAudioParamVoice = "ballad"
537 ChatCompletionAudioParamVoiceCoral ChatCompletionAudioParamVoice = "coral"
548 ChatCompletionAudioParamVoiceCoral ChatCompletionAudioParamVoice = "coral"
538 ChatCompletionAudioParamVoiceEcho ChatCompletionAudioParamVoice = "echo"
549 ChatCompletionAudioParamVoiceEcho ChatCompletionAudioParamVoice = "echo"
550+ ChatCompletionAudioParamVoiceFable ChatCompletionAudioParamVoice = "fable"
551+ ChatCompletionAudioParamVoiceOnyx ChatCompletionAudioParamVoice = "onyx"
552+ ChatCompletionAudioParamVoiceNova ChatCompletionAudioParamVoice = "nova"
539 ChatCompletionAudioParamVoiceSage ChatCompletionAudioParamVoice = "sage"
553 ChatCompletionAudioParamVoiceSage ChatCompletionAudioParamVoice = "sage"
540 ChatCompletionAudioParamVoiceShimmer ChatCompletionAudioParamVoice = "shimmer"
554 ChatCompletionAudioParamVoiceShimmer ChatCompletionAudioParamVoice = "shimmer"
541 ChatCompletionAudioParamVoiceVerse ChatCompletionAudioParamVoice = "verse"
555 ChatCompletionAudioParamVoiceVerse ChatCompletionAudioParamVoice = "verse"
@@ -558,9 +572,25 @@ type ChatCompletionChunk struct {
558 Model string `json:"model,required"`
572 Model string `json:"model,required"`
559 // The object type, which is always `chat.completion.chunk`.
573 // The object type, which is always `chat.completion.chunk`.
560 Object constant.ChatCompletionChunk `json:"object,required"`
574 Object constant.ChatCompletionChunk `json:"object,required"`
561− // The service tier used for processing the request.
575+ // Specifies the processing type used for serving the request.
577+ // - If set to 'auto', then the request will be processed with the service tier
578+ // configured in the Project settings. Unless otherwise configured, the Project
579+ // will use 'default'.
580+ // - If set to 'default', then the requset will be processed with the standard
581+ // pricing and performance for the selected model.
582+ // - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
583+ // 'priority', then the request will be processed with the corresponding service
584+ // tier. [Contact sales](https://openai.com/contact-sales) to learn more about
585+ // Priority processing.
586+ // - When not set, the default behavior is 'auto'.
588+ // When the `service_tier` parameter is set, the response body will include the
589+ // `service_tier` value based on the processing mode actually used to serve the
590+ // request. This response value may be different from the value set in the
563− // Any of "scale", "default".
593+ // Any of "auto", "default", "flex", "scale", "priority".
564 ServiceTier ChatCompletionChunkServiceTier `json:"service_tier,nullable"`
594 ServiceTier ChatCompletionChunkServiceTier `json:"service_tier,nullable"`
565 // This fingerprint represents the backend configuration that the model runs with.
595 // This fingerprint represents the backend configuration that the model runs with.
566 // Can be used in conjunction with the `seed` request parameter to understand when
596 // Can be used in conjunction with the `seed` request parameter to understand when
@@ -574,18 +604,17 @@ type ChatCompletionChunk struct {
574 // **NOTE:** If the stream is interrupted or cancelled, you may not receive the
604 // **NOTE:** If the stream is interrupted or cancelled, you may not receive the
575 // final usage chunk which contains the total token usage for the request.
605 // final usage chunk which contains the total token usage for the request.
576 Usage CompletionUsage `json:"usage,nullable"`
606 Usage CompletionUsage `json:"usage,nullable"`
577− // Metadata for the response, check the presence of optional fields with the
607+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
578− // [resp.Field.IsPresent] method.
579 JSON struct {
608 JSON struct {
580− ID resp.Field
609+ ID respjson.Field
581− Choices resp.Field
610+ Choices respjson.Field
582− Created resp.Field
611+ Created respjson.Field
583− Model resp.Field
612+ Model respjson.Field
584− Object resp.Field
613+ Object respjson.Field
585− ServiceTier resp.Field
614+ ServiceTier respjson.Field
586− SystemFingerprint resp.Field
615+ SystemFingerprint respjson.Field
587− Usage resp.Field
616+ Usage respjson.Field
588− ExtraFields map[string]resp.Field
617+ ExtraFields map[string]respjson.Field
589 raw string
618 raw string
590 } `json:"-"`
619 } `json:"-"`
@@ -612,14 +641,13 @@ type ChatCompletionChunkChoice struct {
612 Index int64 `json:"index,required"`
641 Index int64 `json:"index,required"`
613 // Log probability information for the choice.
642 // Log probability information for the choice.
614 Logprobs ChatCompletionChunkChoiceLogprobs `json:"logprobs,nullable"`
643 Logprobs ChatCompletionChunkChoiceLogprobs `json:"logprobs,nullable"`
615− // Metadata for the response, check the presence of optional fields with the
644+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
616− // [resp.Field.IsPresent] method.
617 JSON struct {
645 JSON struct {
618− Delta resp.Field
646+ Delta respjson.Field
619− FinishReason resp.Field
647+ FinishReason respjson.Field
620− Index resp.Field
648+ Index respjson.Field
621− Logprobs resp.Field
649+ Logprobs respjson.Field
622− ExtraFields map[string]resp.Field
650+ ExtraFields map[string]respjson.Field
623 raw string
651 raw string
624 } `json:"-"`
652 } `json:"-"`
@@ -646,15 +674,14 @@ type ChatCompletionChunkChoiceDelta struct {
646 // Any of "developer", "system", "user", "assistant", "tool".
674 // Any of "developer", "system", "user", "assistant", "tool".
647 Role string `json:"role"`
675 Role string `json:"role"`
648 ToolCalls []ChatCompletionChunkChoiceDeltaToolCall `json:"tool_calls"`
676 ToolCalls []ChatCompletionChunkChoiceDeltaToolCall `json:"tool_calls"`
649− // Metadata for the response, check the presence of optional fields with the
677+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
650− // [resp.Field.IsPresent] method.
651 JSON struct {
678 JSON struct {
652− Content resp.Field
679+ Content respjson.Field
653− FunctionCall resp.Field
680+ FunctionCall respjson.Field
654− Refusal resp.Field
681+ Refusal respjson.Field
655− Role resp.Field
682+ Role respjson.Field
656− ToolCalls resp.Field
683+ ToolCalls respjson.Field
657− ExtraFields map[string]resp.Field
684+ ExtraFields map[string]respjson.Field
658 raw string
685 raw string
659 } `json:"-"`
686 } `json:"-"`
@@ -677,12 +704,11 @@ type ChatCompletionChunkChoiceDeltaFunctionCall struct {
677 Arguments string `json:"arguments"`
704 Arguments string `json:"arguments"`
678 // The name of the function to call.
705 // The name of the function to call.
679 Name string `json:"name"`
706 Name string `json:"name"`
680− // Metadata for the response, check the presence of optional fields with the
707+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
681− // [resp.Field.IsPresent] method.
682 JSON struct {
708 JSON struct {
683− Arguments resp.Field
709+ Arguments respjson.Field
684− Name resp.Field
710+ Name respjson.Field
685− ExtraFields map[string]resp.Field
711+ ExtraFields map[string]respjson.Field
686 raw string
712 raw string
687 } `json:"-"`
713 } `json:"-"`
@@ -702,14 +728,13 @@ type ChatCompletionChunkChoiceDeltaToolCall struct {
703 // Any of "function".
729 // Any of "function".
704 Type string `json:"type"`
730 Type string `json:"type"`
705− // Metadata for the response, check the presence of optional fields with the
731+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
706− // [resp.Field.IsPresent] method.
707 JSON struct {
732 JSON struct {
708− Index resp.Field
733+ Index respjson.Field
709− ID resp.Field
734+ ID respjson.Field
710− Function resp.Field
735+ Function respjson.Field
711− Type resp.Field
736+ Type respjson.Field
712− ExtraFields map[string]resp.Field
737+ ExtraFields map[string]respjson.Field
713 raw string
738 raw string
714 } `json:"-"`
739 } `json:"-"`
@@ -728,12 +753,11 @@ type ChatCompletionChunkChoiceDeltaToolCallFunction struct {
728 Arguments string `json:"arguments"`
753 Arguments string `json:"arguments"`
729 // The name of the function to call.
754 // The name of the function to call.
730 Name string `json:"name"`
755 Name string `json:"name"`
731− // Metadata for the response, check the presence of optional fields with the
756+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
732− // [resp.Field.IsPresent] method.
733 JSON struct {
757 JSON struct {
734− Arguments resp.Field
758+ Arguments respjson.Field
735− Name resp.Field
759+ Name respjson.Field
736− ExtraFields map[string]resp.Field
760+ ExtraFields map[string]respjson.Field
737 raw string
761 raw string
738 } `json:"-"`
762 } `json:"-"`
@@ -750,12 +774,11 @@ type ChatCompletionChunkChoiceLogprobs struct {
750 Content []ChatCompletionTokenLogprob `json:"content,required"`
774 Content []ChatCompletionTokenLogprob `json:"content,required"`
751 // A list of message refusal tokens with log probability information.
775 // A list of message refusal tokens with log probability information.
752 Refusal []ChatCompletionTokenLogprob `json:"refusal,required"`
776 Refusal []ChatCompletionTokenLogprob `json:"refusal,required"`
753− // Metadata for the response, check the presence of optional fields with the
777+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
754− // [resp.Field.IsPresent] method.
755 JSON struct {
778 JSON struct {
756− Content resp.Field
779+ Content respjson.Field
757− Refusal resp.Field
780+ Refusal respjson.Field
758− ExtraFields map[string]resp.Field
781+ ExtraFields map[string]respjson.Field
759 raw string
782 raw string
760 } `json:"-"`
783 } `json:"-"`
@@ -766,12 +789,31 @@ func (r *ChatCompletionChunkChoiceLogprobs) UnmarshalJSON(data []byte) error {
766 return apijson.UnmarshalRoot(data, r)
789 return apijson.UnmarshalRoot(data, r)
769−// The service tier used for processing the request.
792+// Specifies the processing type used for serving the request.
794+// - If set to 'auto', then the request will be processed with the service tier
795+// configured in the Project settings. Unless otherwise configured, the Project
796+// will use 'default'.
797+// - If set to 'default', then the requset will be processed with the standard
798+// pricing and performance for the selected model.
799+// - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
800+// 'priority', then the request will be processed with the corresponding service
801+// tier. [Contact sales](https://openai.com/contact-sales) to learn more about
802+// Priority processing.
803+// - When not set, the default behavior is 'auto'.
805+// When the `service_tier` parameter is set, the response body will include the
806+// `service_tier` value based on the processing mode actually used to serve the
807+// request. This response value may be different from the value set in the
770type ChatCompletionChunkServiceTier string
809type ChatCompletionChunkServiceTier string
812+ ChatCompletionChunkServiceTierAuto ChatCompletionChunkServiceTier = "auto"
813+ ChatCompletionChunkServiceTierDefault ChatCompletionChunkServiceTier = "default"
814+ ChatCompletionChunkServiceTierFlex ChatCompletionChunkServiceTier = "flex"
773− ChatCompletionChunkServiceTierScale ChatCompletionChunkServiceTier = "scale"
815+ ChatCompletionChunkServiceTierScale ChatCompletionChunkServiceTier = "scale"
774− ChatCompletionChunkServiceTierDefault ChatCompletionChunkServiceTier = "default"
816+ ChatCompletionChunkServiceTierPriority ChatCompletionChunkServiceTier = "priority"
777func TextContentPart(text string) ChatCompletionContentPartUnionParam {
819func TextContentPart(text string) ChatCompletionContentPartUnionParam {
@@ -809,13 +851,11 @@ type ChatCompletionContentPartUnionParam struct {
809 paramUnion
851 paramUnion
812−// IsPresent returns true if the field's value is not omitted and not the JSON
813−// "null". To check if this field is omitted, use [param.IsOmitted].
814−func (u ChatCompletionContentPartUnionParam) IsPresent() bool {
815− return !param.IsOmitted(u) && !u.IsNull()
817func (u ChatCompletionContentPartUnionParam) MarshalJSON() ([]byte, error) {
854func (u ChatCompletionContentPartUnionParam) MarshalJSON() ([]byte, error) {
818− return param.MarshalUnion[ChatCompletionContentPartUnionParam](u.OfText, u.OfImageURL, u.OfInputAudio, u.OfFile)
855+ return param.MarshalUnion(u, u.OfText, u.OfImageURL, u.OfInputAudio, u.OfFile)
857+func (u *ChatCompletionContentPartUnionParam) UnmarshalJSON(data []byte) error {
858+ return apijson.UnmarshalRoot(data, u)
821func (u *ChatCompletionContentPartUnionParam) asAny() any {
861func (u *ChatCompletionContentPartUnionParam) asAny() any {
@@ -880,26 +920,10 @@ func (u ChatCompletionContentPartUnionParam) GetType() *string {
880func init() {
920func init() {
881 apijson.RegisterUnion[ChatCompletionContentPartUnionParam](
921 apijson.RegisterUnion[ChatCompletionContentPartUnionParam](
883− apijson.UnionVariant{
884− TypeFilter: gjson.JSON,
885− Type: reflect.TypeOf(ChatCompletionContentPartTextParam{}),
923+ apijson.Discriminator[ChatCompletionContentPartTextParam]("text"),
886− DiscriminatorValue: "text",
888− apijson.UnionVariant{
889− TypeFilter: gjson.JSON,
890− Type: reflect.TypeOf(ChatCompletionContentPartImageParam{}),
924+ apijson.Discriminator[ChatCompletionContentPartImageParam]("image_url"),
891− DiscriminatorValue: "image_url",
893− apijson.UnionVariant{
894− TypeFilter: gjson.JSON,
895− Type: reflect.TypeOf(ChatCompletionContentPartInputAudioParam{}),
925+ apijson.Discriminator[ChatCompletionContentPartInputAudioParam]("input_audio"),
896− DiscriminatorValue: "input_audio",
898− apijson.UnionVariant{
899− TypeFilter: gjson.JSON,
900− Type: reflect.TypeOf(ChatCompletionContentPartFileParam{}),
926+ apijson.Discriminator[ChatCompletionContentPartFileParam]("file"),
901− DiscriminatorValue: "file",
@@ -916,15 +940,13 @@ type ChatCompletionContentPartFileParam struct {
919−// IsPresent returns true if the field's value is not omitted and not the JSON
920−// "null". To check if this field is omitted, use [param.IsOmitted].
921−func (f ChatCompletionContentPartFileParam) IsPresent() bool {
922− return !param.IsOmitted(f) && !f.IsNull()
924func (r ChatCompletionContentPartFileParam) MarshalJSON() (data []byte, err error) {
943func (r ChatCompletionContentPartFileParam) MarshalJSON() (data []byte, err error) {
925 type shadow ChatCompletionContentPartFileParam
944 type shadow ChatCompletionContentPartFileParam
926 return param.MarshalObject(r, (*shadow)(&r))
945 return param.MarshalObject(r, (*shadow)(&r))
947+func (r *ChatCompletionContentPartFileParam) UnmarshalJSON(data []byte) error {
948+ return apijson.UnmarshalRoot(data, r)
929type ChatCompletionContentPartFileFileParam struct {
951type ChatCompletionContentPartFileFileParam struct {
930 // The base64 encoded file data, used when passing the file to the model as a
952 // The base64 encoded file data, used when passing the file to the model as a
@@ -937,15 +959,13 @@ type ChatCompletionContentPartFileFileParam struct {
940−// IsPresent returns true if the field's value is not omitted and not the JSON
941−// "null". To check if this field is omitted, use [param.IsOmitted].
942−func (f ChatCompletionContentPartFileFileParam) IsPresent() bool {
943− return !param.IsOmitted(f) && !f.IsNull()
945func (r ChatCompletionContentPartFileFileParam) MarshalJSON() (data []byte, err error) {
962func (r ChatCompletionContentPartFileFileParam) MarshalJSON() (data []byte, err error) {
946 type shadow ChatCompletionContentPartFileFileParam
963 type shadow ChatCompletionContentPartFileFileParam
947 return param.MarshalObject(r, (*shadow)(&r))
964 return param.MarshalObject(r, (*shadow)(&r))
966+func (r *ChatCompletionContentPartFileFileParam) UnmarshalJSON(data []byte) error {
967+ return apijson.UnmarshalRoot(data, r)
950// Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
970// Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
@@ -959,15 +979,13 @@ type ChatCompletionContentPartImageParam struct {
962−// IsPresent returns true if the field's value is not omitted and not the JSON
963−// "null". To check if this field is omitted, use [param.IsOmitted].
964−func (f ChatCompletionContentPartImageParam) IsPresent() bool {
965− return !param.IsOmitted(f) && !f.IsNull()
967func (r ChatCompletionContentPartImageParam) MarshalJSON() (data []byte, err error) {
982func (r ChatCompletionContentPartImageParam) MarshalJSON() (data []byte, err error) {
968 type shadow ChatCompletionContentPartImageParam
983 type shadow ChatCompletionContentPartImageParam
969 return param.MarshalObject(r, (*shadow)(&r))
984 return param.MarshalObject(r, (*shadow)(&r))
986+func (r *ChatCompletionContentPartImageParam) UnmarshalJSON(data []byte) error {
987+ return apijson.UnmarshalRoot(data, r)
972// The property URL is required.
990// The property URL is required.
973type ChatCompletionContentPartImageImageURLParam struct {
991type ChatCompletionContentPartImageImageURLParam struct {
@@ -981,19 +999,17 @@ type ChatCompletionContentPartImageImageURLParam struct {
984−// IsPresent returns true if the field's value is not omitted and not the JSON
985−// "null". To check if this field is omitted, use [param.IsOmitted].
986−func (f ChatCompletionContentPartImageImageURLParam) IsPresent() bool {
987− return !param.IsOmitted(f) && !f.IsNull()
989func (r ChatCompletionContentPartImageImageURLParam) MarshalJSON() (data []byte, err error) {
1002func (r ChatCompletionContentPartImageImageURLParam) MarshalJSON() (data []byte, err error) {
990 type shadow ChatCompletionContentPartImageImageURLParam
1003 type shadow ChatCompletionContentPartImageImageURLParam
991 return param.MarshalObject(r, (*shadow)(&r))
1004 return param.MarshalObject(r, (*shadow)(&r))
1006+func (r *ChatCompletionContentPartImageImageURLParam) UnmarshalJSON(data []byte) error {
1007+ return apijson.UnmarshalRoot(data, r)
994func init() {
1010func init() {
995 apijson.RegisterFieldValidator[ChatCompletionContentPartImageImageURLParam](
1011 apijson.RegisterFieldValidator[ChatCompletionContentPartImageImageURLParam](
996− "Detail", false, "auto", "low", "high",
1012+ "detail", "auto", "low", "high",
@@ -1009,15 +1025,13 @@ type ChatCompletionContentPartInputAudioParam struct {
1009 paramObj
1025 paramObj
1012−// IsPresent returns true if the field's value is not omitted and not the JSON
1013−// "null". To check if this field is omitted, use [param.IsOmitted].
1014−func (f ChatCompletionContentPartInputAudioParam) IsPresent() bool {
1015− return !param.IsOmitted(f) && !f.IsNull()
1017func (r ChatCompletionContentPartInputAudioParam) MarshalJSON() (data []byte, err error) {
1028func (r ChatCompletionContentPartInputAudioParam) MarshalJSON() (data []byte, err error) {
1018 type shadow ChatCompletionContentPartInputAudioParam
1029 type shadow ChatCompletionContentPartInputAudioParam
1019 return param.MarshalObject(r, (*shadow)(&r))
1030 return param.MarshalObject(r, (*shadow)(&r))
1032+func (r *ChatCompletionContentPartInputAudioParam) UnmarshalJSON(data []byte) error {
1033+ return apijson.UnmarshalRoot(data, r)
1022// The properties Data, Format are required.
1036// The properties Data, Format are required.
1023type ChatCompletionContentPartInputAudioInputAudioParam struct {
1037type ChatCompletionContentPartInputAudioInputAudioParam struct {
@@ -1030,19 +1044,17 @@ type ChatCompletionContentPartInputAudioInputAudioParam struct {
1030 paramObj
1044 paramObj
1033−// IsPresent returns true if the field's value is not omitted and not the JSON
1034−// "null". To check if this field is omitted, use [param.IsOmitted].
1035−func (f ChatCompletionContentPartInputAudioInputAudioParam) IsPresent() bool {
1036− return !param.IsOmitted(f) && !f.IsNull()
1038func (r ChatCompletionContentPartInputAudioInputAudioParam) MarshalJSON() (data []byte, err error) {
1047func (r ChatCompletionContentPartInputAudioInputAudioParam) MarshalJSON() (data []byte, err error) {
1039 type shadow ChatCompletionContentPartInputAudioInputAudioParam
1048 type shadow ChatCompletionContentPartInputAudioInputAudioParam
1040 return param.MarshalObject(r, (*shadow)(&r))
1049 return param.MarshalObject(r, (*shadow)(&r))
1051+func (r *ChatCompletionContentPartInputAudioInputAudioParam) UnmarshalJSON(data []byte) error {
1052+ return apijson.UnmarshalRoot(data, r)
1043func init() {
1055func init() {
1044 apijson.RegisterFieldValidator[ChatCompletionContentPartInputAudioInputAudioParam](
1056 apijson.RegisterFieldValidator[ChatCompletionContentPartInputAudioInputAudioParam](
1045− "Format", false, "wav", "mp3",
1057+ "format", "wav", "mp3",
@@ -1057,15 +1069,13 @@ type ChatCompletionContentPartRefusalParam struct {
1057 paramObj
1069 paramObj
1060−// IsPresent returns true if the field's value is not omitted and not the JSON
1061−// "null". To check if this field is omitted, use [param.IsOmitted].
1062−func (f ChatCompletionContentPartRefusalParam) IsPresent() bool {
1063− return !param.IsOmitted(f) && !f.IsNull()
1065func (r ChatCompletionContentPartRefusalParam) MarshalJSON() (data []byte, err error) {
1072func (r ChatCompletionContentPartRefusalParam) MarshalJSON() (data []byte, err error) {
1066 type shadow ChatCompletionContentPartRefusalParam
1073 type shadow ChatCompletionContentPartRefusalParam
1067 return param.MarshalObject(r, (*shadow)(&r))
1074 return param.MarshalObject(r, (*shadow)(&r))
1076+func (r *ChatCompletionContentPartRefusalParam) UnmarshalJSON(data []byte) error {
1077+ return apijson.UnmarshalRoot(data, r)
1070// Learn about
1080// Learn about
1071// [text inputs](https://platform.openai.com/docs/guides/text-generation).
1081// [text inputs](https://platform.openai.com/docs/guides/text-generation).
@@ -1081,15 +1091,13 @@ type ChatCompletionContentPartTextParam struct {
1081 paramObj
1091 paramObj
1084−// IsPresent returns true if the field's value is not omitted and not the JSON
1085−// "null". To check if this field is omitted, use [param.IsOmitted].
1086−func (f ChatCompletionContentPartTextParam) IsPresent() bool {
1087− return !param.IsOmitted(f) && !f.IsNull()
1089func (r ChatCompletionContentPartTextParam) MarshalJSON() (data []byte, err error) {
1094func (r ChatCompletionContentPartTextParam) MarshalJSON() (data []byte, err error) {
1090 type shadow ChatCompletionContentPartTextParam
1095 type shadow ChatCompletionContentPartTextParam
1091 return param.MarshalObject(r, (*shadow)(&r))
1096 return param.MarshalObject(r, (*shadow)(&r))
1098+func (r *ChatCompletionContentPartTextParam) UnmarshalJSON(data []byte) error {
1099+ return apijson.UnmarshalRoot(data, r)
1094type ChatCompletionDeleted struct {
1102type ChatCompletionDeleted struct {
1095 // The ID of the chat completion that was deleted.
1103 // The ID of the chat completion that was deleted.
@@ -1098,13 +1106,12 @@ type ChatCompletionDeleted struct {
1098 Deleted bool `json:"deleted,required"`
1106 Deleted bool `json:"deleted,required"`
1099 // The type of object being deleted.
1107 // The type of object being deleted.
1100 Object constant.ChatCompletionDeleted `json:"object,required"`
1108 Object constant.ChatCompletionDeleted `json:"object,required"`
1101− // Metadata for the response, check the presence of optional fields with the
1109+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1102− // [resp.Field.IsPresent] method.
1103 JSON struct {
1110 JSON struct {
1104− ID resp.Field
1111+ ID respjson.Field
1105− Deleted resp.Field
1112+ Deleted respjson.Field
1106− Object resp.Field
1113+ Object respjson.Field
1107− ExtraFields map[string]resp.Field
1114+ ExtraFields map[string]respjson.Field
1108 raw string
1115 raw string
1109 } `json:"-"`
1116 } `json:"-"`
@@ -1133,15 +1140,13 @@ type ChatCompletionDeveloperMessageParam struct {
1133 paramObj
1140 paramObj
1136−// IsPresent returns true if the field's value is not omitted and not the JSON
1137−// "null". To check if this field is omitted, use [param.IsOmitted].
1138−func (f ChatCompletionDeveloperMessageParam) IsPresent() bool {
1139− return !param.IsOmitted(f) && !f.IsNull()
1141func (r ChatCompletionDeveloperMessageParam) MarshalJSON() (data []byte, err error) {
1143func (r ChatCompletionDeveloperMessageParam) MarshalJSON() (data []byte, err error) {
1142 type shadow ChatCompletionDeveloperMessageParam
1144 type shadow ChatCompletionDeveloperMessageParam
1143 return param.MarshalObject(r, (*shadow)(&r))
1145 return param.MarshalObject(r, (*shadow)(&r))
1147+func (r *ChatCompletionDeveloperMessageParam) UnmarshalJSON(data []byte) error {
1148+ return apijson.UnmarshalRoot(data, r)
1146// Only one field can be non-zero.
1151// Only one field can be non-zero.
@@ -1152,13 +1157,11 @@ type ChatCompletionDeveloperMessageParamContentUnion struct {
1152 paramUnion
1157 paramUnion
1155−// IsPresent returns true if the field's value is not omitted and not the JSON
1156−// "null". To check if this field is omitted, use [param.IsOmitted].
1157−func (u ChatCompletionDeveloperMessageParamContentUnion) IsPresent() bool {
1158− return !param.IsOmitted(u) && !u.IsNull()
1160func (u ChatCompletionDeveloperMessageParamContentUnion) MarshalJSON() ([]byte, error) {
1160func (u ChatCompletionDeveloperMessageParamContentUnion) MarshalJSON() ([]byte, error) {
1161+ return param.MarshalUnion(u, u.OfString, u.OfArrayOfContentParts)
1161− return param.MarshalUnion[ChatCompletionDeveloperMessageParamContentUnion](u.OfString, u.OfArrayOfContentParts)
1163+func (u *ChatCompletionDeveloperMessageParamContentUnion) UnmarshalJSON(data []byte) error {
1164+ return apijson.UnmarshalRoot(data, u)
1164func (u *ChatCompletionDeveloperMessageParamContentUnion) asAny() any {
1167func (u *ChatCompletionDeveloperMessageParamContentUnion) asAny() any {
@@ -1180,15 +1183,13 @@ type ChatCompletionFunctionCallOptionParam struct {
1180 paramObj
1183 paramObj
1183−// IsPresent returns true if the field's value is not omitted and not the JSON
1184−// "null". To check if this field is omitted, use [param.IsOmitted].
1185−func (f ChatCompletionFunctionCallOptionParam) IsPresent() bool {
1186− return !param.IsOmitted(f) && !f.IsNull()
1188func (r ChatCompletionFunctionCallOptionParam) MarshalJSON() (data []byte, err error) {
1186func (r ChatCompletionFunctionCallOptionParam) MarshalJSON() (data []byte, err error) {
1189 type shadow ChatCompletionFunctionCallOptionParam
1187 type shadow ChatCompletionFunctionCallOptionParam
1190 return param.MarshalObject(r, (*shadow)(&r))
1188 return param.MarshalObject(r, (*shadow)(&r))
1190+func (r *ChatCompletionFunctionCallOptionParam) UnmarshalJSON(data []byte) error {
1191+ return apijson.UnmarshalRoot(data, r)
1193// Deprecated: deprecated
1194// Deprecated: deprecated
@@ -1205,15 +1206,13 @@ type ChatCompletionFunctionMessageParam struct {
1205 paramObj
1206 paramObj
1208−// IsPresent returns true if the field's value is not omitted and not the JSON
1209−// "null". To check if this field is omitted, use [param.IsOmitted].
1210−func (f ChatCompletionFunctionMessageParam) IsPresent() bool {
1211− return !param.IsOmitted(f) && !f.IsNull()
1213func (r ChatCompletionFunctionMessageParam) MarshalJSON() (data []byte, err error) {
1209func (r ChatCompletionFunctionMessageParam) MarshalJSON() (data []byte, err error) {
1214 type shadow ChatCompletionFunctionMessageParam
1210 type shadow ChatCompletionFunctionMessageParam
1215 return param.MarshalObject(r, (*shadow)(&r))
1211 return param.MarshalObject(r, (*shadow)(&r))
1213+func (r *ChatCompletionFunctionMessageParam) UnmarshalJSON(data []byte) error {
1214+ return apijson.UnmarshalRoot(data, r)
1218// A chat completion message generated by the model.
1217// A chat completion message generated by the model.
1219type ChatCompletionMessage struct {
1218type ChatCompletionMessage struct {
@@ -1237,17 +1236,16 @@ type ChatCompletionMessage struct {
1237 FunctionCall ChatCompletionMessageFunctionCall `json:"function_call"`
1236 FunctionCall ChatCompletionMessageFunctionCall `json:"function_call"`
1238 // The tool calls generated by the model, such as function calls.
1237 // The tool calls generated by the model, such as function calls.
1239 ToolCalls []ChatCompletionMessageToolCall `json:"tool_calls"`
1238 ToolCalls []ChatCompletionMessageToolCall `json:"tool_calls"`
1240− // Metadata for the response, check the presence of optional fields with the
1239+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1241− // [resp.Field.IsPresent] method.
1242 JSON struct {
1240 JSON struct {
1243− Content resp.Field
1241+ Content respjson.Field
1244− Refusal resp.Field
1242+ Refusal respjson.Field
1245− Role resp.Field
1243+ Role respjson.Field
1246− Annotations resp.Field
1244+ Annotations respjson.Field
1247− Audio resp.Field
1245+ Audio respjson.Field
1248− FunctionCall resp.Field
1246+ FunctionCall respjson.Field
1249− ToolCalls resp.Field
1247+ ToolCalls respjson.Field
1250− ExtraFields map[string]resp.Field
1248+ ExtraFields map[string]respjson.Field
1251 raw string
1249 raw string
1252 } `json:"-"`
1250 } `json:"-"`
@@ -1300,12 +1298,11 @@ type ChatCompletionMessageAnnotation struct {
1300 Type constant.URLCitation `json:"type,required"`
1298 Type constant.URLCitation `json:"type,required"`
1301 // A URL citation when using web search.
1299 // A URL citation when using web search.
1302 URLCitation ChatCompletionMessageAnnotationURLCitation `json:"url_citation,required"`
1300 URLCitation ChatCompletionMessageAnnotationURLCitation `json:"url_citation,required"`
1303− // Metadata for the response, check the presence of optional fields with the
1301+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1304− // [resp.Field.IsPresent] method.
1305 JSON struct {
1302 JSON struct {
1306− Type resp.Field
1303+ Type respjson.Field
1307− URLCitation resp.Field
1304+ URLCitation respjson.Field
1308− ExtraFields map[string]resp.Field
1305+ ExtraFields map[string]respjson.Field
1309 raw string
1306 raw string
1310 } `json:"-"`
1307 } `json:"-"`
@@ -1326,14 +1323,13 @@ type ChatCompletionMessageAnnotationURLCitation struct {
1326 Title string `json:"title,required"`
1323 Title string `json:"title,required"`
1327 // The URL of the web resource.
1324 // The URL of the web resource.
1328 URL string `json:"url,required"`
1325 URL string `json:"url,required"`
1329− // Metadata for the response, check the presence of optional fields with the
1326+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1330− // [resp.Field.IsPresent] method.
1331 JSON struct {
1327 JSON struct {
1332− EndIndex resp.Field
1328+ EndIndex respjson.Field
1333− StartIndex resp.Field
1329+ StartIndex respjson.Field
1334− Title resp.Field
1330+ Title respjson.Field
1335− URL resp.Field
1331+ URL respjson.Field
1336− ExtraFields map[string]resp.Field
1332+ ExtraFields map[string]respjson.Field
1337 raw string
1333 raw string
1338 } `json:"-"`
1334 } `json:"-"`
@@ -1356,12 +1352,11 @@ type ChatCompletionMessageFunctionCall struct {
1356 Arguments string `json:"arguments,required"`
1352 Arguments string `json:"arguments,required"`
1357 // The name of the function to call.
1353 // The name of the function to call.
1358 Name string `json:"name,required"`
1354 Name string `json:"name,required"`
1359− // Metadata for the response, check the presence of optional fields with the
1355+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1360− // [resp.Field.IsPresent] method.
1361 JSON struct {
1356 JSON struct {
1362− Arguments resp.Field
1357+ Arguments respjson.Field
1363− Name resp.Field
1358+ Name respjson.Field
1364− ExtraFields map[string]resp.Field
1359+ ExtraFields map[string]respjson.Field
1365 raw string
1360 raw string
1366 } `json:"-"`
1361 } `json:"-"`
@@ -1448,17 +1443,17 @@ type ChatCompletionMessageParamUnion struct {
1448 paramUnion
1443 paramUnion
1451−// IsPresent returns true if the field's value is not omitted and not the JSON
1452−// "null". To check if this field is omitted, use [param.IsOmitted].
1453−func (u ChatCompletionMessageParamUnion) IsPresent() bool { return !param.IsOmitted(u) && !u.IsNull() }
1454func (u ChatCompletionMessageParamUnion) MarshalJSON() ([]byte, error) {
1446func (u ChatCompletionMessageParamUnion) MarshalJSON() ([]byte, error) {
1455− return param.MarshalUnion[ChatCompletionMessageParamUnion](u.OfDeveloper,
1447+ return param.MarshalUnion(u, u.OfDeveloper,
1456 u.OfSystem,
1448 u.OfSystem,
1457 u.OfUser,
1449 u.OfUser,
1458 u.OfAssistant,
1450 u.OfAssistant,
1459 u.OfTool,
1451 u.OfTool,
1460 u.OfFunction)
1452 u.OfFunction)
1454+func (u *ChatCompletionMessageParamUnion) UnmarshalJSON(data []byte) error {
1455+ return apijson.UnmarshalRoot(data, u)
1463func (u *ChatCompletionMessageParamUnion) asAny() any {
1458func (u *ChatCompletionMessageParamUnion) asAny() any {
1464 if !param.IsOmitted(u.OfDeveloper) {
1459 if !param.IsOmitted(u.OfDeveloper) {
@@ -1495,7 +1490,7 @@ func (u ChatCompletionMessageParamUnion) GetFunctionCall() *ChatCompletionAssist
1496// Returns a pointer to the underlying variant's property, if present.
1491// Returns a pointer to the underlying variant's property, if present.
1497func (u ChatCompletionMessageParamUnion) GetRefusal() *string {
1492func (u ChatCompletionMessageParamUnion) GetRefusal() *string {
1498− if vt := u.OfAssistant; vt != nil && vt.Refusal.IsPresent() {
1493+ if vt := u.OfAssistant; vt != nil && vt.Refusal.Valid() {
1499 return &vt.Refusal.Value
1494 return &vt.Refusal.Value
1501 return nil
1496 return nil
@@ -1537,13 +1532,13 @@ func (u ChatCompletionMessageParamUnion) GetRole() *string {
1538// Returns a pointer to the underlying variant's property, if present.
1533// Returns a pointer to the underlying variant's property, if present.
1539func (u ChatCompletionMessageParamUnion) GetName() *string {
1534func (u ChatCompletionMessageParamUnion) GetName() *string {
1540− if vt := u.OfDeveloper; vt != nil && vt.Name.IsPresent() {
1535+ if vt := u.OfDeveloper; vt != nil && vt.Name.Valid() {
1541 return &vt.Name.Value
1536 return &vt.Name.Value
1542− } else if vt := u.OfSystem; vt != nil && vt.Name.IsPresent() {
1537+ } else if vt := u.OfSystem; vt != nil && vt.Name.Valid() {
1543 return &vt.Name.Value
1538 return &vt.Name.Value
1544− } else if vt := u.OfUser; vt != nil && vt.Name.IsPresent() {
1539+ } else if vt := u.OfUser; vt != nil && vt.Name.Valid() {
1545 return &vt.Name.Value
1540 return &vt.Name.Value
1546− } else if vt := u.OfAssistant; vt != nil && vt.Name.IsPresent() {
1541+ } else if vt := u.OfAssistant; vt != nil && vt.Name.Valid() {
1547 return &vt.Name.Value
1542 return &vt.Name.Value
1548 } else if vt := u.OfFunction; vt != nil {
1543 } else if vt := u.OfFunction; vt != nil {
1549 return (*string)(&vt.Name)
1544 return (*string)(&vt.Name)
@@ -1556,32 +1551,25 @@ func (u ChatCompletionMessageParamUnion) GetName() *string {
1556// Or use AsAny() to get the underlying value
1551// Or use AsAny() to get the underlying value
1557func (u ChatCompletionMessageParamUnion) GetContent() (res chatCompletionMessageParamUnionContent) {
1552func (u ChatCompletionMessageParamUnion) GetContent() (res chatCompletionMessageParamUnionContent) {
1558 if vt := u.OfDeveloper; vt != nil {
1553 if vt := u.OfDeveloper; vt != nil {
1559− res.ofChatCompletionDeveloperMessageContent = &vt.Content
1554+ res.any = vt.Content.asAny()
1560 } else if vt := u.OfSystem; vt != nil {
1555 } else if vt := u.OfSystem; vt != nil {
1561− res.ofChatCompletionSystemMessageContent = &vt.Content
1556+ res.any = vt.Content.asAny()
1562 } else if vt := u.OfUser; vt != nil {
1557 } else if vt := u.OfUser; vt != nil {
1563− res.ofChatCompletionUserMessageContent = &vt.Content
1558+ res.any = vt.Content.asAny()
1564 } else if vt := u.OfAssistant; vt != nil {
1559 } else if vt := u.OfAssistant; vt != nil {
1565− res.ofChatCompletionAssistantMessageContent = &vt.Content
1560+ res.any = vt.Content.asAny()
1566 } else if vt := u.OfTool; vt != nil {
1561 } else if vt := u.OfTool; vt != nil {
1567− res.ofChatCompletionToolMessageContent = &vt.Content
1562+ res.any = vt.Content.asAny()
1568− } else if vt := u.OfFunction; vt != nil && vt.Content.IsPresent() {
1563+ } else if vt := u.OfFunction; vt != nil && vt.Content.Valid() {
1569− res.ofString = &vt.Content.Value
1564+ res.any = &vt.Content.Value
1574−// Only one field can be non-zero.
1569+// Can have the runtime types [*string], [_[]ChatCompletionContentPartTextParam],
1575−//
1570+// [_[]ChatCompletionContentPartUnionParam],
1576−// Use [param.IsOmitted] to confirm if a field is set.
1571+// [\*[]ChatCompletionAssistantMessageParamContentArrayOfContentPartUnion]
1577−type chatCompletionMessageParamUnionContent struct {
1572+type chatCompletionMessageParamUnionContent struct{ any }
1578− ofChatCompletionDeveloperMessageContent *ChatCompletionDeveloperMessageParamContentUnion
1579− ofChatCompletionSystemMessageContent *ChatCompletionSystemMessageParamContentUnion
1580− ofChatCompletionUserMessageContent *ChatCompletionUserMessageParamContentUnion
1581− ofChatCompletionAssistantMessageContent *ChatCompletionAssistantMessageParamContentUnion
1582− ofChatCompletionToolMessageContent *ChatCompletionToolMessageParamContentUnion
1586// Use the following switch statement to get the type of the union:
1574// Use the following switch statement to get the type of the union:
@@ -1593,56 +1581,17 @@ type chatCompletionMessageParamUnionContent struct {
1593// default:
1581// default:
1594// fmt.Errorf("not present")
1582// fmt.Errorf("not present")
1596−func (u chatCompletionMessageParamUnionContent) AsAny() any {
1584+func (u chatCompletionMessageParamUnionContent) AsAny() any { return u.any }
1597− if !param.IsOmitted(u.ofChatCompletionDeveloperMessageContent) {
1598− return u.ofChatCompletionDeveloperMessageContent.asAny()
1599− } else if !param.IsOmitted(u.ofChatCompletionSystemMessageContent) {
1600− return u.ofChatCompletionSystemMessageContent.asAny()
1601− } else if !param.IsOmitted(u.ofChatCompletionUserMessageContent) {
1602− return u.ofChatCompletionUserMessageContent.asAny()
1603− } else if !param.IsOmitted(u.ofChatCompletionAssistantMessageContent) {
1604− return u.ofChatCompletionAssistantMessageContent.asAny()
1605− } else if !param.IsOmitted(u.ofChatCompletionToolMessageContent) {
1606− return u.ofChatCompletionToolMessageContent.asAny()
1607− } else if !param.IsOmitted(u.ofString) {
1613func init() {
1586func init() {
1614 apijson.RegisterUnion[ChatCompletionMessageParamUnion](
1587 apijson.RegisterUnion[ChatCompletionMessageParamUnion](
1616− apijson.UnionVariant{
1617− TypeFilter: gjson.JSON,
1618− Type: reflect.TypeOf(ChatCompletionDeveloperMessageParam{}),
1589+ apijson.Discriminator[ChatCompletionDeveloperMessageParam]("developer"),
1619− DiscriminatorValue: "developer",
1621− apijson.UnionVariant{
1622− TypeFilter: gjson.JSON,
1623− Type: reflect.TypeOf(ChatCompletionSystemMessageParam{}),
1590+ apijson.Discriminator[ChatCompletionSystemMessageParam]("system"),
1624− DiscriminatorValue: "system",
1626− apijson.UnionVariant{
1627− TypeFilter: gjson.JSON,
1628− Type: reflect.TypeOf(ChatCompletionUserMessageParam{}),
1591+ apijson.Discriminator[ChatCompletionUserMessageParam]("user"),
1629− DiscriminatorValue: "user",
1631− apijson.UnionVariant{
1632− TypeFilter: gjson.JSON,
1633− Type: reflect.TypeOf(ChatCompletionAssistantMessageParam{}),
1592+ apijson.Discriminator[ChatCompletionAssistantMessageParam]("assistant"),
1634− DiscriminatorValue: "assistant",
1636− apijson.UnionVariant{
1637− TypeFilter: gjson.JSON,
1638− Type: reflect.TypeOf(ChatCompletionToolMessageParam{}),
1593+ apijson.Discriminator[ChatCompletionToolMessageParam]("tool"),
1639− DiscriminatorValue: "tool",
1641− apijson.UnionVariant{
1642− TypeFilter: gjson.JSON,
1643− Type: reflect.TypeOf(ChatCompletionFunctionMessageParam{}),
1594+ apijson.Discriminator[ChatCompletionFunctionMessageParam]("function"),
1644− DiscriminatorValue: "function",
@@ -1653,13 +1602,12 @@ type ChatCompletionMessageToolCall struct {
1653 Function ChatCompletionMessageToolCallFunction `json:"function,required"`
1602 Function ChatCompletionMessageToolCallFunction `json:"function,required"`
1654 // The type of the tool. Currently, only `function` is supported.
1603 // The type of the tool. Currently, only `function` is supported.
1655 Type constant.Function `json:"type,required"`
1604 Type constant.Function `json:"type,required"`
1656− // Metadata for the response, check the presence of optional fields with the
1605+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1657− // [resp.Field.IsPresent] method.
1658 JSON struct {
1606 JSON struct {
1659− ID resp.Field
1607+ ID respjson.Field
1660− Function resp.Field
1608+ Function respjson.Field
1661− Type resp.Field
1609+ Type respjson.Field
1662− ExtraFields map[string]resp.Field
1610+ ExtraFields map[string]respjson.Field
1663 raw string
1611 raw string
1664 } `json:"-"`
1612 } `json:"-"`
@@ -1675,9 +1623,9 @@ func (r *ChatCompletionMessageToolCall) UnmarshalJSON(data []byte) error {
1676// Warning: the fields of the param type will not be present. ToParam should only
1624// Warning: the fields of the param type will not be present. ToParam should only
1677// be used at the last possible moment before sending a request. Test for this with
1625// be used at the last possible moment before sending a request. Test for this with
1678−// ChatCompletionMessageToolCallParam.IsOverridden()
1626+// ChatCompletionMessageToolCallParam.Overrides()
1679func (r ChatCompletionMessageToolCall) ToParam() ChatCompletionMessageToolCallParam {
1627func (r ChatCompletionMessageToolCall) ToParam() ChatCompletionMessageToolCallParam {
1680− return param.OverrideObj[ChatCompletionMessageToolCallParam](r.RawJSON())
1628+ return param.Override[ChatCompletionMessageToolCallParam](json.RawMessage(r.RawJSON()))
1683// The function that the model called.
1631// The function that the model called.
@@ -1689,12 +1637,11 @@ type ChatCompletionMessageToolCallFunction struct {
1689 Arguments string `json:"arguments,required"`
1637 Arguments string `json:"arguments,required"`
1690 // The name of the function to call.
1638 // The name of the function to call.
1691 Name string `json:"name,required"`
1639 Name string `json:"name,required"`
1692− // Metadata for the response, check the presence of optional fields with the
1640+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1693− // [resp.Field.IsPresent] method.
1694 JSON struct {
1641 JSON struct {
1695− Arguments resp.Field
1642+ Arguments respjson.Field
1696− Name resp.Field
1643+ Name respjson.Field
1697− ExtraFields map[string]resp.Field
1644+ ExtraFields map[string]respjson.Field
1698 raw string
1645 raw string
1699 } `json:"-"`
1646 } `json:"-"`
@@ -1718,15 +1665,13 @@ type ChatCompletionMessageToolCallParam struct {
1718 paramObj
1665 paramObj
1721−// IsPresent returns true if the field's value is not omitted and not the JSON
1722−// "null". To check if this field is omitted, use [param.IsOmitted].
1723−func (f ChatCompletionMessageToolCallParam) IsPresent() bool {
1724− return !param.IsOmitted(f) && !f.IsNull()
1726func (r ChatCompletionMessageToolCallParam) MarshalJSON() (data []byte, err error) {
1668func (r ChatCompletionMessageToolCallParam) MarshalJSON() (data []byte, err error) {
1727 type shadow ChatCompletionMessageToolCallParam
1669 type shadow ChatCompletionMessageToolCallParam
1728 return param.MarshalObject(r, (*shadow)(&r))
1670 return param.MarshalObject(r, (*shadow)(&r))
1672+func (r *ChatCompletionMessageToolCallParam) UnmarshalJSON(data []byte) error {
1673+ return apijson.UnmarshalRoot(data, r)
1731// The function that the model called.
1676// The function that the model called.
@@ -1742,15 +1687,13 @@ type ChatCompletionMessageToolCallFunctionParam struct {
1742 paramObj
1687 paramObj
1745−// IsPresent returns true if the field's value is not omitted and not the JSON
1746−// "null". To check if this field is omitted, use [param.IsOmitted].
1747−func (f ChatCompletionMessageToolCallFunctionParam) IsPresent() bool {
1748− return !param.IsOmitted(f) && !f.IsNull()
1750func (r ChatCompletionMessageToolCallFunctionParam) MarshalJSON() (data []byte, err error) {
1690func (r ChatCompletionMessageToolCallFunctionParam) MarshalJSON() (data []byte, err error) {
1751 type shadow ChatCompletionMessageToolCallFunctionParam
1691 type shadow ChatCompletionMessageToolCallFunctionParam
1752 return param.MarshalObject(r, (*shadow)(&r))
1692 return param.MarshalObject(r, (*shadow)(&r))
1694+func (r *ChatCompletionMessageToolCallFunctionParam) UnmarshalJSON(data []byte) error {
1695+ return apijson.UnmarshalRoot(data, r)
1755// Specifies a tool the model should use. Use to force the model to call a specific
1698// Specifies a tool the model should use. Use to force the model to call a specific
1756// function.
1699// function.
@@ -1765,15 +1708,13 @@ type ChatCompletionNamedToolChoiceParam struct {
1765 paramObj
1708 paramObj
1768−// IsPresent returns true if the field's value is not omitted and not the JSON
1769−// "null". To check if this field is omitted, use [param.IsOmitted].
1770−func (f ChatCompletionNamedToolChoiceParam) IsPresent() bool {
1771− return !param.IsOmitted(f) && !f.IsNull()
1773func (r ChatCompletionNamedToolChoiceParam) MarshalJSON() (data []byte, err error) {
1711func (r ChatCompletionNamedToolChoiceParam) MarshalJSON() (data []byte, err error) {
1774 type shadow ChatCompletionNamedToolChoiceParam
1712 type shadow ChatCompletionNamedToolChoiceParam
1775 return param.MarshalObject(r, (*shadow)(&r))
1713 return param.MarshalObject(r, (*shadow)(&r))
1715+func (r *ChatCompletionNamedToolChoiceParam) UnmarshalJSON(data []byte) error {
1716+ return apijson.UnmarshalRoot(data, r)
1778// The property Name is required.
1719// The property Name is required.
1779type ChatCompletionNamedToolChoiceFunctionParam struct {
1720type ChatCompletionNamedToolChoiceFunctionParam struct {
@@ -1782,15 +1723,13 @@ type ChatCompletionNamedToolChoiceFunctionParam struct {
1782 paramObj
1723 paramObj
1785−// IsPresent returns true if the field's value is not omitted and not the JSON
1786−// "null". To check if this field is omitted, use [param.IsOmitted].
1787−func (f ChatCompletionNamedToolChoiceFunctionParam) IsPresent() bool {
1788− return !param.IsOmitted(f) && !f.IsNull()
1790func (r ChatCompletionNamedToolChoiceFunctionParam) MarshalJSON() (data []byte, err error) {
1726func (r ChatCompletionNamedToolChoiceFunctionParam) MarshalJSON() (data []byte, err error) {
1791 type shadow ChatCompletionNamedToolChoiceFunctionParam
1727 type shadow ChatCompletionNamedToolChoiceFunctionParam
1792 return param.MarshalObject(r, (*shadow)(&r))
1728 return param.MarshalObject(r, (*shadow)(&r))
1730+func (r *ChatCompletionNamedToolChoiceFunctionParam) UnmarshalJSON(data []byte) error {
1731+ return apijson.UnmarshalRoot(data, r)
1795// Static predicted output content, such as the content of a text file that is
1734// Static predicted output content, such as the content of a text file that is
1796// being regenerated.
1735// being regenerated.
@@ -1809,15 +1748,13 @@ type ChatCompletionPredictionContentParam struct {
1809 paramObj
1748 paramObj
1812−// IsPresent returns true if the field's value is not omitted and not the JSON
1813−// "null". To check if this field is omitted, use [param.IsOmitted].
1814−func (f ChatCompletionPredictionContentParam) IsPresent() bool {
1815− return !param.IsOmitted(f) && !f.IsNull()
1817func (r ChatCompletionPredictionContentParam) MarshalJSON() (data []byte, err error) {
1751func (r ChatCompletionPredictionContentParam) MarshalJSON() (data []byte, err error) {
1818 type shadow ChatCompletionPredictionContentParam
1752 type shadow ChatCompletionPredictionContentParam
1819 return param.MarshalObject(r, (*shadow)(&r))
1753 return param.MarshalObject(r, (*shadow)(&r))
1755+func (r *ChatCompletionPredictionContentParam) UnmarshalJSON(data []byte) error {
1756+ return apijson.UnmarshalRoot(data, r)
1822// Only one field can be non-zero.
1759// Only one field can be non-zero.
@@ -1828,13 +1765,11 @@ type ChatCompletionPredictionContentContentUnionParam struct {
1828 paramUnion
1765 paramUnion
1831−// IsPresent returns true if the field's value is not omitted and not the JSON
1832−// "null". To check if this field is omitted, use [param.IsOmitted].
1833−func (u ChatCompletionPredictionContentContentUnionParam) IsPresent() bool {
1834− return !param.IsOmitted(u) && !u.IsNull()
1836func (u ChatCompletionPredictionContentContentUnionParam) MarshalJSON() ([]byte, error) {
1768func (u ChatCompletionPredictionContentContentUnionParam) MarshalJSON() ([]byte, error) {
1769+ return param.MarshalUnion(u, u.OfString, u.OfArrayOfContentParts)
1837− return param.MarshalUnion[ChatCompletionPredictionContentContentUnionParam](u.OfString, u.OfArrayOfContentParts)
1771+func (u *ChatCompletionPredictionContentContentUnionParam) UnmarshalJSON(data []byte) error {
1772+ return apijson.UnmarshalRoot(data, u)
1840func (u *ChatCompletionPredictionContentContentUnionParam) asAny() any {
1775func (u *ChatCompletionPredictionContentContentUnionParam) asAny() any {
@@ -1850,11 +1785,10 @@ func (u *ChatCompletionPredictionContentContentUnionParam) asAny() any {
1850type ChatCompletionStoreMessage struct {
1785type ChatCompletionStoreMessage struct {
1851 // The identifier of the chat message.
1786 // The identifier of the chat message.
1852 ID string `json:"id,required"`
1787 ID string `json:"id,required"`
1853− // Metadata for the response, check the presence of optional fields with the
1788+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1854− // [resp.Field.IsPresent] method.
1855 JSON struct {
1789 JSON struct {
1856− ID resp.Field
1790+ ID respjson.Field
1857− ExtraFields map[string]resp.Field
1791+ ExtraFields map[string]respjson.Field
1858 raw string
1792 raw string
1859 } `json:"-"`
1793 } `json:"-"`
1860 ChatCompletionMessage
1794 ChatCompletionMessage
@@ -1879,13 +1813,13 @@ type ChatCompletionStreamOptionsParam struct {
1879 paramObj
1813 paramObj
1882−// IsPresent returns true if the field's value is not omitted and not the JSON
1883−// "null". To check if this field is omitted, use [param.IsOmitted].
1884−func (f ChatCompletionStreamOptionsParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
1885func (r ChatCompletionStreamOptionsParam) MarshalJSON() (data []byte, err error) {
1816func (r ChatCompletionStreamOptionsParam) MarshalJSON() (data []byte, err error) {
1886 type shadow ChatCompletionStreamOptionsParam
1817 type shadow ChatCompletionStreamOptionsParam
1887 return param.MarshalObject(r, (*shadow)(&r))
1818 return param.MarshalObject(r, (*shadow)(&r))
1820+func (r *ChatCompletionStreamOptionsParam) UnmarshalJSON(data []byte) error {
1821+ return apijson.UnmarshalRoot(data, r)
1890// Developer-provided instructions that the model should follow, regardless of
1824// Developer-provided instructions that the model should follow, regardless of
1891// messages sent by the user. With o1 models and newer, use `developer` messages
1825// messages sent by the user. With o1 models and newer, use `developer` messages
@@ -1905,13 +1839,13 @@ type ChatCompletionSystemMessageParam struct {
1905 paramObj
1839 paramObj
1908−// IsPresent returns true if the field's value is not omitted and not the JSON
1909−// "null". To check if this field is omitted, use [param.IsOmitted].
1910−func (f ChatCompletionSystemMessageParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
1911func (r ChatCompletionSystemMessageParam) MarshalJSON() (data []byte, err error) {
1842func (r ChatCompletionSystemMessageParam) MarshalJSON() (data []byte, err error) {
1912 type shadow ChatCompletionSystemMessageParam
1843 type shadow ChatCompletionSystemMessageParam
1913 return param.MarshalObject(r, (*shadow)(&r))
1844 return param.MarshalObject(r, (*shadow)(&r))
1846+func (r *ChatCompletionSystemMessageParam) UnmarshalJSON(data []byte) error {
1847+ return apijson.UnmarshalRoot(data, r)
1916// Only one field can be non-zero.
1850// Only one field can be non-zero.
@@ -1922,13 +1856,11 @@ type ChatCompletionSystemMessageParamContentUnion struct {
1922 paramUnion
1856 paramUnion
1925−// IsPresent returns true if the field's value is not omitted and not the JSON
1926−// "null". To check if this field is omitted, use [param.IsOmitted].
1927−func (u ChatCompletionSystemMessageParamContentUnion) IsPresent() bool {
1928− return !param.IsOmitted(u) && !u.IsNull()
1930func (u ChatCompletionSystemMessageParamContentUnion) MarshalJSON() ([]byte, error) {
1859func (u ChatCompletionSystemMessageParamContentUnion) MarshalJSON() ([]byte, error) {
1860+ return param.MarshalUnion(u, u.OfString, u.OfArrayOfContentParts)
1931− return param.MarshalUnion[ChatCompletionSystemMessageParamContentUnion](u.OfString, u.OfArrayOfContentParts)
1862+func (u *ChatCompletionSystemMessageParamContentUnion) UnmarshalJSON(data []byte) error {
1863+ return apijson.UnmarshalRoot(data, u)
1934func (u *ChatCompletionSystemMessageParamContentUnion) asAny() any {
1866func (u *ChatCompletionSystemMessageParamContentUnion) asAny() any {
@@ -1956,14 +1888,13 @@ type ChatCompletionTokenLogprob struct {
1956 // position. In rare cases, there may be fewer than the number of requested
1888 // position. In rare cases, there may be fewer than the number of requested
1957 // `top_logprobs` returned.
1889 // `top_logprobs` returned.
1958 TopLogprobs []ChatCompletionTokenLogprobTopLogprob `json:"top_logprobs,required"`
1890 TopLogprobs []ChatCompletionTokenLogprobTopLogprob `json:"top_logprobs,required"`
1959− // Metadata for the response, check the presence of optional fields with the
1891+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1960− // [resp.Field.IsPresent] method.
1961 JSON struct {
1892 JSON struct {
1962− Token resp.Field
1893+ Token respjson.Field
1963− Bytes resp.Field
1894+ Bytes respjson.Field
1964− Logprob resp.Field
1895+ Logprob respjson.Field
1965− TopLogprobs resp.Field
1896+ TopLogprobs respjson.Field
1966− ExtraFields map[string]resp.Field
1897+ ExtraFields map[string]respjson.Field
1967 raw string
1898 raw string
1968 } `json:"-"`
1899 } `json:"-"`
@@ -1986,13 +1917,12 @@ type ChatCompletionTokenLogprobTopLogprob struct {
1986 // tokens. Otherwise, the value `-9999.0` is used to signify that the token is very
1917 // tokens. Otherwise, the value `-9999.0` is used to signify that the token is very
1987 // unlikely.
1918 // unlikely.
1988 Logprob float64 `json:"logprob,required"`
1919 Logprob float64 `json:"logprob,required"`
1989− // Metadata for the response, check the presence of optional fields with the
1920+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1990− // [resp.Field.IsPresent] method.
1991 JSON struct {
1921 JSON struct {
1992− Token resp.Field
1922+ Token respjson.Field
1993− Bytes resp.Field
1923+ Bytes respjson.Field
1994− Logprob resp.Field
1924+ Logprob respjson.Field
1995− ExtraFields map[string]resp.Field
1925+ ExtraFields map[string]respjson.Field
1996 raw string
1926 raw string
1997 } `json:"-"`
1927 } `json:"-"`
@@ -2013,13 +1943,13 @@ type ChatCompletionToolParam struct {
2013 paramObj
1943 paramObj
2016−// IsPresent returns true if the field's value is not omitted and not the JSON
2017−// "null". To check if this field is omitted, use [param.IsOmitted].
2018−func (f ChatCompletionToolParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
2019func (r ChatCompletionToolParam) MarshalJSON() (data []byte, err error) {
1946func (r ChatCompletionToolParam) MarshalJSON() (data []byte, err error) {
2020 type shadow ChatCompletionToolParam
1947 type shadow ChatCompletionToolParam
2021 return param.MarshalObject(r, (*shadow)(&r))
1948 return param.MarshalObject(r, (*shadow)(&r))
1950+func (r *ChatCompletionToolParam) UnmarshalJSON(data []byte) error {
1951+ return apijson.UnmarshalRoot(data, r)
2024func ChatCompletionToolChoiceOptionParamOfChatCompletionNamedToolChoice(function ChatCompletionNamedToolChoiceFunctionParam) ChatCompletionToolChoiceOptionUnionParam {
1954func ChatCompletionToolChoiceOptionParamOfChatCompletionNamedToolChoice(function ChatCompletionNamedToolChoiceFunctionParam) ChatCompletionToolChoiceOptionUnionParam {
2025 var variant ChatCompletionNamedToolChoiceParam
1955 var variant ChatCompletionNamedToolChoiceParam
@@ -2037,13 +1967,11 @@ type ChatCompletionToolChoiceOptionUnionParam struct {
2037 paramUnion
1967 paramUnion
2040−// IsPresent returns true if the field's value is not omitted and not the JSON
2041−// "null". To check if this field is omitted, use [param.IsOmitted].
2042−func (u ChatCompletionToolChoiceOptionUnionParam) IsPresent() bool {
2043− return !param.IsOmitted(u) && !u.IsNull()
2045func (u ChatCompletionToolChoiceOptionUnionParam) MarshalJSON() ([]byte, error) {
1970func (u ChatCompletionToolChoiceOptionUnionParam) MarshalJSON() ([]byte, error) {
1971+ return param.MarshalUnion(u, u.OfAuto, u.OfChatCompletionNamedToolChoice)
2046− return param.MarshalUnion[ChatCompletionToolChoiceOptionUnionParam](u.OfAuto, u.OfChatCompletionNamedToolChoice)
1973+func (u *ChatCompletionToolChoiceOptionUnionParam) UnmarshalJSON(data []byte) error {
1974+ return apijson.UnmarshalRoot(data, u)
2049func (u *ChatCompletionToolChoiceOptionUnionParam) asAny() any {
1977func (u *ChatCompletionToolChoiceOptionUnionParam) asAny() any {
@@ -2055,21 +1983,16 @@ func (u *ChatCompletionToolChoiceOptionUnionParam) asAny() any {
2055 return nil
1983 return nil
2058−// Returns a pointer to the underlying variant's property, if present.
1986+// `none` means the model will not call any tool and instead generates a message.
2059−func (u ChatCompletionToolChoiceOptionUnionParam) GetFunction() *ChatCompletionNamedToolChoiceFunctionParam {
1987+// `auto` means the model can pick between generating a message or calling one or
2060− if vt := u.OfChatCompletionNamedToolChoice; vt != nil {
1988+// more tools. `required` means the model must call one or more tools.
2061− return &vt.Function
1989+type ChatCompletionToolChoiceOptionAuto string
2066−// Returns a pointer to the underlying variant's property, if present.
1991+const (
2067−func (u ChatCompletionToolChoiceOptionUnionParam) GetType() *string {
1992+ ChatCompletionToolChoiceOptionAutoNone ChatCompletionToolChoiceOptionAuto = "none"
2068− if vt := u.OfChatCompletionNamedToolChoice; vt != nil {
1993+ ChatCompletionToolChoiceOptionAutoAuto ChatCompletionToolChoiceOptionAuto = "auto"
2069− return (*string)(&vt.Type)
1994+ ChatCompletionToolChoiceOptionAutoRequired ChatCompletionToolChoiceOptionAuto = "required"
2074// The properties Content, Role, ToolCallID are required.
1997// The properties Content, Role, ToolCallID are required.
2075type ChatCompletionToolMessageParam struct {
1998type ChatCompletionToolMessageParam struct {
@@ -2084,13 +2007,13 @@ type ChatCompletionToolMessageParam struct {
2084 paramObj
2007 paramObj
2087−// IsPresent returns true if the field's value is not omitted and not the JSON
2088−// "null". To check if this field is omitted, use [param.IsOmitted].
2089−func (f ChatCompletionToolMessageParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
2090func (r ChatCompletionToolMessageParam) MarshalJSON() (data []byte, err error) {
2010func (r ChatCompletionToolMessageParam) MarshalJSON() (data []byte, err error) {
2091 type shadow ChatCompletionToolMessageParam
2011 type shadow ChatCompletionToolMessageParam
2092 return param.MarshalObject(r, (*shadow)(&r))
2012 return param.MarshalObject(r, (*shadow)(&r))
2014+func (r *ChatCompletionToolMessageParam) UnmarshalJSON(data []byte) error {
2015+ return apijson.UnmarshalRoot(data, r)
2095// Only one field can be non-zero.
2018// Only one field can be non-zero.
@@ -2101,13 +2024,11 @@ type ChatCompletionToolMessageParamContentUnion struct {
2101 paramUnion
2024 paramUnion
2104−// IsPresent returns true if the field's value is not omitted and not the JSON
2105−// "null". To check if this field is omitted, use [param.IsOmitted].
2106−func (u ChatCompletionToolMessageParamContentUnion) IsPresent() bool {
2107− return !param.IsOmitted(u) && !u.IsNull()
2109func (u ChatCompletionToolMessageParamContentUnion) MarshalJSON() ([]byte, error) {
2027func (u ChatCompletionToolMessageParamContentUnion) MarshalJSON() ([]byte, error) {
2028+ return param.MarshalUnion(u, u.OfString, u.OfArrayOfContentParts)
2110− return param.MarshalUnion[ChatCompletionToolMessageParamContentUnion](u.OfString, u.OfArrayOfContentParts)
2030+func (u *ChatCompletionToolMessageParamContentUnion) UnmarshalJSON(data []byte) error {
2031+ return apijson.UnmarshalRoot(data, u)
2113func (u *ChatCompletionToolMessageParamContentUnion) asAny() any {
2034func (u *ChatCompletionToolMessageParamContentUnion) asAny() any {
@@ -2136,13 +2057,13 @@ type ChatCompletionUserMessageParam struct {
2136 paramObj
2057 paramObj
2139−// IsPresent returns true if the field's value is not omitted and not the JSON
2140−// "null". To check if this field is omitted, use [param.IsOmitted].
2141−func (f ChatCompletionUserMessageParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
2142func (r ChatCompletionUserMessageParam) MarshalJSON() (data []byte, err error) {
2060func (r ChatCompletionUserMessageParam) MarshalJSON() (data []byte, err error) {
2143 type shadow ChatCompletionUserMessageParam
2061 type shadow ChatCompletionUserMessageParam
2144 return param.MarshalObject(r, (*shadow)(&r))
2062 return param.MarshalObject(r, (*shadow)(&r))
2064+func (r *ChatCompletionUserMessageParam) UnmarshalJSON(data []byte) error {
2065+ return apijson.UnmarshalRoot(data, r)
2147// Only one field can be non-zero.
2068// Only one field can be non-zero.
@@ -2153,13 +2074,11 @@ type ChatCompletionUserMessageParamContentUnion struct {
2153 paramUnion
2074 paramUnion
2156−// IsPresent returns true if the field's value is not omitted and not the JSON
2157−// "null". To check if this field is omitted, use [param.IsOmitted].
2158−func (u ChatCompletionUserMessageParamContentUnion) IsPresent() bool {
2159− return !param.IsOmitted(u) && !u.IsNull()
2161func (u ChatCompletionUserMessageParamContentUnion) MarshalJSON() ([]byte, error) {
2077func (u ChatCompletionUserMessageParamContentUnion) MarshalJSON() ([]byte, error) {
2078+ return param.MarshalUnion(u, u.OfString, u.OfArrayOfContentParts)
2162− return param.MarshalUnion[ChatCompletionUserMessageParamContentUnion](u.OfString, u.OfArrayOfContentParts)
2080+func (u *ChatCompletionUserMessageParamContentUnion) UnmarshalJSON(data []byte) error {
2081+ return apijson.UnmarshalRoot(data, u)
2165func (u *ChatCompletionUserMessageParamContentUnion) asAny() any {
2084func (u *ChatCompletionUserMessageParamContentUnion) asAny() any {
@@ -2179,7 +2098,7 @@ type ChatCompletionNewParams struct {
2179 // [images](https://platform.openai.com/docs/guides/vision), and
2098 // [images](https://platform.openai.com/docs/guides/vision), and
2180 // [audio](https://platform.openai.com/docs/guides/audio).
2099 // [audio](https://platform.openai.com/docs/guides/audio).
2181 Messages []ChatCompletionMessageParamUnion `json:"messages,omitzero,required"`
2100 Messages []ChatCompletionMessageParamUnion `json:"messages,omitzero,required"`
2182− // Model ID used to generate the response, like `gpt-4o` or `o1`. OpenAI offers a
2101+ // Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a
2183 // wide range of models with different capabilities, performance characteristics,
2102 // wide range of models with different capabilities, performance characteristics,
2184 // and price points. Refer to the
2103 // and price points. Refer to the
2185 // [model guide](https://platform.openai.com/docs/models) to browse and compare
2104 // [model guide](https://platform.openai.com/docs/models) to browse and compare
@@ -2203,7 +2122,7 @@ type ChatCompletionNewParams struct {
2204 // This value is now deprecated in favor of `max_completion_tokens`, and is not
2123 // This value is now deprecated in favor of `max_completion_tokens`, and is not
2205 // compatible with
2124 // compatible with
2206− // [o1 series models](https://platform.openai.com/docs/guides/reasoning).
2125+ // [o-series models](https://platform.openai.com/docs/guides/reasoning).
2207 MaxTokens param.Opt[int64] `json:"max_tokens,omitzero"`
2126 MaxTokens param.Opt[int64] `json:"max_tokens,omitzero"`
2208 // How many chat completion choices to generate for each input message. Note that
2127 // How many chat completion choices to generate for each input message. Note that
2209 // you will be charged based on the number of generated tokens across all of the
2128 // you will be charged based on the number of generated tokens across all of the
@@ -2222,6 +2141,8 @@ type ChatCompletionNewParams struct {
2222 // Whether or not to store the output of this chat completion request for use in
2141 // Whether or not to store the output of this chat completion request for use in
2223 // our [model distillation](https://platform.openai.com/docs/guides/distillation)
2142 // our [model distillation](https://platform.openai.com/docs/guides/distillation)
2224 // or [evals](https://platform.openai.com/docs/guides/evals) products.
2143 // or [evals](https://platform.openai.com/docs/guides/evals) products.
2145+ // Supports text and image inputs. Note: image inputs over 10MB will be dropped.
2225 Store param.Opt[bool] `json:"store,omitzero"`
2146 Store param.Opt[bool] `json:"store,omitzero"`
2226 // What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
2147 // What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
2227 // make the output more random, while lower values like 0.2 will make it more
2148 // make the output more random, while lower values like 0.2 will make it more
@@ -2242,8 +2163,8 @@ type ChatCompletionNewParams struct {
2242 // [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling)
2163 // [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling)
2243 // during tool use.
2164 // during tool use.
2244 ParallelToolCalls param.Opt[bool] `json:"parallel_tool_calls,omitzero"`
2165 ParallelToolCalls param.Opt[bool] `json:"parallel_tool_calls,omitzero"`
2245− // A unique identifier representing your end-user, which can help OpenAI to monitor
2166+ // A stable identifier for your end-users. Used to boost cache hit rates by better
2246− // and detect abuse.
2167+ // bucketing similar requests and to help OpenAI detect and prevent abuse.
2247 // [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
2168 // [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
2248 User param.Opt[string] `json:"user,omitzero"`
2169 User param.Opt[string] `json:"user,omitzero"`
2249 // Parameters for audio output. Required when audio output is requested with
2170 // Parameters for audio output. Required when audio output is requested with
@@ -2265,7 +2186,7 @@ type ChatCompletionNewParams struct {
2266 // Keys are strings with a maximum length of 64 characters. Values are strings with
2187 // Keys are strings with a maximum length of 64 characters. Values are strings with
2267 // a maximum length of 512 characters.
2188 // a maximum length of 512 characters.
2268− Metadata shared.MetadataParam `json:"metadata,omitzero"`
2189+ Metadata shared.Metadata `json:"metadata,omitzero"`
2269 // Output types that you would like the model to generate. Most models are capable
2190 // Output types that you would like the model to generate. Most models are capable
2270 // of generating text, which is the default:
2191 // of generating text, which is the default:
@@ -2276,6 +2197,8 @@ type ChatCompletionNewParams struct {
2276 // this model generate both text and audio responses, you can use:
2197 // this model generate both text and audio responses, you can use:
2278 // `["text", "audio"]`
2199 // `["text", "audio"]`
2201+ // Any of "text", "audio".
2279 Modalities []string `json:"modalities,omitzero"`
2202 Modalities []string `json:"modalities,omitzero"`
2280 // **o-series models only**
2203 // **o-series models only**
@@ -2286,23 +2209,28 @@ type ChatCompletionNewParams struct {
2287 // Any of "low", "medium", "high".
2210 // Any of "low", "medium", "high".
2288 ReasoningEffort shared.ReasoningEffort `json:"reasoning_effort,omitzero"`
2211 ReasoningEffort shared.ReasoningEffort `json:"reasoning_effort,omitzero"`
2289− // Specifies the latency tier to use for processing the request. This parameter is
2212+ // Specifies the processing type used for serving the request.
2290− // relevant for customers subscribed to the scale tier service:
2213+ //
2291− //
2214+ // - If set to 'auto', then the request will be processed with the service tier
2292− // - If set to 'auto', and the Project is Scale tier enabled, the system will
2215+ // configured in the Project settings. Unless otherwise configured, the Project
2293− // utilize scale tier credits until they are exhausted.
2216+ // will use 'default'.
2294− // - If set to 'auto', and the Project is not Scale tier enabled, the request will
2217+ // - If set to 'default', then the requset will be processed with the standard
2295− // be processed using the default service tier with a lower uptime SLA and no
2218+ // pricing and performance for the selected model.
2296− // latency guarentee.
2219+ // - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
2297− // - If set to 'default', the request will be processed using the default service
2220+ // 'priority', then the request will be processed with the corresponding service
2298− // tier with a lower uptime SLA and no latency guarentee.
2221+ // tier. [Contact sales](https://openai.com/contact-sales) to learn more about
2222+ // Priority processing.
2299 // - When not set, the default behavior is 'auto'.
2223 // - When not set, the default behavior is 'auto'.
2301− // When this parameter is set, the response body will include the `service_tier`
2225+ // When the `service_tier` parameter is set, the response body will include the
2302− // utilized.
2226+ // `service_tier` value based on the processing mode actually used to serve the
2227+ // request. This response value may be different from the value set in the
2304− // Any of "auto", "default".
2230+ // Any of "auto", "default", "flex", "scale", "priority".
2305 ServiceTier ChatCompletionNewParamsServiceTier `json:"service_tier,omitzero"`
2231 ServiceTier ChatCompletionNewParamsServiceTier `json:"service_tier,omitzero"`
2232+ // Not supported with latest reasoning models `o3` and `o4-mini`.
2306 // Up to 4 sequences where the API will stop generating further tokens. The
2234 // Up to 4 sequences where the API will stop generating further tokens. The
2307 // returned text will not contain the stop sequence.
2235 // returned text will not contain the stop sequence.
2308 Stop ChatCompletionNewParamsStopUnion `json:"stop,omitzero"`
2236 Stop ChatCompletionNewParamsStopUnion `json:"stop,omitzero"`
@@ -2362,14 +2290,13 @@ type ChatCompletionNewParams struct {
2362 paramObj
2290 paramObj
2365−// IsPresent returns true if the field's value is not omitted and not the JSON
2366−// "null". To check if this field is omitted, use [param.IsOmitted].
2367−func (f ChatCompletionNewParams) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
2369func (r ChatCompletionNewParams) MarshalJSON() (data []byte, err error) {
2293func (r ChatCompletionNewParams) MarshalJSON() (data []byte, err error) {
2370 type shadow ChatCompletionNewParams
2294 type shadow ChatCompletionNewParams
2371 return param.MarshalObject(r, (*shadow)(&r))
2295 return param.MarshalObject(r, (*shadow)(&r))
2297+func (r *ChatCompletionNewParams) UnmarshalJSON(data []byte) error {
2298+ return apijson.UnmarshalRoot(data, r)
2374// Only one field can be non-zero.
2301// Only one field can be non-zero.
@@ -2381,13 +2308,11 @@ type ChatCompletionNewParamsFunctionCallUnion struct {
2381 paramUnion
2308 paramUnion
2384−// IsPresent returns true if the field's value is not omitted and not the JSON
2385−// "null". To check if this field is omitted, use [param.IsOmitted].
2386−func (u ChatCompletionNewParamsFunctionCallUnion) IsPresent() bool {
2387− return !param.IsOmitted(u) && !u.IsNull()
2389func (u ChatCompletionNewParamsFunctionCallUnion) MarshalJSON() ([]byte, error) {
2311func (u ChatCompletionNewParamsFunctionCallUnion) MarshalJSON() ([]byte, error) {
2312+ return param.MarshalUnion(u, u.OfFunctionCallMode, u.OfFunctionCallOption)
2390− return param.MarshalUnion[ChatCompletionNewParamsFunctionCallUnion](u.OfFunctionCallMode, u.OfFunctionCallOption)
2314+func (u *ChatCompletionNewParamsFunctionCallUnion) UnmarshalJSON(data []byte) error {
2315+ return apijson.UnmarshalRoot(data, u)
2393func (u *ChatCompletionNewParamsFunctionCallUnion) asAny() any {
2318func (u *ChatCompletionNewParamsFunctionCallUnion) asAny() any {
@@ -2399,13 +2324,15 @@ func (u *ChatCompletionNewParamsFunctionCallUnion) asAny() any {
2399 return nil
2324 return nil
2402−// Returns a pointer to the underlying variant's property, if present.
2327+// `none` means the model will not call a function and instead generates a message.
2403−func (u ChatCompletionNewParamsFunctionCallUnion) GetName() *string {
2328+// `auto` means the model can pick between generating a message or calling a
2404− if vt := u.OfFunctionCallOption; vt != nil {
2329+// function.
2405− return &vt.Name
2330+type ChatCompletionNewParamsFunctionCallFunctionCallMode string
2407− return nil
2332+const (
2408−}
2333+ ChatCompletionNewParamsFunctionCallFunctionCallModeNone ChatCompletionNewParamsFunctionCallFunctionCallMode = "none"
2334+ ChatCompletionNewParamsFunctionCallFunctionCallModeAuto ChatCompletionNewParamsFunctionCallFunctionCallMode = "auto"
2410// Deprecated: deprecated
2337// Deprecated: deprecated
@@ -2428,13 +2355,13 @@ type ChatCompletionNewParamsFunction struct {
2428 paramObj
2355 paramObj
2431−// IsPresent returns true if the field's value is not omitted and not the JSON
2432−// "null". To check if this field is omitted, use [param.IsOmitted].
2433−func (f ChatCompletionNewParamsFunction) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
2434func (r ChatCompletionNewParamsFunction) MarshalJSON() (data []byte, err error) {
2358func (r ChatCompletionNewParamsFunction) MarshalJSON() (data []byte, err error) {
2435 type shadow ChatCompletionNewParamsFunction
2359 type shadow ChatCompletionNewParamsFunction
2436 return param.MarshalObject(r, (*shadow)(&r))
2360 return param.MarshalObject(r, (*shadow)(&r))
2362+func (r *ChatCompletionNewParamsFunction) UnmarshalJSON(data []byte) error {
2363+ return apijson.UnmarshalRoot(data, r)
2439// Only one field can be non-zero.
2366// Only one field can be non-zero.
@@ -2446,13 +2373,11 @@ type ChatCompletionNewParamsResponseFormatUnion struct {
2446 paramUnion
2373 paramUnion
2449−// IsPresent returns true if the field's value is not omitted and not the JSON
2450−// "null". To check if this field is omitted, use [param.IsOmitted].
2451−func (u ChatCompletionNewParamsResponseFormatUnion) IsPresent() bool {
2452− return !param.IsOmitted(u) && !u.IsNull()
2454func (u ChatCompletionNewParamsResponseFormatUnion) MarshalJSON() ([]byte, error) {
2376func (u ChatCompletionNewParamsResponseFormatUnion) MarshalJSON() ([]byte, error) {
2455− return param.MarshalUnion[ChatCompletionNewParamsResponseFormatUnion](u.OfText, u.OfJSONSchema, u.OfJSONObject)
2377+ return param.MarshalUnion(u, u.OfText, u.OfJSONSchema, u.OfJSONObject)
2379+func (u *ChatCompletionNewParamsResponseFormatUnion) UnmarshalJSON(data []byte) error {
2380+ return apijson.UnmarshalRoot(data, u)
2458func (u *ChatCompletionNewParamsResponseFormatUnion) asAny() any {
2383func (u *ChatCompletionNewParamsResponseFormatUnion) asAny() any {
@@ -2486,48 +2411,54 @@ func (u ChatCompletionNewParamsResponseFormatUnion) GetType() *string {
2486 return nil
2411 return nil
2489−// Specifies the latency tier to use for processing the request. This parameter is
2414+// Specifies the processing type used for serving the request.
2490−// relevant for customers subscribed to the scale tier service:
2492−// - If set to 'auto', and the Project is Scale tier enabled, the system will
2416+// - If set to 'auto', then the request will be processed with the service tier
2493−// utilize scale tier credits until they are exhausted.
2417+// configured in the Project settings. Unless otherwise configured, the Project
2494−// - If set to 'auto', and the Project is not Scale tier enabled, the request will
2418+// will use 'default'.
2495−// be processed using the default service tier with a lower uptime SLA and no
2419+// - If set to 'default', then the requset will be processed with the standard
2496−// latency guarentee.
2420+// pricing and performance for the selected model.
2421+// - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
2497−// - If set to 'default', the request will be processed using the default service
2422+// 'priority', then the request will be processed with the corresponding service
2498−// tier with a lower uptime SLA and no latency guarentee.
2423+// tier. [Contact sales](https://openai.com/contact-sales) to learn more about
2424+// Priority processing.
2499// - When not set, the default behavior is 'auto'.
2425// - When not set, the default behavior is 'auto'.
2501−// When this parameter is set, the response body will include the `service_tier`
2427+// When the `service_tier` parameter is set, the response body will include the
2502−// utilized.
2428+// `service_tier` value based on the processing mode actually used to serve the
2429+// request. This response value may be different from the value set in the
2503type ChatCompletionNewParamsServiceTier string
2431type ChatCompletionNewParamsServiceTier string
2506− ChatCompletionNewParamsServiceTierAuto ChatCompletionNewParamsServiceTier = "auto"
2434+ ChatCompletionNewParamsServiceTierAuto ChatCompletionNewParamsServiceTier = "auto"
2507− ChatCompletionNewParamsServiceTierDefault ChatCompletionNewParamsServiceTier = "default"
2435+ ChatCompletionNewParamsServiceTierDefault ChatCompletionNewParamsServiceTier = "default"
2436+ ChatCompletionNewParamsServiceTierFlex ChatCompletionNewParamsServiceTier = "flex"
2437+ ChatCompletionNewParamsServiceTierScale ChatCompletionNewParamsServiceTier = "scale"
2438+ ChatCompletionNewParamsServiceTierPriority ChatCompletionNewParamsServiceTier = "priority"
2510// Only one field can be non-zero.
2441// Only one field can be non-zero.
2512// Use [param.IsOmitted] to confirm if a field is set.
2443// Use [param.IsOmitted] to confirm if a field is set.
2513type ChatCompletionNewParamsStopUnion struct {
2444type ChatCompletionNewParamsStopUnion struct {
2514− OfString param.Opt[string] `json:",omitzero,inline"`
2445+ OfString param.Opt[string] `json:",omitzero,inline"`
2515− OfChatCompletionNewsStopArray []string `json:",omitzero,inline"`
2446+ OfStringArray []string `json:",omitzero,inline"`
2516 paramUnion
2447 paramUnion
2519−// IsPresent returns true if the field's value is not omitted and not the JSON
2520−// "null". To check if this field is omitted, use [param.IsOmitted].
2521−func (u ChatCompletionNewParamsStopUnion) IsPresent() bool { return !param.IsOmitted(u) && !u.IsNull() }
2522func (u ChatCompletionNewParamsStopUnion) MarshalJSON() ([]byte, error) {
2450func (u ChatCompletionNewParamsStopUnion) MarshalJSON() ([]byte, error) {
2451+ return param.MarshalUnion(u, u.OfString, u.OfStringArray)
2523− return param.MarshalUnion[ChatCompletionNewParamsStopUnion](u.OfString, u.OfChatCompletionNewsStopArray)
2453+func (u *ChatCompletionNewParamsStopUnion) UnmarshalJSON(data []byte) error {
2454+ return apijson.UnmarshalRoot(data, u)
2526func (u *ChatCompletionNewParamsStopUnion) asAny() any {
2457func (u *ChatCompletionNewParamsStopUnion) asAny() any {
2527 if !param.IsOmitted(u.OfString) {
2458 if !param.IsOmitted(u.OfString) {
2528 return &u.OfString.Value
2459 return &u.OfString.Value
2529− } else if !param.IsOmitted(u.OfChatCompletionNewsStopArray) {
2460+ } else if !param.IsOmitted(u.OfStringArray) {
2530− return &u.OfChatCompletionNewsStopArray
2461+ return &u.OfStringArray
2532 return nil
2463 return nil
@@ -2546,19 +2477,17 @@ type ChatCompletionNewParamsWebSearchOptions struct {
2546 paramObj
2477 paramObj
2549−// IsPresent returns true if the field's value is not omitted and not the JSON
2550−// "null". To check if this field is omitted, use [param.IsOmitted].
2551−func (f ChatCompletionNewParamsWebSearchOptions) IsPresent() bool {
2552− return !param.IsOmitted(f) && !f.IsNull()
2554func (r ChatCompletionNewParamsWebSearchOptions) MarshalJSON() (data []byte, err error) {
2480func (r ChatCompletionNewParamsWebSearchOptions) MarshalJSON() (data []byte, err error) {
2555 type shadow ChatCompletionNewParamsWebSearchOptions
2481 type shadow ChatCompletionNewParamsWebSearchOptions
2556 return param.MarshalObject(r, (*shadow)(&r))
2482 return param.MarshalObject(r, (*shadow)(&r))
2484+func (r *ChatCompletionNewParamsWebSearchOptions) UnmarshalJSON(data []byte) error {
2485+ return apijson.UnmarshalRoot(data, r)
2559func init() {
2488func init() {
2560 apijson.RegisterFieldValidator[ChatCompletionNewParamsWebSearchOptions](
2489 apijson.RegisterFieldValidator[ChatCompletionNewParamsWebSearchOptions](
2561− "SearchContextSize", false, "low", "medium", "high",
2490+ "search_context_size", "low", "medium", "high",
@@ -2575,15 +2504,13 @@ type ChatCompletionNewParamsWebSearchOptionsUserLocation struct {
2575 paramObj
2504 paramObj
2578−// IsPresent returns true if the field's value is not omitted and not the JSON
2579−// "null". To check if this field is omitted, use [param.IsOmitted].
2580−func (f ChatCompletionNewParamsWebSearchOptionsUserLocation) IsPresent() bool {
2581− return !param.IsOmitted(f) && !f.IsNull()
2583func (r ChatCompletionNewParamsWebSearchOptionsUserLocation) MarshalJSON() (data []byte, err error) {
2507func (r ChatCompletionNewParamsWebSearchOptionsUserLocation) MarshalJSON() (data []byte, err error) {
2584 type shadow ChatCompletionNewParamsWebSearchOptionsUserLocation
2508 type shadow ChatCompletionNewParamsWebSearchOptionsUserLocation
2585 return param.MarshalObject(r, (*shadow)(&r))
2509 return param.MarshalObject(r, (*shadow)(&r))
2511+func (r *ChatCompletionNewParamsWebSearchOptionsUserLocation) UnmarshalJSON(data []byte) error {
2512+ return apijson.UnmarshalRoot(data, r)
2588// Approximate location parameters for the search.
2515// Approximate location parameters for the search.
2589type ChatCompletionNewParamsWebSearchOptionsUserLocationApproximate struct {
2516type ChatCompletionNewParamsWebSearchOptionsUserLocationApproximate struct {
@@ -2600,15 +2527,13 @@ type ChatCompletionNewParamsWebSearchOptionsUserLocationApproximate struct {
2600 paramObj
2527 paramObj
2603−// IsPresent returns true if the field's value is not omitted and not the JSON
2604−// "null". To check if this field is omitted, use [param.IsOmitted].
2605−func (f ChatCompletionNewParamsWebSearchOptionsUserLocationApproximate) IsPresent() bool {
2606− return !param.IsOmitted(f) && !f.IsNull()
2608func (r ChatCompletionNewParamsWebSearchOptionsUserLocationApproximate) MarshalJSON() (data []byte, err error) {
2530func (r ChatCompletionNewParamsWebSearchOptionsUserLocationApproximate) MarshalJSON() (data []byte, err error) {
2609 type shadow ChatCompletionNewParamsWebSearchOptionsUserLocationApproximate
2531 type shadow ChatCompletionNewParamsWebSearchOptionsUserLocationApproximate
2610 return param.MarshalObject(r, (*shadow)(&r))
2532 return param.MarshalObject(r, (*shadow)(&r))
2534+func (r *ChatCompletionNewParamsWebSearchOptionsUserLocationApproximate) UnmarshalJSON(data []byte) error {
2535+ return apijson.UnmarshalRoot(data, r)
2613type ChatCompletionUpdateParams struct {
2538type ChatCompletionUpdateParams struct {
2614 // Set of 16 key-value pairs that can be attached to an object. This can be useful
2539 // Set of 16 key-value pairs that can be attached to an object. This can be useful
@@ -2617,18 +2542,17 @@ type ChatCompletionUpdateParams struct {
2618 // Keys are strings with a maximum length of 64 characters. Values are strings with
2543 // Keys are strings with a maximum length of 64 characters. Values are strings with
2619 // a maximum length of 512 characters.
2544 // a maximum length of 512 characters.
2620− Metadata shared.MetadataParam `json:"metadata,omitzero,required"`
2545+ Metadata shared.Metadata `json:"metadata,omitzero,required"`
2621 paramObj
2546 paramObj
2624−// IsPresent returns true if the field's value is not omitted and not the JSON
2625−// "null". To check if this field is omitted, use [param.IsOmitted].
2626−func (f ChatCompletionUpdateParams) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
2628func (r ChatCompletionUpdateParams) MarshalJSON() (data []byte, err error) {
2549func (r ChatCompletionUpdateParams) MarshalJSON() (data []byte, err error) {
2629 type shadow ChatCompletionUpdateParams
2550 type shadow ChatCompletionUpdateParams
2630 return param.MarshalObject(r, (*shadow)(&r))
2551 return param.MarshalObject(r, (*shadow)(&r))
2553+func (r *ChatCompletionUpdateParams) UnmarshalJSON(data []byte) error {
2554+ return apijson.UnmarshalRoot(data, r)
2633type ChatCompletionListParams struct {
2557type ChatCompletionListParams struct {
2634 // Identifier for the last chat completion from the previous pagination request.
2558 // Identifier for the last chat completion from the previous pagination request.
@@ -2640,7 +2564,7 @@ type ChatCompletionListParams struct {
2640 // A list of metadata keys to filter the Chat Completions by. Example:
2564 // A list of metadata keys to filter the Chat Completions by. Example:
2642 // `metadata[key1]=value1&metadata[key2]=value2`
2566 // `metadata[key1]=value1&metadata[key2]=value2`
2643− Metadata shared.MetadataParam `query:"metadata,omitzero" json:"-"`
2567+ Metadata shared.Metadata `query:"metadata,omitzero" json:"-"`
2644 // Sort order for Chat Completions by timestamp. Use `asc` for ascending order or
2568 // Sort order for Chat Completions by timestamp. Use `asc` for ascending order or
2645 // `desc` for descending order. Defaults to `asc`.
2569 // `desc` for descending order. Defaults to `asc`.
@@ -2649,13 +2573,9 @@ type ChatCompletionListParams struct {
2649 paramObj
2573 paramObj
2652−// IsPresent returns true if the field's value is not omitted and not the JSON
2653−// "null". To check if this field is omitted, use [param.IsOmitted].
2654−func (f ChatCompletionListParams) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
2656// URLQuery serializes [ChatCompletionListParams]'s query parameters as
2576// URLQuery serializes [ChatCompletionListParams]'s query parameters as
2657// `url.Values`.
2577// `url.Values`.
2658−func (r ChatCompletionListParams) URLQuery() (v url.Values) {
2578+func (r ChatCompletionListParams) URLQuery() (v url.Values, err error) {
2659 return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
2579 return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
2660 ArrayFormat: apiquery.ArrayQueryFormatBrackets,
2580 ArrayFormat: apiquery.ArrayQueryFormatBrackets,
2661 NestedFormat: apiquery.NestedQueryFormatBrackets,
2581 NestedFormat: apiquery.NestedQueryFormatBrackets,