FastAPI server that extracts OpenAI Sentinel tokens using Camoufox (anti-detection Firefox browser).
- On startup, launches a Context Pool of N Camoufox browser instances, each with a unique randomized fingerprint (OS, user-agent, canvas, WebGL, etc.)
- Pre-warms pages by navigating to the target URL in advance — when a request arrives, the page is already loaded and ready (~0.8s latency)
- Resource blocking — images, fonts, media, and analytics requests are aborted to reduce per-page memory (~760 MB idle with 1 browser, down from 2.2 GB without blocking)
- After serving a request, the pool immediately starts warming a replacement page in the background
- Round-robin browser rotation ensures consecutive requests produce unique Sentinel tokens
- Python 3.11+
- uv
# Install dependencies
uv sync
# Download Camoufox browser binary
uv run python -m camoufox fetchuv run python main.py| Variable | Default | Description |
|---|---|---|
HOST |
0.0.0.0 |
Server bind address |
PORT |
8000 |
Server bind port |
POOL_SIZE |
1 |
Number of browser instances in pool |
HEADLESS |
true |
Run browsers in headless mode |
MAX_CONCURRENCY |
5 |
Max concurrent token extractions |
NAVIGATION_TIMEOUT |
30000 |
Page navigation timeout (ms) |
TOKEN_TIMEOUT |
30000 |
SentinelSDK.token() timeout (ms) |
PAGE_WAIT |
2000 |
Wait after page load before injection (ms) |
Example:
PORT=9000 POOL_SIZE=5 uv run python main.pyGET /token
| Query Param | Default | Description |
|---|---|---|
timeout |
TOKEN_TIMEOUT env value |
Override token timeout for this request (ms, 1000-120000) |
Response (200):
{
"p": "...",
"t": "...",
"c": "...",
"id": "uuid"
}| Status | Description |
|---|---|
| 200 | Token extracted successfully |
| 502 | Browser error |
| 504 | Timeout |
API docs available at /docs.