Architecture

What happens on every call.

A single request flows through ten gateway stages — auth to billing — in under 15ms of added latency. Here is the whole lifecycle.

Customer

X-API-Key

Gateway

auth · limit · resolve

Wallet HOLD

Redis Lua

Router

cheapest healthy

Adapter

req → vendor

Vendor

upstream API

Normalize

canonical schema

CAPTURE / RELEASE

success → debit · fail → refund

Wallet ledger

prepaid billing

Usage stream

ClickHouse

Response

call_id + result

1

Authenticate

Your X-API-Key is verified against a Redis cache (Postgres fallback). We attach your tenant, scopes and rate limits.

2

Rate limit

A Redis sliding window enforces per-key RPS and RPM. Bursts beyond your plan get a 429 with Retry-After.

3

Resolve product

The slug maps to a product contract; your request body is validated against its JSON Schema before any vendor is touched.

4

Idempotency check

If you send an Idempotency-Key, a 24-hour replay returns the original response byte-for-byte.

5

Wallet hold

We resolve your sale price and atomically reserve it from your wallet via a Redis Lua script. Insufficient balance → 402.

6

Pick cheapest healthy vendor

The router sorts active mappings by cost, filters by health, and prefers healthy over degraded — with circuit breakers on failures.

7

Adapter → vendor call

A per-mapping JSON adapter transforms your request into the vendor format and calls it with per-vendor timeouts.

8

Normalize response

The response adapter maps the vendor payload back into our canonical schema and decides success vs error.

9

Capture or release

On success we capture the hold at your price. On failure we release the hold — you are not charged.

10

Emit & return

A usage event streams to analytics; the normalized response (with call_id) returns to you, ready for your usage dashboard.

Pay only for what works

Billing is prepaid and paise-precise. On every call we place a hold on your wallet, then either capture it on success or release it on failure — so you are never charged for a call that didn't return a result. Every transaction shows up in your usage ledger.

capture

On a successful call, the held amount is charged at your price.

release

If the call fails, the hold is released back — you pay nothing.

See it on your own keys

Sandbox mode runs the whole flow without touching a vendor.