Use this file to discover all available pages before exploring further.
The moderations endpoint classifies text against a set of content policy categories and returns a flag indicating whether the content violates policy, along with per-category scores. Use it to screen user-generated content before passing it to a model or storing it.
The moderation model to use. When omitted, the latest stable moderation model is used automatically. Common values include text-moderation-stable and text-moderation-latest.
A map of category names to booleans indicating whether the content was flagged in each category. Common categories include hate, hate/threatening, harassment, self-harm, sexual, sexual/minors, violence, and violence/graphic.
A map of category names to floating-point confidence scores between 0 and 1. Higher scores indicate greater model confidence that the content belongs to that category.
from openai import OpenAIclient = OpenAI( api_key="sk-your-token", base_url="https://YOUR_NEWAPI_BASE_URL/v1",)inputs = [ "I love sunny days at the park.", "How do I make explosives?", "Can you help me write a cover letter?",]response = client.moderations.create(input=inputs)for i, result in enumerate(response.results): status = "FLAGGED" if result.flagged else "OK" print(f"[{status}] Input {i}: {inputs[i][:50]}")