This guide provides multiple ways to start the OpenTextShield API, supporting both Docker and local development environments.
./scripts/start.shBest for: Most users - automatically detects your environment and configures accordingly.
./scripts/start-local.shBest for: Local development with hot reload and development features.
./scripts/start-manual.shBest for: Users who already have dependencies installed and want direct control.
# Build locally (includes 679MB mBERT model)
docker build -t opentextshield .
docker run -d -p 8002:8002 -p 8080:8080 opentextshield
# Alternative if port 8080 is in use
docker run -d -p 8002:8002 -p 8081:8080 opentextshield
# Using pre-built image
docker pull telecomsxchange/opentextshield:latest
docker run -d -p 8002:8002 -p 8080:8080 telecomsxchange/opentextshield:latestAccess: API at http://localhost:8002, Frontend at http://localhost:8080 (or 8081)
- Python: 3.8+ (3.10+ recommended)
- Operating System: macOS, Linux, or Windows WSL
- Memory: 2GB+ RAM recommended
- Storage: 1GB+ free space
- Docker: Version 20.0+
- Memory: 4GB+ RAM recommended
- Storage: 2GB+ free space
| Script | Environment | Virtual Env | Dependencies | Hot Reload | Best For |
|---|---|---|---|---|---|
scripts/start.sh |
Auto-detect | ✅ Creates | ✅ Installs | ✅ Yes | General use |
scripts/start-local.sh |
Local only | ✅ Creates | ✅ Installs | ✅ Yes | Development |
scripts/start-manual.sh |
Any | ❌ Uses current | ❌ Must exist | ✅ Yes | Advanced users |
| Docker | Container | ✅ Built-in | ✅ Pre-installed | ❌ No | Production |
# Install Python if needed
brew install python3
# Start the API
./scripts/start.sh# Install Python if needed
sudo apt-get update
sudo apt-get install python3 python3-venv python3-pip
# Start the API
./scripts/start.sh# In WSL terminal
sudo apt-get update
sudo apt-get install python3 python3-venv python3-pip
# Start the API
./scripts/start.shOnce started, verify the API is working:
curl http://localhost:8002/healthOpen in browser: http://localhost:8002/docs
curl -X POST "http://localhost:8002/predict/" \
-H "Content-Type: application/json" \
-d '{"text":"Free money! Click here!","model":"bert"}'# API Configuration
export OTS_API_HOST=0.0.0.0
export OTS_API_PORT=8002
export OTS_LOG_LEVEL=INFO
# Security
export OTS_ALLOWED_IPS="127.0.0.1,10.0.0.0/8"
export OTS_CORS_ORIGINS="https://yourdomain.com"
# Models
export OTS_DEFAULT_MODEL=bert
export OTS_MAX_TEXT_LENGTH=512
# Then start
./scripts/start.shCreate a .env file in the project root:
OTS_API_PORT=8003
OTS_LOG_LEVEL=DEBUG
OTS_ALLOWED_IPS=ANY❌ "Python 3 not found"
# macOS
brew install python3
# Ubuntu
sudo apt-get install python3 python3-pip
# Check version
python3 --version❌ "Virtual environment creation failed"
# Install venv module
sudo apt-get install python3-venv # Ubuntu
# or
python3 -m pip install virtualenv # Any platform❌ "Port 8002 already in use"
# Find what's using the port
lsof -i :8002
# Kill the process (replace PID)
kill <PID>
# Or use different port
export OTS_API_PORT=8003
./scripts/start.sh❌ "uvicorn not found"
# Install manually
pip install uvicorn
# Or reinstall dependencies
rm -rf ots/ # Remove virtual env
./scripts/start.sh # Recreate and install# Enable debug logging
export OTS_LOG_LEVEL=DEBUG
./scripts/start.sh# Remove virtual environment and start fresh
rm -rf ots/
./scripts/start.sh# Build with custom tag
docker build -t my-opentextshield:latest .
# Run with custom settings
docker run -d \
-p 8003:8002 \
-e OTS_LOG_LEVEL=DEBUG \
my-opentextshield:latestCreate docker-compose.yml:
version: '3.8'
services:
opentextshield:
image: telecomsxchange/opentextshield:latest
ports:
- "8002:8002"
environment:
- OTS_LOG_LEVEL=INFO
- OTS_ALLOWED_IPS=ANY
restart: unless-stoppedRun with:
docker-compose up -d# Set production environment
export OTS_LOG_LEVEL=WARNING
export OTS_ALLOWED_IPS="10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"
export OTS_CORS_ORIGINS="https://yourdomain.com"
# Start with production script
./scripts/start.shserver {
listen 80;
server_name your-api-domain.com;
location / {
proxy_pass http://127.0.0.1:8002;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}If you encounter issues:
- Check the logs: Look for error messages in the terminal output
- Verify dependencies: Ensure Python 3.8+ is installed
- Test basic functionality: Try the health check endpoint
- Reset environment: Remove
ots/directory and restart - Report issues: Open an issue on GitHub with full error output
- API Documentation: http://localhost:8002/docs
- Health Check: http://localhost:8002/health
- Repository: https://github.com/TelecomsXChangeAPi/OpenTextShield
- Issues: https://github.com/TelecomsXChangeAPi/OpenTextShield/issues