Skip to content
NewClientOS is live — the self-hosted client portal for agencies.
work/routehook

Product · AI API gateway

Routehook

One API, one key and one prepaid balance for text, image and video models from every major provider.

  • API platform · Billing
  • 2026
Routehook — Product · AI API gateway

About Routehook

Introduction

Teams building AI products end up integrating provider after provider: a different SDK, key, bill and rate limit for every model they want to try. Routehook puts one OpenAI-compatible endpoint in front of all of them. Chat, embeddings, images and video go through a single base URL; long-running generations run as queued jobs with webhooks and failover; and every request is charged from a prepaid balance on an append-only ledger, so a customer can never be billed twice or spend past their balance.

Details

Project
Routehook
Timeframe
2026
Type
API platform · Billing
Stack
  • Next.js
  • NestJS
  • PostgreSQL
  • Redis
  • Drizzle
  • Stripe
  • better-auth
  • Docker
Problem
Using several AI providers means several integrations, keys and invoices — and switching models usually means rewriting code. Image and video models add a second problem: a generation can run for minutes, fail halfway, and still have to be billed correctly.
What we built
A gateway that speaks the OpenAI and Anthropic wire formats, with provider adapters behind it, async jobs for image and video, per-key rate limiting, routing and failover between providers, a hold-then-settle billing ledger, a customer dashboard with a live playground, and an admin console.
Outcome
Live at routehook.ai with a public model catalogue and published per-request pricing.
provider adapters behind one endpoint
11
wire formats: Chat Completions, Responses and Anthropic Messages
3
routing strategies to choose from, per model
5
tools on the MCP server
16

Inside the dashboard.

The console a customer runs their AI traffic from, rebuilt here in code from its own screens. Pick a page, or click the sidebar.

Routehook — Models

Every model, at your price

One catalogue of text, image, video, audio, embedding and rerank models, each with the customer’s own price and how much they have used it in the last 30 days.

  • Search by name or model id
  • Filter by type, or Used by me
  • Live or Coming soon
  • Try it, or ask for a discount

Recreated from the dashboard’s interface. Labels and columns are Routehook’s own; the account, requests, prices and numbers are samples, and the images are CC0 photographs standing in for model output.

The parts, up close.

The gateway behaviour behind the dashboard, at full size.

What went into it.

  1. 01

    Unified gateway

    One /v1 endpoint for chat, completions, embeddings, rerank, audio, images and video, with adapters for Anthropic, Gemini, OpenAI-compatible providers and the image, video and audio model hosts.

  2. 02

    Billing you can trust

    A prepaid balance on an append-only ledger with hold-then-settle charging, usage per key and a per-request cost log. Stripe and crypto top-ups via webhooks.

  3. 03

    Growth tooling

    Server-side ad conversion tracking for Meta, Reddit, X, Google Ads and GA4, plus an MCP server with OAuth for agent access.

How it is built.

The running parts

Gateway API
NestJS, forked across CPU cores, with Drizzle for data and better-auth for sessions and API keys.
Three web apps
The public site with docs and the model catalogue, the customer dashboard and the admin console, all Next.js, sharing one package of request and response schemas.
PostgreSQL
Accounts, the ledger, the request log and the job queue itself. There is no separate message broker to run.
Redis and object storage
Redis holds rate-limit buckets and realtime fan-out. Generated media goes to S3-compatible storage.
Deployment
Docker Compose on Dokploy, built from source on every push to main, behind Traefik with automatic certificates.

The hard parts

  1. 01

    Never spend more than the balance

    Before a request leaves, its worst-case cost is reserved as a hold, and a database constraint refuses any hold the balance cannot cover. Afterwards the hold settles to the real cost. A sweeper releases holds a crash left behind, and a reconciler charges jobs that finished but never settled.

  2. 02

    A ledger nobody can edit

    A database trigger rejects every update and delete on ledger entries, and it is the only thing allowed to write the settled balance. The application cannot quietly change history even with a bug.

  3. 03

    Failover without charging twice

    A stream is committed to a provider at its first byte. Before that, a bad request stops the chain, an auth failure skips only that provider, and a circuit breaker takes a failing provider out of rotation and lets a single probe test it again.

  4. 04

    Rate limits that hold across processes

    Limits run as one atomic script in Redis with a bucket per key, so every API process sees the same count and a burst cannot slip between two of them.

  5. 05

    A job queue without a broker

    Workers claim jobs straight from PostgreSQL with row locks that skip what another worker already holds. Outgoing webhooks are signed, retried with backoff, and checked against the resolved address so they cannot be pointed at internal systems.

Start here

Have a problem worth solving?

Tell us what is slow, manual or missing. You will hear back within one working day — then get a written scope and a fixed quote, or an honest no.

brief.md
  1. # New project brief
  2. ## What is slow, manual or missing?
  3. - [x] Written scope
  4. - [x] Fixed quote
  5. - [x] Or an honest no
Reply within one working daySend brief
Message Us