Skip to content

feat(gateway): serve free Auto to guests and members, and add provider pins - #5194

Merged
reachjalil merged 37 commits into
devfrom
feature/free-auto-gateway
Sep 30, 2026
Merged

reachjalil merged 37 commits into
devfrom
feature/free-auto-gateway

Conversation

@reachjalil

@reachjalil reachjalil commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

What is this about?

Guests and members of unsubscribed organizations can use free Auto without provider keys. Subscribed organizations keep paid Models.

What problem does it solve?

People need a useful starter model, with free allowance kept separate from paid billing and guest access protected against abuse.

What was the situation before?

Gateway offered no free route for guests or members, and organization models had no ordered pins.

How is this implemented?

  • Share request, proof, release-window, and accounting contracts through packages/free-auto.
  • Admit members against one weekly allowance across their memberships; admit guests against machine allowances, global caps, and signed release proofs.
  • Check used allowance before dispatch and charge once afterward using the OpenAI completion ID, with a fixed estimate for missing usage.
  • Record member traffic as openwork_free; preserve paid billing and reject free requests when access is disabled.
  • Migration 0116 adds seven free-access tables, ordered pins, and the request-log route. Free and guest flags default off.

What else changed?

CIDR proxy trust, a release-key fingerprint, and an isolated free database pool support guest admission. The release branch includes current integration changes.

Release note

Free Auto provides a starter model for guests and members without a paid Models subscription.

Evidence

No E2E; Gateway unit and real-MySQL tests cover admission, idempotent accounting, caps, and simultaneous member requests before → after allowance settlement.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Deploying openwork with  Cloudflare Pages  Cloudflare Pages

Latest commit: 089a17c
Status: ✅  Deploy successful!
Preview URL: https://fbc24724.openwork.pages.dev
Branch Preview URL: https://feature-free-auto-gateway.openwork.pages.dev

View logs

@mintlify

mintlify Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
differentai 🟢 Ready View Preview Sep 30, 2026, 8:16 PM

💡 Tip: Enable Automations to automatically generate PRs for you.

Comment thread ee/apps/den-api/src/inference.ts Fixed
reachjalil and others added 2 commits September 23, 2026 16:15
…SHA-256

Free credentials and identities were stored as plain SHA-256 digests, which
code scanning flags as weak hashing of sensitive data. Den and the Gateway now
share one domain-separated helper: identities use a keyed SHA-256 tag and
free credentials use a WebCrypto HMAC, matching the Gateway bearer-key store.
Free access is off by default and unreleased, so no stored tags need migrating.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BMeBni56bB19LwDFqNsQEw
… OpenAI key

Treat signed-out, signed-in and subscribed users as three separate systems:

- Signed-out desktops keep dedicated anonymous_inference_* tables with no
  organization, member, user or key columns. Their allowance is keyed on a
  machine id carried in the signed proof, so reinstalling does not reset it.
- Signed-in members of unsubscribed organizations use their regular
  OpenWork Models (ow_inf_) key on /api/v1. The proxy serves them only Auto,
  within a weekly per-person allowance held in inference_free_* tables.
  The separate ow_auto_ credential and inference_free_keys are removed.
- Subscribed organizations keep the existing paid path unchanged.

Free requests no longer touch OpenRouter. Both free paths call OpenAI Chat
Completions with a single INFERENCE_FREE_OPENAI_API_KEY; revoking that key is
the kill switch, and its OpenAI usage shows the running cost. Allowance cost
is computed from OpenAI token counts, and requests OpenAI refuses (401, 403,
429) release their hold instead of being charged.
Guests may use free Auto only from the newest three stable desktop releases,
with every release supported for at least 14 days after it ships. Each stable
release derives its own secret from DESKTOP_FREE_RELEASE_KEY at build time and
tags its signed proof with it (proof v3); the gateway derives the same secret
from the version the proof claims, so a secret lifted from one release cannot
be presented as another and expires with its release.

