tavily-key-generator-proxy

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Tavily Key Generator + API Proxy

Tavily密钥生成器 + API代理

Skill by ara.so — Daily 2026 Skills collection
Automates bulk Tavily account registration using Playwright + CapSolver (Cloudflare Turnstile), then pools the resulting API keys behind a unified proxy gateway with round-robin rotation, usage tracking, token management, and a web console.

来自ara.so的Skill — 2026每日Skill合集
使用Playwright + CapSolver(Cloudflare Turnstile)自动化批量注册Tavily账户,随后将生成的API密钥集中到统一代理网关后,实现轮询调度、使用跟踪、令牌管理以及Web控制台功能。

What It Does

功能说明

ComponentLocationPurpose
Key Generatorroot
/
Playwright-driven headless Firefox registers Tavily accounts, solves Turnstile CAPTCHAs, verifies email, extracts API key
API Proxy
proxy/
FastAPI service that round-robins requests across pooled keys, exposes
/api/search
and
/api/extract
, serves web console at
/console
Each free Tavily account yields 1,000 API calls/month. The proxy aggregates quota: 10 keys = 10,000 calls/month via one endpoint.

组件位置用途
密钥生成器根目录
/
由Playwright驱动的无头Firefox浏览器注册Tavily账户、解决Turnstile验证码、验证邮箱、提取API密钥
API代理
proxy/
FastAPI服务,在集中的密钥间轮询分发请求,暴露
/api/search
/api/extract
接口,在
/console
提供Web控制台
每个免费Tavily账户每月可提供1000次API调用。代理会汇总配额:10个密钥 = 通过一个端点实现每月10000次调用。

Installation

安装步骤

Key Generator

密钥生成器

bash
git clone https://github.com/skernelx/tavily-key-generator.git
cd tavily-key-generator
pip install -r requirements.txt
playwright install firefox
cp config.example.py config.py
bash
git clone https://github.com/skernelx/tavily-key-generator.git
cd tavily-key-generator
pip install -r requirements.txt
playwright install firefox
cp config.example.py config.py

Edit config.py with your CapSolver key and email backend

Edit config.py with your CapSolver key and email backend

python main.py
undefined
python main.py
undefined

API Proxy (Docker — recommended)

API代理(推荐使用Docker)

bash
cd proxy/
cp .env.example .env
bash
cd proxy/
cp .env.example .env

Set ADMIN_PASSWORD in .env

Set ADMIN_PASSWORD in .env

docker compose up -d
docker compose up -d

---

---

Configuration (
config.py
)

