Screen a Prompt
Send text, an image, or both, and get a verdict.
Get Moderation Usage
See your billable screens and your next charge.
Overview
The Moderation API screens user input before your AI product generates from it. You send the text of a prompt, an image, or both, and Dodo Payments returns a verdict ofallow, flag, or deny, together with a score for each content category.
Use it in front of any image, video, or text generation model that takes input from your users. The Moderation API is on for every business by default and runs with your existing Dodo Payments API key, so there is nothing to sign up for. Dodo Payments can turn it off for an individual business, and calls then return 403 with MODERATION_DISABLED.
Why We Built the Moderation API
An AI generation product creates new content from whatever its users type. You cannot review each prompt by hand, and one harmful output can put your business at risk. As your Merchant of Record, Dodo Payments is legally and reputationally responsible for what is sold through the platform. The Merchant Acceptance Policy reviews AI content generation tools and does not allow impersonation, deepfakes, or explicit content, including AI-generated content. An account that generates harmful content, excessive chargebacks, or flags from payment partners can be placed under review or suspended. We built the Moderation API so that you can stop this content before your model creates it:- Screen before you generate. A blocked prompt never reaches your model, so no harmful output exists and you spend no compute on it.
- Cover the categories that matter for generation. The screen scores 17 categories, including real-person likeness, non-consensual intimate imagery, minor-coded language, and the combination of a real person with sexual content that marks a sexual deepfake.
- Integrate without another vendor. The API runs with your Dodo Payments API key, and its fee is debited from your balance. There is no separate contract, invoice, or account.
- Keep user content private. Dodo Payments does not store or log the text and images you screen.
The Moderation API is a tool for your own enforcement. It does not replace the Merchant Acceptance Policy, and you remain responsible for what your product generates.
How It Works
Call the Moderation API from your backend after the user submits a prompt and before your model runs: Each call is one screen. Text and an image sent in the same call count as one screen.Verdicts
Thedecision field carries the verdict:
Screening a Prompt
To screen a prompt, send aPOST request to /moderation/screen with at least one of text and image. The request accepts three fields:
The TypeScript and Python SDKs expose the endpoint as
client.moderation.screen(). This example blocks generation on deny, on flag, and on any error:
The examples call live mode, because only live mode runs the moderation model. Test mode returns mock verdicts and never screens the content. Live mode screens are billed.
flag like deny. If your product allows some flagged content, check triggered to decide by category instead.
Screening Images
Send an image to screen an uploaded reference image, or a generated image before you show it. The image must meet these requirements:- The format is JPEG, PNG, WebP, GIF, or BMP.
- The base64 string is at most 6,991,530 characters, and the decoded image is at most 5 MiB.
- The image is a single still frame. Animated GIF and WebP images are rejected.
- The longest edge is at least 32 pixels.
400 with MODERATION_INVALID_IMAGE, or 413 with MODERATION_INPUT_TOO_LARGE when it is too large.
To screen an image, read the file, encode it as base64, and send it in image. To screen an image and its prompt together, send both text and image in the same call. It counts as one screen. This example uses the client from the previous example:
Reading the Response
The response returns the verdict and the evidence behind it:
Base your logic on
decision and triggered. Each category has its own threshold, so a single score cut-off in your code does not match the verdict.
Categories
Every response scores the content against 17 categories:Handling Errors
Errors return the standard Dodo Payments error body with acode and a message. No error is a verdict, so none of them allow generation:
The SDKs retry a
429 or a 503 twice by default and wait for Retry-After between attempts. When the retries run out, the SDK raises an error, and your code must block the request.
Testing Your Integration
Test mode returns mock verdicts and never calls the moderation model, so you can test your routing without cost. Send requests tohttps://test.dodopayments.com with a test mode API key.
The default mock verdict is allow. To get another outcome, put one of these strings anywhere in text:
A mock verdict carries a note that says it is a mock, and all its category scores are
0. Test mode applies the same request validation as live mode. For images, it checks the base64 encoding and the format, but not the frame count or the dimensions.
Before you go live, confirm that your integration handles each case:
1
Deny Blocks Generation
Send
dodo_mock_deny and confirm your model is not called.2
Flag Follows Your Policy
Send
dodo_mock_flag and confirm your product does what your policy says.3
Overload Retries
Send
dodo_mock_overloaded and confirm your code waits for Retry-After and does not generate without a verdict.4
An Outage Blocks Generation
Send
dodo_mock_not_ready and confirm your model is not called.5
Every Generation Path Screens
Check that every code path that reaches your model calls the Moderation API first.
Pricing and Billing
The Moderation API costs $0.30 USD per 1,000 billable screens. There is no free tier and no minimum. A billable screen is a live mode screen that returns a verdict. These screens are free and not counted:- Screens in test mode.
- Screens that return an error, including
429and503.
moderation_fees. Payouts show it under Moderation Fees.
Tracking Usage
To see your usage, callGET /moderation/usage. The response returns:
Access and Privacy
Screening requires an API key with write access. Any API key, including a read-only key, can read usage. See Authentication for how to create a key and set its access level. Dodo Payments does not store the text or images you screen, and does not write them to logs. For each live mode screen, it keeps the time, the verdict, and yourrequest_id for billing and usage reporting.
Usage-Based Billing
Charge your own customers for each generation.
Credit-Based Billing
Sell generation credits and deduct them per use.