---
title: "Tempo Keys · Tempo AI Platform docs"
description: "The Tempo Key: an API key with a budget Tempo enforces on chain. Request, pay, update, stop and revoke a key, and set up Codex in one command."
url: "https://gateway.tempo-dev.workers.dev/docs/keys"
---

> Every page of the Tempo AI Platform is Markdown at its URL with .md, or with Accept: text/markdown. The index of every page is https://gateway.tempo-dev.workers.dev/llms.txt, the API https://gateway.tempo-dev.workers.dev/openapi.json and the MCP server https://gateway.tempo-dev.workers.dev/mcp.

# One key with a budget

One key pays for the whole platform: models, services, cards, compute, machines, memory, mail and phone numbers. You set its budget, Tempo enforces it on chain, and you can stop it at any moment.

[Get your Tempo Key](https://gateway.tempo-dev.workers.dev/key.md) · [Codex in one command](#codex)

- **A budget on chain.** Tempo ID signs the key's limit and expiry with your passkey, and Tempo enforces them. No one can make it spend more, us included.
- **MACH from a card.** MACH is Tempo's credit for paying machine merchants: buy it with a card in Tempo ID, and the gateway accepts it directly. It can only be spent at merchants, as on [Mercator](https://mercator.sh).
- **Any stablecoin.** A key pays with whatever its wallet holds: MACH, OUSD, pathUSD or USDC.e, swapping on Tempo's DEX when a service needs another.
- **Stop any time.** Stop ends the key's agents, sandboxes, browsers and hands, then revokes it. What it did not spend comes back.
- **Fees on us.** The gateway sponsors the network fees of opening, topping up and closing the key's channel.
- **MPP underneath.** Under the key every call is an MPP session voucher, so anything paid with a key can be paid without one.

## Use it

A Tempo Key is the standard way in, for every route and the MCP server. Underneath, every call is an MPP payment, which a wallet can make with no key and no account.

### From your cloud agent

Give [your agent](https://gateway.tempo-dev.workers.dev/docs/quickstart.md) a turn. It already has these tools:

> Check how much of my Tempo Key is left with GET /api/keys/me, and stop before you spend more than $2 on this task.

**Cloud agent**

```sh
curl https://gateway.tempo-dev.workers.dev/v1/agents/$AGENT/turns \
  -H "authorization: Bearer $TEMPO_KEY" \
  -H gateway-app:default \
  -H content-type:application/json \
  -H accept:text/event-stream \
  -d '{"prompt":"Check how much of my Tempo Key is left with GET /api/keys/me, and stop before you spend more than $2 on this task."}'
```

### With your Tempo Key

Get a key at /key: choose its budget, term and token, approve it with your passkey, and paste one line. It works like an OpenAI or Anthropic key, for every route and the MCP server.

**Balance**

```sh
curl https://gateway.tempo-dev.workers.dev/api/keys/me -H "authorization: Bearer $TEMPO_KEY"
```

**Top up**

```sh
curl https://gateway.tempo-dev.workers.dev/api/keys/topup \
  -H "authorization: Bearer $TEMPO_KEY" \
  -H content-type:application/json \
  -d '{"amount":1}'
```

**Stop**

```sh
curl https://gateway.tempo-dev.workers.dev/api/keys/stop \
  -H "authorization: Bearer $TEMPO_KEY" \
  -H content-type:application/json \
  -d '{"dryRun":true}'
```

**Codex asks for one**

```sh
curl -fsSL https://gateway.tempo-dev.workers.dev/codex | sh
```

### Over MPP, no account

Every paid route answers 402 with tempo/session challenges, MACH first and OUSD second. Any MPP client opens a channel from its wallet, signs a voucher per request and keeps the channel, and its wallet is its identity.

**tempo request**

```sh
tempo request --mach -X POST \
  -H gateway-app:default \
  --json '{"key":"results/codecs"}' \
  https://gateway.tempo-dev.workers.dev/v1/kv/get
```

**mppx**

```ts
import { Mppx, tempo } from "mppx/client";
import { createSqliteChannelStore } from "mppx/client/node";
import { privateKeyToAccount } from "viem/accounts";

const account = privateKeyToAccount(process.env.PRIVATE_KEY);
const channelStore = createSqliteChannelStore({ namespace: "https://gateway.tempo-dev.workers.dev" });
const mppx = Mppx.create({ methods: [tempo({ account, channelStore, maxDeposit: "1" })], polyfill: false });

const response = await mppx.fetch("https://gateway.tempo-dev.workers.dev/v1/kv/get", {
  body: JSON.stringify({ key: "results/codecs" }),
  headers: { "content-type": "application/json", "gateway-app": "default" },
  method: "POST",
});
```

**The 402**

```sh
curl -i https://gateway.tempo-dev.workers.dev/v1/kv/get \
  -H gateway-app:default \
  -H content-type:application/json \
  -d '{"key":"results/codecs"}'
```

### As MCP tools

Send the key as a bearer to the MCP server and every paid tool is paid from it. capabilities lists every price, and send_feedback reaches support.

`capabilities`, `send_feedback`

**Claude Code**

```sh
claude mcp add --transport http tempo https://gateway.tempo-dev.workers.dev/mcp \
  --header "authorization: Bearer $TEMPO_KEY"
```

**Codex**

```sh
curl -fsSL https://gateway.tempo-dev.workers.dev/codex | sh
```

## How a key works

A Tempo Key is an `sk-tempo-…` API key with a budget. Behind it is a Tempo access key that your wallet authorizes once with your passkey, with a spending limit, an expiry and the calls it may make. The gateway keeps that access key sealed and signs each payment with it; you only hold the token. Tempo enforces the limit on chain, so a leaked token can never spend more than you approved, and revoking the key in Tempo ID stops it.

## Request a key

[/key](https://gateway.tempo-dev.workers.dev/key.md) does it in your browser: choose the budget (1 to 1,000), how many days it lasts and the token it pays the gateway in, approve in Tempo ID, and copy the key, which is shown once. [The Codex installer](#codex) asks Tempo ID for one from the terminal.

Without a browser, ask for a device request: Tempo ID shows its approval on any device with the link it answers, and the request id polls for the key until you approve, decline (403 `access_denied`) or let it expire after 5 minutes (404).

**device request**

```sh
export GW=https://gateway.tempo-dev.workers.dev
REQUEST=$(curl -sS $GW/api/keys/request -H content-type:application/json \
  -d '{"limit":5,"days":30,"token":"mach","device":true}')
echo "Approve in Tempo ID: $(jq -r .device.verificationUriFull <<<"$REQUEST")"
curl -sS $GW/api/keys/complete -H content-type:application/json \
  -d "{\"id\":\"$(jq -r .id <<<"$REQUEST")\"}"
```

Complete answers `{"status":"pending"}` until Tempo ID returns the authorization, then `{"status":"completed","key":"sk-tempo-…"}` with the key's access key, limits and expiry. A device request also signs you in: the same passkey signature signs a message the gateway issues, and a request with `grants` shares items of the wallet with the key in that signature.

- **limit**\
  The most the key may spend, 1 to 1,000 (20 by default).
- **days**\
  How long the key lasts, 1 to 365 (30 by default).
- **token**\
  mach (the default), ousd, usdce or pathusd: the token the key's limit, deposit and top-up are counted in, and the one it pays the gateway from.
- **deposit and topUp**\
  What the key's payment channel opens with and each automatic top-up adds, 1 by default or the limit when it is lower; topUp 0 turns automatic top-ups off.
- **device**\
  true asks Tempo ID for the approval and answers its link, for clients without a browser.

## Limits and tokens

A key may spend its whole limit in each of MACH, OUSD, pathUSD and USDC.e (the stablecoins with 10 bps more, the headroom of a swap), so it pays with whatever your wallet holds. The page that approves it says so before you sign.

- **The gateway**\
  A MACH key pays the gateway's sessions in MACH and every other key in OUSD, buying the OUSD it lacks on the stablecoin DEX from the other stablecoins first.
- **MPP vendors**\
  Search, Code Storage, E2B, Browserbase, Locus, Orthogonal's AgentPhone and any USDC.e service a call reaches are paid by the key itself, swapping on the DEX within 10 bps when the wallet holds too little of their token. A MACH key pays MACH-enabled vendors through the MACH swapper.
- **Network fees**\
  The gateway sponsors them. When it cannot, the key pays its own fee from the stablecoin its wallet holds most of, within its limits.

## How a key pays

The key opens an MPP session channel on Tempo with its deposit (1 MACH unless you set it) and pays each request from it. When a request needs more than the channel holds, the gateway tops it up by the key's top-up, never past its limit. A wallet or a limit that cannot fund the whole top-up funds what it can, as long as that covers the request, and the same goes for the deposit a channel opens with; `usage.topUp` of `/api/keys/me` gives the `amount` the next top-up would add and, when that is less than the key's top-up, why in `blocked`: `limit` or `balance`. Model requests hold what they may cost and get the unused part back, so a channel needs room for one whole hold. A key that has used its limit retires itself and answers 401, which makes Codex's key command ask for a new one. Check a key with:

```sh
curl https://gateway.tempo-dev.workers.dev/api/keys/me -H "authorization: Bearer $(cat ~/.codex/tempo-gateway.key)"
```

### Every paid route

- **A key or a session**\
  Paid routes take a Tempo Key as `Authorization: Bearer` or an MPP session credential. Sessions accept MACH directly and OUSD second; a wallet holding another stablecoin swaps it to OUSD through the stablecoin DEX before it pays.
- **Gateway-App**\
  The routes that keep data (kv, bucket, git, compute, browsers, cards, email, phone and grants) take a `Gateway-App` header naming the app: lowercase letters, digits and `-`, and `default` without it, as for agents and MCP. Your data lives under your wallet and that app, so reuse the name to see it again.
- **Validated first**\
  A request is validated before it is charged, so a malformed one answers 400 and costs nothing.
- **One channel, many requests**\
  Requests of one key share its channel. When another request's payment lands first the gateway signs this one again, and a request that keeps losing answers 429 `payment_failed` with `Retry-After` before anything ran or was charged, so send it again.
- **Problem JSON**\
  Errors are problem JSON with a stable `code`.
- **Expiry**\
  Every value and object expires, at most after 90 days.
- **The same tools**\
  Every route is also an [MCP tool](https://gateway.tempo-dev.workers.dev/docs/mcp.md), and an agent's cells reach them as `tools.mcp__gateway__*`.

## Update a key

`POST /api/keys/update` with the key as its bearer changes its limit, days, token, deposit or top-up and keeps the same `sk-tempo-` token, so its agents, hands, grants and Codex config keep working. Each field defaults to the current one. A key retired for its limit, or expired, may update; a revoked one may not. The answer's `mode` says what Tempo ID signs:

- **reauthorize**\
  The access key is not on Tempo yet, so Tempo ID signs the same access key again with the new settings.
- **limits**\
  Only the limits change: send the answer's updateAccessKey with wallet_updateAccessKey, then poll /api/keys/complete with the id.
- **replace**\
  Anything else (a new expiry or token, or inPlace: false): a new access key under the same token. Completing it closes the old key's channels and answers previous, to revoke in Tempo ID.

/key's "Update an existing key" and the console's "Change budget" run the whole flow for you.

## Stop or revoke a key

`POST /api/keys/stop` ends everything the key runs, its agents' turns, sandboxes, browsers and hands, each as best it can, and then revokes it, so lease refunds are credited before its channels close. It answers what it found and stopped in each step; with `{"dryRun":true}` it lists what would stop and changes nothing. Running it again on a revoked key stops what is left.

`POST /api/keys/revoke` only revokes: it disables the key at once, asks for the close of its channels, and answers its authorization so Tempo ID can revoke the access key too; what the key did not spend comes back to your wallet. Revoking it in Tempo ID reaches the gateway within minutes. Every agent on the key stops at its next payment, and the grants and team members the key set end with it.

## Routes

The key routes are free. Every one takes the key as `Authorization: Bearer`, except `request` and `complete`, which create it.

| Route                   | What it does                                                                                                                                                                            |
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| POST /api/keys/request  | Start a key: limit, days, token (mach, ousd, usdce or pathusd; MACH by default), deposit and topUp in that token; device: true also asks Tempo ID for the approval and returns its link |
| POST /api/keys/complete | Finish it: the request id alone polls the Tempo ID approval, or send the key authorization Tempo ID returned                                                                            |
| GET /api/keys/me        | The key's channel deposit and spend, its remaining limit, the wallet's balance, the next top-up and the grants it set                                                                   |
| PATCH /api/keys/me      | Change the deposit a channel opens with and the automatic top-up (0 turns it off)                                                                                                       |
| POST /api/keys/topup    | Top the channel up by an amount now, or open it with that deposit, which costs the smallest request price, $0.0001                                                                      |
| POST /api/keys/update   | Change the key's limit, days, token, deposit or topUp and keep the same sk-tempo- token; mode says how Tempo ID signs it                                                                |
| POST /api/keys/stop     | End the key's agent turns, sandboxes, browsers and hands, then revoke it; dryRun: true lists what would stop and changes nothing                                                        |
| POST /api/keys/revoke   | Disable the key, close its channels, and answer its authorization for revocation in Tempo ID                                                                                            |
| GET /v1/capabilities    | Every price, limit and currency, with no key                                                                                                                                            |

## Console

[The console](https://gateway.tempo-dev.workers.dev/console.md) signs you in with Tempo ID, without a key, and shows every key of your wallet, your data and your agents. Its routes keep the session in an HttpOnly cookie, and every request that is not a GET must come from the gateway's own origin with `X-Tempo-Console: 1`, so they serve the console page rather than scripts.

| Route                             | What it does                                                                                          |
| --------------------------------- | ----------------------------------------------------------------------------------------------------- |
| POST /api/session/challenge       | A sign-in message that Tempo ID binds to the approval of a key as its challenge, valid for 10 minutes |
| POST /api/session/complete        | Verify the signed message once and set the session cookie, good for 30 days                           |
| GET /api/session                  | The signed-in wallet; DELETE ends the session                                                         |
| DELETE /api/sessions              | End every session of the wallet                                                                       |
| GET /api/console/keys             | The wallet's keys, newest first: status, limits left, channel and agents                              |
| PATCH /api/console/keys/:id       | Rename a key, or change its deposit and top-up                                                        |
| POST /api/console/keys/:id/update | Update a key, as /api/keys/update does for its token                                                  |
| POST /api/console/keys/:id/stop   | Stop a key, as /api/keys/stop does                                                                    |
| POST /api/console/keys/:id/revoke | Revoke a key, as /api/keys/revoke does                                                                |
| GET /api/console/apps             | Every app with values, objects, repositories or agents, with counts                                   |
| GET /api/console/items            | A page of an app's kv values, bucket objects or repositories (app, kind, prefix, cursor, limit)       |
| POST /api/console/visibility      | Make one of them public or private                                                                    |
| GET /api/console/agents           | The agents of the wallet's live keys                                                                  |
| DELETE /api/console/agents/:id    | Delete an agent; ?app= and ?key= choose one when its id is used twice                                 |

## Codex in one command

One command sets Codex up: it asks Tempo ID for an API key, you approve it with your passkey, and Codex pays the gateway per request in MACH. No key to copy.

**Codex setup**

```sh
curl -fsSL https://gateway.tempo-dev.workers.dev/codex | sh
codex
```

### What it does

- **1. Asks for a key**\
  The script opens Tempo ID with a request for an API key that may spend at most 20 in each of MACH, OUSD, pathUSD and USDC.e from your wallet for 30 days, and pays the gateway in MACH. On a machine without a browser, open the link it prints.
- **2. You approve it**\
  The key goes on Tempo with its first payment, and the gateway pays the network fees.
- **3. You run codex**\
  The gateway is now its default provider and MCP server (tempo, with Codex 0.152 or later); your earlier \~/.codex/config.toml is kept as config.toml.before-tempo.

### Options

Pass flags after `sh -s --`, or set the variable after each on the `sh`:

```sh
curl -fsSL https://gateway.tempo-dev.workers.dev/codex | sh -s -- --model @cf/zai-org/glm-5.3 --limit 5 --profile-only
```

```sh
curl -fsSL https://gateway.tempo-dev.workers.dev/codex | TEMPO_GATEWAY_LIMIT=5 sh
```

| Option           | What it does                                                                                                                                        |
| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| --model ID       | Codex's model (default @cf/deepseek-ai/deepseek-v4.1-flash-1017); TEMPO_GATEWAY_MODEL                                                               |
| --limit MACH     | The key's spending limit (default 20); TEMPO_GATEWAY_LIMIT                                                                                          |
| --deposit MACH   | The key's first channel deposit (default 1); TEMPO_GATEWAY_DEPOSIT                                                                                  |
| --top-up MACH    | Each automatic top-up, 0 for none (default 1); TEMPO_GATEWAY_TOPUP                                                                                  |
| --days DAYS      | How long the key lasts (default 30); TEMPO_GATEWAY_DAYS                                                                                             |
| --profile-only   | Leave Codex's default alone and add the profile tempo (codex --profile tempo); TEMPO_GATEWAY_DEFAULT=0                                              |
| --wait SECONDS   | How long to wait for Tempo ID's approval (default 600); TEMPO_GATEWAY_WAIT                                                                          |
| --codex-home DIR | Where Codex keeps its config (default \~/.codex); CODEX_HOME                                                                                        |
| --key KEY        | Use a Tempo Key you already have (sk-tempo-…) instead of asking Tempo ID; one that is used up or expired is updated in Tempo ID and kept; TEMPO_KEY |
| --help           | List the options                                                                                                                                    |

The key lives in `~/.codex/tempo-gateway.key`, and Codex asks `~/.codex/tempo-gateway-key` for it, which asks Tempo ID for a new one once it is revoked or expires.

[<- Memory](https://gateway.tempo-dev.workers.dev/docs/memory.md) · [Pricing ->](https://gateway.tempo-dev.workers.dev/docs/pricing.md)
