Skip to content

RegBot Integration

KeyPool reads API keys directly from RegBot's D1 database. RegBot is the single source of truth for all upstream credentials.

Architecture

RegBot (registers accounts, checks balances)
  → stores credentials in RegBot D1 (regbot-storage-v2-production)
    ← KeyPool reads credentials directly via cross-D1 binding (REGBOT_DB)
      → KeyPool proxies requests using pooled keys

KeyPool has read-only access to RegBot's credentials table. No sync or copy needed.

RegBot Credential Schema (Source)

From regbot/schemas/collaborative_schema_fixed.sql:

CREATE TABLE credentials (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    service TEXT NOT NULL,          -- 'assemblyai', 'exaai', 'firecrawl', 'groq', 'tavily', 'serper', 'elevenlabs', 'cartesia', 'deepgram'
    api_key TEXT NOT NULL,
    email TEXT,
    quota_total INTEGER,
    quota_used INTEGER DEFAULT 0,
    quota_unit TEXT DEFAULT 'requests',
    status TEXT DEFAULT 'active',   -- active, expired, suspended
    last_usage_check TIMESTAMP,
    extra_metadata TEXT,            -- JSON
    created_at TIMESTAMP,
    updated_at TIMESTAMP
);

Service Name Mapping

KeyPool services.regbot_service_name maps to RegBot's credentials.service:

KeyPool name RegBot service Notes
exa exaai RegBot uses exaai, KeyPool uses exa (matches SDK)
firecrawl firecrawl Direct match
assemblyai assemblyai Direct match
groq groq Direct match
tavily tavily Direct match
serper serper Direct match
elevenlabs elevenlabs Direct match
cartesia cartesia Direct match
deepgram deepgram Direct match

Responsibilities

Concern Owner
Account registration RegBot
API key storage RegBot D1
Balance checking RegBot
Key validity/status RegBot
Key selection & load balancing KeyPool
Circuit breakers KeyPool (KV)
Team auth & rate limiting KeyPool
Usage logging KeyPool D1

D1 Binding

In wrangler.jsonc:

{
  "binding": "REGBOT_DB",
  "database_name": "regbot-storage-v2-production",
  "database_id": "d7bde9cb-e940-4636-af99-bdc46536ca49"
}

KeyPool queries RegBot D1 at request time:

SELECT * FROM credentials WHERE service = ? AND status = 'active' ORDER BY id