gproxy-lite instead: a separate, thin engine built from the same channels and the same protocol conversion, compiled to one WebAssembly module with a small JavaScript shell per platform.
What it is and what it leaves out
gproxy-lite serves one operator. It has:
- every channel of the full gateway, including the ones that sign in with OAuth;
- every operation over HTTP, in every dialect: content generation (streamed or not), token counting, embeddings, images, model listing, compaction, files and video, passed through when the upstream speaks the client’s dialect and converted when it does not;
- WebSocket operations on Cloudflare, relayed to an upstream that speaks them.
- users, organizations, teams, API keys or permissions: one access key admits every request;
- budgets, quotas, pricing, usage records, rate limits or an audit log;
- several credentials per provider, credential selection or retry on another credential;
- routes, aliases and tiers: a request names its provider;
- rewrite rules and per-operation routing rules: routing is the channel’s default;
- the console, the management API and multi-instance synchronization;
- MCP servers and channel service routes (usage pages, quota queries);
- a local model catalogue and tokenizer: an operation the upstream does not have is refused, not estimated;
- stored files: a converted image request cannot be answered with a URL, only with
b64_json; - conversion of a Responses WebSocket client onto an HTTP upstream.
Configuration
The whole configuration is one JSON document in the environment variableGPROXY_LITE_CONFIG. It contains the access key and upstream credentials, so store it as a secret.
A configuration the engine cannot use (unknown channel, duplicate name, a credential the channel does not accept) is refused at start, and every request answers
500 with the reason.
Addressing a provider
/{provider}/v1/...sends to that provider. The model is the upstream’s own name.- Without the prefix, the model field reads
provider/model. - With a single provider configured, the prefix may be left out.
GET /v1/models without a prefix lists the models of all of them, each id prefixed with its provider.
Signing in to an OAuth channel
A provider without acredential is signed in through three paths, all behind the access key. No browser redirect has to reach the deployment.
1
Start
session and either an authorize_url to open in a browser or, for a device login, a user_code and a verification_uri. A channel with both flows takes "mode": "authorization_code" or "device_code".2
Authorize
Open the URL and approve. An authorization code login ends on a page that does not load (a
localhost address) or that shows a code: copy the whole address, or the code.3
Complete
callback_url or code, not both. For a device login send only the session, and repeat while the answer is {"status":"pending"}, waiting interval_secs in between. {"status":"ready"} means the credential is stored.GET /lite/status lists every provider with the state of its credential: none, configured, signed_in or dead. A dead credential is one the upstream refused to renew; reason says why, and only signing in again replaces it.
Staying signed in
A credential that expires is renewed when a request finds it about to expire, again if the upstream answers401, and on a schedule, so that a sign-in outlives a period without requests. Every template runs the schedule once a day, at 04:00 UTC. POST /lite/renew, behind the access key, does the same on demand and answers with what happened to each provider that has something to renew:
On Vercel, set the environment variable
CRON_SECRET to a random string of at least 16 characters and deploy again. Vercel sends it as the bearer token of the scheduled request, and the function accepts that request only with it. Without CRON_SECRET the scheduled request is refused and nothing is renewed on schedule.
Once a day is enough for refresh tokens, which live for days or longer. Where the schedule does not run, or runs less often than a session lives (the playground channel rotates its cookies every ten minutes), requests still renew the credential, and one left unused for too long has to sign in again.
Renewals of one credential never overlap, because some upstreams revoke every token of a sign-in when a refresh token is presented twice. A renewal first takes a lease: a store entry created only if absent, which expires after 30 seconds. Another instance that finds the lease taken waits up to 10 seconds for the renewed credential and uses it. If the holder dies, the lease expires and the next renewal takes it. A renewal that outlasts its lease can still overlap with the next one; the stored result is then decided by compare-and-exchange.
State
Everything the engine remembers is in one key-value store per deployment: credentials that were signed in or renewed, pending sign-ins, and the state protocol conversion keeps between requests. A pasted credential stays in the configuration and is written to the store only when the channel renews it. Credentials are stored as the upstream issued them, without the master-key encryption of the full gateway, so restrict who can read the store.Deploying
The Cloudflare, Netlify and Vercel buttons in the repository’s README deploy these templates without a Rust toolchain. Their build step,npm run build, runs prepare-lite.mjs: it downloads gproxy-lite.zip from the staging release, which is built from main, checks it against that release’s SHA256SUMS and unpacks it into lite/. Set GPROXY_LITE_RELEASE to latest or to a tag such as v4.3.1 to use a stable release instead. The button asks for GPROXY_LITE_CONFIG; on Vercel it also adds Upstash Redis and asks for CRON_SECRET.
To build the module yourself, the templates are in deploy/lite of the repository. prepare-lite.mjs keeps a lite/ that is already there. Building this needs Rust with the wasm32-unknown-unknown target and wasm-bindgen-cli at the version in Cargo.lock:
- Cloudflare Workers
- Netlify
- Vercel
wrangler.toml; there is nothing to create first. For a local run, copy dev.vars.example to .dev.vars and start wrangler dev.