Skip to main content

Quick Start

Get your application protected with PromptGuard in under a minute.

Prerequisites

Step 1: Install CLI

curl -fsSL https://raw.githubusercontent.com/acebot712/promptguard-cli/main/install.sh | sh
Already installed? Skip to Step 2

Step 2: Initialize PromptGuard

Navigate to your project and run:
cd /path/to/your/project
promptguard init --api-key pg_sk_test_xxx
Replace pg_sk_test_xxx with your actual API key from the dashboard.

What Happens?

The CLI will:
  1. Scan your project for LLM SDK usage (OpenAI, Anthropic, Cohere, HuggingFace)
  2. Show detected SDKs and ask for confirmation
  3. Create backups of all files to be modified (.bak extension)
  4. Transform code to route requests through PromptGuard
  5. Save API key to .env file
  6. Create config (.promptguard.json)

Example Output

🛡️  PromptGuard CLI v2.0.0
==================================================

📁 Scanning project...
 Scanning 47 files...

🔍 Detected LLM SDKs:
 OpenAI SDK (3 files)
 src/services/ai.ts
 src/utils/chat.ts
 lib/completions.ts

📝 Configuration:
 Proxy URL: https://api.promptguard.co/api/v1
 Backup files: Yes (*.bak)
 Environment: .env

Apply these changes? [Y/n]: y

🔧 Applying changes...
 src/services/ai.ts (added baseURL for openai)
 src/utils/chat.ts (added baseURL for openai)
 lib/completions.ts (added baseURL for openai)
 .env (added PROMPTGUARD_API_KEY)
 .promptguard.json (created)

 PromptGuard is now active!

Next steps:
 Run your app normally - all LLM requests now go through PromptGuard
 View logs: promptguard logs --follow
 Check dashboard: https://app.promptguard.co/dashboard

Step 3: Run Your Application

That’s it! Your application is now protected. Run it normally:
# Node.js
npm run dev

# Python
python main.py

# Your app works exactly the same, but requests go through PromptGuard

Step 4: Monitor Requests

View your protected requests in real-time:

What Changed?

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY
});

Common Options

Specify Provider

If auto-detection picks up the wrong provider:
promptguard init --provider openai --api-key pg_sk_test_xxx

Dry Run (Preview Changes)

See what would change without modifying files:
promptguard scan

Skip Confirmation

Auto-accept all changes:
promptguard init --api-key pg_sk_test_xxx -y

No Backups

Skip backup file creation (not recommended):
promptguard init --api-key pg_sk_test_xxx --no-backup

Next Steps

1

Check Status

promptguard status
View current configuration and active status
2

Test Configuration

promptguard test
Verify API key and connectivity
3

View Dashboard

Visit app.promptguard.co/dashboard to see your requests

Disable or Remove

Temporarily Disable

Restore original files but keep configuration:
promptguard disable
Re-enable later:
promptguard enable

Completely Remove

Restore original files and delete configuration:
promptguard revert -y

Example Workflows

cd my-nextjs-app
promptguard init --provider openai --api-key pg_sk_test_xxx

# Start development server
npm run dev

# Your API routes now go through PromptGuard
# Visit app.promptguard.co to see requests
cd my-fastapi-app
promptguard init --provider anthropic --api-key pg_sk_test_xxx

# Run app
uvicorn main:app --reload

# All Claude API calls now protected
cd my-backend
promptguard init --provider openai --api-key pg_sk_test_xxx

# Start server
node server.js

# Monitor requests
promptguard logs --follow
cd my-app

# Initialize for OpenAI
promptguard init --provider openai --api-key pg_sk_test_xxx

# The CLI detects all providers automatically
# Both OpenAI and Anthropic SDKs will be configured if found

Troubleshooting

The CLI looks for common patterns. If not detected:
  • Ensure you have SDK initialization code (not just imports)
  • Check file extensions: .ts, .js, .tsx, .jsx, .py
  • Files in node_modules, dist, .venv are excluded by default
The CLI needs write access to .env. Check file permissions:
chmod 644 .env
Verify your key format:
  • Test keys: pg_sk_test_xxxxx
  • Production keys: pg_sk_prod_xxxxx
Get a new key: Go to your project dashboard, select your project, then navigate to the API Keys tab.
  1. Check your app is actually running
  2. Verify baseURL was added: cat path/to/file.ts | grep baseURL
  3. Test API key: promptguard test
  4. Check API key matches in dashboard

Video Tutorial

Watch an interactive demo: Create and Manage Security Policies on PromptGuard

Need Help?