openai 0.64.0 → 0.66.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/README.md +1 -1
  4. data/lib/openai/models/admin/organization/audit_log_list_params.rb +6 -0
  5. data/lib/openai/models/admin/organization/audit_log_list_response.rb +231 -1
  6. data/lib/openai/models/chat/chat_completion.rb +341 -3
  7. data/lib/openai/models/chat/chat_completion_chunk.rb +341 -1
  8. data/lib/openai/models/chat/completion_create_params.rb +42 -1
  9. data/lib/openai/models/conversations/conversation_create_params.rb +2 -2
  10. data/lib/openai/models/conversations/conversation_item.rb +57 -1
  11. data/lib/openai/models/conversations/conversation_item_list.rb +2 -2
  12. data/lib/openai/models/conversations/item_create_params.rb +2 -2
  13. data/lib/openai/models/responses/compacted_response.rb +2 -2
  14. data/lib/openai/models/responses/input_token_count_params.rb +41 -4
  15. data/lib/openai/models/responses/response.rb +296 -6
  16. data/lib/openai/models/responses/response_compact_params.rb +3 -3
  17. data/lib/openai/models/responses/response_create_params.rb +45 -4
  18. data/lib/openai/models/responses/response_function_web_search.rb +11 -9
  19. data/lib/openai/models/responses/response_input_item.rb +38 -1
  20. data/lib/openai/models/responses/response_item.rb +57 -1
  21. data/lib/openai/models/responses/response_item_list.rb +2 -2
  22. data/lib/openai/models/responses/response_output_item.rb +57 -1
  23. data/lib/openai/models/responses/response_output_item_added_event.rb +2 -2
  24. data/lib/openai/models/responses/response_output_item_done_event.rb +2 -2
  25. data/lib/openai/models/responses/responses_client_event.rb +46 -4
  26. data/lib/openai/resources/chat/completions.rb +6 -2
  27. data/lib/openai/resources/conversations/items.rb +3 -3
  28. data/lib/openai/resources/conversations.rb +1 -1
  29. data/lib/openai/resources/responses/input_items.rb +1 -1
  30. data/lib/openai/resources/responses/input_tokens.rb +4 -2
  31. data/lib/openai/resources/responses.rb +9 -5
  32. data/lib/openai/version.rb +1 -1
  33. data/rbi/openai/models/admin/organization/audit_log_list_params.rbi +30 -0
  34. data/rbi/openai/models/admin/organization/audit_log_list_response.rbi +489 -3
  35. data/rbi/openai/models/chat/chat_completion.rbi +620 -3
  36. data/rbi/openai/models/chat/chat_completion_chunk.rbi +621 -0
  37. data/rbi/openai/models/chat/completion_create_params.rbi +76 -0
  38. data/rbi/openai/models/conversations/conversation_create_params.rbi +3 -0
  39. data/rbi/openai/models/conversations/conversation_item.rbi +150 -0
  40. data/rbi/openai/models/conversations/conversation_item_list.rbi +1 -0
  41. data/rbi/openai/models/conversations/item_create_params.rbi +3 -0
  42. data/rbi/openai/models/responses/compacted_response.rbi +1 -0
  43. data/rbi/openai/models/responses/input_token_count_params.rbi +85 -0
  44. data/rbi/openai/models/responses/response.rbi +510 -0
  45. data/rbi/openai/models/responses/response_create_params.rbi +78 -0
  46. data/rbi/openai/models/responses/response_function_web_search.rbi +11 -8
  47. data/rbi/openai/models/responses/response_input_item.rbi +120 -0
  48. data/rbi/openai/models/responses/response_item.rbi +150 -0
  49. data/rbi/openai/models/responses/response_item_list.rbi +1 -0
  50. data/rbi/openai/models/responses/response_output_item.rbi +150 -0
  51. data/rbi/openai/models/responses/response_output_item_added_event.rbi +1 -0
  52. data/rbi/openai/models/responses/response_output_item_done_event.rbi +1 -0
  53. data/rbi/openai/models/responses/responses_client_event.rbi +78 -0
  54. data/rbi/openai/resources/chat/completions.rbi +28 -0
  55. data/rbi/openai/resources/conversations/items.rbi +1 -0
  56. data/rbi/openai/resources/conversations.rbi +1 -0
  57. data/rbi/openai/resources/responses/input_tokens.rbi +9 -0
  58. data/rbi/openai/resources/responses.rbi +28 -0
  59. data/sig/openai/models/admin/organization/audit_log_list_params.rbs +12 -0
  60. data/sig/openai/models/admin/organization/audit_log_list_response.rbs +216 -3
  61. data/sig/openai/models/chat/chat_completion.rbs +243 -0
  62. data/sig/openai/models/chat/chat_completion_chunk.rbs +243 -0
  63. data/sig/openai/models/chat/completion_create_params.rbs +15 -0
  64. data/sig/openai/models/conversations/conversation_item.rbs +58 -0
  65. data/sig/openai/models/responses/input_token_count_params.rbs +20 -0
  66. data/sig/openai/models/responses/response.rbs +189 -0
  67. data/sig/openai/models/responses/response_create_params.rbs +15 -0
  68. data/sig/openai/models/responses/response_function_web_search.rbs +7 -5
  69. data/sig/openai/models/responses/response_input_item.rbs +33 -0
  70. data/sig/openai/models/responses/response_item.rbs +58 -0
  71. data/sig/openai/models/responses/response_output_item.rbs +58 -0
  72. data/sig/openai/models/responses/responses_client_event.rbs +15 -0
  73. data/sig/openai/resources/chat/completions.rbs +2 -0
  74. data/sig/openai/resources/responses/input_tokens.rbs +1 -0
  75. data/sig/openai/resources/responses.rbs +2 -0
  76. metadata +2 -2
