Faregate puts a price on your API or MCP server. Agents pay per call from prepaid credits; you get paid out through Stripe. Integration is a URL โ no billing code.
๐ค Building with an AI assistant? Point it at faregate.io/llms.txt โ the entire integration (both sides, all endpoints, the signature algorithm, copy-paste code) in one plaintext file. Paste the URL into your coding session and say "integrate this."
https://proxy.faregate.io/s/{your-slug}/
curl https://proxy.faregate.io/s/{service}/some/path \
-H "x-faregate-key: fg_your_key_here"
Authorization: Bearer fg_โฆ works too. Every response tells you what happened:
| Response header | Meaning |
|---|---|
| x-faregate-charge | free (free tier), paid (credits drawn), or none (zero-priced) |
| x-faregate-balance | Your key's remaining credit after this call |
A request without credit (or without a key) gets HTTP 402 Payment Required with a machine-readable body โ so an agent, or the person running it, always knows exactly how to proceed:
{
"error": "payment_required",
"faregate": {
"version": 1,
"service": "flight-search",
"price_micro_usd": 20000,
"price_display": "$0.0200",
"free_tier": 25,
"accepts": ["faregate_credits"],
"topup_url": "https://faregate.io/topup?service=flight-search",
"docs_url": "https://faregate.io/docs/402"
}
}
Prices are integer micro-USD (1,000,000 ยต$ = $1.00) โ exact arithmetic, no floats. Handle a 402 by topping up the key, then retry.
| Endpoint | Description |
|---|---|
| GET /v1/balance | Current credit for the key in x-faregate-key. Returns balance_micro_usd and balance_display. |
| POST /v1/topup/checkout | Body {"key": "fg_โฆ", "amount_usd": 20} ($5โ$500). Returns a Stripe checkout_url. Credits land automatically on payment. |
| GET /s/{slug}/* | The metered proxy itself (any method). Authenticated + billed, then forwarded to the service origin. |
Base URL for all endpoints: https://proxy.faregate.io. Errors are JSON with an
error field; auth failures are 401, unknown services 404, payment required 402.
Your metered URL forwards to your origin โ so you should reject traffic that reaches the origin without going through Faregate (and its billing). Every request we forward is signed with your service's signing secret (shown when you create the service, and copyable from the Services list):
| Header | Value |
|---|---|
| x-faregate-timestamp | Unix seconds when the proxy signed the request |
| x-faregate-signature | Hex HMAC-SHA256(secret, "{timestamp}.{METHOD}.{path+query}") |
Verify by recomputing the HMAC and comparing in constant time; reject if the timestamp is more than 300 seconds off. With the SDK it's one middleware:
import { originVerifier } from "@faregate/sdk";
const verify = originVerifier({ secret: process.env.FAREGATE_SIGNING_SECRET! });
// in your handler (anything Request-shaped):
if (!(await verify(req))) {
return new Response(JSON.stringify({ error: "unverified_request" }), { status: 401 });
}
Express: app.use(expressVerifier({ secret })) ยท Hono:
app.use("*", honoVerifier({ secret })). Not on TypeScript? The algorithm above
is three lines in any language โ a Python reference implementation is in
llms.txt.
@faregate/sdk is dependency-free TypeScript (Node 18+, Bun, Deno, Workers,
browsers) covering both sides:
| Export | Side | What it does |
|---|---|---|
| faregateFetch({ key }) | Buyer | Drop-in fetch that attaches your key and throws a typed PaymentRequiredError (with the top-up URL) on 402 |
| originVerifier({ secret }) | Seller | Framework-agnostic request verification |
| expressVerifier / honoVerifier | Seller | One-line middleware for Express and Hono |
During early access the SDK ships from the repo โ email support@faregate.io for access and we'll set you up personally. The raw HTTP interface above is fully supported and identical in capability.
MCP servers speak HTTP, so metering one is the same single step: register your MCP server's
public URL as the service origin and give agents the metered URL as the server address. Calls
arrive with the agent's key header; unpaid calls get the 402 payload above, which the agent
can surface to its operator. Add originVerifier to the server if you want to
reject unbilled direct traffic.
Email support@faregate.io โ during early access you're talking directly to the engineers.