Protect model API calls with the AI Gateway
Put the WASViking AI Gateway between your applications and OpenAI, Anthropic, Gemini, Azure OpenAI or any OpenAI-compatible endpoint. Bring your provider key, create a gateway and a key, point your SDK at the gateway, and see every decision in the request log.
The WASViking® AI Gateway sits between your applications and the model providers they call. Each request is checked against your AI Guardian policies before it leaves: a secret can be blocked, personal data can be replaced by a placeholder, a prompt injection can be stopped. Answers can be inspected before they reach the application. Every decision is recorded with the rule that made it, the policy version, and whether it was actually enforced.
Your applications keep their SDK. They change the base URL and the key, and nothing else.
For a guided first run with example values and the result to expect at each step, follow Your first protected request through the AI Gateway. To send Claude Code through the gateway, see Route Claude Code through the AI Gateway.
The gateway protects applications and scripts that call model APIs. Employees using ChatGPT, Claude or Gemini in the browser are covered by the AI Guardian browser extension instead (Deploy AI Guardian).
Not every AI application can be pointed at a gateway. Before you plan a rollout, see Which AI applications can go through the AI Gateway: application by application, whether the gateway applies and what covers the rest.
Before you start
- The AI Gateway is an add-on from the Pro plan, contracted on its own. Until it is part of your contract, its screen shows a locked page with Activate, which sends the request to your partner or WASViking sales.
- You need an administrator role, or a role with AI Gateway manage access.
- Have the API key of the provider you use. It is stored encrypted and never shown again; screens only show its last four characters.
Step 1: turn on the AI Gateway
Open AI Guard, Protection, AI Gateway and select Turn on the AI Gateway. Until it is on, any request that presents a gateway key is refused. You can prepare everything below first and turn it on at the end.
Step 2: add a provider credential
On Providers & Models, select Add credential:
| Field | What to enter |
|---|---|
| Name | A label for your team, for example "OpenAI production". |
| Provider | OpenAI, Anthropic, Google Gemini, Azure OpenAI, OpenAI-compatible or Ollama. |
| Endpoint URL | Leave empty for the official endpoint. Required for Azure OpenAI, OpenAI-compatible and Ollama. It must be an https:// address reachable from the internet; private and internal addresses are refused. |
| API version | Azure OpenAI only. |
| API key | The provider key. |
Select Test on the new row. The gateway asks the provider for its model list with your key and tells you whether the key was accepted, rejected, or the endpoint could not be reached.
Step 3: create a gateway
A gateway is one workload: its own keys, models, guardrails, limits and budget. On Workloads, select New gateway:
| Setting | What it does |
|---|---|
| Identifier | A short name used in policy conditions and in the request log. |
| Input inspection | Inspect and apply policy enforces your rules on prompts. Inspect and record measures without changing anything. |
| Answer inspection | Buffer before release holds the answer until it is inspected, so it can be withheld or redacted. Stream and monitor streams as it arrives and records what it finds, without being able to undo it. |
| When policy cannot be evaluated | Deny refuses the request. Allow and record as degraded lets it through and marks it. |
| Requests per minute per key | A rate limit for each key. Leave it empty for no limit. |
| Daily and monthly budget | Caps on estimated spend. Leave a budget empty for no cap; a budget of 0 refuses every request. When a cap is reached the gateway answers 429 until the period resets (UTC). |
| Allowed and denied models | Exact model names or prefixes ending in *. The denied list always wins. |
Step 4: add a route
On Routing & Failover, choose the gateway and the credential, the models the
route serves (*, a prefix such as gpt-4o*, or an exact name) and whether it
is a primary or a fallback. Fallbacks are used only when a primary fails or
answers with a server error or a rate limit. A fallback serves the same model
unless you map it explicitly with Serve as model, and the answer always says
which model replied (header x-wasviking-routed-model).
To be told when every route of a gateway fails, open Notification Channels and turn on the AI Guardian Gateway Degraded event for a channel. The Routing & Failover tab shows which channels receive it.
Step 5: create a key
On Access & Keys, select the gateway, give the key a label and choose who it belongs to: a person from your directory or a named service account. Copy the key when it appears: it is shown once. Revoking it takes effect on the next request.
Step 6: point your application at the gateway
The Integrations tab shows your base URLs and ready-to-copy examples for the
OpenAI SDK, the Anthropic SDK and Gemini REST. The quickest check is a request
with curl:
curl https://api.wasviking.com/ai-gateway/openai/v1/chat/completions \
-H "Authorization: Bearer $WASVIKING_GATEWAY_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-4o-mini", "messages": [{"role": "user", "content": "Hello"}]}'
| Client | Base URL |
|---|---|
| OpenAI SDKs (Chat Completions, Responses, Models) | https://api.wasviking.com/ai-gateway/openai/v1 |
| Anthropic SDKs (Messages) | https://api.wasviking.com/ai-gateway/anthropic |
| Gemini REST (generateContent) | https://api.wasviking.com/ai-gateway/gemini |
The key goes in the header your SDK already uses: Authorization: Bearer,
x-api-key or x-goog-api-key. The gateway does not translate between
formats: an OpenAI-format request reaches an OpenAI-format provider.
Step 7: add the rules that matter
In AI Guardian Policies, create rules and choose where they apply: AI Gateway: requests, AI Gateway: responses, or both. Common first rules:
- Block secrets in prompts (data class secret, action Block).
- Redact personal data in prompts (data class pii, action Redact and forward).
- Block prompt injection (threat instruction override, action Block).
- Withhold answers that contain secrets (data class secret on responses, action Block).
Set a new rule to Audit only to see what it would do before it enforces. The Policy simulator on the same screen runs a sample through your rules and explains the decision.
Read the request log
Traffic lists every request with the caller, the model requested and the model that answered, the decision, the rule, the status, the latency and the estimated cost. Select a row for the detail: the data classes found, the policy and detector versions, the tokens and the trace id. Prompts and answers are never stored, only their classification.
Labels to know:
- Blocked and Redacted count only what the gateway enforced.
- (audit only) means a rule matched but did not change anything.
- Would block (streamed, not enforced) means the answer had already streamed when the detection happened.
- Failed: provider unavailable means your policy allowed the request but no provider route answered.
- Refused: request too large means the request was above the gateway size limit and never reached a provider.
Spend is an estimate from list prices, not your provider invoice. Models the price table does not know are shown as not priced and do not count toward a budget. Streamed answers count too: when a provider does not report the token counts of a stream, the gateway estimates them from the text length and the request detail says so.
Usage and limits
Your contract sets how many AI Gateway requests the organization makes over the last 30 days, blocked requests included, and how many concurrent connections it can hold (streamed answers still open). A panel under the header of the AI Gateway screen shows the usage against the contract, and the AI Guardian tab of Profile & Plan Usage has the same numbers in one card per module.
- Notices go out at 80% and 100% of the contract, to the alert destinations subscribed to AI Guardian Usage and by e-mail to the organization administrators.
- Above the contract nothing is billed automatically and protection never stops: every decision still applies. Allowed requests with no finding (no rule, detection, redaction, mask, approval or error) stop being recorded while usage stays above.
- After 30 days above the contract, new gateway keys wait until the capacity is raised. Existing keys keep working, and the hold lifts as soon as the capacity is raised. While usage is above, the panel shows the date new keys would start to wait.
- A new request above the concurrent connections is answered at once with 429
concurrency_limitandRetry-After: 2. Requests already running are never cut.
Your WASViking partner raises the capacity, or WASViking sales if you buy directly. If your organization received the AI Gateway as a 60-day trial when the modules were packaged, the panel also shows the date the trial ends.
Troubleshooting
| Answer | Meaning |
|---|---|
401 invalid_api_key |
The key is wrong, revoked or expired. |
403 gateway_disabled |
The AI Gateway or this gateway is off. |
403 module_not_contracted |
"The AI Gateway is not part of this organization's WASViking contract." Ask your partner or WASViking sales to add it. |
403 model_not_allowed |
The model is outside the allowed list, or on the denied list. |
403 policy_blocked or output_blocked |
A rule blocked the prompt or withheld the answer. The message names the rule. |
429 rate_limited or budget_exceeded |
A per-key rate limit or a budget cap was reached. |
429 concurrency_limit |
"Too many requests are running at once for your organization. Retry in a moment." The organization reached its concurrent connections. Retry after the Retry-After header. |
| Creating a key shows "Your organization has been above its contracted AI Gateway requests for 30 days" | New gateway keys wait until the capacity is raised. Existing keys keep working. Ask your partner or WASViking to add capacity; new keys work again as soon as it is raised. |
502 no_route |
No route serves this model in this request format. |
502 upstream_unavailable |
Every provider route failed. Check Routing & Failover. |
503 policy_unavailable |
Policy could not be evaluated and the gateway denies when that happens. |
What next
- Protect agent tools with the MCP Gateway.
- Measure your rules with AI Security Testing and keep the record in AI Governance (AI Guardian overview).
- Subscribe a channel to AI Guardian Gateway Degraded in Alert destinations to hear when a gateway cannot evaluate policy or reach a provider.