Knobs: DESKTOP_FREE_SUPPORTED_RELEASE_COUNT, DESKTOP_FREE_SUPPORTED_RELEASE_MIN_DAYS,
DESKTOP_FREE_BLOCKED_RELEASES, DESKTOP_FREE_RELEASE_KEY_PREVIOUS (rotation
overlap), DESKTOP_FREE_FIRST_RELEASE_TAG_VERSION (v2 cutover) and a dev-mode
DESKTOP_FREE_DEV_RELEASE_SECRET for unversioned developer builds. The release
list comes from GitHub and is served stale for up to a day if GitHub fails.
Signed-in members are unaffected.
Guests can assert any machine id, so make a fresh one worth little instead of
trying to prove it: the weekly device allowance ramps with the machine's age
(ANONYMOUS_INSTALL_RAMP, default $0.10 on day 0, $0.25 from day 1, $0.50 from
day 3, full from day 7; a bucket's limit only ever rises within its week),
each IP may introduce only a few never-seen machines a day
(ANONYMOUS_IP_NEW_IDENTITIES_PER_DAY, default 5), and minting a guest session
costs a small proof of work bound to the proof's single-use nonce
(ANONYMOUS_SESSION_POW_BITS, default 20). First sightings live in the guest-only
anonymous_inference_identities table.
…and tighten the proof of work

The device allowance now ramps on active minutes rather than wall-clock age:
every signed guest request is a heartbeat, and the time since the previous one
is credited only when the gap is short enough to mean the app stayed open
(ANONYMOUS_ACTIVITY_MAX_GAP_MS, default 3 minutes). Default tiers: $0.10, then
$0.20 after 10 active minutes, $0.50 after 20, the full $1 after 30.

The session proof of work becomes eight 20-bit puzzles instead of one 23-bit
puzzle, so the time to solve clusters around one to three seconds instead of
occasionally taking many times longer; verification stays eight hashes.
Brings in centralized Gateway usage management (#5139), per-member Google
Vertex sign-in (#5236) and Mistral providers (#5264). Our migration moves to
0111 on top of dev's 0108-0110 with an unchanged table set; the DB test now
upgrades from the 0110 snapshot. dev's shared session-cache helper replaces
our local copy in the management-boundary test.
…uto and split the gateway by audience

Free Auto's rules had to be identical in the gateway, the desktop relay and the
desktop app, but lived as copies in each. They now live once in
packages/free-auto:

- `.`            protocol (routes, headers, proof and release-tag messages,
                 signable routes), proof-of-work parameters and verification,
                 desktop version and release-window rules
- `./accounting` usage cost, reservation size, the activity ramp
- `./node`       SHA-256, release secret and tag HMACs, the proof-of-work solver
                 and a worker built from the verifier's own functions

@openwork/types/desktop-free-access is removed; its contents moved unchanged.

The gateway's thirteen flat free-Auto files become src/free/{guest,member,shared}
behind one entry, with shared/ never importing guest/ or member/. That removes
three inverted imports (request parsing reaching into the guest proof module,
the gate reaching into dispatch for its error helper, config reaching into the
release source for a URL). Behaviour and test counts are unchanged.

The gateway, den and den-gateway images copy and build the new package.
@reachjalil
reachjalil marked this pull request as ready for review September 24, 2026 18:11
@reachjalil
reachjalil requested a review from a team September 24, 2026 18:11
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

OpenWork evidence

Status Commit Preview Updated
⚪ No new preview 089a17c View run 2026-09-30 20:16:29 UTC

No change-specific evidence selected

The deploymentEnabled overrides named this stack's branches and would have
landed in dev's Vercel config; previews build normally again.
Moved down from the picker PR: it is Gateway accounting. A member's free
Auto request writes the same write-ahead Gateway request log as every other
route (route openwork_free, against the member's key); if that record cannot
be written the request fails closed and the reservation is released without
an upstream call. Guest requests are never attributed to an organization.
Migration 0112 adds the openwork_free route to the request-log enums.
…ease window

The release source capped the list at 1 MB, but GitHub's last 20 OpenWork
releases, with notes and assets, are about 1.7 MB. Every refresh was
rejected, so guests would have been refused as desktop_version_unavailable.
The cap is now 8 MB, and a regression test uses a list of realistic size.
@vercel

vercel Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
openwork-app Ready Ready Preview Sep 30, 2026 8:16pm UTC
openwork-den Ready Ready Preview Sep 30, 2026 8:16pm UTC
openwork-diagnostics Ready Ready Preview Sep 30, 2026 8:16pm UTC
openwork-landing Ready Ready Preview, v0 Sep 30, 2026 8:16pm UTC

@vercel
vercel Bot temporarily deployed to Preview – openwork-landing September 28, 2026 22:30 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-app September 28, 2026 22:30 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-den September 28, 2026 22:30 Inactive
dev added migration 0114 (audit operation capture), so the free Auto
migration is regenerated on top of it as 0115_free_auto_and_provider_pins
(same statements). Provider create keeps dev's audit-assigned id and the
pins column. openapi.json and the SDK are regenerated.
Free Auto now follows the paid Models pattern. Before a request it checks
that each window's used total is below its limit. Afterwards it charges the
real cost once, keyed on OpenAI's completion id. When no usage report
arrives, it charges a fixed estimate. Nothing is held up front, so parallel
requests from one person (subagents, parallel chats, title generation) run
as they do on paid Models.

Removed: reservations and reservation charges, the single-row control
tables, the one-request-per-person lock, the global in-flight count, the
per-IP daily spend window, the member global caps, the per-request and
per-proof rate counters, the 4,096-token output cap, the input-size
pre-check, and the whole-stream timeout.

Migration 0115 is regenerated with seven tables: usage windows and one
usage record per request (for guests and for members), plus machine
identities, proof signatures and the new-machine counter.

This branch was successfully deployed

5 active deployments
Preview – openwork-landing — 089a17c7 Deployed Sep 30, 2026 by vercel[bot]
Preview – openwork-den — 089a17c7 Deployed Sep 30, 2026 by vercel[bot]
Preview – openwork-app — 089a17c7 Deployed Sep 30, 2026 by vercel[bot]
staging - packages/docs — 089a17c7 Deployed Sep 30, 2026 by mintlify[bot]
Preview – openwork-diagnostics — 089a17c7 Deployed Sep 30, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants