All Engineering Guides

Zero-Storage LLM Proxy Mode with Pass-Through Headers

Route OpenAI, Anthropic, and Gemini calls through Noethekx spend controls while keeping upstream API keys strictly in request memory.

4 min readsource: src/lib/proxy/upstream.ts, src/lib/security/crypto.ts

Verified Source Facts

256 bits of entropy12-byte CSPRNG IV16-byte auth tag2MB proxy body limit25 requests$0.10 lifetime cap

Security teams often avoid third-party LLM gateways because storing long-lived upstream provider keys in another database expands their credential blast radius. Noethekx supports two distinct credential models so teams can match their compliance boundary:

  1. AES-256-GCM BYOK Vault: Provider keys encrypted at rest with a 12-byte CSPRNG IV, a 16-byte auth tag, and authenticated additional data (${orgId}:${credentialId}:${keyVersion}).
  2. Zero-Storage Pass-Through Mode: Upstream keys passed per request via x-upstream-api-key and kept strictly in request memory without any Firestore persistence or log emission.

Priority Order in `resolveUpstreamKey`

When a request arrives at https://nothekx.com/api/v1, resolveUpstreamKey resolves the upstream credential in strict order:

  1. If the x-upstream-api-key header is present, Noethekx validates that the value is non-empty, trims control whitespace, and uses it exclusively for the current request fetch. Nothing is written to provider_credentials or proxy_logs.
  2. Otherwise, Noethekx queries provider_credentials for the organization's most recent stored credential matching the target provider and decrypts it in memory using verified AAD.
  3. For Gemini calls without either credential source, Noethekx falls back to the Zero-Key Gemini Sandbox (capped at 25 requests and a $0.10 lifetime cap per organization).

All requests remain bounded by the 2MB proxy body limit (MAX_PROXY_BODY_BYTES), and proxy keys themselves are generated with 256 bits of entropy (nk_live_) and verified via HMAC-SHA256 with crypto.timingSafeEqual.

Pass-Through Examples for OpenAI and Anthropic

Pass x-upstream-api-key alongside your scoped nk_live_your_key_here proxy key:

bash
curl -X POST https://nothekx.com/api/v1/chat/completions \
  -H "Authorization: Bearer nk_live_your_key_here" \
  -H "x-upstream-api-key: sk-your-key-placeholder" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini",
    "max_tokens": 128,
    "messages": [{"role": "user", "content": "Validate zero-storage passthrough"}]
  }'

For Anthropic Messages (https://nothekx.com/api/v1/messages), supply x-api-key for your Noethekx proxy key (or Authorization: Bearer) and pass your Anthropic key in x-upstream-api-key:

ts
const res = await fetch('https://nothekx.com/api/v1/messages', {
  method: 'POST',
  headers: {
    'x-api-key': process.env.NOETHEKX_KEY ?? 'nk_live_your_key_here',
    'x-upstream-api-key': process.env.UPSTREAM_ANTHROPIC_KEY ?? 'sk-ant-placeholder',
    'anthropic-version': '2023-06-01',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'claude-sonnet-4-5',
    max_tokens: 256,
    messages: [{ role: 'user', content: 'List three HTTP status codes.' }],
  }),
});

Even in zero-storage pass-through mode, full spend reservation, sliding-window loop detection, and instant kill switches enforce hard dollar caps on every call.

Test hard spend caps in the Zero-Key Sandbox

Route requests through https://nothekx.com/api/v1 or inspect pass-through header mode.