Base URL
All API requests should be made to:Authentication
All requests require authentication using an API key in the Authorization header:Core Endpoints
MySafeCache provides a simple, yet powerful API with just 3 core endpoints:Check Cache
POST /api/v1/check
Check if a response is cachedStore Response
POST /api/v1/store
Cache a new responseUsage Stats
GET /api/v1/usage
Get cache statisticsRequest Format
All requests must include:Content-Type: application/jsonheader- Valid JSON body (for POST requests)
- Authorization header with API key
Response Format
All responses are returned in JSON format with consistent structure:Error Handling
MySafeCache uses standard HTTP status codes:| Status Code | Meaning |
|---|---|
| 200 | Success |
| 400 | Bad Request - Invalid input |
| 401 | Unauthorized - Invalid API key |
| 404 | Not Found - Endpoint doesn’t exist |
| 429 | Too Many Requests - Rate limit exceeded |
| 500 | Internal Server Error |
Error Response Format
Rate Limits
API calls are rate limited based on your plan:| Plan | Requests/minute | Burst |
|---|---|---|
| Free | 60 | 100 |
| Pro | 600 | 1000 |
| Enterprise | 6000 | 10000 |
Message Format
MySafeCache uses the OpenAI message format for consistency:Supported Roles
system: Sets the behavior of the assistantuser: Messages from the userassistant: Previous responses from the AI
Cache Types
MySafeCache returns different cache types based on how the match was found:| Cache Type | Description | Response Time |
|---|---|---|
exact | Perfect hash match | 1-5ms |
semantic | Vector similarity match | 5-20ms |
Pagination
For endpoints that return lists (like analytics), pagination is supported:page: Page number (default: 1)per_page: Items per page (default: 20, max: 100)
Timestamps
All timestamps are returned in ISO 8601 format with UTC timezone:Testing
Use our test endpoint to verify your integration:SDK Support
Official SDKs are available for popular languages:Python
JavaScript/Node.js
Go
PHP
OpenAPI Specification
Download our complete OpenAPI specification:Download OpenAPI Spec
Complete machine-readable API specification