Installation Guide
Install PromptShield SDKs and tools for your preferred platform and environment.
System Requirements
Python SDK
- Python 3.7 or higher
- pip 19.0+
- 2GB RAM minimum
- SSL/TLS support
Node.js SDK
- Node.js 14.0 or higher
- npm 6+ or yarn 1.22+
- 2GB RAM minimum
- TypeScript 4.0+ (optional)
Python SDK Installation
Using pip
pip install prompt-shield
Using Poetry
poetry add prompt-shield
Using Conda
conda install -c perfecxion prompt-shield
Optional Dependencies
For async support:
pip install "prompt-shield[async]"
For framework integrations:
pip install "prompt-shield[frameworks]"
For all features:
pip install "prompt-shield[all]"
Node.js SDK Installation
Using npm
npm install @prompt-shield/sdk
Using yarn
yarn add @prompt-shield/sdk
Using pnpm
pnpm add @prompt-shield/sdk
TypeScript Support
TypeScript definitions are included. No additional @types package needed.
// tsconfig.json { "compilerOptions": { "types": ["@prompt-shield/sdk"] } }
CLI Tool Installation
Global Installation
npm install -g @prompt-shield/cli
Verify Installation
promptshield --version # Output: PromptShield CLI v1.0.0 promptshield --help # Shows all available commands promptshield test --help # Shows testing options
Docker Installation
Pull the Docker Image
docker pull promptshield/promptshield:latest
Run with Docker Compose
# docker-compose.yml version: '3.8' services: promptshield: image: promptshield/promptshield:latest environment: - PROMPTSHIELD_API_KEY=your-api-key - PROMPTSHIELD_LOG_LEVEL=info - PROMPTSHIELD_PORT=8080 ports: - "8080:8080" - "9090:9090" # Metrics endpoint volumes: - ./config:/app/config - ./logs:/app/logs deploy: resources: limits: cpus: '2' memory: 2G reservations: cpus: '1' memory: 1G # Optional: Local Redis for caching redis: image: redis:7-alpine ports: - "6379:6379" volumes: - redis-data:/data volumes: redis-data:
Kubernetes Deployment
Helm Chart Installation
# Add Helm repository helm repo add promptshield https://charts.perfecxion.ai helm repo update # Install PromptShield helm install promptshield promptshield/promptshield \ --set apiKey=your-api-key \ --set replicas=3 \ --set resources.requests.memory=1Gi \ --set resources.requests.cpu=500m \ --namespace promptshield \ --create-namespace
Custom Values Configuration
# values.yaml replicaCount: 3 image: repository: promptshield/promptshield tag: "1.0.0" pullPolicy: IfNotPresent service: type: LoadBalancer port: 80 metricsPort: 9090 ingress: enabled: true className: nginx annotations: cert-manager.io/cluster-issuer: letsencrypt hosts: - host: promptshield.your-domain.com paths: - path: / pathType: Prefix autoscaling: enabled: true minReplicas: 3 maxReplicas: 10 targetCPUUtilizationPercentage: 70 targetMemoryUtilizationPercentage: 80 cache: enabled: true type: redis redis: host: redis-master port: 6379 monitoring: prometheus: enabled: true serviceMonitor: enabled: true
Environment Configuration
Environment Variables
# .env file PROMPTSHIELD_API_KEY=your-api-key-here PROMPTSHIELD_API_URL=https://api.perfecxion.ai/v1 PROMPTSHIELD_LOG_LEVEL=info PROMPTSHIELD_CACHE_ENABLED=true PROMPTSHIELD_CACHE_TTL=3600 PROMPTSHIELD_TIMEOUT_MS=5000 PROMPTSHIELD_MAX_RETRIES=3 PROMPTSHIELD_BATCH_SIZE=100
Configuration File
# promptshield.config.yaml api: key: ${PROMPTSHIELD_API_KEY} endpoint: https://api.perfecxion.ai/v1 timeout: 5s retries: 3 detection: default_mode: "standard" sensitivity: "balanced" layers: heuristic: enabled: true patterns_update: "auto" llm: enabled: true model: "gpt-3.5-turbo" fallback: "heuristic_only" canary: enabled: true token_rotation: "daily" performance: cache: enabled: true ttl: 3600 max_size: 1000 batching: enabled: true max_batch_size: 100 max_wait_ms: 100 monitoring: metrics: enabled: true port: 9090 path: /metrics logging: level: info format: json output: stdout
Verify Your Installation
Python
import prompt_shield # Check version print(prompt_shield.__version__) # Test connection from prompt_shield import PromptShield shield = PromptShield(api_key="your-api-key") health = shield.health_check() print(f"Connection status: {health.status}") print(f"API version: {health.api_version}") print(f"Detection layers: {', '.join(health.active_layers)}")
Node.js
const { PromptShield } = require('@prompt-shield/sdk'); // Check version console.log(PromptShield.VERSION); // Test connection const shield = new PromptShield({ apiKey: 'your-api-key' }); const health = await shield.healthCheck(); console.log(`Connection status: ${health.status}`); console.log(`API version: ${health.apiVersion}`); console.log(`Detection layers: ${health.activeLayers.join(', ')}`);
CLI
# Test CLI connection promptshield test-connection # Run detection test promptshield detect "Sample text to test" # Validate configuration promptshield config validate
Framework-Specific Installation
React
npm install @prompt-shield/react # Usage import { PromptShieldProvider } from '@prompt-shield/react'; <PromptShieldProvider apiKey={process.env.REACT_APP_PROMPTSHIELD_KEY}> <App /> </PromptShieldProvider>
Django
pip install prompt-shield[django] # settings.py INSTALLED_APPS = [ # ... 'prompt_shield.django', ] PROMPTSHIELD_API_KEY = 'your-api-key'
FastAPI
pip install prompt-shield[fastapi] # main.py from prompt_shield.fastapi import PromptShieldMiddleware app.add_middleware( PromptShieldMiddleware, api_key="your-api-key" )
Common Installation Issues
SSL Certificate Errors
For corporate proxies: export NODE_TLS_REJECT_UNAUTHORIZED=0
Permission Denied
Use sudo
for global installs or use a virtual environment
Network Timeouts
Configure proxy settings or increase timeout values in configuration
Version Conflicts
Check compatibility matrix in documentation for framework versions