Quickstart
Three steps: get a gateway URL and key, change the base URL in your client, and read the verdict.
1. Get a URL and a key
During early access, a pilot gives you a gateway URL and an API key. Keep the key out of source control. Models are configured by the operator; list the ones available to you with GET /v1/models.
2. Send a request
curl
curl -sS "$GATEWAY/v1/chat/completions" \
-H "Authorization: Bearer $GATEWAY_KEY" \
-H "Content-Type: application/json" \
-D - \
-d '{
"model": "your-model-id",
"messages": [{"role": "user", "content": "Summarise the GDPR in two sentences."}],
"max_tokens": 200
}'Python
from openai import OpenAI
client = OpenAI(base_url="https://your-gateway.example/v1", api_key="YOUR_GATEWAY_KEY")
resp = client.chat.completions.with_raw_response.create(
model="your-model-id",
messages=[{"role": "user", "content": "Summarise the GDPR in two sentences."}],
max_tokens=200,
)
print(resp.headers.get("x-wattsfor-verdict")) # LEGAL for an allowed request
print(resp.parse().choices[0].message.content)Node
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://your-gateway.example/v1", apiKey: process.env.GATEWAY_KEY });
try {
const resp = await client.chat.completions.create({
model: "your-model-id",
messages: [{ role: "user", content: "Summarise the GDPR in two sentences." }],
max_tokens: 200,
});
console.log(resp.choices[0].message.content);
} catch (err) {
if (err.status === 451) console.log("Blocked by policy:", err.error?.message);
else throw err;
}3. Read the verdict
Allowed requests return the upstream response unchanged, with headers that say what the gate did. Blocked requests return HTTP 451 and your model is never called.
HTTP/1.1 451
x-wattsfor-verdict: ILLEGAL
x-wattsfor-risk-category: <category>
x-wattsfor-policy: <version>:<policy hash prefix>
{
"error": {
"message": "Prompt rejected by <classifier> ... (<category>): <reason>. Credits consumed.",
"type": "illegal_prompt_rejected",
"code": 451,
"credits_consumed_usd": 0.001,
"credits_remaining_usd": 9.998
}
}The shape is the gateway's; values in angle brackets and the credit amounts are illustrative. Header names currently carry the gateway's original x-wattsfor- prefix, which will change with the rename; match on the suffix, or pin the gateway version.
With the output guard on, a streamed completion is buffered by the gateway and released only after it has been inspected. The first token therefore arrives after the full completion has been generated. Turn the output guard off, or use non-streaming requests, if first-token latency matters more to you than output screening.
Things that will surprise you
- Only text content is accepted. A message whose content includes an image part is refused with a 400.
- If you omit
max_tokens, the gateway sets 2048 before forwarding. The maximum is 16,384. - Fields the gateway does not recognise are dropped, not forwarded. Keys that differ only in letter case (for example
Messages) are rejected. - Models the operator has not configured are refused with
unknown_model.
Next: the API reference and the error table.