XE Key Service
Use your own model-provider account for your app, agent or DAO. Your key stays inside XE's attested relay, your provider bills you, and every answer comes with a receipt.
XE's own AI services (Private, Zero retention, Anonymous and the AI Judge) run on XE's provider accounts and answer XE's own apps: XE AI Chat, XE Markets, the AI DAO demo and XE's agents. An app, agent, DAO or company that is not XE brings its own provider account through the Key Service.
With the Key Service:
- your provider key is sealed into XE's attested relay and used only there. XE never sees it, holds it or sells access to it;
- your provider bills you for the model, under your agreement with them;
- XE charges a small fee per request for the relay, paid in XE;
- you decide who may call it, which models, a daily budget and an end date. You can stop it at any time.
The Key Service console does all of this from your wallet. Apps and servers use the SDK, @xe-network/protocol/byok.
#What you need
- An XE account for the business that owns the key. Its wallet signs the grant.
- An OpenRouter account, or an API key from OpenAI, Anthropic, Gemini, Mistral or Venice.
- The XE accounts that will call it: your app's account, your agents' accounts, or your DAO's delegates.
#1. Put your key in the relay
The relay's sealing key is bound into an attestation that every XE node verified, and XE's service owner approves each relay build. Check both before a key leaves your device: the console shows the three checks, and the SDK's attestedRelay refuses a relay that fails one.
- OpenRouter: sign in from the relay. The relay makes the one-time PKCE secret, you approve on OpenRouter and set the key's credit limit there, and the relay redeems the code from inside its enclave. The key is created inside the relay and never exists anywhere else.
- A provider API key: seal it on your device to the relay's attested key (
sealKey) and send it. Only the attested relay can open it.
You get a key id and a manage token. Keep the token: it changes the key's own daily cap, which applies across every grant on the key, or deletes the key. The console keeps a copy in your browser and offers a backup file.
#2. Publish a grant
A grant is an XE service your account publishes, named xe-key-<label>. Its document says what the key may be used for:
{ "xe_key_grant": 1, "key_id": "<from step 1>", "provider": "openrouter", "models": ["openai/gpt-5-mini", "anthropic/*"], "daily_usd": "20", "caller_daily_usd": "2", "expires": 1798761600, "callers": ["<XE account>", "<XE account>"], "zdr": true}- Budgets.
daily_usdcaps the grant across all callers,caller_daily_usdeach caller. The relay holds each request's worst case against the key's cap and the grant's budgets before it calls the provider, and refuses what would go over. - Callers. XE accounts, at most 24. With none, only your account and its delegates may call it.
- Retention. By default the provider keeps prompts as its terms with you say. On an OpenRouter key,
"zdr": truesends requests only to zero-retention endpoints and the receipts say so. If you have a zero-retention agreement with another provider,"asserted_zdr": truestates it in every receipt; XE doesn't check it.
Your wallet shows every line of the grant before it signs: the provider, the models, both budgets, the end date and each caller. The relay serves a grant only if the key belongs to the account that published it.
#3. Call it
A caller seals each request to the relay on your grant (scheme xe-byok-v1) and sends it as the inline input of a service_request to the grant's service id. The grant's id is in the sealed request, so a request copied onto another grant doesn't open.
From a server that holds its XE account's key, KeyServiceClient does all of it: checks the relay and the grant, seals, requests, opens the answer once its receipt checks out, and settles.
import { KeyServiceClient } from "@xe-network/protocol/byok/client"; const ks = new KeyServiceClient({ node: NODE, relay: RELAY_URL, signer: { seed } });const a = await ks.ask({ grant: GRANT, model: "openai/gpt-5-mini", messages: [{ role: "user", content: "Summarise this proposal in three lines." }], stream: true, onText: (piece) => process.stdout.write(piece),});a.receipt.usage; // tokens in and outa.receipt.grant.remaining_usd; // what is left of today's budgetsigner can also be { publicKey, signHash } for a key in an HSM or a KMS. A request the relay refuses (a model not on the grant, a budget used up) settles with your fee returned. An AbortSignal stops a streamed answer: the relay ends the provider call and answers with what came.
To pay for requests your own way, use the pieces:
import { attestedRelay, sealGrantRequest, openGrantOutput } from "@xe-network/protocol/byok"; const relay = await attestedRelay(RELAY_URL, NODE); // attested on XE, at a build XE approvesconst sealed = sealGrantRequest(relay, GRANT, { model: "<a model your grant allows>", messages: [{ role: "user", content: "Summarise this proposal in three lines." }], max_tokens: 400,});// … send sealed.envelope as the inline input of a service_request to GRANT, then read the result's output …const { content, receipt } = openGrantOutput(output, sealed, relay);openGrantOutput opens nothing until the receipt checks out: signed by the relay's attested key, for this relay, this request and this grant, answered on the owner's key.
#Stopping it
| What you do | What stops |
|---|---|
| Retire the grant (your wallet signs it) | New requests on it, from the next block |
| Remove a caller (publish a new grant version, then retire the old one) | That caller |
| Delete the key with its manage token | Every grant on that key |
| Revoke the key at your provider | Everything, whatever happens on XE |
#Your provider's terms
You stay the provider's customer, and you are responsible for every use of your key. Your callers are your own app's users, staff, agents or delegates. A grant must not resell access to the provider: OpenAI, Anthropic, OpenRouter and Venice all forbid reselling or transferring access to a key. Check your provider's rules for apps you offer to others, and bind your users to terms at least as strict.
#Receipts
The receipt has the same shape as in Private inference, with "tier": "byok", a key section that names the owner's key by its id, never the key itself, and a grant section with the provider's cost and what is left of the day's budget. A grant with zero-retention routing gets grade zero_retention, checked the same way. The console lists every request on a grant, from you and your callers, with its receipt checked. Answers stay sealed to whoever asked.