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.
/ai/think/ai/execute
What it doesAnalyzes a portfolio with live market signals and returns a decision (hold, buy, sell)Builds unsigned swap calldata from AVNU (Starknet DEX aggregator)
Best forAutonomous agents, portfolio advisors, risk-managed botsExecuting the decision — turning a “buy ETH” signal into a real transaction
InputPortfolio balances + risk scoreToken pair + USD amount + wallet address
OutputStructured JSON: action, reason, confidence, risk paramsUnsigned transaction calls ready to sign and submit
CostPer token (same as /chat)$0.002 flat per call

What you can build

  • Autonomous DeFi agent/think runs on a schedule (hourly, daily), if it says “buy” → /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: hold, buy, or sell — with confidence and reasoning. Cost: Per token (same as /chat — the model call is the cost)
curl -X POST https://api.chipipay.com/v1/ai/think \
  -H "Authorization: Bearer sk_prod_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "haiku",
    "portfolio": {
      "USDC": {"balance": 100, "usd": 100},
      "ETH": {"balance": 0.04, "usd": 88},
      "STRK": {"balance": 500, "usd": 17}
    },
    "riskScore": 7,
    "chain": "starknet"
  }'

Request body

FieldTypeDefaultDescription
portfolioobjectRequiredToken balances and USD values. Keys are symbols, values have balance and usd.
riskScorenumber51 (ultra conservative) to 10 (max risk). All thresholds scale with this score.
chainstring"starknet"Chain for yield data in signals.
modelstring"haiku"Any model from Models & Pricing.

Risk parameter overrides

All optional. Defaults scale linearly with riskScore. Override any individual param without affecting others.
FieldTypeDescription
maxSingleTradePercentnumberMax % of portfolio per trade
minStablecoinPercentnumberMin % to keep in stablecoins
maxDrawdownPercentnumberMax acceptable drawdown %
minSignalStrengthnumberMin signal strength to act (0-1)
minExpectedGainPercentnumberMin expected gain to justify a swap

How risk scoring works

Risk parameters scale with riskScore from conservative (1) to aggressive (10):
ParameterriskScore = 1riskScore = 5riskScore = 10
Max single trade14%30%50%
Min stablecoins45%25%5%
Max drawdown8.5%22.5%40%
Min signal strength0.740.500.20
Min expected gain1.11%0.75%0.30%
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.

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)
curl -X POST https://api.chipipay.com/v1/ai/execute \
  -H "Authorization: Bearer sk_prod_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "chain": "starknet",
    "action": "swap",
    "from": "USDC",
    "to": "ETH",
    "amountUsd": 10,
    "walletAddress": "0x0189e2ebb955fc19bf37bd8fc0400de24c123363e7955282bcfb99679a773e61",
    "slippage": 0.005
  }'

Request body

FieldTypeDefaultDescription
chainstringRequired"starknet" (more chains coming soon).
actionstringRequired"swap" (more actions coming soon).
fromstringRequiredSell token symbol: USDC, ETH, STRK, WBTC, USDT, DAI.
tostringRequiredBuy token symbol: USDC, ETH, STRK, WBTC, USDT, DAI.
amountUsdnumberRequiredUSD amount to swap (converted to token amount using live prices).
walletAddressstringRequiredYour Starknet wallet address.
slippagenumber0.005Slippage tolerance. Default: 0.5%. Max: 50%.
/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 decision is buy or sellExecute — get unsigned swap calldata
  3. Sign the calls with your wallet or session key
  4. Submit via Chipi’s gasless paymaster
// 1. Get AI decision
const decision = await fetch("https://api.chipipay.com/v1/ai/think", {
  method: "POST",
  headers: { "Authorization": "Bearer sk_prod_YOUR_KEY", "Content-Type": "application/json" },
  body: JSON.stringify({
    portfolio: { USDC: { balance: 100, usd: 100 }, ETH: { balance: 0.04, usd: 88 } },
    riskScore: 7,
  }),
}).then(r => r.json());

// 2. If actionable, build swap calldata
if (decision.decision.action !== "hold") {
  const swap = await fetch("https://api.chipipay.com/v1/ai/execute", {
    method: "POST",
    headers: { "Authorization": "Bearer sk_prod_YOUR_KEY", "Content-Type": "application/json" },
    body: JSON.stringify({
      chain: "starknet",
      action: "swap",
      from: "USDC",
      to: "ETH",
      amountUsd: 10,
      walletAddress: "0x...",
    }),
  }).then(r => r.json());

  // 3. Sign swap.calls with your wallet and submit
  console.log("Calls to sign:", swap.calls);
}