For the complete documentation index, see llms.txt. This page is also available as Markdown.

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:

Model
Hugging Face ID
Served model name
Role

Qwen3Guard 8B

qwen3guard-gen-8b

Fast safety classifier

Gemma 4 E2B IT

gemma-4-e2b-it

Lightweight arbiter

Gemma 4 26B A4B IT

gemma-4-26b-a4b-it

High-accuracy arbiter (MoE, 4B active parameters)

Recommended GPU: NVIDIA H100 80GB. Each model fits on a single H100 (--tensor-parallel-size 1). For production, run one model per GPU.

Prerequisites

  • A Linux host with at least one NVIDIA H100 80GB GPU, for example AWS p5, GCP a3-highgpu, or Azure ND 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:

  1. Installs Docker Engine from Docker's official apt repository, unless Docker is already installed.

  2. Installs and configures the NVIDIA Container Toolkit, unless it is already installed.

  3. Checks that Docker can access the GPU.

  4. Starts the vLLM container for the model you choose, and replaces an existing container of the same name.

  5. Waits until the server is healthy, then prints the base URL and served model name.

The script does not install the NVIDIA driver, because a driver install requires a reboot. Most GPU cloud images include the driver. If nvidia-smi fails, install the driver (for example, sudo ubuntu-drivers install --gpgpu), reboot, and run the script again.

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:

Variable
Default
Description

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

1

Verify GPU access from Docker

Check that the host and Docker can both see the GPU:

Both commands must list the H100. If the second command fails, install or reconfigure the NVIDIA Container Toolkit, then restart Docker.

2

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:

3

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.

Guardrails only scan text. Setting the multimodal limits to 0 keeps vLLM from reserving GPU memory for the image and audio encoders. vLLM uses the extra memory for the KV cache.

4

Monitor the startup

The server is ready when the logs show Application startup complete. Then check the health endpoint. The health endpoint does not require the API key:

A 200 OK response means the model is loaded.

5

Verify the API

List the served models:

Send a test chat completion. Set model to the served model name of the container you started:

Qwen3Guard returns a verdict such as Safety: Unsafe followed by the violated category. A request without the Authorization header must return 401 Unauthorized.

6

Share the endpoint with Akto

Send these details to your Akto contact through a secure channel:

  • Base URL: http://<host-or-load-balancer>/v1, or the https:// URL if you terminate TLS

  • Served model name: for example, qwen3guard-gen-8b

  • API key: the value of VLLM_API_KEY

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.

Tuning Parameters

Flag
Default in this guide
When to change it

--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 latest with a specific vLLM release tag so that upgrades happen only when you choose.

Troubleshooting

Symptom
Likely cause and fix

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