From zero to your first encrypted write

Get an agent reading and writing encrypted, per-request-paid KV in a few commands — no signup, no dashboard, just a wallet and a key.

Prerequisites

node --version # v20.3 or newer
export AGENTKV_ENDPOINT=https://api.agentx402.ai
export AGENTKV_MAX_SPEND_USD=5 # optional — refuse any op above this

Pick your path

Two ways to hold a namespace. Choose by how your agent's wallet works — then follow that track end to end.

Your own wallet

You hold the private key. The agent authenticates and pays with its own wallet — identity and payment are one key, and there's no account to manage.

  1. Create a wallet.

    Generate a fresh keypair. The private key prints once and is never stored — capture it and export it for the CLI and client.

    agentkv wallet new
    # → { "address": "0x…", "privateKey": "0x…" }  — shown once, not saved
    export AGENTKV_PRIVATE_KEY=0x…

    Store the private key in a secret manager — it's shown once and can't be recovered.

  2. Fund it.

    agentkv fund prints a card-to-USDC onramp URL that sends USDC to the wallet — the command makes no payment itself. Or send USDC to the address directly (e.g. awal send). Then pay per op — a write is $0.005, a read $0.003 — or run agentkv deposit <usd> to pre-pay credits (minimum $1) at a tenth the price.

    agentkv fund # prints a card → USDC onramp URL (makes no payment itself)
    # — or send USDC straight to the wallet address:
    awal send <amount> <address>
    # — or pre-pay credits instead of paying per op:
    agentkv deposit <usd>
  3. Write & read.

    Same store from every surface — pick the one that fits your agent.

    agentkv set session:42 '{"step":3}' # encrypted, paid per write
    agentkv get session:42 # decrypted client-side

Managed wallet with awal

A managed or embedded wallet — like awal — that can't expose a signing key. A client-generated account key owns the namespace, and any wallet can fund it: payer funds, bearer owns. Provision it with a one-time deposit, or skip the deposit entirely and pay per call.

  1. Mint an account key.

    Generate an ak_… bearer token plus a local encryption key. The bearer owns the namespace; the encryption key never leaves your machine.

    agentkv account new
    # → account key:    ak_…
    # → encryption key: 0x…  (local — never sent to the server)
    export AGENTKV_ACCOUNT_KEY=ak_…
    export AGENTKV_ENCRYPTION_KEY=0x…

    Both are unrecoverable — back them up. Lose the encryption key and the data can't be decrypted.

  2. Get awal ready.

    awal is the wallet that pays. npx [email protected] status signs you in; if its wallet is empty, awal address gives you a deposit address — send it USDC. A brand-new awal wallet also needs a little ETH on Base (~$1) for its one-time smart-account deployment, before it can sign anything, so send that too.

    npx [email protected] status # sign in
    # if empty: awal address → send USDC, plus a little ETH (~$1, one-time)
  3. Provision: deposit for prepaid credits.

    A brand-new ak_… has no account yet — deposit once to provision it (minimum $1, from any wallet — payer funds, bearer owns) at a tenth the pay-per-op price. Set AGENTKV_TOPOFF=awal and the client keeps it topped up automatically as credits run low. This is the economical path for repeat use.

    awal x402 pay https://api.agentx402.ai/v1/account/deposit \
      --headers '{"Authorization":"Bearer ak_…"}'
    export AGENTKV_TOPOFF=awal # tops off from awal when credits run low
  4. Or skip the deposit — pay per call.

    No deposit needed: the first set/get against a never-funded account gets a 402 account_not_provisioned challenge (distinct from an ordinary out-of-credit insufficient_credits) instead of running unfunded — a bare awal pays it out of the box, no AgentKV-specific setup required. Our own CLI and client gate that first payment behind an explicit opt-in instead, since auto-funding it is indistinguishable from funding a typo'd key: set AGENTKV_INLINE=awal to pay each op inline, plus AGENTKV_BOOTSTRAP=1 to let it cover that first challenge too. Skip the flag if the account key is read straight from agentkv account new's own ~/.agentkv/account.json (not re-exported) — a file the CLI wrote itself can't be a typo, so it bootstraps automatically.

    export AGENTKV_INLINE=awal    # pay each op inline via x402 — no prepaid credits
    export AGENTKV_BOOTSTRAP=1    # opt in to paying the FIRST-ever op too
    agentkv set session:42 '{"step":3}' # 402s once (account_not_provisioned), awal pays it
  5. Write & read.

    Same store, same surfaces — the client and MCP take the account key and encryption key instead of a private key.

    agentkv set session:42 '{"step":3}' # encrypted, paid per write
    agentkv get session:42 # decrypted client-side

Before you ship

Writes need a human “yes” by default

Every state-changing operation — set, delete, and both deposit ops — is flagged in every manifest (MCP annotations, OpenAPI side-effect flags), so MCP clients prompt before running one and well-behaved agents ask first; reads never do. The API itself never asks — a signed request executes. Running unattended? Pre-approve those tools in your client and rely on the spend cap.

Cap the spend

Set maxSpendUsd in the client (or AGENTKV_MAX_SPEND_USD for the CLI and MCP) and any single operation above it is refused. That caps one call, not the total — to bound a runaway agent, also set maxSessionSpendUsd (AGENTKV_MAX_SESSION_SPEND_USD), which caps cumulative spend for the session. agentkv mcp warns on startup when it is unset.