Ready-to-run examples for building payment-enabled AI agents with Proco.
This repo contains practical examples showing how to wire up Proco payments in the most popular agent frameworks — from a single-agent LangChain tool to multi-agent CrewAI workflows with shared budgets.
npm install @proco/sdkYou'll need a Proco API key. Get one at procohq.com/sign-in — or use the sandbox for free testnet USDC.
export PROCO_API_KEY=sk_sandbox_...The simplest possible Proco integration — create a wallet and execute a payment.
// examples/basic/index.ts
import { Proco } from '@proco/sdk'
const proco = new Proco({ apiKey: process.env.PROCO_API_KEY, env: 'sandbox' })
const wallet = await proco.wallets.create({
agentId: 'demo-agent',
policies: { dailyCap: 10_00, currency: 'USDC' }
})
const tx = await proco.payments.create({
wallet: wallet.id,
amount: 1_00,
vendor: 'api.example.com',
memo: 'demo payment'
})
console.log(`✓ Payment ${tx.id} settled in ${tx.settlementMs}ms`)Use proco.fetch() to call any x402-compatible API. Payment is handled automatically when the server responds with HTTP 402.
// examples/x402-fetch/index.ts
import { Proco } from '@proco/sdk'
const proco = new Proco({ apiKey: process.env.PROCO_API_KEY, env: 'sandbox' })
const wallet = await proco.wallets.create({
agentId: 'x402-agent',
policies: { dailyCap: 20_00, currency: 'USDC' }
})
// Proco intercepts the 402, pays, and returns the 200 response
const res = await proco.fetch('https://api.x402-demo.com/data', {
wallet: wallet.id
})
const data = await res.json()
console.log('Response:', data)Adds Proco as a LangChain tool so your agent can pay for APIs as part of a reasoning chain.
// examples/langchain/agent.ts
import { ChatOpenAI } from '@langchain/openai'
import { AgentExecutor, createOpenAIFunctionsAgent } from 'langchain/agents'
import { ProcoPaymentTool } from '@proco/sdk/langchain'
import { Proco } from '@proco/sdk'
import { pull } from 'langchain/hub'
const proco = new Proco({ apiKey: process.env.PROCO_API_KEY, env: 'sandbox' })
const wallet = await proco.wallets.create({
agentId: 'langchain-research-agent',
policies: {
dailyCap: 50_00,
vendors: ['api.perplexity.ai', 'serper.dev'],
currency: 'USDC'
}
})
const tools = [
new ProcoPaymentTool({ wallet: wallet.id, proco }),
]
const llm = new ChatOpenAI({ model: 'gpt-4o', temperature: 0 })
const prompt = await pull('hwchase17/openai-functions-agent')
const agent = await createOpenAIFunctionsAgent({ llm, tools, prompt })
const executor = new AgentExecutor({ agent, tools, verbose: true })
const result = await executor.invoke({
input: 'Research the latest AI agent papers and pay for any paywalled queries'
})
console.log(result.output)# examples/crewai/crew.py
import os, requests
from crewai import Agent, Task, Crew
PROCO_API_KEY = os.environ['PROCO_API_KEY']
PROCO_BASE = 'https://sandbox.api.procohq.com/v1'
def create_wallet(agent_id: str, daily_cap_cents: int) -> str:
res = requests.post(f'{PROCO_BASE}/wallets', json={
'agentId': agent_id,
'policies': { 'dailyCap': daily_cap_cents, 'currency': 'USDC' }
}, headers={ 'Authorization': f'Bearer {PROCO_API_KEY}' })
return res.json()['id']
researcher_wallet = create_wallet('crewai-researcher', 30_00)
researcher = Agent(
role='Market Researcher',
goal='Find data on competitor pricing',
backstory='Expert at sourcing market intelligence',
tools=[]
)
task = Task(
description='Research competitor pricing',
expected_output='Structured pricing comparison',
agent=researcher
)
crew = Crew(agents=[researcher], tasks=[task], verbose=True)
result = crew.kickoff()
print(result)// examples/autogen/settlement.ts
import { Proco } from '@proco/sdk'
const proco = new Proco({ apiKey: process.env.PROCO_API_KEY, env: 'sandbox' })
const orchestratorWallet = await proco.wallets.create({ agentId: 'orchestrator' })
const workerWallet = await proco.wallets.create({ agentId: 'worker-01' })
const invoice = await proco.invoices.create({
from: workerWallet.agentId,
to: orchestratorWallet.agentId,
amount: 5_00,
description: 'Document extraction — 12 files'
})
const settlement = await proco.invoices.settle(invoice.id, {
wallet: orchestratorWallet.id
})
console.log(`✓ Settled: ${settlement.txHash}`)// examples/policy-enforcement/index.ts
import { Proco, PolicyViolationError } from '@proco/sdk'
const proco = new Proco({ apiKey: process.env.PROCO_API_KEY, env: 'sandbox' })
const wallet = await proco.wallets.create({
agentId: 'policy-demo-agent',
policies: { dailyCap: 5_00, perTx: 2_00 }
})
try {
await proco.payments.create({
wallet: wallet.id,
amount: 10_00,
vendor: 'expensive-api.com'
})
} catch (e) {
if (e instanceof PolicyViolationError) {
console.log('Payment blocked:', e.reason)
// → 'Payment blocked: exceeds daily cap ($5.00)'
}
}git clone https://github.com/procohq/examples
cd examples
npm install
export PROCO_API_KEY=sk_sandbox_...
npx ts-node examples/basic/index.ts
npx ts-node examples/langchain/agent.ts
npx ts-node examples/x402-fetch/index.ts- Go to procohq.com/sandbox
- Create a sandbox account — no credit card required
- Your wallet starts with 1,000 testnet USDC
Have a framework integration we're missing? Open a PR.
- Fork this repo
- Add your example under
examples/<framework-name>/ - Include a
README.mdexplaining prerequisites and how to run - Open a pull request
@proco/sdk— the core SDK- Proco Sandbox — free testnet environment
- x402 Protocol — the HTTP payment standard
- procohq.com
MIT · Built by Proco