@@ -964,6 +964,59 @@ func (r *ChatCompletionContentPartFileFileParam) UnmarshalJSON(data []byte) erro
964964 return apijson .UnmarshalRoot (data , r )
965965}
966966
967+ // Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
968+ type ChatCompletionContentPartImage struct {
969+ ImageURL ChatCompletionContentPartImageImageURL `json:"image_url,required"`
970+ // The type of the content part.
971+ Type constant.ImageURL `json:"type,required"`
972+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
973+ JSON struct {
974+ ImageURL respjson.Field
975+ Type respjson.Field
976+ ExtraFields map [string ]respjson.Field
977+ raw string
978+ } `json:"-"`
979+ }
980+
981+ // Returns the unmodified JSON received from the API
982+ func (r ChatCompletionContentPartImage ) RawJSON () string { return r .JSON .raw }
983+ func (r * ChatCompletionContentPartImage ) UnmarshalJSON (data []byte ) error {
984+ return apijson .UnmarshalRoot (data , r )
985+ }
986+
987+ // ToParam converts this ChatCompletionContentPartImage to a
988+ // ChatCompletionContentPartImageParam.
989+ //
990+ // Warning: the fields of the param type will not be present. ToParam should only
991+ // be used at the last possible moment before sending a request. Test for this with
992+ // ChatCompletionContentPartImageParam.Overrides()
993+ func (r ChatCompletionContentPartImage ) ToParam () ChatCompletionContentPartImageParam {
994+ return param.Override [ChatCompletionContentPartImageParam ](json .RawMessage (r .RawJSON ()))
995+ }
996+
997+ type ChatCompletionContentPartImageImageURL struct {
998+ // Either a URL of the image or the base64 encoded image data.
999+ URL string `json:"url,required" format:"uri"`
1000+ // Specifies the detail level of the image. Learn more in the
1001+ // [Vision guide](https://platform.openai.com/docs/guides/vision#low-or-high-fidelity-image-understanding).
1002+ //
1003+ // Any of "auto", "low", "high".
1004+ Detail string `json:"detail"`
1005+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1006+ JSON struct {
1007+ URL respjson.Field
1008+ Detail respjson.Field
1009+ ExtraFields map [string ]respjson.Field
1010+ raw string
1011+ } `json:"-"`
1012+ }
1013+
1014+ // Returns the unmodified JSON received from the API
1015+ func (r ChatCompletionContentPartImageImageURL ) RawJSON () string { return r .JSON .raw }
1016+ func (r * ChatCompletionContentPartImageImageURL ) UnmarshalJSON (data []byte ) error {
1017+ return apijson .UnmarshalRoot (data , r )
1018+ }
1019+
9671020// Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
9681021//
9691022// The properties ImageURL, Type are required.
@@ -1074,6 +1127,38 @@ func (r *ChatCompletionContentPartRefusalParam) UnmarshalJSON(data []byte) error
10741127 return apijson .UnmarshalRoot (data , r )
10751128}
10761129
1130+ // Learn about
1131+ // [text inputs](https://platform.openai.com/docs/guides/text-generation).
1132+ type ChatCompletionContentPartText struct {
1133+ // The text content.
1134+ Text string `json:"text,required"`
1135+ // The type of the content part.
1136+ Type constant.Text `json:"type,required"`
1137+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1138+ JSON struct {
1139+ Text respjson.Field
1140+ Type respjson.Field
1141+ ExtraFields map [string ]respjson.Field
1142+ raw string
1143+ } `json:"-"`
1144+ }
1145+
1146+ // Returns the unmodified JSON received from the API
1147+ func (r ChatCompletionContentPartText ) RawJSON () string { return r .JSON .raw }
1148+ func (r * ChatCompletionContentPartText ) UnmarshalJSON (data []byte ) error {
1149+ return apijson .UnmarshalRoot (data , r )
1150+ }
1151+
1152+ // ToParam converts this ChatCompletionContentPartText to a
1153+ // ChatCompletionContentPartTextParam.
1154+ //
1155+ // Warning: the fields of the param type will not be present. ToParam should only
1156+ // be used at the last possible moment before sending a request. Test for this with
1157+ // ChatCompletionContentPartTextParam.Overrides()
1158+ func (r ChatCompletionContentPartText ) ToParam () ChatCompletionContentPartTextParam {
1159+ return param.Override [ChatCompletionContentPartTextParam ](json .RawMessage (r .RawJSON ()))
1160+ }
1161+
10771162// Learn about
10781163// [text inputs](https://platform.openai.com/docs/guides/text-generation).
10791164//
@@ -1795,11 +1880,15 @@ func (u *ChatCompletionPredictionContentContentUnionParam) asAny() any {
17951880type ChatCompletionStoreMessage struct {
17961881 // The identifier of the chat message.
17971882 ID string `json:"id,required"`
1883+ // If a content parts array was provided, this is an array of `text` and
1884+ // `image_url` parts. Otherwise, null.
1885+ ContentParts []ChatCompletionStoreMessageContentPartUnion `json:"content_parts,nullable"`
17981886 // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
17991887 JSON struct {
1800- ID respjson.Field
1801- ExtraFields map [string ]respjson.Field
1802- raw string
1888+ ID respjson.Field
1889+ ContentParts respjson.Field
1890+ ExtraFields map [string ]respjson.Field
1891+ raw string
18031892 } `json:"-"`
18041893 ChatCompletionMessage
18051894}
@@ -1810,6 +1899,41 @@ func (r *ChatCompletionStoreMessage) UnmarshalJSON(data []byte) error {
18101899 return apijson .UnmarshalRoot (data , r )
18111900}
18121901
1902+ // ChatCompletionStoreMessageContentPartUnion contains all possible properties and
1903+ // values from [ChatCompletionContentPartText], [ChatCompletionContentPartImage].
1904+ //
1905+ // Use the methods beginning with 'As' to cast the union to one of its variants.
1906+ type ChatCompletionStoreMessageContentPartUnion struct {
1907+ // This field is from variant [ChatCompletionContentPartText].
1908+ Text string `json:"text"`
1909+ Type string `json:"type"`
1910+ // This field is from variant [ChatCompletionContentPartImage].
1911+ ImageURL ChatCompletionContentPartImageImageURL `json:"image_url"`
1912+ JSON struct {
1913+ Text respjson.Field
1914+ Type respjson.Field
1915+ ImageURL respjson.Field
1916+ raw string
1917+ } `json:"-"`
1918+ }
1919+
1920+ func (u ChatCompletionStoreMessageContentPartUnion ) AsTextContentPart () (v ChatCompletionContentPartText ) {
1921+ apijson .UnmarshalRoot (json .RawMessage (u .JSON .raw ), & v )
1922+ return
1923+ }
1924+
1925+ func (u ChatCompletionStoreMessageContentPartUnion ) AsImageContentPart () (v ChatCompletionContentPartImage ) {
1926+ apijson .UnmarshalRoot (json .RawMessage (u .JSON .raw ), & v )
1927+ return
1928+ }
1929+
1930+ // Returns the unmodified JSON received from the API
1931+ func (u ChatCompletionStoreMessageContentPartUnion ) RawJSON () string { return u .JSON .raw }
1932+
1933+ func (r * ChatCompletionStoreMessageContentPartUnion ) UnmarshalJSON (data []byte ) error {
1934+ return apijson .UnmarshalRoot (data , r )
1935+ }
1936+
18131937// Options for streaming response. Only set this when you set `stream: true`.
18141938type ChatCompletionStreamOptionsParam struct {
18151939 // If set, an additional chunk will be streamed before the `data: [DONE]` message.
@@ -2173,9 +2297,21 @@ type ChatCompletionNewParams struct {
21732297 // [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling)
21742298 // during tool use.
21752299 ParallelToolCalls param.Opt [bool ] `json:"parallel_tool_calls,omitzero"`
2176- // A stable identifier for your end-users. Used to boost cache hit rates by better
2177- // bucketing similar requests and to help OpenAI detect and prevent abuse.
2178- // [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
2300+ // Used by OpenAI to cache responses for similar requests to optimize your cache
2301+ // hit rates. Replaces the `user` field.
2302+ // [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
2303+ PromptCacheKey param.Opt [string ] `json:"prompt_cache_key,omitzero"`
2304+ // A stable identifier used to help detect users of your application that may be
2305+ // violating OpenAI's usage policies. The IDs should be a string that uniquely
2306+ // identifies each user. We recommend hashing their username or email address, in
2307+ // order to avoid sending us any identifying information.
2308+ // [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
2309+ SafetyIdentifier param.Opt [string ] `json:"safety_identifier,omitzero"`
2310+ // This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
2311+ // `prompt_cache_key` instead to maintain caching optimizations. A stable
2312+ // identifier for your end-users. Used to boost cache hit rates by better bucketing
2313+ // similar requests and to help OpenAI detect and prevent abuse.
2314+ // [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
21792315 User param.Opt [string ] `json:"user,omitzero"`
21802316 // Parameters for audio output. Required when audio output is requested with
21812317 // `modalities: ["audio"]`.
0 commit comments