@@ -170,6 +170,19 @@ module OpenAI
170
170
  sig { returns(T.nilable(Integer)) }
171
171
  attr_accessor :max_tool_calls
172
172
 
173
+ # Moderation results for the response input and output, if moderated completions
174
+ # were requested.
175
+ sig { returns(T.nilable(OpenAI::Responses::Response::Moderation)) }
176
+ attr_reader :moderation
177
+
178
+ sig do
179
+ params(
180
+ moderation:
181
+ T.nilable(OpenAI::Responses::Response::Moderation::OrHash)
182
+ ).void
183
+ end
184
+ attr_writer :moderation
185
+
173
186
  # The unique ID of the previous response to the model. Use this to create
174
187
  # multi-turn conversations. Learn more about
175
188
  # [conversation state](https://platform.openai.com/docs/guides/conversation-state).
@@ -202,6 +215,14 @@ module OpenAI
202
215
  # prompt caching, which keeps cached prefixes active for longer, up to a maximum
203
216
  # of 24 hours.
204
217
  # [Learn more](https://platform.openai.com/docs/guides/prompt-caching#prompt-cache-retention).
218
+ # For `gpt-5.5`, `gpt-5.5-pro`, and future models, only `24h` is supported.
219
+ #
220
+ # For older models that support both `in_memory` and `24h`, the default depends on
221
+ # your organization's data retention policy:
222
+ #
223
+ # - Organizations without ZDR enabled default to `24h`.
224
+ # - Organizations with ZDR enabled default to `in_memory` when
225
+ # `prompt_cache_retention` is not specified.
205
226
  sig do
