@@ -6,7 +6,8 @@ import * as ModerationsAPI from './moderations';
66
77export class Moderations extends APIResource {
88 /**
9- * Classifies if text is potentially harmful.
9+ * Classifies if text and/or image inputs are potentially harmful. Learn more in
10+ * the [moderation guide](https://platform.openai.com/docs/guides/moderation).
1011 */
1112 create (
1213 body : ModerationCreateParams ,
@@ -22,6 +23,11 @@ export interface Moderation {
2223 */
2324 categories : Moderation . Categories ;
2425
26+ /**
27+ * A list of the categories along with the input type(s) that the score applies to.
28+ */
29+ category_applied_input_types : Moderation . CategoryAppliedInputTypes ;
30+
2531 /**
2632 * A list of the categories along with their scores as predicted by model.
2733 */
@@ -65,6 +71,20 @@ export namespace Moderation {
6571 */
6672 'hate/threatening' : boolean ;
6773
74+ /**
75+ * Content that includes instructions or advice that facilitate the planning or
76+ * execution of wrongdoing, or that gives advice or instruction on how to commit
77+ * illicit acts. For example, "how to shoplift" would fit this category.
78+ */
79+ illicit : boolean ;
80+
81+ /**
82+ * Content that includes instructions or advice that facilitate the planning or
83+ * execution of wrongdoing that also includes violence, or that gives advice or
84+ * instruction on the procurement of any weapon.
85+ */
86+ 'illicit/violent' : boolean ;
87+
6888 /**
6989 * Content that promotes, encourages, or depicts acts of self-harm, such as
7090 * suicide, cutting, and eating disorders.
@@ -107,6 +127,76 @@ export namespace Moderation {
107127 'violence/graphic' : boolean ;
108128 }
109129
130+ /**
131+ * A list of the categories along with the input type(s) that the score applies to.
132+ */
133+ export interface CategoryAppliedInputTypes {
134+ /**
135+ * The applied input type(s) for the category 'harassment'.
136+ */
137+ harassment : Array < 'text' > ;
138+
139+ /**
140+ * The applied input type(s) for the category 'harassment/threatening'.
141+ */
142+ 'harassment/threatening' : Array < 'text' > ;
143+
144+ /**
145+ * The applied input type(s) for the category 'hate'.
146+ */
147+ hate : Array < 'text' > ;
148+
149+ /**
150+ * The applied input type(s) for the category 'hate/threatening'.
151+ */
152+ 'hate/threatening' : Array < 'text' > ;
153+
154+ /**
155+ * The applied input type(s) for the category 'illicit'.
156+ */
157+ illicit : Array < 'text' > ;
158+
159+ /**
160+ * The applied input type(s) for the category 'illicit/violent'.
161+ */
162+ 'illicit/violent' : Array < 'text' > ;
163+
164+ /**
165+ * The applied input type(s) for the category 'self-harm'.
166+ */
167+ 'self-harm' : Array < 'text' | 'image' > ;
168+
169+ /**
170+ * The applied input type(s) for the category 'self-harm/instructions'.
171+ */
172+ 'self-harm/instructions' : Array < 'text' | 'image' > ;
173+
174+ /**
175+ * The applied input type(s) for the category 'self-harm/intent'.
176+ */
177+ 'self-harm/intent' : Array < 'text' | 'image' > ;
178+
179+ /**
180+ * The applied input type(s) for the category 'sexual'.
181+ */
182+ sexual : Array < 'text' | 'image' > ;
183+
184+ /**
185+ * The applied input type(s) for the category 'sexual/minors'.
186+ */
187+ 'sexual/minors' : Array < 'text' > ;
188+
189+ /**
190+ * The applied input type(s) for the category 'violence'.
191+ */
192+ violence : Array < 'text' | 'image' > ;
193+
194+ /**
195+ * The applied input type(s) for the category 'violence/graphic'.
196+ */
197+ 'violence/graphic' : Array < 'text' | 'image' > ;
198+ }
199+
110200 /**
111201 * A list of the categories along with their scores as predicted by model.
112202 */
@@ -131,6 +221,16 @@ export namespace Moderation {
131221 */
132222 'hate/threatening' : number ;
133223
224+ /**
225+ * The score for the category 'illicit'.
226+ */
227+ illicit : number ;
228+
229+ /**
230+ * The score for the category 'illicit/violent'.
231+ */
232+ 'illicit/violent' : number ;
233+
134234 /**
135235 * The score for the category 'self-harm'.
136236 */
@@ -168,7 +268,58 @@ export namespace Moderation {
168268 }
169269}
170270
171- export type ModerationModel = 'text-moderation-latest' | 'text-moderation-stable' ;
271+ /**
272+ * An object describing an image to classify.
273+ */
274+ export interface ModerationImageURLInput {
275+ /**
276+ * Contains either an image URL or a data URL for a base64 encoded image.
277+ */
278+ image_url : ModerationImageURLInput . ImageURL ;
279+
280+ /**
281+ * Always `image_url`.
282+ */
283+ type : 'image_url' ;
284+ }
285+
286+ export namespace ModerationImageURLInput {
287+ /**
288+ * Contains either an image URL or a data URL for a base64 encoded image.
289+ */
290+ export interface ImageURL {
291+ /**
292+ * Either a URL of the image or the base64 encoded image data.
293+ */
294+ url : string ;
295+ }
296+ }
297+
298+ export type ModerationModel =
299+ | 'omni-moderation-latest'
300+ | 'omni-moderation-2024-09-26'
301+ | 'text-moderation-latest'
302+ | 'text-moderation-stable' ;
303+
304+ /**
305+ * An object describing an image to classify.
306+ */
307+ export type ModerationMultiModalInput = ModerationImageURLInput | ModerationTextInput ;
308+
309+ /**
310+ * An object describing text to classify.
311+ */
312+ export interface ModerationTextInput {
313+ /**
314+ * A string of text to classify.
315+ */
316+ text : string ;
317+
318+ /**
319+ * Always `text`.
320+ */
321+ type : 'text' ;
322+ }
172323
173324/**
174325 * Represents if a given text input is potentially harmful.
@@ -192,26 +343,26 @@ export interface ModerationCreateResponse {
192343
193344export interface ModerationCreateParams {
194345 /**
195- * The input text to classify
346+ * Input (or inputs) to classify. Can be a single string, an array of strings, or
347+ * an array of multi-modal input objects similar to other models.
196348 */
197- input : string | Array < string > ;
349+ input : string | Array < string > | Array < ModerationMultiModalInput > ;
198350
199351 /**
200- * Two content moderations models are available: `text-moderation-stable` and
201- * `text-moderation-latest`.
202- *
203- * The default is `text-moderation-latest` which will be automatically upgraded
204- * over time. This ensures you are always using our most accurate model. If you use
205- * `text-moderation-stable`, we will provide advanced notice before updating the
206- * model. Accuracy of `text-moderation-stable` may be slightly lower than for
207- * `text-moderation-latest`.
352+ * The content moderation model you would like to use. Learn more in
353+ * [the moderation guide](https://platform.openai.com/docs/guides/moderation), and
354+ * learn about available models
355+ * [here](https://platform.openai.com/docs/models/moderation).
208356 */
209357 model ?: ( string & { } ) | ModerationModel ;
210358}
211359
212360export namespace Moderations {
213361 export import Moderation = ModerationsAPI . Moderation ;
362+ export import ModerationImageURLInput = ModerationsAPI . ModerationImageURLInput ;
214363 export import ModerationModel = ModerationsAPI . ModerationModel ;
364+ export import ModerationMultiModalInput = ModerationsAPI . ModerationMultiModalInput ;
365+ export import ModerationTextInput = ModerationsAPI . ModerationTextInput ;
215366 export import ModerationCreateResponse = ModerationsAPI . ModerationCreateResponse ;
216367 export import ModerationCreateParams = ModerationsAPI . ModerationCreateParams ;
217368}
0 commit comments