Docs · Agent frameworks
Copy one block into your framework
16 tools, one per mode, generated from the same contract the API validates against. Each framework names the schema field differently, so each block below is in that framework's own shape. You do not have to translate anything.
- /api/v1/agent-tools/openai.json — Responses API shape, strict mode on.
- /api/v1/agent-tools/anthropic.json — Messages API shape.
Both files carry an endpoints map from tool name to the coach URL that serves it. Calls are paid per call over x402, so the examples wrap the request in an x402 client. Each one shows the gardenpatch_diagnose_growth tool. The others have the same shape.
OpenAI (Responses API)
// npm i @x402/fetch @x402/evm viem openai
import OpenAI from "openai";
import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm";
import { privateKeyToAccount } from "viem/accounts";
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
const fetchWithPay = wrapFetchWithPaymentFromConfig(fetch, {
schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(account) }],
});
// Every mode: const { tools, endpoints } = await (await fetch("https://gardenpatch.xyz/api/v1/agent-tools/openai.json")).json();
const tool = {
"type": "function",
"name": "gardenpatch_diagnose_growth",
"description": "Find the one growth constraint that is actually binding, and rank the levers against it. Paid per call over x402 ($0.18 USDC on Base): POST the arguments as the JSON body to https://gardenpatch.xyz/api/v1/agents/mary/call.",
"parameters": {
"type": "object",
"properties": {
"mode": {
"type": "string",
"enum": [
"diagnose_growth"
]
},
"messages": {
"minItems": 1,
"maxItems": 40,
"type": "array",
"items": {
"type": "object",
"properties": {
"role": {
"type": "string",
"enum": [
"user",
"assistant"
]
},
"content": {
"type": "string"
}
},
"required": [
"role",
"content"
],
"additionalProperties": false
}
},
"context": {
"anyOf": [
{
"type": "object",
"properties": {
"company": {
"anyOf": [
{
"type": "object",
"properties": {
"name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"what_they_sell": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"stage": {
"anyOf": [
{
"type": "string",
"enum": [
"idea",
"pre_revenue",
"early_revenue",
"scaling",
"mature"
]
},
{
"type": "null"
}
]
},
"industry": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"website": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
}
},
"required": [
"name",
"what_they_sell",
"stage",
"industry",
"website"
],
"additionalProperties": false
},
{
"type": "null"
}
]
},
"metrics": {
"anyOf": [
{
"type": "object",
"properties": {
"monthly_revenue_usd": {
"anyOf": [
{
"type": "number",
"minimum": 0
},
{
"type": "null"
}
]
},
"mrr_usd": {
"anyOf": [
{
"type": "number",
"minimum": 0
},
{
"type": "null"
}
]
},
"leads_per_month": {
"anyOf": [
{
"type": "number",
"minimum": 0
},
{
"type": "null"
}
]
},
"close_rate_pct": {
"anyOf": [
{
"type": "number",
"minimum": 0,
"maximum": 100
},
{
"type": "null"
}
]
},
"average_order_value_usd": {
"anyOf": [
{
"type": "number",
"minimum": 0
},
{
"type": "null"
}
]
},
"cac_usd": {
"anyOf": [
{
"type": "number",
"minimum": 0
},
{
"type": "null"
}
]
},
"monthly_churn_pct": {
"anyOf": [
{
"type": "number",
"minimum": 0,
"maximum": 100
},
{
"type": "null"
}
]
},
"traffic_per_month": {
"anyOf": [
{
"type": "number",
"minimum": 0
},
{
"type": "null"
}
]
}
},
"required": [
"monthly_revenue_usd",
"mrr_usd",
"leads_per_month",
"close_rate_pct",
"average_order_value_usd",
"cac_usd",
"monthly_churn_pct",
"traffic_per_month"
],
"additionalProperties": false
},
{
"type": "null"
}
]
},
"offer": {
"anyOf": [
{
"type": "object",
"properties": {
"name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"price_usd": {
"anyOf": [
{
"type": "number",
"minimum": 0
},
{
"type": "null"
}
]
},
"promise": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"guarantee": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
}
},
"required": [
"name",
"price_usd",
"promise",
"guarantee"
],
"additionalProperties": false
},
{
"type": "null"
}
]
},
"audience": {
"anyOf": [
{
"type": "object",
"properties": {
"icp": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"segments": {
"anyOf": [
{
"maxItems": 20,
"type": "array",
"items": {
"type": "string"
}
},
{
"type": "null"
}
]
},
"pain": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
}
},
"required": [
"icp",
"segments",
"pain"
],
"additionalProperties": false
},
{
"type": "null"
}
]
}
},
"required": [
"company",
"metrics",
"offer",
"audience"
],
"additionalProperties": false
},
{
"type": "null"
}
]
}
},
"required": [
"mode",
"messages",
"context"
],
"additionalProperties": false
},
"strict": true
};
const openai = new OpenAI();
const response = await openai.responses.create({
model: "gpt-5",
input: "Where is our growth stuck?",
tools: [tool],
});
// Strict mode sends optional fields as null; the API wants them absent.
const isEmptyObject = (x) => x && typeof x === "object" && !Array.isArray(x) && Object.keys(x).length === 0;
const dropNulls = (v) =>
Array.isArray(v) ? v.map(dropNulls)
: v && typeof v === "object"
? Object.fromEntries(
Object.entries(v)
.filter(([, x]) => x !== null)
.map(([k, x]) => [k, dropNulls(x)])
.filter(([, x]) => !isEmptyObject(x)),
)
: v;
for (const call of response.output.filter((o) => o.type === "function_call")) {
const res = await fetchWithPay("https://gardenpatch.xyz/api/v1/agents/mary/call", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(dropNulls(JSON.parse(call.arguments))),
});
console.log(await res.json());
}
// Chat Completions wants the same tool nested under `function`:
// { type: "function", function: { name, description, parameters, strict } }Anthropic (Messages API)
// npm i @x402/fetch @x402/evm viem @anthropic-ai/sdk
import Anthropic from "@anthropic-ai/sdk";
import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm";
import { privateKeyToAccount } from "viem/accounts";
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
const fetchWithPay = wrapFetchWithPaymentFromConfig(fetch, {
schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(account) }],
});
// Every mode: const { tools, endpoints } = await (await fetch("https://gardenpatch.xyz/api/v1/agent-tools/anthropic.json")).json();
const tool = {
"name": "gardenpatch_diagnose_growth",
"description": "Find the one growth constraint that is actually binding, and rank the levers against it. Paid per call over x402 ($0.18 USDC on Base): POST the arguments as the JSON body to https://gardenpatch.xyz/api/v1/agents/mary/call.",
"input_schema": {
"type": "object",
"properties": {
"mode": {
"type": "string",
"const": "diagnose_growth"
},
"messages": {
"minItems": 1,
"maxItems": 40,
"type": "array",
"items": {
"type": "object",
"properties": {
"role": {
"type": "string",
"enum": [
"user",
"assistant"
]
},
"content": {
"type": "string",
"minLength": 1,
"maxLength": 20000
}
},
"required": [
"role",
"content"
]
}
},
"context": {
"type": "object",
"properties": {
"company": {
"type": "object",
"properties": {
"name": {
"type": "string",
"maxLength": 200
},
"what_they_sell": {
"type": "string",
"maxLength": 2000
},
"stage": {
"type": "string",
"enum": [
"idea",
"pre_revenue",
"early_revenue",
"scaling",
"mature"
]
},
"industry": {
"type": "string",
"maxLength": 200
},
"website": {
"type": "string",
"maxLength": 500
}
}
},
"metrics": {
"type": "object",
"properties": {
"monthly_revenue_usd": {
"type": "number",
"minimum": 0
},
"mrr_usd": {
"type": "number",
"minimum": 0
},
"leads_per_month": {
"type": "number",
"minimum": 0
},
"close_rate_pct": {
"type": "number",
"minimum": 0,
"maximum": 100
},
"average_order_value_usd": {
"type": "number",
"minimum": 0
},
"cac_usd": {
"type": "number",
"minimum": 0
},
"monthly_churn_pct": {
"type": "number",
"minimum": 0,
"maximum": 100
},
"traffic_per_month": {
"type": "number",
"minimum": 0
}
}
},
"offer": {
"type": "object",
"properties": {
"name": {
"type": "string",
"maxLength": 200
},
"price_usd": {
"type": "number",
"minimum": 0
},
"promise": {
"type": "string",
"maxLength": 2000
},
"guarantee": {
"type": "string",
"maxLength": 1000
}
}
},
"audience": {
"type": "object",
"properties": {
"icp": {
"type": "string",
"maxLength": 2000
},
"segments": {
"maxItems": 20,
"type": "array",
"items": {
"type": "string",
"maxLength": 200
}
},
"pain": {
"type": "string",
"maxLength": 2000
}
}
}
}
}
},
"required": [
"mode",
"messages"
]
}
};
const anthropic = new Anthropic();
const message = await anthropic.messages.create({
model: "claude-sonnet-4-5",
max_tokens: 1024,
tools: [tool],
messages: [{ role: "user", content: "Where is our growth stuck?" }],
});
for (const block of message.content.filter((b) => b.type === "tool_use")) {
const res = await fetchWithPay("https://gardenpatch.xyz/api/v1/agents/mary/call", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(block.input),
});
console.log(await res.json());
}Vercel AI SDK
// npm i @x402/fetch @x402/evm viem ai
import { tool, jsonSchema } from "ai";
import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm";
import { privateKeyToAccount } from "viem/accounts";
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
const fetchWithPay = wrapFetchWithPaymentFromConfig(fetch, {
schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(account) }],
});
const generated = {
"description": "Find the one growth constraint that is actually binding, and rank the levers against it. Paid per call over x402 ($0.18 USDC on Base): POST the arguments as the JSON body to https://gardenpatch.xyz/api/v1/agents/mary/call.",
"inputSchema": {
"type": "object",
"properties": {
"mode": {
"type": "string",
"const": "diagnose_growth"
},
"messages": {
"minItems": 1,
"maxItems": 40,
"type": "array",
"items": {
"type": "object",
"properties": {
"role": {
"type": "string",
"enum": [
"user",
"assistant"
]
},
"content": {
"type": "string",
"minLength": 1,
"maxLength": 20000
}
},
"required": [
"role",
"content"
]
}
},
"context": {
"type": "object",
"properties": {
"company": {
"type": "object",
"properties": {
"name": {
"type": "string",
"maxLength": 200
},
"what_they_sell": {
"type": "string",
"maxLength": 2000
},
"stage": {
"type": "string",
"enum": [
"idea",
"pre_revenue",
"early_revenue",
"scaling",
"mature"
]
},
"industry": {
"type": "string",
"maxLength": 200
},
"website": {
"type": "string",
"maxLength": 500
}
}
},
"metrics": {
"type": "object",
"properties": {
"monthly_revenue_usd": {
"type": "number",
"minimum": 0
},
"mrr_usd": {
"type": "number",
"minimum": 0
},
"leads_per_month": {
"type": "number",
"minimum": 0
},
"close_rate_pct": {
"type": "number",
"minimum": 0,
"maximum": 100
},
"average_order_value_usd": {
"type": "number",
"minimum": 0
},
"cac_usd": {
"type": "number",
"minimum": 0
},
"monthly_churn_pct": {
"type": "number",
"minimum": 0,
"maximum": 100
},
"traffic_per_month": {
"type": "number",
"minimum": 0
}
}
},
"offer": {
"type": "object",
"properties": {
"name": {
"type": "string",
"maxLength": 200
},
"price_usd": {
"type": "number",
"minimum": 0
},
"promise": {
"type": "string",
"maxLength": 2000
},
"guarantee": {
"type": "string",
"maxLength": 1000
}
}
},
"audience": {
"type": "object",
"properties": {
"icp": {
"type": "string",
"maxLength": 2000
},
"segments": {
"maxItems": 20,
"type": "array",
"items": {
"type": "string",
"maxLength": 200
}
},
"pain": {
"type": "string",
"maxLength": 2000
}
}
}
}
}
},
"required": [
"mode",
"messages"
]
}
};
export const gardenpatch_diagnose_growth = tool({
description: generated.description,
inputSchema: jsonSchema(generated.inputSchema),
execute: async (input) => {
const res = await fetchWithPay("https://gardenpatch.xyz/api/v1/agents/mary/call", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(input),
});
return res.json();
},
});LangChain JS
// npm i @x402/fetch @x402/evm viem @langchain/core
import { tool } from "@langchain/core/tools";
import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm";
import { privateKeyToAccount } from "viem/accounts";
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
const fetchWithPay = wrapFetchWithPaymentFromConfig(fetch, {
schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(account) }],
});
const generated = {
"name": "gardenpatch_diagnose_growth",
"description": "Find the one growth constraint that is actually binding, and rank the levers against it. Paid per call over x402 ($0.18 USDC on Base): POST the arguments as the JSON body to https://gardenpatch.xyz/api/v1/agents/mary/call.",
"schema": {
"type": "object",
"properties": {
"mode": {
"type": "string",
"const": "diagnose_growth"
},
"messages": {
"minItems": 1,
"maxItems": 40,
"type": "array",
"items": {
"type": "object",
"properties": {
"role": {
"type": "string",
"enum": [
"user",
"assistant"
]
},
"content": {
"type": "string",
"minLength": 1,
"maxLength": 20000
}
},
"required": [
"role",
"content"
]
}
},
"context": {
"type": "object",
"properties": {
"company": {
"type": "object",
"properties": {
"name": {
"type": "string",
"maxLength": 200
},
"what_they_sell": {
"type": "string",
"maxLength": 2000
},
"stage": {
"type": "string",
"enum": [
"idea",
"pre_revenue",
"early_revenue",
"scaling",
"mature"
]
},
"industry": {
"type": "string",
"maxLength": 200
},
"website": {
"type": "string",
"maxLength": 500
}
}
},
"metrics": {
"type": "object",
"properties": {
"monthly_revenue_usd": {
"type": "number",
"minimum": 0
},
"mrr_usd": {
"type": "number",
"minimum": 0
},
"leads_per_month": {
"type": "number",
"minimum": 0
},
"close_rate_pct": {
"type": "number",
"minimum": 0,
"maximum": 100
},
"average_order_value_usd": {
"type": "number",
"minimum": 0
},
"cac_usd": {
"type": "number",
"minimum": 0
},
"monthly_churn_pct": {
"type": "number",
"minimum": 0,
"maximum": 100
},
"traffic_per_month": {
"type": "number",
"minimum": 0
}
}
},
"offer": {
"type": "object",
"properties": {
"name": {
"type": "string",
"maxLength": 200
},
"price_usd": {
"type": "number",
"minimum": 0
},
"promise": {
"type": "string",
"maxLength": 2000
},
"guarantee": {
"type": "string",
"maxLength": 1000
}
}
},
"audience": {
"type": "object",
"properties": {
"icp": {
"type": "string",
"maxLength": 2000
},
"segments": {
"maxItems": 20,
"type": "array",
"items": {
"type": "string",
"maxLength": 200
}
},
"pain": {
"type": "string",
"maxLength": 2000
}
}
}
}
}
},
"required": [
"mode",
"messages"
]
}
};
export const gardenpatch_diagnose_growth = tool(async (input) => {
const res = await fetchWithPay("https://gardenpatch.xyz/api/v1/agents/mary/call", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(input),
});
return JSON.stringify(await res.json());
}, generated);Python (x402 + Anthropic)
# pip install "x402[httpx,evm]" anthropic
import asyncio, os
import anthropic, httpx
from eth_account import Account
from x402 import x402Client
from x402.mechanisms.evm import EthAccountSigner
from x402.mechanisms.evm.exact import register_exact_evm_client
from x402.http.clients.httpx import x402HttpxClient
DEFS = httpx.get("https://gardenpatch.xyz/api/v1/agent-tools/anthropic.json").json()
payer = x402Client()
register_exact_evm_client(payer, EthAccountSigner(Account.from_key(os.environ["PRIVATE_KEY"])))
# The client caps each payment at $1 by default and raises an error (it does
# not pay) for anything above it. Set the cap you want explicitly.
payer.set_spend_controls({"max_amount_per_payment": "$2"})
async def run_tool(name: str, args: dict) -> dict:
async with x402HttpxClient(payer) as client:
res = await client.post(DEFS["endpoints"][name], json=args)
res.raise_for_status()
return res.json()
async def main():
message = anthropic.Anthropic().messages.create(
model="claude-sonnet-4-5",
max_tokens=1024,
tools=DEFS["tools"],
messages=[{"role": "user", "content": "Where is our growth stuck?"}],
)
for block in message.content:
if block.type == "tool_use":
print(await run_tool(block.name, block.input))
asyncio.run(main())Every tool
| Tool | Price | Endpoint |
|---|---|---|
| gardenpatch_diagnose_growth | $0.18 | /api/v1/agents/mary/call |
| gardenpatch_design_offer | $0.25 | /api/v1/agents/mary/call |
| gardenpatch_rewrite_pricing | $0.25 | /api/v1/agents/mary/call |
| gardenpatch_funnel_review | $0.25 | /api/v1/agents/mary/call |
| gardenpatch_write_outbound_sequence | $0.25 | /api/v1/agents/mary/call |
| gardenpatch_audit_function | $0.25 | /api/v1/agents/mary/call |
| gardenpatch_handle_objections | $0.45 | /api/v1/agents/reed/call |
| gardenpatch_position_against_alternatives | $0.45 | /api/v1/agents/iris/call |
| gardenpatch_plan_capacity | $0.45 | /api/v1/agents/oak/call |
| gardenpatch_draft_sop | $0.45 | /api/v1/agents/oak/call |
| gardenpatch_rescue_churn | $0.45 | /api/v1/agents/violet/call |
| gardenpatch_plan_onboarding | $0.25 | /api/v1/agents/violet/call |
| gardenpatch_decide_stack | $0.45 | /api/v1/agents/fern/call |
| gardenpatch_map_automation | $0.25 | /api/v1/agents/fern/call |
| gardenpatch_scope_role | $0.45 | /api/v1/agents/willow/call |
| gardenpatch_map_accountability | $0.25 | /api/v1/agents/willow/call |