The PromptGuard API is fully compatible with OpenAI’s API structure, making it a seamless drop-in replacement for your existing integrations.
Overview
PromptGuard provides two types of APIs:| API Type | Base URL | Authentication | Purpose |
|---|---|---|---|
| Developer API | https://api.promptguard.co/api/v1 | API Key (X-API-Key) | AI requests, usage stats |
| Dashboard API | https://api.promptguard.co/dashboard | Session Cookie | Project management, analytics |
Authentication
All PromptGuard API endpoints require authentication. For the Developer API, you’ll use two keys:- PromptGuard API key (in
X-API-Keyheader) - Authenticates your PromptGuard account - LLM provider key (in
Authorizationheader) - Your OpenAI/Anthropic key that gets forwarded to the provider
Developer API Authentication
For detailed authentication setup and code examples, see Authentication.
Dashboard API Authentication
For dashboard applications, use session-based authentication:Base URLs
| Environment | URL |
|---|---|
| Production | https://api.promptguard.co/api/v1 |
| Staging | https://staging-api.promptguard.co/api/v1 |
Available Endpoints
Chat Completions (OpenAI Compatible)
The primary endpoint for AI requests. Fully compatible with OpenAI’s API:model- Any supported LLM model (OpenAI, Anthropic, Google, Mistral, DeepSeek, Cohere, Groq, Azure OpenAI). See Supported LLM Providers for complete model listmessages- Array of message objectstemperature,max_tokens,top_p, etc.stream- Enable streaming responsesuser- Unique user identifier for tracking
Guard API
Scan content for threats without proxying to an LLM provider. Accepts structured messages with direction and context:Security Scan
Analyze raw text for prompt injection, jailbreaks, and other threats:Security Redact
Strip PII from text and return both original and redacted versions:Agent Security
Validate tool calls and monitor agent sessions:Models
List available models:Usage Statistics
Get your current usage:Rate Limits
Rate limits vary by plan:| Plan | Monthly Limit | Type |
|---|---|---|
| Free | 10,000 requests | Hard limit (blocks when exceeded) |
| Pro | 100,000 requests | Hard limit (blocks when exceeded) |
| Scale | 1,000,000 requests | Soft limit (alerts only, never blocks) |
Infrastructure Rate Limiting: Cloud Armor enforces 100 requests per minute per IP address at the infrastructure level. This is separate from your monthly subscription limits and applies to all plans.
Rate limits are per API key. Distribute load across multiple keys if needed. Contact sales@promptguard.co for higher limits.
Response Headers
PromptGuard adds helpful headers to every response:| Header | Description |
|---|---|
X-PromptGuard-Event-ID | Unique identifier for tracking this request |
X-PromptGuard-Decision | Security decision: allow, block, or redact |
X-PromptGuard-Confidence | Confidence score of the security decision (0.0 - 1.0) |
X-PromptGuard-Threat-Type | Type of threat detected (e.g., prompt_injection, pii_leak, none) |
Error Handling
PromptGuard uses conventional HTTP response codes:| Code | Description | Action |
|---|---|---|
200 | Success | Request processed normally |
400 | Bad Request | Check request format or security policy violation |
401 | Unauthorized | Verify API key is valid |
403 | Forbidden | Request blocked by security policy, or check subscription status / API key validity |
429 | Too Many Requests | Implement exponential backoff |
500 | Server Error | Retry with backoff |
Error Response Format
dashboard_url links directly to the event in the dashboard for audit and debugging.
Security Policy Violations
When a request is blocked for security reasons:SDKs & Libraries
PromptGuard works with existing OpenAI/Anthropic SDKs by simply changing the base URL:Node.js / TypeScript
Use the official OpenAI SDK with PromptGuard
Python
Use the official OpenAI Python library
Guard API
Standalone content scanning without proxying
Auto-Instrumentation
One line secures all LLM calls
OpenAPI Specification
The complete OpenAPI specification is available for:- Auto-generating client libraries
- API testing and validation
- Documentation generation
Download OpenAPI Spec
Get the full OpenAPI specification for the Developer API
Next Steps
Quick Start
Get started with PromptGuard in 5 minutes
First Request
Make your first secure AI request
Authentication
Learn more about API key management
Security Rules
Configure protection for your use case