配置(
config.py

CAPTCHA Solver (required)

验证码求解器(必填)

python
undefined
python
undefined

CapSolver — recommended (~$0.001/solve, high success rate)

CapSolver — 推荐(约$0.001/次求解,成功率高)

CAPTCHA_SOLVER = "capsolver" CAPSOLVER_API_KEY = "CAP-..." # from capsolver.com
CAPTCHA_SOLVER = "capsolver" CAPSOLVER_API_KEY = "CAP-..." # from capsolver.com

Browser click fallback — free but low success rate

浏览器点击备选方案 — 免费但成功率低

CAPTCHA_SOLVER = "browser"
undefined
CAPTCHA_SOLVER = "browser"
undefined

Email Backend (required — pick one)

邮件后端(必填 — 选择其一)

Option A: Cloudflare Email Worker (self-hosted, free)
python
EMAIL_BACKEND = "cloudflare"
EMAIL_DOMAIN = "mail.yourdomain.com"
EMAIL_API_URL = "https://mail.yourdomain.com"
EMAIL_API_TOKEN = "your-worker-token"
Option B: DuckMail (third-party temporary email)
python
EMAIL_BACKEND = "duckmail"
DUCKMAIL_API_BASE = "https://api.duckmail.sbs"
DUCKMAIL_BEARER = "dk_..."
DUCKMAIL_DOMAIN = "duckmail.sbs"
If both backends are configured, the CLI prompts you to choose at runtime.
选项A:Cloudflare Email Worker(自托管,免费)
python
EMAIL_BACKEND = "cloudflare"
EMAIL_DOMAIN = "mail.yourdomain.com"
EMAIL_API_URL = "https://mail.yourdomain.com"
EMAIL_API_TOKEN = "your-worker-token"
选项B:DuckMail(第三方临时邮箱)
python
EMAIL_BACKEND = "duckmail"
DUCKMAIL_API_BASE = "https://api.duckmail.sbs"
DUCKMAIL_BEARER = "dk_..."
DUCKMAIL_DOMAIN = "duckmail.sbs"
如果同时配置了两个后端,CLI会在运行时提示你选择。

Registration Throttle (anti-ban)

注册限流(防封禁)

python
THREADS = 2                  # Max 3 — more = higher ban risk
COOLDOWN_BASE = 45           # Seconds between registrations
COOLDOWN_JITTER = 15         # Random additional seconds
BATCH_LIMIT = 20             # Pause after this many registrations
python
THREADS = 2                  # 最大3 — 数量越多封禁风险越高
COOLDOWN_BASE = 45           # 注册间隔秒数
COOLDOWN_JITTER = 15         # 随机额外增加的秒数
BATCH_LIMIT = 20             # 注册该数量后暂停

Auto-upload to Proxy (optional)

自动上传到代理(可选)

python
PROXY_AUTO_UPLOAD = True
PROXY_URL = "http://localhost:9874"
PROXY_ADMIN_PASSWORD = "your-admin-password"

python
PROXY_AUTO_UPLOAD = True
PROXY_URL = "http://localhost:9874"
PROXY_ADMIN_PASSWORD = "your-admin-password"

Running the Key Generator

运行密钥生成器

bash
python main.py
bash
python main.py

Prompts: how many keys to generate, which email backend

提示:要生成的密钥数量、选择哪个邮件后端

Output: api_keys.md with all generated keys

输出:包含所有生成密钥的api_keys.md

If PROXY_AUTO_UPLOAD=True, keys are pushed to proxy automatically

如果PROXY_AUTO_UPLOAD=True,密钥会自动推送到代理


Generated `api_keys.md` format (used for bulk import into proxy):
tvly-abc123... tvly-def456... tvly-ghi789...

---

生成的`api_keys.md`格式(用于批量导入代理):
tvly-abc123... tvly-def456... tvly-ghi789...

---

API Proxy Usage

API代理使用方法

Calling the Proxy (drop-in Tavily replacement)

调用代理(直接替换Tavily使用)

bash
undefined
bash
undefined

Search — replace base URL only

搜索 — 仅替换基础URL

curl -X POST http://your-server:9874/api/search
-H "Authorization: Bearer tvly-YOUR_PROXY_TOKEN"
-H "Content-Type: application/json"
-d '{"query": "latest AI news", "search_depth": "basic"}'
curl -X POST http://your-server:9874/api/search
-H "Authorization: Bearer tvly-YOUR_PROXY_TOKEN"
-H "Content-Type: application/json"
-d '{"query": "latest AI news", "search_depth": "basic"}'

Extract

提取

curl -X POST http://your-server:9874/api/extract
-H "Authorization: Bearer tvly-YOUR_PROXY_TOKEN"
-H "Content-Type: application/json"
-d '{"urls": ["https://example.com/article"]}'

Token can also be passed in the request body as `api_key` (Tavily SDK compatible):

```python
import requests

response = requests.post(
    "http://your-server:9874/api/search",
    json={
        "query": "Python web scraping",
        "api_key": "tvly-YOUR_PROXY_TOKEN"
    }
)
print(response.json())
curl -X POST http://your-server:9874/api/extract
-H "Authorization: Bearer tvly-YOUR_PROXY_TOKEN"
-H "Content-Type: application/json"
-d '{"urls": ["https://example.com/article"]}'

令牌也可以在请求体中作为`api_key`传递(兼容Tavily SDK):

```python
import requests

response = requests.post(
    "http://your-server:9874/api/search",
    json={
        "query": "Python web scraping",
        "api_key": "tvly-YOUR_PROXY_TOKEN"
    }
)
print(response.json())

Python SDK Integration

Python SDK集成

python
from tavily import TavilyClient
python
from tavily import TavilyClient

Point SDK at your proxy — no other changes needed

将SDK指向你的代理 — 无需其他修改

client = TavilyClient( api_key="tvly-YOUR_PROXY_TOKEN", base_url="http://your-server:9874" )
results = client.search("machine learning trends 2025")

---
client = TavilyClient( api_key="tvly-YOUR_PROXY_TOKEN", base_url="http://your-server:9874" )
results = client.search("machine learning trends 2025")

---

Admin API Reference

管理API参考

All admin endpoints require header:
X-Admin-Password: your-password
所有管理端点需要请求头:
X-Admin-Password: your-password

Keys Management

密钥管理

bash
undefined
bash
undefined

List all keys

列出所有密钥

curl http://localhost:9874/api/keys
-H "X-Admin-Password: secret"
curl http://localhost:9874/api/keys
-H "X-Admin-Password: secret"

Add a single key

添加单个密钥

curl -X POST http://localhost:9874/api/keys
-H "X-Admin-Password: secret"
-H "Content-Type: application/json"
-d '{"key": "tvly-abc123..."}'
curl -X POST http://localhost:9874/api/keys
-H "X-Admin-Password: secret"
-H "Content-Type: application/json"
-d '{"key": "tvly-abc123..."}'

Bulk import from api_keys.md text

从api_keys.md文本批量导入

curl -X POST http://localhost:9874/api/keys
-H "X-Admin-Password: secret"
-H "Content-Type: application/json"
-d '{"bulk": "tvly-abc...\ntvly-def...\ntvly-ghi..."}'
curl -X POST http://localhost:9874/api/keys
-H "X-Admin-Password: secret"
-H "Content-Type: application/json"
-d '{"bulk": "tvly-abc...\ntvly-def...\ntvly-ghi..."}'

Toggle key enabled/disabled

切换密钥启用/禁用状态

curl -X PUT http://localhost:9874/api/keys/{id}/toggle
-H "X-Admin-Password: secret"
curl -X PUT http://localhost:9874/api/keys/{id}/toggle
-H "X-Admin-Password: secret"

Delete key

删除密钥

curl -X DELETE http://localhost:9874/api/keys/{id}
-H "X-Admin-Password: secret"
undefined
curl -X DELETE http://localhost:9874/api/keys/{id}
-H "X-Admin-Password: secret"
undefined

Token Management

令牌管理

bash
undefined
bash
undefined

Create access token

创建访问令牌

curl -X POST http://localhost:9874/api/tokens
-H "X-Admin-Password: secret"
-H "Content-Type: application/json"
-d '{"label": "my-app"}'
curl -X POST http://localhost:9874/api/tokens
-H "X-Admin-Password: secret"
-H "Content-Type: application/json"
-d '{"label": "my-app"}'

Returns: {"token": "tvly-...", "id": "..."}

返回:{"token": "tvly-...", "id": "..."}

List tokens

列出令牌

curl http://localhost:9874/api/tokens
-H "X-Admin-Password: secret"
curl http://localhost:9874/api/tokens
-H "X-Admin-Password: secret"

Delete token

删除令牌

curl -X DELETE http://localhost:9874/api/tokens/{id}
-H "X-Admin-Password: secret"
undefined
curl -X DELETE http://localhost:9874/api/tokens/{id}
-H "X-Admin-Password: secret"
undefined

Stats

统计信息

bash
curl http://localhost:9874/api/stats \
  -H "X-Admin-Password: secret"
bash
curl http://localhost:9874/api/stats \
  -H "X-Admin-Password: secret"

Returns: total_quota, used, remaining, active_keys, disabled_keys

返回:total_quota, used, remaining, active_keys, disabled_keys

undefined
undefined

Change Admin Password

修改管理员密码

bash
curl -X PUT http://localhost:9874/api/password \
  -H "X-Admin-Password: current-password" \
  -H "Content-Type: application/json" \
  -d '{"new_password": "new-secure-password"}'

bash
curl -X PUT http://localhost:9874/api/password \
  -H "X-Admin-Password: current-password" \
  -H "Content-Type: application/json" \
  -d '{"new_password": "new-secure-password"}'

Proxy Behavior

代理行为

  • Round-robin: requests distributed evenly across active keys
  • Auto-disable: key disabled after 3 consecutive failures
  • Quota tracking: total = active_keys × 1,000/month; updates automatically on add/delete/toggle
  • Token format: proxy tokens use
    tvly-
    prefix, indistinguishable from real Tavily keys to clients

  • 轮询调度:请求均匀分发到所有活跃密钥
  • 自动禁用:连续3次失败后禁用密钥
  • 配额跟踪:总配额 = 活跃密钥数 × 1000/月;添加/删除/切换密钥时自动更新
  • 令牌格式:代理令牌使用
    tvly-
    前缀,对客户端来说与真实Tavily密钥无区别

Proxy
.env
Configuration

代理
.env
配置

env
ADMIN_PASSWORD=change-this-immediately
PORT=9874
env
ADMIN_PASSWORD=change-this-immediately
PORT=9874

Optional: restrict CORS origins

可选:限制CORS源

Nginx Reverse Proxy + HTTPS

Nginx反向代理 + HTTPS

nginx
server {
    listen 443 ssl;
    server_name tavily-proxy.yourdomain.com;

    ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1:9874;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

nginx
server {
    listen 443 ssl;
    server_name tavily-proxy.yourdomain.com;

    ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1:9874;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Integration Pattern: Auto-replenish Pool

集成模式:自动补充密钥池

python
undefined
python
undefined

replenish.py — run on cron when quota runs low

replenish.py — 配额不足时通过定时任务运行

import requests
PROXY_URL = "http://localhost:9874" ADMIN_PASSWORD = "your-password" MIN_ACTIVE_KEYS = 10
def get_stats(): r = requests.get(f"{PROXY_URL}/api/stats", headers={"X-Admin-Password": ADMIN_PASSWORD}) return r.json()
def trigger_registration(count: int): """Call your key generator as subprocess or import directly""" import subprocess subprocess.run(["python", "main.py", "--count", str(count)], check=True)
stats = get_stats() active = stats["active_keys"] if active < MIN_ACTIVE_KEYS: needed = MIN_ACTIVE_KEYS - active print(f"Pool low ({active} keys), registering {needed} more...") trigger_registration(needed)

---
import requests
PROXY_URL = "http://localhost:9874" ADMIN_PASSWORD = "your-password" MIN_ACTIVE_KEYS = 10
def get_stats(): r = requests.get(f"{PROXY_URL}/api/stats", headers={"X-Admin-Password": ADMIN_PASSWORD}) return r.json()
def trigger_registration(count: int): """通过子进程调用密钥生成器或直接导入""" import subprocess subprocess.run(["python", "main.py", "--count", str(count)], check=True)
stats = get_stats() active = stats["active_keys"] if active < MIN_ACTIVE_KEYS: needed = MIN_ACTIVE_KEYS - active print(f"密钥池不足({active}个密钥),正在注册{needed}个新密钥...") trigger_registration(needed)

---

Troubleshooting

故障排除

ProblemCauseFix
CAPTCHA solve failuresTavily elevated bot detectionPause several hours, reduce
THREADS
to 1
Email verification timeoutSlow email deliveryIncrease poll timeout in config
Keys immediately disabled in proxyTavily account flagged/suspendedRegister from different IP
playwright install firefox
fails
Missing system depsRun
playwright install-deps firefox
first
Docker compose port conflict9874 in useChange
PORT
in
.env
and
docker-compose.yml
X-Admin-Password
401
Wrong passwordCheck
.env
, restart container after changes
IP ban during registrationToo many registrationsUse
BATCH_LIMIT=10
, wait hours between batches
问题原因解决方法
验证码求解失败Tavily增强了机器人检测暂停数小时,将
THREADS
减少到1
邮箱验证超时邮件投递缓慢增加配置中的轮询超时时间
密钥在代理中立即被禁用Tavily账户被标记/封禁使用不同IP注册
playwright install firefox
失败
缺少系统依赖先运行
playwright install-deps firefox
Docker compose端口冲突9874端口被占用修改
.env
docker-compose.yml
中的
PORT
X-Admin-Password
返回401
密码错误检查
.env
,修改后重启容器
注册时IP被封禁注册次数过多设置
BATCH_LIMIT=10
,批次间间隔数小时

Rate Limit Safe Settings

限流安全设置

python
undefined
python
undefined

Conservative — minimizes ban risk

保守配置 — 最小化封禁风险

THREADS = 1 COOLDOWN_BASE = 60 COOLDOWN_JITTER = 30 BATCH_LIMIT = 10

---
THREADS = 1 COOLDOWN_BASE = 60 COOLDOWN_JITTER = 30 BATCH_LIMIT = 10

---

Security Checklist

安全检查清单

  • Change
    ADMIN_PASSWORD
    from default immediately after deploy
  • Add
    config.py
    to
    .gitignore
    (already included, verify before push)
  • Deploy behind HTTPS in production
  • Rotate proxy tokens periodically
  • Never commit
    api_keys.md
    to public repositories
  • 部署后立即修改默认的
    ADMIN_PASSWORD
  • config.py
    添加到
    .gitignore
    (已包含,推送前确认)
  • 生产环境部署在HTTPS后
  • 定期轮换代理令牌
  • 切勿将
    api_keys.md
    提交到公共仓库