Skip to main content

AI Gateway vs API Gateway: What Each One Does

· 9 min read

An API gateway manages HTTP traffic to your services: TLS, authentication, routing, request-rate limits and access logs. An AI gateway reads what is inside AI traffic — the model, the tokens, the prompt, the tool call — and applies controls to it: personal-data checks, prompt-injection guardrails, model and tool policy, token budgets, provider translation and an audit record of each call. Most teams need both. The API gateway stays at the edge, and the AI gateway sits behind it on the path to model providers, tool servers and other agents.

Updated November 9, 2026 for DVARA 1.13.0. This rewrite replaces the March 2026 version and its August correction note.

DVARA is an AI gateway that governs model, tool and agent-to-agent calls, and deploys anywhere. This post explains the difference in plain terms, says where API gateway products have added AI features, and shows what each layer records about the same call.

What is the difference between an AI gateway and an API gateway?​

The difference is what the gateway reads. An API gateway treats a request body as bytes. An AI gateway parses it as a model call, a tool call or an agent message, so it can act on its meaning.

QuestionAPI gatewayAI gateway
What does it read?Method, path, headers, status, bytesModel, messages, tokens, tool calls, agent session
What does it limit?Requests per secondTokens and spend, as well as requests
What does it check?Who is calling, and whether the route existsPersonal data, prompt injection, model and tool policy
What does it translate?Usually nothing in the bodyOne request format to each provider's API
What does it log?An access log lineA record of the governed decision and its outcome
Where does it sit?At the edgeBehind the edge, in front of providers and tool servers

Neither replaces the other. Each one does a different job.

What does each one see about the same call?​

Take one chat request that a policy refuses. A typical API gateway access log records the HTTP envelope:

POST /v1/chat/completions 403 4ms api_key=<key-id>

DVARA's Open Source gateway, with its audit file turned on, writes a GATEWAY_RESPONSE record for the same call. This line follows the record's real structure; the IDs, times and signatures are illustrative:

{
"seq": 42,
"eventId": "0NB7Q2H3X9K1M",
"timestamp": "2026-11-09T10:15:02.123456Z",
"workspaceId": "default",
"eventType": "GATEWAY_RESPONSE",
"payload": {
"trace_id": "99115c790f614434b3d5bda41eecacc1",
"model": "mock/unapproved",
"status": 403,
"latency_ms": 4,
"doorway": "chat_completions",
"api_key": "<key-id>",
"error_code": "policy_denied",
"policy_decision": "DENY",
"policy_id": "approved-models-only",
"policy_rule_id": "deny-unapproved"
},
"previousHash": "<hmac-of-record-41>",
"hmac": "<hmac-of-this-record>",
"signedAt": "2026-11-09T10:15:02.124001Z"
}

Three things differ. The record names the model and the policy rule that refused it. It carries the trace_id the client saw, so you can find it from the error response. And it is HMAC-SHA256 signed and hash-chained to the record before it. That makes the trail tamper-evident: a changed or missing record is detected. It does not prevent changes: someone with access to the storage can still delete a file. The chain tells you that it happened.

The api_key field holds the key's opaque ID, never the secret. A policy denial also writes its own POLICY_DENIED event. For what auditors ask of this trail, see AI audit and compliance.

Do API gateway vendors offer AI gateway features?​

Yes, and the line between the categories is about what is inspected, not who sells it. Two examples, from each vendor's own documentation as of November 9, 2026:

  • Kong sells Kong AI Gateway. Its docs describe routing and load balancing across AI providers with failover, an AI Prompt Guard plugin, an AI Semantic Cache plugin, an AI Sanitizer plugin that redacts PII before a request reaches the provider, and MCP support. The AI Proxy plugin (Kong Gateway 3.6 and later) transforms OpenAI-format requests for a range of providers. AI Rate Limiting Advanced limits on the token counts the provider reports, or on cost from 3.8. See the Kong AI Gateway docs.
  • Amazon API Gateway throttles with a token bucket in which "a token counts for a request". Its limits are requests per second plus a burst, and clients over the limit get 429 Too Many Requests. Per-client limits use API keys in usage plans. See AWS API Gateway throttling.

So if you already run Kong, you can add AI features to the gateway you have. The questions to ask any AI gateway — including DVARA — are the same: what is checked on every call by default, what is signed in the audit trail, and whether tool calls and agent-to-agent calls are governed as well as model calls.

