Deploy Guardrail Models with vLLM
Overview
Akto's Agent Guard can run its guard models on infrastructure that you control. This guide explains how to serve the models on your own GPU host with vLLM. vLLM exposes an OpenAI-compatible API (/v1/chat/completions), and Akto connects to that API.
The guide covers these models:
Gemma 4 26B A4B IT
gemma-4-26b-a4b-it
High-accuracy arbiter (MoE, 4B active parameters)
Prerequisites
A Linux host with at least one NVIDIA H100 80GB GPU, for example AWS
p5, GCPa3-highgpu, or AzureND H100 v5.At least 200 GB of free disk space for model weights and the vLLM compile cache.
The NVIDIA driver, Docker, and the NVIDIA Container Toolkit installed. On Ubuntu, the install script installs Docker and the toolkit for you.
A Hugging Face access token with read access.
The Gemma models are gated. Sign in to Hugging Face with the account that owns the token, then accept the license on the Gemma 4 E2B and Gemma 4 26B A4B model pages. Qwen3Guard is not gated.
Quick Start with the Install Script
The script below runs the whole setup on a fresh Ubuntu 22.04 or 24.04 GPU host. It does the following:
Installs Docker Engine from Docker's official apt repository, unless Docker is already installed.
Installs and configures the NVIDIA Container Toolkit, unless it is already installed.
Checks that Docker can access the GPU.
Starts the vLLM container for the model you choose, and replaces an existing container of the same name.
Waits until the server is healthy, then prints the base URL and served model name.
Save the script as deploy-vllm.sh:
Run it with the model you want to deploy:
Set MODEL to qwen3guard, gemma4-e2b, or gemma4-26b-a4b. If VLLM_API_KEY is not set, the script generates a key and prints it once at the end. Store that key securely.
You can override these optional variables the same way as MODEL:
GPU_DEVICE
0
Index of the GPU to run the model on
HOST_PORT
80
Host port that exposes the API
MAX_MODEL_LEN
8192
Value for --max-model-len
MAX_NUM_SEQS
16
Value for --max-num-seqs
GPU_MEMORY_UTILIZATION
0.90
Value for --gpu-memory-utilization
VLLM_IMAGE
Per model, as in the commands below
vLLM Docker image
STARTUP_TIMEOUT_SEC
1800
How long to wait for the server to become healthy
For example, to run Gemma 4 E2B on the second GPU and port 8002:
After the script finishes, continue with Verify the API. To set up the host by hand instead, follow the steps below.
Steps to Deploy
Set the credentials
Generate an API key. vLLM requires this key on every request:
Export the Hugging Face token and the generated key in your shell:
Treat both values as secrets. Do not commit them to source control or paste them into tickets or chat. To keep them out of your shell history, store them in an env file (chmod 600) and pass it to Docker with --env-file instead of -e.
Start the vLLM container
Run the command for the model you want to deploy. All three commands use the same flags. Only the model, the served name, the multimodal limits, and the container name differ.
Qwen3Guard is text-only, so the command omits --limit-mm-per-prompt.
In bfloat16, the weights use about 52 GB. With --gpu-memory-utilization 0.90, about 20 GB of the H100 remains for the KV cache.
The first start downloads the model weights and compiles CUDA graphs, which can take several minutes. Later starts reuse the huggingface-cache and vllm-cache volumes and are much faster.
Running Multiple Models
For production, deploy each model on its own GPU and give each container its own device and host port:
Container
--gpus
-p
qwen3guard-8b
'"device=0"'
8001:8000
gemma4-e2b
'"device=1"'
8002:8000
gemma4-26b-a4b
'"device=2"'
8003:8000
All containers can share the huggingface-cache and vllm-cache volumes.
--gpu-memory-utilization is the fraction of the whole GPU that one vLLM instance reserves. To share one H100 between two small models, for example Qwen3Guard 8B and Gemma 4 E2B, set a lower value on each container, such as 0.45, so that the sum stays below 0.90. Do not share a GPU with Gemma 4 26B A4B.
Tuning Parameters
--max-model-len
8192
Raise it if Akto scans prompts or responses longer than about 6,000 tokens. Longer contexts use more KV cache and reduce concurrency.
--max-num-seqs
16
The maximum number of requests processed in parallel. Raise it for higher throughput if the logs show free KV cache. Lower it if you see preemption warnings.
--gpu-memory-utilization
0.90
Lower it only when you share the GPU with another process or model.
--shm-size
16g
Shared memory for PyTorch workers. Keep it at 16g or higher.
--restart unless-stopped
—
Restarts the container after a crash or host reboot.
Security Recommendations
Restrict network access. Allow inbound traffic on the exposed port only from Akto's egress IPs or your internal network. Do not expose vLLM to the public internet without a firewall rule.
Terminate TLS. The container serves plain HTTP. Put a load balancer or reverse proxy (NGINX, AWS ALB, and similar) with a TLS certificate in front of it. This keeps the API key and scanned content encrypted in transit.
Rotate the API key. To rotate the key, set a new
VLLM_API_KEY, recreate the container, and share the new key with Akto.Pin the image version. In production, replace
latestwith a specific vLLM release tag so that upgrades happen only when you choose.
Troubleshooting
401 or 403 from Hugging Face when the container starts
The token is missing or invalid, or the Gemma license has not been accepted for the account that owns the token.
CUDA out of memory at startup
Another process is using the GPU. Check nvidia-smi, or lower --gpu-memory-utilization or --max-model-len.
could not select device driver "" with capabilities: [[gpu]]
The NVIDIA Container Toolkit is not installed or configured. Run sudo nvidia-ctk runtime configure --runtime=docker and restart Docker.
401 Unauthorized from vLLM
The Authorization: Bearer <key> header is missing or does not match VLLM_API_KEY.
404 with a message that the model does not exist
The model field in the request does not match --served-model-name.
Slow first request after a restart
CUDA graph capture and warm-up. Later requests are fast.
Last updated