Skip to main content
Base URL: https://api.chipipay.com/v1

When to use

/ai/think and /ai/execute work together to power autonomous DeFi agents. Think decides what to do; Execute builds the how.

What you can build

  • Autonomous DeFi agent — /think runs on a schedule (hourly, daily), if it says swap → /execute builds the swap → your agent signs and submits via session key. Fully automated, gasless.
  • Portfolio advisor app — Show users a dashboard with AI recommendations. /think with their real balances + chosen risk level. They review the suggestion and approve manually.
  • Risk-managed vault — A smart contract-backed strategy where /think enforces risk params (max drawdown, min stablecoins) before any rebalance.
  • Telegram trading bot — User sends portfolio snapshot, bot calls /think, replies with the recommendation and a “execute” button that triggers /execute.
  • Yield optimizer — /think includes DeFi yield data from DefiLlama. An agent can compare swap gains vs. yield APY and pick the better move.
/think automatically fetches live signals (RSI, MACD, Fear & Greed, yields) — you don’t need to call /signals first. Just send the portfolio.

POST /ai/think

DeFi portfolio advisor. Analyzes your portfolio with real-time market signals (RSI, MACD, Fear & Greed, yields) and returns a structured JSON decision: swap, supply, withdraw or hold, with confidence and reasoning. Cost: Per token (same as /chat — the model call is the cost)

Request body

Risk parameter overrides

All optional. Defaults scale linearly with riskScore. Override any individual param without affecting others.

How risk scoring works

Risk parameters scale with riskScore from conservative (1) to aggressive (10):
The /think endpoint automatically injects live market data (signals, yields, Fear & Greed) into the AI prompt. You don’t need to fetch signals separately — just send the portfolio and risk score.

Pay per call with x402

An agent can pay a /think call itself, in USDC from its session key, instead of from your org’s credits. Chipi offers this only when your credits are short and you call with a secret key (sk_). The 402 then carries an x402 offer: The price covers the model, the gas Chipi sponsors for your payment and the platform margin, for the worst case of every payable model. Credits stay cheaper (about $0.002 a decision on haiku), because they need no payment transaction. sdk.ai.think pays for you with payWithSession. Without it, a 402 is thrown as before.
Pay from a wallet of the organization that owns the sk_. The API refuses a payment from any other wallet with PAYER_NOT_IN_ORG, because transaction hashes are public and only the payer’s own organization may spend its transfer. On 14.15.0 that refusal comes after the USDC has moved; 14.15.1 checks first.
What the SDK does with a 402 offer:
  1. Checks before paying. It refuses X402_PRICE_ABOVE_MAX, X402_MODEL_NOT_PAYABLE, X402_PAYLOAD_TOO_LARGE or X402_INVALID_MAX_AMOUNT, and nothing is paid. From 14.15.1 it also names the wallet in an X-PAYER header, and refuses with X402_PAYER_NOT_IN_ORG when the offer’s extra.payer says a payment from it would not be accepted.
  2. Pays with a session-signed USDC transfer to the offer’s payTo and waits for the receipt.
  3. Sends X-PAYMENT only if the USDC reached payTo. A transfer the wallet refused comes back succeeded with nothing moved: that throws X402_PAYMENT_FAILED and is never sent. Whitelist transfer in the session and cap USDC.
  4. Hands a paid-but-unserved call back. If the call fails after paying (X402_PAYMENT_PENDING, or an API error on the paid retry), error.details.xPayment holds the payment: pass it as options.xPayment to retry without paying again. A payment is spent only once a call is served.

POST /ai/execute

Build unsigned swap calldata from AVNU (Starknet DEX aggregator). Returns the transaction calls — you sign and submit via session key or wallet. Cost: $0.002 per call (flat, not per token)

Request body

/execute returns unsigned calls. It does NOT submit the transaction. You sign with your wallet or session key and submit via the Chipi paymaster (gasless). Swaps with more than 3% price impact are rejected.

Putting it together: Think + Execute

A typical DeFi agent flow:
  1. Think — send portfolio + risk score, get a decision
  2. If the decision is swap → Execute — get unsigned swap calldata
  3. Sign the calls with your wallet or session key
  4. Submit via Chipi’s gasless paymaster

With the SDK (14.14.0+)

@chipi-stack/backend wraps these endpoints as sdk.ai. It authenticates with your secret key and refuses to run without one, so it is server-only.
API errors throw ChipiApiError with the API’s code and status, for example INSUFFICIENT_BALANCE (402), MODEL_RATE_LIMITED (429), MODEL_UNAVAILABLE (503) or SIGNALS_UNAVAILABLE (503). The full error body is on error.details, which is how you read the x402 offer of a 402.
✅ Verified against the live API on 2026-10-05.