What does DVARA do on the AI side?​

DVARA leads with governance. Each item says when it applies.

  1. Tamper-evident audit. Every governed call writes a signed, chained record. In the Open Source gateway it goes to a local file that is off until you set DVARA_AUDIT_FILE_PATH and a signing secret. On the Enterprise platform it goes to a durable store, enabled by default, with search and export.
  2. Policy on every call. Policy-as-Code rules allow or deny models and other request attributes per workspace. In the Open Source gateway, policies apply once you define them in gateway.yaml.
  3. Personal-data checks. PII detection is on by default in the Open Source gateway, with 16 built-in patterns. The default action is LOG: it records the finding and forwards the request unchanged. BLOCK refuses the request with 400. REDACT removes the value permanently. TOKENIZE, which swaps provider-bound values for tokens that authorised users can reverse, is Enterprise.
  4. Prompt-injection guardrails. 31 built-in patterns cover jailbreaks, direct injection, instructions hidden in tool results and system-prompt extraction. Guardrails are on by default with the action LOG, so detections are recorded, not blocked, until you set BLOCK. Output sanitisation, which catches script, SQL, shell and internal-URL payloads in model output, is Enterprise.
  5. Control over agents. The DVARA MCP Gateway and A2A Gateway apply tool-level policy, approval gates and PII checks on tool arguments and results. Loop detection is on by default: the fifth identical tool call in a row is blocked, and so is a repeating cycle of two to four calls after three repetitions. Auto-kill is on by default and ends the looping session. These planes are Enterprise; without a licence they run in non-production within 3 workspaces and 100,000 governed calls a month.
  6. Token budgets and cost attribution. On the Enterprise platform, budget caps run daily, weekly or monthly (monthly by default), warn at 80% by default and refuse with 402 at the hard limit. Cost is attributed to workspace, API key, model and provider.
  7. The basics that come standard. One OpenAI-compatible API in front of every provider, routing, retries and failover. DVARA translates each request to the provider's own format. On Anthropic, system messages move to the separate system field and a JSON-schema request becomes a forced tool call. On Gemini, a JSON schema becomes responseMimeType plus responseSchema. On Bedrock, requests are SigV4-signed and tools move into toolConfig. When a caller leaves out max_tokens, DVARA sets it to 4096 by default.

Drop-in compatibility is there so governance applies from the first call. Point an OpenAI SDK at DVARA, and every request is policy-checked and recorded without changing your application code.

How do an API gateway and an AI gateway fit together?​

LayerJobExample
EdgeTLS, IP filtering, DDoS protection, global request limitsYour API gateway, load balancer or CDN
AI governancePolicy, PII, guardrails, budgets, audit, tool and agent control, provider translationDVARA
UpstreamModel inference, tool execution, other agentsModel providers, MCP servers, A2A agents
Clients → [API gateway] → [DVARA: LLM Gateway] → model providers
Agents → [API gateway] → [DVARA: MCP Gateway] → MCP tool servers
Agents → [API gateway] → [DVARA: A2A Gateway] → other agents

The API gateway handles the network. DVARA handles what the AI traffic means. If you already run an API gateway, keep it.

When is an API gateway on its own enough?​

An API gateway on its own can be enough if all of these are true: you call one provider, no prompt carries personal or regulated data, nobody needs a per-call record of which model answered under which rule, and no agent calls tools on its own. Once any of these stops being true, you need something that reads the payload.

What does an AI gateway not cover?​

Be clear about the boundary:

  • Traffic that bypasses the gateway is not governed. A team that calls a provider directly with its own key gets no policy, no PII check and no audit record. Closing that gap takes egress rules and holding provider keys in the gateway.
  • Some APIs are not served. Image generation, audio, realtime streams, moderations and fine-tuning do not go through DVARA today, so traffic to them is ungoverned. Batches are only partly governed.
  • Injection detection reads text. Images and audio in a request are passed on, not scanned.
  • It is not your edge. DVARA does not replace DDoS protection, a web application firewall or TLS at the perimeter.

The full list is on what the gateway does not govern.

Try it​

To see the difference on your own machine, run the Open Source quickstart. It starts the DVARA LLM Gateway in Docker on port 8080 with a Mock provider, a gateway.yaml and no database. It gives you a gw_ API key and a policy that denies one model, so you can send one allowed and one refused request and read both records in the audit file.

For the wider picture, see the pillar guide, What Is an LLM Gateway?.