Skip to main content

Build from Source

Use this path when you want to build and run the firewall locally.

Install Rust

curl https://sh.rustup.rs -sSf | sh
source "$HOME/.cargo/env"
rustc --version
cargo --version

Start Redis

Redis is required for exact caching.

docker run -d --name redis-aif -p 6379:6379 redis:8
docker exec -it redis-aif redis-cli ping

Expected output:

PONG

Start Qdrant

Qdrant is required only when semantic cache is enabled.

docker run -d --rm --name qdrant \
-p 6333:6333 \
-p 6334:6334 \
qdrant/qdrant

Verify REST health:

curl http://127.0.0.1:6333/healthz

AI Cost Firewall uses Qdrant gRPC on port 6334. Port 6333 is exposed here for manual checks.

Build

git clone https://github.com/vcal-project/ai-firewall.git
cd ai-firewall
cargo build --release

The binary is created at:

./target/release/ai-firewall

Configure

cp configs/ai-firewall.conf.example configs/ai-firewall.conf
nano configs/ai-firewall.conf

For local source builds:

redis_url redis://127.0.0.1:6379;
qdrant_url http://127.0.0.1:6334;

Validate configuration

./target/release/ai-firewall --config configs/ai-firewall.conf --test-config

Or, if not built yet:

cargo run -- --config configs/ai-firewall.conf --test-config

Expected output:

configuration OK

Run

./target/release/ai-firewall --config configs/ai-firewall.conf

Check:

curl -i http://localhost:8080/healthz
curl -i http://localhost:8080/readyz
curl http://localhost:8080/metrics

Optional install

sudo install -m 0755 target/release/ai-firewall /usr/local/bin/ai-firewall