Files

97 lines
4.7 KiB
TypeScript

import { Code } from '@/components/code'
import { HEADLESS } from '@/lib/agents'
import AgentsPage from './view'
// Every sample below was run against the live API on 2026-10-26 (LLM.md,
// "Agents"): the CLI login and token, the free chat call, the MCP server in
// Claude Code, and the decision and harness against Kai.
const KEY = `curl -fsSL https://hanzo.sh | sh
hanzo auth login # no browser here? it prints a link and a code
export HANZO_API_KEY="$(hanzo auth token)"
hanzo account keys create --name agent --type secret # a key for a server`
const CALL = `curl https://api.hanzo.ai/v1/chat/completions \\
-H "Authorization: Bearer $HANZO_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{"model":"zen-free","messages":[{"role":"user","content":"Hello"}]}'`
const MCP = `claude mcp add hanzo --env HANZO_API_KEY=$HANZO_API_KEY \\
-- npx -y --package=@hanzo/mcp@latest hanzo-mcp serve`
const KAI = `curl https://api.hanzo.ai/v1/decisions \\
-H "Authorization: Bearer $HANZO_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{"model":"kai",
"state":{"ticket":"The export button throws a 500 error since this morning."},
"questions":{"team":{"type":"choice",
"instructions":"Which team should handle this ticket?",
"criteria":{"billing":"charges, invoices, refunds",
"tech":"bugs, errors, outages",
"other":"anything else"}}}}'
# {"answers":{"team":{"choice":"tech","confidence":0.951, ...}},
# "usage":{"input_tokens":41,"output_tokens":0}, "latency_ms":121.2}`
const HARNESS = `git clone --depth 1 https://github.com/hanzoai/benchmarks && cd benchmarks/decision
python3 harness/run_kai.py --limit 3 --out $PWD/kai.json.gz \\
--suites app.phishing,app.support_triage,app.email_spam,app.rag_relevance
uv run --with numpy python harness/merge.py --kai $PWD/kai.json.gz --out $PWD/out
cat out/table.md # Kai beside Jev's recorded answers, suite by suite`
const TOPUP = `# Top up your org balance with USDC (headless, no browser):
# 1. Get gateway terms (EIP-712 typed data to sign)
curl https://api.hanzo.ai/v1/billing/crypto/gateway -H "Authorization: Bearer $HANZO_API_KEY"
# -> { x402Version, scheme, payTo, nonce, salt, minCents, maxCents, types, accepts }
# 2. Sign the EIP-712 TransferWithAuthorization with your wallet
# from=your wallet, to=payTo, value=amount in USDC base units (6 decimals)
# validAfter/validBefore from terms, nonce=terms.nonce
# 3. Submit the signed payment
curl https://api.hanzo.ai/v1/billing/crypto/gateway -H "Authorization: Bearer $HANZO_API_KEY" -H "Content-Type: application/json" -d '{"authorization":{"from":"0x...","to":"0x...","value":"1000000","validAfter":"...","validBefore":"...","nonce":"0x..."},"network":"eip155:8453","salt":"0x...","signature":"0x..."}'
# -> { id, status, credited }
# 4. Check status (poll until credited)
curl https://api.hanzo.ai/v1/billing/crypto/gateway/{id} -H "Authorization: Bearer $HANZO_API_KEY"
# 5. Verify balance
curl https://api.hanzo.ai/v1/billing/balance -H "Authorization: Bearer $HANZO_API_KEY"
# Supported: USDC on Base/Ethereum/Solana, USDT on Ethereum. Min 100 cents ($1).
# Testnet: use https://api-test.hanzo.ai and Circle faucet (faucet.circle.com)
# Deposit (no signing): POST /v1/billing/crypto/deposit {"chain":"base","token":"USDC","amount":100}
# -> returns depositAddress; send USDC there, credited when confirmed.`
// Read from the campaign and event operations in api.hanzo.ai's OpenAPI
// document. A draft commits nothing; launching spends the ad budget, so the
// sample stops before it.
const CAMPAIGN = `curl "https://api.hanzo.ai/v1/event/overview?range=7d" -H "Authorization: Bearer $HANZO_API_KEY"
curl https://api.hanzo.ai/v1/campaign \\
-H "Authorization: Bearer $HANZO_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{"name":"Spring launch","audience":"returning-visitors",
"content":["Variant A, written by zen-free","Variant B"],
"budget":50000,
"channels":[{"kind":"paid","platform":"meta"},{"kind":"email"}]}'
# a draft: nothing sent, no budget committed until POST /v1/campaign/{id}/launch
# then: GET /v1/campaign/{id}/metrics?range=7d (CTR, CVR, CAC, ROAS per channel)`
/** The page, with its samples highlighted where it is built (components/code). */
export default function Page() {
return (
<AgentsPage
samples={{
headless: <Code lang="ts" code={HEADLESS} />,
key: <Code lang="bash" code={KEY} />,
call: <Code lang="bash" code={CALL} />,
mcp: <Code lang="bash" code={MCP} />,
kai: <Code lang="bash" code={KAI} />,
harness: <Code lang="bash" code={HARNESS} />,
campaign: <Code lang="bash" code={CAMPAIGN} />,
topup: <Code lang="bash" code={TOPUP} />,
}}
/>
)
}