Skip to content

About

Rust multi-tenant model gateway with governed workspaces and a React dashboard

Resources

Security policy

Accessibility

Stars

4 stars

Watchers

0 watching

Forks

Repository files navigation

Open Model Gateway

A single-enterprise inference gateway: Rust/Axum/Tokio/SQLx + PostgreSQL 17, with a React/Vite management SPA served by Rust. Node.js is a build/test dependency, not a production application server.

Development software. The enterprise rebuild is undergoing integrated acceptance. Local checks do not establish production readiness, real-IdP acceptance or universal provider compatibility. The approved requirements are in enterprise rebuild; current execution evidence belongs in verification.

Enterprise boundaries

  • One installation is the enterprise boundary. Teams, Projects and owner-private personal workspaces are sibling security scopes; there is no organization picker or organization API.
  • Platform Admin, Auditor and User are explicit entitlements, separate from successful SSO. Admin/Auditor include User. Shared workspaces have independent owner/admin/member grants.
  • Generic, signed OIDC groups synchronize at sign-in. Manual grants survive mapped-source removal. Entitlement loss revokes human sessions/keys, with a 30-day grace period and automatic cleanup retaining accounting/audit history. Group loss is not detected between sign-ins in this release.
  • Personal keys/request details remain private even from Platform Admin/Auditor; platform reports show a personal workspace's identity with its usage, cost and storage totals and its platform-managed configuration (see platform administration). Shared members see their own activity; administrators see shared-workspace activity.
  • Models are selected from multiple available catalogs or assigned directly. Live type defaults and replacement overrides govern eligibility; losing access never restores retired key selections when eligibility returns.

The dashboard follows Grounded's Bitop UI and Workspace/Admin composition, with gateway-specific permissions and resources. See dashboard, management API and Bitop provenance.

What works today

  • Workspace: Home, Models (catalog, model compare), API keys (one-time disclosure, rotate/disable/revoke, per-key models and limits, key safety findings), Logs (requests, generations, sessions), Usage & costs, Settings and Alerts for Team/Project admins.
  • Admin: Users, Teams, Projects, SSO group mappings, Connections (OpenAI, Anthropic, OpenRouter, AWS Bedrock with default/profile/role access modes, approved local endpoints), Models with routes and immutable prices, Catalogs and defaults, limits and budgets, cost centers, Logs and Usage (Team/Project rows only), key safety, audit, Settings (general, limits, data & privacy, email, sign-in) and Alerts (budget thresholds, spend spikes, error rates, failing connections; in-app and email). Auditors get the same views read-only.
  • Alert webhooks: saved platform receivers with HMAC-signed bounded delivery, a fixed test send and redacted status, administered in Admin › Settings › Alerts › Webhooks (Auditors read-only); see alerts.
  • Provider-reported cost reconciliation: Admin › Usage & costs › Provider reconciliation; Admins upload Anthropic Cost Report JSON, attest mappings and freeze comparisons, Auditors read only. Signed charges, unknown variance, separate holds and identity-free personal totals; no financial-history rewrite or verified invoice. Anthropic/USD only; OpenAI Costs export is follow-up #393 (workflow).
  • Checks: Rust unit/integration tests on real PostgreSQL, mock-provider and SDK contracts, Vitest, and a Playwright journey with axe accessibility scans for every persona (verification, accessibility).

