IamBishal
AuthorAI / LLMDeveloper ToolsFeatured

Agent Doorway

Every AI call comes through one door: checked, metered and on the record.

A self-hostable control plane for company AI: one gateway in front of LLM providers and MCP tools that enforces identity, policy, budgets, reliability and a tamper-evident audit log on every call.

Agent Doorway cover: indigo background with the headline and a terminal showing x-doorway response headers, a team's budget warning then a 402, and a tampered audit row caught.
Your role
Author
Language
Python
License
MIT
Status
Active

Overview

Why it exists

Companies now have many apps and agents calling LLM providers and MCP tools directly, each with its own keys, no shared spending limits, no consistent safety checks and no reliable record of who did what. Agent Doorway sits in front of those calls and puts every one of them through the same door.

Apps keep using the official OpenAI and Anthropic SDKs; only the base URL and the key change. Each call is authenticated, rate limited, checked against the tenant's YAML policy (allowed models, prompt-injection guardrails, PII redaction, tool permissions) and its monthly budget, then dispatched with retries, an ordered fallback chain and a circuit breaker per provider and model. Tool calls are validated against their JSON Schema before the client sees them, and agents reach their team's MCP servers through the gateway, with hidden tools refused, egress to internal addresses blocked and idempotent writes that run once.

Every call leaves a usage record with exact cost in integer micro-dollars and a row in a per-tenant hash chain whose head is signed with an Ed25519 key, so doorway audit verify catches an edited row and a full rewrite alike. Prompts are stored only as hashes unless a tenant opts into redacted or full capture with a retention period.

It is a reference implementation: every design decision is written down as an ADR, with a threat model, OpenTelemetry traces, Prometheus metrics, two provisioned Grafana dashboards, an admin API and console, a load test and a Helm chart. The built-in mock model means the whole thing runs with no provider key.

Topics

  • AI governance
  • Agentic AI
  • Platform engineering

Features

What it can do

  • Drop-in for the official OpenAI and Anthropic SDKs, streaming included: change the base URL and the key
  • Retries with full-jitter backoff, ordered fallback chains, a circuit breaker per target and token-bucket rate limits
  • Per-tenant YAML policies with hot reload: allowed models, prompt-injection guardrails and PII redaction
  • Tool calls checked before the client sees them: declared, valid against the JSON Schema and allowed for the team
  • MCP proxy with per-team tool lists, egress checks and idempotent writes
  • Usage and cost per tenant, team, key and task, in exact micro-dollars, with monthly budgets (warning, then 402)
  • Tamper-evident audit log: a hash chain per tenant with an Ed25519-signed head; prompts kept only as hashes
  • OpenTelemetry traces, Prometheus metrics and two provisioned Grafana dashboards
  • Admin API, a read-only console and a CLI over one service layer, with separate admin keys
  • Runs with no provider key: a built-in mock model for demos, tests and CI

Quick start

Up and running

  1. Start the stack

    Requires Docker. Postgres, Redis, migrations and the gateway; no provider key needed.

    Terminal
    git clone https://github.com/bishal-saha/agent-doorway.git && cd agent-doorway
    docker compose up -d --build --wait
  2. Create a tenant, a team and a key

    The key is printed once; only its sha256 hash is stored.

    Terminal
    docker compose exec gateway doorway tenants create acme --name "Acme Ltd"
    docker compose exec gateway doorway teams create acme support
    KEY=$(docker compose exec -T gateway doorway keys create acme support --name demo)
  3. Send a request

    The built-in mock model answers every request.

    Terminal
    curl localhost:8080/v1/chat/completions \
      -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
      -d '{"model": "mock", "messages": [{"role": "user", "content": "Where is my order?"}]}'
  4. Or use the official SDK

    Only the base URL and the key change.

    Python
    from openai import OpenAI
    
    client = OpenAI(base_url="http://localhost:8080/v1", api_key=KEY)
    client.chat.completions.create(model="mock", messages=[{"role": "user", "content": "hi"}])

Tech stack

Built with

Language
  • Python 3.12
Gateway
  • FastAPI
  • httpx
  • MCP SDK
Data
  • PostgreSQL
  • SQLAlchemy
  • Alembic
  • Redis
Security
  • Ed25519 signed audit chain
  • JSON Schema
  • PII redaction
Observability
  • OpenTelemetry
  • Prometheus
  • Grafana
  • Tempo
Console
  • Jinja
  • htmx
  • Pico CSS
Delivery
  • Docker Compose
  • Helm

Screens

A look inside

01Quick start: one key, one door
02Guardrails per tenant policy
03Tamper-evident audit log

Bishal SahaLet's build together

Have a system to design, or an AI feature to get right?

Tell me about the problem. You'll get a clear, honest view of the best way forward.

  • Reply within 24 hoursOn business days, with my honest view and a next step.
  • Accepting select engagementsArchitecture, AI features and full builds.
  • Remote, worldwideWorking with startups, SMEs and enterprises.