PARANOID

Integration

The gateway speaks the OpenAI chat completions API, so most SDKs work by changing two settings.

OpenAI SDK (Node)

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://<gateway>/api/v1",
  apiKey: process.env.PARANOID_KEY, // a bundle of request proofs from the app
});

const res = await client.chat.completions.create({
  model: "default",
  messages: [{ role: "user", content: "Summarise the zkAPI design in two lines." }],
});
console.log(res.choices[0].message.content);
console.log(res.headers?.get?.("x-paranoid-requests-left"));

curl

curl https://<gateway>/api/v1/chat/completions \
  -H "Authorization: Bearer $PARANOID_KEY" \
  -H "Content-Type: application/json" \
  -d '{"messages":[{"role":"user","content":"hello"}]}'

Agents

An agent should hold its own secret and make its own proofs, so its operator's wallet never appears next to its requests. Give each task its own credential.

Running a gateway

The gateway is a set of Next.js route handlers. It needs read access to the program's Tree account through an RPC and a model endpoint to forward to. It keeps only the nullifiers of the current and previous epoch in memory (a key outlives its epoch by a grace of a sixth of an epoch, at most ten minutes) and writes no request logs. Set PARANOID_RPC, PARANOID_MODEL_URL, PARANOID_MODEL_NAME, PARANOID_MODEL_KEY and, to slash double spenders at once, PARANOID_REPORTER_KEY (a fee-paying keypair; slashing pays the reporter nothing).

Next: API reference