@@ -964,6 +964,59 @@ func (r *ChatCompletionContentPartFileFileParam) UnmarshalJSON(data []byte) erro
964
964
return apijson .UnmarshalRoot (data , r )
965
965
}
966
966
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
+
967
1020
// Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
968
1021
//
969
1022
// The properties ImageURL, Type are required.
@@ -1074,6 +1127,38 @@ func (r *ChatCompletionContentPartRefusalParam) UnmarshalJSON(data []byte) error
1074
1127
return apijson .UnmarshalRoot (data , r )
1075
1128
}
1076
1129
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
+
1077
1162
// Learn about
1078
1163
// [text inputs](https://platform.openai.com/docs/guides/text-generation).
1079
1164
//
@@ -1795,11 +1880,15 @@ func (u *ChatCompletionPredictionContentContentUnionParam) asAny() any {
1795
1880
type ChatCompletionStoreMessage struct {
1796
1881
// The identifier of the chat message.
1797
1882
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"`
1798
1886
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1799
1887
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
1803
1892
} `json:"-"`
1804
1893
ChatCompletionMessage
1805
1894
}
@@ -1810,6 +1899,41 @@ func (r *ChatCompletionStoreMessage) UnmarshalJSON(data []byte) error {
1810
1899
return apijson .UnmarshalRoot (data , r )
1811
1900
}
1812
1901
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
+
1813
1937
// Options for streaming response. Only set this when you set `stream: true`.
1814
1938
type ChatCompletionStreamOptionsParam struct {
1815
1939
// If set, an additional chunk will be streamed before the `data: [DONE]` message.
@@ -2173,9 +2297,21 @@ type ChatCompletionNewParams struct {
2173
2297
// [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling)
2174
2298
// during tool use.
2175
2299
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).
2179
2315
User param.Opt [string ] `json:"user,omitzero"`
2180
2316
// Parameters for audio output. Required when audio output is requested with
2181
2317
// `modalities: ["audio"]`.
0 commit comments