One Gateway, One Platform Table: Route a Model Alias to the Claude API, Bedrock or Google Cloud and Check Parity Before the Call
Three tenants on three platforms, and a model id copied from the Claude API to Bedrock fails. A gateway turns the alias support-main into the right platform and id, keeps all 6 keys, counts a quota per tenant, refuses a Files API request on Bedrock and a 31 MB request over a 30 MB limit before any call, and logs every request.
What you will learn
- Route a tenant's model alias to a platform and the model id that platform expects
- Keep every platform key in the gateway and give tenants only a gateway token
- Refuse a request before any call when the platform lacks a needed feature or the request is over its size limit
- Run a parity report over every route before a tenant is moved
Before you start
- Calling Claude through Bedrock, Google Cloud and Foundry
- Multi-tenant quotas for one shared LLM
The support agent answers tickets all day, and now three customers run it on three different platforms: Acme on the Claude API, Bluebank on Amazon Bedrock, Northwind on Claude Models on Google Cloud and Microsoft Foundry. Each team keeps its own copy of the model id, its own key and its own limit.
Then one team copies the Claude API model id to Bedrock. Bedrock expects its own id, and the call fails. Three copies of the id, three copies of the key, three limits to remember, and nobody sees the problem until a customer does. This article puts one gateway in front of all of them, with one table that says what each platform needs.
A company travel desk
- Routing. Staff ask for a trip, not an airline. That's an alias (
support-main), not a platform id. The desk picks the airline. - Keys. The desk holds the company card; nobody keeps one in a drawer. The platform keys live in the gateway.
- The ledger. The desk records who booked what, and every team has a budget. That's a quota and a log line per tenant.
The calling side of each platform (client class, sign-in, model id format, features not supported) is covered in calling Claude through Bedrock, Google Cloud and Foundry. Here we stop each team from learning all of that, and put it behind one door.
platforms.py: the one table
The project runs on a stand-in (the Anthropic SDK on an httpx mock transport, one stand-in per platform with its own key and the model ids it accepts), so no API key is needed and the replies are test replies. The real platforms sign in differently (API key, AWS credentials, Google Cloud credentials, Entra ID); the stand-in uses one SDK shape for all of them.
"""The one table: what each platform calls the model, how big a request may be, and what it does not support."""
PREFIX = {"bedrock": "anthropic."} # every other platform uses the Claude API id as it is
ALIASES = {"support-main": "claude-sonnet-5-5", "support-fast": "claude-haiku-5-5"}
PLATFORMS = {
"claude_api": {"label": "Claude API", "max_mb": 128, "missing": set()},
"bedrock": {"label": "Amazon Bedrock", "max_mb": 20,
"missing": {"files_api", "message_batches", "mcp_connector", "web_search", "server_side_fallback"}},
"aws_platform": {"label": "Claude Platform on AWS", "max_mb": 32, "missing": set()},
"google_managed": {"label": "Claude Models on Google Cloud (Google managed)", "max_mb": 30,
"missing": {"files_api", "message_batches", "mcp_connector", "server_side_fallback"}},
"google_anthropic": {"label": "Claude Models on Google Cloud (Anthropic managed)", "max_mb": 32, "missing": set()},
# Foundry row: deployments hosted on Anthropic. Azure-hosted ones lack more (see its page).
"foundry": {"label": "Microsoft Foundry", "max_mb": 32, "missing": {"message_batches", "server_side_fallback"}},
}
def model_id(platform, alias):
return PREFIX.get(platform, "") + ALIASES[alias]
Per the README, the ids, the request limits and the unsupported features come from the Claude docs (Models overview; the API overview's "Claude API versus cloud platforms"; each platform's "Features not supported"), and the missing sets list only features SupportDesk uses. Feature availability varies by platform, so check each platform's page before you rely on a row.
| What must stay equal | Claude API | Bedrock | Google Cloud (Google managed) | Foundry |
|---|---|---|---|---|
| Model id for support-main | claude-sonnet-5-5 | anthropic.claude-sonnet-5-5 | claude-sonnet-5-5 | claude-sonnet-5-5 |
| Largest request | 128 MB | 20 MB | 30 MB | 32 MB |
| Features SupportDesk uses that are missing | none | 5 | 4 | 2 |
The gateway reads all of this from the table, never from someone's memory.
gateway.py: route, quota, parity, call, log
TENANTS = {"gw-acme": ("acme", 2), "gw-bluebank": ("bluebank", 5), "gw-northwind": ("northwind", 5)} # name, quota
ROUTES = {"acme": {"support-main": "claude_api", "support-fast": "claude_api"},
"bluebank": {"support-main": "bedrock", "support-fast": "bedrock"},
"northwind": {"support-main": "google_managed", "support-fast": "foundry"}}
VAULT = {p: f"key-{p}" for p in PLATFORMS} # the only place keys live
def handle(token, alias, needs=(), size_mb=0.1):
"""Every request ends in one log line, whether it is served or refused."""
entry = {"tenant": "-", "alias": alias, "platform": "-", "model": "-"}
def done(status, why=""):
LOG.append({**entry, "status": status})
return {**entry, "status": status, "why": why}
if token not in TENANTS:
return done(401, "unknown gateway token")
entry["tenant"], quota = TENANTS[token]
USED[entry["tenant"]] = USED.get(entry["tenant"], 0) + 1
if USED[entry["tenant"]] > quota:
return done(429, f"tenant quota {quota} used")
platform = entry["platform"] = ROUTES[entry["tenant"]][alias]
spec = PLATFORMS[platform]
gap = sorted(set(needs) & spec["missing"])
if gap:
return done(422, f"{platform} has no {gap[0]}")
if size_mb > spec["max_mb"]:
return done(413, f"over the {spec['max_mb']} MB limit")
entry["model"] = model_id(platform, alias)
CLIENTS[platform].messages.create(model=entry["model"], max_tokens=64, messages=[{"role": "user", "content": "T-101"}])
return done(200)
That's an excerpt (the imports, CLIENTS, USED and LOG set-up are left out). The order matters:
- The gateway token says which tenant this is. Tenants never hold a platform key.
- The quota is counted per tenant.
- The route: the tenant and the alias pick the platform.
- The parity check: a needed feature the platform lacks, or a request over its size limit, is refused before any call.
- The call, with the platform's own model id and the key from the vault.
- One log line on every path, served or refused.
The tenants, routes, quotas, alias names and the 422 status are the lecture's own choices for the demo.
One decision per request
direct calls, one id copied by hand
claude_api claude-sonnet-5-5 -> 200
bedrock claude-sonnet-5-5 -> 404 id not recognised
through the gateway
acme support-main claude_api claude-sonnet-5-5 -> 200
bluebank support-main bedrock anthropic.claude-sonnet-5-5 -> 200
northwind support-fast foundry claude-haiku-5-5 -> 200
bluebank support-main bedrock bedrock has no files_api -> 422
northwind support-main google_managed over the 30 MB limit -> 413
acme support-fast claude_api claude-haiku-5-5 -> 200
acme support-main - tenant quota 2 used -> 429
guest support-main - unknown gateway token -> 401
parity report
acme support-main claude_api ok
acme support-fast claude_api ok
bluebank support-main bedrock gap: files_api
bluebank support-fast bedrock gap: message_batches
northwind support-main google_managed gap: files_api
northwind support-fast foundry gap: message_batches
log: 8 lines, one per request, each with tenant, alias, platform, model, status
keys: 6 in the gateway, 0 in tenant config
- Direct calls. The Claude API accepts the copied id; Bedrock doesn't recognise it. That 404 is the stand-in's behaviour (it serves only the ids its platform expects); the real platform's error text may differ.
- Through the gateway, one alias reaches three platforms with three different model ids, and nobody typed a platform id.
- A request that needs the Files API on Bedrock gets a 422, our own code, and nothing is sent.
- A 31 MB request to the Google-managed route is over its 30 MB limit: 413, again before any call. (The size is passed in as a number; the stand-in doesn't send real megabytes.)
- Acme's third request hits its quota of 2: 429. An unknown token: 401.
- The parity report lists the same gaps for every route, before any tenant is moved.
- Eight log lines, one per request. Six keys, all in the gateway; zero in tenant config.
The same front-door idea for MCP tool servers (a gateway that checks its own token, routes versions and mints a new upstream token) is in a remote MCP server in production. What this lecture adds is the platform side: an alias that becomes a different id per platform, and a parity table checked before the call instead of discovered after it. When the route itself fails over to another model, see fallback model chains; the same parity table is what tells you whether the backup can even take the request.
Common mistakes
- Copying the Claude API model id everywhere. Bedrock expects its own prefix, as the 404 showed.
- Giving each team its own platform keys. Six keys spread across tenant configs instead of one vault.
- Assuming every platform has every feature. Bedrock lacks five of the features SupportDesk uses, the Google-managed route four, Foundry two.
- Finding a gap from the platform's error. Check the table and refuse before the call; then the log says exactly why.
- Moving a tenant without a parity report. Run it over every route first.
Quick recap
| Job | Where it lives | In the run |
|---|---|---|
| Route by tenant and alias | ROUTES + model_id() | One alias, three ids |
| Hold the keys | VAULT | 6 in the gateway, 0 in tenant config |
| Count a quota per tenant | TENANTS | acme: 429 after 2 |
| Check parity before the call | PLATFORMS table | 422 files_api, 413 over 30 MB |
| Log every request | done() | 8 lines |
StudyEasy AI Community
Learn AI engineering, share what you build, and connect with other learners.
Free resources: lesson files, notebooks and code
Ask questions and join engineering discussions
Meet real people learning and building with AI
Related course on Udemy
Claude Certified Developer - Professional (CCDV-P) Exam Prep
Claude agents in production: reliability, observability, evals, cost, guardrails and fleets.View on Udemy ↗: Claude Certified Developer - Professional (CCDV-P) Exam Prep (paid course, opens in a new tab)Related posts
The Claude Messages API: Your First Call, Field by Field
One request in, one Message out. The four fields of a Messages API call (model, max_tokens, system, messages), how to read content blocks, stop_reason and usage, and why every turn resends the history.
Claude Tool Use: How tool_use and tool_result Work in the Messages API
Follow one order question through Claude's tool round trip: define a tool, read the tool_use block, run your own function and send a matching tool_result back, including parallel calls and is_error.
Claude Client SDKs Wrap One REST API: Raw HTTP, Python, TypeScript and Async Calls Compared
Every Claude client SDK wraps the same REST request: a POST to /v1/messages with a JSON body. See it built by hand, through the Python and TypeScript SDKs, as typed errors, and as async calls that wait together.
Anthropic SDK Timeouts, Retries and Error Classes: Configure the Client Once, Then Give 429, 529, 400 and Timeouts Their Own Move
Configure the Anthropic SDK client (timeout, max_retries, with_options, async, pagination), see which errors it retries by itself, then repair a retry wrapper so a 429, a 529, a 400 and a timeout each get the move the docs support.
