D/01API Reference
Docs & API
reference.
Latensgate's API mirrors the OpenAI chat completion contract. Add a single header and route through your tenant URL. All requests are end-to-end encrypted to the enclave's attested public key.
Quickstart
Install the SDK and replace your OpenAI base URL.
npm install @latensgate/sdk
import { Latensgate } from '@latensgate/sdk';
const lg = new Latensgate({
apiKey: process.env.LATENSGATE_KEY,
tenant: 'tnt_a3f9c42b',
});
const response = await lg.chat.completions.create({
model: 'claude-3.5-sonnet',
messages: [{ role: 'user', content: 'Summarize the attached document.' }],
});
// response.attestation_hash is verifiable at /verify
console.log(response.choices[0].message.content);Endpoints
POST/api/inference
Submit an encrypted prompt for inference inside the enclave.
Request body
{
"prompt_ciphertext": "<base64>",
"model": "claude-3.5-sonnet",
"tenant_id": "tnt_a3f9c42b"
}Response
{
"response_ciphertext": "<base64>",
"audit_receipt_id": "aud_8f9e1a0d56e9bb6a",
"attestation_hash": "sha384:c8f8e1a0...",
"latency_ms": 23,
"pii_detected": false
}GET/api/attest?hash={hash}
Retrieve the attestation document for a given hash.
Response
{
"hash": "sha384:c8f8e1a0...",
"pcr_values": { "PCR0": "0...", ... },
"timestamp": "2025-11-14T09:23:41Z",
"enclave_image_sha": "sha384:b3c8f8...",
"status": "verified",
"region": "us-east-1"
}GET/api/audit?page=1&limit=25
Retrieve paginated audit log entries for the authenticated tenant.
GET/api/keys
List all API keys for the authenticated tenant.
POST/api/keys
Generate a new API key. The full key is returned exactly once.
Request body
{
"name": "production-pipeline",
"scopes": ["inference:read", "audit:read"],
"expiry": "90d"
}GET/api/health
Check enclave, KMS, and Bedrock health. Used by Vercel deployment checks.
Error Codes
ERR_ENCLAVE_TIMEOUT504vsock connection timed out after 5000ms
ERR_ATTESTATION_INVALID422PCR values do not match expected enclave image
ERR_KMS_DENIED403KMS key policy rejected the attestation document
ERR_RATE_LIMITED429Exceeded 60 requests/minute for this tenant
ERR_PII_HARD_FAIL422Detected PII category that is configured to hard-fail