{"openapi":"3.1.0","info":{"title":"Aki Agent API","version":"1","description":"Pay-per-call APIs for AI agents. Auth: API key with prepaid credits (POST /v1/keys, no signup) or x402 v2 (USDC on Base) per call. Ledger: $0.04 per page, $0.02 per spreadsheet, $0.005 per intents-only call. Failed calls are free. Intent format: /docs/intents.md"},"x-generated-by":"scripts/gen-openapi.ts — do not edit; change src/contract.ts and run pnpm openapi","components":{"schemas":{"Problem":{"type":"object","properties":{"type":{"type":"string"},"title":{"type":"string"},"status":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"code":{"type":"string"},"detail":{"type":"string"}},"required":["type","title","status","code"],"additionalProperties":{}}},"securitySchemes":{"apiKey":{"type":"http","scheme":"bearer","description":"API key from POST /v1/keys (aki_…)."},"x402":{"type":"apiKey","in":"header","name":"PAYMENT-SIGNATURE","description":"x402 v2 payment payload (base64). Requirements come in the PAYMENT-REQUIRED header of the 402."},"stripeSignature":{"type":"apiKey","in":"header","name":"Stripe-Signature"},"opsKey":{"type":"apiKey","in":"header","name":"x-usage-key"}}},"paths":{"/v1/keys":{"post":{"operationId":"POST_v1_keys","summary":"Create an account and API key (no signup). The key is shown once. New keys get a small free trial credit (limited per IP per day).","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"label":{"type":"string","minLength":1,"maxLength":80},"email":{"type":"string","maxLength":200,"format":"email","pattern":"^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"}}}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"key":{"type":"string"},"key_id":{"type":"string"},"account_id":{"type":"string"},"trial_usd":{"type":"string"},"balance_usd":{"type":"string"},"next":{"type":"array","items":{"type":"string"}}},"required":["key","key_id","account_id","trial_usd","balance_usd","next"],"additionalProperties":false}}}},"default":{"description":"RFC 9457. code: invalid_json, invalid_input, rate_limited","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}}},"x-problem-codes":["invalid_json","invalid_input","rate_limited"]}},"/v1/account":{"get":{"operationId":"GET_v1_account","summary":"Balance and the last 20 credit entries.","security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"account_id":{"type":"string"},"balance_usd":{"type":"string"},"entries":{"type":"array","items":{"type":"object","properties":{"kind":{"type":"string"},"amount_usd":{"type":"string"},"source":{"type":"string"},"tool":{"type":["string","null"]},"units":{"anyOf":[{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},{"type":"null"}]},"at":{"type":"string"}},"required":["kind","amount_usd","source","tool","units","at"],"additionalProperties":false}}},"required":["account_id","balance_usd","entries"],"additionalProperties":false}}}},"default":{"description":"RFC 9457. code: unauthorized","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}}},"x-problem-codes":["unauthorized"]}},"/v1/account/rotate":{"post":{"operationId":"POST_v1_account_rotate","summary":"Revoke this key and issue a new one for the same account (balance stays).","security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"key":{"type":"string"},"key_id":{"type":"string"},"revoked":{"type":"string"}},"required":["key","key_id","revoked"],"additionalProperties":false}}}},"default":{"description":"RFC 9457. code: unauthorized","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}}},"x-problem-codes":["unauthorized"]}},"/v1/credits/topup":{"post":{"operationId":"POST_v1_credits_topup","summary":"Get a payment link to hand to a human: card (Stripe) or USDC from a browser wallet. Amounts: 5, 20, 100 USD.","security":[{"apiKey":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"amount_usd":{"anyOf":[{"type":"number","const":5},{"type":"number","const":20},{"type":"number","const":100}]}},"required":["amount_usd"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"topup_id":{"type":"string"},"amount_usd":{"type":"string"},"url":{"type":"string"},"expires_at":{"type":"string"},"methods":{"type":"array","items":{"type":"string","enum":["card","usdc"]}}},"required":["topup_id","amount_usd","url","expires_at","methods"],"additionalProperties":false}}}},"default":{"description":"RFC 9457. code: unauthorized, invalid_json, invalid_input, not_configured","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}}},"x-problem-codes":["unauthorized","invalid_json","invalid_input","not_configured"]}},"/v1/credits/x402":{"post":{"operationId":"POST_v1_credits_x402","summary":"Top up credits with x402 (USDC on Base) — for agents that hold a wallet. Send the API key and a PAYMENT-SIGNATURE for the amount.","security":[{"apiKey":[],"x402":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"amount_usd":{"anyOf":[{"type":"number","const":5},{"type":"number","const":20},{"type":"number","const":100}]}},"required":["amount_usd"]}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","const":true},"credited_usd":{"type":"string"},"balance_usd":{"type":"string"},"transaction":{"type":"string"},"explorer":{"type":["string","null"]}},"required":["ok","credited_usd","balance_usd","transaction","explorer"],"additionalProperties":false}}}},"402":{"description":"Payment required: PAYMENT-REQUIRED header (x402 v2) and how_to_pay in the body","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"default":{"description":"RFC 9457. code: unauthorized, invalid_json, invalid_input, payment_required, invalid_payment, settlement_failed, payment_reused, upstream_unavailable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}}},"x-problem-codes":["unauthorized","invalid_json","invalid_input","payment_required","invalid_payment","settlement_failed","payment_reused","upstream_unavailable"]}},"/v1/pricing":{"get":{"operationId":"GET_v1_pricing","summary":"Prices, top-up amounts and payment methods.","security":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"currency":{"type":"string","const":"USD"},"tools":{"type":"array","items":{"type":"object","properties":{"tool":{"type":"string"},"unit":{"type":"string"},"price_usd":{"type":"string"},"note":{"type":"string"}},"required":["tool","unit","price_usd","note"],"additionalProperties":false}},"topup_usd":{"type":"array","items":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}},"trial_usd":{"type":"string"},"x402":{"type":"object","properties":{"enabled":{"type":"boolean"},"network":{"type":["string","null"]},"asset":{"type":["string","null"]},"pay_to":{"type":["string","null"]}},"required":["enabled","network","asset","pay_to"],"additionalProperties":false},"card":{"type":"object","properties":{"enabled":{"type":"boolean"}},"required":["enabled"],"additionalProperties":false}},"required":["currency","tools","topup_usd","trial_usd","x402","card"],"additionalProperties":false}}}},"default":{"description":"RFC 9457. code: (none)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}}},"x-problem-codes":[]}},"/v1/ledger/convert":{"post":{"operationId":"POST_v1_ledger_convert","summary":"Bank / card / WeChat / Alipay statement (PDF, screenshots, CSV, xlsx) and/or ledger intents → Beancount text you can append to your ledger. Send your main.bean + wearcal.json to reuse your accounts, rules and conventions. Max 60 pages. Nothing is stored.","security":[{"apiKey":[]},{"x402":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"parts":{"maxItems":6,"type":"array","items":{"type":"object","properties":{"mime":{"type":"string","minLength":1,"maxLength":100},"data":{"type":"string","minLength":4,"pattern":"^[A-Za-z0-9+/]+={0,2}$"}},"required":["mime","data"]}},"intents":{"anyOf":[{"type":"string","maxLength":400000},{"maxItems":500,"type":"array","items":{}}]},"ledger":{"type":"object","properties":{"files":{"type":"object","propertyNames":{"type":"string","minLength":1,"maxLength":200},"additionalProperties":{"type":"string"}},"main":{"type":"string","maxLength":200}},"required":["files"]},"classify":{"type":"boolean"},"account":{"type":"string","minLength":1,"maxLength":200},"lang":{"type":"string","enum":["zh","en"]},"currency":{"type":"string","pattern":"^[A-Z][A-Z0-9._-]{0,22}[A-Z0-9]$"},"today":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}}}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"bean":{"type":"string"},"config_json":{"type":["string","null"]},"counts":{"type":"object","properties":{"written":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"pending":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"duplicates":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"balances":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"opened":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}},"required":["written","pending","duplicates","balances","opened"],"additionalProperties":false},"opened":{"type":"array","items":{"type":"string"}},"statement":{"anyOf":[{"type":"object","properties":{"label":{"type":"string"},"account":{"type":["string","null"]},"from":{"type":["string","null"]},"to":{"type":["string","null"]}},"required":["label","account","from","to"],"additionalProperties":{}},{"type":"null"}]},"date_check":{"anyOf":[{"type":"object","properties":{"reliable":{"type":"boolean"}},"required":["reliable"],"additionalProperties":{}},{"type":"null"}]},"rows":{"type":"array","items":{"type":"object","properties":{"date":{"type":"string"},"amount":{"type":"number"},"payee":{"type":"string"},"narration":{"type":"string"},"account":{"type":"string"},"category":{"type":"string"},"flag":{"type":"string"}},"required":["date","amount","payee","narration","account","category","flag"],"additionalProperties":{}}},"issues":{"type":"array","items":{"type":"string"}},"intent_issues":{"type":"array","items":{"type":"object","properties":{"line":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"message":{"type":"string"}},"required":["line","message"],"additionalProperties":{}}},"pages":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}},"required":["bean","config_json","counts","opened","statement","date_check","rows","issues","intent_issues","pages"],"additionalProperties":{}}}}},"402":{"description":"Payment required: PAYMENT-REQUIRED header (x402 v2) and how_to_pay in the body","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"default":{"description":"RFC 9457. code: unauthorized, payment_required, insufficient_credits, invalid_payment, settlement_failed, payment_reused, upstream_unavailable, invalid_json, invalid_input, payload_too_large, unsupported_media_type, statement_unreadable, account_required, ledger_unreadable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}}},"x-problem-codes":["unauthorized","payment_required","insufficient_credits","invalid_payment","settlement_failed","payment_reused","upstream_unavailable","invalid_json","invalid_input","payload_too_large","unsupported_media_type","statement_unreadable","account_required","ledger_unreadable"]}}},"servers":[{"url":"https://api.akifukaku.com"}]}