Moderation
Run batch content moderation through OpenAI omni-moderation and Mistral with Batchwork's normalized flagged/category verdicts.
Moderation batches are supported through OpenAI (omni-moderation-latest, text plus image_urls) and Mistral (mistral-moderation-latest, text only). Pass the model as a provider/model string.
CLI
Use batchwork submit moderations to return after registration or batchwork run moderations for the complete lifecycle. JSON, JSONL, CSV, and text sources map to BatchModerationRequest; each request needs a value, image_urls, or both.
batchwork --json run moderations values.txt \
--model openai/omni-moderation-latest
CSV columns are custom_id, value, and image_url (at least one of value/image_url per row). Text input supplies one value per line. There are no modality default flags.
OpenAI
from batchwork import BatchModerationRequest, Batchwork
async with Batchwork() as client:
job = await client.batch_moderations(
model="openai/omni-moderation-latest",
requests=[
BatchModerationRequest(custom_id="comment-1", value="User comment text."),
BatchModerationRequest(
custom_id="upload-1",
image_urls=["https://example.com/upload.png"],
),
],
)
await job.wait(timeout=3600)
verdict = (await job.collect())[0].moderation
OpenAI text-only requests serialize input as the string; requests with image_urls serialize input as a parts list mixing text and image_url entries.
Mistral
job = await client.batch_moderations(
model="mistral/mistral-moderation-latest",
requests=[BatchModerationRequest(custom_id="comment-1", value="User comment text.")],
)
Mistral moderation is text-only: image_urls are rejected locally before upload. Mistral omits a top-level flagged field, so Batchwork computes it as “any category flagged”.
Result shape
result.moderation # BatchModeration | None
A BatchModeration contains flagged, categories (dict[str, bool]), and category_scores (dict[str, float]) with provider-native category names.
Unsupported providers
Anthropic, Azure, Google Gemini, Groq, Together AI, and xAI moderation submissions fail locally.
See Provider overview and Results.