Planned, not implemented: content guardrails beyond input secrets and custom patterns (redaction, output inspection and model detectors: #841–#846), an OpenRouter video adapter (video has no supported provider: OpenAI shut down the Sora 2 models and the Videos API on 2026-09-24), video remix/edits/references, native batches beyond OpenAI and Anthropic, image edits, token-by-token Responses/Messages streaming, OpenAI Costs export support (#393). See roadmap.

Local account picker

See local demo for the fresh, loopback-only gateway_enterprise_demo database and five personas: Platform Admin, Auditor, Alex (workspace administrator), Blair (member), and an authenticated but unentitled SSO user.

The demo has disabled example deployments and illustrative prices, not paid credentials or fabricated usage. Personal workspaces are provisioned on actual entitled sign-in. Existing databases are never reset or upgraded into the enterprise schema.

Initialize a new installation

Prerequisites: current stable Rust, Node.js 22.12+, npm and PostgreSQL 17 (Docker Compose is provided).

cp .env.example .env
npm ci
docker compose up -d --wait postgres
cargo run -p open-model-gateway -- migrate

The explicit migration command performs read-only compatibility checks before DDL. Only an empty database or a recognized enterprise migration prefix is accepted. Legacy migrations remain historical evidence, not an upgrade path. serve requires the exact current enterprise lineage and never migrates implicitly.

Configure your registered OIDC issuer/client and ${GATEWAY_PUBLIC_URL}/api/v1/auth/callback; production requires HTTPS. The signed ID token must contain a verified email and the configured groups claim (default groups). Missing/malformed groups fail closed without erasing prior grants. Establish the first administrator through trusted provisioning:

cargo run -p open-model-gateway -- provision-user \
  --email operator@example.org --platform-admin

This grants entitlement and permits one controlled initial verified-email link; it does not authenticate a user or rebind an existing identity. Configure group mappings through Admin afterward. Never put credentials in VITE_* variables or upload provider secrets through the browser. See identity.

cargo run -p open-model-gateway -- serve
# Optional Vite development proxy, in another terminal:
npm run dev:web

For a matched, Rust-served deployment:

npm run build:web
GATEWAY_WEB_DIR=apps/web/dist cargo run -p open-model-gateway -- serve

Keep the binary and compiled SPA from the same verified revision. Use a separate output directory for acceptance builds; never overwrite a running UI with an unverified build.

Inference and accounting

Route Supported workload
GET /health/live, /health/ready Liveness and exact migration readiness
GET /v1/models Live workspace-authorized, enabled aliases
POST /v1/chat/completions Bounded text/function-tool subset
POST /v1/responses Stateless text/function-tool subset; OpenAI
POST /v1/messages Text/tool subset; Anthropic and Bedrock
POST /v1/embeddings String/string-batch input, float or base64 vectors; declared embedding profiles
POST /v1/rerank {model,query,documents,top_n?} → scored indices; OpenRouter
POST /v1/systemone TypeSafe System One contract (TypeSafe SDK compatible); OpenRouter
/v1/videos, /v1/files, /v1/batches Gateway Files API; batches for any model (native OpenAI/Anthropic batch APIs or gateway-run lines, batches), workspace-owned gateway ids. /v1/videos returns unsupported_capability: no supported video provider since OpenAI's Videos API shutdown (2026-09-24) (async jobs)
/api/v1/* Browser-session management with exact-Origin/CSRF checks

Inference keys never authorize management. Model-declared protocols must intersect adapter support. OpenAI, Anthropic, AWS Bedrock and OpenRouter have separate adapters; local vLLM, SGLang, Ollama and generic-compatible profiles have explicit, narrow contracts. Local HTTP requires exact server-controlled endpoint approval and pinned IP destinations; cloud requires HTTPS. Redirects, ambient proxies and implicit retries are disabled.

  • Fixed-minute request/token quotas, leased concurrency and hard USD budgets per UTC day, ISO week or calendar month (chosen per policy layer) are shared across replicas. There are no installation-wide limits; an installation spend alert reports total spend without blocking.
  • Immutable prices pin each attempt. Cache reads and disjoint write allocations are accounted without double charging aggregate writes. Amounts use exact integer micro-USD arithmetic.
  • Unknown usage/rates are not zero. Partial known charges are not finite upper bounds. Monetary-budget requests without a finite admission bound are denied before dispatch; unresolved activity retains conservative holds.
  • Embeddings are an input-only workload, not synthetic chat. Local prices are configured token rates, not measured GPU/electricity costs.
  • Routing supports priority/weight, residency labels, passive cooldown and at most three explicitly permitted attempts. No failover follows a returned stream. After a cooldown, one real request per route decides whether traffic resumes; the gateway sends no synthetic health probes (routing).
  • Reports use strict UTC date intervals, known actual versus active held amounts, explicit accounting coverage and optional admission-time cost-center snapshots. Costs are configured estimates, not provider invoices.

See protocol matrix, providers, cache pricing, governance and reports. Base64 image generation (/v1/images/generations, OpenAI gpt-image-* and OpenRouter) is a bounded first increment, as are audio transcription (/v1/audio/transcriptions) and speech (/v1/audio/speech) for OpenAI and OpenRouter. Chat Completions batches (OpenAI) are one attempt and reservation each, polled in the background and mock-tested only; video jobs share that path but have no supported provider until the planned OpenRouter video adapter (async jobs). Inline image input (base64 data URLs) works on Chat Completions through the OpenAI, OpenRouter, local OpenAI-compatible, Anthropic and Bedrock adapters and on Responses through OpenAI, on deployments an admin opts in (image input); image edits are not implemented yet. Realtime audio is a bounded OpenAI WebSocket subset whose per-response holds are sized from the session's context (realtime). Native Responses and Messages SSE stream text deltas as they arrive; tool calls are delivered whole.

Verification and deployment

cargo fmt --all -- --check
cargo clippy --workspace --all-targets --all-features -- -D warnings
# SQLx creates disposable databases; use a dedicated test PostgreSQL role.
DATABASE_URL=postgres://gateway:gateway@127.0.0.1:54339/gateway \
  cargo test --workspace --all-features
npm run typecheck:web
npm run test:web
npm run test:demo
npm run test:container   # builds the image; needs Docker
npm run test:supply-chain   # needs Bash 4.4+ first on PATH (macOS's /bin/bash 3.2 is refused)
npm run test:staging
npm run build:web
# Playwright + axe against a disposable database on 54339 (never the demo):
npm run test:browser

Date dependency ownership, bounded compatibility contracts and the private SDK update procedure are documented in datetime maintenance.

CI scans pull requests, pushes to main and v* tags for committed secrets (gitleaks, pinned; .gitleaks.toml). An optional pre-commit hook runs the same scan locally (python3 -I scripts/secret-scan.py staged); what to do when it flags something is in verification.

Mock-provider and SDK tests require no paid calls or real enterprise IdP modifications. See staging for restricted runtime roles, the image, TLS rehearsal and backup/restore tooling, and Kubernetes for the Helm chart (explicit migration Job, optional CloudNativePG Cluster/Pooler, NetworkPolicy, loadtest profile). Use a new enterprise staging database; do not run initialization against an existing legacy deployment. Production load/availability, real-provider certification, full live IdP acceptance, observability and off-host recovery acceptance remain unfinished. Live SCIM acceptance has passed once, against Authentik on v0.9.1 (SCIM), and has not been repeated on a later release.

Releases and security

  • Current release: v0.19.0 improves batch cancellation, retry recovery and route capacity during takeover. Drain the gateway, apply migrations 0084–0087, and update runtime grants. Images now publish under ghcr.io/bitop-dev/open-model-gateway. Upgrade guide · Previous release.
  • Earlier patch scope: v0.9.1 refreshes the supported runtime and CA trust store, isolates image publication and fixes dashboard navigation/accessibility. No migrations or new provider capabilities; validate outbound TLS before upgrading. v0.9.0 adds scheduled cost reports (#102), signed alert webhooks with a dashboard (#45), bounded key issuance and fair alert dispatch (#253, #277), aged unknown-hold alerts (#101), opt-in OTLP metrics and operational logs (#99, #294) and Claude Code native Anthropic fidelity (#70). It adds migrations 0053 to 0067 (schema 0067): stop old alert evaluators before migration 0059 and every older replica before 0067, then run migrate and grants apply explicitly. Breaking: local-upstream approvals in special-use ranges are now refused at startup (#203); see the upgrade notes. Upgrading from v0.6.1 also requires the v0.7.0 allowlist precautions. The broader #222 compatibility program is not complete. Publication and deployment acceptance are separate gates.
  • Releases: changelog and per-release notes in docs/releases/ (migrations, new settings, upgrade steps, known limitations). Upgrades are explicit: back up, migrate, reapply runtime grants, budget verify.
  • Images: new builds publish to ghcr.io/bitop-dev/open-model-gateway after the repository transfer. Published releases from v0.3.0 through v0.18.0 remain at ghcr.io/ncecere/open-model-gateway with their original signing identity; old tags were not copied. Release images for both architectures (linux/amd64, linux/arm64) carry SBOM/provenance attestations and a cosign keyless signature. Each architecture's exact digest passes the isolated staging rehearsal and a Trivy scan before it is tagged. Deploy by digest and verify the matching signature first. v0.1.0 and v0.2.0 have no published images. After v0.3.0 the runtime image is distroless (no shell or curl): the binary is the entrypoint, reads *_FILE secrets itself and provides open-model-gateway healthcheck (container image).
  • Security: report vulnerabilities privately as SECURITY.md describes. Only the latest minor release (0.19.x) gets fixes.

License

MIT. Copyright (c) 2026 Nicholas Cecere.

About

Rust multi-tenant model gateway with governed workspaces and a React dashboard

Resources

Security policy

Accessibility

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages