Run a Routstr Node
Routstr is an OpenAI-compatible proxy in front of AI model providers. Clients pay per request with Cashu, a Bitcoin ecash token, and find nodes through Nostr. A node sits between its users and the model provider, so its operator, and whoever hosts it, could read every prompt that passes through.
That is the problem this walkthrough removes. The routstr-node template runs the public Routstr build inside an AMD SEV-SNP TEE from a digest-pinned image. Enclava operates the node but cannot read its memory or its storage, and anyone can check which code is serving.
- You deploy the template. The node claims its encrypted storage and generates its keys on first boot.
- You configure it in Routstr's own dashboard: admin password, model providers, pricing, payout address.
- Your users pay per request, or send requests encrypted end to end to a provider enclave.
- Anyone verifies which image, signer and platform release serve the node.
Who can read a prompt
Routstr serves two kinds of requests, and they carry different promises.
| Plain request | Encrypted request | |
|---|---|---|
| Enclava and the host | No. The CPU encrypts the VM's memory, and the platform never holds the storage keys. | No. |
| You, the operator | The node's code handles the prompt in the clear. You choose the provider it goes to and can read the node's logs with your log key. There is no shell inside the workload. | No. The body stays encrypted. The node sees the model name, the payment, and the timing and size of the request. |
| The model provider | Yes. A public API receives the prompt in the clear. | Only the enclave the client verified. |
| Your users | Can verify which image, signer and platform release serve the node. | The same, plus the provider enclave, which their SDK verifies before sending anything. |
Routstr's logs are request, billing and error events. The node does not log prompt text.
What it proves, and what it doesn't
- It pins code, not correctness. The template image is built from
enclava-labs/routstr-core-enclava: upstream Routstr plus three packaging files. Read it, or deploy a build you have reviewed. - Plain requests are readable inside the node and at the provider. Only encrypted requests keep the prompt from both.
- You choose the providers, and attestation does not cover that choice. Clients can see which one served a request: the
X-Routstr-Providerresponse header, or theproviderfield in each streamed chunk. - The node holds money. Client balances are the node's IOUs, and
/app/.walletholds the sats users have paid. Both live on the encrypted volume. Lose the storage password and the recovery material and they are gone. Enclava cannot recover them. - Availability is not protected. Enclava can restart or stop the node. After a restart it stays locked until you unlock it.
Before you start
-
An Enclava account and organization. On a fresh organization, deploys are refused until you run
enclava key setup --backup-out <file>to create its signing authority. Keep that file. -
An API key for the provider you resell: any OpenAI-compatible API, or Tinfoil for encrypted requests.
-
A storage password in a file only you can read, also stored in your password manager:
openssl rand -base64 32 > ~/.enclava/routstr-storage-password
chmod 600 ~/.enclava/routstr-storage-password -
A few sats as a Cashu token from a mint the node accepts, for the paid test.
Deploy
Log in with log access approved. You need it to read the node's first-boot logs.
enclava login --approve-logs
enclava template deploy routstr-node --name my-node \
--storage-password-file ~/.enclava/routstr-storage-password \
--generate-log-key my-node-logs \
--log-private-key-file ~/.enclava/my-node-log-key.private
The password file claims ownership without a prompt. --generate-log-key creates the key that encrypts this app's logs and writes its private half to the file you name. Enclava never sees either secret.
enclava status --app my-node --json
status: running and tee_status: unlocked mean the node is serving. domain is its address. Expect a minute between the deploy printing and this state — the deploy finishing is not the end of readiness.
Back up the recovery material now, and keep the file off this machine:
enclava key backup --out ~/my-org-recovery.json
Sign in the first time
The node generates its admin password once, on first boot, and prints it to its logs. A redeploy never prints it again.
enclava logs --app my-node --log-private-key-file ~/.enclava/my-node-log-key.private
Find the line No admin password set; generated a temporary one (shown only now). Open https://<domain>/admin, sign in, and change the password under Settings → Admin Settings → Change Admin Password.
Store the new password in your password manager. There is no shell inside the workload to run Routstr's password-reset script, so on Enclava a lost admin password is not recoverable.
First boot also writes the node's own ROUTSTR_SECRET_KEY to /data/routstr_secret.key and asks you to back it up. It lives on the encrypted volume: your storage password and enclava key backup are what keep it, and losing both loses the secrets it protects.
Set up the node
Everything below is in the dashboard, under Settings → Admin Settings unless noted.
- Basic Information. Give the node a name and a description. HTTP URL is what the node publishes to Nostr: set it to
https://<domain>to list the node, or leave it empty to stay unlisted. The node's Nostr identity was generated on first boot. Itsnpubis shown here and byGET /v1/info. - Cashu Mints. The mints users can pay with.
- Lightning Payout Settings. The Lightning address the node pays its earnings to.
- Nostr Relays. Where the node announces itself.
- Analytics Sharing. On by default. It publishes per-day totals per model to Nostr: request counts, tokens and revenue. No prompts, no user identifiers. Switch it off if you do not want that public.
- Providers → Add Provider. The upstream the node resells: provider type, base URL, API key, and the fee you add on top. The provider's models are served right away —
GET /v1/modelslists them — and the provider's Models panel sets prices, aliases and which of them are enabled.
A node that publishes to Nostr should use a hostname you control. See Custom domains.
Take a paid request
List the models first, then send a request with a Cashu token in place of an API key:
curl https://<domain>/v1/models
curl https://<domain>/v1/chat/completions \
-H "Content-Type: application/json" \
-H "x-cashu: <cashu-token>" \
-d '{"model": "<model>", "messages": [{"role": "user", "content": "hello"}]}'
The node redeems the token, bills the request at the token usage the provider reports, and refunds the rest. Two payment shapes work: the x-cashu header spends the token per request, while Authorization: Bearer <token> redeems it once into a balance on the node that later requests draw on. Before forwarding, the node can reserve the model's worst-case cost — its price times the full context — so a large-context model may demand thousands of sats of cover against your balance or token even though a short request costs a fraction of a sat. Unused value is refunded or released. An OpenAI SDK works the same way: point base_url at https://<domain>/v1 and pass the token as api_key.
Encrypted requests, end to end
With a public provider, the prompt is plaintext inside your node and at the provider. Routstr's Tinfoil provider closes both gaps.
Tinfoil serves open models inside attested enclaves. A client using the Tinfoil SDK verifies the enclave before sending anything, then encrypts the request to the enclave's key. The encryption is EHBP: the HTTP body is sealed with HPKE and stays sealed through your node, while the headers remain in the clear for routing. Your node reads the model name from a header, forwards the opaque body to the enclave the client verified, and bills from the usage figure the enclave returns in a response header. It never holds the prompt. On the wire the body is HPKE ciphertext; only the model name, the payment and the routing headers are readable.
Add the provider as Tinfoil with your Tinfoil API key, then point the SDK at your node:
import { SecureClient } from "tinfoil";
const node = "https://<domain>";
const client = new SecureClient({ baseURL: `${node}/`, attestationBundleURL: node });
await client.ready(); // fetches the enclave's attestation through the node and verifies it
const res = await client.fetch("/v1/chat/completions", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer <cashu token>",
"X-Routstr-Model": "tinfoil-<model>", // the node's id, as listed by GET /v1/models
},
body: JSON.stringify({ model: "<model>", messages: [{ role: "user", content: "Hello" }] }),
});
Two attestations cover the two hops, and each is checked independently of the other:
- Your node, by Enclava.
enclava verifyconfirms the Routstr image, its signer and the platform it runs on. That is what makes the node's routing and billing trustworthy. - The provider enclave, by the client. The Tinfoil SDK checks the enclave's attestation against the hardware vendor's root and Tinfoil's published code, and takes the encryption key from that verified report. Your node relays the attestation bundle but cannot alter it.
Prove it to your users
Everything above is your claim until a user checks it. The check is one command, run against a policy they hold:
enclava verify https://<domain> --policy trust-policy.json
Publish trust-policy.json in a repository your users can read. Three groups of values go into it:
- The platform: launch measurement, sidecar digests, platform release, policy-signing keys. Take them from what Enclava publishes for the platform, not from your node: the signed platform release in
enclava-ops-manifests(environments/<env>/base/platform-release.json) carries the release version, the policy-signing key and the sidecar digests, and theenclava-canaryrepository shows a complete policy shape. - The image and signer: the
routstr-nodetemplate's digest and signer workflow.enclava template list --jsonpublishes both, so users can compare your policy with the catalog instead of taking your word for it. - Your deployment: origin, organization and app IDs, org keyring.
enclava describe https://<domain> --policy-skeleton draft.jsonfills them in.
Verify a running app walks through the whole procedure and what a pass does and does not prove. Run enclava verify --json on a schedule in CI and fail the job on a non-zero exit, so a pin that stops matching is your finding first.
Put this on your node's page, next to a link to your policy:
This node runs the Routstr build published by Enclava's
routstr-nodetemplate, inside an AMD SEV-SNP TEE. The host cannot read its memory or storage. Plain requests are visible to the model provider; encrypted requests are visible to no one but the provider's enclave. Check it yourself:enclava verify https://<domain> --policy <link>. Every pin in that policy has a source you can check on its own — Verify a running app says where each one comes from.
Day two
Restarts. The node runs in password mode. After every restart, whether from a redeploy, a node drain or a platform roll, it boots locked — and a locked node cannot serve at all: its certificates live on the encrypted volume, so every connection to the hostname dies in the TLS handshake. enclava status shows TEE: locked and the app stays deploying until:
enclava unlock --app my-node --password-file ~/.enclava/routstr-storage-password
enclava status --app my-node showing TEE: unlocked means it is serving again.
Logs. Encrypted end to end. Only your key opens them:
enclava logs --app my-node --log-private-key-file ~/.enclava/my-node-log-key.private
Backups. /data holds the database and the node's secret key. /app/.wallet holds the sats users have paid. Run enclava key backup --out <file> after the first deploy and after every later claim, and keep the file off the machine. Storage, unlock and recovery explains what it contains.
Upgrades. Enclava pins the template's image. When the template moves to a new build, deploy again with the same name. Storage, keys and the log-key binding are kept. Update your trust policy only after you have looked at what changed.
Destroy. enclava destroy --app my-node deletes the node's data volumes, the wallet included. Withdraw first.
Other ways to run it
The template is the least work and pins the image for you. To choose the build yourself, deploy the same published image as your own app. The repository carries an enclava.toml that already declares the storage paths and the outbound access the node needs. It names the app routstr-core; change [app] name there first if you want another.
git clone https://github.com/enclava-labs/routstr-core-enclava
cd routstr-core-enclava
enclava create --image ghcr.io/enclava-labs/routstr-core-enclava:enclava \
--signer-subject https://github.com/enclava-labs/routstr-core-enclava/.github/workflows/enclava-deploy.yml@refs/heads/main
enclava log-key generate --app routstr-core --key-id routstr-core-logs \
--private-key-file ~/.enclava/routstr-core-log-key.private
enclava deploy --image ghcr.io/enclava-labs/routstr-core-enclava@sha256:<digest> \
--storage-password-file ~/.enclava/routstr-storage-password
Create the log key between create and deploy: the deploy has no log-key flags, and without a bound key enclava logs refuses — taking the first-boot admin password with it. deploy needs the digest. Read it from the repository's latest workflow run or with docker buildx imagetools inspect ghcr.io/enclava-labs/routstr-core-enclava:enclava. To build your own image from the source instead, start from Deploy your own image.
Troubleshooting
- The hostname stops answering, connections reset during the TLS handshake. The node is locked after a restart. Run
enclava unlock. enclava logsrefuses withencrypted_logs_required. The app has no log key bound. Deploy with--generate-log-key, or select an existing key with--log-key.- No models after adding a provider. Check in the dashboard that the provider is enabled and that its base URL and key are correct. The template allows outbound internet access, so this is not the network.
- The browser warns about the certificate. Some environments serve app certificates from Let's Encrypt's staging directory. That is a platform setting, not a fault of the node.
enclava statusshows atee_error. The node failed its startup checks inside the TEE and did not start. Runenclava destroy --app my-node --forceand deploy again. If it repeats, thetee_errorcode is what support needs.