LLM gateway · Cost · Security · Reliability

Your model spend, itemized to the token — including the part you’re wasting.

ModelGate sits between your application and OpenAI, Anthropic, Gemini and Azure. Every request is logged, priced against a versioned rate table, and scored for waste. The same gateway screens traffic for prompt injection, secrets and personal data — and scores whether your bot is reliable: stable, in format, and consistent. Three axes, one integration. No estimates, no sampling.

  • No card to start
  • Prompts not stored by default
  • Optimizations off by default
  • Cancel anytime
Statement of spendIllustrative · synthetic data
Total spend · 30d$172.55billed by providers
Recoverable$24.5614.2% of spend
Requests21,500all logged
Waste score41/100average, medium
Spend over time billed recoverable
$0$5$10$15$20Jun 5Jun 12Jun 19Jun 26Jul 3
Top waste reasons
  • Repeated prompts38%
  • Large context31%
  • Premium model, small task17%
  • Low output vs input14%
Illustrative cost by model over thirty days
gpt-4o6,000 requests$114.00
claude-sonnet-52,000 requests$42.00
gemini-2.5-pro1,500 requests$13.13
gpt-4o-mini12,000 requests$3.42
Synthetic example, not customer data. Every dollar figure is computed from ModelGate’s published rate table.
Works withOpenAIAnthropicGoogle GeminiAzure OpenAI

Sample audit

Change the request. Watch the ledger and the rules move.

Sample requestWorked example

A retrieval pipeline stuffing the whole context window to get a short answer.

System: You answer only from the supplied documents.
User: [12 retrieved passages] — Which clause covers early termination?
What the gateway recordsgpt-4o · $2.50 in / $10.00 out per 1M
Input$0.01506,000 tokens
Output$0.001800180 tokens
Charged$0.0168billed by the provider
Waste score30/100Medium
RuleFires whenWeight
EXPENSIVE_MODEL_SMALL_REQUESTpremium model name, and input + output ≤ 400 tokens
LARGE_CONTEXTPROMPT_COMPRESSIONinput ≥ 4,000 tokens+20
REPEATED_PROMPTthis exact prompt hash was seen before, and was not served from cache
LOW_OUTPUT_VS_INPUTMAX_TOKENS_REDUCTIONoutput × 4 < input+10
LATENCY_ISSUElatency ≥ 8,000 ms
ERROR_WASTEthe request errored — you paid for nothing
Waste scoresum of the rules that fired, capped at 10030

Computed in your browser from ModelGate’s published rate table and the same rule set the gateway applies. Token counts are yours to change — a real request’s counts come from the provider.

Read the full integration guide →

Integration

One change. That’s it.

No new client library and no request rewriting. The gateway speaks the OpenAI chat-completions dialect and forwards to whichever provider owns the model you named.

Beforeapp.py
client = OpenAI(
    base_url="https://api.openai.com/v1",
    api_key=OPENAI_KEY,
)
# cost: unknown   waste: unknown
Afterapp.py
client = OpenAI(
    base_url="https://gw.modelgatehq.com/v1",
    api_key="unused",   # ModelGate reads x-api-key
    default_headers={"x-api-key": MODELGATE_KEY},
)
# every call logged, priced, scored

Requests route through the gateway

ModelGate authenticates your key, applies your rate, token and spend ceilings, and forwards the call using the provider credential you stored. Prompt bodies are not persisted unless you ask for it.

Each call is priced exactly

Token counts come from the provider; rates come from a versioned table. Fixed-point arithmetic, no floating-point drift — and if a model has no published rate, the call is logged without a cost rather than with a guess.

Waste is flagged and quantified

Six rules produce a 0–100 score and named flags, and a worker turns them into recommendations carrying a computed saving, a confidence level and a risk rating.

One thing worth knowing before you switch: authentication is the x-api-key header rather than Authorization: Bearer. stream: true works and returns OpenAI-format SSE — the one exception is a project running outbound secret/PII enforce, where a stream would be refused because redaction can’t be applied mid-stream.

What the audit finds

Three ways teams quietly overpay — and what the gateway does about each.

The waste rules are deterministic and published. If one of these matches your setup, the finding lands on your dashboard with the flag that raised it.

Repeated prompts

Your assistant answers the same question all day.

A support bot or internal helpdesk fires near-identical prompts thousands of times a week — same system prompt, same FAQs — and pays the provider in full for each one. ModelGate hashes the normalized prompt, sees the repeat, and can serve it from an exact cache.

