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
Models
List available models:Usage Statistics
Get your current usage:Presets
List available security presets: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 [email protected] 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 |
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 | Check permissions or subscription status |
429 | Too Many Requests | Implement exponential backoff |
500 | Server Error | Retry with backoff |
Error Response Format
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
React / Next.js
Frontend integration patterns
CLI Tool
Automatic code transformation
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