Python SDK for Vettly content moderation API
Project description
Vettly Python SDK
Python SDK for protecting your platform from toxic content.
Your users remember how they feel. One toxic comment, one harmful image, one bad experience - and they're gone. Vettly stops harmful content before it reaches your community.
Why Vettly?
- 🛡️ Protect your community - Block hate speech, harassment, and harmful content
- 👁️ Multi-modal coverage - Text, images, and video all checked
- ⚡ Async support - High-performance async/await for production apps
- 🎯 Flexible policies - Strict, moderate, or permissive - you decide
- 💰 10k text + 250 image + 100 video checks/month free - No credit card required
Get Your Free API Key
- Visit vettly.dev
- Sign up for a free account (10k text + 250 image + 100 video checks/month free)
- Go to API Keys in the dashboard
- Create and copy your API key
Installation
pip install vettly
Quick Start
from vettly import ModerationClient
client = ModerationClient(api_key="your-api-key")
# Protect your users in one line
result = client.check(
content="User-generated content here",
policy_id="moderate"
)
if result.action == "block":
# Harmful content blocked - your users never see it
print("Content blocked for community safety")
elif result.flagged:
# Queue for human review
print("Content flagged for review")
else:
# Safe to show your community
print("Content is safe")
The Problem
One bad experience can undo months of community building:
- Toxic comments drive users away - and they tell their friends
- Harmful images destroy trust instantly
- No real-time protection means users see harmful content before you can remove it
The Solution
Vettly protects your community across all content types:
# Protect text content
result = client.check(
content="Some user comment",
policy_id="moderate"
)
# Protect image uploads
result = client.check(
content="https://example.com/image.jpg",
content_type="image",
policy_id="strict"
)
# Batch protection for efficiency
from vettly import BatchItem
results = client.batch_check(
policy_id="moderate",
items=[
BatchItem(id="1", content="First message"),
BatchItem(id="2", content="Second message"),
],
)
Async Support
For high-performance applications:
from vettly import AsyncModerationClient
async with AsyncModerationClient(api_key="your-api-key") as client:
result = await client.check(
content="User content",
policy_id="moderate"
)
Framework Integration
FastAPI
from fastapi import FastAPI, HTTPException
from vettly import AsyncModerationClient
app = FastAPI()
client = AsyncModerationClient(api_key="your-api-key")
@app.post("/comments")
async def create_comment(content: str):
result = await client.check(content=content, policy_id="moderate")
if result.action == "block":
raise HTTPException(status_code=403, detail="Content blocked for community safety")
# Safe to save
return {"status": "ok"}
Django
from vettly import ModerationClient
client = ModerationClient(api_key="your-api-key")
def moderate_content(content: str) -> bool:
result = client.check(content=content, policy_id="moderate")
return result.action != "block"
Flask
from flask import Flask, request, jsonify
from vettly import ModerationClient
app = Flask(__name__)
client = ModerationClient(api_key="your-api-key")
@app.route("/submit", methods=["POST"])
def submit():
content = request.json.get("content")
result = client.check(content=content, policy_id="moderate")
if result.action == "block":
return jsonify({"error": "Content blocked for community safety"}), 403
return jsonify({"status": "ok"})
Policies
| Policy | Use Case | Protection Level |
|---|---|---|
strict |
Schools, kids apps, enterprise | Maximum protection |
moderate |
Social apps, forums, comments | Balanced |
permissive |
Gaming, creative writing | Fewer restrictions |
API Reference
ModerationClient
client = ModerationClient(
api_key="your-api-key",
api_url="https://api.vettly.dev", # Optional
timeout=30.0, # Optional, in seconds
)
Methods
check(content, policy_id, **kwargs)
Check content for harmful material.
result = client.check(
content="User message",
policy_id="moderate",
content_type="text", # "text", "image", or "video"
metadata={"user_id": "123"},
user_id="user-123",
)
batch_check(policy_id, items)
Check multiple items in one request.
from vettly import BatchItem
results = client.batch_check(
policy_id="moderate",
items=[
BatchItem(id="1", content="First message"),
BatchItem(id="2", content="Second message"),
],
)
create_policy(policy_id, yaml_content)
Create or update a protection policy.
policy = client.create_policy(
policy_id="custom-policy",
yaml_content="""
name: Custom Policy
categories:
- name: toxicity
threshold: 0.7
action: block
"""
)
list_policies()
List all policies.
policies = client.list_policies()
get_decision(decision_id)
Get details of a past decision.
decision = client.get_decision("dec_123")
register_webhook(url, events)
Get notified when harmful content is blocked.
webhook = client.register_webhook(
url="https://yoursite.com/webhooks/vettly",
events=["decision.block", "decision.flag"],
)
Error Handling
from vettly import (
ModerationClient,
VettlyAuthError,
VettlyRateLimitError,
VettlyAPIError,
)
client = ModerationClient(api_key="your-api-key")
try:
result = client.check(content="test", policy_id="moderate")
except VettlyAuthError:
print("Invalid API key")
except VettlyRateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after} seconds")
except VettlyAPIError as e:
print(f"API error: {e.message}")
Pricing
| Plan | Text | Images | Videos | Price |
|---|---|---|---|---|
| Free | 10,000/mo | 250/mo | 100/mo | $0 |
| Starter | Unlimited | 5,000/mo | 2,000/mo | $29/mo |
| Pro | Unlimited | 20,000/mo | 10,000/mo | $79/mo |
| Enterprise | Unlimited | Unlimited | Unlimited | Custom |
Start protecting your community today. No credit card required.
Links
- Start Protecting - Get your free API key
- Documentation
- GitHub
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vettly-0.1.1.tar.gz.
File metadata
- Download URL: vettly-0.1.1.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4425875a7c5b0600758841d95c40a54c4445eaa5656dcab2ee7435d1f0b868e5
|
|
| MD5 |
157d0127fafec14ae5fadfec81061fc7
|
|
| BLAKE2b-256 |
2ff9667dcac841219a953fb75a7ebfaf2444204ec567edaab4eea0150bc305ef
|
File details
Details for the file vettly-0.1.1-py3-none-any.whl.
File metadata
- Download URL: vettly-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a5ca3d401ce1f5408f1eb3c15ba5fa2cdeabb4aa97cefb7bb2af9aa3d02554a
|
|
| MD5 |
9197d542940409b614c4e580661892bf
|
|
| BLAKE2b-256 |
1b6f5b40a646734cfb764fabf2c8dfbef76eb2e25d9e6b22a6659668f76b3131
|