Waste flag raisedREPEATED_PROMPT
Optimization proposedCACHE_CANDIDATE
What a cache hit costs$0.00

Premium model, trivial task

You're running a flagship model to label a sentence.

Sentiment tags, field extraction, short classifications — work a value-tier model handles — quietly run on a premium model. ModelGate flags the mismatch, and with routing switched on it moves small, simple, low-temperature GPT-4-family calls to gpt-4o-mini.

Waste flag raisedEXPENSIVE_MODEL_SMALL_REQUEST
Optimization proposedMODEL_DOWNGRADE
gpt-4o → gpt-4o-mini per token−94%

Context beyond usefulness

You send 6,000 tokens to get a 180-token answer.

RAG pipelines and long chats keep stuffing history into every request well past the point it changes the answer. ModelGate records the input-to-output ratio on every call, so the features where context stopped earning its cost are visible rather than assumed.

Waste flags raisedLARGE_CONTEXT · LOW_OUTPUT_VS_INPUT
Optimizations proposedPROMPT_COMPRESSION · MAX_TOKENS_REDUCTION
Thresholdsinput ≥ 4,000 · output × 4 < input

Security by design

Every request already passes through here. So can your security policy.

One place to screen traffic across every model and provider, with no application changes. Each category is off until you turn it on: detect records incidents without touching a request, enforce blocks or redacts. These are pattern-based detectors, not guarantees — we describe exactly what they match so you can judge the fit.

Inbound

Prompt-injection signals, scored.

Ten weighted signals — instruction override, system-prompt exfiltration, role hijack, jailbreak personas, safety bypass, chat-template injection, zero-width characters and more — score the untrusted part of every request from 0 to 100. It is a heuristic: it catches the common families, not every phrasing.

Recorded as an incident atscore ≥ 35
Refused with 403 in enforce mode atscore ≥ 50

Outbound

Known secret patterns, redacted.

Seventeen credential signatures — provider keys, AWS and Google keys, GitHub and Slack tokens, Stripe keys, PEM private keys, JWTs, bearer tokens, database URLs with passwords — plus a Shannon-entropy pass for tokens no signature knows.

Detectedsignature + entropy
Replaced in enforce mode with[REDACTED:RULE_NAME]

Outbound

Personal data, masked before it leaves.

Email addresses, Luhn-valid card numbers, structurally valid US Social Security numbers, phone numbers, IP addresses and IBANs. Overlapping matches resolve to the most severe, so a card number is never filed away as a phone number.

Card numbersLuhn-checked
Masked in enforce modebefore the response returns

At rest

Keys sealed, prompts not kept.

Your provider credentials are encrypted with AES-256-GCM under a master key held outside the database, and only a first-four-last-four hint is ever shown back. ModelGate API keys are stored as salted HMAC-SHA256 digests and compared in constant time.

Prompt bodies storedonly if you switch it on
Incident records keepa masked snippet, never the value

View the security architecture →

Reliability by design

Cost is what your bot spends. Reliability is whether you can trust it.

The gateway sees every answer, so it can score whether your bot is stable — same task, same answer; in format; not contradicting itself as a conversation grows — and show what’s confusing it. Deterministic checks are free and always leading with the evidence; judge-based checks and active tests are an add-on.

Synthetic conversationIllustrative · synthetic data

The same labelling task, asked four ways. A reliable bot gives one answer regardless of phrasing.

Classify the sentiment. Reply as JSON {label}.
#1{"label":"positive"}
#2{"label":"positive"}
#3{"label":"positive"}
#4{"label":"positive"}
What the gateway recordsmean pairwise agreement · deterministic detectors
Consistency100/100Stable
Answers flagged0of 4
Worst pair#1·#2agree 100/100
DetectorFires whenHits
FORMAT_VIOLATIONJSON/shape was requested and the answer didn't parse
DEGENERATEempty, truncated, or a repetition loop
REFUSALthe answer reads as a refusal / deflection
Consistency scoremean agreement across every answer pair100

Computed in your browser with the same shape of logic the gateway applies — a consistency score plus deterministic detectors, no model call. The score is an estimate; the flagged answers are the evidence.

See how reliability works →

Controls

Visibility is always on. Everything that changes a request is not.

