---
name: otsukai
description: Pay for HTTP APIs from an Otsukai spending account, within the limits its owner set. Use when a URL answers 402 Payment Required with an "otsukai" option.
---

# Otsukai

You have an Otsukai account: USDG held by a contract on chain 4663, and an agent key that can sign payments.
The key can only pay the payees your owner listed, at most the per-call cap, at most the daily limit.
Anything else is refused by the contract, so a refusal is final: do not retry it with another amount.

## Setup

    mkdir otsukai && cd otsukai && npm i viem
    curl -O https://otsukai.dev/sdk/otsukai.mjs

Environment: OTSUKAI_KEY (the agent key), OTSUKAI_ACCOUNT (the account), optional OTSUKAI_MAX (local ceiling per call in USDG, default 0.05).

## Paying for a call

    import { otsukaiFetch, left } from "./otsukai.mjs";
    const res = await otsukaiFetch("https://otsukai.dev/api/paid/quote?symbol=NVDA&usd=100");
    console.log(res.status, await res.json(), res.payment);

otsukaiFetch behaves like fetch. On a 402 with scheme "otsukai" it checks the price, signs one payment
(EIP-712, domain Otsukai / 1 / 4663 / the account) and retries with an X-PAYMENT header. The server
settles on chain before it answers; res.payment holds the transaction hash and the receipt id.

## Before you spend

- Call left() to read what is left today. Tell your owner when the budget is low instead of guessing.
- Prices are in USDG with 6 decimals: 10000 is $0.01.
- Never print or send OTSUKAI_KEY anywhere.

## Paid endpoints that accept Otsukai

- GET https://otsukai.dev/api/paid/quote?symbol=NVDA&usd=100  ($0.01): executable price of a tokenized stock in USDG, at your size and at $1,000.
- GET https://otsukai.dev/api/paid/holdings?address=0x...  ($0.02): every tokenized stock position of an address, valued in USDG.

Docs: https://otsukai.dev/docs
