Encrypted Chat Completions (RVENC)
Simple pass-through to enclave chat completion endpoint with encrypted payload. Rvenc = raw volatile encrypted. Accepts a single encrypted inference parameter that encapsulates all chat completion data. Only provides authentication, security checks, and token rate limiting. No chat history, file management, or custom features.
TypeScript SDK
The SDK is available on GitHub: premAI-io/api-sdk-tsUsage
Basic Setup
Create a client with auto-generated encryption keys:Pre-generate Keys
You can pre-generate encryption keys and reuse them:Non-streaming Requests
Streaming Requests
Configuration
| Option | Default | Description |
|---|---|---|
apiKey | required | Authorization token |
encryptionKeys | auto-generated | Pre-generated { sharedSecret, cipherText } |
requestTimeoutMs | 30000 | Request timeout in ms |
maxBufferSize | 10MB | Max SSE buffer size |
OpenAI-Compatible API Server
Run as a standalone server with automatic DEK store management per API key:API Reference
Authorizations
Send your access token as header Authorization: Bearer {accessToken}
Your API key that starts with sk_live or sk_test. You can create yours at go.prem.io/api-keys.
Body
Request body for rvenc (raw volatile encrypted) chat completion. Contains an encrypted payload with cryptographic materials needed for decryption.
Encrypted JSON string containing all chat completion parameters. When decrypted, this string must match the structure shown in the expandable _decryptedInference property below (reference only - do not send this property).
Cipher text for shared secret generation (ECDH key exchange)
Nonce used for encrypting the inference payload
Response
Server-sent events stream with encrypted OpenAI-compatible chat completion chunks. Each chunk in the stream is encrypted and must be decrypted using the same shared secret and nonce from the request.
Server-sent events (SSE) stream response structure. The actual response is a text stream, but this schema documents the structure for reference.
Server-sent events (SSE) stream with encrypted chat completion chunks. The stream contains three types of events:
event: datafollowed bydata: <encrypted_hex_string>- Encrypted chunk that must be decrypted using the same shared secret and nonce from the request. When decrypted, each chunk matches the structure shown in the_decryptedChunkproperty below (reference only).event: errorfollowed bydata: <error_data>- Error event (can be encrypted or plain JSON)event: donefollowed bydata: [DONE]- Stream completion marker
Each encrypted data: line contains a hex-encoded string. Decrypt each chunk using XChaCha20-Poly1305 with the shared secret and nonce from your request.
Reference only - This shows the structure that each encrypted chunk should contain when decrypted. Decrypt each chunk in the stream using the same shared secret and nonce from your request to get this structure.
{
"id": "cd9d05b657a041a6a14ab2fc890a7d7e",
"object": "chat.completion.chunk",
"created": 1764004858,
"model": "openai/gpt-oss-120b",
"choices": [
{
"index": 0,
"delta": {
"role": null,
"content": null,
"reasoning_content": "This ",
"tool_calls": null
},
"logprobs": null,
"finish_reason": null,
"matched_stop": null
}
],
"usage": null
}{
"id": "cd9d05b657a041a6a14ab2fc890a7d7e",
"object": "chat.completion.chunk",
"created": 1764004858,
"model": "openai/gpt-oss-120b",
"choices": [
{
"index": 0,
"delta": {
"role": "assistant",
"content": "Hello",
"reasoning_content": null,
"tool_calls": null
},
"logprobs": null,
"finish_reason": null,
"matched_stop": null
}
],
"usage": null
}{
"id": "cd9d05b657a041a6a14ab2fc890a7d7e",
"object": "chat.completion.chunk",
"created": 1764004858,
"model": "openai/gpt-oss-120b",
"choices": [
{
"index": 0,
"delta": [],
"logprobs": null,
"finish_reason": "stop",
"matched_stop": null
}
],
"usage": null
}
