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
td-fast and td-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, case identifier and trace identifier, so cost and incidents can be traced to a unit of work.
In this platform language models are used only for documentation. They never receive exact locations or traveler names, and are never part of the path from event to alert.
The developer workflow
1 · Request a project
Raise a request with the service name, data classes and expected volume. The platform team creates the dev, test and prod keys, budgets and a security profile.
2 · Call the sandbox
Develop against the sandbox gateway, which runs the same scanning with small budgets and synthetic data only.
3 · Use aliases and tools
Call td-fast for extraction and drafting, td-reasoner for hard cases. Tools are declared in the request; execution stays in your service.
4 · Handle gateway errors
Treat a guardrail block, a budget stop and a provider failure as different outcomes with different handling.
5 · Run the evaluation set
Run the shared evaluation set against your branch. Thresholds gate the merge.
6 · Promote
The prod key is bound to the production profile. Nothing in the code changes between environments except configuration.
Calling the gateway
A step that drafts an incident report uses the standard OpenAI-compatible SDK (Software Development Kit) with the base URL (Uniform Resource Locator) pointed at the gateway. The service passes structured facts and metadata as headers. The result is a draft.
import os, json
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": "duty-platform", "x-stage": "documentation"},
)
def draft_incident_report(facts: dict, incident_id: str, trace_id: str) -> str:
resp = client.chat.completions.create(
model="td-fast", # alias, repointed by the platform team
messages=[
{"role": "system", "content": INCIDENT_REPORT_PROMPT},
{"role": "user", "content": json.dumps(facts)}, # structured facts only: counts and times, no names or locations
],
temperature=0,
extra_headers={"x-incident-id": incident_id, "x-trace-id": trace_id},
)
return resp.choices[0].message.content # a draft: the duty officer edits and signs before anything is filedThe code never names a vendor or a model version. A repoint of the td-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. Volumes are small, so budgets are small.
routes:
- alias: td-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: 15000
guardrails: [ prisma-airs:duty-docs-prod ]
- alias: td-reasoner
primary: { provider: provider-a, model: large-model }
fallbacks: [ { provider: provider-b, model: large-model } ]
timeout_ms: 45000
guardrails: [ prisma-airs:duty-docs-prod ]
keys:
td-platform-prod:
routes: [ td-fast, td-reasoner ]
budget: { usd_per_day: 60, alert_at: 0.8 }
rate_limit: { requests_per_minute: 60 }
metadata_required: [ x-app, x-incident-id, x-trace-id ]Errors and what happens to the draft
| Gateway outcome | Meaning | Service behaviour | Result for the work item |
|---|---|---|---|
| 200 with content | Normal reply, scans passed | Continue the pipeline | Normal processing |
| Guardrail block | Input or output failed a scan | Log a security event, do not retry the same text, never echo the blocked content | Routed to a person with the reason |
| 429 rate or budget | Key limit reached | Back off, then queue the work and alert the platform team | Delayed, not lost |
| 5xx or timeout | Provider failure after fallbacks | Keep the state, retry once, then queue for a person | Delayed or routed to a person |
| Schema failure | Model returned an invalid structure | Retry once with the validation error, then route to a person | Routed to a person |
The service sees one call and one answer. Which provider answered shows only in the metadata.
Testing without surprises
Unit tests
Mock the gateway client and test the rules, validators and error handling with fixed replies.
Record and replay
Record sandbox responses for a set of cases 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 unit of work 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, case and trace metadata.
- Guardrail blocks, rate limits and provider failures each have a tested path.
- 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 task does not need.
- No language-model component imports, calls or shares credentials with the register, the exposure matcher, the alert engine or the communications service.
Build this for your business
This example is speculative, but the same pattern, minimal and consented data, deterministic rules for every safety duty, a governed gateway, runtime security, advisory-only AI and accountable people, fits any service that looks after people. We can scope a pilot on your own systems.
Book a discovery call