Documentation Index
Fetch the complete documentation index at: https://docs.faremeter.xyz/llms.txt
Use this file to discover all available pages before exploring further.
@faremeter/gateway-nginx is the OSS package that lets a marketplace operator turn an OpenAPI spec into a working payment-enforcing nginx configuration. It is what the marketplace API nodes use under the hood. Most readers do not need to install it — but it helps to know what it does, because it shapes what publishers can express in their pricing.
Package: @faremeter/gateway-nginx
What it does
The gateway SDK takes a parsed OpenAPI spec (withx-faremeter-* extensions) and emits two things:
- nginx location blocks — included by the operator inside their own
server { }block. Each priced endpoint gets a Lua-instrumented location. - A bundled Lua module (
faremeter.lua) — referenced by the location blocks at runtime to talk to a sidecar process that evaluates pricing and validates payment.
generateConfig is a pure function — no I/O, no network — so it is safe to call in tests or build pipelines.
How it fits
@faremeter/middleware and the payment evaluator. nginx itself never imports Faremeter code; it just speaks HTTP/JSON to the sidecar via Unix socket.
For the full nginx phase model (access_by_lua_block, header_filter_by_lua_block, body_filter_by_lua_block, log_by_lua_block), see the package’s ARCHITECTURE.md.
Capabilities a publisher can use
The pricing extensions in your OpenAPI spec map to features the SDK supports:- Three transports — HTTP JSON, Server-Sent Events (SSE) streaming, and WebSocket frame relay. The transport is detected from the response and handled appropriately.
- Method dispatch — different pricing for
GETvsPOSTon the same path. - Response field capture — pricing can depend on response data (e.g.
usage.total_tokensfrom an LLM response). The generator statically analyzes the spec and only parses chunks that could contain referenced fields. - Optional spec hosting — serve the OpenAPI spec at
/.well-known/openapi.yamlfor discovery clients.
Prerequisites for operators
The generated config requires OpenResty (nginx + LuaJIT) and the lua-resty-http module. The operator runs OpenResty, includes the generatedlocationsConf, and runs the sidecar process.
Gateway-mode vs legacy
Gateway-mode (the path described above) is the current and recommended way to enforce payment at the proxy. The marketplace repo also contains a hand-written Lua access module from earlier work; new tenants should be on gateway-mode and existing tenants are being migrated.What’s next
Publisher path
Where the OpenAPI spec the SDK consumes comes from.
Self-hosting
Run the SDK inside your own marketplace deployment.
Facilitators
What the sidecar talks to when validating and settling payment.
Package on GitHub
README, ARCHITECTURE.md, and source.