Skip to content

About

IAM-aware LLM gateway with OpenRouter and direct provider routing

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

OpenGranter routes client requests through identity, policy, and limits to approved OpenRouter or direct-provider destinations, with audit and usage records

OpenGranter

Control who can call which LLM — and account for every attempt.

Repository checks Node.js 22.14 or later In development

Evaluate locally · Documentation · Compatibility · Contribute

OpenGranter is an LLM access-control gateway for a single organization. It combines user and role policies, approved model/provider routes, usage accounting, and audit records behind compatible chat boundaries. Use an OpenRouter-delegated route or a managed route to registered OpenAI, Anthropic, and Google Gemini providers without treating routing as an authorization bypass.

Development status: this repository contains tested gateway modules, HTTP boundaries, PostgreSQL adapters, and an engineering harness — not a packaged, production-ready service. Deployment startup and remaining management and operational release gates are still in progress. The images below show architecture and local verification, not a shipped management dashboard. See the roadmap and acceptance scenarios.

Why OpenGranter?

  • Authorize the destination, not just the API key. Evaluate both the model and final inference provider. Default Deny and explicit Deny precedence remain in effect across supported paths.
  • Keep routing inside policy. Select only approved candidates; fallback stays within a route kind. Caller-supplied arbitrary upstream URLs are not a proxy feature.
  • Separate access from provider credentials. Gateway identity and attachment controls are distinct from administrator-registered upstream secret references.
  • Make accounting limitations visible. Preserve per-attempt usage and audit evidence; missing usage and possibly billed failures must not masquerade as zero cost. Estimated cost is not provider-billed cost.
  • Measure compatibility instead of assuming it. Contract tests, pinned structural schema checks, and bounded external-client conformance record what has actually been verified.

How a request flows

  1. Authenticate the caller and resolve their current principal and attachments.
  2. Resolve approved route candidates and evaluate the complete enforceable model/provider scope.
  3. Check limits before invoking an allowed upstream.
  4. Record attempt usage and the required audit outcome, including supported failure paths.
Route Upstream boundary Authorization boundary
OpenRouter-delegated A registered OpenRouter upstream Model and enforceable final-provider scope; constrained routing/fallback
Managed Registered direct OpenAI, Anthropic, or Google Gemini adapter Model and final provider; managed selection among allowed candidates

The diagram is a conceptual overview, not a timing guarantee for every persistence operation. Read routing and architecture for ordering and failure semantics.

Capability map

“Implemented” here means repository modules and tests, not a deployable release or exhaustive provider certification.

Area Repository evidence Boundary to keep in mind
Identity and policy Principal/role evaluation, attachment authentication, policy simulation Internal IAM-style engine, not AWS IAM integration
Gateway and routing Chat/model HTTP boundaries, Node socket bridge, managed/delegated coordination No turnkey service startup; only registered, approved destinations
Providers and streams OpenRouter, OpenAI, Anthropic, Gemini adapters; bounded text, tools, image, and streaming cases Exact fields, combinations, and clients are bounded by the compatibility matrix
Persistence and accounting PostgreSQL adapters and migrations, usage ledger, audit and export modules Application-owned connection lifecycle, secrets, retention, and operational controls
External clients Pinned OpenAI/OpenRouter SDK, AI SDK, and OpenCode conformance cases Controlled fixtures are not live-provider or all-workflow certification

Start with the compatibility matrix, AI SDK evidence, and OpenCode evidence before choosing a client workflow.

Evaluate locally

Requires Node.js 22.14 or later, npm, and Python 3.11 or later for document checks. This is a source checkout, not an npm package installation.

git clone https://github.com/Theorvane/OpenGranter.git
cd OpenGranter
npm ci
npm run check

npm run check runs TypeScript checks, linting, tests, document/contract checks, and offline validation of reviewed OpenRouter structural pins. It does not start a gateway or call live inference providers. Without an explicit test database URL, real PostgreSQL integration tests skip; unit and embedded database tests still run.

For a smaller first look, run the policy and routing contracts:

node --experimental-strip-types --test --test-reporter=spec \
  test/policy.contract.test.ts test/route.contract.test.ts

Actual local verification

Visualization of a real local policy and routing contract run; see the accompanying transcript and reproduction notes for exact results

Actual local contract-test output rendered as a terminal-style visualization, not a product UI or live-provider session. See asset provenance and reproduction and the raw transcript. A focused passing run is not a production-readiness claim.

Continue with the evaluation guide for PostgreSQL checks, schema drift, and deployment responsibilities.

Documentation

I want to… Start here
Understand the product and release gates Requirements · Acceptance · Roadmap
Evaluate the source checkout Local evaluation · Engineering harness
Integrate a compatible client OpenRouter compatibility and setup
Understand authorization and routing Routing contract · Architecture
Find detailed contracts and decisions Documentation index
Continue development as a contributor or agent Contributing · Agent handoff · Coding rules

Contributing

Open an issue, write an English implementation plan, use an issue-numbered branch, and submit a pull request. Production-code changes follow red–green–refactor; documentation-only changes run applicable checks. Contributions require a human DCO sign-off and disclosure of material AI assistance. See CONTRIBUTING.md.

Repository documentation is written in English. CLAUDE.md links to AGENTS.md. Planning interviews use the grill-with-docs skill, with agreed terminology in CONTEXT.md; upstream skill licensing is preserved in skills/LICENSE.

Service process adapter

For an explicit deployment-owned bootstrap, validated listener settings and bounded signal shutdown, see running the gateway service. This is not a turnkey deployment or a built-in quota/secret-manager implementation.

Codex device OAuth (operator authentication only)

See Codex OAuth setup for isolated official-CLI login/status/logout. Subscription-backed model inference through the gateway is not implemented by this command.

About

IAM-aware LLM gateway with OpenRouter and direct provider routing

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages