Skip to main content

AI Gateway via Docker

This guide covers both standalone Docker (single host) and Docker Swarm (orchestrated cluster). Pick your deployment mode below; the selection persists across every step on this page.

Run the AI Gateway as a single container on one host. Best for evaluation, a single-node lab, or a small edge deployment.

Setup

Prerequisites

Before installing the Levo AI Gateway, ensure you have:

  • Met the system requirements listed in Install AI Gateway
  • Docker Engine 20.10.0 or higher
  • Admin privileges on the Docker host
  • Your Environment ID and Authorization Key from the steps in Install AI Gateway

Nothing additional — a single Docker host is all you need.

1. Pull the Images

docker pull levoai/ai-gateway:latest
docker pull levoai/ai-guardrails-models:latest

2. Prepare the Environment

No additional preparation is required — skip to step 3.

3. Populate the Models Volume (Guardrails Only)

Skip this step if you are installing without guardrails.

Guardrails require ML models (~4 GB) stored on a local Docker volume. Create the volume and populate it — this runs once and takes a few minutes:

docker volume create levoai-models

docker run --rm \
-v levoai-models:/opt/models \
levoai/ai-guardrails-models:latest \
cp -r /models/. /opt/models/

The volume lives on this host only.

4. Run the AI Gateway

docker run -d \
--name levoai-aigateway \
--restart unless-stopped \
-p 4141:8080 \
-e LEVOAI_BASE_URL="https://api.levo.ai" \
-e LEVO_ENVIRONMENT_ID="<Environment ID>" \
-e LEVOAI_AUTH_KEY="<Authorization Key>" \
-e LEVOAI_ORG_ID="<Organisation ID>" \
-e LEVOAI_ENV_NAME="<Environment Name>" \
-e LEVOAI_SATELLITE_URL="<Satellite URL>" \
-e MODELS_PATH="/opt/models" \
-v levoai-models:/opt/models:ro \
levoai/ai-gateway:latest

For LEVOAI_SATELLITE_URL, use https://satellite.levo.ai (Levo-hosted) or your own on-premise satellite address. For accounts on the India domain, set LEVOAI_BASE_URL to https://api.india-1.levo.ai.

5. Verify the Installation

Check that the container is running:

docker ps -f name=levoai-aigateway

If the AI Gateway is healthy, you should see output similar to the following:

CONTAINER ID   IMAGE                       COMMAND                CREATED         STATUS         PORTS                    NAMES
a3f1c2b9d4e7 levoai/ai-gateway:latest "/usr/local/bin/..." 1 minute ago Up 1 minute 0.0.0.0:4141->8080/tcp levoai-aigateway

Verify connectivity to Levo.ai by checking the logs:

docker logs levoai-aigateway | grep -iE "saas|policies"

If connectivity is healthy, you should see output similar to the following:

connecting to Levo SaaS platform; gateway will process all inbound requests for this environment
saas control plane started
policies control plane started
note

With guardrails enabled, the container may show 0/1 replicas (Swarm) or a non-ready health status (standalone) for the first 1–2 minutes while it warms up the ML model cache. This is expected — the gateway marks itself ready only after all scanner models are loaded.

Please contact support@levo.ai if you notice health or connectivity errors.

6. Configure Routes in the Levo Dashboard

The AI Gateway polls the Levo platform every 60 seconds and automatically applies the latest configuration. Routes, LLM backends, and guardrail policies are all managed from the dashboard.

Refer to step 5 in AI Gateway on Kubernetes for configuration instructions and an example YAML — the configuration format is identical for Docker and Kubernetes deployments.

7. Point Your Application at the Gateway

Update your application to send LLM requests to the gateway instead of directly to the LLM provider.

Replace the LLM provider's base URL with http://<Docker-host-IP>:4141/v1.

For example, if you are using the OpenAI SDK:

from openai import OpenAI

client = OpenAI(
base_url="http://<gateway-address>:4141/v1",
api_key="<Your OpenAI API Key>",
)

AI Gateway Lifecycle Management

Upgrade AI Gateway

Pull the latest image:

docker pull levoai/ai-gateway:latest

If you are running with guardrails, also refresh the models:

docker pull levoai/ai-guardrails-models:latest

docker run --rm \
-v levoai-models:/opt/models \
levoai/ai-guardrails-models:latest \
cp -r /models/. /opt/models/

Stop and remove the existing container, then re-run the docker run command from Step 4:

docker stop levoai-aigateway && docker rm levoai-aigateway

Stop AI Gateway

docker stop levoai-aigateway

Uninstall AI Gateway

docker stop levoai-aigateway && docker rm levoai-aigateway

If you created a models volume, remove it too:

docker volume rm levoai-models

Troubleshooting

Container or Service Fails to Start

Check the container logs for errors:

docker logs levoai-aigateway

Common causes:

  • Invalid credentials: Verify your LEVO_ENVIRONMENT_ID and LEVOAI_AUTH_KEY are correct and not expired.
  • Network connectivity: Confirm the host can reach api.levo.ai (or api.india-1.levo.ai) on port 443.
  • Missing models volume (guardrails only): the host or Swarm node running the container must have levoai-models populated. Repeat step 3 on that host.

Check Gateway Health

The readiness endpoint is on port 15021 inside the container and is not published externally:

docker exec levoai-aigateway curl -sf http://localhost:15021/healthz/ready

A healthy gateway responds with HTTP 200.

Enable Debug Logging

Stop and re-run the container with RUST_LOG=debug:

docker stop levoai-aigateway && docker rm levoai-aigateway

docker run -d \
--name levoai-aigateway \
--restart unless-stopped \
-p 4141:8080 \
-e LEVOAI_BASE_URL="https://api.levo.ai" \
-e LEVO_ENVIRONMENT_ID="<Environment ID>" \
-e LEVOAI_AUTH_KEY="<Authorization Key>" \
-e LEVOAI_ORG_ID="<Organisation ID>" \
-e LEVOAI_ENV_NAME="<Environment Name>" \
-e LEVOAI_SATELLITE_URL="<Satellite URL>" \
-e RUST_LOG="debug" \
levoai/ai-gateway:latest

Need Help?

For further assistance, please reach out to support@levo.ai.

Was this page helpful?