206
227
  returns(
207
228
  T.nilable(
@@ -345,6 +366,7 @@ module OpenAI
345
366
  OpenAI::Responses::ResponseReasoningItem::OrHash,
346
367
  OpenAI::Responses::ResponseToolSearchCall::OrHash,
347
368
  OpenAI::Responses::ResponseToolSearchOutputItem::OrHash,
369
+ OpenAI::Responses::ResponseOutputItem::AdditionalTools::OrHash,
348
370
  OpenAI::Responses::ResponseCompactionItem::OrHash,
349
371
  OpenAI::Responses::ResponseOutputItem::ImageGenerationCall::OrHash,
350
372
  OpenAI::Responses::ResponseCodeInterpreterToolCall::OrHash,
@@ -402,6 +424,8 @@ module OpenAI
402
424
  T.nilable(OpenAI::Responses::Response::Conversation::OrHash),
403
425
  max_output_tokens: T.nilable(Integer),
404
426
  max_tool_calls: T.nilable(Integer),
427
+ moderation:
428
+ T.nilable(OpenAI::Responses::Response::Moderation::OrHash),
405
429
  previous_response_id: T.nilable(String),
406
430
  prompt: T.nilable(OpenAI::Responses::ResponsePrompt::OrHash),
407
431
  prompt_cache_key: String,
@@ -514,6 +538,9 @@ module OpenAI
514
538
  # individual tool. Any further attempts to call a tool by the model will be
515
539
  # ignored.
516
540
  max_tool_calls: nil,
541
+ # Moderation results for the response input and output, if moderated completions
542
+ # were requested.
543
+ moderation: nil,
517
544
  # The unique ID of the previous response to the model. Use this to create
518
545
  # multi-turn conversations. Learn more about
519
546
  # [conversation state](https://platform.openai.com/docs/guides/conversation-state).
@@ -530,6 +557,14 @@ module OpenAI
530
557
  # prompt caching, which keeps cached prefixes active for longer, up to a maximum
531
558
  # of 24 hours.
532
559
  # [Learn more](https://platform.openai.com/docs/guides/prompt-caching#prompt-cache-retention).
560
+ # For `gpt-5.5`, `gpt-5.5-pro`, and future models, only `24h` is supported.
561
+ #
562
+ # For older models that support both `in_memory` and `24h`, the default depends on
563
+ # your organization's data retention policy:
564
+ #
565
+ # - Organizations without ZDR enabled default to `24h`.
566
+ # - Organizations with ZDR enabled default to `in_memory` when
567
+ # `prompt_cache_retention` is not specified.
533
568
  prompt_cache_retention: nil,
534
569
  # **gpt-5 and o-series models only**
535
570
  #
@@ -620,6 +655,7 @@ module OpenAI
620
655
  T.nilable(OpenAI::Responses::Response::Conversation),
621
656
  max_output_tokens: T.nilable(Integer),
622
657
  max_tool_calls: T.nilable(Integer),
658
+ moderation: T.nilable(OpenAI::Responses::Response::Moderation),
623
659
  previous_response_id: T.nilable(String),
624
660
  prompt: T.nilable(OpenAI::Responses::ResponsePrompt),
625
661
  prompt_cache_key: String,
@@ -824,10 +860,484 @@ module OpenAI
824
860
  end
825
861
  end
826
862
 
863
+ class Moderation < OpenAI::Internal::Type::BaseModel
864
+ OrHash =
865
+ T.type_alias do
866
+ T.any(
867
+ OpenAI::Responses::Response::Moderation,
868
+ OpenAI::Internal::AnyHash
869
+ )
870
+ end
871
+
872
+ # Moderation for the response input.
873
+ sig do
874
+ returns(OpenAI::Responses::Response::Moderation::Input::Variants)
875
+ end
876
+ attr_accessor :input
877
+
878
+ # Moderation for the response output.
879
+ sig do
880
+ returns(OpenAI::Responses::Response::Moderation::Output::Variants)
881
+ end
882
+ attr_accessor :output
883
+
884
+ # Moderation results for the response input and output, if moderated completions
885
+ # were requested.
886
+ sig do
887
+ params(
888
+ input:
889
+ T.any(
890
+ OpenAI::Responses::Response::Moderation::Input::ModerationResult::OrHash,
891
+ OpenAI::Responses::Response::Moderation::Input::Error::OrHash
892
+ ),
893
+ output:
894
+ T.any(
895
+ OpenAI::Responses::Response::Moderation::Output::ModerationResult::OrHash,
896
+ OpenAI::Responses::Response::Moderation::Output::Error::OrHash
897
+ )
898
+ ).returns(T.attached_class)
899
+ end
900
+ def self.new(
901
+ # Moderation for the response input.
902
+ input:,
903
+ # Moderation for the response output.
904
+ output:
905
+ )
906
+ end
907
+
908
+ sig do
909
+ override.returns(
910
+ {
911
+ input: OpenAI::Responses::Response::Moderation::Input::Variants,
912
+ output:
913
+ OpenAI::Responses::Response::Moderation::Output::Variants
914
+ }
915
+ )
916
+ end
917
+ def to_hash
918
+ end
919
+
920
+ # Moderation for the response input.
921
+ module Input
922
+ extend OpenAI::Internal::Type::Union
923
+
924
+ Variants =
925
+ T.type_alias do
926
+ T.any(
927
+ OpenAI::Responses::Response::Moderation::Input::ModerationResult,
928
+ OpenAI::Responses::Response::Moderation::Input::Error
929
+ )
930
+ end
931
+
932
+ class ModerationResult < OpenAI::Internal::Type::BaseModel
933
+ OrHash =
934
+ T.type_alias do
935
+ T.any(
936
+ OpenAI::Responses::Response::Moderation::Input::ModerationResult,
937
+ OpenAI::Internal::AnyHash
938
+ )
939
+ end
940
+
941
+ # A dictionary of moderation categories to booleans, True if the input is flagged
942
+ # under this category.
943
+ sig { returns(T::Hash[Symbol, T::Boolean]) }
944
+ attr_accessor :categories
945
+
946
+ # Which modalities of input are reflected by the score for each category.
947
+ sig do
948
+ returns(
949
+ T::Hash[
950
+ Symbol,
951
+ T::Array[
952
+ OpenAI::Responses::Response::Moderation::Input::ModerationResult::CategoryAppliedInputType::TaggedSymbol
953
+ ]
954
+ ]
955
+ )
956
+ end
957
+ attr_accessor :category_applied_input_types
958
+
959
+ # A dictionary of moderation categories to scores.
960
+ sig { returns(T::Hash[Symbol, Float]) }
961
+ attr_accessor :category_scores
962
+
963
+ # A boolean indicating whether the content was flagged by any category.
964
+ sig { returns(T::Boolean) }
965
+ attr_accessor :flagged
966
+
967
+ # The moderation model that produced this result.
968
+ sig { returns(String) }
969
+ attr_accessor :model
970
+
971
+ # The object type, which was always `moderation_result` for successful moderation
972
+ # results.
973
+ sig { returns(Symbol) }
974
+ attr_accessor :type
975
+
976
+ # A moderation result produced for the response input or output.
977
+ sig do
978
+ params(
979
+ categories: T::Hash[Symbol, T::Boolean],
980
+ category_applied_input_types:
981
+ T::Hash[
982
+ Symbol,
983
+ T::Array[
984
+ OpenAI::Responses::Response::Moderation::Input::ModerationResult::CategoryAppliedInputType::OrSymbol
985
+ ]
986
+ ],
987
+ category_scores: T::Hash[Symbol, Float],
988
+ flagged: T::Boolean,
989
+ model: String,
990
+ type: Symbol
991
+ ).returns(T.attached_class)
992
+ end
993
+ def self.new(
994
+ # A dictionary of moderation categories to booleans, True if the input is flagged
995
+ # under this category.
996
+ categories:,
997
+ # Which modalities of input are reflected by the score for each category.
998
+ category_applied_input_types:,
999
+ # A dictionary of moderation categories to scores.
1000
+ category_scores:,
1001
+ # A boolean indicating whether the content was flagged by any category.
1002
+ flagged:,
1003
+ # The moderation model that produced this result.
1004
+ model:,
1005
+ # The object type, which was always `moderation_result` for successful moderation
1006
+ # results.
1007
+ type: :moderation_result
1008
+ )
1009
+ end
1010
+
1011
+ sig do
1012
+ override.returns(
1013
+ {
1014
+ categories: T::Hash[Symbol, T::Boolean],
1015
+ category_applied_input_types:
1016
+ T::Hash[
1017
+ Symbol,
1018
+ T::Array[
1019
+ OpenAI::Responses::Response::Moderation::Input::ModerationResult::CategoryAppliedInputType::TaggedSymbol
1020
+ ]
1021
+ ],
1022
+ category_scores: T::Hash[Symbol, Float],
1023
+ flagged: T::Boolean,
1024
+ model: String,
1025
+ type: Symbol
1026
+ }
1027
+ )
1028
+ end
1029
+ def to_hash
1030
+ end
1031
+
1032
+ module CategoryAppliedInputType
1033
+ extend OpenAI::Internal::Type::Enum
1034
+
1035
+ TaggedSymbol =
1036
+ T.type_alias do
1037
+ T.all(
1038
+ Symbol,
1039
+ OpenAI::Responses::Response::Moderation::Input::ModerationResult::CategoryAppliedInputType
1040
+ )
1041
+ end
1042
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
1043
+
1044
+ TEXT =
1045
+ T.let(
1046
+ :text,
1047
+ OpenAI::Responses::Response::Moderation::Input::ModerationResult::CategoryAppliedInputType::TaggedSymbol
1048
+ )
1049
+ IMAGE =
1050
+ T.let(
1051
+ :image,
1052
+ OpenAI::Responses::Response::Moderation::Input::ModerationResult::CategoryAppliedInputType::TaggedSymbol
1053
+ )
1054
+
1055
+ sig do
1056
+ override.returns(
1057
+ T::Array[
1058
+ OpenAI::Responses::Response::Moderation::Input::ModerationResult::CategoryAppliedInputType::TaggedSymbol
1059
+ ]
1060
+ )
1061
+ end
1062
+ def self.values
1063
+ end
1064
+ end
1065
+ end
1066
+
1067
+ class Error < OpenAI::Internal::Type::BaseModel
1068
+ OrHash =
1069
+ T.type_alias do
1070
+ T.any(
1071
+ OpenAI::Responses::Response::Moderation::Input::Error,
1072
+ OpenAI::Internal::AnyHash
1073
+ )
1074
+ end
1075
+
1076
+ # The error code.
1077
+ sig { returns(String) }
1078
+ attr_accessor :code
1079
+
1080
+ # The error message.
1081
+ sig { returns(String) }
1082
+ attr_accessor :message
1083
+
1084
+ # The object type, which was always `error` for moderation failures.
1085
+ sig { returns(Symbol) }
1086
+ attr_accessor :type
1087
+
1088
+ # An error produced while attempting moderation for the response input or output.
1089
+ sig do
1090
+ params(code: String, message: String, type: Symbol).returns(
1091
+ T.attached_class
1092
+ )
1093
+ end
1094
+ def self.new(
1095
+ # The error code.
1096
+ code:,
1097
+ # The error message.
1098
+ message:,
1099
+ # The object type, which was always `error` for moderation failures.
1100
+ type: :error
1101
+ )
1102
+ end
1103
+
1104
+ sig do
1105
+ override.returns(
1106
+ { code: String, message: String, type: Symbol }
1107
+ )
1108
+ end
1109
+ def to_hash
1110
+ end
1111
+ end
1112
+
1113
+ sig do
1114
+ override.returns(
1115
+ T::Array[
1116
+ OpenAI::Responses::Response::Moderation::Input::Variants
1117
+ ]
1118
+ )
1119
+ end
1120
+ def self.variants
1121
+ end
1122
+ end
1123
+
1124
+ # Moderation for the response output.
1125
+ module Output
1126
+ extend OpenAI::Internal::Type::Union
1127
+
1128
+ Variants =
1129
+ T.type_alias do
1130
+ T.any(
1131
+ OpenAI::Responses::Response::Moderation::Output::ModerationResult,
1132
+ OpenAI::Responses::Response::Moderation::Output::Error
1133
+ )
1134
+ end
1135
+
1136
+ class ModerationResult < OpenAI::Internal::Type::BaseModel
1137
+ OrHash =
1138
+ T.type_alias do
1139
+ T.any(
1140
+ OpenAI::Responses::Response::Moderation::Output::ModerationResult,
1141
+ OpenAI::Internal::AnyHash
1142
+ )
1143
+ end
1144
+
1145
+ # A dictionary of moderation categories to booleans, True if the input is flagged
1146
+ # under this category.
1147
+ sig { returns(T::Hash[Symbol, T::Boolean]) }
1148
+ attr_accessor :categories
1149
+
1150
+ # Which modalities of input are reflected by the score for each category.
1151
+ sig do
1152
+ returns(
1153
+ T::Hash[
1154
+ Symbol,
1155
+ T::Array[
1156
+ OpenAI::Responses::Response::Moderation::Output::ModerationResult::CategoryAppliedInputType::TaggedSymbol
1157
+ ]
1158
+ ]
1159
+ )
1160
+ end
1161
+ attr_accessor :category_applied_input_types
1162
+
1163
+ # A dictionary of moderation categories to scores.
1164
+ sig { returns(T::Hash[Symbol, Float]) }
1165
+ attr_accessor :category_scores
1166
+
1167
+ # A boolean indicating whether the content was flagged by any category.
1168
+ sig { returns(T::Boolean) }
1169
+ attr_accessor :flagged
1170
+
1171
+ # The moderation model that produced this result.
1172
+ sig { returns(String) }
1173
+ attr_accessor :model
1174
+
1175
+ # The object type, which was always `moderation_result` for successful moderation
1176
+ # results.
1177
+ sig { returns(Symbol) }
1178
+ attr_accessor :type
1179
+
1180
+ # A moderation result produced for the response input or output.
1181
+ sig do
1182
+ params(
1183
+ categories: T::Hash[Symbol, T::Boolean],
1184
+ category_applied_input_types:
1185
+ T::Hash[
1186
+ Symbol,
1187
+ T::Array[
1188
+ OpenAI::Responses::Response::Moderation::Output::ModerationResult::CategoryAppliedInputType::OrSymbol
1189
+ ]
1190
+ ],
1191
+ category_scores: T::Hash[Symbol, Float],
1192
+ flagged: T::Boolean,
1193
+ model: String,
1194
+ type: Symbol
1195
+ ).returns(T.attached_class)
1196
+ end
1197
+ def self.new(
1198
+ # A dictionary of moderation categories to booleans, True if the input is flagged
1199
+ # under this category.
1200
+ categories:,
1201
+ # Which modalities of input are reflected by the score for each category.
1202
+ category_applied_input_types:,
1203
+ # A dictionary of moderation categories to scores.
1204
+ category_scores:,
1205
+ # A boolean indicating whether the content was flagged by any category.
1206
+ flagged:,
1207
+ # The moderation model that produced this result.
1208
+ model:,
1209
+ # The object type, which was always `moderation_result` for successful moderation
1210
+ # results.
1211
+ type: :moderation_result
1212
+ )
1213
+ end
1214
+
1215
+ sig do
1216
+ override.returns(
1217
+ {
1218
+ categories: T::Hash[Symbol, T::Boolean],
1219
+ category_applied_input_types:
1220
+ T::Hash[
1221
+ Symbol,
1222
+ T::Array[
1223
+ OpenAI::Responses::Response::Moderation::Output::ModerationResult::CategoryAppliedInputType::TaggedSymbol
1224
+ ]
1225
+ ],
1226
+ category_scores: T::Hash[Symbol, Float],
1227
+ flagged: T::Boolean,
1228
+ model: String,
1229
+ type: Symbol
1230
+ }
1231
+ )
1232
+ end
1233
+ def to_hash
1234
+ end
1235
+
1236
+ module CategoryAppliedInputType
1237
+ extend OpenAI::Internal::Type::Enum
1238
+
1239
+ TaggedSymbol =
1240
+ T.type_alias do
1241
+ T.all(
1242
+ Symbol,
1243
+ OpenAI::Responses::Response::Moderation::Output::ModerationResult::CategoryAppliedInputType
1244
+ )
1245
+ end
1246
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
1247
+
1248
+ TEXT =
1249
+ T.let(
1250
+ :text,
1251
+ OpenAI::Responses::Response::Moderation::Output::ModerationResult::CategoryAppliedInputType::TaggedSymbol
1252
+ )
1253
+ IMAGE =
1254
+ T.let(
1255
+ :image,
1256
+ OpenAI::Responses::Response::Moderation::Output::ModerationResult::CategoryAppliedInputType::TaggedSymbol
1257
+ )
1258
+
1259
+ sig do
1260
+ override.returns(
1261
+ T::Array[
1262
+ OpenAI::Responses::Response::Moderation::Output::ModerationResult::CategoryAppliedInputType::TaggedSymbol
1263
+ ]
1264
+ )
1265
+ end
1266
+ def self.values
1267
+ end
1268
+ end
1269
+ end
1270
+
1271
+ class Error < OpenAI::Internal::Type::BaseModel
1272
+ OrHash =
1273
+ T.type_alias do
1274
+ T.any(
1275
+ OpenAI::Responses::Response::Moderation::Output::Error,
1276
+ OpenAI::Internal::AnyHash
1277
+ )
1278
+ end
1279
+
1280
+ # The error code.
1281
+ sig { returns(String) }
1282
+ attr_accessor :code
1283
+
1284
+ # The error message.
1285
+ sig { returns(String) }
1286
+ attr_accessor :message
1287
+
1288
+ # The object type, which was always `error` for moderation failures.
1289
+ sig { returns(Symbol) }
1290
+ attr_accessor :type
1291
+
1292
+ # An error produced while attempting moderation for the response input or output.
1293
+ sig do
1294
+ params(code: String, message: String, type: Symbol).returns(
1295
+ T.attached_class
1296
+ )
1297
+ end
1298
+ def self.new(
1299
+ # The error code.
1300
+ code:,
1301
+ # The error message.
1302
+ message:,
1303
+ # The object type, which was always `error` for moderation failures.
1304
+ type: :error
1305
+ )
1306
+ end
1307
+
1308
+ sig do
1309
+ override.returns(
1310
+ { code: String, message: String, type: Symbol }
1311
+ )
1312
+ end
1313
+ def to_hash
1314
+ end
1315
+ end
1316
+
1317
+ sig do
1318
+ override.returns(
1319
+ T::Array[
1320
+ OpenAI::Responses::Response::Moderation::Output::Variants
1321
+ ]
1322
+ )
1323
+ end
1324
+ def self.variants
1325
+ end
1326
+ end
1327
+ end
1328
+
827
1329
  # The retention policy for the prompt cache. Set to `24h` to enable extended
828
1330
  # prompt caching, which keeps cached prefixes active for longer, up to a maximum
829
1331
  # of 24 hours.
830
1332
  # [Learn more](https://platform.openai.com/docs/guides/prompt-caching#prompt-cache-retention).
1333
+ # For `gpt-5.5`, `gpt-5.5-pro`, and future models, only `24h` is supported.
1334
+ #
1335
+ # For older models that support both `in_memory` and `24h`, the default depends on
1336
+ # your organization's data retention policy:
1337
+ #
1338
+ # - Organizations without ZDR enabled default to `24h`.
1339
+ # - Organizations with ZDR enabled default to `in_memory` when
1340
+ # `prompt_cache_retention` is not specified.
831
1341
  module PromptCacheRetention
832
1342
  extend OpenAI::Internal::Type::Enum
833
1343
 
@@ -153,6 +153,24 @@ module OpenAI
153
153
  end
154
154
  attr_writer :model
155
155
 
156
+ # Configuration for running moderation on the input and output of this response.
157
+ sig do
158
+ returns(
159
+ T.nilable(OpenAI::Responses::ResponseCreateParams::Moderation)
160
+ )
161
+ end
162
+ attr_reader :moderation
163
+
164
+ sig do
165
+ params(
166
+ moderation:
167
+ T.nilable(
168
+ OpenAI::Responses::ResponseCreateParams::Moderation::OrHash
169
+ )
170
+ ).void
171
+ end
172
+ attr_writer :moderation
173
+
156
174
  # Whether to allow the model to run tool calls in parallel.
157
175
  sig { returns(T.nilable(T::Boolean)) }
158
176
  attr_accessor :parallel_tool_calls
@@ -189,6 +207,14 @@ module OpenAI
189
207
  # prompt caching, which keeps cached prefixes active for longer, up to a maximum
190
208
  # of 24 hours.
191
209
  # [Learn more](https://platform.openai.com/docs/guides/prompt-caching#prompt-cache-retention).
210
+ # For `gpt-5.5`, `gpt-5.5-pro`, and future models, only `24h` is supported.
211
+ #
212
+ # For older models that support both `in_memory` and `24h`, the default depends on
213
+ # your organization's data retention policy:
214
+ #
215
+ # - Organizations without ZDR enabled default to `24h`.
216
+ # - Organizations with ZDR enabled default to `in_memory` when
217
+ # `prompt_cache_retention` is not specified.
192
218
  sig do
193
219
  returns(
194
220
  T.nilable(
@@ -475,6 +501,10 @@ module OpenAI
475
501
  OpenAI::ChatModel::OrSymbol,
476
502
  OpenAI::ResponsesModel::ResponsesOnlyModel::OrSymbol
477
503
  ),
504
+ moderation:
505
+ T.nilable(
506
+ OpenAI::Responses::ResponseCreateParams::Moderation::OrHash
507
+ ),
478
508
  parallel_tool_calls: T.nilable(T::Boolean),
479
509
  previous_response_id: T.nilable(String),
480
510
  prompt: T.nilable(OpenAI::Responses::ResponsePrompt::OrHash),
@@ -605,6 +635,8 @@ module OpenAI
605
635
  # [model guide](https://platform.openai.com/docs/models) to browse and compare
606
636
  # available models.
607
637
  model: nil,
638
+ # Configuration for running moderation on the input and output of this response.
639
+ moderation: nil,
608
640
  # Whether to allow the model to run tool calls in parallel.
609
641
  parallel_tool_calls: nil,
610
642
  # The unique ID of the previous response to the model. Use this to create
@@ -623,6 +655,14 @@ module OpenAI
623
655
  # prompt caching, which keeps cached prefixes active for longer, up to a maximum
624
656
  # of 24 hours.
625
657
  # [Learn more](https://platform.openai.com/docs/guides/prompt-caching#prompt-cache-retention).
658
+ # For `gpt-5.5`, `gpt-5.5-pro`, and future models, only `24h` is supported.
659
+ #
660
+ # For older models that support both `in_memory` and `24h`, the default depends on
661
+ # your organization's data retention policy:
662
+ #
663
+ # - Organizations without ZDR enabled default to `24h`.
664
+ # - Organizations with ZDR enabled default to `in_memory` when
665
+ # `prompt_cache_retention` is not specified.
626
666
  prompt_cache_retention: nil,
627
667
  # **gpt-5 and o-series models only**
628
668
  #
@@ -749,6 +789,8 @@ module OpenAI
749
789
  OpenAI::ChatModel::OrSymbol,
750
790
  OpenAI::ResponsesModel::ResponsesOnlyModel::OrSymbol
751
791
  ),
792
+ moderation:
793
+ T.nilable(OpenAI::Responses::ResponseCreateParams::Moderation),
752
794
  parallel_tool_calls: T.nilable(T::Boolean),
753
795
  previous_response_id: T.nilable(String),
754
796
  prompt: T.nilable(OpenAI::Responses::ResponsePrompt),
@@ -906,10 +948,46 @@ module OpenAI
906
948
  end
907
949
  end
908
950
 
951
+ class Moderation < OpenAI::Internal::Type::BaseModel
952
+ OrHash =
953
+ T.type_alias do
954
+ T.any(
955
+ OpenAI::Responses::ResponseCreateParams::Moderation,
956
+ OpenAI::Internal::AnyHash
957
+ )
958
+ end
959
+
960
+ # The moderation model to use for moderated completions, e.g.
961
+ # 'omni-moderation-latest'.
962
+ sig { returns(String) }
963
+ attr_accessor :model
964
+
965
+ # Configuration for running moderation on the input and output of this response.
966
+ sig { params(model: String).returns(T.attached_class) }
967
+ def self.new(
968
+ # The moderation model to use for moderated completions, e.g.
969
+ # 'omni-moderation-latest'.
970
+ model:
971
+ )
972
+ end
973
+
974
+ sig { override.returns({ model: String }) }
975
+ def to_hash
976
+ end
977
+ end
978
+
909
979
  # The retention policy for the prompt cache. Set to `24h` to enable extended
910
980
  # prompt caching, which keeps cached prefixes active for longer, up to a maximum
911
981
  # of 24 hours.
912
982
  # [Learn more](https://platform.openai.com/docs/guides/prompt-caching#prompt-cache-retention).
983
+ # For `gpt-5.5`, `gpt-5.5-pro`, and future models, only `24h` is supported.
984
+ #
985
+ # For older models that support both `in_memory` and `24h`, the default depends on
986
+ # your organization's data retention policy:
987
+ #
988
+ # - Organizations without ZDR enabled default to `24h`.
989
+ # - Organizations with ZDR enabled default to `in_memory` when
990
+ # `prompt_cache_retention` is not specified.
913
991
  module PromptCacheRetention
914
992
  extend OpenAI::Internal::Type::Enum
915
993