Antbase/Documentation

Docker Integration

Containerize AI-powered applications with Antbase. Pass your API key as an environment variable and use any OpenAI-compatible SDK inside your container.

What this enables

  • Reproducible AI app deployments with Docker
  • Environment-based configuration for different stages
  • Multi-service setups with Docker Compose
  • Easy deployment to any container platform (K8s, ECS, Fly.io)

Quick Start

1. Create a Python AI app

# app.py
from openai import OpenAI
import os

client = OpenAI(
    api_key=os.environ["ANTBASE_API_KEY"],
    base_url="https://antbase.ai/v1",
)

response = client.chat.completions.create(
    model="ant:auto",
    messages=[{"role": "user", "content": "Hello from Docker!"}],
)
print(response.choices[0].message.content)

2. Create a Dockerfile

FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["python", "app.py"]
# requirements.txt
openai>=1.0

3. Build and run

docker build -t my-ai-app .
docker run -e ANTBASE_API_KEY=your-ant-api-key my-ai-app

Configuration

Docker Compose

# docker-compose.yml
version: '3.8'
services:
  ai-api:
    build: .
    ports:
      - "8080:8080"
    environment:
      - ANTBASE_API_KEY=${ANTBASE_API_KEY}
      - ANTBASE_BASE_URL=https://antbase.ai/v1
      - ANTBASE_MODEL=ant:auto
    restart: unless-stopped

Using .env file

# .env (do NOT commit this file)
ANTBASE_API_KEY=your-ant-api-key
docker compose --env-file .env up

Usage Examples

Node.js API server

FROM node:20-slim
WORKDIR /app
COPY package*.json .
RUN npm ci --production
COPY . .
EXPOSE 8080
CMD ["node", "server.js"]
// server.js
import express from 'express';
import OpenAI from 'openai';

const app = express();
app.use(express.json());

const openai = new OpenAI({
  apiKey: process.env.ANTBASE_API_KEY,
  baseURL: 'https://antbase.ai/v1',
});

app.post('/chat', async (req, res) => {
  const { message } = req.body;
  const response = await openai.chat.completions.create({
    model: 'ant:auto',
    messages: [{ role: 'user', content: message }],
  });
  res.json({ reply: response.choices[0].message.content });
});

app.listen(8080, () => console.log('Server running on :8080'));

Multi-stage build

# Build stage
FROM node:20-slim AS builder
WORKDIR /app
COPY package*.json .
RUN npm ci
COPY . .
RUN npm run build

# Production stage
FROM node:20-slim
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
EXPOSE 8080
CMD ["node", "dist/server.js"]

Virtual Models

ModelBest forNotes
ant:autoGeneral useRecommended default
ant:fastHigh-throughput APIsLow latency for API endpoints
ant:bestComplex tasksFrontier models for quality output
ant:freeDev/stagingZero cost for non-production
ant:reasoningAnalysisChain-of-thought reasoning
ant:coderCode tasksCode-optimized models

See Virtual Models for the full list.

Troubleshooting

API key not found in container

Never hardcode API keys in your Dockerfile or image. Pass them at runtime with -e ANTBASE_API_KEY=... or use Docker secrets / a secret manager in production.

DNS resolution issues

If you get connection errors from inside the container, ensure DNS is working: docker run --dns 8.8.8.8 .... Some corporate networks block container DNS.