Perishable¶
A secure proxy for OpenAI APIs that prevents API key abuse while maintaining full SDK compatibility.
What is Perishable?¶
Perishable is a library that allows frontend applications to use OpenAI's API without exposing API keys. It consists of two parts:
- Client Library - A shim layer that works with the OpenAI SDK
- Proxy Server - Validates requests and forwards them to OpenAI
Key Features¶
- API Key Protection - Your OpenAI API key never leaves your server
- Client Fingerprinting - Identifies and tracks clients to prevent abuse
- Entropy Collection - Requires user interaction to prevent automated abuse
- Session Management - Time-limited sessions with automatic expiration
- Rate Limiting - Prevents abuse through request throttling
- SDK Compatible - Works seamlessly with the OpenAI SDK
How It Works¶
┌─────────────┐ ┌──────────────────┐ ┌─────────────┐
│ Browser │────>│ Perishable │────>│ OpenAI │
│ Client │<────│ Proxy Server │<────│ API │
└─────────────┘ └──────────────────┘ └─────────────┘
│ │
│ Session Token │ API Key
│ Fingerprint │ (secure)
└─────────────────────┘
- Client generates a fingerprint and collects entropy from user interactions
- Client requests a session from the proxy server
- Proxy server validates the client and issues a JWT token
- Client makes API requests through the proxy using the token
- Proxy server forwards validated requests to OpenAI
Quick Example¶
Server (Node.js):
import { server } from 'perishable';
const proxy = new server.PerishableServer({
openaiApiKey: process.env.OPENAI_API_KEY,
port: 3000
});
proxy.start();
Client (Browser):
import { client } from 'perishable';
client.PerishableOpenAI.initEntropyCollection();
const perishable = new client.PerishableOpenAI({
proxyUrl: 'http://localhost:3000'
});
const response = await perishable.createChatCompletion({
model: 'gpt-3.5-turbo',
messages: [{ role: 'user', content: 'Hello!' }]
});
Next Steps¶
- Getting Started - Set up Perishable in 5 minutes
- Installation - Detailed installation instructions
- Server Guide - Configure your proxy server
- Client Guide - Integrate the client library