Deployment
Deploy Structure-D as a FastAPI HTTP service or use the high-performance Rust CLI.
FastAPI service
Structure-D ships a production-ready FastAPI application factory. Start it with Uvicorn:
bash
# Development
uvicorn structure_d.api.app:create_app --factory --reload --port 8080
# Production
uvicorn structure_d.api.app:create_app \
--factory \
--host 0.0.0.0 \
--port 8080 \
--workers 4 Or programmatically:
python
import uvicorn
from structure_d.api.app import create_app
app = create_app()
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8080) API endpoints
All routes are mounted under /api/v1:
| Method | Path | Description |
|---|---|---|
GET | /api/v1/health | Health check |
GET | /api/v1/models | List registered models |
GET | /api/v1/schemas | List built-in schemas |
GET | /api/v1/formats | List supported file formats |
POST | /api/v1/extract | Upload a file and extract structured data |
Example extraction request:
bash
curl -X POST http://localhost:8080/api/v1/extract \
-F "file=@invoice.pdf" \
-F "schema_name=key_value" \
-F "task=extraction" \
-F "save_format=jsonl" Rust CLI
The CLI provides the same extraction pipeline as a native binary with no Python overhead:
bash
# Extract from a single file
structure-d extract invoice.pdf --schema key_value --output output/
# Batch extraction from a directory
structure-d batch invoices/ --schema key_value --concurrent 8
# List available schemas / models / formats
structure-d schemas
structure-d models
structure-d formats
# Use a custom config
structure-d extract doc.pdf --config configs/production.yaml Docker
Dockerfile dockerfile
FROM python:3.12-slim
WORKDIR /app
# Install system deps for Tesseract OCR (optional)
RUN apt-get update && apt-get install -y tesseract-ocr && rm -rf /var/lib/apt/lists/*
COPY pyproject.toml .
RUN pip install --no-cache-dir ".[ingestion,api,llm]"
COPY . .
EXPOSE 8080
CMD ["uvicorn", "structure_d.api.app:create_app", "--factory", "--host", "0.0.0.0", "--port", "8080"] bash
docker build -t structure-d .
docker run -p 8080:8080 \
-e OPENAI_API_KEY=sk-... \
-e SD_INFERENCE__PROVIDER__PROVIDER=openai \
structure-d Environment variables
| Variable | Description |
|---|---|
OPENAI_API_KEY | OpenAI API key |
ANTHROPIC_API_KEY | Anthropic API key |
GOOGLE_API_KEY | Gemini API key |
SD_INFERENCE__PROVIDER__PROVIDER | Override inference provider |
SD_LOG_LEVEL | Log level: DEBUG / INFO / WARNING / ERROR |
SD_API__PORT | FastAPI server port (default: 8080) |
SD_STORAGE__OUTPUT_DIR | Output directory for saved results |
API authentication is a Phase 3 feature
The current FastAPI service has no authentication layer. Do not expose it directly to the internet without a reverse proxy and authentication middleware.