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
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 OpenAI, Anthropic, or Groq modelmessages- 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 | Requests/Month | Requests/Minute | Burst |
|---|---|---|---|
| Free | 1,000 | 100 | 200 |
| Starter | 50,000 | 100 | 200 |
| Growth | 500,000 | 1,000 | 2,000 |
| Enterprise | Custom | Custom | Custom |
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 |
X-PromptGuard-Latency | Processing time in milliseconds |
X-PromptGuard-Version | PromptGuard API version |
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