CLI¶
AIForge provides a command-line interface built on Typer
for scaffolding projects, starting servers, launching the playground,
running every SDK module from the terminal, and managing infrastructure.
The aiforge command is registered automatically when you install the package.
Table of Contents¶
- CLI
- Table of Contents
- Installation
- Global Help
- Infrastructure Commands
- Module Commands
- RAG Commands
- Agent Commands
- Evaluation Commands
- Discovery Commands
- Common Options
- Environment Variables
- Exit Codes
- Examples
- Makefile
- Docker
- Troubleshooting
- See Also
Installation¶
The aiforge command is available after installing the package:
Verify the installation:
Some commands require optional extras:
| Command | Required Extra | Install |
|---|---|---|
aiforge serve |
server |
pip install "aiforge-kit[server]" |
aiforge playground |
playground |
pip install "aiforge-kit[playground]" |
aiforge qa ask, aiforge chat |
agentic (LangGraph) |
pip install "aiforge-kit[agentic]" |
Any command with AIFORGE_PROVIDER=anthropic / ollama / gemini / bedrock / mistral |
that provider's extra | pip install "aiforge-kit[gemini]" etc. (see Providers) |
| All other commands | (none) | — |
Global Help¶
$ aiforge --help
Usage: aiforge [OPTIONS] COMMAND [ARGS]...
AIForge — plug-and-play AI toolkit
╭─ Commands ───────────────────────────────────────────────────────────────╮
│ init Scaffold aiforge.yaml + .env.example │
│ serve Start the FastAPI REST API server │
│ playground Start the Streamlit interactive playground │
│ migrate Inspect or manage vector store collections │
│ summarize Summarise text │
│ classify Classify text into labels │
│ extract Extract structured data from text │
│ generate Generate text from a prompt / template │
│ moderate Content moderation & PII redaction │
│ translate Translate text between languages │
│ vision Analyze images with vision models │
│ rewrite Rewrite text according to instructions │
│ sentiment Analyze text sentiment │
│ qa Document Q&A: ingest documents and ask questions │
│ search Semantic search: index documents and query │
│ chat Interactive AI chat agent │
│ config Show resolved configuration │
│ models List models & estimate costs │
│ registry Explore registered components │
│ eval Evaluate modules against test datasets │
╰──────────────────────────────────────────────────────────────────────────╯
Infrastructure Commands¶
aiforge init¶
Scaffold configuration files in the current directory.
Creates two files from bundled templates:
| File Created | Source Template | Purpose |
|---|---|---|
aiforge.yaml |
aiforge.yaml.example |
Main configuration |
.env |
.env.example |
API keys and secrets |
Options:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--force |
-f |
bool |
False |
Overwrite existing files |
Behaviour:
- If files already exist and
--forceis not set, they are silently skipped - Prints a green checkmark for each file created
- After running, edit
aiforge.yamland.envwith your provider and API keys
Examples:
# Scaffold a new project
mkdir my-project && cd my-project
aiforge init
# Reset config to defaults
aiforge init --force
aiforge serve¶
Start the FastAPI REST API server.
Requires the server extra (pip install "aiforge-kit[server]").
Options:
| Flag | Type | Default | Description |
|---|---|---|---|
--host |
str |
0.0.0.0 |
Bind address (all interfaces by default) |
--port |
int |
8000 |
Bind port |
--reload |
bool |
False |
Enable hot-reload for development |
Behaviour:
- Launches a Uvicorn server running the FastAPI app at
aiforge/server/app.py - Prints the server URL and Swagger docs URL on startup
- Server runs until interrupted (Ctrl+C)
- With
--reload, the server auto-restarts when source files change
Server Endpoints:
| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Liveness probe |
/health/ready |
GET | Readiness probe (validates config) |
/stats |
GET | Cost and token usage statistics |
/summarize |
POST | Summariser module |
/qa |
POST | Document Q&A module |
/classify |
POST | Classifier module |
/extract |
POST | Extractor module |
/search |
POST | Semantic search module |
/generate |
POST | Generator module |
/chat |
POST | Chat agent module |
/moderate |
POST | Content moderator module |
/pipeline |
POST | Pipeline execution |
/jobs |
POST/GET | Job management |
/docs |
GET | Swagger UI |
Configuration used:
The server reads all settings from the standard configuration system
(aiforge.yaml, .env, environment variables). Key settings:
| Variable | Default | Description |
|---|---|---|
AIFORGE_API_KEY |
— | Bearer token for auth (optional; if set, all endpoints require it) |
AIFORGE_CORS_ORIGINS |
* |
CORS allowed origins |
AIFORGE_PROVIDER |
openai |
LLM provider |
AIFORGE_MODEL |
gpt-4o |
LLM model |
AIFORGE_LOG_LEVEL |
INFO |
Log level |
AIFORGE_LOG_FORMAT |
console |
Log format (console or json) |
Examples:
# Default — listen on all interfaces, port 8000
aiforge serve
# Localhost-only on custom port
aiforge serve --host localhost --port 9000
# Development mode with auto-reload
aiforge serve --reload
# Production with env vars
AIFORGE_API_KEY=my-secret-key AIFORGE_LOG_FORMAT=json aiforge serve
aiforge playground¶
Launch the Streamlit interactive playground UI.
Requires the playground extra (pip install "aiforge-kit[playground]").
Options:
| Flag | Type | Default | Description |
|---|---|---|---|
--port |
int |
8501 |
Streamlit server port |
Behaviour:
- Spawns a separate Streamlit process running
aiforge/playground/app.py - Prints the playground URL on startup
- The playground reads all AIForge settings from the standard configuration
- Blocks until the Streamlit process exits (Ctrl+C to stop)
Playground Pages:
| Page | Module |
|---|---|
| Summarize | Summarizer |
| Q&A | DocQA |
| Search | SemanticSearch |
| Classify | Classifier |
| Extract | Extractor |
| Generate | Generator |
| Chat | ChatAgent |
| Moderate | Moderator |
| Pipeline | Pipeline |
| Settings | Configuration dashboard |
Examples:
aiforge migrate¶
Inspect or manage vector store collections.
Options:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--all |
-a |
bool |
False |
List all collections |
--status |
-s |
bool |
False |
Show collection statistics |
--collection |
-c |
str |
— | Inspect a specific collection |
--delete |
-d |
str |
— | Delete a named collection (with confirmation) |
At least one flag is required. If no action flag is provided, the command prints a usage hint and exits.
Behaviour:
- Initialises the vector store using
AIFORGE_CHROMA_PERSIST_DIR --all/--status: Displays a Rich table with collection names and chunk counts--collection: Filters the listing to a single collection--delete: Prompts for confirmation before deleting the collection (irreversible)
Output format (Rich table):
┌──────────────┬────────┐
│ Name │ Chunks │
├──────────────┼────────┤
│ default │ 1,247 │
│ products │ 89 │
│ support-docs │ 403 │
└──────────────┴────────┘
Configuration used:
| Variable | Default | Description |
|---|---|---|
AIFORGE_CHROMA_PERSIST_DIR |
./aiforge_data |
ChromaDB storage directory |
Examples:
# List all collections with chunk counts
aiforge migrate --all
# List with detailed stats
aiforge migrate -a -s
# Inspect a single collection
aiforge migrate --collection my_docs
# Delete a collection (prompts for confirmation)
aiforge migrate --delete old_collection
Module Commands¶
Every SDK module is exposed as a top-level CLI command. Module commands share a common set of options described in Common Options.
aiforge summarize¶
Summarise text with configurable style and strategy.
aiforge summarize --text "long article…"
aiforge summarize --file article.txt --style bullets --strategy map_reduce
cat article.txt | aiforge summarize
Options:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--text |
-t |
str |
— | Text to summarise |
--file |
-f |
path |
— | Read text from a file |
--style |
-s |
str |
paragraph |
Output style: paragraph | bullets | headline |
--max-length |
int |
— | Approximate max output length (tokens) | |
--strategy |
str |
— | Chunking strategy: stuff | map_reduce | refine |
|
--output |
-o |
path |
— | Write result to file |
--format |
str |
json |
Output format: json | yaml |
If --text and --file are both omitted, the command reads from stdin.
aiforge classify¶
Classify text into one or more labels.
aiforge classify --text "I love this product" --labels "positive,negative,neutral"
aiforge classify -f review.txt -l "spam,ham" --multi-label
Options:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--text |
-t |
str |
— | Text to classify |
--file |
-f |
path |
— | Read text from a file |
--labels |
-l |
str |
(required) | Comma-separated candidate labels |
--multi-label |
bool |
False |
Allow multiple labels | |
--examples-file |
path |
— | JSON file with few-shot examples | |
--output |
-o |
path |
— | Write result to file |
--format |
str |
json |
Output format: json | yaml |
aiforge extract¶
Extract structured data from text using a JSON schema.
aiforge extract --text "John Doe, age 32, NYC" --schema-file person.json
cat receipt.txt | aiforge extract --schema-file receipt_schema.json
Options:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--text |
-t |
str |
— | Text to extract from |
--file |
-f |
path |
— | Read text from a file |
--schema-file |
path |
— | JSON Schema file defining the output structure | |
--max-retries |
int |
2 |
Max validation retries | |
--output |
-o |
path |
— | Write result to file |
--format |
str |
json |
Output format: json | yaml |
aiforge generate¶
Generate text from a prompt or Jinja2 template.
aiforge generate --prompt "Write a haiku about coding"
aiforge generate -f template.txt --var topic=AI --var tone=formal
aiforge generate -p "List 5 ideas" --guardrails competitors --max-tokens 200
Options:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--prompt |
-p |
str |
— | Prompt text |
--file |
-f |
path |
— | Read prompt from a file |
--var |
str |
— | Template variable as key=value (repeatable) |
|
--guardrails |
-g |
str |
— | Comma-separated guardrail names |
--max-tokens |
int |
— | Max output tokens | |
--temperature |
float |
— | Sampling temperature (0.0–2.0) | |
--output |
-o |
path |
— | Write result to file |
--format |
str |
json |
Output format: json | yaml |
aiforge moderate¶
Content moderation and PII redaction.
aiforge moderate --text "Check this user post…"
aiforge moderate --file comment.txt --checks toxicity,bias
aiforge moderate --text "My SSN is 123-45-6789" --redact
Options:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--text |
-t |
str |
— | Text to moderate |
--file |
-f |
path |
— | Read text from a file |
--checks |
-c |
str |
— | Comma-separated checks (e.g. toxicity,bias,pii) |
--pii-types |
str |
— | Comma-separated PII types to detect | |
--redact |
-r |
bool |
False |
Redact PII instead of just flagging |
--output |
-o |
path |
— | Write result to file |
--format |
str |
json |
Output format: json | yaml |
RAG Commands¶
AIForge has two RAG-oriented modules. They both use vector stores and embeddings, but serve different purposes:
qa |
search |
|
|---|---|---|
| Purpose | Answer a question in natural language | Find the most similar documents |
| LLM calls | Yes — agentic pipeline generates an answer | None — embedding-only |
| Ingestion | Raw files/dirs/URLs (auto-chunks & embeds) | Pre-structured documents (id + text + metadata) |
| Output | Synthesized answer, sources, confidence | Ranked hits with similarity scores |
| Cost | Embedding + LLM tokens | Embedding tokens only |
| Use when | You need a written answer derived from docs | You need a ranked list of matching passages |
Think of search as a smarter grep and qa as a research assistant that
reads the results and writes you an answer.
aiforge qa¶
Document Q&A using retrieval-augmented generation (RAG). Has two
subcommands: ingest (load documents) and ask (query them).
aiforge qa ingest¶
aiforge qa ingest ./docs/ --collection my-docs --extensions ".md,.txt"
aiforge qa ingest ./docs/ --collection my-docs --mode incremental
aiforge qa ingest https://github.com/user/repo --collection repo-docs
Arguments:
| Argument | Required | Description |
|---|---|---|
SOURCE |
Yes | File path, directory, or git URL to ingest |
Options:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--collection |
-c |
str |
default |
Target collection name |
--extensions |
-e |
str |
— | Comma-separated file extensions (e.g. .py,.md) |
--batch-size |
int |
100 |
Embedding batch size | |
--mode |
str |
full |
Ingest mode: full | incremental |
|
--format |
str |
json |
Output format: json | yaml |
--mode incremental re-indexes only changed/new files and purges stale chunks for updated/deleted files.
aiforge qa ask¶
aiforge qa ask "How does authentication work?"
aiforge qa ask "What is the retry policy?" --collection my-docs --trace
Arguments:
| Argument | Required | Description |
|---|---|---|
QUERY |
Yes | The question to ask |
Options:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--collection |
-c |
str |
default |
Collection to search |
--filter |
str |
— | Filter results by source path substring | |
--trace |
bool |
False |
Include agent reasoning trace | |
--output |
-o |
path |
— | Write result to file |
--format |
str |
json |
Output format: json | yaml |
aiforge search¶
Semantic search over indexed documents. Has two subcommands:
index (build index) and query (search).
aiforge search index¶
Arguments:
| Argument | Required | Description |
|---|---|---|
SOURCE |
Yes | File path or directory to index |
Options:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--collection |
-c |
str |
default |
Target collection |
--extensions |
-e |
str |
— | Comma-separated file extensions |
--format |
str |
json |
Output format: json | yaml |
aiforge search query¶
aiforge search query "database connection pooling" --top-k 10
aiforge search query "error handling" --format table
Arguments:
| Argument | Required | Description |
|---|---|---|
QUERY |
Yes | Search query text |
Options:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--collection |
-c |
str |
default |
Collection to search |
--top-k |
-k |
int |
5 |
Number of results (1–100) |
--output |
-o |
path |
— | Write result to file |
--format |
str |
json |
Output format: json | yaml | table |
When --format table is used, results are displayed as a Rich table with
columns: #, Score, ID, Text.
Agent Commands¶
aiforge chat¶
Interactive chat with an AI agent. Supports single-turn and REPL modes.
Arguments:
| Argument | Required | Description |
|---|---|---|
MESSAGE |
No | Single message (omit for interactive REPL) |
Options:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--system |
-s |
str |
— | System prompt |
--memory |
-m |
str |
buffer |
Memory mode: buffer | summary | none |
--memory-k |
int |
10 |
Messages to keep in memory |
Interactive REPL commands:
| Command | Description |
|---|---|
/reset |
Clear conversation history |
/quit or /exit |
Exit the chat |
Ctrl+C |
Exit the chat |
Evaluation Commands¶
aiforge eval run¶
Run a module or a Python callable over a dataset, score each output and print a report. It exits non-zero when a threshold is missed or the run regressed against a baseline, so it can gate CI.
aiforge eval run cases.jsonl --module classify \
--module-args '{"labels": ["billing", "bug", "feature_request"]}' \
--scorer label_match --min-pass-rate 0.9 \
--output report.json --baseline main-report.json
DATASET is a .jsonl, .json, .yaml/.yml or .csv file. Pass either
--module or --target.
| Option | Short | Default | Description |
|---|---|---|---|
--module |
-m |
— | Registered module name, e.g. classify |
--module-args |
— | Module constructor kwargs as JSON, e.g. '{"labels": ["a"]}' |
|
--target |
— | Callable to evaluate instead of a module: pkg.mod:func |
|
--method |
module's main method | Module method to call | |
--call-args |
— | Kwargs passed on every call, as JSON | |
--scorer |
-s |
— | Scorer name, optionally with JSON params: 'contains:{"value": "refund"}'. Repeatable |
--min-pass-rate |
1.0 |
Minimum pass rate (0–1) for every scorer | |
--threshold |
— | Per-scorer minimum, e.g. llm_judge=0.8. Repeatable |
|
--concurrency |
-c |
5 |
Cases in flight |
--timeout |
— | Per-case timeout (seconds) | |
--judge-provider |
configured | Provider for llm_judge |
|
--judge-model |
configured | Model for llm_judge |
|
--output |
-o |
— | Write the JSON report here |
--baseline |
-b |
— | Baseline report to compare against |
--tolerance |
0.0 |
Allowed drop (0–1) before a regression is flagged | |
--name |
dataset file stem | Report name | |
--max-failures |
10 |
Failing cases to print |
aiforge eval compare¶
Compare two saved reports and flag per-scorer regressions. Exits 3 when the
current report regressed.
| Argument / Option | Default | Description |
|---|---|---|
CURRENT |
(required) | Current report JSON |
BASELINE |
(required) | Baseline report JSON |
--tolerance |
0.0 |
Allowed drop (0–1) before a regression is flagged |
See Evaluations for scorers, datasets and the report format.
Discovery Commands¶
aiforge config¶
Display the resolved AIForge configuration.
Options:
| Flag | Type | Default | Description |
|---|---|---|---|
--format |
str |
json |
Output format: json | yaml |
--reveal |
bool |
False |
Show secret values (keys, tokens); masked by default |
Secrets (any key containing key, secret, token, password, or
credential) are replaced with *** unless --reveal is specified.
aiforge models¶
List available models and estimate costs.
aiforge models list¶
aiforge models list
aiforge models list --quality fast --provider openai
aiforge models list --format json
Options:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--quality |
-q |
str |
— | Filter by tier: fast | balanced | quality |
--provider |
-p |
str |
— | Filter by provider name |
--format |
str |
table |
Output format: json | yaml | table |
Table output columns: Model, Provider, Quality, Context, Input $/1K, Output $/1K.
aiforge models estimate¶
Arguments:
| Argument | Required | Description |
|---|---|---|
MODEL |
Yes | Model name (e.g. gpt-4o-mini) |
Options:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--input |
-i |
int |
1000 |
Estimated input tokens |
--output |
-o |
int |
500 |
Estimated output tokens |
aiforge registry¶
Show all registered modules, providers, and vector stores.
Options:
| Flag | Type | Default | Description |
|---|---|---|---|
--format |
str |
table |
Output format: json | yaml | table |
Table output shows three categories: modules, providers, vectorstores and their registered items.
Common Options¶
Most module commands share these patterns:
Input: Every module command accepts --text/-t for inline text,
--file/-f to read from a file, or stdin when both are omitted:
aiforge summarize --text "inline text"
aiforge summarize --file doc.txt
echo "piped text" | aiforge summarize
Output: Use --output/-o to write results to a file instead of stdout,
and --format to switch between JSON and YAML:
aiforge classify -t "hello" -l "en,fr" --format yaml
aiforge extract -f data.txt --schema-file s.json -o result.json
Metrics footer: After every module call, the CLI prints a one-line metrics footer showing cost, token counts, and latency:
CLI commands interact with AIForge's layered configuration system. The priority order (lowest to highest):
1. Built-in defaults in code
2. aiforge.yaml (if present in cwd)
3. .env file (if present in cwd)
4. Environment variables (AIFORGE_* prefix)
5. CLI flags (--host, --port, etc.)
CLI flags like --host, --port, and --reload are command-specific and
override nothing in the settings system — they are passed directly to the
underlying server process. All other configuration (provider, model, API keys,
etc.) flows through the standard settings hierarchy.
Example flow:
# aiforge.yaml has provider: openai
# .env has AIFORGE_MODEL=gpt-4o-mini
# Shell has: export AIFORGE_MODEL=gpt-4o
aiforge serve --port 9000
# → Port: 9000 (from CLI flag)
# → Model: gpt-4o (env var wins over .env)
# → Provider: openai (from aiforge.yaml)
Environment Variables¶
Common environment variables used across CLI commands:
| Variable | Default | Used By | Description |
|---|---|---|---|
AIFORGE_PROVIDER |
openai |
serve, playground |
LLM provider |
AIFORGE_MODEL |
gpt-4o |
serve, playground |
LLM model |
AIFORGE_OPENAI_API_KEY |
— | serve, playground |
OpenAI API key |
AIFORGE_ANTHROPIC_API_KEY |
— | serve, playground |
Anthropic API key |
AIFORGE_VOYAGE_API_KEY |
— | serve, playground |
Voyage AI embedding key |
AIFORGE_AZURE_OPENAI_API_KEY |
— | serve, playground |
Azure OpenAI key |
AIFORGE_AZURE_OPENAI_ENDPOINT |
— | serve, playground |
Azure resource URL |
AIFORGE_OLLAMA_BASE_URL |
http://localhost:11434 |
serve, playground |
Ollama server URL |
AIFORGE_GOOGLE_API_KEY |
— | serve, playground |
Google Gemini API key |
AIFORGE_MISTRAL_API_KEY |
— | serve, playground |
Mistral API key |
AIFORGE_AWS_REGION |
AWS default | serve, playground |
Amazon Bedrock region |
AIFORGE_AWS_PROFILE |
— | serve, playground |
AWS named profile for Bedrock |
AIFORGE_CHROMA_PERSIST_DIR |
./aiforge_data |
migrate |
ChromaDB data directory |
AIFORGE_API_KEY |
— | serve |
API auth bearer token |
AIFORGE_LOG_LEVEL |
INFO |
serve |
Logging level |
AIFORGE_LOG_FORMAT |
json |
serve |
Log format (json / console) |
AIFORGE_CORS_ORIGINS |
* |
serve |
CORS allowed origins |
Exit Codes¶
| Code | Meaning |
|---|---|
0 |
Success |
1 |
Missing dependency (uvicorn or streamlit not installed) |
aiforge eval has its own exit codes so it can gate CI:
| Code | Meaning |
|---|---|
0 |
Every scorer met its threshold and there was no regression |
1 |
At least one scorer is below its minimum pass rate |
2 |
Bad usage (unknown module or scorer, invalid JSON, …) |
3 |
Thresholds met, but the run regressed against the baseline |
All commands use Rich console output for coloured, formatted messages: - Green checkmarks for success - Red text for errors with install instructions - Yellow text for warnings or no-action hints
Examples¶
Scaffold a New Project¶
mkdir my-ai-app && cd my-ai-app
aiforge init
# ✓ Created aiforge.yaml
# ✓ Created .env
nano aiforge.yaml # Set provider, model, etc.
nano .env # Add API keys
Start the API Server¶
aiforge serve
aiforge serve --reload --port 9000
AIFORGE_API_KEY=secret-token AIFORGE_LOG_FORMAT=json aiforge serve
Launch the Playground¶
Run Module Commands¶
# Summarise a file
aiforge summarize --file article.txt --style bullets
# Classify piped input
echo "This is spam" | aiforge classify -l "spam,ham"
# Extract structured data
aiforge extract --text "Alice, 30, NYC" --schema-file person.json --format yaml
# Generate with template variables
aiforge generate -f email_template.txt --var name=Alice --var product=Widget
# Moderate and redact PII
aiforge moderate --text "Call me at 555-867-5309" --redact
Document Q&A Workflow¶
# Ingest documentation
aiforge qa ingest ./docs/ --collection my-docs --extensions ".md,.txt"
# ✓ Indexed 247 chunks from 12 files into 'my-docs'.
# Incremental re-index after edits
aiforge qa ingest ./docs/ --collection my-docs --mode incremental
# Ask questions
aiforge qa ask "How do I configure authentication?" --collection my-docs
Semantic Search Workflow¶
# Index a codebase
aiforge search index ./src/ --collection codebase --extensions ".py,.ts"
# Search with a Rich table
aiforge search query "error handling patterns" --top-k 10 --format table
Interactive Chat¶
# Single question
aiforge chat "Explain Python decorators"
# REPL session
aiforge chat --system "You are a helpful coding assistant"
# you > How do I sort a dict by value?
# ...
# you > /quit
Explore Models & Config¶
# See resolved config (secrets masked)
aiforge config
# List all models in table form
aiforge models list
# Estimate cost
aiforge models estimate gpt-4o --input 5000 --output 2000
# See registered components
aiforge registry
Manage Collections¶
Docker Compose Workflow¶
# Build and start API + Playground
docker compose up -d
# Or use the Makefile shortcut
make docker-up
# API: http://localhost:8000
# Swagger: http://localhost:8000/docs
# Playground: http://localhost:8501
See Docker below for full details on the Dockerfile and compose configuration.
Makefile¶
The project includes a Makefile with shortcuts for common development
tasks. Run make help to see all targets:
$ make help
help Show this help
venv Create virtual environment
install Install core dependencies
install-dev Install with dev extras
install-all Install all extras
lint Run ruff linter
format Auto-format code with ruff
typecheck Run mypy type checks
test Run tests
test-cov Run tests with coverage report
serve Start the API server (dev mode)
playground Start the Streamlit playground
docker-build Build Docker image
docker-up Start all services (API + Playground)
docker-down Stop all services
docker-logs Tail service logs
clean Remove build artifacts and caches
Quick Start with Make¶
# First-time setup
make install-dev # creates venv + installs with dev extras
# Daily workflow
make lint # check code style
make format # auto-fix formatting
make typecheck # run mypy
make test # run test suite
make test-cov # run tests with HTML coverage report
# Run locally
make serve # starts API server with --reload
make playground # starts Streamlit UI
Docker via Make¶
make docker-build # docker compose build
make docker-up # docker compose up -d
make docker-logs # docker compose logs -f
make docker-down # docker compose down
Cleanup¶
Docker¶
AIForge ships with a multi-stage Dockerfile and a docker-compose.yml
that runs both the API server and the Playground UI.
Dockerfile¶
The Dockerfile uses a two-stage build:
- Builder — installs the package with
server,agentic, anddocsextras into a prefix directory. - Runtime — copies only the installed packages into a slim image.
# Build the image manually
docker build -t aiforge .
# Run the API server
docker run -p 8000:8000 --env-file .env aiforge
# Run with a persistent ChromaDB volume
docker run -p 8000:8000 --env-file .env \
-v aiforge-data:/data/chroma \
-e AIFORGE_CHROMA_PERSIST_DIR=/data/chroma \
aiforge
# Override the entrypoint to run the playground instead
docker run -p 8501:8501 --env-file .env \
aiforge playground --port 8501
The image exposes port 8000 and includes a HEALTHCHECK that hits
/health every 30 seconds.
docker-compose.yml¶
The compose file defines two services:
| Service | Port | Description |
|---|---|---|
api |
8000 (configurable via AIFORGE_PORT) |
FastAPI server with ChromaDB volume |
playground |
8501 (configurable via AIFORGE_PLAYGROUND_PORT) |
Streamlit UI, waits for API health |
# Start everything
docker compose up -d
# Custom ports
AIFORGE_PORT=9000 AIFORGE_PLAYGROUND_PORT=9501 docker compose up -d
# View logs
docker compose logs -f
# Tear down (data persists in the named volume)
docker compose down
# Tear down AND delete data
docker compose down -v
Both services read secrets from .env via env_file. The API service's
ChromaDB data is stored in a named volume (chroma-data) so it survives
container restarts.
Troubleshooting¶
| Symptom | Cause | Fix |
|---|---|---|
command not found: aiforge |
Package not installed or venv not activated | pip install -e "." and activate your virtual environment |
uvicorn not installed when running serve |
Missing server extra | pip install "aiforge-kit[server]" |
Streamlit not installed when running playground |
Missing playground extra | pip install "aiforge-kit[playground]" |
aiforge init skips files silently |
Files already exist | Use aiforge init --force to overwrite |
aiforge migrate prints "No action specified" |
No flag provided | Add --all, --status, --collection, or --delete |
| Module command hangs waiting for input | No --text/--file and stdin is a terminal |
Provide --text or --file, or pipe input |
| Server requests fail with 401 | AIFORGE_API_KEY is set |
Include Authorization: Bearer <key> header in requests |
| LLM calls fail | API keys not configured | Edit .env or set AIFORGE_OPENAI_API_KEY etc. |
config shows *** for keys |
Secrets masked by default | Use aiforge config --reveal to view |
models list returns empty table |
No provider configured | Set AIFORGE_PROVIDER and API key |
| Port already in use | Another process on that port | Use --port <other> or stop the conflicting process |
See Also¶
- Quick Start — Getting started guide
- Configuration — Full configuration reference
- API Server — REST API endpoints and authentication
- API Auth — API key authentication details
- Playground — Interactive UI documentation
- Providers — Provider setup and configuration
- Evaluations — Datasets, scorers and CI gating for
aiforge eval