2.1 Gateway (API layer)
Service name:
px-gateway
Tech stack: FastAPI, Python 3.12
Port:
7070
Docker image:
ghcr.io/privacyx-org/px-gateway
Responsibilities
Exposes the public API endpoints:
/v1/detect/image
/v1/detect/video
Performs API key validation.
Fetches and base64-encodes images.
Forwards requests to the Scheduler.
Integrates QoS filtering based on PRVX token balance.
Supports VIP access via the
x-prvx-address
header.
QoS mechanism
The gateway verifies token eligibility via on-chain balance:
is_eligible(address, threshold_wei)
If the wallet holds ≥ 1 PRVX (default threshold), the request gains priority scheduling.
This is powered by the qos.py
module, which interacts with the Ethereum RPC using Web3.py.
Environment Variables
API_KEYS
Authorized API keys
dev_key_123
PRVX_RPC_URL
Ethereum RPC provider
—
PRVX_TOKEN_ADDRESS
PRVX ERC20 token address
—
PRVX_QOS_THRESHOLD_WEI
Eligibility threshold
1e18
SCHEDULER_URL
Scheduler endpoint
http://scheduler:7080
TIMEOUT_IMAGE_MS
Gateway timeout for image jobs
20000
TIMEOUT_VIDEO_MS
Gateway timeout for video jobs
30000
Last updated