java/resources/moderations/methods/create/index.md +0 −406 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 - `OMNI_MODERATION_LATEST("omni-moderation-latest")`
64
65 - `OMNI_MODERATION_2024_09_26("omni-moderation-2024-09-26")`
66
67 - `TEXT_MODERATION_LATEST("text-moderation-latest")`
68
69 - `TEXT_MODERATION_STABLE("text-moderation-stable")`
70
71### Returns
72
73- `class ModerationCreateResponse:`
74
75 Represents if a given text input is potentially harmful.
76
77 - `String id`
78
79 The unique identifier for the moderation request.
80
81 - `String model`
82
83 The model used to generate the moderation results.
84
85 - `List<Moderation> results`
86
87 A list of moderation objects.
88
89 - `Categories categories`
90
91 A list of the categories, and whether they are flagged or not.
92
93 - `boolean harassment`
94
95 Content that expresses, incites, or promotes harassing language towards any target.
96
97 - `boolean harassmentThreatening`
98
99 Harassment content that also includes violence or serious harm towards any target.
100
101 - `boolean hate`
102
103 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.
104
105 - `boolean hateThreatening`
106
107 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.
108
109 - `Optional<Boolean> illicit`
110
111 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.
112
113 - `Optional<Boolean> illicitViolent`
114
115 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.
116
117 - `boolean selfHarm`
118
119 Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders.
120
121 - `boolean selfHarmInstructions`
122
123 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.
124
125 - `boolean selfHarmIntent`
126
127 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.
128
129 - `boolean sexual`
130
131 Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness).
132
133 - `boolean sexualMinors`
134
135 Sexual content that includes an individual who is under 18 years old.
136
137 - `boolean violence`
138
139 Content that depicts death, violence, or physical injury.
140
141 - `boolean violenceGraphic`
142
143 Content that depicts death, violence, or physical injury in graphic detail.
144
145 - `CategoryAppliedInputTypes categoryAppliedInputTypes`
146
147 A list of the categories along with the input type(s) that the score applies to.
148
149 - `List<Harassment> harassment`
150
151 The applied input type(s) for the category 'harassment'.
152
153 - `TEXT("text")`
154
155 - `List<HarassmentThreatening> harassmentThreatening`
156
157 The applied input type(s) for the category 'harassment/threatening'.
158
159 - `TEXT("text")`
160
161 - `List<Hate> hate`
162
163 The applied input type(s) for the category 'hate'.
164
165 - `TEXT("text")`
166
167 - `List<HateThreatening> hateThreatening`
168
169 The applied input type(s) for the category 'hate/threatening'.
170
171 - `TEXT("text")`
172
173 - `List<Illicit> illicit`
174
175 The applied input type(s) for the category 'illicit'.
176
177 - `TEXT("text")`
178
179 - `List<IllicitViolent> illicitViolent`
180
181 The applied input type(s) for the category 'illicit/violent'.
182
183 - `TEXT("text")`
184
185 - `List<SelfHarm> selfHarm`
186
187 The applied input type(s) for the category 'self-harm'.
188
189 - `TEXT("text")`
190
191 - `IMAGE("image")`
192
193 - `List<SelfHarmInstruction> selfHarmInstructions`
194
195 The applied input type(s) for the category 'self-harm/instructions'.
196
197 - `TEXT("text")`
198
199 - `IMAGE("image")`
200
201 - `List<SelfHarmIntent> selfHarmIntent`
202
203 The applied input type(s) for the category 'self-harm/intent'.
204
205 - `TEXT("text")`
206
207 - `IMAGE("image")`
208
209 - `List<Sexual> sexual`
210
211 The applied input type(s) for the category 'sexual'.
212
213 - `TEXT("text")`
214
215 - `IMAGE("image")`
216
217 - `List<SexualMinor> sexualMinors`
218
219 The applied input type(s) for the category 'sexual/minors'.
220
221 - `TEXT("text")`
222
223 - `List<Violence> violence`
224
225 The applied input type(s) for the category 'violence'.
226
227 - `TEXT("text")`
228
229 - `IMAGE("image")`
230
231 - `List<ViolenceGraphic> violenceGraphic`
232
233 The applied input type(s) for the category 'violence/graphic'.
234
235 - `TEXT("text")`
236
237 - `IMAGE("image")`
238
239 - `CategoryScores categoryScores`
240
241 A list of the categories along with their scores as predicted by model.
242
243 - `double harassment`
244
245 The score for the category 'harassment'.
246
247 - `double harassmentThreatening`
248
249 The score for the category 'harassment/threatening'.
250
251 - `double hate`
252
253 The score for the category 'hate'.
254
255 - `double hateThreatening`
256
257 The score for the category 'hate/threatening'.
258
259 - `double illicit`
260
261 The score for the category 'illicit'.
262
263 - `double illicitViolent`
264
265 The score for the category 'illicit/violent'.
266
267 - `double selfHarm`
268
269 The score for the category 'self-harm'.
270
271 - `double selfHarmInstructions`
272
273 The score for the category 'self-harm/instructions'.
274
275 - `double selfHarmIntent`
276
277 The score for the category 'self-harm/intent'.
278
279 - `double sexual`
280
281 The score for the category 'sexual'.
282
283 - `double sexualMinors`
284
285 The score for the category 'sexual/minors'.
286
287 - `double violence`
288
289 The score for the category 'violence'.
290
291 - `double violenceGraphic`
292
293 The score for the category 'violence/graphic'.
294
295 - `boolean flagged`
296
297 Whether any of the below categories are flagged.
298
299### Example
300
301```java
302package com.openai.example;
303
304import com.openai.client.OpenAIClient;
305import com.openai.client.okhttp.OpenAIOkHttpClient;
306import com.openai.models.moderations.ModerationCreateParams;
307import com.openai.models.moderations.ModerationCreateResponse;
308
309public final class Main {
310 private Main() {}
311
312 public static void main(String[] args) {
313 OpenAIClient client = OpenAIOkHttpClient.fromEnv();
314
315 ModerationCreateParams params = ModerationCreateParams.builder()
316 .input("I want to kill them.")
317 .build();
318 ModerationCreateResponse moderation = client.moderations().create(params);
319 }
320}
321```
322
323#### Response
324
325```json
326{
327 "id": "id",
328 "model": "model",
329 "results": [
330 {
331 "categories": {
332 "harassment": true,
333 "harassment/threatening": true,
334 "hate": true,
335 "hate/threatening": true,
336 "illicit": true,
337 "illicit/violent": true,
338 "self-harm": true,
339 "self-harm/instructions": true,
340 "self-harm/intent": true,
341 "sexual": true,
342 "sexual/minors": true,
343 "violence": true,
344 "violence/graphic": true
345 },
346 "category_applied_input_types": {
347 "harassment": [
348 "text"
349 ],
350 "harassment/threatening": [
351 "text"
352 ],
353 "hate": [
354 "text"
355 ],
356 "hate/threatening": [
357 "text"
358 ],
359 "illicit": [
360 "text"
361 ],
362 "illicit/violent": [
363 "text"
364 ],
365 "self-harm": [
366 "text"
367 ],
368 "self-harm/instructions": [
369 "text"
370 ],
371 "self-harm/intent": [
372 "text"
373 ],
374 "sexual": [
375 "text"
376 ],
377 "sexual/minors": [
378 "text"
379 ],
380 "violence": [
381 "text"
382 ],
383 "violence/graphic": [
384 "text"
385 ]
386 },
387 "category_scores": {
388 "harassment": 0,
389 "harassment/threatening": 0,
390 "hate": 0,
391 "hate/threatening": 0,
392 "illicit": 0,
393 "illicit/violent": 0,
394 "self-harm": 0,
395 "self-harm/instructions": 0,
396 "self-harm/intent": 0,
397 "sexual": 0,
398 "sexual/minors": 0,
399 "violence": 0,
400 "violence/graphic": 0
401 },
402 "flagged": true
403 }
404 ]
405}
406```