---
title: "It's an API · Tempo AI Platform docs"
description: "How a Tempo Key turns a bearer token into payments signed by an access key your wallet limits on chain."
url: "https://gateway.tempo-dev.workers.dev/docs/guides/api"
---

> 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.

# It's an API

A Tempo Key is a bearer token, like an OpenAI or Anthropic key, that works on every route, the MCP server and cloud agents. Behind it is a Tempo access key that your wallet authorized once with your passkey, with a spending limit Tempo enforces on chain. The gateway holds that access key sealed and signs each payment with it, so you hold a token and never key material.

[Get your Tempo Key](https://gateway.tempo-dev.workers.dev/key.md) · [Tempo Keys reference](https://gateway.tempo-dev.workers.dev/docs/keys.md)

## Architecture

```text
once, at /key                         on every request
-------------                         ----------------
the Worker makes a P-256 access key   Authorization: Bearer sk-tempo-...
  |                                     |
Tempo ID: your passkey signs        v
  its limits, scopes and expiry       SHA-256 of the token -> its row,
  |                                     then unseal the access key
the Worker verifies it, seals the       |
  private key (AES-GCM) and keeps       v
  the SHA-256 of a new token          take the route's 402, sign a
  |                                     voucher as the access key and
sk-tempo-... shown once                 serve it as an MPP payment
                                        |
                                      Tempo enforces the limits, the
                                        expiry and the scopes
```

Issuing a key once, and paying with it on every request.

## How a key is issued

1. `POST /api/keys/request` makes a new P-256 access key in the Worker and answers what Tempo ID should authorize: the limits, the calls the key may make and its expiry, from 1 to 365 days. The request waits 30 minutes for the approval.
2. Tempo ID shows the request, and your passkey signs it. Connecting your agent at [/key](https://gateway.tempo-dev.workers.dev/key.md) also signs a sign-in message into the same signature, so one approval issues the key and logs you in to the console.
3. `POST /api/keys/complete` checks the signature, the key's address, the chain, the expiry, the limits and the scopes against the request, seals the access key's private key with AES-GCM under a key only the gateway has, and stores the SHA-256 of a new `sk-tempo-` token. The token is shown once; the gateway cannot show it again.
4. The key goes on Tempo with its first transaction, the opening of its payment channel, whose fee the gateway pays.

## How a request is paid

1. The Worker hashes the bearer token and finds the key's row, which it caches for up to 5 minutes, refreshing it in the background after 30 seconds.
2. It asks the route for the 402 an MPP client would get, signs the voucher in process as the access key on the key's channel with the gateway, and serves the request as an ordinary MPP payment. Prices, holds, refunds, settlement and ownership are exactly an MPP client's: the owner is the key's wallet. [The MPP service](https://gateway.tempo-dev.workers.dev/docs/guides/mpp.md)
3. When the channel lacks room for a call, the key tops it up by its top-up, never past the limit left on chain. A model call starts upstream as soon as its voucher is signed, while the gateway checks it, and is served once the payment is verified.

## What bounds it

- **The limit, on chain**\
  Tempo's account keychain refuses any spend by the access key past its limit or after its expiry, so not even the gateway, which signs with it, can make it spend more. A key may spend its whole limit in each of MACH, OUSD, pathUSD and USDC.e, so it pays with whatever your wallet holds.
- **The scopes, on chain**\
  The access key may only transfer with a memo, swap on Tempo's DEX or the MACH swapper, and open, top up, close and withdraw payment channels. It cannot approve arbitrary contracts.
- **A leaked token**\
  can spend at most what is left of the limit until the key expires or you revoke it, and only through those calls.
- **Fees**\
  The gateway sponsors the key's network fees. When it cannot, the key pays its own from the stablecoin its wallet holds most of, within its limits.

## How a key ends

- **Used up**\
  A key that has spent its limit retires itself and answers 401, which makes Codex's key command ask Tempo ID for a new one.
- **Stopped or revoked**\
  `/api/keys/stop` ends the key's agent turns, sandboxes, browsers and hands, then revokes it; `/api/keys/revoke` only revokes. Either closes its channels, so what it did not spend comes back to your wallet.
- **Revoked in Tempo ID**\
  Every 5 minutes the gateway reads the account keychain for its live keys, so a key revoked in Tempo ID is revoked at the gateway too, with the grants and team members it set.

## Where it works

| Client            | How                                                                                                               |
| ----------------- | ----------------------------------------------------------------------------------------------------------------- |
| OpenAI clients    | Base URL /v1 and the key as the API key: Responses, Chat Completions and Embeddings, on every model               |
| Anthropic clients | The gateway as ANTHROPIC_BASE_URL and the key as ANTHROPIC_AUTH_TOKEN: Messages, so Claude Code runs on any model |
| Codex             | curl -fsSL /codex \| sh makes the gateway Codex's provider and MCP server and asks Tempo ID for the key           |
| Every /v1 route   | Agents, compute, memory, mail, phone, cards and /v1/fetch, with the key as Authorization: Bearer                  |
| MCP               | Authorization: Bearer on POST /mcp pays every tool from the key                                                   |

**Codex**

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

**Claude Code**

```sh
ANTHROPIC_BASE_URL=https://gateway.tempo-dev.workers.dev ANTHROPIC_AUTH_TOKEN=$TEMPO_KEY ANTHROPIC_MODEL=vercel/anthropic/claude-sonnet-5.5 claude
```

**OpenAI SDK**

```ts
new OpenAI({ baseURL: "https://gateway.tempo-dev.workers.dev/v1", apiKey: process.env.TEMPO_KEY })
```

**MCP tools**

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

## Go deeper

- [Tempo Keys](https://gateway.tempo-dev.workers.dev/docs/keys.md): requests, limits, top-ups, updates and every key route.
- [Models](https://gateway.tempo-dev.workers.dev/docs/models.md): the OpenAI and Anthropic routes.
- [Console](https://gateway.tempo-dev.workers.dev/console.md): your keys, their spend and your data.

[<- It connects to your tools](https://gateway.tempo-dev.workers.dev/docs/guides/connectors.md) · [It's an MCP ->](https://gateway.tempo-dev.workers.dev/docs/guides/mcp.md)
