Build Stuff 2026 · Vilnius · Beta 1 · Fri 4 Dec · 14:30

How AI gateways
work

Lessons from building one.

Johannes Brüderl · Principal Software Engineer · Redpanda Data

About me

Johannes Brüderl

  • Principal Software Engineer at Redpanda Data, tech lead of the AI team.
  • We build the Agentic Data Plane: a governance layer for enterprise agents. The AI gateway is its core.
  • Working on the AI gateway, sandboxes and more.
  • Before that: the multi-tenant control plane behind Redpanda Cloud.

github.com/birdayz
redpanda.com

Part 1 · What

What is an
AI gateway?

Where it sits, what it does, and where the gateway ends and the platform begins.

What

An AI platform, and the gateway in the middle

The obvious question

Isn't this just an API gateway?

API gateway · thinks in HTTP

route  /orders/*  → orders:8080
match  header x-tenant
limit  100 req/s per API key

You configure paths, headers and upstream hosts.

AI gateway · thinks in GenAI

provider  my-anthropic, my-bedrock
model     allowlist, fallbacks, smart routing
mcp       all the tools you want
identity  users, agents, applications

You configure GenAI stuff.

AI gateways sit one abstraction level higher. You can build one on top of an API gateway.

Part 2 · Why

Why use an
AI gateway?

Me, to our CTO, about 18 months ago

“AI gateways will be a commodity. Not worth building our own.”

Expose MCP serversModify MCP serversPolicies on MCP serversGuardrails

Turned out almost everything we add goes through the gateway. Owning it makes us way faster.

Recap

Why?

Governance

Know what happens

Audit log · transcripts · policies · cost

Platform engineering & IT

Centralize LLM access

All traffic, all vendors · routing, fallback

Tools

Context and actions

Register and share

Identity

Control access

Policies & on-behalf-of identity

Part 3 · How

Now the
deep dive

  1. 01LLM provider APIs
  2. 02Model catalogs
  3. 03MCP and tools
  4. ↑Then back up: should you build one?

The gateway

The important APIs

01

LLM API

Reverse proxy to the LLM providers. Many wire protocols.

Adoption · massive

02

MCP API

The data integration layer. Tools for agents. JSON-RPC over HTTP and SSE.

Adoption · massive

03

A2A API

Most popular standard to expose agents. No clear winner yet.

Adoption · lagging

04

Management

API of the AI gateway itself, to manage it.

Adoption · just us

Honorable mentions: AG-UI and others. Agent protocols are far from settled.

Deep dive · 01 / 03

LLM provider API
deep dive

Providers, wire protocols, and the conventions around them.

LLM API

The most important protocols

OpenAI

Chat Completions
/v1/chat/completions

Responses
/v1/responses

Two native APIs. Responses is the one OpenAI recommends for new work.

Anthropic

Messages
/v1/messages

Chat Completions
/v1/chat/completions

No prompt caching on compat. Anthropic: not for production use.

Google

generateContent
/v1beta/models/{m}:generateContent

Chat Completions
/v1beta/openai/chat/completions

The model is in the URL, not the body.

AWS Bedrock

Invoke · Converse
/model/{id}/invoke · /converse

Messages some models

Chat Completions · Responses
/openai/v1/…

Support varies per model. Two hosts.

Other providers (have to) use one of these.

Core abstractions

Provider vs. wire protocol

Core abstractions

Wire protocols

Chat Completions

POST /v1/chat/completions
{
  "model": "gpt-5",
  "stream": true,
  "max_completion_tokens": 256,
  "messages": [
    {
      "role": "system",
      "content": "Be brief."
    },
    {
      "role": "user",
      "content": "Hi"
    }
  ]
}

Messages

POST /v1/messages
{
  "model": "claude-sonnet-4-5",
  "stream": true,
  "max_tokens": 256,
  "system": "Be brief.",
  "messages": [
    {
      "role": "user",
      "content": "Hi"
    }
  ]
}

Converse

POST /model/<model-id>
  /converse-stream
{
  "system": [
    { "text": "Be brief." }
  ],
  "messages": [
    {
      "role": "user",
      "content": [
        { "text": "Hi" }
      ]
    }
  ],
  "inferenceConfig": {
    "maxTokens": 256
  }
}

generateContent

POST /v1beta/models/
  gemini-2.5-flash
  :streamGenerateContent
{
  "systemInstruction": {
    "parts": [
      { "text": "Be brief." }
    ]
  },
  "contents": [
    {
      "role": "user",
      "parts": [
        { "text": "Hi" }
      ]
    }
  ],
  "generationConfig": {
    "maxOutputTokens": 256
  }
}

First design question

How does a client pick the provider?

HTTP Body

{"model": "my-anthropic/claude-…"}
  • Popular early on. Prefix the model
  • Extract from HTTP Body
  • Generic routing decision depends on provider-specific code. Works, but not pretty.

HTTP Header

X-Provider: my-anthropic
  • Not Provider specific, good for AI Gateway
  • Hard to use in AI SDKs
    • Got better, but you cannot always set headers

HTTP Path · what we do

/llm/v1/providers/my-anthropic
  • Not provider specific
  • Every AI SDK supports it
https://gateway.example.com/llm/v1/providers/my-anthropic/v1/messages
the mount · owned by the gatewaybehind the mount · owned by the provider code

Paths · sounds trivial, is not

The /v1/v1 mystery

Have you seen this one?

POST …my-ai-gateway/…whatever…/v1/v1/messages
404 Not Found from api.anthropic.com
base URL you give the SDKpath the SDK appends

OpenAI SDK · /v1 is part of the base URL

https://api.openai.com/v1/chat/completions

Anthropic SDK · bare base URL, the SDK appends /v1

https://api.anthropic.com/v1/messages

There it is · a /v1 in the base URL, to "look like OpenAI"

…/providers/my-anthropic/v1/v1/messages

Paths · you are not alone

/v1/v1 in the wild

Red: papered over it. Strip, dedupe or special-case /v1.

Paths · do it properly

Trimming /v1/v1 is a hack

base URLupstream URLappended by the SDK · never touched

For now and forever

The official SDK is the spec.

Base URL what the user types into the provider's official SDK.

Upstream URL where the gateway sends it. Whatever the SDK adds after the base URL gets appended.

OpenAI SDK

base URL…/providers/my-openai/chat/completions upstream URLhttps://api.openai.com/v1/chat/completions

Anthropic SDK

base URL…/providers/my-anthropic/v1/messages upstream URLhttps://api.anthropic.com/v1/messages

Wire protocols

What the gateway does with every request

Usage

"cache_read_input_tokens": 1200
  • In, cached, output, thinking tokens
  • Every wire protocol names them differently
  • Cached part of input? OpenAI yes, Anthropic no
  • Streams: OpenAI opt-in, Anthropic split over two events

Errors

{"type": "error", "error": {…}}
  • Always in the wire protocol's error format
  • Even for your own errors
  • Correct HTTP status code: 403 vs. 429 vs. 5xx, SDKs behave differently

Streaming

data: [DONE]
  • SSE, in different flavors
  • OpenAI: data: lines, [DONE]
  • Anthropic: named events
  • Gemini: JSON array, unless alt=sse
  • Bedrock: binary frames

This is the bare minimum. On top: guardrails, transcripts, audit logs, budgets, rate limits, …

Wire protocols

Error handling

  • Your own errors too: bad key, unknown provider, budget exceeded, guardrail block.
  • Wrong shape: the client cannot tell what went wrong.
  • Status code matters: SDKs retry 429 and 5xx on their own.
  • Streaming semantics apply
    • The 200 is already sent. The error has to be a stream event.
    • Just closing the connection looks like a short answer.
    • Retry only before the first token.
// a guardrail block, Anthropic Messages
{"type": "error",
 "error": {"type": "invalid_request_error",
           "message": "Blocked by policy"}}

// the same block, OpenAI Chat Completions
{"error": {"type": "invalid_request_error",
           "code": "content_policy",
           "message": "Blocked by policy"}}

// simplified

The client only speaks its wire protocol. Even when the gateway is the one saying no.

Built on wire protocols

Protocol translation

Fallback rides on this. Same model, next host, until the first token.

Testing

How to test this?

Most tests

Contract tests

  • Highly realistic fakes that store the contract between your code and the provider
  • Record every behavior you program against
  • Every wire format × every host, unary and streamed
  • Fast, offline. Cheap because they are fake :)

The real proof

Live tests

  • The real hosts, every night
  • Slow, costly and flaky: 500s, quotas, throttling
  • Bad for iteration, so not in PR CI
  • A reviewed live answer becomes the next fixture

The worst

KV Cache

  • Prompt caching needs warm-up requests and TTLs
  • A hit is not guaranteed
  • Therefore super flaky
  • But we need proof that caching works!

Models

You need a model catalog

id: eu.anthropic.claude-haiku-4-5-20251001-v1:0
model: anthropic/claude-haiku-4-5 failover UI
wire_apis: [anthropic_messages, bedrock_converse] translate snippets
capabilities:
  tools: true agent failover
  tool_search: false
reasoning:
  budget: true
modalities:
  input: [text, image, document]
constraints:
  max_input_tokens: 200000 agent UI
  max_output_tokens: 64000 gateway
  supported_params: [temperature, top_p, max_tokens, stop]
pricing: cost
  input_usd_per_m: 1.10
  output_usd_per_m: 5.50
  cached_input_usd_per_m: 0.11
attributes:
  inference_geo: eu UI
# trimmed, simplified
  • Why: agents need the limits. Your UI needs snippets, release and retirement dates, providers.
  • Wire protocol: per provider, per model. On Bedrock and Vertex, it's per model.
  • Pricing: per model, per route, region, service tier, context size, date, …
  • Capabilities: params, features, reasoning, modalities
  • Limits: max input tokens, max output tokens
  • It ages, basically daily. AI can do the maintenance.

Deep dive · 03 / 03

MCP

MCP fragmentation is real

MCP

Why MCP in the AI gateway

  • Gives agents access to tools
    • Huge value. Easy to access data, do things, …
  • Proxying to remote MCP servers
    • You need to be protocol compliant
  • Managed MCP servers (we do a lot of this)

The whole company, one place: centralization.

Identity

Acting on behalf of the user

  • The usual setup: one API key for the third-party service. Everyone acts as that service account.
    • Terrible for security. And for users: they want their own stuff, under their own name, not some bot's.
  • End-to-end identity. Every call runs as the user.
    • Upstream permissions apply. The audit log shows the user.
  • The gateway brokers OAuth. Second login: consent with Jira, once.
    • Token vault per user and connection. Encrypted, refreshed. The agent never sees it.

Tools

Tools are dynamic.

The list of tools can change: per caller, and over time.

Why dynamic is the right design

Dynamic vs. Static Schema

Static · one schema for everyone

create_issue({
  project: string,
  fields: [{ name: string, value: string }]
})
  • The model guesses field names and formats.
  • Mistakes show up as failed calls to Jira.

Dynamic · this project, this caller, only fields they can see

create_issue({
  summary:      string,
  story_points: integer,
  customer:     "Acme" | "Globex",
  due:          string // format: date
})
  • Strongly typed.
  • AI can see the shape and make better decisions.

Generate it dynamically, e.g. one tool per table. High-fidelity schemas give much better results.

Tools

The list of tools is not fixed either

The tools an MCP server lists can depend on the user.

  • Log in first. Until then, one tool: connect_account. It returns the sign-in link.
  • Why a tool? Tools are the universal language every agent speaks.
    • MCP can do more, like elicitation. A lot of clients do not support it. You will see this everywhere.
  • Different per user. Alice and Bob get different tools.
    • From access policies in the gateway, or from the remote system.

alice

connect_account

jira_search

jira_get_issue

jira_create_issue

jira_transition

project lead

bob

connect_account

jira_search

jira_get_issue

read-only

Part 4 · Back up

So, should you
build one?

Build, buy or self-host · per situation

It depends on who you are

You areYou mostly needVerdict
A small teamone or two providersKeys out of the apps, a spend limitbuy or self-host an open-source proxy is enough
A platform teammany teams, many providersCost per team, allow-lists, one base URL for everyonebuy or build self-hosting is not worth it
A regulated enterprisedata stays in your cloudPer-user identity, audit, tools that act as the userbuy a vendor that deploys into your account
An AI platform vendorthe gateway is your productAll of the above, for your customersbuild and staff it for good

Build Stuff 2026 · Vilnius

Thank you!
Questions?

Johannes Brüderl · Principal Software Engineer · Redpanda Data

github.com/birdayz