Skip to main content

Smart API Router

How a zn Cloud API request moves through rules and the Galvanize 3.1 model, and how zn-gate fits in front of it.

View .md

This page is for developers who call the optional zn Cloud API from their own code. Just want to protect your coding agent? Open your own terminal (not the agent's chat), run npx -y zn-gate init, then npx -y zn-gate check. Step by step: Install.

Every call to the zn Cloud API (POST /analyze) goes through the Smart API Router. It runs two layers in the same request and combines them; zn-gate can run a third layer on your machine before anything is sent.

Layer 1: rules

Deterministic regex and structure checks for instruction overrides, sensitive paths, exfiltration patterns and obfuscation. A high-confidence match decides the verdict; the model still scores the request.

Layer 2: Galvanize 3.1

The neural model scores almost every request, so paraphrased and multilingual inputs are covered even when no rule matches. The threshold applied is returned in every response as threshold. The verdict is block if either layer blocks. If Galvanize 3.1 is unavailable, the previous model, Galvanize-60M, scores the request instead, at its own threshold of 0.95; ml_version in the response says which model was used.

Model property Value
Base model Fine-tuned from Horizon-Labs/prompt-injection-guard-small (Apache-2.0), multilingual
Input Up to 2,000 characters are scored in one pass; longer inputs in overlapping 512-token windows (up to 20)
Runtime Full-precision ONNX on CPU

Results, method and weak spots: Galvanize 3.1: catching the injections hidden in what your agent reads. The previous models: Galvanize 2 (results, open weights: usezn/Galvanize-2) and Galvanize-60M.

Layer 3: zn-gate on your machine (optional)

zn-gate runs its own rules locally first: if they block a prompt, nothing is sent. Tool arguments never leave your machine, and tool output does not either unless you turn on the opt-in cloudCheckToolOutput setting in Claude Code, which sends a capped, redacted sample. Local checks are free and never count against cloud quota; their measured latency is in the FAQ. The Galvanize 3.1 weights are open on Hugging Face (usezn/Galvanize-3.1) if you want to self-host the model; the previous Galvanize 2 and Galvanize-60M weights are there too, under Apache-2.0.

Which layer decided?

Read decided_by in the response (rules, ml, or a fallback value) and the X-ZN-Router-Level header. Every analyzed request counts against your plan, whichever layer decided. The neural model scores every request except short small talk, such as a greeting, which the rules allow without it (X-ZN-Model-Score is then n/a). If both models fail, the rules alone decide and X-ZN-Model-Score is n/a.