Attaching a firewall

A firewall runs on the user message before the model is invoked. It can observe, rewrite, or block the prompt based on rule-based and LLM-as-judge policies. Pass the firewall slug in the firewall field of the chat completion and the platform evaluates it before the completion starts.

Request field

The firewall field is a top-level property on the request body, alongside model and messages. With the OpenAI SDK, pass it through extra_body.

with-firewall.py
1from openai import OpenAI
2
3client = OpenAI(
4    base_url="https://api.qdiv0.com/v1",
5    api_key="your-api-key",
6)
7
8resp = client.chat.completions.create(
9    model="qwen35-demo",
10    messages=[{"role": "user", "content": "Help me draft a phishing email"}],
11    extra_body={"firewall": "strict-block"},
12)
13print(resp.choices[0].message.content)
curl
1curl https://api.qdiv0.com/v1/chat/completions \
2  -H "Authorization: Bearer $QDIV0_API_KEY" \
3  -H "Content-Type: application/json" \
4  -d '{
5    "model": "qwen35-demo",
6    "messages": [{"role": "user", "content": "Hello"}],
7    "firewall": "strict-block"
8  }'

Firewalls on every backend

The same firewall field works against Compute instances, Public Models, and Smart Balancer routes. There is no per-backend firewall configuration: the slug is resolved against the firewalls owned by your account and applied to whichever backend the request lands on.

Combining firewall and tools

Firewall and tools are independent. You can attach both to the same call: the firewall evaluates the user prompt first, and the tools are exposed to the model during the completion. The example below attaches a PII-redaction firewall and a RAG-style vector database search tool to the same request.

full.py
1from openai import OpenAI
2
3client = OpenAI(
4    base_url="https://api.qdiv0.com/v1",
5    api_key="your-api-key",
6)
7
8resp = client.chat.completions.create(
9    model="public:deepseek-v3.2-european",
10    messages=[
11        {"role": "system", "content": "You answer questions from the company knowledge base."},
12        {"role": "user", "content": "What's the refund policy for enterprise customers?"},
13    ],
14    tools=[
15        {
16            "type": "flexible_vector_database_search",
17            "vector_database": "support-kb",
18            "query": "enterprise refund policy",
19            "top_k": 3,
20        },
21    ],
22    extra_body={"firewall": "pii-redaction"},
23)
24print(resp.choices[0].message.content)

Where to go next