VerifyAI Python Integration
Call the VerifyAI REST API from Python with requests, or httpx when you need async. There is no VerifyAI package to install: the examples below are plain HTTPS, and the Flask webhook receiver is run against real signed deliveries in our test suite.
Quick Start
1. Install
# No VerifyAI package: any HTTP client works.
pip install requests # or httpx for async
export VERIFY_AI_KEY=vai_your_api_key2. Use
import json
import os
import requests
with open("photo.jpg", "rb") as photo:
res = requests.post(
"https://verify.switchlabs.dev/api/v1/verify",
headers={"X-API-Key": os.environ["VERIFY_AI_KEY"]},
files={"image": ("photo.jpg", photo, "image/jpeg")},
data={"policy": "scooter_parking", "metadata": json.dumps({"trip_id": "trip_123"})},
timeout=30,
)
res.raise_for_status()
result = res.json()
if result["is_compliant"]:
print("Verified:", result["id"])
else:
print("Issue:", result["feedback"], result["violation_reasons"])Features
Plain HTTPS
One POST to /api/v1/verify with an X-API-Key header. Use requests, httpx, aiohttp or urllib, with nothing VerifyAI-specific to install or upgrade.
Sync or Async
requests for scripts and workers; httpx.AsyncClient for FastAPI and other asyncio services. The request is identical.
Any Framework
Flask, Django, FastAPI or a batch job: VerifyAI is an HTTP call, so it fits wherever you already make one.
Multipart or JSON
Upload the file as multipart, or send base64 in a JSON body when the image reached your server that way.
Idempotent Retries
Send an Idempotency-Key header and a retried request returns the original result instead of running, and billing, the check twice.
Tested Webhook Receiver
Verify X-VerifyAI-Signature over the raw body with hmac and hashlib. The Flask receiver below runs against real signed deliveries in our test suite.
Code Examples
Requirements
- Python 3.8 or higher
- requests (or httpx for async)
- A VerifyAI API key (vai_…), kept on your server
- Your webhook signing secret (whsec_…) for the receiver
Frequently Asked Questions
Start Building with Python
Get an API key and verify your first photo with a single requests call.
Other ways to integrate
Mobile SDKs, server-side HTTP examples, the REST API, webhooks, and no-code automation platforms.