java/resources/moderations/methods/create/index.md +0 −398 deleted
File Deleted View Diff
1## Create moderation
2
3`ModerationCreateResponse moderations().create(ModerationCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`
4
5**post** `/moderations`
6
7Classifies if text and/or image inputs are potentially harmful. Learn
8more in the [moderation guide](https://platform.openai.com/docs/guides/moderation).
9
10### Parameters
11
12- `ModerationCreateParams params`
13
14 - `Input input`
15
16 Input (or inputs) to classify. Can be a single string, an array of strings, or
17 an array of multi-modal input objects similar to other models.
18
19 - `String`
20
21 - `List<String>`
22
23 - `List<ModerationMultiModalInput>`
24
25 - `class ModerationImageUrlInput:`
26
27 An object describing an image to classify.
28
29 - `ImageUrl imageUrl`
30
31 Contains either an image URL or a data URL for a base64 encoded image.
32
33 - `String url`
34
35 Either a URL of the image or the base64 encoded image data.
36
37 - `JsonValue; type "image_url"constant`
38
39 Always `image_url`.
40
41 - `IMAGE_URL("image_url")`
42
43 - `class ModerationTextInput:`
44
45 An object describing text to classify.
46
47 - `String text`
48
49 A string of text to classify.
50
51 - `JsonValue; type "text"constant`
52
53 Always `text`.
54
55 - `TEXT("text")`
56
57 - `Optional<ModerationModel> model`
58
59 The content moderation model you would like to use. Learn more in
60 [the moderation guide](https://platform.openai.com/docs/guides/moderation), and learn about
61 available models [here](https://platform.openai.com/docs/models#moderation).
62
63### Returns
64
65- `class ModerationCreateResponse:`
66
67 Represents if a given text input is potentially harmful.
68
69 - `String id`
70
71 The unique identifier for the moderation request.
72
73 - `String model`
74
75 The model used to generate the moderation results.
76
77 - `List<Moderation> results`
78
79 A list of moderation objects.
80
81 - `Categories categories`
82
83 A list of the categories, and whether they are flagged or not.
84
85 - `boolean harassment`
86
87 Content that expresses, incites, or promotes harassing language towards any target.
88
89 - `boolean harassmentThreatening`
90
91 Harassment content that also includes violence or serious harm towards any target.
92
93 - `boolean hate`
94
95 Content that expresses, incites, or promotes hate based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste. Hateful content aimed at non-protected groups (e.g., chess players) is harassment.
96
97 - `boolean hateThreatening`
98
99 Hateful content that also includes violence or serious harm towards the targeted group based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste.
100
101 - `Optional<Boolean> illicit`
102
103 Content that includes instructions or advice that facilitate the planning or execution of wrongdoing, or that gives advice or instruction on how to commit illicit acts. For example, "how to shoplift" would fit this category.
104
105 - `Optional<Boolean> illicitViolent`
106
107 Content that includes instructions or advice that facilitate the planning or execution of wrongdoing that also includes violence, or that gives advice or instruction on the procurement of any weapon.
108
109 - `boolean selfHarm`
110
111 Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders.
112
113 - `boolean selfHarmInstructions`
114
115 Content that encourages performing acts of self-harm, such as suicide, cutting, and eating disorders, or that gives instructions or advice on how to commit such acts.
116
117 - `boolean selfHarmIntent`
118
119 Content where the speaker expresses that they are engaging or intend to engage in acts of self-harm, such as suicide, cutting, and eating disorders.
120
121 - `boolean sexual`
122
123 Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness).
124
125 - `boolean sexualMinors`
126
127 Sexual content that includes an individual who is under 18 years old.
128
129 - `boolean violence`
130
131 Content that depicts death, violence, or physical injury.
132
133 - `boolean violenceGraphic`
134
135 Content that depicts death, violence, or physical injury in graphic detail.
136
137 - `CategoryAppliedInputTypes categoryAppliedInputTypes`
138
139 A list of the categories along with the input type(s) that the score applies to.
140
141 - `List<Harassment> harassment`
142
143 The applied input type(s) for the category 'harassment'.
144
145 - `TEXT("text")`
146
147 - `List<HarassmentThreatening> harassmentThreatening`
148
149 The applied input type(s) for the category 'harassment/threatening'.
150
151 - `TEXT("text")`
152
153 - `List<Hate> hate`
154
155 The applied input type(s) for the category 'hate'.
156
157 - `TEXT("text")`
158
159 - `List<HateThreatening> hateThreatening`
160
161 The applied input type(s) for the category 'hate/threatening'.
162
163 - `TEXT("text")`
164
165 - `List<Illicit> illicit`
166
167 The applied input type(s) for the category 'illicit'.
168
169 - `TEXT("text")`
170
171 - `List<IllicitViolent> illicitViolent`
172
173 The applied input type(s) for the category 'illicit/violent'.
174
175 - `TEXT("text")`
176
177 - `List<SelfHarm> selfHarm`
178
179 The applied input type(s) for the category 'self-harm'.
180
181 - `TEXT("text")`
182
183 - `IMAGE("image")`
184
185 - `List<SelfHarmInstruction> selfHarmInstructions`
186
187 The applied input type(s) for the category 'self-harm/instructions'.
188
189 - `TEXT("text")`
190
191 - `IMAGE("image")`
192
193 - `List<SelfHarmIntent> selfHarmIntent`
194
195 The applied input type(s) for the category 'self-harm/intent'.
196
197 - `TEXT("text")`
198
199 - `IMAGE("image")`
200
201 - `List<Sexual> sexual`
202
203 The applied input type(s) for the category 'sexual'.
204
205 - `TEXT("text")`
206
207 - `IMAGE("image")`
208
209 - `List<SexualMinor> sexualMinors`
210
211 The applied input type(s) for the category 'sexual/minors'.
212
213 - `TEXT("text")`
214
215 - `List<Violence> violence`
216
217 The applied input type(s) for the category 'violence'.
218
219 - `TEXT("text")`
220
221 - `IMAGE("image")`
222
223 - `List<ViolenceGraphic> violenceGraphic`
224
225 The applied input type(s) for the category 'violence/graphic'.
226
227 - `TEXT("text")`
228
229 - `IMAGE("image")`
230
231 - `CategoryScores categoryScores`
232
233 A list of the categories along with their scores as predicted by model.
234
235 - `double harassment`
236
237 The score for the category 'harassment'.
238
239 - `double harassmentThreatening`
240
241 The score for the category 'harassment/threatening'.
242
243 - `double hate`
244
245 The score for the category 'hate'.
246
247 - `double hateThreatening`
248
249 The score for the category 'hate/threatening'.
250
251 - `double illicit`
252
253 The score for the category 'illicit'.
254
255 - `double illicitViolent`
256
257 The score for the category 'illicit/violent'.
258
259 - `double selfHarm`
260
261 The score for the category 'self-harm'.
262
263 - `double selfHarmInstructions`
264
265 The score for the category 'self-harm/instructions'.
266
267 - `double selfHarmIntent`
268
269 The score for the category 'self-harm/intent'.
270
271 - `double sexual`
272
273 The score for the category 'sexual'.
274
275 - `double sexualMinors`
276
277 The score for the category 'sexual/minors'.
278
279 - `double violence`
280
281 The score for the category 'violence'.
282
283 - `double violenceGraphic`
284
285 The score for the category 'violence/graphic'.
286
287 - `boolean flagged`
288
289 Whether any of the below categories are flagged.
290
291### Example
292
293```java
294package com.openai.example;
295
296import com.openai.client.OpenAIClient;
297import com.openai.client.okhttp.OpenAIOkHttpClient;
298import com.openai.models.moderations.ModerationCreateParams;
299import com.openai.models.moderations.ModerationCreateResponse;
300
301public final class Main {
302 private Main() {}
303
304 public static void main(String[] args) {
305 OpenAIClient client = OpenAIOkHttpClient.fromEnv();
306
307 ModerationCreateParams params = ModerationCreateParams.builder()
308 .input("I want to kill them.")
309 .build();
310 ModerationCreateResponse moderation = client.moderations().create(params);
311 }
312}
313```
314
315#### Response
316
317```json
318{
319 "id": "id",
320 "model": "model",
321 "results": [
322 {
323 "categories": {
324 "harassment": true,
325 "harassment/threatening": true,
326 "hate": true,
327 "hate/threatening": true,
328 "illicit": true,
329 "illicit/violent": true,
330 "self-harm": true,
331 "self-harm/instructions": true,
332 "self-harm/intent": true,
333 "sexual": true,
334 "sexual/minors": true,
335 "violence": true,
336 "violence/graphic": true
337 },
338 "category_applied_input_types": {
339 "harassment": [
340 "text"
341 ],
342 "harassment/threatening": [
343 "text"
344 ],
345 "hate": [
346 "text"
347 ],
348 "hate/threatening": [
349 "text"
350 ],
351 "illicit": [
352 "text"
353 ],
354 "illicit/violent": [
355 "text"
356 ],
357 "self-harm": [
358 "text"
359 ],
360 "self-harm/instructions": [
361 "text"
362 ],
363 "self-harm/intent": [
364 "text"
365 ],
366 "sexual": [
367 "text"
368 ],
369 "sexual/minors": [
370 "text"
371 ],
372 "violence": [
373 "text"
374 ],
375 "violence/graphic": [
376 "text"
377 ]
378 },
379 "category_scores": {
380 "harassment": 0,
381 "harassment/threatening": 0,
382 "hate": 0,
383 "hate/threatening": 0,
384 "illicit": 0,
385 "illicit/violent": 0,
386 "self-harm": 0,
387 "self-harm/instructions": 0,
388 "self-harm/intent": 0,
389 "sexual": 0,
390 "sexual/minors": 0,
391 "violence": 0,
392 "violence/graphic": 0
393 },
394 "flagged": true
395 }
396 ]
397}
398```