Logging, pricing and scoring ship on. Every optimization and every guardrail ships off, as a per-project setting you raise when you trust it — with a middle setting that only recommends.

Request logging & pricingEvery request — including failures — is logged and priced against the versioned rate table.Always on
Waste scoreA 0–100 score with named flags on every completed request: repeated prompt, large context, premium model on a small task, low output vs input, latency, error waste.Always on
Provider credential encryptionAES-256-GCM with a master key held outside the database. Only a masked hint is ever displayed.Always on
Exact response cacheDeterministic requests only — temperature 0, no tools, no response format. 24-hour entries; a hit costs nothing and records the original call's cost as the saving.Off → Recommend → Auto
Model routingSmall, simple, low-temperature GPT-4-family calls can move to gpt-4o-mini. Features or endpoints named legal, medical, financial or security are never downgraded.Off → Recommend → Safe auto
Prompt-injection scan (inbound)Scores untrusted input; enforce refuses high-risk requests with 403 before a provider is called.Off → Detect → Enforce
Secret-leak scan (outbound)Signature and entropy detection on the response; enforce replaces the value with a redaction marker.Off → Detect → Enforce
Personal-data scan (outbound)Emails, cards, SSNs, phones, IPs, IBANs; enforce masks them before the response is returned.Off → Detect → Enforce
Reliability detectors (deterministic)Format breaks, degenerate/looping output and refusals, plus a consistency score and daily trend — computed inline on live traffic. Free on every plan.Detect by default
Reliability detectors (judge)Self-contradiction, instruction drift and grounding — read a whole conversation with a model call. Need response capture and the Reliability add-on.Off → Detect → Enforce
Prompt storageRequest bodies are stored only when you enable it per project — for richer recommendations. Responses are stored only if you opt into reliability response capture (retention-capped); metadata and one-way hashes are always kept.Off by default
Provider failoverOne retry, then your secondary provider — for transient failures only (5xx, 429, network). A 4xx is returned as-is.Configurable
Rate, token & spend ceilingsRequests per minute, maximum prompt and output tokens, and a monthly spend cap enforced before the provider is called. New projects start at 60/min, 8,000, 1,024 and $5.Configurable
Streaming responsesstream: true forwards SSE chunks in the OpenAI format across every provider. Cost, tokens and the waste score are computed on the assembled response when the stream closes.Supported (except under outbound enforce)

Open source

Prefer to run the gateway yourself? Start with ModelGate OSS.

An open-source, local-first LLM gateway for cost visibility, usage analytics, and basic heuristic security signals. Point your OpenAI or Anthropic client at it and every call is logged, priced and scored on your own machine — no ModelGate account, no telemetry. It’s the same idea as ModelGate Cloud, small enough to read end to end.

Open source · Apache 2.0 · Early v0.1.0
  • OpenAI Chat Completions & Responses
  • Anthropic Messages
  • Incremental streaming relay
  • Token & estimated cost tracking
  • Latency & error visibility
  • Repeated-request detection
  • Transparent heuristic security rules
  • Searchable local dashboard
  • Local SQLite storage
  • Prompts & responses not stored by default
  • No ModelGate account required
  • No ModelGate telemetry
Quick startDocker Compose
git clone https://github.com/razdgann/modelgate-oss.git
cd modelgate-oss
cp .env.example .env
docker compose up --build
The ModelGate OSS local dashboard: a searchable request ledger with tokens, latency, estimated cost and a waste score per call.
The local ModelGate OSS dashboard, shown with deterministic demo data — not production traffic.

ModelGate OSS

Runs on your machine

  • Local gateway
  • Local observability
  • Estimated costs
  • Basic heuristic signals
  • Local storage & dashboard

ModelGate Cloud

Managed, and a step further

  • Managed infrastructure
  • Continuous optimization
  • Advanced runtime protection
  • Shared team analytics
  • Longer retention
  • Commercial optimization recommendations

ModelGate OSS v0.1.0 is an early release and is not yet recommended for critical production workloads without your own validation.

Raz Dagan

Built by people you can reach.

Raz DaganFounder, ModelGate

System engineer with a background in physics, mathematics and AI. Building ModelGate to make LLM infrastructure more transparent, efficient and secure.

Start free. See your spend from the first request.

Three months free, no card. The ledger fills as your traffic arrives, and nothing changes about how your application calls a model until you decide it should.

Follow ModelGate in Google Search — make us a preferred source: