AI gateway for agent and employee LLM traffic

Formal's AI gateway, also called an LLM gateway or LLM proxy, reads each prompt, response and tool call your agents and employees send to model providers, ties it to a person, redacts what your policies match and caps spend per user, with no SDK change on laptops.

logs · llmexample
AGENT  claude-cli   maya@acme.com
ALLOW  llm  POST api.anthropic.com/v1/messages
#      model claude-sonnet-4-6 · 18204 in / 912 out tokens
#      tool_call Bash {"command": "git status"}
HUMAN  browser      maya@acme.com
ALLOW  llm  POST chatgpt.com/backend-api/conversation
#      every request tied to a Formal user

The problem

Why do security teams need an AI gateway?

Your engineers’ coding agents already call api.anthropic.com from their laptops, and that traffic never passes through a gateway you configured. A secure AI gateway has to sit where those calls start: on the laptop, in the Pod and in front of the apps you build. It puts identity, redaction and spend policy on each request before it leaves, including the tool calls the model sends back and the models and tools nobody approved.

  1. Secrets and PII in prompts

    Coding agents call model providers straight from laptops, and employees paste into chatgpt.com. Whatever is in the prompt goes to the provider.

  2. Requests nobody can tie to a person

    Server-side apps share one API key. A provider console shows which key was used; the person or agent behind the prompt stays unknown.

  3. LLM spend without a cap

    Tokens are counted against the key, with no limit per person, so an agent's next request goes out however much it has already spent.

today · no policy on the pathexample
01
maya · browserPOST chatgpt.com/backend-api/conversationALLOWED
02
shared API keyPOST api.anthropic.com/v1/messagesALLOWED
03
claude-cli · mayaPOST api.anthropic.com/v1/messagesALLOWED

# Without a gateway, all three go through.

Solutions

Two jobs on the AI gateway with their own pages

AI data loss prevention rewrites PII and secrets out of a prompt before it leaves, blocks tool calls that carry a token and limits where an agent process can send data. AI cost management puts an estimated cost on every log from the token prices you set, and blocks a user once a daily, weekly or monthly budget in cost or tokens is reached. Spend refreshes every few minutes, so a burst of requests can go slightly over.

Definition

What is an AI gateway?

AI gatewaynoun

An AI gateway is a proxy between the clients that call AI models (apps, agents and employees) and the model providers’ APIs. LLM gateway and LLM proxy are other names for the same thing.
  • One control point

    Every request passes one control point, so you can authenticate it, apply policy, log the prompt and response, and track cost.

  • Most AI gateways are built for routing

    A team points its app’s base URL at the gateway to switch between models, fall back when a provider is down, cache responses and see token costs per app. On one developer’s machine, Claude Code Router does a version of this for coding agents through a local endpoint. If routing is your problem, use one of those.

  • Formal answers the security questions

    Formal doesn’t route between models or fail over: each request goes to the provider it was sent to. It answers what an AI security gateway gets asked: which person or agent sent this prompt, what was in it, which tools did the model call, and can you stop the request before it leaves?

How it works

How the AI gateway is set up

Each step has its docs page: LLM resources, the Endpoint, network rules and AI usage.

  1. Step 1 of 4

    Create LLM resources

    Add an LLM resource for each provider API you want to inspect, such as api.anthropic.com or chatgpt.com, for example with the Formal Terraform provider.

    LLM RESOURCESexample
    • api.anthropic.com added as an LLM resource✓
    • chatgpt.com added as an LLM resource✓
    • managed with the Formal Terraform provider✓
  2. Step 2 of 4

    Turn on Transparent Mode

    Install the Formal Endpoint on macOS or Linux, or run it as a native sidecar in Kubernetes Pods. Server-side apps can send traffic to a Connector instead.

    WHERE IT RUNSexample
    • maya-mbp · macOSTRANSPARENT MODE
    • agent pod · KubernetesNATIVE SIDECAR
    • support app · your VPCCONNECTOR
  3. Step 3 of 4

    Match agent traffic

    Write a network rule that intercepts LLM traffic from known agents, or from known LLM provider hostnames on Linux. Apps keep calling the provider as before.

    NETWORK RULEexample
    • known agents, by code-signed identity on macOS✓
    • the processes those agents spawn✓
    • post-TLS technology llm or mcp✓
  4. Step 4 of 4

    Enforce and review

    Add session, request and response policies, then review prompts, tool calls, cost and Insights in Logs, Sessions and the AI usage pages.

    ENFORCED AND LOGGEDexample
    • POST api.anthropic.com/v1/messagesALLOWED
    • prompt with an SSN, rewrittenMASKED
    • tool_call Bash, risk above thresholdBLOCKED

Interception

How Formal intercepts LLM traffic

Formal enforces LLM traffic in one of two places. The Formal Endpoint intercepts it on laptops and servers with Transparent Mode, and as a native sidecar in Kubernetes Pods. The Formal Connector sits in your infrastructure for server-side apps. Both evaluate the same policies, then forward the request to the provider. On the Endpoint, a network rule picks which flows to intercept; this one, from the AI governance docs, intercepts LLM and MCP traffic from known agents on macOS.

  • On macOS, known agents are recognized by their code-signed process identity, including the processes they spawn. On Linux, the rule matches process names or known LLM provider hostnames
  • Apps keep calling api.anthropic.com, with no SDK or base URL change
  • Server-side apps link an LLM resource to a Connector listener and call https://anthropic.<connector-hostname>/v1/messages. The Endpoint can also forward its LLM traffic to a Connector rather than evaluate it locally
  • Transparent Mode terminates TLS with certificates from a local Formal CA. Browsers and Go programs trust it through the OS trust store, and on macOS the Endpoint points Node.js and Python clients at it through environment variables (how TLS inspection works with each client)
AI governance docs ›
network rule · known agents (CEL)text
{
  "condition": {
    "pre_tcp": process.is_agent || process.has_agent_ancestor,
    "pre_tls": true,
    "post_tls": technology in ["mcp", "llm"]
  }
}

Capabilities

Inspect prompts, block tool calls

Two checkpoints: the prompt on its way out, the tool call on its way back. Account restrictions and an inventory of what’s in use run on the same traffic.

Inspect

Every prompt, response and tool call, tied to a person

Formal parses the provider’s wire format, so each log holds the model, the provider, the full prompt and completion, tool calls with their arguments and results, and token usage. Streaming responses are reassembled before logging. On the Endpoint, policies also see which agent sent the request and whether Claude Code runs in YOLO mode.

  • Agent identity: Claude Code, Cursor, Codex and other known agents, matched by code-signed process identity on macOS and by process name on Linux, with the Formal user behind each request
  • Session replay: every request and response in a session, including tool call exchanges
  • Redaction: rewriting a secret out of the prompt before it leaves, and encrypting prompts in Formal’s own logs, are covered on AI data loss prevention
AI data loss prevention ›
logs · llmexample
claude-sonnet-4-6claude-cli for mayaPOST api.anthropic.com/v1/messages · 18204 in / 912 out tokensALLOWED
tool_callclaude-cli for mayaBash {"command": "git status"}ALLOWED
maya · browserPOST chatgpt.com/backend-api/conversationALLOWED
Response rules

Stop a tool call before the agent runs it

The model asks for a tool inside its response, so a response-stage policy sees each call’s name and arguments before the agent does. Match exact values in Rego, or act on Assessments, which score every tool call for risk and for alignment with what the user asked.

  • Exact match: block a Bash call with a given command, as in the policy evaluation docs
  • Scores: input.assessment.risk and input.assessment.alignment, from 0 to 1, on each response that carries a tool call
  • Labels: conditions you describe in plain language, assigned to responses and matched by name in a policy
policy · tool callsexample
responseclaude-cli for mayatool_call Bash {"command": "git status"}ALLOWED
responseclaude-cli for mayatool_call Bash, assessment.risk above the policy thresholdBLOCKED
claude-cli for mayathe agent receives Formal's block message
Accounts

Org-only Claude accounts

Data also leaves through accounts: an engineer signed in to a personal Claude account sends company code to a workspace you don’t control. Anthropic’s tenant restrictions let a proxy allowlist your organization ID, and a Formal rewrite policy injects the anthropic-allowed-org-ids header on Claude traffic.

  • Only accounts and API keys from your Anthropic organization work
  • Personal accounts and other orgs get a 403 from Anthropic
  • Setup is in the restrict Anthropic sign-ins guide
endpoint · claude trafficexample
rewrite policyinject anthropic-allowed-org-ids on Claude trafficALLOWED
leo · company orgPOST api.anthropic.com/v1/messagesALLOWED
leo · personal account403 from AnthropicBLOCKED
Inventory

Discover shadow AI tools and models

The AI usage pages list every model, AI client application and provider in proxied traffic, with users, requests, tokens and policy hits. That makes them the start of AI usage monitoring and the first place shadow AI shows up.

  • Reviewing, approving or blocking those tools is covered on shadow AI detection
  • Usage pages are described in the AI usage docs
Shadow AI detection ›
AI usage · proxied trafficexample
security team> clients and providers seen this week
clientprovideruser
claude-cliapi.anthropic.commaya@acme.com
browserchatgpt.commaya@acme.com
2 rowsREVIEW

Coverage

What can't an LLM gateway see about coding agents?

An LLM gateway that depends on a base URL change sees only the clients someone pointed at it, and even on the path it sees the conversation and nothing else. On the Endpoint, Formal covers more of that ground. Deciding which hosts an agent’s child processes may reach is the secure web gateway‘s job, and the MCP gateway governs remote MCP servers over HTTPS. Two gaps remain, listed in the last rows (Windows docs).

Base URL LLM gatewayFormal Endpoint
Coding agents on laptopsClaude Code, Cursor and Codex call their providers straight from the laptop, so the gateway never receives that trafficTransparent Mode intercepts LLM traffic on macOS, on Linux and in Kubernetes Pods without a base URL change
Who sent itThe provider's log names only the API keyEach request is logged under the Formal user and the agent that sent it
Shell commands, files, MCP callsSeen only as a tool call in the model's reply and a tool result in the next requestA network rule on process.has_agent_ancestor also sees the connections an agent's child processes open
Windows laptopsOnly the apps someone pointed at itNot yet: Transparent Mode isn't available on Windows, so agent traffic from Windows laptops isn't intercepted
Local stdio MCP serversNot seen: the server talks to the agent over a pipeNot seen either: no proxy is on a pipe

Detection

Can an LLM gateway detect prompt injection?

Yes, after the fact, in the traffic it logs. Every 15 minutes, Formal’s Insights engine checks new LLM requests and responses against the OWASP Top 10 for LLM Applications (2025). Each insight names the risk, the entity involved and the log events behind it, and goes to your SIEM through your log integrations.

  • LLM01 Prompt Injection

    Flagged in logged traffic. A response-stage rule stops a redirected agent at the action it was steered toward, such as a Bash command, by exact match or by its Assessment risk score.

    Insight + response rule
  • LLM02 Sensitive Information Disclosure

    Flagged in logged traffic. Redaction before the request leaves is on AI data loss prevention.

    Insight + redaction
  • LLM06 Excessive Agency

    Flagged in logged traffic, among the categories Insights checks.

    Insight
  • LLM10 Unbounded Consumption

    Flagged in logged traffic. Per-user budgets that block the next request are on AI cost management.

    Insight + budget
  • Insights never block a request

    Blocking is a policy’s job, which is roughly the line between an AI firewall (filtering prompts and responses for attacks) and an AI gateway (the proxy that filtering runs on, along with logging, identity and cost).

    Detection only

The LLM security guide maps all ten OWASP categories to controls, including the ones a gateway can’t reach.

Works with

Works with your agents, apps and model providers

On laptops and in pods, apps keep calling the provider’s own hostname. Server-side apps swap that hostname for the Connector’s. Findings go to your SIEM.

  • Claude Code
  • Cursor
  • Codex
  • ChatGPT in the browser
  • api.anthropic.com
  • Any provider API you add as an LLM resource
  • Datadog
  • Splunk
  • Amazon S3
  • Google Cloud Storage
  • Azure Blob Storage
LLM resources docs ›

Architecture

Laptops, pods and server-side apps under one policy layer

AI gateway flow: coding agents and agents in pods reach LLM providers through Formal Endpoint and server-side apps through the Formal Connector, with the same policies logging prompts, masking sensitive data, blocking requests and capping spend.
Both paths apply the same policies, and each request goes to the provider it was sent to.

Deployment

An enterprise AI gateway on the systems you already run

Runs in your environment today: laptops, pods and your VPC.

Formal Endpoint on laptops

Transparent Mode on macOS and Linux; roll it out to Macs with your MDM. Existing clients keep working without a base URL change (docs).

Formal Endpoint in pods and tasks

A native sidecar in Kubernetes Pods, injected by label with the Helm chart, and a sidecar container in Amazon ECS tasks (docs).

Formal Connector in your VPC

Linux on AMD64 or ARM64: AWS ECS Fargate behind a Network Load Balancer, or Helm on EKS, GKE, AKS or on-premises Kubernetes. In production, run 2 or more nodes behind a load balancer (docs).

Your identity provider

People sign in with SSO, and SCIM keeps users and groups in sync. Policies use the groups you already manage.

Logs in your SIEM

Log integrations forward Formal logs to AWS S3, Google Cloud Storage, Azure Blob Storage, Datadog, Splunk or Panther.

Policy as code, audited controls

Policies are written in Rego. Manage Formal with Terraform, Pulumi or the Kubernetes Operator. Formal holds SOC 2 Type II and ISO/IEC 27001; the reports are on security.formal.ai.

Platform

The products behind the AI gateway

The proxies that carry LLM traffic also carry MCP tool calls and database queries, and the Control Plane holds one set of policies and logs for all of them. The tools a model asks for are governed on the MCP gateway; sensitive columns in query results, on data masking.

Endpoint

Formal Endpoint

Intercepts LLM traffic on macOS and Linux laptops with Transparent Mode, and as a native sidecar in Kubernetes Pods, with no base URL change. Formal Endpoint.

Connector

Formal Connector

Sits in your infrastructure for server-side apps, which call its hostname instead of the provider’s. It applies the same policies as the Endpoint. Formal Connector.

In production

Technologies secured
10+
Resources secured
1,000+
Logs per week
40M+
Sessions per week
600K+
“Without Formal, we couldn't have agents with access to sensitive data. With Formal, because we are able to inspect all traffic and enforce controls, we are able to provide a safe environment for the agents to get the job done.”
Travis McPeak
Travis McPeak
Head of Security, Cursor
Read the Cursor story ›

FAQ

Questions about AI gateways

Buying and fit

Do I need an AI gateway?

You need one if agents or employees send company data to model providers and you can’t say who sent what. Without a gateway, prompts, tool calls and costs sit in each provider’s console, split by API key. If your only LLM use is a single app you control, the provider’s own logging may be enough.

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

An API gateway fronts your own APIs: it authenticates callers, rate-limits them and sends requests to your services. An AI gateway sits on outbound traffic to model providers and understands LLM payloads: the model, the messages, the tool calls and the token usage. Formal parses each provider’s wire format, so policies can read input.llm.messages and input.llm.tool_calls directly.

What's the best AI gateway?

The one that fits whose traffic you need to control. Developer gateways are judged on routing, caching and SDK support for one app, and we cover open source LLM proxies on the LiteLLM alternative page. A security team should check three things: does the gateway see laptop and sandbox traffic without a base URL change, tie each request to a person, and block tool calls by policy? You can compare AI gateways on those criteria.

How much does an AI gateway cost?

Formal doesn’t publish prices, so get a demo for a quote. Plan for the LLM spend the gateway makes visible too: Formal has no built-in price list, so you enter token prices per model and provider, and per-user spend caps work from those.

Product

How do employees sign in to an AI gateway?

With Formal, employees sign in to the Formal Endpoint once with your company SSO in the browser, and SCIM keeps users and groups in sync with your identity provider. Each LLM request the Endpoint intercepts is then logged under that Formal user, and the agent needs no new key or base URL. CI jobs and cloud workloads sign in with OIDC or an API key instead (Linux install docs).

Do AI gateways retain prompt and response data?

Most log it, since the log is much of the point. Formal records the full prompt, completion and tool calls of each request, and those logs reach the Control Plane. A log schema can encrypt the LLM content fields on the Endpoint or Connector with an asymmetric key in your AWS KMS, GCP KMS or Azure Key Vault, so Formal’s servers only store ciphertext and you decrypt in your browser. Or it can drop prompts from logs entirely.

What is the difference between an MCP gateway and an LLM gateway?

An LLM gateway controls traffic to model providers: prompts, completions, the tool calls the model asks for, and tokens. An MCP gateway controls traffic to MCP servers, where agents run those tools, such as Linear or Notion. Formal covers both, and one network rule on the Endpoint can intercept llm and mcp traffic from known agents.

Put a security gateway on your LLM traffic

One AI gateway for agents, employees and server-side apps, with each prompt tied to a person and every policy in one place.