Skip to content
Common-Good-IntelligencePublic

About

Metered API-as-a-Service for AI agents — prepaid credit, priority queue, idempotent workers, per-call settlement over a compliant supply side (architecture write-up)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Tollgate

Metered API-as-a-Service. Sells billed, idempotent data/action API calls to AI agents and developers. Prepaid credit, priority queue, stateless idempotent workers, per-call settlement, full audit trail — over a compliant supply side.

One of three independent passive-cashflow systems. Sibling products: Rainmaker (Business-in-a-Box) and Ratchet (compute broker). Each is self-contained and embeds its own copy of the shared core engine.

Status

Furthest along of the three systems. The billing rails, the worker engine, and a 10-endpoint catalog are built and under test; deployment configs, legal docs, and a launch kit are written. Not yet taking outside traffic — the remaining work is operational (host it, point a domain at it, take the first paying call), not architectural.

  • 35 tests passing across the shared core and the product workers
  • 10 billable endpoints in the catalog (below)
  • Self-host path is real: Dockerfile, docker-compose.yml, and a Render blueprint

Endpoint catalog

Endpoint What it does
text.summarize Condense text to a target length
text.classify Label text against caller-supplied categories
text.extract Pull entities/fields out of free text
text.keywords Rank salient terms
text.redact Find and mask PII (emails, phones, SSNs, cards) + report what was found
text.structured Schema-guided extraction — caller supplies fields/JSON schema, gets JSON back
text.chunk Token-sized chunks with overlap, for RAG pipelines
text.language Language detection
html.extract HTML → main article text, title, links; nav/ads stripped
document.extract PDF → structured JSON

LLM mode is optional and keyless-capable

text.structured runs rules-first and can be upgraded to an LLM backend through an OpenAI-compatible client. The default preset targets Ollama on the host — no API key, no per-token vendor cost, nothing leaving the machine. If the model is unreachable, the endpoint degrades to the rules path rather than failing the call.

Layout

src/core/        shared engine: ledger, pricing, queue, worker, auth,
                 gateway, ratelimit, audit, config, db, errors
src/tollgate/    the product: billable workers, LLM client, API boot
docs/            architecture (00-overview, 01-core, 02-tollgate),
                 endpoint roadmap, ADRs
legal/           TERMS, PRIVACY, ACCEPTABLE_USE
tests/           35 tests

Operational docs live alongside the code: DEPLOY.md, SELF_HOST.md, MONITORING.md, LAUNCH.md. A dashboard ships in-repo, and an admin metrics endpoint reports revenue derived from purchase-tagged ledger entries, with a stdlib digest script for cron/systemd.

Quickstart

pip install -e ".[dev]"
pytest
uvicorn tollgate.app:create_app --factory

See docs/00-overview.md to get oriented, docs/01-core.md for the shared engine, and docs/02-tollgate.md for the worker/API contract. docs/adr/0001 records the compliant-supply-side decision.

Next steps

  1. Deploy it and take one real call. Everything needed is written — the gap is an actual host, a domain, and a first transaction end to end.
  2. image.ocr — scanned PDFs and receipts are the highest-demand endpoint still missing. It needs Tesseract as a system package, which is why it slipped behind the pure-Python tier.
  3. data.normalize — validation and normalization, to round out the catalog.
  4. Move off SQLite once concurrent traffic justifies it; self-hosted Postgres is the planned target.
  5. Own the ingress. Currently a free Cloudflare Tunnel; the in-house path is Caddy or Nginx with Let's Encrypt.

Source code is private. This repository is a public write-up of what the project does, how it's built, and the decisions behind it — not the implementation.

About

Metered API-as-a-Service for AI agents — prepaid credit, priority queue, idempotent workers, per-call settlement over a compliant supply side (architecture write-up)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors