What the gateway gives a developer
The enterprise AI gateway is the one front door to models. A developer does not hold a provider key, pick a vendor or write retry logic. They call an OpenAI-compatible endpoint with a project key and a model alias, and the platform team owns routing, fallback, budgets, guardrails and logging behind it. The gateway in this example sits in front of Prisma AIRS scanning; the same developer experience applies whichever product provides the gateway, such as Portkey or the Databricks AI Gateway.
Header names, paths and configuration keys below are illustrative. Use the names your gateway documents.
Model aliases
booking-fast and booking-reasoner, never a vendor model name. The platform team repoints an alias after the evaluation set passes.
Project keys
One key per service and environment, with its own budget and rate limit. Keys are issued and rotated by the platform team.
Default guardrails
The security profile attached to the key scans every request. Developers do not call the scanner themselves.
Metadata
Each call carries an application name, session identifier, channel and trace identifier, so cost and incidents can be traced to a turn.
The developer workflow
Request a project
Raise a request with the service name, channels and data classes. The platform team creates the dev, test and prod keys, budgets and a security profile.
Call the sandbox
Develop against the sandbox gateway, which runs the same scanning with small budgets and synthetic data only.
Use aliases and tools
Call booking-fast for slot extraction and phrasing, booking-reasoner for hard turns. Tools are declared in the request; execution stays in your service.
Handle gateway errors
Treat a guardrail block, a budget stop and a provider failure as different outcomes with different replies.
Run the evaluation set
Run the shared evaluation set against your branch. Thresholds gate the merge.
Promote
The prod key is bound to the production profile. Nothing in the code changes between environments except configuration.
Calling the gateway
A turn that extracts booking details uses the standard OpenAI-compatible SDK (Software Development Kit) with the base URL (Uniform Resource Locator) pointed at the gateway. The service passes metadata as headers and asks for a structured result.
import os
from openai import OpenAI
client = OpenAI(
base_url=os.environ["AI_GATEWAY_URL"], # the gateway, not a provider
api_key=os.environ["AI_GATEWAY_KEY"], # project key with a budget
default_headers={"x-app": "booking-assistant", "x-channel": "web-chat"},
)
def extract_request(message: str, session_id: str, trace_id: str) -> dict:
resp = client.chat.completions.create(
model="booking-fast", # alias, repointed by the platform team
messages=[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": message},
],
response_format={"type": "json_schema", "json_schema": BOOKING_SLOTS_SCHEMA},
temperature=0,
extra_headers={"x-session-id": session_id, "x-trace-id": trace_id},
)
return json.loads(resp.choices[0].message.content)The code never names a vendor or a model version. A repoint of the booking-fast alias is a configuration change, tested by the evaluation set first.
Gateway configuration as code
The platform team keeps routes, budgets and guardrail attachments in version control and reviews changes like any other code. This is the shape of a route for the booking service.
routes:
- alias: booking-fast
primary: { provider: provider-a, model: small-model }
fallbacks: [ { provider: provider-b, model: small-model } ]
retries: { attempts: 2, on: [429, 500, 503], backoff_ms: 250 }
timeout_ms: 8000
guardrails: [ prisma-airs:booking-chat-prod ]
- alias: booking-reasoner
primary: { provider: provider-a, model: large-model }
fallbacks: [ { provider: provider-b, model: large-model } ]
timeout_ms: 30000
guardrails: [ prisma-airs:booking-chat-prod ]
keys:
booking-assistant-prod:
routes: [ booking-fast, booking-reasoner ]
budget: { usd_per_day: 1500, alert_at: 0.8 }
rate_limit: { requests_per_minute: 1200 }
metadata_required: [ x-app, x-session-id, x-trace-id ]Errors and what the guest sees
A booking assistant must tell a blocked message from a failed provider, because the right behaviour differs.
| Gateway outcome | Meaning | Service behaviour | Guest sees |
|---|---|---|---|
| 200 with content | Normal reply, scans passed | Continue the state machine | The reply |
| Guardrail block | Prompt or reply failed a scan | Log a security event, do not retry the same text, never echo the blocked content | A short, neutral refusal and an offer of a person |
| 429 rate or budget | Key limit reached | Back off, then degrade to a static menu if the limit persists | Please try again shortly, or call the line desk |
| 5xx or timeout | Provider failure after fallbacks | Keep the booking state, retry once, then hand off | An apology and a handoff with the conversation attached |
| Schema failure | Model returned an invalid structure | Retry once with the validation error, then ask a clarifying question | A clarifying question |
Sequence: a call with retry and fallback
The service sees one call and one answer. Which provider answered shows only in the metadata, so cost and fallback rates can be watched without changing application code.
Sequence: a blocked prompt and a budget stop
The two errors need different handling in the service, which is why the error table above separates them.
Testing without surprises
Unit tests
Mock the gateway client and test the state machine, slot validation and error handling with fixed replies.
Record and replay
Record sandbox responses for a set of conversations and replay them in CI (continuous integration), so tests are fast and free.
Contract tests
Check that every alias the service uses exists, returns the structure expected and carries the required metadata.
Adversarial tests
Include prompt injection, personal-data and tool-abuse cases and assert that the gateway blocks them and the service handles the block.
Cost tests
Assert a token budget per turn and fail the build if a prompt change doubles it.
Developer checklist
- No provider keys, vendor SDKs or model version names in the repository.
- Every call carries application, session and trace metadata.
- Guardrail blocks, rate limits and provider failures each have a tested reply.
- Structured outputs are validated against a schema in code.
- Prompts and aliases are versioned, and changes run the evaluation set.
- No personal data in prompts that the turn does not need.
Build this for your business
This example is a booking assistant for a ground-handling network, but the same pattern, a governed gateway, runtime security, grounded knowledge, deterministic commits and measured quality, fits any customer-facing assistant that takes actions. We can scope a pilot on your own systems.
Book a discovery call